History

Merge tag 'v7.0-rc5' into driver-core-next

We need the driver-core fixes in here as well to build on top of.

Danilo Krummrich committed 7 months ago

Commit 14cf4062 parents 9aa64d2 c369299332 files · +3559 −1498Browse files

Unified · Split

332 files
  1. .mailmap +1 −0
  2. Documentation/dev-tools/kunit/run_wrapper.rst +2 −0
  3. Documentation/devicetree/bindings/mtd/st,spear600-smi.yaml +19 −7
  4. Documentation/devicetree/bindings/regulator/regulator.yaml +2 −2
  5. Documentation/driver-api/driver-model/binding.rst +48 −0
  6. Documentation/netlink/specs/net_shaper.yaml +6 −6
  7. MAINTAINERS +8 −6
  8. Makefile +1 −1
  9. arch/arm/configs/multi_v7_defconfig +0 −1
  10. arch/arm64/boot/dts/renesas/r8a78000.dtsi +8 −8
  11. arch/arm64/boot/dts/renesas/r9a09g057.dtsi +0 −30
  12. arch/arm64/boot/dts/renesas/r9a09g077.dtsi +2 −2
  13. arch/arm64/boot/dts/renesas/r9a09g087.dtsi +2 −2
  14. arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi +1 −1
  15. arch/arm64/boot/dts/renesas/rzt2h-n2h-evk-common.dtsi +1 −0
  16. arch/arm64/boot/dts/renesas/rzv2-evk-cn15-sd.dtso +1 −0
  17. arch/arm64/crypto/aes-neonbs-glue.c +23 −14
  18. arch/arm64/kernel/pi/patch-scs.c +8 −0
  19. arch/arm64/kernel/rsi.c +2 −1
  20. arch/loongarch/Kconfig +3 −0
  21. arch/loongarch/include/asm/cmpxchg.h +5 −0
  22. arch/loongarch/include/asm/uaccess.h +12 −2
  23. arch/loongarch/kernel/inst.c +25 −6
  24. arch/loongarch/kvm/vm.c +2 −2
  25. arch/loongarch/net/bpf_jit.c +11 −0
  26. arch/parisc/kernel/cache.c +2 −2
  27. arch/riscv/boot/dts/microchip/mpfs.dtsi +2 −0
  28. arch/sh/drivers/platform_early.c +0 −4
  29. arch/x86/entry/vdso/common/vclock_gettime.c +1 −1
  30. arch/x86/events/core.c +5 −2
  31. arch/x86/events/intel/core.c +21 −10
  32. arch/x86/events/intel/ds.c +7 −4
  33. arch/x86/hyperv/hv_crash.c +52 −48
  34. arch/x86/kernel/apic/x2apic_uv_x.c +16 −2
  35. arch/x86/kernel/cpu/mce/amd.c +11 −6
  36. arch/x86/kernel/cpu/mshyperv.c +3 −2
  37. drivers/acpi/acpi_processor.c +8 −7
  38. drivers/acpi/acpica/acpredef.h +1 −1
  39. drivers/acpi/bus.c +0 −3
  40. drivers/ata/libata-core.c +3 −0
  41. drivers/ata/libata-scsi.c +1 −1
  42. drivers/base/bus.c +42 −1
  43. drivers/base/core.c +2 −0
  44. drivers/base/dd.c +60 −0
  45. drivers/base/platform.c +5 −32
  46. drivers/base/power/runtime.c +1 −0
  47. drivers/bluetooth/btqca.c +2 −0
  48. drivers/bus/simple-pm-bus.c +2 −2
  49. drivers/cache/ax45mp_cache.c +2 −2
  50. drivers/cache/starfive_starlink_cache.c +2 −2
  51. drivers/clk/imx/clk-scu.c +1 −2
  52. drivers/crypto/ccp/sev-dev.c +1 −3
  53. drivers/crypto/padlock-sha.c +7 −0
  54. drivers/firewire/net.c +3 −2
  55. drivers/firmware/arm_ffa/driver.c +4 −4
  56. drivers/firmware/arm_scmi/notify.c +2 −2
  57. drivers/firmware/arm_scmi/protocols.h +2 −2
  58. drivers/firmware/arm_scpi.c +3 −2
  59. drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +4 −0
  60. drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 −1
  61. drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +2 −0
  62. drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +14 −7
  63. drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c +2 −2
  64. drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c +6 −3
  65. drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c +2 −1
  66. drivers/gpu/drm/amd/amdgpu/mmhub_v3_0.c +2 −1
  67. drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_1.c +2 −1
  68. drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_2.c +2 −1
  69. drivers/gpu/drm/amd/amdgpu/mmhub_v4_1_0.c +2 −1
  70. drivers/gpu/drm/amd/amdgpu/mmhub_v4_2_0.c +2 −1
  71. drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 −3
  72. drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c +3 −3
  73. drivers/gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c +4 −4
  74. drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c +3 −0
  75. drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c +3 −1
  76. drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c +1 −1
  77. drivers/gpu/drm/drm_file.c +4 −1
  78. drivers/gpu/drm/drm_mode_config.c +6 −3
  79. drivers/gpu/drm/drm_pagemap_util.c +5 −9
  80. drivers/gpu/drm/i915/display/intel_display_power_well.c +1 −1
  81. drivers/gpu/drm/i915/display/intel_display_types.h +1 −0
  82. drivers/gpu/drm/i915/display/intel_dmc.c +1 −2
  83. drivers/gpu/drm/i915/display/intel_psr.c +5 −2
  84. drivers/gpu/drm/i915/gt/intel_engine_cs.c +2 −1
  85. drivers/gpu/drm/imagination/pvr_device.c +0 −17
  86. drivers/gpu/drm/imagination/pvr_power.c +39 −12
  87. drivers/gpu/drm/radeon/si_dpm.c +3 −1
  88. drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +57 −36
  89. drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +2 −1
  90. drivers/gpu/drm/xe/xe_ggtt.c +4 −6
  91. drivers/gpu/drm/xe/xe_ggtt_types.h +4 −1
  92. drivers/gpu/drm/xe/xe_gt_ccs_mode.c +2 −0
  93. drivers/gpu/drm/xe/xe_guc.c +27 −5
  94. drivers/gpu/drm/xe/xe_guc.h +1 −0
  95. drivers/gpu/drm/xe/xe_guc_ct.c +1 −0
  96. drivers/gpu/drm/xe/xe_guc_submit.c +61 −25
  97. drivers/gpu/drm/xe/xe_lrc.c +2 −2
  98. drivers/gpu/drm/xe/xe_oa.c +5 −2
  99. drivers/gpu/drm/xe/xe_pt.c +29 −9
  100. drivers/hid/bpf/hid_bpf_dispatch.c +2 −0
  101. drivers/hid/hid-appletb-kbd.c +3 −2
  102. drivers/hid/hid-asus.c +3 −0
  103. drivers/hid/hid-core.c +4 −3
  104. drivers/hid/hid-ids.h +1 −2
  105. drivers/hid/hid-input.c +11 −7
  106. drivers/hid/hid-logitech-hidpp.c +5 −1
  107. drivers/hid/hid-multitouch.c +7 −0
  108. drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-hid.c +1 −0
  109. drivers/hid/intel-thc-hid/intel-quickspi/quickspi-hid.c +1 −0
  110. drivers/hid/wacom_wac.c +10 −0
  111. drivers/hv/mshv_regions.c +4 −2
  112. drivers/hv/mshv_root.h +2 −3
  113. drivers/hv/mshv_root_main.c +22 −71
  114. drivers/hv/mshv_synic.c +173 −15
  115. drivers/hwmon/axi-fan-control.c +1 −1
  116. drivers/hwmon/max6639.c +5 −5
  117. drivers/hwmon/pmbus/hac300s.c +2 −0
  118. drivers/hwmon/pmbus/ina233.c +2 −0
  119. drivers/hwmon/pmbus/isl68137.c +5 −2
  120. drivers/hwmon/pmbus/mp2869.c +21 −14
  121. drivers/hwmon/pmbus/mp2975.c +2 −0
  122. drivers/i2c/busses/Kconfig +2 −0
  123. drivers/i2c/busses/i2c-cp2615.c +3 −0
  124. drivers/i2c/busses/i2c-fsi.c +1 −0
  125. drivers/i2c/busses/i2c-pxa.c +16 −1
  126. drivers/i2c/busses/i2c-tegra.c +4 −1
  127. drivers/iommu/amd/iommu.c +14 −1
  128. drivers/iommu/intel/dmar.c +1 −2
  129. drivers/iommu/intel/svm.c +8 −4
  130. drivers/iommu/iommu-sva.c +6 −6
  131. drivers/iommu/iommu.c +5 −1
  132. drivers/irqchip/irq-riscv-rpmi-sysmsi.c +1 −0
  133. drivers/mmc/host/sdhci-pci-gli.c +9 −0
  134. drivers/mmc/host/sdhci.c +8 −1
  135. drivers/mtd/nand/raw/brcmnand/brcmnand.c +2 −4
  136. drivers/mtd/nand/raw/cadence-nand-controller.c +1 −1
  137. drivers/mtd/nand/raw/nand_base.c +12 −2
  138. drivers/mtd/nand/raw/pl35x-nand-controller.c +3 −0
  139. drivers/mtd/parsers/redboot.c +3 −3
  140. drivers/mtd/spi-nor/core.c +7 −7
  141. drivers/net/bonding/bond_debugfs.c +11 −5
  142. drivers/net/bonding/bond_main.c +5 −3
  143. drivers/net/dsa/bcm_sf2.c +6 −2
  144. drivers/net/ethernet/airoha/airoha_eth.c +0 −1
  145. drivers/net/ethernet/broadcom/bnxt/bnxt.c +2 −0
  146. drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 −1
  147. drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c +1 −1
  148. drivers/net/ethernet/broadcom/tg3.c +11 −0
  149. drivers/net/ethernet/cadence/macb_main.c +22 −4
  150. drivers/net/ethernet/cadence/macb_ptp.c +3 −1
  151. drivers/net/ethernet/intel/iavf/iavf_main.c +6 −3
  152. drivers/net/ethernet/intel/igc/igc.h +2 −0
  153. drivers/net/ethernet/intel/igc/igc_main.c +9 −5
  154. drivers/net/ethernet/intel/igc/igc_ptp.c +33 −0
  155. drivers/net/ethernet/intel/libie/fwlog.c +36 −13
  156. drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +2 −2
  157. drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h +1 −0
  158. drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c +22 −28
  159. drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c +9 −14
  160. drivers/net/ethernet/microsoft/mana/hw_channel.c +3 −3
  161. drivers/net/ethernet/ti/icssg/icssg_common.c +5 −0
  162. drivers/net/netdevsim/netdev.c +4 −1
  163. drivers/net/usb/aqc111.c +6 −6
  164. drivers/net/usb/cdc_ncm.c +6 −4
  165. drivers/net/wireless/ath/ath9k/channel.c +2 −4
  166. drivers/net/wireless/mediatek/mt76/scan.c +1 −3
  167. drivers/net/wireless/ti/wlcore/tx.c +1 −1
  168. drivers/net/wireless/virtual/mac80211_hwsim.c +1 −2
  169. drivers/nfc/nxp-nci/i2c.c +2 −2
  170. drivers/nvdimm/bus.c +3 −2
  171. drivers/pci/endpoint/functions/pci-epf-test.c +5 −0
  172. drivers/pci/pwrctrl/core.c +41 −13
  173. drivers/pmdomain/bcm/bcm2835-power.c +4 −8
  174. drivers/pmdomain/mediatek/mtk-pm-domains.c +1 −1
  175. drivers/resctrl/mpam_devices.c +2 −0
  176. drivers/resctrl/test_mpam_devices.c +15 −7
  177. drivers/reset/reset-rzg2l-usbphy-ctrl.c +3 −0
  178. drivers/slimbus/qcom-ngd-ctrl.c +2 −4
  179. drivers/soc/fsl/qbman/qman.c +22 −2
  180. drivers/soc/fsl/qe/qmc.c +2 −2
  181. drivers/soc/microchip/mpfs-sys-controller.c +9 −4
  182. drivers/soc/rockchip/grf.c +1 −0
  183. drivers/spi/spi-amlogic-spifc-a4.c +7 −39
  184. drivers/spi/spi-amlogic-spisg.c +4 −8
  185. drivers/spi/spi-axiado.c +11 −20
  186. drivers/spi/spi-geni-qcom.c +7 −6
  187. drivers/spi/spi.c +12 −13
  188. drivers/tee/tee_shm.c +0 −27
  189. drivers/tty/serial/8250/8250.h +25 −0
  190. drivers/tty/serial/8250/8250_dma.c +15 −0
  191. drivers/tty/serial/8250/8250_dw.c +235 −61
  192. drivers/tty/serial/8250/8250_pci.c +17 −0
  193. drivers/tty/serial/8250/8250_port.c +45 −30
  194. drivers/tty/serial/serial_core.c +4 −1
  195. drivers/tty/serial/uartlite.c +1 −0
  196. drivers/tty/vt/vt.c +8 −0
  197. fs/binfmt_elf_fdpic.c +6 −0
  198. fs/btrfs/backref.c +28 −0
  199. fs/btrfs/block-group.c +36 −0
  200. fs/btrfs/compression.c +8 −3
  201. fs/btrfs/disk-io.c +17 −3
  202. fs/btrfs/extent-tree.c +93 −5
  203. fs/btrfs/file-item.c +7 −0
  204. fs/btrfs/free-space-tree.c +8 −1
  205. fs/btrfs/inode.c +20 −5
  206. fs/btrfs/ioctl.c +9 −3
  207. fs/btrfs/lzo.c +2 −2
  208. fs/btrfs/qgroup.c +8 −0
  209. fs/btrfs/raid56.c +10 −2
  210. fs/btrfs/relocation.c +32 −7
  211. fs/btrfs/tree-checker.c +18 −1
  212. fs/btrfs/tree-log.c +27 −0
  213. fs/btrfs/volumes.c +18 −9
  214. fs/btrfs/zoned.c +11 −2
  215. fs/btrfs/zstd.c +1 −1
  216. fs/nfsd/export.c +54 −9
  217. fs/nfsd/export.h +5 −2
  218. fs/nfsd/nfs4xdr.c +7 −2
  219. fs/nfsd/nfsctl.c +19 −3
  220. fs/nfsd/state.h +12 −5
  221. fs/smb/client/cifsglob.h +6 −0
  222. fs/smb/client/connect.c +4 −0
  223. fs/smb/client/file.c +0 −1
  224. fs/smb/client/inode.c +6 −15
  225. fs/smb/client/smb1transport.c +1 −1
  226. fs/smb/client/smb2ops.c +4 −16
  227. fs/smb/server/mgmt/tree_connect.c +6 −3
  228. fs/smb/server/smb2pdu.c +12 −5
  229. fs/tests/exec_kunit.c +0 −3
  230. include/hyperv/hvgdk_mini.h +2 −1
  231. include/linux/auxvec.h +1 −1
  232. include/linux/build_bug.h +3 −1
  233. include/linux/console_struct.h +1 −0
  234. include/linux/device.h +54 −0
  235. include/linux/device/bus.h +4 −0
  236. include/linux/etherdevice.h +2 −1
  237. include/linux/hid.h +1 −0
  238. include/linux/if_ether.h +2 −1
  239. include/linux/io-pgtable.h +8 −2
  240. include/linux/io_uring_types.h +3 −0
  241. include/linux/local_lock_internal.h +1 −1
  242. include/linux/netdevice.h +5 −4
  243. include/linux/platform_device.h +0 −5
  244. include/linux/serial_8250.h +1 −0
  245. include/net/ip_tunnels.h +23 −7
  246. include/net/mac80211.h +3 −1
  247. include/net/netfilter/nf_tables.h +2 −4
  248. include/net/sch_generic.h +33 −0
  249. include/net/udp_tunnel.h +1 −1
  250. include/trace/events/task.h +5 −2
  251. io_uring/kbuf.c +11 −3
  252. io_uring/poll.c +7 −2
  253. kernel/bpf/btf.c +20 −4
  254. kernel/bpf/core.c +35 −8
  255. kernel/bpf/verifier.c +25 −8
  256. kernel/crash_dump_dm_crypt.c +2 −2
  257. kernel/events/core.c +8 −11
  258. kernel/sched/idle.c +21 −9
  259. kernel/trace/ftrace.c +2 −2
  260. kernel/trace/ring_buffer.c +1 −1
  261. kernel/trace/trace.c +27 −9
  262. lib/bootconfig.c +2 −1
  263. lib/crypto/Makefile +3 −0
  264. mm/huge_memory.c +2 −1
  265. mm/rmap.c +17 −4
  266. net/atm/lec.c +47 −25
  267. net/atm/lec.h +1 −1
  268. net/batman-adv/bat_iv_ogm.c +3 −0
  269. net/bluetooth/hci_conn.c +2 −2
  270. net/bluetooth/hci_sync.c +1 −1
  271. net/bluetooth/hidp/core.c +14 −2
  272. net/bluetooth/l2cap_core.c +31 −20
  273. net/bluetooth/mgmt.c +2 −5
  274. net/bluetooth/smp.c +1 −1
  275. net/bridge/br_cfm.c +2 −2
  276. net/ethernet/eth.c +3 −6
  277. net/ipv4/icmp.c +3 −1
  278. net/ipv4/ip_gre.c +2 −1
  279. net/ipv6/exthdrs.c +4 −0
  280. net/ipv6/seg6_hmac.c +2 −0
  281. net/mac80211/cfg.c +6 −6
  282. net/mac80211/chan.c +4 −2
  283. net/mac80211/debugfs.c +5 −9
  284. net/mac80211/mesh.c +3 −0
  285. net/mac80211/sta_info.c +5 −2
  286. net/mac80211/tdls.c +1 −1
  287. net/mac80211/tx.c +3 −1
  288. net/mac802154/iface.c +3 −1
  289. net/mpls/af_mpls.c +1 −0
  290. net/mptcp/pm_kernel.c +1 −1
  291. net/netfilter/nf_bpf_link.c +1 −1
  292. net/netfilter/nf_conntrack_h323_asn1.c +4 −0
  293. net/netfilter/nf_conntrack_netlink.c +26 −2
  294. net/netfilter/nf_conntrack_proto_sctp.c +2 −1
  295. net/netfilter/nf_conntrack_sip.c +5 −1
  296. net/netfilter/nf_flow_table_ip.c +1 −0
  297. net/netfilter/nf_tables_api.c +7 −19
  298. net/netfilter/nfnetlink_osf.c +13 −0
  299. net/netfilter/nft_ct.c +4 −0
  300. net/netfilter/nft_dynset.c +9 −1
  301. net/netfilter/nft_set_rbtree.c +10 −61
  302. net/netfilter/xt_CT.c +4 −0
  303. net/netfilter/xt_time.c +2 −2
  304. net/phonet/af_phonet.c +4 −1
  305. net/rose/af_rose.c +5 −0
  306. net/sched/sch_generic.c +0 −27
  307. net/sched/sch_ingress.c +8 −6
  308. net/sched/sch_teql.c +2 −5
  309. net/shaper/shaper.c +93 −65
  310. net/shaper/shaper_nl_gen.c +6 −6
  311. net/shaper/shaper_nl_gen.h +5 −0
  312. net/smc/af_smc.c +17 −6
  313. net/smc/smc.h +5 −0
  314. net/smc/smc_close.c +1 −1
  315. net/sunrpc/cache.c +21 −5
  316. net/unix/af_unix.c +2 −0
  317. net/unix/af_unix.h +1 −0
  318. net/unix/garbage.c +51 −28
  319. net/wireless/pmsr.c +1 −0
  320. scripts/livepatch/klp-build +4 −5
  321. sound/soc/samsung/i2s.c +3 −3
  322. tools/bootconfig/main.c +5 −2
  323. tools/objtool/check.c +2 −3
  324. tools/objtool/elf.c +3 −20
  325. tools/objtool/klp-diff.c +2 −1
  326. tools/testing/selftests/bpf/Makefile +1 −1
  327. tools/testing/selftests/bpf/progs/exceptions_fail.c +53 −3
  328. tools/testing/selftests/bpf/progs/verifier_bounds.c +94 −0
  329. tools/testing/selftests/bpf/progs/verifier_bswap.c +22 −0
  330. tools/testing/selftests/bpf/progs/verifier_linked_scalars.c +108 −0
  331. tools/testing/selftests/bpf/progs/verifier_sdiv.c +58 −0
  332. tools/testing/selftests/hid/progs/hid_bpf_helpers.h +12 −0
.mailmap+1−0
@@ -327,6 +327,7 @@ Henrik Rydberg <rydberg@bitmath.org> · 326 unmodified lines
327327 Herbert Xu <herbert@gondor.apana.org.au>
328328 Huacai Chen <chenhuacai@kernel.org> <chenhc@lemote.com>
329329 Huacai Chen <chenhuacai@kernel.org> <chenhuacai@loongson.cn>
330+Ignat Korchagin <ignat@linux.win> <ignat@cloudflare.com>
330331 Ike Panhc <ikepanhc@gmail.com> <ike.pan@canonical.com>
331332 J. Bruce Fields <bfields@fieldses.org> <bfields@redhat.com>
332333 J. Bruce Fields <bfields@fieldses.org> <bfields@citi.umich.edu>
Documentation/dev-tools/kunit/run_wrapper.rst+2−0
@@ -336,6 +336,8 @@ command line arguments: · 335 unmodified lines
336336 - ``--list_tests_attr``: If set, lists all tests that will be run and all of their
337337 attributes.
338338
339+- ``--list_suites``: If set, lists all suites that will be run.
340+
339341 Command-line completion
340342 ==============================
341343
Documentation/devicetree/bindings/mtd/st,spear600-smi.yaml+19−7
@@ -19,9 +19,6 @@ description: · 18 unmodified lines
1919 Flash sub nodes describe the memory range and optional per-flash
2020 properties.
2121
22−allOf:
23− - $ref: mtd.yaml#
24−
2522 properties:
2623 compatible:
2724 const: st,spear600-smi
@@ -42,14 +39,29 @@ properties: · 14 unmodified lines
4239 $ref: /schemas/types.yaml#/definitions/uint32
4340 description: Functional clock rate of the SMI controller in Hz.
4441
45− st,smi-fast-mode:
46− type: boolean
47− description: Indicates that the attached flash supports fast read mode.
42+patternProperties:
43+ "^flash@.*$":
44+ $ref: /schemas/mtd/mtd.yaml#
45+
46+ properties:
47+ reg:
48+ maxItems: 1
49+
50+ st,smi-fast-mode:
51+ type: boolean
52+ description: Indicates that the attached flash supports fast read mode.
53+
54+ unevaluatedProperties: false
55+
56+ required:
57+ - reg
4858
4959 required:
5060 - compatible
5161 - reg
5262 - clock-rate
63+ - "#address-cells"
64+ - "#size-cells"
5365
5466 unevaluatedProperties: false
5567
@@ -64,7 +76,7 @@ examples: · 8 unmodified lines
6476 interrupts = <12>;
6577 clock-rate = <50000000>; /* 50 MHz */
6678
67− flash@f8000000 {
79+ flash@fc000000 {
6880 reg = <0xfc000000 0x1000>;
6981 st,smi-fast-mode;
7082 };
Documentation/devicetree/bindings/regulator/regulator.yaml+2−2
@@ -168,7 +168,7 @@ properties: · 167 unmodified lines
168168 offset from voltage set to regulator.
169169
170170 regulator-uv-protection-microvolt:
171− description: Set over under voltage protection limit. This is a limit where
171+ description: Set under voltage protection limit. This is a limit where
172172 hardware performs emergency shutdown. Zero can be passed to disable
173173 protection and value '1' indicates that protection should be enabled but
174174 limit setting can be omitted. Limit is given as microvolt offset from
@@ -182,7 +182,7 @@ properties: · 7 unmodified lines
182182 is given as microvolt offset from voltage set to regulator.
183183
184184 regulator-uv-warn-microvolt:
185− description: Set over under voltage warning limit. This is a limit where
185+ description: Set under voltage warning limit. This is a limit where
186186 hardware is assumed still to be functional but approaching limit where
187187 it gets damaged. Recovery actions should be initiated. Zero can be passed
188188 to disable detection and value '1' indicates that detection should
Documentation/driver-api/driver-model/binding.rst+48−0
@@ -99,3 +99,51 @@ of the driver is decremented. All symlinks between the two are removed. · 98 unmodified lines
9999 When a driver is removed, the list of devices that it supports is
100100 iterated over, and the driver's remove callback is called for each
101101 one. The device is removed from that list and the symlinks removed.
102+
103+
104+Driver Override
105+~~~~~~~~~~~~~~~
106+
107+Userspace may override the standard matching by writing a driver name to
108+a device's ``driver_override`` sysfs attribute. When set, only a driver
109+whose name matches the override will be considered during binding. This
110+bypasses all bus-specific matching (OF, ACPI, ID tables, etc.).
111+
112+The override may be cleared by writing an empty string, which returns
113+the device to standard matching rules. Writing to ``driver_override``
114+does not automatically unbind the device from its current driver or
115+make any attempt to load the specified driver.
116+
117+Buses opt into this mechanism by setting the ``driver_override`` flag in
118+their ``struct bus_type``::
119+
120+ const struct bus_type example_bus_type = {
121+ ...
122+ .driver_override = true,
123+ };
124+
125+When the flag is set, the driver core automatically creates the
126+``driver_override`` sysfs attribute for every device on that bus.
127+
128+The bus's ``match()`` callback should check the override before performing
129+its own matching, using ``device_match_driver_override()``::
130+
131+ static int example_match(struct device *dev, const struct device_driver *drv)
132+ {
133+ int ret;
134+
135+ ret = device_match_driver_override(dev, drv);
136+ if (ret >= 0)
137+ return ret;
138+
139+ /* Fall through to bus-specific matching... */
140+ }
141+
142+``device_match_driver_override()`` returns > 0 if the override matches
143+the given driver, 0 if the override is set but does not match, or < 0 if
144+no override is set at all.
145+
146+Additional helpers are available:
147+
148+- ``device_set_driver_override()`` - set or clear the override from kernel code.
149+- ``device_has_driver_override()`` - check whether an override is set.
Documentation/netlink/specs/net_shaper.yaml+6−6
@@ -247,8 +247,8 @@ operations: · 246 unmodified lines
247247 flags: [admin-perm]
248248
249249 do:
250− pre: net-shaper-nl-pre-doit
251− post: net-shaper-nl-post-doit
250+ pre: net-shaper-nl-pre-doit-write
251+ post: net-shaper-nl-post-doit-write
252252 request:
253253 attributes:
254254 - ifindex
@@ -278,8 +278,8 @@ operations: · 23 unmodified lines
278278 flags: [admin-perm]
279279
280280 do:
281− pre: net-shaper-nl-pre-doit
282− post: net-shaper-nl-post-doit
281+ pre: net-shaper-nl-pre-doit-write
282+ post: net-shaper-nl-post-doit-write
283283 request:
284284 attributes: *ns-binding
285285
@@ -309,8 +309,8 @@ operations: · 23 unmodified lines
309309 flags: [admin-perm]
310310
311311 do:
312− pre: net-shaper-nl-pre-doit
313− post: net-shaper-nl-post-doit
312+ pre: net-shaper-nl-pre-doit-write
313+ post: net-shaper-nl-post-doit-write
314314 request:
315315 attributes:
316316 - ifindex
MAINTAINERS+8−6
@@ -4022,7 +4022,7 @@ F: drivers/hwmon/asus_wmi_sensors.c · 4021 unmodified lines
40224022 ASYMMETRIC KEYS
40234023 M: David Howells <dhowells@redhat.com>
40244024 M: Lukas Wunner <lukas@wunner.de>
4025−M: Ignat Korchagin <ignat@cloudflare.com>
4025+M: Ignat Korchagin <ignat@linux.win>
40264026 L: keyrings@vger.kernel.org
40274027 L: linux-crypto@vger.kernel.org
40284028 S: Maintained
@@ -4035,7 +4035,7 @@ F: include/linux/verification.h · 6 unmodified lines
40354035
40364036 ASYMMETRIC KEYS - ECDSA
40374037 M: Lukas Wunner <lukas@wunner.de>
4038−M: Ignat Korchagin <ignat@cloudflare.com>
4038+M: Ignat Korchagin <ignat@linux.win>
40394039 R: Stefan Berger <stefanb@linux.ibm.com>
40404040 L: linux-crypto@vger.kernel.org
40414041 S: Maintained
@@ -4045,14 +4045,14 @@ F: include/crypto/ecc* · 3 unmodified lines
40454045
40464046 ASYMMETRIC KEYS - GOST
40474047 M: Lukas Wunner <lukas@wunner.de>
4048−M: Ignat Korchagin <ignat@cloudflare.com>
4048+M: Ignat Korchagin <ignat@linux.win>
40494049 L: linux-crypto@vger.kernel.org
40504050 S: Odd fixes
40514051 F: crypto/ecrdsa*
40524052
40534053 ASYMMETRIC KEYS - RSA
40544054 M: Lukas Wunner <lukas@wunner.de>
4055−M: Ignat Korchagin <ignat@cloudflare.com>
4055+M: Ignat Korchagin <ignat@linux.win>
40564056 L: linux-crypto@vger.kernel.org
40574057 S: Maintained
40584058 F: crypto/rsa*
@@ -7998,7 +7998,9 @@ F: Documentation/devicetree/bindings/display/himax,hx8357.yaml · 3939 unmodified lines
79987998 F: drivers/gpu/drm/tiny/hx8357d.c
79997999
80008000 DRM DRIVER FOR HYPERV SYNTHETIC VIDEO DEVICE
8001−M: Deepak Rawat <drawat.floss@gmail.com>
8001+M: Dexuan Cui <decui@microsoft.com>
8002+M: Long Li <longli@microsoft.com>
8003+M: Saurabh Sengar <ssengar@linux.microsoft.com>
80028004 L: linux-hyperv@vger.kernel.org
80038005 L: dri-devel@lists.freedesktop.org
80048006 S: Maintained
@@ -24900,9 +24902,9 @@ F: drivers/clk/spear/ · 16895 unmodified lines
2490024902 F: drivers/pinctrl/spear/
2490124903
2490224904 SPI NOR SUBSYSTEM
24903−M: Tudor Ambarus <tudor.ambarus@linaro.org>
2490424905 M: Pratyush Yadav <pratyush@kernel.org>
2490524906 M: Michael Walle <mwalle@kernel.org>
24907+R: Takahiro Kuwano <takahiro.kuwano@infineon.com>
2490624908 L: linux-mtd@lists.infradead.org
2490724909 S: Maintained
2490824910 W: http://www.linux-mtd.infradead.org/
Makefile+1−1
@@ -2,7 +2,7 @@ · 1 unmodified line
22 VERSION = 7
33 PATCHLEVEL = 0
44 SUBLEVEL = 0
5−EXTRAVERSION = -rc4
5+EXTRAVERSION = -rc5
66 NAME = Baby Opossum Posse
77
88 # *DOCUMENTATION*
arch/arm/configs/multi_v7_defconfig+0−1
@@ -279,7 +279,6 @@ CONFIG_TI_CPSW_SWITCHDEV=y · 278 unmodified lines
279279 CONFIG_TI_CPTS=y
280280 CONFIG_TI_KEYSTONE_NETCP=y
281281 CONFIG_TI_KEYSTONE_NETCP_ETHSS=y
282−CONFIG_TI_PRUSS=m
283282 CONFIG_TI_PRUETH=m
284283 CONFIG_XILINX_EMACLITE=y
285284 CONFIG_SFP=m
arch/arm64/boot/dts/renesas/r8a78000.dtsi+8−8
@@ -698,7 +698,7 @@ · 697 unmodified lines
698698 compatible = "renesas,scif-r8a78000",
699699 "renesas,rcar-gen5-scif", "renesas,scif";
700700 reg = <0 0xc0700000 0 0x40>;
701− interrupts = <GIC_SPI 4074 IRQ_TYPE_LEVEL_HIGH>;
701+ interrupts = <GIC_ESPI 10 IRQ_TYPE_LEVEL_HIGH>;
702702 clocks = <&dummy_clk_sgasyncd16>, <&dummy_clk_sgasyncd16>, <&scif_clk>;
703703 clock-names = "fck", "brg_int", "scif_clk";
704704 status = "disabled";
@@ -708,7 +708,7 @@ · 3 unmodified lines
708708 compatible = "renesas,scif-r8a78000",
709709 "renesas,rcar-gen5-scif", "renesas,scif";
710710 reg = <0 0xc0704000 0 0x40>;
711− interrupts = <GIC_SPI 4075 IRQ_TYPE_LEVEL_HIGH>;
711+ interrupts = <GIC_ESPI 11 IRQ_TYPE_LEVEL_HIGH>;
712712 clocks = <&dummy_clk_sgasyncd16>, <&dummy_clk_sgasyncd16>, <&scif_clk>;
713713 clock-names = "fck", "brg_int", "scif_clk";
714714 status = "disabled";
@@ -718,7 +718,7 @@ · 3 unmodified lines
718718 compatible = "renesas,scif-r8a78000",
719719 "renesas,rcar-gen5-scif", "renesas,scif";
720720 reg = <0 0xc0708000 0 0x40>;
721− interrupts = <GIC_SPI 4076 IRQ_TYPE_LEVEL_HIGH>;
721+ interrupts = <GIC_ESPI 12 IRQ_TYPE_LEVEL_HIGH>;
722722 clocks = <&dummy_clk_sgasyncd16>, <&dummy_clk_sgasyncd16>, <&scif_clk>;
723723 clock-names = "fck", "brg_int", "scif_clk";
724724 status = "disabled";
@@ -728,7 +728,7 @@ · 3 unmodified lines
728728 compatible = "renesas,scif-r8a78000",
729729 "renesas,rcar-gen5-scif", "renesas,scif";
730730 reg = <0 0xc070c000 0 0x40>;
731− interrupts = <GIC_SPI 4077 IRQ_TYPE_LEVEL_HIGH>;
731+ interrupts = <GIC_ESPI 13 IRQ_TYPE_LEVEL_HIGH>;
732732 clocks = <&dummy_clk_sgasyncd16>, <&dummy_clk_sgasyncd16>, <&scif_clk>;
733733 clock-names = "fck", "brg_int", "scif_clk";
734734 status = "disabled";
@@ -738,7 +738,7 @@ · 3 unmodified lines
738738 compatible = "renesas,hscif-r8a78000",
739739 "renesas,rcar-gen5-hscif", "renesas,hscif";
740740 reg = <0 0xc0710000 0 0x60>;
741− interrupts = <GIC_SPI 4078 IRQ_TYPE_LEVEL_HIGH>;
741+ interrupts = <GIC_ESPI 14 IRQ_TYPE_LEVEL_HIGH>;
742742 clocks = <&dummy_clk_sgasyncd4>, <&dummy_clk_sgasyncd4>, <&scif_clk>;
743743 clock-names = "fck", "brg_int", "scif_clk";
744744 status = "disabled";
@@ -748,7 +748,7 @@ · 3 unmodified lines
748748 compatible = "renesas,hscif-r8a78000",
749749 "renesas,rcar-gen5-hscif", "renesas,hscif";
750750 reg = <0 0xc0714000 0 0x60>;
751− interrupts = <GIC_SPI 4079 IRQ_TYPE_LEVEL_HIGH>;
751+ interrupts = <GIC_ESPI 15 IRQ_TYPE_LEVEL_HIGH>;
752752 clocks = <&dummy_clk_sgasyncd4>, <&dummy_clk_sgasyncd4>, <&scif_clk>;
753753 clock-names = "fck", "brg_int", "scif_clk";
754754 status = "disabled";
@@ -758,7 +758,7 @@ · 3 unmodified lines
758758 compatible = "renesas,hscif-r8a78000",
759759 "renesas,rcar-gen5-hscif", "renesas,hscif";
760760 reg = <0 0xc0718000 0 0x60>;
761− interrupts = <GIC_SPI 4080 IRQ_TYPE_LEVEL_HIGH>;
761+ interrupts = <GIC_ESPI 16 IRQ_TYPE_LEVEL_HIGH>;
762762 clocks = <&dummy_clk_sgasyncd4>, <&dummy_clk_sgasyncd4>, <&scif_clk>;
763763 clock-names = "fck", "brg_int", "scif_clk";
764764 status = "disabled";
@@ -768,7 +768,7 @@ · 3 unmodified lines
768768 compatible = "renesas,hscif-r8a78000",
769769 "renesas,rcar-gen5-hscif", "renesas,hscif";
770770 reg = <0 0xc071c000 0 0x60>;
771− interrupts = <GIC_SPI 4081 IRQ_TYPE_LEVEL_HIGH>;
771+ interrupts = <GIC_ESPI 17 IRQ_TYPE_LEVEL_HIGH>;
772772 clocks = <&dummy_clk_sgasyncd4>, <&dummy_clk_sgasyncd4>, <&scif_clk>;
773773 clock-names = "fck", "brg_int", "scif_clk";
774774 status = "disabled";
arch/arm64/boot/dts/renesas/r9a09g057.dtsi+0−30
@@ -581,16 +581,6 @@ · 580 unmodified lines
581581 status = "disabled";
582582 };
583583
584− wdt0: watchdog@11c00400 {
585− compatible = "renesas,r9a09g057-wdt";
586− reg = <0 0x11c00400 0 0x400>;
587− clocks = <&cpg CPG_MOD 0x4b>, <&cpg CPG_MOD 0x4c>;
588− clock-names = "pclk", "oscclk";
589− resets = <&cpg 0x75>;
590− power-domains = <&cpg>;
591− status = "disabled";
592− };
593−
594584 wdt1: watchdog@14400000 {
595585 compatible = "renesas,r9a09g057-wdt";
596586 reg = <0 0x14400000 0 0x400>;
@@ -601,26 +591,6 @@ · 4 unmodified lines
601591 status = "disabled";
602592 };
603593
604− wdt2: watchdog@13000000 {
605− compatible = "renesas,r9a09g057-wdt";
606− reg = <0 0x13000000 0 0x400>;
607− clocks = <&cpg CPG_MOD 0x4f>, <&cpg CPG_MOD 0x50>;
608− clock-names = "pclk", "oscclk";
609− resets = <&cpg 0x77>;
610− power-domains = <&cpg>;
611− status = "disabled";
612− };
613−
614− wdt3: watchdog@13000400 {
615− compatible = "renesas,r9a09g057-wdt";
616− reg = <0 0x13000400 0 0x400>;
617− clocks = <&cpg CPG_MOD 0x51>, <&cpg CPG_MOD 0x52>;
618− clock-names = "pclk", "oscclk";
619− resets = <&cpg 0x78>;
620− power-domains = <&cpg>;
621− status = "disabled";
622− };
623−
624594 rtc: rtc@11c00800 {
625595 compatible = "renesas,r9a09g057-rtca3", "renesas,rz-rtca3";
626596 reg = <0 0x11c00800 0 0x400>;
arch/arm64/boot/dts/renesas/r9a09g077.dtsi+2−2
@@ -974,8 +974,8 @@ · 973 unmodified lines
974974
975975 cpg: clock-controller@80280000 {
976976 compatible = "renesas,r9a09g077-cpg-mssr";
977− reg = <0 0x80280000 0 0x1000>,
978− <0 0x81280000 0 0x9000>;
977+ reg = <0 0x80280000 0 0x10000>,
978+ <0 0x81280000 0 0x10000>;
979979 clocks = <&extal_clk>;
980980 clock-names = "extal";
981981 #clock-cells = <2>;
arch/arm64/boot/dts/renesas/r9a09g087.dtsi+2−2
@@ -977,8 +977,8 @@ · 976 unmodified lines
977977
978978 cpg: clock-controller@80280000 {
979979 compatible = "renesas,r9a09g087-cpg-mssr";
980− reg = <0 0x80280000 0 0x1000>,
981− <0 0x81280000 0 0x9000>;
980+ reg = <0 0x80280000 0 0x10000>,
981+ <0 0x81280000 0 0x10000>;
982982 clocks = <&extal_clk>;
983983 clock-names = "extal";
984984 #clock-cells = <2>;
arch/arm64/boot/dts/renesas/rzg3s-smarc-som.dtsi+1−1
@@ -162,7 +162,7 @@ · 161 unmodified lines
162162 <100000000>;
163163 renesas,settings = [
164164 80 00 11 19 4c 42 dc 2f 06 7d 20 1a 5f 1e f2 27
165− 00 40 00 00 00 00 00 00 06 0c 19 02 3f f0 90 86
165+ 00 40 00 00 00 00 00 00 06 0c 19 02 3b f0 90 86
166166 a0 80 30 30 9c
167167 ];
168168 };
arch/arm64/boot/dts/renesas/rzt2h-n2h-evk-common.dtsi+1−0
@@ -53,6 +53,7 @@ · 52 unmodified lines
5353 regulator-max-microvolt = <3300000>;
5454 gpios-states = <0>;
5555 states = <3300000 0>, <1800000 1>;
56+ regulator-ramp-delay = <60>;
5657 };
5758 #endif
5859
arch/arm64/boot/dts/renesas/rzv2-evk-cn15-sd.dtso+1−0
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 regulator-max-microvolt = <3300000>;
2626 gpios-states = <0>;
2727 states = <3300000 0>, <1800000 1>;
28+ regulator-ramp-delay = <60>;
2829 };
2930 };
3031
arch/arm64/crypto/aes-neonbs-glue.c+23−14
@@ -76,19 +76,24 @@ static int aesbs_setkey(struct crypto_skcipher *tfm, const u8 *in_key, · 75 unmodified lines
7676 unsigned int key_len)
7777 {
7878 struct aesbs_ctx *ctx = crypto_skcipher_ctx(tfm);
79− struct crypto_aes_ctx rk;
79+ struct crypto_aes_ctx *rk;
8080 int err;
8181
82− err = aes_expandkey(&rk, in_key, key_len);
82+ rk = kmalloc(sizeof(*rk), GFP_KERNEL);
83+ if (!rk)
84+ return -ENOMEM;
85+
86+ err = aes_expandkey(rk, in_key, key_len);
8387 if (err)
84− return err;
88+ goto out;
8589
8690 ctx->rounds = 6 + key_len / 4;
8791
8892 scoped_ksimd()
89− aesbs_convert_key(ctx->rk, rk.key_enc, ctx->rounds);
90−
91− return 0;
93+ aesbs_convert_key(ctx->rk, rk->key_enc, ctx->rounds);
94+out:
95+ kfree_sensitive(rk);
96+ return err;
9297 }
9398
9499 static int __ecb_crypt(struct skcipher_request *req,
@@ -133,22 +138,26 @@ static int aesbs_cbc_ctr_setkey(struct crypto_skcipher *tfm, const u8 *in_key, · 38 unmodified lines
133138 unsigned int key_len)
134139 {
135140 struct aesbs_cbc_ctr_ctx *ctx = crypto_skcipher_ctx(tfm);
136− struct crypto_aes_ctx rk;
141+ struct crypto_aes_ctx *rk;
137142 int err;
138143
139− err = aes_expandkey(&rk, in_key, key_len);
144+ rk = kmalloc(sizeof(*rk), GFP_KERNEL);
145+ if (!rk)
146+ return -ENOMEM;
147+
148+ err = aes_expandkey(rk, in_key, key_len);
140149 if (err)
141− return err;
150+ goto out;
142151
143152 ctx->key.rounds = 6 + key_len / 4;
144153
145− memcpy(ctx->enc, rk.key_enc, sizeof(ctx->enc));
154+ memcpy(ctx->enc, rk->key_enc, sizeof(ctx->enc));
146155
147156 scoped_ksimd()
148− aesbs_convert_key(ctx->key.rk, rk.key_enc, ctx->key.rounds);
149− memzero_explicit(&rk, sizeof(rk));
150−
151− return 0;
157+ aesbs_convert_key(ctx->key.rk, rk->key_enc, ctx->key.rounds);
158+out:
159+ kfree_sensitive(rk);
160+ return err;
152161 }
153162
154163 static int cbc_encrypt(struct skcipher_request *req)
arch/arm64/kernel/pi/patch-scs.c+8−0
@@ -192,6 +192,14 @@ static int scs_handle_fde_frame(const struct eh_frame *frame, · 191 unmodified lines
192192 size -= 2;
193193 break;
194194
195+ case DW_CFA_advance_loc4:
196+ loc += *opcode++ * code_alignment_factor;
197+ loc += (*opcode++ << 8) * code_alignment_factor;
198+ loc += (*opcode++ << 16) * code_alignment_factor;
199+ loc += (*opcode++ << 24) * code_alignment_factor;
200+ size -= 4;
201+ break;
202+
195203 case DW_CFA_def_cfa:
196204 case DW_CFA_offset_extended:
197205 size = skip_xleb128(&opcode, size);
arch/arm64/kernel/rsi.c+2−1
@@ -12,6 +12,7 @@ · 11 unmodified lines
1212
1313 #include <asm/io.h>
1414 #include <asm/mem_encrypt.h>
15+#include <asm/pgtable.h>
1516 #include <asm/rsi.h>
1617
1718 static struct realm_config config;
@@ -146,7 +147,7 @@ void __init arm64_rsi_init(void) · 128 unmodified lines
146147 return;
147148 if (WARN_ON(rsi_get_realm_config(&config)))
148149 return;
149− prot_ns_shared = BIT(config.ipa_bits - 1);
150+ prot_ns_shared = __phys_to_pte_val(BIT(config.ipa_bits - 1));
150151
151152 if (arm64_ioremap_prot_hook_register(realm_ioremap_hook))
152153 return;
arch/loongarch/Kconfig+3−0
@@ -304,6 +304,9 @@ config AS_HAS_LBT_EXTENSION · 303 unmodified lines
304304 config AS_HAS_LVZ_EXTENSION
305305 def_bool $(as-instr,hvcl 0)
306306
307+config AS_HAS_SCQ_EXTENSION
308+ def_bool $(as-instr,sc.q \$t0$(comma)\$t1$(comma)\$t2)
309+
307310 config CC_HAS_ANNOTATE_TABLEJUMP
308311 def_bool $(cc-option,-mannotate-tablejump)
309312
arch/loongarch/include/asm/cmpxchg.h+5−0
@@ -238,6 +238,8 @@ __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, unsigned int · 237 unmodified lines
238238 arch_cmpxchg((ptr), (o), (n)); \
239239 })
240240
241+#ifdef CONFIG_AS_HAS_SCQ_EXTENSION
242+
241243 union __u128_halves {
242244 u128 full;
243245 struct {
@@ -290,6 +292,9 @@ union __u128_halves { · 46 unmodified lines
290292 BUILD_BUG_ON(sizeof(*(ptr)) != 16); \
291293 __arch_cmpxchg128(ptr, o, n, ""); \
292294 })
295+
296+#endif /* CONFIG_AS_HAS_SCQ_EXTENSION */
297+
293298 #else
294299 #include <asm-generic/cmpxchg-local.h>
295300 #define arch_cmpxchg64_local(ptr, o, n) __generic_cmpxchg64_local((ptr), (o), (n))
arch/loongarch/include/asm/uaccess.h+12−2
@@ -253,8 +253,13 @@ do { \ · 252 unmodified lines
253253 \
254254 __get_kernel_common(*((type *)(dst)), sizeof(type), \
255255 (__force type *)(src)); \
256− if (unlikely(__gu_err)) \
256+ if (unlikely(__gu_err)) { \
257+ pr_info("%s: memory access failed, ecode 0x%x\n", \
258+ __func__, read_csr_excode()); \
259+ pr_info("%s: the caller is %pS\n", \
260+ __func__, __builtin_return_address(0)); \
257261 goto err_label; \
262+ } \
258263 } while (0)
259264
260265 #define __put_kernel_nofault(dst, src, type, err_label) \
@@ -264,8 +269,13 @@ do { \ · 3 unmodified lines
264269 \
265270 __pu_val = *(__force type *)(src); \
266271 __put_kernel_common(((type *)(dst)), sizeof(type)); \
267− if (unlikely(__pu_err)) \
272+ if (unlikely(__pu_err)) { \
273+ pr_info("%s: memory access failed, ecode 0x%x\n", \
274+ __func__, read_csr_excode()); \
275+ pr_info("%s: the caller is %pS\n", \
276+ __func__, __builtin_return_address(0)); \
268277 goto err_label; \
278+ } \
269279 } while (0)
270280
271281 extern unsigned long __copy_user(void *to, const void *from, __kernel_size_t n);
arch/loongarch/kernel/inst.c+25−6
@@ -246,32 +246,51 @@ static int text_copy_cb(void *data) · 245 unmodified lines
246246
247247 if (smp_processor_id() == copy->cpu) {
248248 ret = copy_to_kernel_nofault(copy->dst, copy->src, copy->len);
249− if (ret)
249+ if (ret) {
250250 pr_err("%s: operation failed\n", __func__);
251+ return ret;
252+ }
251253 }
252254
253255 flush_icache_range((unsigned long)copy->dst, (unsigned long)copy->dst + copy->len);
254256
255− return ret;
257+ return 0;
256258 }
257259
258260 int larch_insn_text_copy(void *dst, void *src, size_t len)
259261 {
260262 int ret = 0;
263+ int err = 0;
261264 size_t start, end;
262265 struct insn_copy copy = {
263266 .dst = dst,
264267 .src = src,
265268 .len = len,
266− .cpu = smp_processor_id(),
269+ .cpu = raw_smp_processor_id(),
267270 };
268271
272+ /*
273+ * Ensure copy.cpu won't be hot removed before stop_machine.
274+ * If it is removed nobody will really update the text.
275+ */
276+ lockdep_assert_cpus_held();
277+
269278 start = round_down((size_t)dst, PAGE_SIZE);
270279 end = round_up((size_t)dst + len, PAGE_SIZE);
271280
272− set_memory_rw(start, (end - start) / PAGE_SIZE);
273− ret = stop_machine(text_copy_cb, &copy, cpu_online_mask);
274− set_memory_rox(start, (end - start) / PAGE_SIZE);
281+ err = set_memory_rw(start, (end - start) / PAGE_SIZE);
282+ if (err) {
283+ pr_info("%s: set_memory_rw() failed\n", __func__);
284+ return err;
285+ }
286+
287+ ret = stop_machine_cpuslocked(text_copy_cb, &copy, cpu_online_mask);
288+
289+ err = set_memory_rox(start, (end - start) / PAGE_SIZE);
290+ if (err) {
291+ pr_info("%s: set_memory_rox() failed\n", __func__);
292+ return err;
293+ }
275294
276295 return ret;
277296 }
arch/loongarch/kvm/vm.c+2−2
@@ -49,8 +49,8 @@ static void kvm_vm_init_features(struct kvm *kvm) · 48 unmodified lines
4949 kvm->arch.kvm_features |= BIT(KVM_LOONGARCH_VM_FEAT_PMU);
5050
5151 /* Enable all PV features by default */
52− kvm->arch.pv_features = BIT(KVM_FEATURE_IPI);
53− kvm->arch.kvm_features = BIT(KVM_LOONGARCH_VM_FEAT_PV_IPI);
52+ kvm->arch.pv_features |= BIT(KVM_FEATURE_IPI);
53+ kvm->arch.kvm_features |= BIT(KVM_LOONGARCH_VM_FEAT_PV_IPI);
5454 if (kvm_pvtime_supported()) {
5555 kvm->arch.pv_features |= BIT(KVM_FEATURE_PREEMPT);
5656 kvm->arch.pv_features |= BIT(KVM_FEATURE_STEAL_TIME);
arch/loongarch/net/bpf_jit.c+11−0
@@ -1379,9 +1379,11 @@ void *bpf_arch_text_copy(void *dst, void *src, size_t len) · 1378 unmodified lines
13791379 {
13801380 int ret;
13811381
1382+ cpus_read_lock();
13821383 mutex_lock(&text_mutex);
13831384 ret = larch_insn_text_copy(dst, src, len);
13841385 mutex_unlock(&text_mutex);
1386+ cpus_read_unlock();
13851387
13861388 return ret ? ERR_PTR(-EINVAL) : dst;
13871389 }
@@ -1429,10 +1431,12 @@ int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type old_t, · 41 unmodified lines
14291431 if (ret)
14301432 return ret;
14311433
1434+ cpus_read_lock();
14321435 mutex_lock(&text_mutex);
14331436 if (memcmp(ip, new_insns, LOONGARCH_LONG_JUMP_NBYTES))
14341437 ret = larch_insn_text_copy(ip, new_insns, LOONGARCH_LONG_JUMP_NBYTES);
14351438 mutex_unlock(&text_mutex);
1439+ cpus_read_unlock();
14361440
14371441 return ret;
14381442 }
@@ -1450,10 +1454,12 @@ int bpf_arch_text_invalidate(void *dst, size_t len) · 11 unmodified lines
14501454 for (i = 0; i < (len / sizeof(u32)); i++)
14511455 inst[i] = INSN_BREAK;
14521456
1457+ cpus_read_lock();
14531458 mutex_lock(&text_mutex);
14541459 if (larch_insn_text_copy(dst, inst, len))
14551460 ret = -EINVAL;
14561461 mutex_unlock(&text_mutex);
1462+ cpus_read_unlock();
14571463
14581464 kvfree(inst);
14591465
@@ -1568,6 +1574,11 @@ void arch_free_bpf_trampoline(void *image, unsigned int size) · 108 unmodified lines
15681574 bpf_prog_pack_free(image, size);
15691575 }
15701576
1577+int arch_protect_bpf_trampoline(void *image, unsigned int size)
1578+{
1579+ return 0;
1580+}
1581+
15711582 /*
15721583 * Sign-extend the register if necessary
15731584 */
arch/parisc/kernel/cache.c+2−2
@@ -953,7 +953,7 @@ SYSCALL_DEFINE3(cacheflush, unsigned long, addr, unsigned long, bytes, · 952 unmodified lines
953953 #else
954954 "1: cmpb,<<,n %0,%2,1b\n"
955955 #endif
956− " fic,m %3(%4,%0)\n"
956+ " fdc,m %3(%4,%0)\n"
957957 "2: sync\n"
958958 ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 2b, "%1")
959959 : "+r" (start), "+r" (error)
@@ -968,7 +968,7 @@ SYSCALL_DEFINE3(cacheflush, unsigned long, addr, unsigned long, bytes, · 8 unmodified lines
968968 #else
969969 "1: cmpb,<<,n %0,%2,1b\n"
970970 #endif
971− " fdc,m %3(%4,%0)\n"
971+ " fic,m %3(%4,%0)\n"
972972 "2: sync\n"
973973 ASM_EXCEPTIONTABLE_ENTRY_EFAULT(1b, 2b, "%1")
974974 : "+r" (start), "+r" (error)
arch/riscv/boot/dts/microchip/mpfs.dtsi+2−0
@@ -428,6 +428,7 @@ · 427 unmodified lines
428428 clocks = <&clkcfg CLK_CAN0>, <&clkcfg CLK_MSSPLL3>;
429429 interrupt-parent = <&plic>;
430430 interrupts = <56>;
431+ resets = <&mss_top_sysreg CLK_CAN0>;
431432 status = "disabled";
432433 };
433434
@@ -437,6 +438,7 @@ · 3 unmodified lines
437438 clocks = <&clkcfg CLK_CAN1>, <&clkcfg CLK_MSSPLL3>;
438439 interrupt-parent = <&plic>;
439440 interrupts = <57>;
441+ resets = <&mss_top_sysreg CLK_CAN1>;
440442 status = "disabled";
441443 };
442444
arch/sh/drivers/platform_early.c+0−4
@@ -26,10 +26,6 @@ static int platform_match(struct device *dev, struct device_driver *drv) · 25 unmodified lines
2626 struct platform_device *pdev = to_platform_device(dev);
2727 struct platform_driver *pdrv = to_platform_driver(drv);
2828
29− /* When driver_override is set, only bind to the matching driver */
30− if (pdev->driver_override)
31− return !strcmp(pdev->driver_override, drv->name);
32−
3329 /* Then try to match against the id table */
3430 if (pdrv->id_table)
3531 return platform_match_id(pdrv->id_table, pdev) != NULL;
arch/x86/entry/vdso/common/vclock_gettime.c+1−1
@@ -13,7 +13,7 @@ · 12 unmodified lines
1313 #include <linux/types.h>
1414 #include <vdso/gettime.h>
1515
16−#include "../../../../lib/vdso/gettimeofday.c"
16+#include "lib/vdso/gettimeofday.c"
1717
1818 int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
1919 {
arch/x86/events/core.c+5−2
@@ -1372,14 +1372,17 @@ static void x86_pmu_enable(struct pmu *pmu) · 1371 unmodified lines
13721372 else if (i < n_running)
13731373 continue;
13741374
1375− if (hwc->state & PERF_HES_ARCH)
1375+ cpuc->events[hwc->idx] = event;
1376+
1377+ if (hwc->state & PERF_HES_ARCH) {
1378+ static_call(x86_pmu_set_period)(event);
13761379 continue;
1380+ }
13771381
13781382 /*
13791383 * if cpuc->enabled = 0, then no wrmsr as
13801384 * per x86_pmu_enable_event()
13811385 */
1382− cpuc->events[hwc->idx] = event;
13831386 x86_pmu_start(event, PERF_EF_RELOAD);
13841387 }
13851388 cpuc->n_added = 0;
arch/x86/events/intel/core.c+21−10
@@ -4628,6 +4628,19 @@ static inline void intel_pmu_set_acr_caused_constr(struct perf_event *event, · 4627 unmodified lines
46284628 event->hw.dyn_constraint &= hybrid(event->pmu, acr_cause_mask64);
46294629 }
46304630
4631+static inline int intel_set_branch_counter_constr(struct perf_event *event,
4632+ int *num)
4633+{
4634+ if (branch_sample_call_stack(event))
4635+ return -EINVAL;
4636+ if (branch_sample_counters(event)) {
4637+ (*num)++;
4638+ event->hw.dyn_constraint &= x86_pmu.lbr_counters;
4639+ }
4640+
4641+ return 0;
4642+}
4643+
46314644 static int intel_pmu_hw_config(struct perf_event *event)
46324645 {
46334646 int ret = x86_pmu_hw_config(event);
@@ -4698,21 +4711,19 @@ static int intel_pmu_hw_config(struct perf_event *event) · 64 unmodified lines
46984711 * group, which requires the extra space to store the counters.
46994712 */
47004713 leader = event->group_leader;
4701− if (branch_sample_call_stack(leader))
4714+ if (intel_set_branch_counter_constr(leader, &num))
47024715 return -EINVAL;
4703− if (branch_sample_counters(leader)) {
4704− num++;
4705− leader->hw.dyn_constraint &= x86_pmu.lbr_counters;
4706− }
47074716 leader->hw.flags |= PERF_X86_EVENT_BRANCH_COUNTERS;
47084717
47094718 for_each_sibling_event(sibling, leader) {
4710− if (branch_sample_call_stack(sibling))
4719+ if (intel_set_branch_counter_constr(sibling, &num))
4720+ return -EINVAL;
4721+ }
4722+
4723+ /* event isn't installed as a sibling yet. */
4724+ if (event != leader) {
4725+ if (intel_set_branch_counter_constr(event, &num))
47114726 return -EINVAL;
4712− if (branch_sample_counters(sibling)) {
4713− num++;
4714− sibling->hw.dyn_constraint &= x86_pmu.lbr_counters;
4715− }
47164727 }
47174728
47184729 if (num > fls(x86_pmu.lbr_counters))
arch/x86/events/intel/ds.c+7−4
@@ -345,12 +345,12 @@ static u64 parse_omr_data_source(u8 dse) · 344 unmodified lines
345345 if (omr.omr_remote)
346346 val |= REM;
347347
348− val |= omr.omr_hitm ? P(SNOOP, HITM) : P(SNOOP, HIT);
349−
350348 if (omr.omr_source == 0x2) {
351− u8 snoop = omr.omr_snoop | omr.omr_promoted;
349+ u8 snoop = omr.omr_snoop | (omr.omr_promoted << 1);
352350
353− if (snoop == 0x0)
351+ if (omr.omr_hitm)
352+ val |= P(SNOOP, HITM);
353+ else if (snoop == 0x0)
354354 val |= P(SNOOP, NA);
355355 else if (snoop == 0x1)
356356 val |= P(SNOOP, MISS);
@@ -359,7 +359,10 @@ static u64 parse_omr_data_source(u8 dse) · 2 unmodified lines
359359 else if (snoop == 0x3)
360360 val |= P(SNOOP, NONE);
361361 } else if (omr.omr_source > 0x2 && omr.omr_source < 0x7) {
362+ val |= omr.omr_hitm ? P(SNOOP, HITM) : P(SNOOP, HIT);
362363 val |= omr.omr_snoop ? P(SNOOPX, FWD) : 0;
364+ } else {
365+ val |= P(SNOOP, NONE);
363366 }
364367
365368 return val;
arch/x86/hyperv/hv_crash.c+52−48
@@ -107,14 +107,12 @@ static void __noreturn hv_panic_timeout_reboot(void) · 106 unmodified lines
107107 cpu_relax();
108108 }
109109
110−/* This cannot be inlined as it needs stack */
111−static noinline __noclone void hv_crash_restore_tss(void)
110+static void hv_crash_restore_tss(void)
112111 {
113112 load_TR_desc();
114113 }
115114
116−/* This cannot be inlined as it needs stack */
117−static noinline void hv_crash_clear_kernpt(void)
115+static void hv_crash_clear_kernpt(void)
118116 {
119117 pgd_t *pgd;
120118 p4d_t *p4d;
@@ -125,6 +123,25 @@ static noinline void hv_crash_clear_kernpt(void) · 4 unmodified lines
125123 native_p4d_clear(p4d);
126124 }
127125
126+
127+static void __noreturn hv_crash_handle(void)
128+{
129+ hv_crash_restore_tss();
130+ hv_crash_clear_kernpt();
131+
132+ /* we are now fully in devirtualized normal kernel mode */
133+ __crash_kexec(NULL);
134+
135+ hv_panic_timeout_reboot();
136+}
137+
138+/*
139+ * __naked functions do not permit function calls, not even to __always_inline
140+ * functions that only contain asm() blocks themselves. So use a macro instead.
141+ */
142+#define hv_wrmsr(msr, val) \
143+ asm volatile("wrmsr" :: "c"(msr), "a"((u32)val), "d"((u32)(val >> 32)) : "memory")
144+
128145 /*
129146 * This is the C entry point from the asm glue code after the disable hypercall.
130147 * We enter here in IA32-e long mode, ie, full 64bit mode running on kernel
@@ -133,51 +150,38 @@ static noinline void hv_crash_clear_kernpt(void) · 2 unmodified lines
133150 * available. We restore kernel GDT, and rest of the context, and continue
134151 * to kexec.
135152 */
136−static asmlinkage void __noreturn hv_crash_c_entry(void)
153+static void __naked hv_crash_c_entry(void)
137154 {
138− struct hv_crash_ctxt *ctxt = &hv_crash_ctxt;
139−
140155 /* first thing, restore kernel gdt */
141− native_load_gdt(&ctxt->gdtr);
156+ asm volatile("lgdt %0" : : "m" (hv_crash_ctxt.gdtr));
142157
143− asm volatile("movw %%ax, %%ss" : : "a"(ctxt->ss));
144− asm volatile("movq %0, %%rsp" : : "m"(ctxt->rsp));
158+ asm volatile("movw %0, %%ss\n\t"
159+ "movq %1, %%rsp"
160+ :: "m"(hv_crash_ctxt.ss), "m"(hv_crash_ctxt.rsp));
145161
146− asm volatile("movw %%ax, %%ds" : : "a"(ctxt->ds));
147− asm volatile("movw %%ax, %%es" : : "a"(ctxt->es));
148− asm volatile("movw %%ax, %%fs" : : "a"(ctxt->fs));
149− asm volatile("movw %%ax, %%gs" : : "a"(ctxt->gs));
162+ asm volatile("movw %0, %%ds" : : "m"(hv_crash_ctxt.ds));
163+ asm volatile("movw %0, %%es" : : "m"(hv_crash_ctxt.es));
164+ asm volatile("movw %0, %%fs" : : "m"(hv_crash_ctxt.fs));
165+ asm volatile("movw %0, %%gs" : : "m"(hv_crash_ctxt.gs));
150166
151− native_wrmsrq(MSR_IA32_CR_PAT, ctxt->pat);
152− asm volatile("movq %0, %%cr0" : : "r"(ctxt->cr0));
167+ hv_wrmsr(MSR_IA32_CR_PAT, hv_crash_ctxt.pat);
168+ asm volatile("movq %0, %%cr0" : : "r"(hv_crash_ctxt.cr0));
153169
154− asm volatile("movq %0, %%cr8" : : "r"(ctxt->cr8));
155− asm volatile("movq %0, %%cr4" : : "r"(ctxt->cr4));
156− asm volatile("movq %0, %%cr2" : : "r"(ctxt->cr4));
170+ asm volatile("movq %0, %%cr8" : : "r"(hv_crash_ctxt.cr8));
171+ asm volatile("movq %0, %%cr4" : : "r"(hv_crash_ctxt.cr4));
172+ asm volatile("movq %0, %%cr2" : : "r"(hv_crash_ctxt.cr2));
157173
158− native_load_idt(&ctxt->idtr);
159− native_wrmsrq(MSR_GS_BASE, ctxt->gsbase);
160− native_wrmsrq(MSR_EFER, ctxt->efer);
174+ asm volatile("lidt %0" : : "m" (hv_crash_ctxt.idtr));
175+ hv_wrmsr(MSR_GS_BASE, hv_crash_ctxt.gsbase);
176+ hv_wrmsr(MSR_EFER, hv_crash_ctxt.efer);
161177
162178 /* restore the original kernel CS now via far return */
163− asm volatile("movzwq %0, %%rax\n\t"
164− "pushq %%rax\n\t"
165− "pushq $1f\n\t"
166− "lretq\n\t"
167− "1:nop\n\t" : : "m"(ctxt->cs) : "rax");
168−
169− /* We are in asmlinkage without stack frame, hence make C function
170− * calls which will buy stack frames.
171− */
172− hv_crash_restore_tss();
173− hv_crash_clear_kernpt();
174−
175− /* we are now fully in devirtualized normal kernel mode */
176− __crash_kexec(NULL);
177−
178− hv_panic_timeout_reboot();
179+ asm volatile("pushq %q0\n\t"
180+ "pushq %q1\n\t"
181+ "lretq"
182+ :: "r"(hv_crash_ctxt.cs), "r"(hv_crash_handle));
179183 }
180−/* Tell gcc we are using lretq long jump in the above function intentionally */
184+/* Tell objtool we are using lretq long jump in the above function intentionally */
181185 STACK_FRAME_NON_STANDARD(hv_crash_c_entry);
182186
183187 static void hv_mark_tss_not_busy(void)
@@ -195,20 +199,20 @@ static void hv_hvcrash_ctxt_save(void) · 11 unmodified lines
195199 {
196200 struct hv_crash_ctxt *ctxt = &hv_crash_ctxt;
197201
198− asm volatile("movq %%rsp,%0" : "=m"(ctxt->rsp));
202+ ctxt->rsp = current_stack_pointer;
199203
200204 ctxt->cr0 = native_read_cr0();
201205 ctxt->cr4 = native_read_cr4();
202206
203− asm volatile("movq %%cr2, %0" : "=a"(ctxt->cr2));
204− asm volatile("movq %%cr8, %0" : "=a"(ctxt->cr8));
207+ asm volatile("movq %%cr2, %0" : "=r"(ctxt->cr2));
208+ asm volatile("movq %%cr8, %0" : "=r"(ctxt->cr8));
205209
206− asm volatile("movl %%cs, %%eax" : "=a"(ctxt->cs));
207− asm volatile("movl %%ss, %%eax" : "=a"(ctxt->ss));
208− asm volatile("movl %%ds, %%eax" : "=a"(ctxt->ds));
209− asm volatile("movl %%es, %%eax" : "=a"(ctxt->es));
210− asm volatile("movl %%fs, %%eax" : "=a"(ctxt->fs));
211− asm volatile("movl %%gs, %%eax" : "=a"(ctxt->gs));
210+ asm volatile("movw %%cs, %0" : "=m"(ctxt->cs));
211+ asm volatile("movw %%ss, %0" : "=m"(ctxt->ss));
212+ asm volatile("movw %%ds, %0" : "=m"(ctxt->ds));
213+ asm volatile("movw %%es, %0" : "=m"(ctxt->es));
214+ asm volatile("movw %%fs, %0" : "=m"(ctxt->fs));
215+ asm volatile("movw %%gs, %0" : "=m"(ctxt->gs));
212216
213217 native_store_gdt(&ctxt->gdtr);
214218 store_idt(&ctxt->idtr);
arch/x86/kernel/apic/x2apic_uv_x.c+16−2
@@ -1708,8 +1708,22 @@ static void __init uv_system_init_hub(void) · 1707 unmodified lines
17081708 struct uv_hub_info_s *new_hub;
17091709
17101710 /* Allocate & fill new per hub info list */
1711− new_hub = (bid == 0) ? &uv_hub_info_node0
1712− : kzalloc_node(bytes, GFP_KERNEL, uv_blade_to_node(bid));
1711+ if (bid == 0) {
1712+ new_hub = &uv_hub_info_node0;
1713+ } else {
1714+ int nid;
1715+
1716+ /*
1717+ * Deconfigured sockets are mapped to SOCK_EMPTY. Use
1718+ * NUMA_NO_NODE to allocate on a valid node.
1719+ */
1720+ nid = uv_blade_to_node(bid);
1721+ if (nid == SOCK_EMPTY)
1722+ nid = NUMA_NO_NODE;
1723+
1724+ new_hub = kzalloc_node(bytes, GFP_KERNEL, nid);
1725+ }
1726+
17131727 if (WARN_ON_ONCE(!new_hub)) {
17141728 /* do not kfree() bid 0, which is statically allocated */
17151729 while (--bid > 0)
arch/x86/kernel/cpu/mce/amd.c+11−6
@@ -875,13 +875,18 @@ void amd_clear_bank(struct mce *m) · 874 unmodified lines
875875 {
876876 amd_reset_thr_limit(m->bank);
877877
878− /* Clear MCA_DESTAT for all deferred errors even those logged in MCA_STATUS. */
879− if (m->status & MCI_STATUS_DEFERRED)
880− mce_wrmsrq(MSR_AMD64_SMCA_MCx_DESTAT(m->bank), 0);
878+ if (mce_flags.smca) {
879+ /*
880+ * Clear MCA_DESTAT for all deferred errors even those
881+ * logged in MCA_STATUS.
882+ */
883+ if (m->status & MCI_STATUS_DEFERRED)
884+ mce_wrmsrq(MSR_AMD64_SMCA_MCx_DESTAT(m->bank), 0);
881885
882− /* Don't clear MCA_STATUS if MCA_DESTAT was used exclusively. */
883− if (m->kflags & MCE_CHECK_DFR_REGS)
884− return;
886+ /* Don't clear MCA_STATUS if MCA_DESTAT was used exclusively. */
887+ if (m->kflags & MCE_CHECK_DFR_REGS)
888+ return;
889+ }
885890
886891 mce_wrmsrq(mca_msr_reg(m->bank, MCA_STATUS), 0);
887892 }
arch/x86/kernel/cpu/mshyperv.c+3−2
@@ -496,8 +496,9 @@ static void hv_reserve_irq_vectors(void) · 495 unmodified lines
496496 test_and_set_bit(HYPERV_DBG_FASTFAIL_VECTOR, system_vectors))
497497 BUG();
498498
499− pr_info("Hyper-V: reserve vectors: %d %d %d\n", HYPERV_DBG_ASSERT_VECTOR,
500− HYPERV_DBG_SERVICE_VECTOR, HYPERV_DBG_FASTFAIL_VECTOR);
499+ pr_info("Hyper-V: reserve vectors: 0x%x 0x%x 0x%x\n",
500+ HYPERV_DBG_ASSERT_VECTOR, HYPERV_DBG_SERVICE_VECTOR,
501+ HYPERV_DBG_FASTFAIL_VECTOR);
501502 }
502503
503504 static void __init ms_hyperv_init_platform(void)
drivers/acpi/acpi_processor.c+8−7
@@ -113,6 +113,10 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev) · 112 unmodified lines
113113 PCI_ANY_ID, PCI_ANY_ID, NULL);
114114 if (ide_dev) {
115115 errata.piix4.bmisx = pci_resource_start(ide_dev, 4);
116+ if (errata.piix4.bmisx)
117+ dev_dbg(&ide_dev->dev,
118+ "Bus master activity detection (BM-IDE) erratum enabled\n");
119+
116120 pci_dev_put(ide_dev);
117121 }
118122
@@ -131,20 +135,17 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev) · 12 unmodified lines
131135 if (isa_dev) {
132136 pci_read_config_byte(isa_dev, 0x76, &value1);
133137 pci_read_config_byte(isa_dev, 0x77, &value2);
134− if ((value1 & 0x80) || (value2 & 0x80))
138+ if ((value1 & 0x80) || (value2 & 0x80)) {
135139 errata.piix4.fdma = 1;
140+ dev_dbg(&isa_dev->dev,
141+ "Type-F DMA livelock erratum (C3 disabled)\n");
142+ }
136143 pci_dev_put(isa_dev);
137144 }
138145
139146 break;
140147 }
141148
142− if (ide_dev)
143− dev_dbg(&ide_dev->dev, "Bus master activity detection (BM-IDE) erratum enabled\n");
144−
145− if (isa_dev)
146− dev_dbg(&isa_dev->dev, "Type-F DMA livelock erratum (C3 disabled)\n");
147−
148149 return 0;
149150 }
150151
drivers/acpi/acpica/acpredef.h+1−1
@@ -451,7 +451,7 @@ const union acpi_predefined_info acpi_gbl_predefined_methods[] = { · 450 unmodified lines
451451
452452 {{"_DSM",
453453 METHOD_4ARGS(ACPI_TYPE_BUFFER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER,
454− ACPI_TYPE_ANY | ACPI_TYPE_PACKAGE) |
454+ ACPI_TYPE_PACKAGE | ACPI_TYPE_ANY) |
455455 ARG_COUNT_IS_MINIMUM,
456456 METHOD_RETURNS(ACPI_RTYPE_ALL)}}, /* Must return a value, but it can be of any type */
457457
drivers/acpi/bus.c+0−3
@@ -818,9 +818,6 @@ const struct acpi_device *acpi_companion_match(const struct device *dev) · 817 unmodified lines
818818 if (list_empty(&adev->pnp.ids))
819819 return NULL;
820820
821− if (adev->pnp.type.backlight)
822− return adev;
823−
824821 return acpi_primary_dev_companion(adev, dev);
825822 }
826823
drivers/ata/libata-core.c+3−0
@@ -4188,6 +4188,9 @@ static const struct ata_dev_quirks_entry __ata_dev_quirks[] = { · 4187 unmodified lines
41884188 { "ST3320[68]13AS", "SD1[5-9]", ATA_QUIRK_NONCQ |
41894189 ATA_QUIRK_FIRMWARE_WARN },
41904190
4191+ /* ADATA devices with LPM issues. */
4192+ { "ADATA SU680", NULL, ATA_QUIRK_NOLPM },
4193+
41914194 /* Seagate disks with LPM issues */
41924195 { "ST1000DM010-2EP102", NULL, ATA_QUIRK_NOLPM },
41934196 { "ST2000DM008-2FR102", NULL, ATA_QUIRK_NOLPM },
drivers/ata/libata-scsi.c+1−1
@@ -3600,7 +3600,7 @@ static unsigned int ata_scsiop_maint_in(struct ata_device *dev, · 3599 unmodified lines
36003600
36013601 if (cdb[2] != 1 && cdb[2] != 3) {
36023602 ata_dev_warn(dev, "invalid command format %d\n", cdb[2]);
3603− ata_scsi_set_invalid_field(dev, cmd, 1, 0xff);
3603+ ata_scsi_set_invalid_field(dev, cmd, 2, 0xff);
36043604 return 0;
36053605 }
36063606
drivers/base/bus.c+42−1
@@ -504,6 +504,36 @@ int bus_for_each_drv(const struct bus_type *bus, struct device_driver *start, · 503 unmodified lines
504504 }
505505 EXPORT_SYMBOL_GPL(bus_for_each_drv);
506506
507+static ssize_t driver_override_store(struct device *dev,
508+ struct device_attribute *attr,
509+ const char *buf, size_t count)
510+{
511+ int ret;
512+
513+ ret = __device_set_driver_override(dev, buf, count);
514+ if (ret)
515+ return ret;
516+
517+ return count;
518+}
519+
520+static ssize_t driver_override_show(struct device *dev,
521+ struct device_attribute *attr, char *buf)
522+{
523+ guard(spinlock)(&dev->driver_override.lock);
524+ return sysfs_emit(buf, "%s\n", dev->driver_override.name);
525+}
526+static DEVICE_ATTR_RW(driver_override);
527+
528+static struct attribute *driver_override_dev_attrs[] = {
529+ &dev_attr_driver_override.attr,
530+ NULL,
531+};
532+
533+static const struct attribute_group driver_override_dev_group = {
534+ .attrs = driver_override_dev_attrs,
535+};
536+
507537 /**
508538 * bus_add_device - add device to bus
509539 * @dev: device being added
@@ -537,9 +567,15 @@ int bus_add_device(struct device *dev) · 27 unmodified lines
537567 if (error)
538568 goto out_put;
539569
570+ if (dev->bus->driver_override) {
571+ error = device_add_group(dev, &driver_override_dev_group);
572+ if (error)
573+ goto out_groups;
574+ }
575+
540576 error = sysfs_create_link(&sp->devices_kset->kobj, &dev->kobj, dev_name(dev));
541577 if (error)
542− goto out_groups;
578+ goto out_override;
543579
544580 error = sysfs_create_link(&dev->kobj, &sp->subsys.kobj, "subsystem");
545581 if (error)
@@ -550,6 +586,9 @@ int bus_add_device(struct device *dev) · 4 unmodified lines
550586
551587 out_subsys:
552588 sysfs_remove_link(&sp->devices_kset->kobj, dev_name(dev));
589+out_override:
590+ if (dev->bus->driver_override)
591+ device_remove_group(dev, &driver_override_dev_group);
553592 out_groups:
554593 device_remove_groups(dev, sp->bus->dev_groups);
555594 out_put:
@@ -607,6 +646,8 @@ void bus_remove_device(struct device *dev) · 51 unmodified lines
607646
608647 sysfs_remove_link(&dev->kobj, "subsystem");
609648 sysfs_remove_link(&sp->devices_kset->kobj, dev_name(dev));
649+ if (dev->bus->driver_override)
650+ device_remove_group(dev, &driver_override_dev_group);
610651 device_remove_groups(dev, dev->bus->dev_groups);
611652 if (klist_node_attached(&dev->p->knode_bus))
612653 klist_del(&dev->p->knode_bus);
drivers/base/core.c+2−0
@@ -2556,6 +2556,7 @@ static void device_release(struct kobject *kobj) · 2555 unmodified lines
25562556 devres_release_all(dev);
25572557
25582558 kfree(dev->dma_range_map);
2559+ kfree(dev->driver_override.name);
25592560
25602561 if (dev->release)
25612562 dev->release(dev);
@@ -3160,6 +3161,7 @@ void device_initialize(struct device *dev) · 598 unmodified lines
31603161 kobject_init(&dev->kobj, &device_ktype);
31613162 INIT_LIST_HEAD(&dev->dma_pools);
31623163 mutex_init(&dev->mutex);
3164+ spin_lock_init(&dev->driver_override.lock);
31633165 lockdep_set_novalidate_class(&dev->mutex);
31643166 spin_lock_init(&dev->devres_lock);
31653167 INIT_LIST_HEAD(&dev->devres_head);
drivers/base/dd.c+60−0
@@ -381,6 +381,66 @@ static void __exit deferred_probe_exit(void) · 380 unmodified lines
381381 }
382382 __exitcall(deferred_probe_exit);
383383
384+int __device_set_driver_override(struct device *dev, const char *s, size_t len)
385+{
386+ const char *new, *old;
387+ char *cp;
388+
389+ if (!s)
390+ return -EINVAL;
391+
392+ /*
393+ * The stored value will be used in sysfs show callback (sysfs_emit()),
394+ * which has a length limit of PAGE_SIZE and adds a trailing newline.
395+ * Thus we can store one character less to avoid truncation during sysfs
396+ * show.
397+ */
398+ if (len >= (PAGE_SIZE - 1))
399+ return -EINVAL;
400+
401+ /*
402+ * Compute the real length of the string in case userspace sends us a
403+ * bunch of \0 characters like python likes to do.
404+ */
405+ len = strlen(s);
406+
407+ if (!len) {
408+ /* Empty string passed - clear override */
409+ spin_lock(&dev->driver_override.lock);
410+ old = dev->driver_override.name;
411+ dev->driver_override.name = NULL;
412+ spin_unlock(&dev->driver_override.lock);
413+ kfree(old);
414+
415+ return 0;
416+ }
417+
418+ cp = strnchr(s, len, '\n');
419+ if (cp)
420+ len = cp - s;
421+
422+ new = kstrndup(s, len, GFP_KERNEL);
423+ if (!new)
424+ return -ENOMEM;
425+
426+ spin_lock(&dev->driver_override.lock);
427+ old = dev->driver_override.name;
428+ if (cp != s) {
429+ dev->driver_override.name = new;
430+ spin_unlock(&dev->driver_override.lock);
431+ } else {
432+ /* "\n" passed - clear override */
433+ dev->driver_override.name = NULL;
434+ spin_unlock(&dev->driver_override.lock);
435+
436+ kfree(new);
437+ }
438+ kfree(old);
439+
440+ return 0;
441+}
442+EXPORT_SYMBOL_GPL(__device_set_driver_override);
443+
384444 /**
385445 * device_is_bound() - Check if device is bound to a driver
386446 * @dev: device to check
drivers/base/platform.c+5−32
@@ -603,7 +603,6 @@ static void platform_device_release(struct device *dev) · 602 unmodified lines
603603 kfree(pa->pdev.dev.platform_data);
604604 kfree(pa->pdev.mfd_cell);
605605 kfree(pa->pdev.resource);
606− kfree(pa->pdev.driver_override);
607606 kfree(pa);
608607 }
609608
@@ -1309,38 +1308,9 @@ static ssize_t numa_node_show(struct device *dev, · 699 unmodified lines
13091308 }
13101309 static DEVICE_ATTR_RO(numa_node);
13111310
1312−static ssize_t driver_override_show(struct device *dev,
1313− struct device_attribute *attr, char *buf)
1314−{
1315− struct platform_device *pdev = to_platform_device(dev);
1316− ssize_t len;
1317−
1318− device_lock(dev);
1319− len = sysfs_emit(buf, "%s\n", pdev->driver_override);
1320− device_unlock(dev);
1321−
1322− return len;
1323−}
1324−
1325−static ssize_t driver_override_store(struct device *dev,
1326− struct device_attribute *attr,
1327− const char *buf, size_t count)
1328−{
1329− struct platform_device *pdev = to_platform_device(dev);
1330− int ret;
1331−
1332− ret = driver_set_override(dev, &pdev->driver_override, buf, count);
1333− if (ret)
1334− return ret;
1335−
1336− return count;
1337−}
1338−static DEVICE_ATTR_RW(driver_override);
1339−
13401311 static struct attribute *platform_dev_attrs[] = {
13411312 &dev_attr_modalias.attr,
13421313 &dev_attr_numa_node.attr,
1343− &dev_attr_driver_override.attr,
13441314 NULL,
13451315 };
13461316
@@ -1378,10 +1348,12 @@ static int platform_match(struct device *dev, const struct device_driver *drv) · 31 unmodified lines
13781348 {
13791349 struct platform_device *pdev = to_platform_device(dev);
13801350 struct platform_driver *pdrv = to_platform_driver(drv);
1351+ int ret;
13811352
13821353 /* When driver_override is set, only bind to the matching driver */
1383− if (pdev->driver_override)
1384− return !strcmp(pdev->driver_override, drv->name);
1354+ ret = device_match_driver_override(dev, drv);
1355+ if (ret >= 0)
1356+ return ret;
13851357
13861358 /* Attempt an OF style match first */
13871359 if (of_driver_match_device(dev, drv))
@@ -1516,6 +1488,7 @@ static const struct dev_pm_ops platform_dev_pm_ops = { · 128 unmodified lines
15161488 const struct bus_type platform_bus_type = {
15171489 .name = "platform",
15181490 .dev_groups = platform_dev_groups,
1491+ .driver_override = true,
15191492 .match = platform_match,
15201493 .uevent = platform_uevent,
15211494 .probe = platform_probe,
drivers/base/power/runtime.c+1−0
@@ -1895,6 +1895,7 @@ void pm_runtime_reinit(struct device *dev) · 1894 unmodified lines
18951895 void pm_runtime_remove(struct device *dev)
18961896 {
18971897 __pm_runtime_disable(dev, false);
1898+ flush_work(&dev->power.work);
18981899 pm_runtime_reinit(dev);
18991900 }
19001901
drivers/bluetooth/btqca.c+2−0
@@ -787,6 +787,8 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, · 786 unmodified lines
787787 */
788788 if (soc_type == QCA_WCN3988)
789789 rom_ver = ((soc_ver & 0x00000f00) >> 0x05) | (soc_ver & 0x0000000f);
790+ else if (soc_type == QCA_WCN3998)
791+ rom_ver = ((soc_ver & 0x0000f000) >> 0x07) | (soc_ver & 0x0000000f);
790792 else
791793 rom_ver = ((soc_ver & 0x00000f00) >> 0x04) | (soc_ver & 0x0000000f);
792794
drivers/bus/simple-pm-bus.c+2−2
@@ -36,7 +36,7 @@ static int simple_pm_bus_probe(struct platform_device *pdev) · 35 unmodified lines
3636 * that's not listed in simple_pm_bus_of_match. We don't want to do any
3737 * of the simple-pm-bus tasks for these devices, so return early.
3838 */
39− if (pdev->driver_override)
39+ if (device_has_driver_override(&pdev->dev))
4040 return 0;
4141
4242 match = of_match_device(dev->driver->of_match_table, dev);
@@ -78,7 +78,7 @@ static void simple_pm_bus_remove(struct platform_device *pdev) · 35 unmodified lines
7878 {
7979 const void *data = of_device_get_match_data(&pdev->dev);
8080
81− if (pdev->driver_override || data)
81+ if (device_has_driver_override(&pdev->dev) || data)
8282 return;
8383
8484 dev_dbg(&pdev->dev, "%s\n", __func__);
drivers/cache/ax45mp_cache.c+2−2
@@ -178,11 +178,11 @@ static const struct of_device_id ax45mp_cache_ids[] = { · 177 unmodified lines
178178
179179 static int __init ax45mp_cache_init(void)
180180 {
181− struct device_node *np;
182181 struct resource res;
183182 int ret;
184183
185− np = of_find_matching_node(NULL, ax45mp_cache_ids);
184+ struct device_node *np __free(device_node) =
185+ of_find_matching_node(NULL, ax45mp_cache_ids);
186186 if (!of_device_is_available(np))
187187 return -ENODEV;
188188
drivers/cache/starfive_starlink_cache.c+2−2
@@ -102,11 +102,11 @@ static const struct of_device_id starlink_cache_ids[] = { · 101 unmodified lines
102102
103103 static int __init starlink_cache_init(void)
104104 {
105− struct device_node *np;
106105 u32 block_size;
107106 int ret;
108107
109− np = of_find_matching_node(NULL, starlink_cache_ids);
108+ struct device_node *np __free(device_node) =
109+ of_find_matching_node(NULL, starlink_cache_ids);
110110 if (!of_device_is_available(np))
111111 return -ENODEV;
112112
drivers/clk/imx/clk-scu.c+1−2
@@ -706,8 +706,7 @@ struct clk_hw *imx_clk_scu_alloc_dev(const char *name, · 705 unmodified lines
706706 if (ret)
707707 goto put_device;
708708
709− ret = driver_set_override(&pdev->dev, &pdev->driver_override,
710− "imx-scu-clk", strlen("imx-scu-clk"));
709+ ret = device_set_driver_override(&pdev->dev, "imx-scu-clk");
711710 if (ret)
712711 goto put_device;
713712
drivers/crypto/ccp/sev-dev.c+1−3
@@ -2408,10 +2408,8 @@ static int sev_ioctl_do_snp_platform_status(struct sev_issue_cmd *argp) · 2407 unmodified lines
24082408 * in Firmware state on failure. Use snp_reclaim_pages() to
24092409 * transition either case back to Hypervisor-owned state.
24102410 */
2411− if (snp_reclaim_pages(__pa(data), 1, true)) {
2412− snp_leak_pages(__page_to_pfn(status_page), 1);
2411+ if (snp_reclaim_pages(__pa(data), 1, true))
24132412 return -EFAULT;
2414− }
24152413 }
24162414
24172415 if (ret)
drivers/crypto/padlock-sha.c+7−0
@@ -332,6 +332,13 @@ static int __init padlock_init(void) · 331 unmodified lines
332332 if (!x86_match_cpu(padlock_sha_ids) || !boot_cpu_has(X86_FEATURE_PHE_EN))
333333 return -ENODEV;
334334
335+ /*
336+ * Skip family 0x07 and newer used by Zhaoxin processors,
337+ * as the driver's self-tests fail on these CPUs.
338+ */
339+ if (c->x86 >= 0x07)
340+ return -ENODEV;
341+
335342 /* Register the newly added algorithm module if on *
336343 * VIA Nano processor, or else just do as before */
337344 if (c->x86_model < 0x0f) {
drivers/firewire/net.c+3−2
@@ -257,9 +257,10 @@ static void fwnet_header_cache_update(struct hh_cache *hh, · 256 unmodified lines
257257 memcpy((u8 *)hh->hh_data + HH_DATA_OFF(FWNET_HLEN), haddr, net->addr_len);
258258 }
259259
260−static int fwnet_header_parse(const struct sk_buff *skb, unsigned char *haddr)
260+static int fwnet_header_parse(const struct sk_buff *skb, const struct net_device *dev,
261+ unsigned char *haddr)
261262 {
262− memcpy(haddr, skb->dev->dev_addr, FWNET_ALEN);
263+ memcpy(haddr, dev->dev_addr, FWNET_ALEN);
263264
264265 return FWNET_ALEN;
265266 }
drivers/firmware/arm_ffa/driver.c+4−4
@@ -205,12 +205,12 @@ static int ffa_rxtx_map(phys_addr_t tx_buf, phys_addr_t rx_buf, u32 pg_cnt) · 204 unmodified lines
205205 return 0;
206206 }
207207
208−static int ffa_rxtx_unmap(u16 vm_id)
208+static int ffa_rxtx_unmap(void)
209209 {
210210 ffa_value_t ret;
211211
212212 invoke_ffa_fn((ffa_value_t){
213− .a0 = FFA_RXTX_UNMAP, .a1 = PACK_TARGET_INFO(vm_id, 0),
213+ .a0 = FFA_RXTX_UNMAP,
214214 }, &ret);
215215
216216 if (ret.a0 == FFA_ERROR)
@@ -2097,7 +2097,7 @@ static int __init ffa_init(void) · 1880 unmodified lines
20972097
20982098 pr_err("failed to setup partitions\n");
20992099 ffa_notifications_cleanup();
2100− ffa_rxtx_unmap(drv_info->vm_id);
2100+ ffa_rxtx_unmap();
21012101 free_pages:
21022102 if (drv_info->tx_buffer)
21032103 free_pages_exact(drv_info->tx_buffer, rxtx_bufsz);
@@ -2112,7 +2112,7 @@ static void __exit ffa_exit(void) · 8 unmodified lines
21122112 {
21132113 ffa_notifications_cleanup();
21142114 ffa_partitions_cleanup();
2115− ffa_rxtx_unmap(drv_info->vm_id);
2115+ ffa_rxtx_unmap();
21162116 free_pages_exact(drv_info->tx_buffer, drv_info->rxtx_bufsz);
21172117 free_pages_exact(drv_info->rx_buffer, drv_info->rxtx_bufsz);
21182118 kfree(drv_info);
drivers/firmware/arm_scmi/notify.c+2−2
@@ -1066,7 +1066,7 @@ static int scmi_register_event_handler(struct scmi_notify_instance *ni, · 1065 unmodified lines
10661066 * since at creation time we usually want to have all setup and ready before
10671067 * events really start flowing.
10681068 *
1069− * Return: A properly refcounted handler on Success, NULL on Failure
1069+ * Return: A properly refcounted handler on Success, ERR_PTR on Failure
10701070 */
10711071 static inline struct scmi_event_handler *
10721072 __scmi_event_handler_get_ops(struct scmi_notify_instance *ni,
@@ -1113,7 +1113,7 @@ __scmi_event_handler_get_ops(struct scmi_notify_instance *ni, · 40 unmodified lines
11131113 }
11141114 mutex_unlock(&ni->pending_mtx);
11151115
1116− return hndl;
1116+ return hndl ?: ERR_PTR(-ENODEV);
11171117 }
11181118
11191119 static struct scmi_event_handler *
drivers/firmware/arm_scmi/protocols.h+2−2
@@ -189,13 +189,13 @@ struct scmi_protocol_handle { · 188 unmodified lines
189189
190190 /**
191191 * struct scmi_iterator_state - Iterator current state descriptor
192− * @desc_index: Starting index for the current mulit-part request.
192+ * @desc_index: Starting index for the current multi-part request.
193193 * @num_returned: Number of returned items in the last multi-part reply.
194194 * @num_remaining: Number of remaining items in the multi-part message.
195195 * @max_resources: Maximum acceptable number of items, configured by the caller
196196 * depending on the underlying resources that it is querying.
197197 * @loop_idx: The iterator loop index in the current multi-part reply.
198− * @rx_len: Size in bytes of the currenly processed message; it can be used by
198+ * @rx_len: Size in bytes of the currently processed message; it can be used by
199199 * the user of the iterator to verify a reply size.
200200 * @priv: Optional pointer to some additional state-related private data setup
201201 * by the caller during the iterations.
drivers/firmware/arm_scpi.c+3−2
@@ -18,6 +18,7 @@ · 17 unmodified lines
1818
1919 #include <linux/bitmap.h>
2020 #include <linux/bitfield.h>
21+#include <linux/cleanup.h>
2122 #include <linux/device.h>
2223 #include <linux/err.h>
2324 #include <linux/export.h>
@@ -940,13 +941,13 @@ static int scpi_probe(struct platform_device *pdev) · 916 unmodified lines
940941 int idx = scpi_drvinfo->num_chans;
941942 struct scpi_chan *pchan = scpi_drvinfo->channels + idx;
942943 struct mbox_client *cl = &pchan->cl;
943− struct device_node *shmem = of_parse_phandle(np, "shmem", idx);
944+ struct device_node *shmem __free(device_node) =
945+ of_parse_phandle(np, "shmem", idx);
944946
945947 if (!of_match_node(shmem_of_match, shmem))
946948 return -ENXIO;
947949
948950 ret = of_address_to_resource(shmem, 0, &res);
949− of_node_put(shmem);
950951 if (ret) {
951952 dev_err(dev, "failed to get SCPI payload mem resource\n");
952953 return ret;
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c+4−0
@@ -36,6 +36,7 @@ · 35 unmodified lines
3636
3737 #define AMDGPU_BO_LIST_MAX_PRIORITY 32u
3838 #define AMDGPU_BO_LIST_NUM_BUCKETS (AMDGPU_BO_LIST_MAX_PRIORITY + 1)
39+#define AMDGPU_BO_LIST_MAX_ENTRIES (128 * 1024)
3940
4041 static void amdgpu_bo_list_free_rcu(struct rcu_head *rcu)
4142 {
@@ -188,6 +189,9 @@ int amdgpu_bo_create_list_entry_array(struct drm_amdgpu_bo_list_in *in, · 146 unmodified lines
188189 const uint32_t bo_number = in->bo_number;
189190 struct drm_amdgpu_bo_list_entry *info;
190191
192+ if (bo_number > AMDGPU_BO_LIST_MAX_ENTRIES)
193+ return -EINVAL;
194+
191195 /* copy the handle array from userspace to a kernel buffer */
192196 if (likely(info_size == bo_info_size)) {
193197 info = vmemdup_array_user(uptr, bo_number, info_size);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c+6−1
@@ -1069,7 +1069,10 @@ amdgpu_vm_tlb_flush(struct amdgpu_vm_update_params *params, · 1068 unmodified lines
10691069 }
10701070
10711071 /* Prepare a TLB flush fence to be attached to PTs */
1072− if (!params->unlocked) {
1072+ /* The check for need_tlb_fence should be dropped once we
1073+ * sort out the issues with KIQ/MES TLB invalidation timeouts.
1074+ */
1075+ if (!params->unlocked && vm->need_tlb_fence) {
10731076 amdgpu_vm_tlb_fence_create(params->adev, vm, fence);
10741077
10751078 /* Makes sure no PD/PT is freed before the flush */
@@ -2602,6 +2605,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm, · 1526 unmodified lines
26022605 ttm_lru_bulk_move_init(&vm->lru_bulk_move);
26032606
26042607 vm->is_compute_context = false;
2608+ vm->need_tlb_fence = amdgpu_userq_enabled(&adev->ddev);
26052609
26062610 vm->use_cpu_for_update = !!(adev->vm_manager.vm_update_mode &
26072611 AMDGPU_VM_USE_CPU_FOR_GFX);
@@ -2739,6 +2743,7 @@ int amdgpu_vm_make_compute(struct amdgpu_device *adev, struct amdgpu_vm *vm) · 131 unmodified lines
27392743 dma_fence_put(vm->last_update);
27402744 vm->last_update = dma_fence_get_stub();
27412745 vm->is_compute_context = true;
2746+ vm->need_tlb_fence = true;
27422747
27432748 unreserve_bo:
27442749 amdgpu_bo_unreserve(vm->root.bo);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h+2−0
@@ -441,6 +441,8 @@ struct amdgpu_vm { · 440 unmodified lines
441441 struct ttm_lru_bulk_move lru_bulk_move;
442442 /* Flag to indicate if VM is used for compute */
443443 bool is_compute_context;
444+ /* Flag to indicate if VM needs a TLB fence (KFD or KGD) */
445+ bool need_tlb_fence;
444446
445447 /* Memory partition number, -1 means any partition */
446448 int8_t mem_id;
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c+14−7
@@ -662,28 +662,35 @@ static int gmc_v9_0_process_interrupt(struct amdgpu_device *adev, · 661 unmodified lines
662662 } else {
663663 switch (amdgpu_ip_version(adev, MMHUB_HWIP, 0)) {
664664 case IP_VERSION(9, 0, 0):
665− mmhub_cid = mmhub_client_ids_vega10[cid][rw];
665+ mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_vega10) ?
666+ mmhub_client_ids_vega10[cid][rw] : NULL;
666667 break;
667668 case IP_VERSION(9, 3, 0):
668− mmhub_cid = mmhub_client_ids_vega12[cid][rw];
669+ mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_vega12) ?
670+ mmhub_client_ids_vega12[cid][rw] : NULL;
669671 break;
670672 case IP_VERSION(9, 4, 0):
671− mmhub_cid = mmhub_client_ids_vega20[cid][rw];
673+ mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_vega20) ?
674+ mmhub_client_ids_vega20[cid][rw] : NULL;
672675 break;
673676 case IP_VERSION(9, 4, 1):
674− mmhub_cid = mmhub_client_ids_arcturus[cid][rw];
677+ mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_arcturus) ?
678+ mmhub_client_ids_arcturus[cid][rw] : NULL;
675679 break;
676680 case IP_VERSION(9, 1, 0):
677681 case IP_VERSION(9, 2, 0):
678− mmhub_cid = mmhub_client_ids_raven[cid][rw];
682+ mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_raven) ?
683+ mmhub_client_ids_raven[cid][rw] : NULL;
679684 break;
680685 case IP_VERSION(1, 5, 0):
681686 case IP_VERSION(2, 4, 0):
682− mmhub_cid = mmhub_client_ids_renoir[cid][rw];
687+ mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_renoir) ?
688+ mmhub_client_ids_renoir[cid][rw] : NULL;
683689 break;
684690 case IP_VERSION(1, 8, 0):
685691 case IP_VERSION(9, 4, 2):
686− mmhub_cid = mmhub_client_ids_aldebaran[cid][rw];
692+ mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_aldebaran) ?
693+ mmhub_client_ids_aldebaran[cid][rw] : NULL;
687694 break;
688695 default:
689696 mmhub_cid = NULL;
drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c+2−2
@@ -129,7 +129,7 @@ static int isp_genpd_add_device(struct device *dev, void *data) · 128 unmodified lines
129129 if (!pdev)
130130 return -EINVAL;
131131
132− if (!dev->type->name) {
132+ if (!dev->type || !dev->type->name) {
133133 drm_dbg(&adev->ddev, "Invalid device type to add\n");
134134 goto exit;
135135 }
@@ -165,7 +165,7 @@ static int isp_genpd_remove_device(struct device *dev, void *data) · 29 unmodified lines
165165 if (!pdev)
166166 return -EINVAL;
167167
168− if (!dev->type->name) {
168+ if (!dev->type || !dev->type->name) {
169169 drm_dbg(&adev->ddev, "Invalid device type to remove\n");
170170 goto exit;
171171 }
drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c+6−3
@@ -154,14 +154,17 @@ mmhub_v2_0_print_l2_protection_fault_status(struct amdgpu_device *adev, · 153 unmodified lines
154154 switch (amdgpu_ip_version(adev, MMHUB_HWIP, 0)) {
155155 case IP_VERSION(2, 0, 0):
156156 case IP_VERSION(2, 0, 2):
157− mmhub_cid = mmhub_client_ids_navi1x[cid][rw];
157+ mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_navi1x) ?
158+ mmhub_client_ids_navi1x[cid][rw] : NULL;
158159 break;
159160 case IP_VERSION(2, 1, 0):
160161 case IP_VERSION(2, 1, 1):
161− mmhub_cid = mmhub_client_ids_sienna_cichlid[cid][rw];
162+ mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_sienna_cichlid) ?
163+ mmhub_client_ids_sienna_cichlid[cid][rw] : NULL;
162164 break;
163165 case IP_VERSION(2, 1, 2):
164− mmhub_cid = mmhub_client_ids_beige_goby[cid][rw];
166+ mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_beige_goby) ?
167+ mmhub_client_ids_beige_goby[cid][rw] : NULL;
165168 break;
166169 default:
167170 mmhub_cid = NULL;
drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c+2−1
@@ -94,7 +94,8 @@ mmhub_v2_3_print_l2_protection_fault_status(struct amdgpu_device *adev, · 93 unmodified lines
9494 case IP_VERSION(2, 3, 0):
9595 case IP_VERSION(2, 4, 0):
9696 case IP_VERSION(2, 4, 1):
97− mmhub_cid = mmhub_client_ids_vangogh[cid][rw];
97+ mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_vangogh) ?
98+ mmhub_client_ids_vangogh[cid][rw] : NULL;
9899 break;
99100 default:
100101 mmhub_cid = NULL;
drivers/gpu/drm/amd/amdgpu/mmhub_v3_0.c+2−1
@@ -110,7 +110,8 @@ mmhub_v3_0_print_l2_protection_fault_status(struct amdgpu_device *adev, · 109 unmodified lines
110110 switch (amdgpu_ip_version(adev, MMHUB_HWIP, 0)) {
111111 case IP_VERSION(3, 0, 0):
112112 case IP_VERSION(3, 0, 1):
113− mmhub_cid = mmhub_client_ids_v3_0_0[cid][rw];
113+ mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_v3_0_0) ?
114+ mmhub_client_ids_v3_0_0[cid][rw] : NULL;
114115 break;
115116 default:
116117 mmhub_cid = NULL;
drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_1.c+2−1
@@ -117,7 +117,8 @@ mmhub_v3_0_1_print_l2_protection_fault_status(struct amdgpu_device *adev, · 116 unmodified lines
117117
118118 switch (amdgpu_ip_version(adev, MMHUB_HWIP, 0)) {
119119 case IP_VERSION(3, 0, 1):
120− mmhub_cid = mmhub_client_ids_v3_0_1[cid][rw];
120+ mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_v3_0_1) ?
121+ mmhub_client_ids_v3_0_1[cid][rw] : NULL;
121122 break;
122123 default:
123124 mmhub_cid = NULL;
drivers/gpu/drm/amd/amdgpu/mmhub_v3_0_2.c+2−1
@@ -108,7 +108,8 @@ mmhub_v3_0_2_print_l2_protection_fault_status(struct amdgpu_device *adev, · 107 unmodified lines
108108 "MMVM_L2_PROTECTION_FAULT_STATUS:0x%08X\n",
109109 status);
110110
111− mmhub_cid = mmhub_client_ids_v3_0_2[cid][rw];
111+ mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_v3_0_2) ?
112+ mmhub_client_ids_v3_0_2[cid][rw] : NULL;
112113 dev_err(adev->dev, "\t Faulty UTCL2 client ID: %s (0x%x)\n",
113114 mmhub_cid ? mmhub_cid : "unknown", cid);
114115 dev_err(adev->dev, "\t MORE_FAULTS: 0x%lx\n",
drivers/gpu/drm/amd/amdgpu/mmhub_v4_1_0.c+2−1
@@ -102,7 +102,8 @@ mmhub_v4_1_0_print_l2_protection_fault_status(struct amdgpu_device *adev, · 101 unmodified lines
102102 status);
103103 switch (amdgpu_ip_version(adev, MMHUB_HWIP, 0)) {
104104 case IP_VERSION(4, 1, 0):
105− mmhub_cid = mmhub_client_ids_v4_1_0[cid][rw];
105+ mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_v4_1_0) ?
106+ mmhub_client_ids_v4_1_0[cid][rw] : NULL;
106107 break;
107108 default:
108109 mmhub_cid = NULL;
drivers/gpu/drm/amd/amdgpu/mmhub_v4_2_0.c+2−1
@@ -688,7 +688,8 @@ mmhub_v4_2_0_print_l2_protection_fault_status(struct amdgpu_device *adev, · 687 unmodified lines
688688 status);
689689 switch (amdgpu_ip_version(adev, MMHUB_HWIP, 0)) {
690690 case IP_VERSION(4, 2, 0):
691− mmhub_cid = mmhub_client_ids_v4_2_0[cid][rw];
691+ mmhub_cid = cid < ARRAY_SIZE(mmhub_client_ids_v4_2_0) ?
692+ mmhub_client_ids_v4_2_0[cid][rw] : NULL;
692693 break;
693694 default:
694695 mmhub_cid = NULL;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c+3−3
@@ -2554,7 +2554,7 @@ static int dm_dmub_sw_init(struct amdgpu_device *adev) · 2553 unmodified lines
25542554 fw_meta_info_params.fw_inst_const = adev->dm.dmub_fw->data +
25552555 le32_to_cpu(hdr->header.ucode_array_offset_bytes) +
25562556 PSP_HEADER_BYTES_256;
2557− fw_meta_info_params.fw_bss_data = region_params.bss_data_size ? adev->dm.dmub_fw->data +
2557+ fw_meta_info_params.fw_bss_data = fw_meta_info_params.bss_data_size ? adev->dm.dmub_fw->data +
25582558 le32_to_cpu(hdr->header.ucode_array_offset_bytes) +
25592559 le32_to_cpu(hdr->inst_const_bytes) : NULL;
25602560 fw_meta_info_params.custom_psp_footer_size = 0;
@@ -13119,7 +13119,7 @@ static void parse_edid_displayid_vrr(struct drm_connector *connector, · 10558 unmodified lines
1311913119 u16 min_vfreq;
1312013120 u16 max_vfreq;
1312113121
13122− if (edid == NULL || edid->extensions == 0)
13122+ if (!edid || !edid->extensions)
1312313123 return;
1312413124
1312513125 /* Find DisplayID extension */
@@ -13129,7 +13129,7 @@ static void parse_edid_displayid_vrr(struct drm_connector *connector, · 3 unmodified lines
1312913129 break;
1313013130 }
1313113131
13132− if (edid_ext == NULL)
13132+ if (i == edid->extensions)
1313313133 return;
1313413134
1313513135 while (j < EDID_LENGTH) {
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c+3−3
@@ -37,19 +37,19 @@ const u64 amdgpu_dm_supported_degam_tfs = · 36 unmodified lines
3737 BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) |
3838 BIT(DRM_COLOROP_1D_CURVE_PQ_125_EOTF) |
3939 BIT(DRM_COLOROP_1D_CURVE_BT2020_INV_OETF) |
40− BIT(DRM_COLOROP_1D_CURVE_GAMMA22_INV);
40+ BIT(DRM_COLOROP_1D_CURVE_GAMMA22);
4141
4242 const u64 amdgpu_dm_supported_shaper_tfs =
4343 BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF) |
4444 BIT(DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF) |
4545 BIT(DRM_COLOROP_1D_CURVE_BT2020_OETF) |
46− BIT(DRM_COLOROP_1D_CURVE_GAMMA22);
46+ BIT(DRM_COLOROP_1D_CURVE_GAMMA22_INV);
4747
4848 const u64 amdgpu_dm_supported_blnd_tfs =
4949 BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) |
5050 BIT(DRM_COLOROP_1D_CURVE_PQ_125_EOTF) |
5151 BIT(DRM_COLOROP_1D_CURVE_BT2020_INV_OETF) |
52− BIT(DRM_COLOROP_1D_CURVE_GAMMA22_INV);
52+ BIT(DRM_COLOROP_1D_CURVE_GAMMA22);
5353
5454 #define MAX_COLOR_PIPELINE_OPS 10
5555
drivers/gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c+4−4
@@ -255,6 +255,10 @@ struct clk_mgr *dc_clk_mgr_create(struct dc_context *ctx, struct pp_smu_funcs *p · 254 unmodified lines
255255 BREAK_TO_DEBUGGER();
256256 return NULL;
257257 }
258+ if (ctx->dce_version == DCN_VERSION_2_01) {
259+ dcn201_clk_mgr_construct(ctx, clk_mgr, pp_smu, dccg);
260+ return &clk_mgr->base;
261+ }
258262 if (ASICREV_IS_SIENNA_CICHLID_P(asic_id.hw_internal_rev)) {
259263 dcn3_clk_mgr_construct(ctx, clk_mgr, pp_smu, dccg);
260264 return &clk_mgr->base;
@@ -267,10 +271,6 @@ struct clk_mgr *dc_clk_mgr_create(struct dc_context *ctx, struct pp_smu_funcs *p · 6 unmodified lines
267271 dcn3_clk_mgr_construct(ctx, clk_mgr, pp_smu, dccg);
268272 return &clk_mgr->base;
269273 }
270− if (ctx->dce_version == DCN_VERSION_2_01) {
271− dcn201_clk_mgr_construct(ctx, clk_mgr, pp_smu, dccg);
272− return &clk_mgr->base;
273− }
274274 dcn20_clk_mgr_construct(ctx, clk_mgr, pp_smu, dccg);
275275 return &clk_mgr->base;
276276 }
drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c+3−0
@@ -1785,7 +1785,10 @@ static bool dml1_validate(struct dc *dc, struct dc_state *context, enum dc_valid · 1784 unmodified lines
17851785
17861786 dc->res_pool->funcs->calculate_wm_and_dlg(dc, context, pipes, pipe_cnt, vlevel);
17871787
1788+ DC_FP_START();
17881789 dcn32_override_min_req_memclk(dc, context);
1790+ DC_FP_END();
1791+
17891792 dcn32_override_min_req_dcfclk(dc, context);
17901793
17911794 BW_VAL_TRACE_END_WATERMARKS();
drivers/gpu/drm/amd/pm/legacy-dpm/si_dpm.c+3−1
@@ -3454,9 +3454,11 @@ static void si_apply_state_adjust_rules(struct amdgpu_device *adev, · 3453 unmodified lines
34543454 if (adev->asic_type == CHIP_HAINAN) {
34553455 if ((adev->pdev->revision == 0x81) ||
34563456 (adev->pdev->revision == 0xC3) ||
3457+ (adev->pdev->device == 0x6660) ||
34573458 (adev->pdev->device == 0x6664) ||
34583459 (adev->pdev->device == 0x6665) ||
3459− (adev->pdev->device == 0x6667)) {
3460+ (adev->pdev->device == 0x6667) ||
3461+ (adev->pdev->device == 0x666F)) {
34603462 max_sclk = 75000;
34613463 }
34623464 if ((adev->pdev->revision == 0xC3) ||
drivers/gpu/drm/bridge/synopsys/dw-hdmi-qp.c+1−1
@@ -848,7 +848,7 @@ static int dw_hdmi_qp_config_audio_infoframe(struct dw_hdmi_qp *hdmi, · 847 unmodified lines
848848
849849 regmap_bulk_write(hdmi->regm, PKT_AUDI_CONTENTS0, &header_bytes, 1);
850850 regmap_bulk_write(hdmi->regm, PKT_AUDI_CONTENTS1, &buffer[3], 1);
851− regmap_bulk_write(hdmi->regm, PKT_AUDI_CONTENTS2, &buffer[4], 1);
851+ regmap_bulk_write(hdmi->regm, PKT_AUDI_CONTENTS2, &buffer[7], 1);
852852
853853 /* Enable ACR, AUDI, AMD */
854854 dw_hdmi_qp_mod(hdmi,
drivers/gpu/drm/drm_file.c+4−1
@@ -233,6 +233,7 @@ static void drm_events_release(struct drm_file *file_priv) · 232 unmodified lines
233233 void drm_file_free(struct drm_file *file)
234234 {
235235 struct drm_device *dev;
236+ int idx;
236237
237238 if (!file)
238239 return;
@@ -249,9 +250,11 @@ void drm_file_free(struct drm_file *file) · 10 unmodified lines
249250
250251 drm_events_release(file);
251252
252− if (drm_core_check_feature(dev, DRIVER_MODESET)) {
253+ if (drm_core_check_feature(dev, DRIVER_MODESET) &&
254+ drm_dev_enter(dev, &idx)) {
253255 drm_fb_release(file);
254256 drm_property_destroy_user_blobs(dev, file);
257+ drm_dev_exit(idx);
255258 }
256259
257260 if (drm_core_check_feature(dev, DRIVER_SYNCOBJ))
drivers/gpu/drm/drm_mode_config.c+6−3
@@ -577,10 +577,13 @@ void drm_mode_config_cleanup(struct drm_device *dev) · 576 unmodified lines
577577 */
578578 WARN_ON(!list_empty(&dev->mode_config.fb_list));
579579 list_for_each_entry_safe(fb, fbt, &dev->mode_config.fb_list, head) {
580− struct drm_printer p = drm_dbg_printer(dev, DRM_UT_KMS, "[leaked fb]");
580+ if (list_empty(&fb->filp_head) || drm_framebuffer_read_refcount(fb) > 1) {
581+ struct drm_printer p = drm_dbg_printer(dev, DRM_UT_KMS, "[leaked fb]");
581582
582− drm_printf(&p, "framebuffer[%u]:\n", fb->base.id);
583− drm_framebuffer_print_info(&p, 1, fb);
583+ drm_printf(&p, "framebuffer[%u]:\n", fb->base.id);
584+ drm_framebuffer_print_info(&p, 1, fb);
585+ }
586+ list_del_init(&fb->filp_head);
584587 drm_framebuffer_free(&fb->base.refcount);
585588 }
586589
drivers/gpu/drm/drm_pagemap_util.c+5−9
@@ -65,18 +65,14 @@ static void drm_pagemap_cache_fini(void *arg) · 64 unmodified lines
6565 drm_dbg(cache->shrinker->drm, "Destroying dpagemap cache.\n");
6666 spin_lock(&cache->lock);
6767 dpagemap = cache->dpagemap;
68− if (!dpagemap) {
69− spin_unlock(&cache->lock);
70− goto out;
71− }
68+ cache->dpagemap = NULL;
69+ if (dpagemap && !drm_pagemap_shrinker_cancel(dpagemap))
70+ dpagemap = NULL;
71+ spin_unlock(&cache->lock);
7272
73− if (drm_pagemap_shrinker_cancel(dpagemap)) {
74− cache->dpagemap = NULL;
75− spin_unlock(&cache->lock);
73+ if (dpagemap)
7674 drm_pagemap_destroy(dpagemap, false);
77− }
7875
79−out:
8076 mutex_destroy(&cache->lookup_mutex);
8177 kfree(cache);
8278 }
drivers/gpu/drm/i915/display/intel_display_power_well.c+1−1
@@ -806,7 +806,7 @@ void gen9_set_dc_state(struct intel_display *display, u32 state) · 805 unmodified lines
806806 power_domains->dc_state, val & mask);
807807
808808 enable_dc6 = state & DC_STATE_EN_UPTO_DC6;
809− dc6_was_enabled = val & DC_STATE_EN_UPTO_DC6;
809+ dc6_was_enabled = power_domains->dc_state & DC_STATE_EN_UPTO_DC6;
810810 if (!dc6_was_enabled && enable_dc6)
811811 intel_dmc_update_dc6_allowed_count(display, true);
812812
drivers/gpu/drm/i915/display/intel_display_types.h+1−0
@@ -1186,6 +1186,7 @@ struct intel_crtc_state { · 1185 unmodified lines
11861186 u32 dc3co_exitline;
11871187 u16 su_y_granularity;
11881188 u8 active_non_psr_pipes;
1189+ u8 entry_setup_frames;
11891190 const char *no_psr_reason;
11901191
11911192 /*
drivers/gpu/drm/i915/display/intel_dmc.c+1−2
@@ -1599,8 +1599,7 @@ static bool intel_dmc_get_dc6_allowed_count(struct intel_display *display, u32 * · 1598 unmodified lines
15991599 return false;
16001600
16011601 mutex_lock(&power_domains->lock);
1602− dc6_enabled = intel_de_read(display, DC_STATE_EN) &
1603− DC_STATE_EN_UPTO_DC6;
1602+ dc6_enabled = power_domains->dc_state & DC_STATE_EN_UPTO_DC6;
16041603 if (dc6_enabled)
16051604 intel_dmc_update_dc6_allowed_count(display, false);
16061605
drivers/gpu/drm/i915/display/intel_psr.c+5−2
@@ -1717,7 +1717,7 @@ static bool _psr_compute_config(struct intel_dp *intel_dp, · 1716 unmodified lines
17171717 entry_setup_frames = intel_psr_entry_setup_frames(intel_dp, conn_state, adjusted_mode);
17181718
17191719 if (entry_setup_frames >= 0) {
1720− intel_dp->psr.entry_setup_frames = entry_setup_frames;
1720+ crtc_state->entry_setup_frames = entry_setup_frames;
17211721 } else {
17221722 crtc_state->no_psr_reason = "PSR setup timing not met";
17231723 drm_dbg_kms(display->drm,
@@ -1815,7 +1815,7 @@ static bool intel_psr_needs_wa_18037818876(struct intel_dp *intel_dp, · 91 unmodified lines
18151815 {
18161816 struct intel_display *display = to_intel_display(intel_dp);
18171817
1818− return (DISPLAY_VER(display) == 20 && intel_dp->psr.entry_setup_frames > 0 &&
1818+ return (DISPLAY_VER(display) == 20 && crtc_state->entry_setup_frames > 0 &&
18191819 !crtc_state->has_sel_update);
18201820 }
18211821
@@ -2189,6 +2189,7 @@ static void intel_psr_enable_locked(struct intel_dp *intel_dp, · 367 unmodified lines
21892189 intel_dp->psr.pkg_c_latency_used = crtc_state->pkg_c_latency_used;
21902190 intel_dp->psr.io_wake_lines = crtc_state->alpm_state.io_wake_lines;
21912191 intel_dp->psr.fast_wake_lines = crtc_state->alpm_state.fast_wake_lines;
2192+ intel_dp->psr.entry_setup_frames = crtc_state->entry_setup_frames;
21922193
21932194 if (!psr_interrupt_error_check(intel_dp))
21942195 return;
@@ -3109,6 +3110,8 @@ void intel_psr_pre_plane_update(struct intel_atomic_state *state, · 914 unmodified lines
31093110 * - Display WA #1136: skl, bxt
31103111 */
31113112 if (intel_crtc_needs_modeset(new_crtc_state) ||
3113+ new_crtc_state->update_m_n ||
3114+ new_crtc_state->update_lrr ||
31123115 !new_crtc_state->has_psr ||
31133116 !new_crtc_state->active_planes ||
31143117 new_crtc_state->has_sel_update != psr->sel_update_enabled ||
drivers/gpu/drm/i915/gt/intel_engine_cs.c+2−1
@@ -1967,7 +1967,8 @@ void intel_engines_reset_default_submission(struct intel_gt *gt) · 1966 unmodified lines
19671967 if (engine->sanitize)
19681968 engine->sanitize(engine);
19691969
1970− engine->set_default_submission(engine);
1970+ if (engine->set_default_submission)
1971+ engine->set_default_submission(engine);
19711972 }
19721973 }
19731974
drivers/gpu/drm/imagination/pvr_device.c+0−17
@@ -225,29 +225,12 @@ static irqreturn_t pvr_device_irq_thread_handler(int irq, void *data) · 224 unmodified lines
225225 }
226226
227227 if (pvr_dev->has_safety_events) {
228− int err;
229−
230− /*
231− * Ensure the GPU is powered on since some safety events (such
232− * as ECC faults) can happen outside of job submissions, which
233− * are otherwise the only time a power reference is held.
234− */
235− err = pvr_power_get(pvr_dev);
236− if (err) {
237− drm_err_ratelimited(drm_dev,
238− "%s: could not take power reference (%d)\n",
239− __func__, err);
240− return ret;
241− }
242−
243228 while (pvr_device_safety_irq_pending(pvr_dev)) {
244229 pvr_device_safety_irq_clear(pvr_dev);
245230 pvr_device_handle_safety_events(pvr_dev);
246231
247232 ret = IRQ_HANDLED;
248233 }
249−
250− pvr_power_put(pvr_dev);
251234 }
252235
253236 return ret;
drivers/gpu/drm/imagination/pvr_power.c+39−12
@@ -90,11 +90,11 @@ pvr_power_request_pwr_off(struct pvr_device *pvr_dev) · 89 unmodified lines
9090 }
9191
9292 static int
93−pvr_power_fw_disable(struct pvr_device *pvr_dev, bool hard_reset)
93+pvr_power_fw_disable(struct pvr_device *pvr_dev, bool hard_reset, bool rpm_suspend)
9494 {
95− if (!hard_reset) {
96− int err;
95+ int err;
9796
97+ if (!hard_reset) {
9898 cancel_delayed_work_sync(&pvr_dev->watchdog.work);
9999
100100 err = pvr_power_request_idle(pvr_dev);
@@ -106,29 +106,47 @@ pvr_power_fw_disable(struct pvr_device *pvr_dev, bool hard_reset) · 5 unmodified lines
106106 return err;
107107 }
108108
109− return pvr_fw_stop(pvr_dev);
109+ if (rpm_suspend) {
110+ /* This also waits for late processing of GPU or firmware IRQs in other cores */
111+ disable_irq(pvr_dev->irq);
112+ }
113+
114+ err = pvr_fw_stop(pvr_dev);
115+ if (err && rpm_suspend)
116+ enable_irq(pvr_dev->irq);
117+
118+ return err;
110119 }
111120
112121 static int
113−pvr_power_fw_enable(struct pvr_device *pvr_dev)
122+pvr_power_fw_enable(struct pvr_device *pvr_dev, bool rpm_resume)
114123 {
115124 int err;
116125
126+ if (rpm_resume)
127+ enable_irq(pvr_dev->irq);
128+
117129 err = pvr_fw_start(pvr_dev);
118130 if (err)
119− return err;
131+ goto out;
120132
121133 err = pvr_wait_for_fw_boot(pvr_dev);
122134 if (err) {
123135 drm_err(from_pvr_device(pvr_dev), "Firmware failed to boot\n");
124136 pvr_fw_stop(pvr_dev);
125− return err;
137+ goto out;
126138 }
127139
128140 queue_delayed_work(pvr_dev->sched_wq, &pvr_dev->watchdog.work,
129141 msecs_to_jiffies(WATCHDOG_TIME_MS));
130142
131143 return 0;
144+
145+out:
146+ if (rpm_resume)
147+ disable_irq(pvr_dev->irq);
148+
149+ return err;
132150 }
133151
134152 bool
@@ -361,7 +379,7 @@ pvr_power_device_suspend(struct device *dev) · 226 unmodified lines
361379 return -EIO;
362380
363381 if (pvr_dev->fw_dev.booted) {
364− err = pvr_power_fw_disable(pvr_dev, false);
382+ err = pvr_power_fw_disable(pvr_dev, false, true);
365383 if (err)
366384 goto err_drm_dev_exit;
367385 }
@@ -391,7 +409,7 @@ pvr_power_device_resume(struct device *dev) · 23 unmodified lines
391409 goto err_drm_dev_exit;
392410
393411 if (pvr_dev->fw_dev.booted) {
394− err = pvr_power_fw_enable(pvr_dev);
412+ err = pvr_power_fw_enable(pvr_dev, true);
395413 if (err)
396414 goto err_power_off;
397415 }
@@ -510,7 +528,16 @@ pvr_power_reset(struct pvr_device *pvr_dev, bool hard_reset) · 112 unmodified lines
510528 }
511529
512530 /* Disable IRQs for the duration of the reset. */
513− disable_irq(pvr_dev->irq);
531+ if (hard_reset) {
532+ disable_irq(pvr_dev->irq);
533+ } else {
534+ /*
535+ * Soft reset is triggered as a response to a FW command to the Host and is
536+ * processed from the threaded IRQ handler. This code cannot (nor needs to)
537+ * wait for any IRQ processing to complete.
538+ */
539+ disable_irq_nosync(pvr_dev->irq);
540+ }
514541
515542 do {
516543 if (hard_reset) {
@@ -518,7 +545,7 @@ pvr_power_reset(struct pvr_device *pvr_dev, bool hard_reset) · 1 unmodified line
518545 queues_disabled = true;
519546 }
520547
521− err = pvr_power_fw_disable(pvr_dev, hard_reset);
548+ err = pvr_power_fw_disable(pvr_dev, hard_reset, false);
522549 if (!err) {
523550 if (hard_reset) {
524551 pvr_dev->fw_dev.booted = false;
@@ -541,7 +568,7 @@ pvr_power_reset(struct pvr_device *pvr_dev, bool hard_reset) · 16 unmodified lines
541568
542569 pvr_fw_irq_clear(pvr_dev);
543570
544− err = pvr_power_fw_enable(pvr_dev);
571+ err = pvr_power_fw_enable(pvr_dev, false);
545572 }
546573
547574 if (err && hard_reset)
drivers/gpu/drm/radeon/si_dpm.c+3−1
@@ -2915,9 +2915,11 @@ static void si_apply_state_adjust_rules(struct radeon_device *rdev, · 2914 unmodified lines
29152915 if (rdev->family == CHIP_HAINAN) {
29162916 if ((rdev->pdev->revision == 0x81) ||
29172917 (rdev->pdev->revision == 0xC3) ||
2918+ (rdev->pdev->device == 0x6660) ||
29182919 (rdev->pdev->device == 0x6664) ||
29192920 (rdev->pdev->device == 0x6665) ||
2920− (rdev->pdev->device == 0x6667)) {
2921+ (rdev->pdev->device == 0x6667) ||
2922+ (rdev->pdev->device == 0x666F)) {
29212923 max_sclk = 75000;
29222924 }
29232925 if ((rdev->pdev->revision == 0xC3) ||
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h+57−36
@@ -96,12 +96,17 @@ struct vmwgfx_hash_item { · 95 unmodified lines
9696
9797 struct vmw_res_func;
9898
99+struct vmw_bo;
100+struct vmw_bo;
101+struct vmw_resource_dirty;
102+
99103 /**
100− * struct vmw-resource - base class for hardware resources
104+ * struct vmw_resource - base class for hardware resources
101105 *
102106 * @kref: For refcounting.
103107 * @dev_priv: Pointer to the device private for this resource. Immutable.
104108 * @id: Device id. Protected by @dev_priv::resource_lock.
109+ * @used_prio: Priority for this resource.
105110 * @guest_memory_size: Guest memory buffer size. Immutable.
106111 * @res_dirty: Resource contains data not yet in the guest memory buffer.
107112 * Protected by resource reserved.
@@ -117,18 +122,16 @@ struct vmw_res_func; · 9 unmodified lines
117122 * pin-count greater than zero. It is not on the resource LRU lists and its
118123 * guest memory buffer is pinned. Hence it can't be evicted.
119124 * @func: Method vtable for this resource. Immutable.
120− * @mob_node; Node for the MOB guest memory rbtree. Protected by
125+ * @mob_node: Node for the MOB guest memory rbtree. Protected by
121126 * @guest_memory_bo reserved.
122127 * @lru_head: List head for the LRU list. Protected by @dev_priv::resource_lock.
123128 * @binding_head: List head for the context binding list. Protected by
124129 * the @dev_priv::binding_mutex
130+ * @dirty: resource's dirty tracker
125131 * @res_free: The resource destructor.
126132 * @hw_destroy: Callback to destroy the resource on the device, as part of
127133 * resource destruction.
128134 */
129−struct vmw_bo;
130−struct vmw_bo;
131−struct vmw_resource_dirty;
132135 struct vmw_resource {
133136 struct kref kref;
134137 struct vmw_private *dev_priv;
@@ -196,8 +199,8 @@ struct vmw_surface_offset; · 61 unmodified lines
196199 * @quality_level: Quality level.
197200 * @autogen_filter: Filter for automatically generated mipmaps.
198201 * @array_size: Number of array elements for a 1D/2D texture. For cubemap
199− texture number of faces * array_size. This should be 0 for pre
200− SM4 device.
202+ * texture number of faces * array_size. This should be 0 for pre
203+ * SM4 device.
201204 * @buffer_byte_stride: Buffer byte stride.
202205 * @num_sizes: Size of @sizes. For GB surface this should always be 1.
203206 * @base_size: Surface dimension.
@@ -265,18 +268,24 @@ struct vmw_fifo_state { · 61 unmodified lines
265268 struct vmw_res_cache_entry {
266269 uint32_t handle;
267270 struct vmw_resource *res;
271+ /* private: */
268272 void *private;
273+ /* public: */
269274 unsigned short valid_handle;
270275 unsigned short valid;
271276 };
272277
273278 /**
274279 * enum vmw_dma_map_mode - indicate how to perform TTM page dma mappings.
280+ * @vmw_dma_alloc_coherent: Use TTM coherent pages
281+ * @vmw_dma_map_populate: Unmap from DMA just after unpopulate
282+ * @vmw_dma_map_bind: Unmap from DMA just before unbind
275283 */
276284 enum vmw_dma_map_mode {
277− vmw_dma_alloc_coherent, /* Use TTM coherent pages */
278− vmw_dma_map_populate, /* Unmap from DMA just after unpopulate */
279− vmw_dma_map_bind, /* Unmap from DMA just before unbind */
285+ vmw_dma_alloc_coherent,
286+ vmw_dma_map_populate,
287+ vmw_dma_map_bind,
288+ /* private: */
280289 vmw_dma_map_max
281290 };
282291
@@ -284,8 +293,11 @@ enum vmw_dma_map_mode { · 1 unmodified line
284293 * struct vmw_sg_table - Scatter/gather table for binding, with additional
285294 * device-specific information.
286295 *
296+ * @mode: which page mapping mode to use
297+ * @pages: Array of page pointers to the pages.
298+ * @addrs: DMA addresses to the pages if coherent pages are used.
287299 * @sgt: Pointer to a struct sg_table with binding information
288− * @num_regions: Number of regions with device-address contiguous pages
300+ * @num_pages: Number of @pages
289301 */
290302 struct vmw_sg_table {
291303 enum vmw_dma_map_mode mode;
@@ -353,6 +365,7 @@ struct vmw_ctx_validation_info; · 61 unmodified lines
353365 * than from user-space
354366 * @fp: If @kernel is false, points to the file of the client. Otherwise
355367 * NULL
368+ * @filp: DRM state for this file
356369 * @cmd_bounce: Command bounce buffer used for command validation before
357370 * copying to fifo space
358371 * @cmd_bounce_size: Current command bounce buffer size
@@ -729,7 +742,7 @@ extern void vmw_svga_disable(struct vmw_private *dev_priv); · 370 unmodified lines
729742 bool vmwgfx_supported(struct vmw_private *vmw);
730743
731744
732−/**
745+/*
733746 * GMR utilities - vmwgfx_gmr.c
734747 */
735748
@@ -739,7 +752,7 @@ extern int vmw_gmr_bind(struct vmw_private *dev_priv, · 3 unmodified lines
739752 int gmr_id);
740753 extern void vmw_gmr_unbind(struct vmw_private *dev_priv, int gmr_id);
741754
742−/**
755+/*
743756 * User handles
744757 */
745758 struct vmw_user_object {
@@ -759,7 +772,7 @@ void *vmw_user_object_map_size(struct vmw_user_object *uo, size_t size); · 13 unmodified lines
759772 void vmw_user_object_unmap(struct vmw_user_object *uo);
760773 bool vmw_user_object_is_mapped(struct vmw_user_object *uo);
761774
762−/**
775+/*
763776 * Resource utilities - vmwgfx_resource.c
764777 */
765778 struct vmw_user_resource_conv;
@@ -819,7 +832,7 @@ static inline bool vmw_resource_mob_attached(const struct vmw_resource *res) · 53 unmodified lines
819832 return !RB_EMPTY_NODE(&res->mob_node);
820833 }
821834
822−/**
835+/*
823836 * GEM related functionality - vmwgfx_gem.c
824837 */
825838 struct vmw_bo_params;
@@ -833,7 +846,7 @@ extern int vmw_gem_object_create_ioctl(struct drm_device *dev, void *data, · 7 unmodified lines
833846 struct drm_file *filp);
834847 extern void vmw_debugfs_gem_init(struct vmw_private *vdev);
835848
836−/**
849+/*
837850 * Misc Ioctl functionality - vmwgfx_ioctl.c
838851 */
839852
@@ -846,7 +859,7 @@ extern int vmw_present_ioctl(struct drm_device *dev, void *data, · 6 unmodified lines
846859 extern int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
847860 struct drm_file *file_priv);
848861
849−/**
862+/*
850863 * Fifo utilities - vmwgfx_fifo.c
851864 */
852865
@@ -880,9 +893,11 @@ extern int vmw_cmd_flush(struct vmw_private *dev_priv, · 27 unmodified lines
880893
881894
882895 /**
883− * vmw_fifo_caps - Returns the capabilities of the FIFO command
896+ * vmw_fifo_caps - Get the capabilities of the FIFO command
884897 * queue or 0 if fifo memory isn't present.
885898 * @dev_priv: The device private context
899+ *
900+ * Returns: capabilities of the FIFO command or %0 if fifo memory not present
886901 */
887902 static inline uint32_t vmw_fifo_caps(const struct vmw_private *dev_priv)
888903 {
@@ -893,9 +908,11 @@ static inline uint32_t vmw_fifo_caps(const struct vmw_private *dev_priv) · 4 unmodified lines
893908
894909
895910 /**
896− * vmw_is_cursor_bypass3_enabled - Returns TRUE iff Cursor Bypass 3
897− * is enabled in the FIFO.
911+ * vmw_is_cursor_bypass3_enabled - check Cursor Bypass 3 enabled setting
912+ * in the FIFO.
898913 * @dev_priv: The device private context
914+ *
915+ * Returns: %true iff Cursor Bypass 3 is enabled in the FIFO
899916 */
900917 static inline bool
901918 vmw_is_cursor_bypass3_enabled(const struct vmw_private *dev_priv)
@@ -903,7 +920,7 @@ vmw_is_cursor_bypass3_enabled(const struct vmw_private *dev_priv) · 1 unmodified line
903920 return (vmw_fifo_caps(dev_priv) & SVGA_FIFO_CAP_CURSOR_BYPASS_3) != 0;
904921 }
905922
906−/**
923+/*
907924 * TTM buffer object driver - vmwgfx_ttm_buffer.c
908925 */
909926
@@ -927,7 +944,7 @@ extern void vmw_piter_start(struct vmw_piter *viter, · 17 unmodified lines
927944 *
928945 * @viter: Pointer to the iterator to advance.
929946 *
930− * Returns false if past the list of pages, true otherwise.
947+ * Returns: false if past the list of pages, true otherwise.
931948 */
932949 static inline bool vmw_piter_next(struct vmw_piter *viter)
933950 {
@@ -939,7 +956,7 @@ static inline bool vmw_piter_next(struct vmw_piter *viter) · 5 unmodified lines
939956 *
940957 * @viter: Pointer to the iterator
941958 *
942− * Returns the DMA address of the page pointed to by @viter.
959+ * Returns: the DMA address of the page pointed to by @viter.
943960 */
944961 static inline dma_addr_t vmw_piter_dma_addr(struct vmw_piter *viter)
945962 {
@@ -951,14 +968,14 @@ static inline dma_addr_t vmw_piter_dma_addr(struct vmw_piter *viter) · 5 unmodified lines
951968 *
952969 * @viter: Pointer to the iterator
953970 *
954− * Returns the DMA address of the page pointed to by @viter.
971+ * Returns: the DMA address of the page pointed to by @viter.
955972 */
956973 static inline struct page *vmw_piter_page(struct vmw_piter *viter)
957974 {
958975 return viter->pages[viter->i];
959976 }
960977
961−/**
978+/*
962979 * Command submission - vmwgfx_execbuf.c
963980 */
964981
@@ -993,7 +1010,7 @@ extern int vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv, · 28 unmodified lines
9931010 int32_t out_fence_fd);
9941011 bool vmw_cmd_describe(const void *buf, u32 *size, char const **cmd);
9951012
996−/**
1013+/*
9971014 * IRQs and wating - vmwgfx_irq.c
9981015 */
9991016
@@ -1016,7 +1033,7 @@ bool vmw_generic_waiter_add(struct vmw_private *dev_priv, u32 flag, · 16 unmodified lines
10161033 bool vmw_generic_waiter_remove(struct vmw_private *dev_priv,
10171034 u32 flag, int *waiter_count);
10181035
1019−/**
1036+/*
10201037 * Kernel modesetting - vmwgfx_kms.c
10211038 */
10221039
@@ -1048,7 +1065,7 @@ extern int vmw_resource_pin(struct vmw_resource *res, bool interruptible); · 25 unmodified lines
10481065 extern void vmw_resource_unpin(struct vmw_resource *res);
10491066 extern enum vmw_res_type vmw_res_type(const struct vmw_resource *res);
10501067
1051−/**
1068+/*
10521069 * Overlay control - vmwgfx_overlay.c
10531070 */
10541071
@@ -1063,20 +1080,20 @@ int vmw_overlay_unref(struct vmw_private *dev_priv, uint32_t stream_id); · 8 unmodified lines
10631080 int vmw_overlay_num_overlays(struct vmw_private *dev_priv);
10641081 int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv);
10651082
1066−/**
1083+/*
10671084 * GMR Id manager
10681085 */
10691086
10701087 int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type);
10711088 void vmw_gmrid_man_fini(struct vmw_private *dev_priv, int type);
10721089
1073−/**
1090+/*
10741091 * System memory manager
10751092 */
10761093 int vmw_sys_man_init(struct vmw_private *dev_priv);
10771094 void vmw_sys_man_fini(struct vmw_private *dev_priv);
10781095
1079−/**
1096+/*
10801097 * Prime - vmwgfx_prime.c
10811098 */
10821099
@@ -1292,7 +1309,7 @@ extern void vmw_cmdbuf_irqthread(struct vmw_cmdbuf_man *man); · 209 unmodified lines
12921309 * @line: The current line of the blit.
12931310 * @line_offset: Offset of the current line segment.
12941311 * @cpp: Bytes per pixel (granularity information).
1295− * @memcpy: Which memcpy function to use.
1312+ * @do_cpy: Which memcpy function to use.
12961313 */
12971314 struct vmw_diff_cpy {
12981315 struct drm_rect rect;
@@ -1380,13 +1397,14 @@ vm_fault_t vmw_bo_vm_mkwrite(struct vm_fault *vmf); · 81 unmodified lines
13801397
13811398 /**
13821399 * VMW_DEBUG_KMS - Debug output for kernel mode-setting
1400+ * @fmt: format string for the args
13831401 *
13841402 * This macro is for debugging vmwgfx mode-setting code.
13851403 */
13861404 #define VMW_DEBUG_KMS(fmt, ...) \
13871405 DRM_DEBUG_DRIVER(fmt, ##__VA_ARGS__)
13881406
1389−/**
1407+/*
13901408 * Inline helper functions
13911409 */
13921410
@@ -1417,11 +1435,13 @@ static inline void vmw_fifo_resource_dec(struct vmw_private *dev_priv) · 24 unmodified lines
14171435
14181436 /**
14191437 * vmw_fifo_mem_read - Perform a MMIO read from the fifo memory
1420− *
1438+ * @vmw: The device private structure
14211439 * @fifo_reg: The fifo register to read from
14221440 *
14231441 * This function is intended to be equivalent to ioread32() on
14241442 * memremap'd memory, but without byteswapping.
1443+ *
1444+ * Returns: the value read
14251445 */
14261446 static inline u32 vmw_fifo_mem_read(struct vmw_private *vmw, uint32 fifo_reg)
14271447 {
@@ -1431,8 +1451,9 @@ static inline u32 vmw_fifo_mem_read(struct vmw_private *vmw, uint32 fifo_reg) · 3 unmodified lines
14311451
14321452 /**
14331453 * vmw_fifo_mem_write - Perform a MMIO write to volatile memory
1434− *
1435− * @addr: The fifo register to write to
1454+ * @vmw: The device private structure
1455+ * @fifo_reg: The fifo register to write to
1456+ * @value: The value to write
14361457 *
14371458 * This function is intended to be equivalent to iowrite32 on
14381459 * memremap'd memory, but without byteswapping.
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c+2−1
@@ -771,7 +771,8 @@ err_out: · 770 unmodified lines
771771 ret = vmw_bo_dirty_add(bo);
772772 if (!ret && surface && surface->res.func->dirty_alloc) {
773773 surface->res.coherent = true;
774− ret = surface->res.func->dirty_alloc(&surface->res);
774+ if (surface->res.dirty == NULL)
775+ ret = surface->res.func->dirty_alloc(&surface->res);
775776 }
776777 ttm_bo_unreserve(&bo->tbo);
777778 }
drivers/gpu/drm/xe/xe_ggtt.c+4−6
@@ -313,6 +313,8 @@ static void dev_fini_ggtt(void *arg) · 312 unmodified lines
313313 {
314314 struct xe_ggtt *ggtt = arg;
315315
316+ scoped_guard(mutex, &ggtt->lock)
317+ ggtt->flags &= ~XE_GGTT_FLAGS_ONLINE;
316318 drain_workqueue(ggtt->wq);
317319 }
318320
@@ -377,6 +379,7 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt) · 58 unmodified lines
377379 if (err)
378380 return err;
379381
382+ ggtt->flags |= XE_GGTT_FLAGS_ONLINE;
380383 err = devm_add_action_or_reset(xe->drm.dev, dev_fini_ggtt, ggtt);
381384 if (err)
382385 return err;
@@ -410,13 +413,10 @@ static void xe_ggtt_initial_clear(struct xe_ggtt *ggtt) · 27 unmodified lines
410413 static void ggtt_node_remove(struct xe_ggtt_node *node)
411414 {
412415 struct xe_ggtt *ggtt = node->ggtt;
413− struct xe_device *xe = tile_to_xe(ggtt->tile);
414416 bool bound;
415− int idx;
416−
417− bound = drm_dev_enter(&xe->drm, &idx);
418417
419418 mutex_lock(&ggtt->lock);
419+ bound = ggtt->flags & XE_GGTT_FLAGS_ONLINE;
420420 if (bound)
421421 xe_ggtt_clear(ggtt, node->base.start, node->base.size);
422422 drm_mm_remove_node(&node->base);
@@ -429,8 +429,6 @@ static void ggtt_node_remove(struct xe_ggtt_node *node) · 6 unmodified lines
429429 if (node->invalidate_on_remove)
430430 xe_ggtt_invalidate(ggtt);
431431
432− drm_dev_exit(idx);
433−
434432 free_node:
435433 xe_ggtt_node_fini(node);
436434 }
drivers/gpu/drm/xe/xe_ggtt_types.h+4−1
@@ -28,11 +28,14 @@ struct xe_ggtt { · 27 unmodified lines
2828 /** @size: Total usable size of this GGTT */
2929 u64 size;
3030
31−#define XE_GGTT_FLAGS_64K BIT(0)
31+#define XE_GGTT_FLAGS_64K BIT(0)
32+#define XE_GGTT_FLAGS_ONLINE BIT(1)
3233 /**
3334 * @flags: Flags for this GGTT
3435 * Acceptable flags:
3536 * - %XE_GGTT_FLAGS_64K - if PTE size is 64K. Otherwise, regular is 4K.
37+ * - %XE_GGTT_FLAGS_ONLINE - is GGTT online, protected by ggtt->lock
38+ * after init
3639 */
3740 unsigned int flags;
3841 /** @scratch: Internal object allocation used as a scratch page */
drivers/gpu/drm/xe/xe_gt_ccs_mode.c+2−0
@@ -12,6 +12,7 @@ · 11 unmodified lines
1212 #include "xe_gt_printk.h"
1313 #include "xe_gt_sysfs.h"
1414 #include "xe_mmio.h"
15+#include "xe_pm.h"
1516 #include "xe_sriov.h"
1617
1718 static void __xe_gt_apply_ccs_mode(struct xe_gt *gt, u32 num_engines)
@@ -150,6 +151,7 @@ ccs_mode_store(struct device *kdev, struct device_attribute *attr, · 132 unmodified lines
150151 xe_gt_info(gt, "Setting compute mode to %d\n", num_engines);
151152 gt->ccs_mode = num_engines;
152153 xe_gt_record_user_engines(gt);
154+ guard(xe_pm_runtime)(xe);
153155 xe_gt_reset(gt);
154156 }
155157
drivers/gpu/drm/xe/xe_guc.c+27−5
@@ -1124,14 +1124,14 @@ static int guc_wait_ucode(struct xe_guc *guc) · 1123 unmodified lines
11241124 struct xe_guc_pc *guc_pc = &gt->uc.guc.pc;
11251125 u32 before_freq, act_freq, cur_freq;
11261126 u32 status = 0, tries = 0;
1127+ int load_result, ret;
11271128 ktime_t before;
11281129 u64 delta_ms;
1129− int ret;
11301130
11311131 before_freq = xe_guc_pc_get_act_freq(guc_pc);
11321132 before = ktime_get();
11331133
1134− ret = poll_timeout_us(ret = guc_load_done(gt, &status, &tries), ret,
1134+ ret = poll_timeout_us(load_result = guc_load_done(gt, &status, &tries), load_result,
11351135 10 * USEC_PER_MSEC,
11361136 GUC_LOAD_TIMEOUT_SEC * USEC_PER_SEC, false);
11371137
@@ -1139,7 +1139,7 @@ static int guc_wait_ucode(struct xe_guc *guc) · 1 unmodified line
11391139 act_freq = xe_guc_pc_get_act_freq(guc_pc);
11401140 cur_freq = xe_guc_pc_get_cur_freq_fw(guc_pc);
11411141
1142− if (ret) {
1142+ if (ret || load_result <= 0) {
11431143 xe_gt_err(gt, "load failed: status = 0x%08X, time = %lldms, freq = %dMHz (req %dMHz)\n",
11441144 status, delta_ms, xe_guc_pc_get_act_freq(guc_pc),
11451145 xe_guc_pc_get_cur_freq_fw(guc_pc));
@@ -1347,15 +1347,37 @@ int xe_guc_enable_communication(struct xe_guc *guc) · 201 unmodified lines
13471347 return 0;
13481348 }
13491349
1350−int xe_guc_suspend(struct xe_guc *guc)
1350+/**
1351+ * xe_guc_softreset() - Soft reset GuC
1352+ * @guc: The GuC object
1353+ *
1354+ * Send soft reset command to GuC through mmio send.
1355+ *
1356+ * Return: 0 if success, otherwise error code
1357+ */
1358+int xe_guc_softreset(struct xe_guc *guc)
13511359 {
1352− struct xe_gt *gt = guc_to_gt(guc);
13531360 u32 action[] = {
13541361 XE_GUC_ACTION_CLIENT_SOFT_RESET,
13551362 };
13561363 int ret;
13571364
1365+ if (!xe_uc_fw_is_running(&guc->fw))
1366+ return 0;
1367+
13581368 ret = xe_guc_mmio_send(guc, action, ARRAY_SIZE(action));
1369+ if (ret)
1370+ return ret;
1371+
1372+ return 0;
1373+}
1374+
1375+int xe_guc_suspend(struct xe_guc *guc)
1376+{
1377+ struct xe_gt *gt = guc_to_gt(guc);
1378+ int ret;
1379+
1380+ ret = xe_guc_softreset(guc);
13591381 if (ret) {
13601382 xe_gt_err(gt, "GuC suspend failed: %pe\n", ERR_PTR(ret));
13611383 return ret;
drivers/gpu/drm/xe/xe_guc.h+1−0
@@ -44,6 +44,7 @@ int xe_guc_opt_in_features_enable(struct xe_guc *guc); · 43 unmodified lines
4444 void xe_guc_runtime_suspend(struct xe_guc *guc);
4545 void xe_guc_runtime_resume(struct xe_guc *guc);
4646 int xe_guc_suspend(struct xe_guc *guc);
47+int xe_guc_softreset(struct xe_guc *guc);
4748 void xe_guc_notify(struct xe_guc *guc);
4849 int xe_guc_auth_huc(struct xe_guc *guc, u32 rsa_addr);
4950 int xe_guc_mmio_send(struct xe_guc *guc, const u32 *request, u32 len);
drivers/gpu/drm/xe/xe_guc_ct.c+1−0
@@ -345,6 +345,7 @@ static void guc_action_disable_ct(void *arg) · 344 unmodified lines
345345 {
346346 struct xe_guc_ct *ct = arg;
347347
348+ xe_guc_ct_stop(ct);
348349 guc_ct_change_state(ct, XE_GUC_CT_STATE_DISABLED);
349350 }
350351
drivers/gpu/drm/xe/xe_guc_submit.c+61−25
@@ -48,6 +48,8 @@ · 47 unmodified lines
4848
4949 #define XE_GUC_EXEC_QUEUE_CGP_CONTEXT_ERROR_LEN 6
5050
51+static int guc_submit_reset_prepare(struct xe_guc *guc);
52+
5153 static struct xe_guc *
5254 exec_queue_to_guc(struct xe_exec_queue *q)
5355 {
@@ -239,7 +241,7 @@ static bool exec_queue_killed_or_banned_or_wedged(struct xe_exec_queue *q) · 185 unmodified lines
239241 EXEC_QUEUE_STATE_BANNED));
240242 }
241243
242−static void guc_submit_fini(struct drm_device *drm, void *arg)
244+static void guc_submit_sw_fini(struct drm_device *drm, void *arg)
243245 {
244246 struct xe_guc *guc = arg;
245247 struct xe_device *xe = guc_to_xe(guc);
@@ -257,6 +259,19 @@ static void guc_submit_fini(struct drm_device *drm, void *arg) · 11 unmodified lines
257259 xa_destroy(&guc->submission_state.exec_queue_lookup);
258260 }
259261
262+static void guc_submit_fini(void *arg)
263+{
264+ struct xe_guc *guc = arg;
265+
266+ /* Forcefully kill any remaining exec queues */
267+ xe_guc_ct_stop(&guc->ct);
268+ guc_submit_reset_prepare(guc);
269+ xe_guc_softreset(guc);
270+ xe_guc_submit_stop(guc);
271+ xe_uc_fw_sanitize(&guc->fw);
272+ xe_guc_submit_pause_abort(guc);
273+}
274+
260275 static void guc_submit_wedged_fini(void *arg)
261276 {
262277 struct xe_guc *guc = arg;
@@ -326,7 +341,11 @@ int xe_guc_submit_init(struct xe_guc *guc, unsigned int num_ids) · 63 unmodified lines
326341
327342 guc->submission_state.initialized = true;
328343
329− return drmm_add_action_or_reset(&xe->drm, guc_submit_fini, guc);
344+ err = drmm_add_action_or_reset(&xe->drm, guc_submit_sw_fini, guc);
345+ if (err)
346+ return err;
347+
348+ return devm_add_action_or_reset(xe->drm.dev, guc_submit_fini, guc);
330349 }
331350
332351 /*
@@ -1252,6 +1271,7 @@ static void disable_scheduling_deregister(struct xe_guc *guc, · 919 unmodified lines
12521271 */
12531272 void xe_guc_submit_wedge(struct xe_guc *guc)
12541273 {
1274+ struct xe_device *xe = guc_to_xe(guc);
12551275 struct xe_gt *gt = guc_to_gt(guc);
12561276 struct xe_exec_queue *q;
12571277 unsigned long index;
@@ -1266,20 +1286,28 @@ void xe_guc_submit_wedge(struct xe_guc *guc) · 8 unmodified lines
12661286 if (!guc->submission_state.initialized)
12671287 return;
12681288
1269− err = devm_add_action_or_reset(guc_to_xe(guc)->drm.dev,
1270− guc_submit_wedged_fini, guc);
1271− if (err) {
1272− xe_gt_err(gt, "Failed to register clean-up in wedged.mode=%s; "
1273− "Although device is wedged.\n",
1274− xe_wedged_mode_to_string(XE_WEDGED_MODE_UPON_ANY_HANG_NO_RESET));
1275− return;
1276− }
1289+ if (xe->wedged.mode == 2) {
1290+ err = devm_add_action_or_reset(guc_to_xe(guc)->drm.dev,
1291+ guc_submit_wedged_fini, guc);
1292+ if (err) {
1293+ xe_gt_err(gt, "Failed to register clean-up on wedged.mode=2; "
1294+ "Although device is wedged.\n");
1295+ return;
1296+ }
12771297
1278− mutex_lock(&guc->submission_state.lock);
1279− xa_for_each(&guc->submission_state.exec_queue_lookup, index, q)
1280− if (xe_exec_queue_get_unless_zero(q))
1281− set_exec_queue_wedged(q);
1282− mutex_unlock(&guc->submission_state.lock);
1298+ mutex_lock(&guc->submission_state.lock);
1299+ xa_for_each(&guc->submission_state.exec_queue_lookup, index, q)
1300+ if (xe_exec_queue_get_unless_zero(q))
1301+ set_exec_queue_wedged(q);
1302+ mutex_unlock(&guc->submission_state.lock);
1303+ } else {
1304+ /* Forcefully kill any remaining exec queues, signal fences */
1305+ guc_submit_reset_prepare(guc);
1306+ xe_guc_submit_stop(guc);
1307+ xe_guc_softreset(guc);
1308+ xe_uc_fw_sanitize(&guc->fw);
1309+ xe_guc_submit_pause_abort(guc);
1310+ }
12831311 }
12841312
12851313 static bool guc_submit_hint_wedged(struct xe_guc *guc)
@@ -2230,6 +2258,7 @@ static const struct xe_exec_queue_ops guc_exec_queue_ops = { · 944 unmodified lines
22302258 static void guc_exec_queue_stop(struct xe_guc *guc, struct xe_exec_queue *q)
22312259 {
22322260 struct xe_gpu_scheduler *sched = &q->guc->sched;
2261+ bool do_destroy = false;
22332262
22342263 /* Stop scheduling + flush any DRM scheduler operations */
22352264 xe_sched_submission_stop(sched);
@@ -2237,7 +2266,7 @@ static void guc_exec_queue_stop(struct xe_guc *guc, struct xe_exec_queue *q) · 1 unmodified line
22372266 /* Clean up lost G2H + reset engine state */
22382267 if (exec_queue_registered(q)) {
22392268 if (exec_queue_destroyed(q))
2240− __guc_exec_queue_destroy(guc, q);
2269+ do_destroy = true;
22412270 }
22422271 if (q->guc->suspend_pending) {
22432272 set_exec_queue_suspended(q);
@@ -2273,18 +2302,15 @@ static void guc_exec_queue_stop(struct xe_guc *guc, struct xe_exec_queue *q) · 29 unmodified lines
22732302 xe_guc_exec_queue_trigger_cleanup(q);
22742303 }
22752304 }
2305+
2306+ if (do_destroy)
2307+ __guc_exec_queue_destroy(guc, q);
22762308 }
22772309
2278−int xe_guc_submit_reset_prepare(struct xe_guc *guc)
2310+static int guc_submit_reset_prepare(struct xe_guc *guc)
22792311 {
22802312 int ret;
22812313
2282− if (xe_gt_WARN_ON(guc_to_gt(guc), vf_recovery(guc)))
2283− return 0;
2284−
2285− if (!guc->submission_state.initialized)
2286− return 0;
2287−
22882314 /*
22892315 * Using an atomic here rather than submission_state.lock as this
22902316 * function can be called while holding the CT lock (engine reset
@@ -2299,6 +2325,17 @@ int xe_guc_submit_reset_prepare(struct xe_guc *guc) · 8 unmodified lines
22992325 return ret;
23002326 }
23012327
2328+int xe_guc_submit_reset_prepare(struct xe_guc *guc)
2329+{
2330+ if (xe_gt_WARN_ON(guc_to_gt(guc), vf_recovery(guc)))
2331+ return 0;
2332+
2333+ if (!guc->submission_state.initialized)
2334+ return 0;
2335+
2336+ return guc_submit_reset_prepare(guc);
2337+}
2338+
23022339 void xe_guc_submit_reset_wait(struct xe_guc *guc)
23032340 {
23042341 wait_event(guc->ct.wq, xe_device_wedged(guc_to_xe(guc)) ||
@@ -2695,8 +2732,7 @@ void xe_guc_submit_pause_abort(struct xe_guc *guc) · 390 unmodified lines
26952732 continue;
26962733
26972734 xe_sched_submission_start(sched);
2698− if (exec_queue_killed_or_banned_or_wedged(q))
2699− xe_guc_exec_queue_trigger_cleanup(q);
2735+ guc_exec_queue_kill(q);
27002736 }
27012737 mutex_unlock(&guc->submission_state.lock);
27022738 }
drivers/gpu/drm/xe/xe_lrc.c+2−2
@@ -2413,14 +2413,14 @@ static int get_ctx_timestamp(struct xe_lrc *lrc, u32 engine_id, u64 *reg_ctx_ts) · 2412 unmodified lines
24132413 * @lrc: Pointer to the lrc.
24142414 *
24152415 * Return latest ctx timestamp. With support for active contexts, the
2416− * calculation may bb slightly racy, so follow a read-again logic to ensure that
2416+ * calculation may be slightly racy, so follow a read-again logic to ensure that
24172417 * the context is still active before returning the right timestamp.
24182418 *
24192419 * Returns: New ctx timestamp value
24202420 */
24212421 u64 xe_lrc_timestamp(struct xe_lrc *lrc)
24222422 {
2423− u64 lrc_ts, reg_ts, new_ts;
2423+ u64 lrc_ts, reg_ts, new_ts = lrc->ctx_timestamp;
24242424 u32 engine_id;
24252425
24262426 lrc_ts = xe_lrc_ctx_timestamp(lrc);
drivers/gpu/drm/xe/xe_oa.c+5−2
@@ -543,8 +543,7 @@ static ssize_t xe_oa_read(struct file *file, char __user *buf, · 542 unmodified lines
543543 size_t offset = 0;
544544 int ret;
545545
546− /* Can't read from disabled streams */
547− if (!stream->enabled || !stream->sample)
546+ if (!stream->sample)
548547 return -EINVAL;
549548
550549 if (!(file->f_flags & O_NONBLOCK)) {
@@ -1460,6 +1459,10 @@ static void xe_oa_stream_disable(struct xe_oa_stream *stream) · 909 unmodified lines
14601459
14611460 if (stream->sample)
14621461 hrtimer_cancel(&stream->poll_check_timer);
1462+
1463+ /* Update stream->oa_buffer.tail to allow any final reports to be read */
1464+ if (xe_oa_buffer_check_unlocked(stream))
1465+ wake_up(&stream->poll_wq);
14631466 }
14641467
14651468 static int xe_oa_enable_preempt_timeslice(struct xe_oa_stream *stream)
drivers/gpu/drm/xe/xe_pt.c+29−9
@@ -1655,14 +1655,35 @@ static int xe_pt_stage_unbind_entry(struct xe_ptw *parent, pgoff_t offset, · 1654 unmodified lines
16551655 XE_WARN_ON(!level);
16561656 /* Check for leaf node */
16571657 if (xe_walk->prl && xe_page_reclaim_list_valid(xe_walk->prl) &&
1658− (!xe_child->base.children || !xe_child->base.children[first])) {
1658+ xe_child->level <= MAX_HUGEPTE_LEVEL) {
16591659 struct iosys_map *leaf_map = &xe_child->bo->vmap;
16601660 pgoff_t count = xe_pt_num_entries(addr, next, xe_child->level, walk);
16611661
16621662 for (pgoff_t i = 0; i < count; i++) {
1663− u64 pte = xe_map_rd(xe, leaf_map, (first + i) * sizeof(u64), u64);
1663+ u64 pte;
16641664 int ret;
16651665
1666+ /*
1667+ * If not a leaf pt, skip unless non-leaf pt is interleaved between
1668+ * leaf ptes which causes the page walk to skip over the child leaves
1669+ */
1670+ if (xe_child->base.children && xe_child->base.children[first + i]) {
1671+ u64 pt_size = 1ULL << walk->shifts[xe_child->level];
1672+ bool edge_pt = (i == 0 && !IS_ALIGNED(addr, pt_size)) ||
1673+ (i == count - 1 && !IS_ALIGNED(next, pt_size));
1674+
1675+ if (!edge_pt) {
1676+ xe_page_reclaim_list_abort(xe_walk->tile->primary_gt,
1677+ xe_walk->prl,
1678+ "PT is skipped by walk at level=%u offset=%lu",
1679+ xe_child->level, first + i);
1680+ break;
1681+ }
1682+ continue;
1683+ }
1684+
1685+ pte = xe_map_rd(xe, leaf_map, (first + i) * sizeof(u64), u64);
1686+
16661687 /*
16671688 * In rare scenarios, pte may not be written yet due to racy conditions.
16681689 * In such cases, invalidate the PRL and fallback to full PPC invalidation.
@@ -1674,9 +1695,8 @@ static int xe_pt_stage_unbind_entry(struct xe_ptw *parent, pgoff_t offset, · 5 unmodified lines
16741695 }
16751696
16761697 /* Ensure it is a defined page */
1677− xe_tile_assert(xe_walk->tile,
1678− xe_child->level == 0 ||
1679− (pte & (XE_PTE_PS64 | XE_PDE_PS_2M | XE_PDPE_PS_1G)));
1698+ xe_tile_assert(xe_walk->tile, xe_child->level == 0 ||
1699+ (pte & (XE_PDE_PS_2M | XE_PDPE_PS_1G)));
16801700
16811701 /* An entry should be added for 64KB but contigious 4K have XE_PTE_PS64 */
16821702 if (pte & XE_PTE_PS64)
@@ -1701,11 +1721,11 @@ static int xe_pt_stage_unbind_entry(struct xe_ptw *parent, pgoff_t offset, · 18 unmodified lines
17011721 killed = xe_pt_check_kill(addr, next, level - 1, xe_child, action, walk);
17021722
17031723 /*
1704− * Verify PRL is active and if entry is not a leaf pte (base.children conditions),
1705− * there is a potential need to invalidate the PRL if any PTE (num_live) are dropped.
1724+ * Verify if any PTE are potentially dropped at non-leaf levels, either from being
1725+ * killed or the page walk covers the region.
17061726 */
1707− if (xe_walk->prl && level > 1 && xe_child->num_live &&
1708− xe_child->base.children && xe_child->base.children[first]) {
1727+ if (xe_walk->prl && xe_page_reclaim_list_valid(xe_walk->prl) &&
1728+ xe_child->level > MAX_HUGEPTE_LEVEL && xe_child->num_live) {
17091729 bool covered = xe_pt_covers(addr, next, xe_child->level, &xe_walk->base);
17101730
17111731 /*
drivers/hid/bpf/hid_bpf_dispatch.c+2−0
@@ -444,6 +444,8 @@ hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz, · 443 unmodified lines
444444 (u64)(long)ctx,
445445 true); /* prevent infinite recursions */
446446
447+ if (ret > size)
448+ ret = size;
447449 if (ret > 0)
448450 memcpy(buf, dma_data, ret);
449451
drivers/hid/hid-appletb-kbd.c+3−2
@@ -476,7 +476,7 @@ static int appletb_kbd_suspend(struct hid_device *hdev, pm_message_t msg) · 475 unmodified lines
476476 return 0;
477477 }
478478
479−static int appletb_kbd_reset_resume(struct hid_device *hdev)
479+static int appletb_kbd_resume(struct hid_device *hdev)
480480 {
481481 struct appletb_kbd *kbd = hid_get_drvdata(hdev);
482482
@@ -500,7 +500,8 @@ static struct hid_driver appletb_kbd_hid_driver = { · 17 unmodified lines
500500 .event = appletb_kbd_hid_event,
501501 .input_configured = appletb_kbd_input_configured,
502502 .suspend = pm_ptr(appletb_kbd_suspend),
503− .reset_resume = pm_ptr(appletb_kbd_reset_resume),
503+ .resume = pm_ptr(appletb_kbd_resume),
504+ .reset_resume = pm_ptr(appletb_kbd_resume),
504505 .driver.dev_groups = appletb_kbd_groups,
505506 };
506507 module_hid_driver(appletb_kbd_hid_driver);
drivers/hid/hid-asus.c+3−0
@@ -1497,6 +1497,9 @@ static const struct hid_device_id asus_devices[] = { · 1496 unmodified lines
14971497 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
14981498 USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY_X),
14991499 QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD | QUIRK_ROG_ALLY_XPAD },
1500+ { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
1501+ USB_DEVICE_ID_ASUSTEK_XGM_2022),
1502+ },
15001503 { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
15011504 USB_DEVICE_ID_ASUSTEK_XGM_2023),
15021505 },
drivers/hid/hid-core.c+4−3
@@ -2057,9 +2057,10 @@ int hid_report_raw_event(struct hid_device *hid, enum hid_report_type type, u8 * · 2056 unmodified lines
20572057 rsize = max_buffer_size;
20582058
20592059 if (csize < rsize) {
2060− dbg_hid("report %d is too short, (%d < %d)\n", report->id,
2061− csize, rsize);
2062− memset(cdata + csize, 0, rsize - csize);
2060+ hid_warn_ratelimited(hid, "Event data for report %d was too short (%d vs %d)\n",
2061+ report->id, rsize, csize);
2062+ ret = -EINVAL;
2063+ goto out;
20632064 }
20642065
20652066 if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event)
drivers/hid/hid-ids.h+1−2
@@ -229,6 +229,7 @@ · 228 unmodified lines
229229 #define USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY_X 0x1b4c
230230 #define USB_DEVICE_ID_ASUSTEK_ROG_CLAYMORE_II_KEYBOARD 0x196b
231231 #define USB_DEVICE_ID_ASUSTEK_FX503VD_KEYBOARD 0x1869
232+#define USB_DEVICE_ID_ASUSTEK_XGM_2022 0x1970
232233 #define USB_DEVICE_ID_ASUSTEK_XGM_2023 0x1a9a
233234
234235 #define USB_VENDOR_ID_ATEN 0x0557
@@ -454,8 +455,6 @@ · 219 unmodified lines
454455 #define USB_DEVICE_ID_TOSHIBA_CLICK_L9W 0x0401
455456 #define USB_DEVICE_ID_HP_X2 0x074d
456457 #define USB_DEVICE_ID_HP_X2_10_COVER 0x0755
457−#define USB_DEVICE_ID_ASUS_UX550VE_TOUCHSCREEN 0x2544
458−#define USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN 0x2706
459458 #define I2C_DEVICE_ID_CHROMEBOOK_TROGDOR_POMPOM 0x2F81
460459
461460 #define USB_VENDOR_ID_ELECOM 0x056e
drivers/hid/hid-input.c+11−7
@@ -354,6 +354,7 @@ static enum power_supply_property hidinput_battery_props[] = { · 353 unmodified lines
354354 #define HID_BATTERY_QUIRK_FEATURE (1 << 1) /* ask for feature report */
355355 #define HID_BATTERY_QUIRK_IGNORE (1 << 2) /* completely ignore the battery */
356356 #define HID_BATTERY_QUIRK_AVOID_QUERY (1 << 3) /* do not query the battery */
357+#define HID_BATTERY_QUIRK_DYNAMIC (1 << 4) /* report present only after life signs */
357358
358359 static const struct hid_device_id hid_battery_quirks[] = {
359360 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
@@ -386,10 +387,6 @@ static const struct hid_device_id hid_battery_quirks[] = { · 26 unmodified lines
386387 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH,
387388 USB_DEVICE_ID_LOGITECH_DINOVO_EDGE_KBD),
388389 HID_BATTERY_QUIRK_IGNORE },
389− { HID_USB_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN),
390− HID_BATTERY_QUIRK_IGNORE },
391− { HID_USB_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ASUS_UX550VE_TOUCHSCREEN),
392− HID_BATTERY_QUIRK_IGNORE },
393390 { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_L),
394391 HID_BATTERY_QUIRK_AVOID_QUERY },
395392 { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_XPPEN_TABLET_DECO_PRO_MW),
@@ -402,8 +399,8 @@ static const struct hid_device_id hid_battery_quirks[] = { · 6 unmodified lines
402399 * Elan HID touchscreens seem to all report a non present battery,
403400 * set HID_BATTERY_QUIRK_IGNORE for all Elan I2C and USB HID devices.
404401 */
405− { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, HID_ANY_ID), HID_BATTERY_QUIRK_IGNORE },
406− { HID_USB_DEVICE(USB_VENDOR_ID_ELAN, HID_ANY_ID), HID_BATTERY_QUIRK_IGNORE },
402+ { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, HID_ANY_ID), HID_BATTERY_QUIRK_DYNAMIC },
403+ { HID_USB_DEVICE(USB_VENDOR_ID_ELAN, HID_ANY_ID), HID_BATTERY_QUIRK_DYNAMIC },
407404 {}
408405 };
409406
@@ -460,11 +457,14 @@ static int hidinput_get_battery_property(struct power_supply *psy, · 50 unmodified lines
460457 int ret = 0;
461458
462459 switch (prop) {
463− case POWER_SUPPLY_PROP_PRESENT:
464460 case POWER_SUPPLY_PROP_ONLINE:
465461 val->intval = 1;
466462 break;
467463
464+ case POWER_SUPPLY_PROP_PRESENT:
465+ val->intval = dev->battery_present;
466+ break;
467+
468468 case POWER_SUPPLY_PROP_CAPACITY:
469469 if (dev->battery_status != HID_BATTERY_REPORTED &&
470470 !dev->battery_avoid_query) {
@@ -577,6 +577,8 @@ static int hidinput_setup_battery(struct hid_device *dev, unsigned report_type, · 106 unmodified lines
577577 if (quirks & HID_BATTERY_QUIRK_AVOID_QUERY)
578578 dev->battery_avoid_query = true;
579579
580+ dev->battery_present = (quirks & HID_BATTERY_QUIRK_DYNAMIC) ? false : true;
581+
580582 dev->battery = power_supply_register(&dev->dev, psy_desc, &psy_cfg);
581583 if (IS_ERR(dev->battery)) {
582584 error = PTR_ERR(dev->battery);
@@ -632,6 +634,7 @@ static void hidinput_update_battery(struct hid_device *dev, unsigned int usage, · 49 unmodified lines
632634 return;
633635
634636 if (hidinput_update_battery_charge_status(dev, usage, value)) {
637+ dev->battery_present = true;
635638 power_supply_changed(dev->battery);
636639 return;
637640 }
@@ -647,6 +650,7 @@ static void hidinput_update_battery(struct hid_device *dev, unsigned int usage, · 9 unmodified lines
647650 if (dev->battery_status != HID_BATTERY_REPORTED ||
648651 capacity != dev->battery_capacity ||
649652 ktime_after(ktime_get_coarse(), dev->battery_ratelimit_time)) {
653+ dev->battery_present = true;
650654 dev->battery_capacity = capacity;
651655 dev->battery_status = HID_BATTERY_REPORTED;
652656 dev->battery_ratelimit_time =
drivers/hid/hid-logitech-hidpp.c+5−1
@@ -4487,10 +4487,12 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) · 4486 unmodified lines
44874487 if (!ret)
44884488 ret = hidpp_ff_init(hidpp, &data);
44894489
4490− if (ret)
4490+ if (ret) {
44914491 hid_warn(hidpp->hid_dev,
44924492 "Unable to initialize force feedback support, errno %d\n",
44934493 ret);
4494+ ret = 0;
4495+ }
44944496 }
44954497
44964498 /*
@@ -4668,6 +4670,8 @@ static const struct hid_device_id hidpp_devices[] = { · 171 unmodified lines
46684670 HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb038) },
46694671 { /* Slim Solar+ K980 Keyboard over Bluetooth */
46704672 HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb391) },
4673+ { /* MX Master 4 mouse over Bluetooth */
4674+ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb042) },
46714675 {}
46724676 };
46734677
drivers/hid/hid-multitouch.c+7−0
@@ -526,12 +526,19 @@ static void mt_get_feature(struct hid_device *hdev, struct hid_report *report) · 525 unmodified lines
526526 dev_warn(&hdev->dev, "failed to fetch feature %d\n",
527527 report->id);
528528 } else {
529+ /* The report ID in the request and the response should match */
530+ if (report->id != buf[0]) {
531+ hid_err(hdev, "Returned feature report did not match the request\n");
532+ goto free;
533+ }
534+
529535 ret = hid_report_raw_event(hdev, HID_FEATURE_REPORT, buf,
530536 size, 0);
531537 if (ret)
532538 dev_warn(&hdev->dev, "failed to report feature\n");
533539 }
534540
541+free:
535542 kfree(buf);
536543 }
537544
drivers/hid/intel-thc-hid/intel-quicki2c/quicki2c-hid.c+1−0
@@ -127,6 +127,7 @@ int quicki2c_hid_probe(struct quicki2c_device *qcdev) · 126 unmodified lines
127127 hid->product = le16_to_cpu(qcdev->dev_desc.product_id);
128128 snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X", "quicki2c-hid",
129129 hid->vendor, hid->product);
130+ strscpy(hid->phys, dev_name(qcdev->dev), sizeof(hid->phys));
130131
131132 ret = hid_add_device(hid);
132133 if (ret) {
drivers/hid/intel-thc-hid/intel-quickspi/quickspi-hid.c+1−0
@@ -118,6 +118,7 @@ int quickspi_hid_probe(struct quickspi_device *qsdev) · 117 unmodified lines
118118 hid->product = le16_to_cpu(qsdev->dev_desc.product_id);
119119 snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X", "quickspi-hid",
120120 hid->vendor, hid->product);
121+ strscpy(hid->phys, dev_name(qsdev->dev), sizeof(hid->phys));
121122
122123 ret = hid_add_device(hid);
123124 if (ret) {
drivers/hid/wacom_wac.c+10−0
@@ -1208,10 +1208,20 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len) · 1207 unmodified lines
12081208
12091209 switch (data[0]) {
12101210 case 0x04:
1211+ if (len < 32) {
1212+ dev_warn(wacom->pen_input->dev.parent,
1213+ "Report 0x04 too short: %zu bytes\n", len);
1214+ break;
1215+ }
12111216 wacom_intuos_bt_process_data(wacom, data + i);
12121217 i += 10;
12131218 fallthrough;
12141219 case 0x03:
1220+ if (i == 1 && len < 22) {
1221+ dev_warn(wacom->pen_input->dev.parent,
1222+ "Report 0x03 too short: %zu bytes\n", len);
1223+ break;
1224+ }
12151225 wacom_intuos_bt_process_data(wacom, data + i);
12161226 i += 10;
12171227 wacom_intuos_bt_process_data(wacom, data + i);
drivers/hv/mshv_regions.c+4−2
@@ -314,15 +314,17 @@ int mshv_region_pin(struct mshv_mem_region *region) · 313 unmodified lines
314314 ret = pin_user_pages_fast(userspace_addr, nr_pages,
315315 FOLL_WRITE | FOLL_LONGTERM,
316316 pages);
317− if (ret < 0)
317+ if (ret != nr_pages)
318318 goto release_pages;
319319 }
320320
321321 return 0;
322322
323323 release_pages:
324+ if (ret > 0)
325+ done_count += ret;
324326 mshv_region_invalidate_pages(region, 0, done_count);
325− return ret;
327+ return ret < 0 ? ret : -ENOMEM;
326328 }
327329
328330 static int mshv_region_chunk_unmap(struct mshv_mem_region *region,
drivers/hv/mshv_root.h+2−3
@@ -190,7 +190,6 @@ struct hv_synic_pages { · 189 unmodified lines
190190 };
191191
192192 struct mshv_root {
193− struct hv_synic_pages __percpu *synic_pages;
194193 spinlock_t pt_ht_lock;
195194 DECLARE_HASHTABLE(pt_htable, MSHV_PARTITIONS_HASH_BITS);
196195 struct hv_partition_property_vmm_capabilities vmm_caps;
@@ -249,8 +248,8 @@ int mshv_register_doorbell(u64 partition_id, doorbell_cb_t doorbell_cb, · 52 unmodified lines
249248 void mshv_unregister_doorbell(u64 partition_id, int doorbell_portid);
250249
251250 void mshv_isr(void);
252−int mshv_synic_init(unsigned int cpu);
253−int mshv_synic_cleanup(unsigned int cpu);
251+int mshv_synic_init(struct device *dev);
252+void mshv_synic_exit(void);
254253
255254 static inline bool mshv_partition_encrypted(struct mshv_partition *partition)
256255 {
drivers/hv/mshv_root_main.c+22−71
@@ -120,7 +120,6 @@ static u16 mshv_passthru_hvcalls[] = { · 119 unmodified lines
120120 HVCALL_SET_VP_REGISTERS,
121121 HVCALL_TRANSLATE_VIRTUAL_ADDRESS,
122122 HVCALL_CLEAR_VIRTUAL_INTERRUPT,
123− HVCALL_SCRUB_PARTITION,
124123 HVCALL_REGISTER_INTERCEPT_RESULT,
125124 HVCALL_ASSERT_VIRTUAL_INTERRUPT,
126125 HVCALL_GET_GPA_PAGES_ACCESS_STATES,
@@ -1289,7 +1288,7 @@ err_out: · 1162 unmodified lines
12891288 */
12901289 static long
12911290 mshv_map_user_memory(struct mshv_partition *partition,
1292− struct mshv_user_mem_region mem)
1291+ struct mshv_user_mem_region *mem)
12931292 {
12941293 struct mshv_mem_region *region;
12951294 struct vm_area_struct *vma;
@@ -1297,12 +1296,12 @@ mshv_map_user_memory(struct mshv_partition *partition, · 1 unmodified line
12971296 ulong mmio_pfn;
12981297 long ret;
12991298
1300− if (mem.flags & BIT(MSHV_SET_MEM_BIT_UNMAP) ||
1301− !access_ok((const void __user *)mem.userspace_addr, mem.size))
1299+ if (mem->flags & BIT(MSHV_SET_MEM_BIT_UNMAP) ||
1300+ !access_ok((const void __user *)mem->userspace_addr, mem->size))
13021301 return -EINVAL;
13031302
13041303 mmap_read_lock(current->mm);
1305− vma = vma_lookup(current->mm, mem.userspace_addr);
1304+ vma = vma_lookup(current->mm, mem->userspace_addr);
13061305 is_mmio = vma ? !!(vma->vm_flags & (VM_IO | VM_PFNMAP)) : 0;
13071306 mmio_pfn = is_mmio ? vma->vm_pgoff : 0;
13081307 mmap_read_unlock(current->mm);
@@ -1310,7 +1309,7 @@ mshv_map_user_memory(struct mshv_partition *partition, · 1 unmodified line
13101309 if (!vma)
13111310 return -EINVAL;
13121311
1313− ret = mshv_partition_create_region(partition, &mem, &region,
1312+ ret = mshv_partition_create_region(partition, mem, &region,
13141313 is_mmio);
13151314 if (ret)
13161315 return ret;
@@ -1348,32 +1347,32 @@ mshv_map_user_memory(struct mshv_partition *partition, · 31 unmodified lines
13481347 return 0;
13491348
13501349 errout:
1351− vfree(region);
1350+ mshv_region_put(region);
13521351 return ret;
13531352 }
13541353
13551354 /* Called for unmapping both the guest ram and the mmio space */
13561355 static long
13571356 mshv_unmap_user_memory(struct mshv_partition *partition,
1358− struct mshv_user_mem_region mem)
1357+ struct mshv_user_mem_region *mem)
13591358 {
13601359 struct mshv_mem_region *region;
13611360
1362− if (!(mem.flags & BIT(MSHV_SET_MEM_BIT_UNMAP)))
1361+ if (!(mem->flags & BIT(MSHV_SET_MEM_BIT_UNMAP)))
13631362 return -EINVAL;
13641363
13651364 spin_lock(&partition->pt_mem_regions_lock);
13661365
1367− region = mshv_partition_region_by_gfn(partition, mem.guest_pfn);
1366+ region = mshv_partition_region_by_gfn(partition, mem->guest_pfn);
13681367 if (!region) {
13691368 spin_unlock(&partition->pt_mem_regions_lock);
13701369 return -ENOENT;
13711370 }
13721371
13731372 /* Paranoia check */
1374− if (region->start_uaddr != mem.userspace_addr ||
1375− region->start_gfn != mem.guest_pfn ||
1376− region->nr_pages != HVPFN_DOWN(mem.size)) {
1373+ if (region->start_uaddr != mem->userspace_addr ||
1374+ region->start_gfn != mem->guest_pfn ||
1375+ region->nr_pages != HVPFN_DOWN(mem->size)) {
13771376 spin_unlock(&partition->pt_mem_regions_lock);
13781377 return -EINVAL;
13791378 }
@@ -1404,9 +1403,9 @@ mshv_partition_ioctl_set_memory(struct mshv_partition *partition, · 24 unmodified lines
14041403 return -EINVAL;
14051404
14061405 if (mem.flags & BIT(MSHV_SET_MEM_BIT_UNMAP))
1407− return mshv_unmap_user_memory(partition, mem);
1406+ return mshv_unmap_user_memory(partition, &mem);
14081407
1409− return mshv_map_user_memory(partition, mem);
1408+ return mshv_map_user_memory(partition, &mem);
14101409 }
14111410
14121411 static long
@@ -2064,7 +2063,6 @@ mshv_dev_release(struct inode *inode, struct file *filp) · 651 unmodified lines
20642063 return 0;
20652064 }
20662065
2067−static int mshv_cpuhp_online;
20682066 static int mshv_root_sched_online;
20692067
20702068 static const char *scheduler_type_to_string(enum hv_scheduler_type type)
@@ -2249,27 +2247,6 @@ root_scheduler_deinit(void) · 178 unmodified lines
22492247 free_percpu(root_scheduler_output);
22502248 }
22512249
2252−static int mshv_reboot_notify(struct notifier_block *nb,
2253− unsigned long code, void *unused)
2254−{
2255− cpuhp_remove_state(mshv_cpuhp_online);
2256− return 0;
2257−}
2258−
2259−struct notifier_block mshv_reboot_nb = {
2260− .notifier_call = mshv_reboot_notify,
2261−};
2262−
2263−static void mshv_root_partition_exit(void)
2264−{
2265− unregister_reboot_notifier(&mshv_reboot_nb);
2266−}
2267−
2268−static int __init mshv_root_partition_init(struct device *dev)
2269−{
2270− return register_reboot_notifier(&mshv_reboot_nb);
2271−}
2272−
22732250 static int __init mshv_init_vmm_caps(struct device *dev)
22742251 {
22752252 int ret;
@@ -2314,39 +2291,21 @@ static int __init mshv_parent_partition_init(void) · 38 unmodified lines
23142291 MSHV_HV_MAX_VERSION);
23152292 }
23162293
2317− mshv_root.synic_pages = alloc_percpu(struct hv_synic_pages);
2318− if (!mshv_root.synic_pages) {
2319− dev_err(dev, "Failed to allocate percpu synic page\n");
2320− ret = -ENOMEM;
2294+ ret = mshv_synic_init(dev);
2295+ if (ret)
23212296 goto device_deregister;
2322− }
2323−
2324− ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mshv_synic",
2325− mshv_synic_init,
2326− mshv_synic_cleanup);
2327− if (ret < 0) {
2328− dev_err(dev, "Failed to setup cpu hotplug state: %i\n", ret);
2329− goto free_synic_pages;
2330− }
2331−
2332− mshv_cpuhp_online = ret;
23332297
23342298 ret = mshv_init_vmm_caps(dev);
23352299 if (ret)
2336− goto remove_cpu_state;
2300+ goto synic_cleanup;
23372301
23382302 ret = mshv_retrieve_scheduler_type(dev);
23392303 if (ret)
2340− goto remove_cpu_state;
2341−
2342− if (hv_root_partition())
2343− ret = mshv_root_partition_init(dev);
2344− if (ret)
2345− goto remove_cpu_state;
2304+ goto synic_cleanup;
23462305
23472306 ret = root_scheduler_init(dev);
23482307 if (ret)
2349− goto exit_partition;
2308+ goto synic_cleanup;
23502309
23512310 ret = mshv_debugfs_init();
23522311 if (ret)
@@ -2367,13 +2326,8 @@ exit_debugfs: · 14 unmodified lines
23672326 mshv_debugfs_exit();
23682327 deinit_root_scheduler:
23692328 root_scheduler_deinit();
2370−exit_partition:
2371− if (hv_root_partition())
2372− mshv_root_partition_exit();
2373−remove_cpu_state:
2374− cpuhp_remove_state(mshv_cpuhp_online);
2375−free_synic_pages:
2376− free_percpu(mshv_root.synic_pages);
2329+synic_cleanup:
2330+ mshv_synic_exit();
23772331 device_deregister:
23782332 misc_deregister(&mshv_dev);
23792333 return ret;
@@ -2387,10 +2341,7 @@ static void __exit mshv_parent_partition_exit(void) · 7 unmodified lines
23872341 misc_deregister(&mshv_dev);
23882342 mshv_irqfd_wq_cleanup();
23892343 root_scheduler_deinit();
2390− if (hv_root_partition())
2391− mshv_root_partition_exit();
2392− cpuhp_remove_state(mshv_cpuhp_online);
2393− free_percpu(mshv_root.synic_pages);
2344+ mshv_synic_exit();
23942345 }
23952346
23962347 module_init(mshv_parent_partition_init);
drivers/hv/mshv_synic.c+173−15
@@ -10,13 +10,22 @@ · 9 unmodified lines
1010 #include <linux/kernel.h>
1111 #include <linux/slab.h>
1212 #include <linux/mm.h>
13+#include <linux/interrupt.h>
1314 #include <linux/io.h>
1415 #include <linux/random.h>
16+#include <linux/cpuhotplug.h>
17+#include <linux/reboot.h>
1518 #include <asm/mshyperv.h>
19+#include <linux/acpi.h>
1620
1721 #include "mshv_eventfd.h"
1822 #include "mshv.h"
1923
24+static int synic_cpuhp_online;
25+static struct hv_synic_pages __percpu *synic_pages;
26+static int mshv_sint_vector = -1; /* hwirq for the SynIC SINTs */
27+static int mshv_sint_irq = -1; /* Linux IRQ for mshv_sint_vector */
28+
2029 static u32 synic_event_ring_get_queued_port(u32 sint_index)
2130 {
2231 struct hv_synic_event_ring_page **event_ring_page;
@@ -26,7 +35,7 @@ static u32 synic_event_ring_get_queued_port(u32 sint_index) · 3 unmodified lines
2635 u32 message;
2736 u8 tail;
2837
29− spages = this_cpu_ptr(mshv_root.synic_pages);
38+ spages = this_cpu_ptr(synic_pages);
3039 event_ring_page = &spages->synic_event_ring_page;
3140 synic_eventring_tail = (u8 **)this_cpu_ptr(hv_synic_eventring_tail);
3241
@@ -393,7 +402,7 @@ unlock_out: · 360 unmodified lines
393402
394403 void mshv_isr(void)
395404 {
396− struct hv_synic_pages *spages = this_cpu_ptr(mshv_root.synic_pages);
405+ struct hv_synic_pages *spages = this_cpu_ptr(synic_pages);
397406 struct hv_message_page **msg_page = &spages->hyp_synic_message_page;
398407 struct hv_message *msg;
399408 bool handled;
@@ -437,25 +446,21 @@ void mshv_isr(void) · 37 unmodified lines
437446 if (msg->header.message_flags.msg_pending)
438447 hv_set_non_nested_msr(HV_MSR_EOM, 0);
439448
440−#ifdef HYPERVISOR_CALLBACK_VECTOR
441− add_interrupt_randomness(HYPERVISOR_CALLBACK_VECTOR);
442−#endif
449+ add_interrupt_randomness(mshv_sint_vector);
443450 } else {
444451 pr_warn_once("%s: unknown message type 0x%x\n", __func__,
445452 msg->header.message_type);
446453 }
447454 }
448455
449−int mshv_synic_init(unsigned int cpu)
456+static int mshv_synic_cpu_init(unsigned int cpu)
450457 {
451458 union hv_synic_simp simp;
452459 union hv_synic_siefp siefp;
453460 union hv_synic_sirbp sirbp;
454−#ifdef HYPERVISOR_CALLBACK_VECTOR
455461 union hv_synic_sint sint;
456−#endif
457462 union hv_synic_scontrol sctrl;
458− struct hv_synic_pages *spages = this_cpu_ptr(mshv_root.synic_pages);
463+ struct hv_synic_pages *spages = this_cpu_ptr(synic_pages);
459464 struct hv_message_page **msg_page = &spages->hyp_synic_message_page;
460465 struct hv_synic_event_flags_page **event_flags_page =
461466 &spages->synic_event_flags_page;
@@ -496,10 +501,12 @@ int mshv_synic_init(unsigned int cpu) · 34 unmodified lines
496501
497502 hv_set_non_nested_msr(HV_MSR_SIRBP, sirbp.as_uint64);
498503
499−#ifdef HYPERVISOR_CALLBACK_VECTOR
504+ if (mshv_sint_irq != -1)
505+ enable_percpu_irq(mshv_sint_irq, 0);
506+
500507 /* Enable intercepts */
501508 sint.as_uint64 = 0;
502− sint.vector = HYPERVISOR_CALLBACK_VECTOR;
509+ sint.vector = mshv_sint_vector;
503510 sint.masked = false;
504511 sint.auto_eoi = hv_recommend_using_aeoi();
505512 hv_set_non_nested_msr(HV_MSR_SINT0 + HV_SYNIC_INTERCEPTION_SINT_INDEX,
@@ -507,13 +514,12 @@ int mshv_synic_init(unsigned int cpu) · 1 unmodified line
507514
508515 /* Doorbell SINT */
509516 sint.as_uint64 = 0;
510− sint.vector = HYPERVISOR_CALLBACK_VECTOR;
517+ sint.vector = mshv_sint_vector;
511518 sint.masked = false;
512519 sint.as_intercept = 1;
513520 sint.auto_eoi = hv_recommend_using_aeoi();
514521 hv_set_non_nested_msr(HV_MSR_SINT0 + HV_SYNIC_DOORBELL_SINT_INDEX,
515522 sint.as_uint64);
516−#endif
517523
518524 /* Enable global synic bit */
519525 sctrl.as_uint64 = hv_get_non_nested_msr(HV_MSR_SCONTROL);
@@ -542,14 +548,14 @@ cleanup: · 22 unmodified lines
542548 return -EFAULT;
543549 }
544550
545−int mshv_synic_cleanup(unsigned int cpu)
551+static int mshv_synic_cpu_exit(unsigned int cpu)
546552 {
547553 union hv_synic_sint sint;
548554 union hv_synic_simp simp;
549555 union hv_synic_siefp siefp;
550556 union hv_synic_sirbp sirbp;
551557 union hv_synic_scontrol sctrl;
552− struct hv_synic_pages *spages = this_cpu_ptr(mshv_root.synic_pages);
558+ struct hv_synic_pages *spages = this_cpu_ptr(synic_pages);
553559 struct hv_message_page **msg_page = &spages->hyp_synic_message_page;
554560 struct hv_synic_event_flags_page **event_flags_page =
555561 &spages->synic_event_flags_page;
@@ -568,6 +574,9 @@ int mshv_synic_cleanup(unsigned int cpu) · 12 unmodified lines
568574 hv_set_non_nested_msr(HV_MSR_SINT0 + HV_SYNIC_DOORBELL_SINT_INDEX,
569575 sint.as_uint64);
570576
577+ if (mshv_sint_irq != -1)
578+ disable_percpu_irq(mshv_sint_irq);
579+
571580 /* Disable Synic's event ring page */
572581 sirbp.as_uint64 = hv_get_non_nested_msr(HV_MSR_SIRBP);
573582 sirbp.sirbp_enabled = false;
@@ -663,3 +672,152 @@ mshv_unregister_doorbell(u64 partition_id, int doorbell_portid) · 89 unmodified lines
663672
664673 mshv_portid_free(doorbell_portid);
665674 }
675+
676+static int mshv_synic_reboot_notify(struct notifier_block *nb,
677+ unsigned long code, void *unused)
678+{
679+ if (!hv_root_partition())
680+ return 0;
681+
682+ cpuhp_remove_state(synic_cpuhp_online);
683+ return 0;
684+}
685+
686+static struct notifier_block mshv_synic_reboot_nb = {
687+ .notifier_call = mshv_synic_reboot_notify,
688+};
689+
690+#ifndef HYPERVISOR_CALLBACK_VECTOR
691+static DEFINE_PER_CPU(long, mshv_evt);
692+
693+static irqreturn_t mshv_percpu_isr(int irq, void *dev_id)
694+{
695+ mshv_isr();
696+ return IRQ_HANDLED;
697+}
698+
699+#ifdef CONFIG_ACPI
700+static int __init mshv_acpi_setup_sint_irq(void)
701+{
702+ return acpi_register_gsi(NULL, mshv_sint_vector, ACPI_EDGE_SENSITIVE,
703+ ACPI_ACTIVE_HIGH);
704+}
705+
706+static void mshv_acpi_cleanup_sint_irq(void)
707+{
708+ acpi_unregister_gsi(mshv_sint_vector);
709+}
710+#else
711+static int __init mshv_acpi_setup_sint_irq(void)
712+{
713+ return -ENODEV;
714+}
715+
716+static void mshv_acpi_cleanup_sint_irq(void)
717+{
718+}
719+#endif
720+
721+static int __init mshv_sint_vector_setup(void)
722+{
723+ int ret;
724+ struct hv_register_assoc reg = {
725+ .name = HV_ARM64_REGISTER_SINT_RESERVED_INTERRUPT_ID,
726+ };
727+ union hv_input_vtl input_vtl = { 0 };
728+
729+ if (acpi_disabled)
730+ return -ENODEV;
731+
732+ ret = hv_call_get_vp_registers(HV_VP_INDEX_SELF, HV_PARTITION_ID_SELF,
733+ 1, input_vtl, &reg);
734+ if (ret || !reg.value.reg64)
735+ return -ENODEV;
736+
737+ mshv_sint_vector = reg.value.reg64;
738+ ret = mshv_acpi_setup_sint_irq();
739+ if (ret < 0) {
740+ pr_err("Failed to setup IRQ for MSHV SINT vector %d: %d\n",
741+ mshv_sint_vector, ret);
742+ goto out_fail;
743+ }
744+
745+ mshv_sint_irq = ret;
746+
747+ ret = request_percpu_irq(mshv_sint_irq, mshv_percpu_isr, "MSHV",
748+ &mshv_evt);
749+ if (ret)
750+ goto out_unregister;
751+
752+ return 0;
753+
754+out_unregister:
755+ mshv_acpi_cleanup_sint_irq();
756+out_fail:
757+ return ret;
758+}
759+
760+static void mshv_sint_vector_cleanup(void)
761+{
762+ free_percpu_irq(mshv_sint_irq, &mshv_evt);
763+ mshv_acpi_cleanup_sint_irq();
764+}
765+#else /* !HYPERVISOR_CALLBACK_VECTOR */
766+static int __init mshv_sint_vector_setup(void)
767+{
768+ mshv_sint_vector = HYPERVISOR_CALLBACK_VECTOR;
769+ return 0;
770+}
771+
772+static void mshv_sint_vector_cleanup(void)
773+{
774+}
775+#endif /* HYPERVISOR_CALLBACK_VECTOR */
776+
777+int __init mshv_synic_init(struct device *dev)
778+{
779+ int ret = 0;
780+
781+ ret = mshv_sint_vector_setup();
782+ if (ret)
783+ return ret;
784+
785+ synic_pages = alloc_percpu(struct hv_synic_pages);
786+ if (!synic_pages) {
787+ dev_err(dev, "Failed to allocate percpu synic page\n");
788+ ret = -ENOMEM;
789+ goto sint_vector_cleanup;
790+ }
791+
792+ ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mshv_synic",
793+ mshv_synic_cpu_init,
794+ mshv_synic_cpu_exit);
795+ if (ret < 0) {
796+ dev_err(dev, "Failed to setup cpu hotplug state: %i\n", ret);
797+ goto free_synic_pages;
798+ }
799+
800+ synic_cpuhp_online = ret;
801+
802+ ret = register_reboot_notifier(&mshv_synic_reboot_nb);
803+ if (ret)
804+ goto remove_cpuhp_state;
805+
806+ return 0;
807+
808+remove_cpuhp_state:
809+ cpuhp_remove_state(synic_cpuhp_online);
810+free_synic_pages:
811+ free_percpu(synic_pages);
812+sint_vector_cleanup:
813+ mshv_sint_vector_cleanup();
814+ return ret;
815+}
816+
817+void mshv_synic_exit(void)
818+{
819+ unregister_reboot_notifier(&mshv_synic_reboot_nb);
820+ cpuhp_remove_state(synic_cpuhp_online);
821+ free_percpu(synic_pages);
822+ mshv_sint_vector_cleanup();
823+}
drivers/hwmon/axi-fan-control.c+1−1
@@ -507,7 +507,7 @@ static int axi_fan_control_probe(struct platform_device *pdev) · 506 unmodified lines
507507 ret = devm_request_threaded_irq(&pdev->dev, ctl->irq, NULL,
508508 axi_fan_control_irq_handler,
509509 IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
510− pdev->driver_override, ctl);
510+ NULL, ctl);
511511 if (ret)
512512 return dev_err_probe(&pdev->dev, ret,
513513 "failed to request an irq\n");
drivers/hwmon/max6639.c+5−5
@@ -232,7 +232,7 @@ static int max6639_read_fan(struct device *dev, u32 attr, int channel, · 231 unmodified lines
232232 static int max6639_set_ppr(struct max6639_data *data, int channel, u8 ppr)
233233 {
234234 /* Decrement the PPR value and shift left by 6 to match the register format */
235− return regmap_write(data->regmap, MAX6639_REG_FAN_PPR(channel), ppr-- << 6);
235+ return regmap_write(data->regmap, MAX6639_REG_FAN_PPR(channel), --ppr << 6);
236236 }
237237
238238 static int max6639_write_fan(struct device *dev, u32 attr, int channel,
@@ -524,8 +524,8 @@ static int max6639_probe_child_from_dt(struct i2c_client *client, · 285 unmodified lines
524524
525525 {
526526 struct device *dev = &client->dev;
527− u32 i;
528− int err, val;
527+ u32 i, val;
528+ int err;
529529
530530 err = of_property_read_u32(child, "reg", &i);
531531 if (err) {
@@ -540,8 +540,8 @@ static int max6639_probe_child_from_dt(struct i2c_client *client, · 8 unmodified lines
540540
541541 err = of_property_read_u32(child, "pulses-per-revolution", &val);
542542 if (!err) {
543− if (val < 1 || val > 5) {
544− dev_err(dev, "invalid pulses-per-revolution %d of %pOFn\n", val, child);
543+ if (val < 1 || val > 4) {
544+ dev_err(dev, "invalid pulses-per-revolution %u of %pOFn\n", val, child);
545545 return -EINVAL;
546546 }
547547 data->ppr[i] = val;
drivers/hwmon/pmbus/hac300s.c+2−0
@@ -58,6 +58,8 @@ static int hac300s_read_word_data(struct i2c_client *client, int page, · 57 unmodified lines
5858 case PMBUS_MFR_VOUT_MIN:
5959 case PMBUS_READ_VOUT:
6060 rv = pmbus_read_word_data(client, page, phase, reg);
61+ if (rv < 0)
62+ return rv;
6163 return FIELD_GET(LINEAR11_MANTISSA_MASK, rv);
6264 default:
6365 return -ENODATA;
drivers/hwmon/pmbus/ina233.c+2−0
@@ -67,6 +67,8 @@ static int ina233_read_word_data(struct i2c_client *client, int page, · 66 unmodified lines
6767 switch (reg) {
6868 case PMBUS_VIRT_READ_VMON:
6969 ret = pmbus_read_word_data(client, 0, 0xff, MFR_READ_VSHUNT);
70+ if (ret < 0)
71+ return ret;
7072
7173 /* Adjust returned value to match VIN coefficients */
7274 /* VIN: 1.25 mV VSHUNT: 2.5 uV LSB */
drivers/hwmon/pmbus/isl68137.c+5−2
@@ -98,8 +98,11 @@ static ssize_t isl68137_avs_enable_show_page(struct i2c_client *client, · 97 unmodified lines
9898 {
9999 int val = pmbus_read_byte_data(client, page, PMBUS_OPERATION);
100100
101− return sprintf(buf, "%d\n",
102− (val & ISL68137_VOUT_AVS) == ISL68137_VOUT_AVS ? 1 : 0);
101+ if (val < 0)
102+ return val;
103+
104+ return sysfs_emit(buf, "%d\n",
105+ (val & ISL68137_VOUT_AVS) == ISL68137_VOUT_AVS);
103106 }
104107
105108 static ssize_t isl68137_avs_enable_store_page(struct i2c_client *client,
drivers/hwmon/pmbus/mp2869.c+21−14
@@ -165,7 +165,7 @@ static int mp2869_read_byte_data(struct i2c_client *client, int page, int reg) · 164 unmodified lines
165165 {
166166 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
167167 struct mp2869_data *data = to_mp2869_data(info);
168− int ret;
168+ int ret, mfr;
169169
170170 switch (reg) {
171171 case PMBUS_VOUT_MODE:
@@ -188,11 +188,14 @@ static int mp2869_read_byte_data(struct i2c_client *client, int page, int reg) · 16 unmodified lines
188188 if (ret < 0)
189189 return ret;
190190
191+ mfr = pmbus_read_byte_data(client, page,
192+ PMBUS_STATUS_MFR_SPECIFIC);
193+ if (mfr < 0)
194+ return mfr;
195+
191196 ret = (ret & ~GENMASK(2, 2)) |
192197 FIELD_PREP(GENMASK(2, 2),
193− FIELD_GET(GENMASK(1, 1),
194− pmbus_read_byte_data(client, page,
195− PMBUS_STATUS_MFR_SPECIFIC)));
198+ FIELD_GET(GENMASK(1, 1), mfr));
196199 break;
197200 case PMBUS_STATUS_TEMPERATURE:
198201 /*
@@ -207,15 +210,16 @@ static int mp2869_read_byte_data(struct i2c_client *client, int page, int reg) · 8 unmodified lines
207210 if (ret < 0)
208211 return ret;
209212
213+ mfr = pmbus_read_byte_data(client, page,
214+ PMBUS_STATUS_MFR_SPECIFIC);
215+ if (mfr < 0)
216+ return mfr;
217+
210218 ret = (ret & ~GENMASK(7, 6)) |
211219 FIELD_PREP(GENMASK(6, 6),
212− FIELD_GET(GENMASK(1, 1),
213− pmbus_read_byte_data(client, page,
214− PMBUS_STATUS_MFR_SPECIFIC))) |
220+ FIELD_GET(GENMASK(1, 1), mfr)) |
215221 FIELD_PREP(GENMASK(7, 7),
216− FIELD_GET(GENMASK(1, 1),
217− pmbus_read_byte_data(client, page,
218− PMBUS_STATUS_MFR_SPECIFIC)));
222+ FIELD_GET(GENMASK(1, 1), mfr));
219223 break;
220224 default:
221225 ret = -ENODATA;
@@ -230,7 +234,7 @@ static int mp2869_read_word_data(struct i2c_client *client, int page, int phase, · 8 unmodified lines
230234 {
231235 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
232236 struct mp2869_data *data = to_mp2869_data(info);
233− int ret;
237+ int ret, mfr;
234238
235239 switch (reg) {
236240 case PMBUS_STATUS_WORD:
@@ -246,11 +250,14 @@ static int mp2869_read_word_data(struct i2c_client *client, int page, int phase, · 9 unmodified lines
246250 if (ret < 0)
247251 return ret;
248252
253+ mfr = pmbus_read_byte_data(client, page,
254+ PMBUS_STATUS_MFR_SPECIFIC);
255+ if (mfr < 0)
256+ return mfr;
257+
249258 ret = (ret & ~GENMASK(2, 2)) |
250259 FIELD_PREP(GENMASK(2, 2),
251− FIELD_GET(GENMASK(1, 1),
252− pmbus_read_byte_data(client, page,
253− PMBUS_STATUS_MFR_SPECIFIC)));
260+ FIELD_GET(GENMASK(1, 1), mfr));
254261 break;
255262 case PMBUS_READ_VIN:
256263 /*
drivers/hwmon/pmbus/mp2975.c+2−0
@@ -313,6 +313,8 @@ static int mp2973_read_word_data(struct i2c_client *client, int page, · 312 unmodified lines
313313 case PMBUS_STATUS_WORD:
314314 /* MP2973 & MP2971 return PGOOD instead of PB_STATUS_POWER_GOOD_N. */
315315 ret = pmbus_read_word_data(client, page, phase, reg);
316+ if (ret < 0)
317+ return ret;
316318 ret ^= PB_STATUS_POWER_GOOD_N;
317319 break;
318320 case PMBUS_OT_FAULT_LIMIT:
drivers/i2c/busses/Kconfig+2−0
@@ -1213,6 +1213,8 @@ config I2C_TEGRA · 1212 unmodified lines
12131213 tristate "NVIDIA Tegra internal I2C controller"
12141214 depends on ARCH_TEGRA || (COMPILE_TEST && (ARC || ARM || ARM64 || M68K || RISCV || SUPERH || SPARC))
12151215 # COMPILE_TEST needs architectures with readsX()/writesX() primitives
1216+ depends on PINCTRL
1217+ # ARCH_TEGRA implies PINCTRL, but the COMPILE_TEST side doesn't.
12161218 help
12171219 If you say yes to this option, support will be included for the
12181220 I2C controller embedded in NVIDIA Tegra SOCs
drivers/i2c/busses/i2c-cp2615.c+3−0
@@ -298,6 +298,9 @@ cp2615_i2c_probe(struct usb_interface *usbif, const struct usb_device_id *id) · 297 unmodified lines
298298 if (!adap)
299299 return -ENOMEM;
300300
301+ if (!usbdev->serial)
302+ return -EINVAL;
303+
301304 strscpy(adap->name, usbdev->serial, sizeof(adap->name));
302305 adap->owner = THIS_MODULE;
303306 adap->dev.parent = &usbif->dev;
drivers/i2c/busses/i2c-fsi.c+1−0
@@ -729,6 +729,7 @@ static int fsi_i2c_probe(struct fsi_device *fsi_dev) · 728 unmodified lines
729729 rc = i2c_add_adapter(&port->adapter);
730730 if (rc < 0) {
731731 dev_err(dev, "Failed to register adapter: %d\n", rc);
732+ of_node_put(np);
732733 kfree(port);
733734 continue;
734735 }
drivers/i2c/busses/i2c-pxa.c+16−1
@@ -268,6 +268,7 @@ struct pxa_i2c { · 267 unmodified lines
268268 struct pinctrl *pinctrl;
269269 struct pinctrl_state *pinctrl_default;
270270 struct pinctrl_state *pinctrl_recovery;
271+ bool reset_before_xfer;
271272 };
272273
273274 #define _IBMR(i2c) ((i2c)->reg_ibmr)
@@ -1144,6 +1145,11 @@ static int i2c_pxa_xfer(struct i2c_adapter *adap, · 870 unmodified lines
11441145 {
11451146 struct pxa_i2c *i2c = adap->algo_data;
11461147
1148+ if (i2c->reset_before_xfer) {
1149+ i2c_pxa_reset(i2c);
1150+ i2c->reset_before_xfer = false;
1151+ }
1152+
11471153 return i2c_pxa_internal_xfer(i2c, msgs, num, i2c_pxa_do_xfer);
11481154 }
11491155
@@ -1521,7 +1527,16 @@ static int i2c_pxa_probe(struct platform_device *dev) · 371 unmodified lines
15211527 }
15221528 }
15231529
1524− i2c_pxa_reset(i2c);
1530+ /*
1531+ * Skip reset on Armada 3700 when recovery is used to avoid
1532+ * controller hang due to the pinctrl state changes done by
1533+ * the generic recovery initialization code. The reset will
1534+ * be performed later, prior to the first transfer.
1535+ */
1536+ if (i2c_type == REGS_A3700 && i2c->adap.bus_recovery_info)
1537+ i2c->reset_before_xfer = true;
1538+ else
1539+ i2c_pxa_reset(i2c);
15251540
15261541 ret = i2c_add_numbered_adapter(&i2c->adap);
15271542 if (ret < 0)
drivers/i2c/busses/i2c-tegra.c+4−1
@@ -2047,8 +2047,11 @@ static int tegra_i2c_probe(struct platform_device *pdev) · 2046 unmodified lines
20472047 *
20482048 * VI I2C device shouldn't be marked as IRQ-safe because VI I2C won't
20492049 * be used for atomic transfers. ACPI device is not IRQ safe also.
2050+ *
2051+ * Devices with pinctrl states cannot be marked IRQ-safe as the pinctrl
2052+ * state transitions during runtime PM require mutexes.
20502053 */
2051− if (!IS_VI(i2c_dev) && !has_acpi_companion(i2c_dev->dev))
2054+ if (!IS_VI(i2c_dev) && !has_acpi_companion(i2c_dev->dev) && !i2c_dev->dev->pins)
20522055 pm_runtime_irq_safe(i2c_dev->dev);
20532056
20542057 pm_runtime_enable(i2c_dev->dev);
drivers/iommu/amd/iommu.c+14−1
@@ -2909,8 +2909,21 @@ static struct iommu_domain blocked_domain = { · 2908 unmodified lines
29092909
29102910 static struct protection_domain identity_domain;
29112911
2912+static int amd_iommu_identity_attach(struct iommu_domain *dom, struct device *dev,
2913+ struct iommu_domain *old)
2914+{
2915+ /*
2916+ * Don't allow attaching a device to the identity domain if SNP is
2917+ * enabled.
2918+ */
2919+ if (amd_iommu_snp_en)
2920+ return -EINVAL;
2921+
2922+ return amd_iommu_attach_device(dom, dev, old);
2923+}
2924+
29122925 static const struct iommu_domain_ops identity_domain_ops = {
2913− .attach_dev = amd_iommu_attach_device,
2926+ .attach_dev = amd_iommu_identity_attach,
29142927 };
29152928
29162929 void amd_iommu_init_identity_domain(void)
drivers/iommu/intel/dmar.c+1−2
@@ -1314,7 +1314,6 @@ static int qi_check_fault(struct intel_iommu *iommu, int index, int wait_index) · 1313 unmodified lines
13141314 if (fault & DMA_FSTS_ITE) {
13151315 head = readl(iommu->reg + DMAR_IQH_REG);
13161316 head = ((head >> shift) - 1 + QI_LENGTH) % QI_LENGTH;
1317− head |= 1;
13181317 tail = readl(iommu->reg + DMAR_IQT_REG);
13191318 tail = ((tail >> shift) - 1 + QI_LENGTH) % QI_LENGTH;
13201319
@@ -1331,7 +1330,7 @@ static int qi_check_fault(struct intel_iommu *iommu, int index, int wait_index) · 10 unmodified lines
13311330 do {
13321331 if (qi->desc_status[head] == QI_IN_USE)
13331332 qi->desc_status[head] = QI_ABORT;
1334− head = (head - 2 + QI_LENGTH) % QI_LENGTH;
1333+ head = (head - 1 + QI_LENGTH) % QI_LENGTH;
13351334 } while (head != tail);
13361335
13371336 /*
drivers/iommu/intel/svm.c+8−4
@@ -164,9 +164,12 @@ static int intel_svm_set_dev_pasid(struct iommu_domain *domain, · 163 unmodified lines
164164 if (IS_ERR(dev_pasid))
165165 return PTR_ERR(dev_pasid);
166166
167− ret = iopf_for_domain_replace(domain, old, dev);
168− if (ret)
169− goto out_remove_dev_pasid;
167+ /* SVA with non-IOMMU/PRI IOPF handling is allowed. */
168+ if (info->pri_supported) {
169+ ret = iopf_for_domain_replace(domain, old, dev);
170+ if (ret)
171+ goto out_remove_dev_pasid;
172+ }
170173
171174 /* Setup the pasid table: */
172175 sflags = cpu_feature_enabled(X86_FEATURE_LA57) ? PASID_FLAG_FL5LP : 0;
@@ -181,7 +184,8 @@ static int intel_svm_set_dev_pasid(struct iommu_domain *domain, · 8 unmodified lines
181184
182185 return 0;
183186 out_unwind_iopf:
184− iopf_for_domain_replace(old, domain, dev);
187+ if (info->pri_supported)
188+ iopf_for_domain_replace(old, domain, dev);
185189 out_remove_dev_pasid:
186190 domain_remove_dev_pasid(domain, dev, pasid);
187191 return ret;
drivers/iommu/iommu-sva.c+6−6
@@ -182,13 +182,13 @@ void iommu_sva_unbind_device(struct iommu_sva *handle) · 181 unmodified lines
182182 iommu_detach_device_pasid(domain, dev, iommu_mm->pasid);
183183 if (--domain->users == 0) {
184184 list_del(&domain->next);
185− iommu_domain_free(domain);
186− }
185+ if (list_empty(&iommu_mm->sva_domains)) {
186+ list_del(&iommu_mm->mm_list_elm);
187+ if (list_empty(&iommu_sva_mms))
188+ iommu_sva_present = false;
189+ }
187190
188− if (list_empty(&iommu_mm->sva_domains)) {
189− list_del(&iommu_mm->mm_list_elm);
190− if (list_empty(&iommu_sva_mms))
191− iommu_sva_present = false;
191+ iommu_domain_free(domain);
192192 }
193193
194194 mutex_unlock(&iommu_sva_lock);
drivers/iommu/iommu.c+5−1
@@ -1213,7 +1213,11 @@ static int iommu_create_device_direct_mappings(struct iommu_domain *domain, · 1212 unmodified lines
12131213 if (addr == end)
12141214 goto map_end;
12151215
1216− phys_addr = iommu_iova_to_phys(domain, addr);
1216+ /*
1217+ * Return address by iommu_iova_to_phys for 0 is
1218+ * ambiguous. Offset to address 1 if addr is 0.
1219+ */
1220+ phys_addr = iommu_iova_to_phys(domain, addr ? addr : 1);
12171221 if (!phys_addr) {
12181222 map_size += pg_size;
12191223 continue;
drivers/irqchip/irq-riscv-rpmi-sysmsi.c+1−0
@@ -250,6 +250,7 @@ static int rpmi_sysmsi_probe(struct platform_device *pdev) · 249 unmodified lines
250250 rc = riscv_acpi_get_gsi_info(fwnode, &priv->gsi_base, &id,
251251 &nr_irqs, NULL);
252252 if (rc) {
253+ mbox_free_channel(priv->chan);
253254 dev_err(dev, "failed to find GSI mapping\n");
254255 return rc;
255256 }
drivers/mmc/host/sdhci-pci-gli.c+9−0
@@ -68,6 +68,9 @@ · 67 unmodified lines
6868 #define GLI_9750_MISC_TX1_DLY_VALUE 0x5
6969 #define SDHCI_GLI_9750_MISC_SSC_OFF BIT(26)
7070
71+#define SDHCI_GLI_9750_GM_BURST_SIZE 0x510
72+#define SDHCI_GLI_9750_GM_BURST_SIZE_R_OSRC_LMT GENMASK(17, 16)
73+
7174 #define SDHCI_GLI_9750_TUNING_CONTROL 0x540
7275 #define SDHCI_GLI_9750_TUNING_CONTROL_EN BIT(4)
7376 #define GLI_9750_TUNING_CONTROL_EN_ON 0x1
@@ -345,10 +348,16 @@ static void gli_set_9750(struct sdhci_host *host) · 271 unmodified lines
345348 u32 misc_value;
346349 u32 parameter_value;
347350 u32 control_value;
351+ u32 burst_value;
348352 u16 ctrl2;
349353
350354 gl9750_wt_on(host);
351355
356+ /* clear R_OSRC_Lmt to avoid DMA write corruption */
357+ burst_value = sdhci_readl(host, SDHCI_GLI_9750_GM_BURST_SIZE);
358+ burst_value &= ~SDHCI_GLI_9750_GM_BURST_SIZE_R_OSRC_LMT;
359+ sdhci_writel(host, burst_value, SDHCI_GLI_9750_GM_BURST_SIZE);
360+
352361 driving_value = sdhci_readl(host, SDHCI_GLI_9750_DRIVING);
353362 pll_value = sdhci_readl(host, SDHCI_GLI_9750_PLL);
354363 sw_ctrl_value = sdhci_readl(host, SDHCI_GLI_9750_SW_CTRL);
drivers/mmc/host/sdhci.c+8−1
@@ -4532,8 +4532,15 @@ int sdhci_setup_host(struct sdhci_host *host) · 4531 unmodified lines
45324532 * their platform code before calling sdhci_add_host(), and we
45334533 * won't assume 8-bit width for hosts without that CAP.
45344534 */
4535− if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA))
4535+ if (host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA) {
4536+ host->caps1 &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_DDR50);
4537+ if (host->quirks2 & SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400)
4538+ host->caps1 &= ~SDHCI_SUPPORT_HS400;
4539+ mmc->caps2 &= ~(MMC_CAP2_HS200 | MMC_CAP2_HS400 | MMC_CAP2_HS400_ES);
4540+ mmc->caps &= ~(MMC_CAP_DDR | MMC_CAP_UHS);
4541+ } else {
45364542 mmc->caps |= MMC_CAP_4_BIT_DATA;
4543+ }
45374544
45384545 if (host->quirks2 & SDHCI_QUIRK2_HOST_NO_CMD23)
45394546 mmc->caps &= ~MMC_CAP_CMD23;
drivers/mtd/nand/raw/brcmnand/brcmnand.c+2−4
@@ -2350,14 +2350,12 @@ static int brcmnand_write(struct mtd_info *mtd, struct nand_chip *chip, · 2349 unmodified lines
23502350 for (i = 0; i < ctrl->max_oob; i += 4)
23512351 oob_reg_write(ctrl, i, 0xffffffff);
23522352
2353− if (mtd->oops_panic_write)
2353+ if (mtd->oops_panic_write) {
23542354 /* switch to interrupt polling and PIO mode */
23552355 disable_ctrl_irqs(ctrl);
2356−
2357− if (use_dma(ctrl) && (has_edu(ctrl) || !oob) && flash_dma_buf_ok(buf)) {
2356+ } else if (use_dma(ctrl) && (has_edu(ctrl) || !oob) && flash_dma_buf_ok(buf)) {
23582357 if (ctrl->dma_trans(host, addr, (u32 *)buf, oob, mtd->writesize,
23592358 CMD_PROGRAM_PAGE))
2360−
23612359 ret = -EIO;
23622360
23632361 goto out;
drivers/mtd/nand/raw/cadence-nand-controller.c+1−1
@@ -3133,7 +3133,7 @@ static int cadence_nand_init(struct cdns_nand_ctrl *cdns_ctrl) · 3132 unmodified lines
31333133 sizeof(*cdns_ctrl->cdma_desc),
31343134 &cdns_ctrl->dma_cdma_desc,
31353135 GFP_KERNEL);
3136− if (!cdns_ctrl->dma_cdma_desc)
3136+ if (!cdns_ctrl->cdma_desc)
31373137 return -ENOMEM;
31383138
31393139 cdns_ctrl->buf_size = SZ_16K;
drivers/mtd/nand/raw/nand_base.c+12−2
@@ -4737,11 +4737,16 @@ static void nand_shutdown(struct mtd_info *mtd) · 4736 unmodified lines
47374737 static int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
47384738 {
47394739 struct nand_chip *chip = mtd_to_nand(mtd);
4740+ int ret;
47404741
47414742 if (!chip->ops.lock_area)
47424743 return -ENOTSUPP;
47434744
4744− return chip->ops.lock_area(chip, ofs, len);
4745+ nand_get_device(chip);
4746+ ret = chip->ops.lock_area(chip, ofs, len);
4747+ nand_release_device(chip);
4748+
4749+ return ret;
47454750 }
47464751
47474752 /**
@@ -4753,11 +4758,16 @@ static int nand_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) · 5 unmodified lines
47534758 static int nand_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
47544759 {
47554760 struct nand_chip *chip = mtd_to_nand(mtd);
4761+ int ret;
47564762
47574763 if (!chip->ops.unlock_area)
47584764 return -ENOTSUPP;
47594765
4760− return chip->ops.unlock_area(chip, ofs, len);
4766+ nand_get_device(chip);
4767+ ret = chip->ops.unlock_area(chip, ofs, len);
4768+ nand_release_device(chip);
4769+
4770+ return ret;
47614771 }
47624772
47634773 /* Set default functions */
drivers/mtd/nand/raw/pl35x-nand-controller.c+3−0
@@ -862,6 +862,9 @@ static int pl35x_nfc_setup_interface(struct nand_chip *chip, int cs, · 861 unmodified lines
862862 PL35X_SMC_NAND_TAR_CYCLES(tmgs.t_ar) |
863863 PL35X_SMC_NAND_TRR_CYCLES(tmgs.t_rr);
864864
865+ writel(plnand->timings, nfc->conf_regs + PL35X_SMC_CYCLES);
866+ pl35x_smc_update_regs(nfc);
867+
865868 return 0;
866869 }
867870
drivers/mtd/parsers/redboot.c+3−3
@@ -270,9 +270,9 @@ nogood: · 269 unmodified lines
270270
271271 strcpy(names, fl->img->name);
272272 #ifdef CONFIG_MTD_REDBOOT_PARTS_READONLY
273− if (!memcmp(names, "RedBoot", 8) ||
274− !memcmp(names, "RedBoot config", 15) ||
275− !memcmp(names, "FIS directory", 14)) {
273+ if (!strcmp(names, "RedBoot") ||
274+ !strcmp(names, "RedBoot config") ||
275+ !strcmp(names, "FIS directory")) {
276276 parts[i].mask_flags = MTD_WRITEABLE;
277277 }
278278 #endif
drivers/mtd/spi-nor/core.c+7−7
@@ -2345,15 +2345,15 @@ int spi_nor_hwcaps_pp2cmd(u32 hwcaps) · 2344 unmodified lines
23452345 }
23462346
23472347 /**
2348− * spi_nor_spimem_check_op - check if the operation is supported
2349− * by controller
2348+ * spi_nor_spimem_check_read_pp_op - check if a read or a page program operation is
2349+ * supported by controller
23502350 *@nor: pointer to a 'struct spi_nor'
23512351 *@op: pointer to op template to be checked
23522352 *
23532353 * Returns 0 if operation is supported, -EOPNOTSUPP otherwise.
23542354 */
2355−static int spi_nor_spimem_check_op(struct spi_nor *nor,
2356− struct spi_mem_op *op)
2355+static int spi_nor_spimem_check_read_pp_op(struct spi_nor *nor,
2356+ struct spi_mem_op *op)
23572357 {
23582358 /*
23592359 * First test with 4 address bytes. The opcode itself might
@@ -2396,7 +2396,7 @@ static int spi_nor_spimem_check_readop(struct spi_nor *nor, · 36 unmodified lines
23962396 if (spi_nor_protocol_is_dtr(nor->read_proto))
23972397 op.dummy.nbytes *= 2;
23982398
2399− return spi_nor_spimem_check_op(nor, &op);
2399+ return spi_nor_spimem_check_read_pp_op(nor, &op);
24002400 }
24012401
24022402 /**
@@ -2414,7 +2414,7 @@ static int spi_nor_spimem_check_pp(struct spi_nor *nor, · 11 unmodified lines
24142414
24152415 spi_nor_spimem_setup_op(nor, &op, pp->proto);
24162416
2417− return spi_nor_spimem_check_op(nor, &op);
2417+ return spi_nor_spimem_check_read_pp_op(nor, &op);
24182418 }
24192419
24202420 /**
@@ -2466,7 +2466,7 @@ spi_nor_spimem_adjust_hwcaps(struct spi_nor *nor, u32 *hwcaps) · 45 unmodified lines
24662466
24672467 spi_nor_spimem_setup_op(nor, &op, nor->reg_proto);
24682468
2469− if (spi_nor_spimem_check_op(nor, &op))
2469+ if (!spi_mem_supports_op(nor->spimem, &op))
24702470 nor->flags |= SNOR_F_NO_READ_CR;
24712471 }
24722472 }
drivers/net/bonding/bond_debugfs.c+11−5
@@ -34,11 +34,17 @@ static int bond_debug_rlb_hash_show(struct seq_file *m, void *v) · 33 unmodified lines
3434 for (; hash_index != RLB_NULL_INDEX;
3535 hash_index = client_info->used_next) {
3636 client_info = &(bond_info->rx_hashtbl[hash_index]);
37− seq_printf(m, "%-15pI4 %-15pI4 %-17pM %s\n",
38− &client_info->ip_src,
39− &client_info->ip_dst,
40− &client_info->mac_dst,
41− client_info->slave->dev->name);
37+ if (client_info->slave)
38+ seq_printf(m, "%-15pI4 %-15pI4 %-17pM %s\n",
39+ &client_info->ip_src,
40+ &client_info->ip_dst,
41+ &client_info->mac_dst,
42+ client_info->slave->dev->name);
43+ else
44+ seq_printf(m, "%-15pI4 %-15pI4 %-17pM (none)\n",
45+ &client_info->ip_src,
46+ &client_info->ip_dst,
47+ &client_info->mac_dst);
4248 }
4349
4450 spin_unlock_bh(&bond->mode_lock);
drivers/net/bonding/bond_main.c+5−3
@@ -1530,9 +1530,11 @@ static int bond_header_create(struct sk_buff *skb, struct net_device *bond_dev, · 1529 unmodified lines
15301530 return ret;
15311531 }
15321532
1533−static int bond_header_parse(const struct sk_buff *skb, unsigned char *haddr)
1533+static int bond_header_parse(const struct sk_buff *skb,
1534+ const struct net_device *dev,
1535+ unsigned char *haddr)
15341536 {
1535− struct bonding *bond = netdev_priv(skb->dev);
1537+ struct bonding *bond = netdev_priv(dev);
15361538 const struct header_ops *slave_ops;
15371539 struct slave *slave;
15381540 int ret = 0;
@@ -1542,7 +1544,7 @@ static int bond_header_parse(const struct sk_buff *skb, unsigned char *haddr) · 3 unmodified lines
15421544 if (slave) {
15431545 slave_ops = READ_ONCE(slave->dev->header_ops);
15441546 if (slave_ops && slave_ops->parse)
1545− ret = slave_ops->parse(skb, haddr);
1547+ ret = slave_ops->parse(skb, slave->dev, haddr);
15461548 }
15471549 rcu_read_unlock();
15481550 return ret;
drivers/net/dsa/bcm_sf2.c+6−2
@@ -980,15 +980,19 @@ static int bcm_sf2_sw_resume(struct dsa_switch *ds) · 979 unmodified lines
980980 ret = bcm_sf2_sw_rst(priv);
981981 if (ret) {
982982 pr_err("%s: failed to software reset switch\n", __func__);
983+ if (!priv->wol_ports_mask)
984+ clk_disable_unprepare(priv->clk);
983985 return ret;
984986 }
985987
986988 bcm_sf2_crossbar_setup(priv);
987989
988990 ret = bcm_sf2_cfp_resume(ds);
989− if (ret)
991+ if (ret) {
992+ if (!priv->wol_ports_mask)
993+ clk_disable_unprepare(priv->clk);
990994 return ret;
991−
995+ }
992996 if (priv->hw_params.num_gphy == 1)
993997 bcm_sf2_gphy_enable_set(ds, true);
994998
drivers/net/ethernet/airoha/airoha_eth.c+0−1
@@ -3083,7 +3083,6 @@ static void airoha_remove(struct platform_device *pdev) · 3082 unmodified lines
30833083 if (!port)
30843084 continue;
30853085
3086− airoha_dev_stop(port->dev);
30873086 unregister_netdev(port->dev);
30883087 airoha_metadata_dst_free(port);
30893088 }
drivers/net/ethernet/broadcom/bnxt/bnxt.c+2−0
@@ -2929,6 +2929,8 @@ static int bnxt_async_event_process(struct bnxt *bp, · 2928 unmodified lines
29292929 u16 type = (u16)BNXT_EVENT_BUF_PRODUCER_TYPE(data1);
29302930 u32 offset = BNXT_EVENT_BUF_PRODUCER_OFFSET(data2);
29312931
2932+ if (type >= ARRAY_SIZE(bp->bs_trace))
2933+ goto async_event_process_exit;
29322934 bnxt_bs_trace_check_wrap(&bp->bs_trace[type], offset);
29332935 goto async_event_process_exit;
29342936 }
drivers/net/ethernet/broadcom/bnxt/bnxt.h+1−1
@@ -2146,7 +2146,7 @@ enum board_idx { · 2145 unmodified lines
21462146 };
21472147
21482148 #define BNXT_TRACE_BUF_MAGIC_BYTE ((u8)0xbc)
2149−#define BNXT_TRACE_MAX 11
2149+#define BNXT_TRACE_MAX (DBG_LOG_BUFFER_FLUSH_REQ_TYPE_ERR_QPC_TRACE + 1)
21502150
21512151 struct bnxt_bs_trace_info {
21522152 u8 *magic_byte;
drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c+1−1
@@ -123,7 +123,7 @@ static int bcmgenet_poll_wol_status(struct bcmgenet_priv *priv) · 122 unmodified lines
123123 while (!(bcmgenet_rbuf_readl(priv, RBUF_STATUS)
124124 & RBUF_STATUS_WOL)) {
125125 retries++;
126− if (retries > 5) {
126+ if (retries > 50) {
127127 netdev_crit(dev, "polling wol mode timeout\n");
128128 return -ETIMEDOUT;
129129 }
drivers/net/ethernet/broadcom/tg3.c+11−0
@@ -17029,6 +17029,13 @@ static int tg3_get_invariants(struct tg3 *tp, const struct pci_device_id *ent) · 17028 unmodified lines
1702917029 return err;
1703017030 }
1703117031
17032+static int tg3_is_default_mac_address(u8 *addr)
17033+{
17034+ static const u8 default_mac_address[ETH_ALEN] = { 0x00, 0x10, 0x18, 0x00, 0x00, 0x00 };
17035+
17036+ return ether_addr_equal(default_mac_address, addr);
17037+}
17038+
1703217039 static int tg3_get_device_address(struct tg3 *tp, u8 *addr)
1703317040 {
1703417041 u32 hi, lo, mac_offset;
@@ -17102,6 +17109,10 @@ static int tg3_get_device_address(struct tg3 *tp, u8 *addr) · 67 unmodified lines
1710217109
1710317110 if (!is_valid_ether_addr(addr))
1710417111 return -EINVAL;
17112+
17113+ if (tg3_is_default_mac_address(addr))
17114+ return device_get_mac_address(&tp->pdev->dev, addr);
17115+
1710517116 return 0;
1710617117 }
1710717118
drivers/net/ethernet/cadence/macb_main.c+22−4
@@ -2669,6 +2669,14 @@ static void macb_init_tieoff(struct macb *bp) · 2668 unmodified lines
26692669 desc->ctrl = 0;
26702670 }
26712671
2672+static void gem_init_rx_ring(struct macb_queue *queue)
2673+{
2674+ queue->rx_tail = 0;
2675+ queue->rx_prepared_head = 0;
2676+
2677+ gem_rx_refill(queue);
2678+}
2679+
26722680 static void gem_init_rings(struct macb *bp)
26732681 {
26742682 struct macb_queue *queue;
@@ -2686,10 +2694,7 @@ static void gem_init_rings(struct macb *bp) · 11 unmodified lines
26862694 queue->tx_head = 0;
26872695 queue->tx_tail = 0;
26882696
2689− queue->rx_tail = 0;
2690− queue->rx_prepared_head = 0;
2691−
2692− gem_rx_refill(queue);
2697+ gem_init_rx_ring(queue);
26932698 }
26942699
26952700 macb_init_tieoff(bp);
@@ -3978,6 +3983,9 @@ static int gem_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd) · 1282 unmodified lines
39783983 struct macb *bp = netdev_priv(netdev);
39793984 int ret;
39803985
3986+ if (!(netdev->hw_features & NETIF_F_NTUPLE))
3987+ return -EOPNOTSUPP;
3988+
39813989 switch (cmd->cmd) {
39823990 case ETHTOOL_SRXCLSRLINS:
39833991 if ((cmd->fs.location >= bp->max_tuples)
@@ -5947,8 +5955,18 @@ static int __maybe_unused macb_resume(struct device *dev) · 1963 unmodified lines
59475955 rtnl_unlock();
59485956 }
59495957
5958+ if (!(bp->caps & MACB_CAPS_MACB_IS_EMAC))
5959+ macb_init_buffers(bp);
5960+
59505961 for (q = 0, queue = bp->queues; q < bp->num_queues;
59515962 ++q, ++queue) {
5963+ if (!(bp->caps & MACB_CAPS_MACB_IS_EMAC)) {
5964+ if (macb_is_gem(bp))
5965+ gem_init_rx_ring(queue);
5966+ else
5967+ macb_init_rx_ring(queue);
5968+ }
5969+
59525970 napi_enable(&queue->napi_rx);
59535971 napi_enable(&queue->napi_tx);
59545972 }
drivers/net/ethernet/cadence/macb_ptp.c+3−1
@@ -357,8 +357,10 @@ void gem_ptp_remove(struct net_device *ndev) · 356 unmodified lines
357357 {
358358 struct macb *bp = netdev_priv(ndev);
359359
360− if (bp->ptp_clock)
360+ if (bp->ptp_clock) {
361361 ptp_clock_unregister(bp->ptp_clock);
362+ bp->ptp_clock = NULL;
363+ }
362364
363365 gem_ptp_clear_timer(bp);
364366
drivers/net/ethernet/intel/iavf/iavf_main.c+6−3
@@ -757,10 +757,13 @@ iavf_vlan_filter *iavf_add_vlan(struct iavf_adapter *adapter, · 756 unmodified lines
757757 adapter->num_vlan_filters++;
758758 iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_ADD_VLAN_FILTER);
759759 } else if (f->state == IAVF_VLAN_REMOVE) {
760− /* IAVF_VLAN_REMOVE means that VLAN wasn't yet removed.
761− * We can safely only change the state here.
760+ /* Re-add the filter since we cannot tell whether the
761+ * pending delete has already been processed by the PF.
762+ * A duplicate add is harmless.
762763 */
763− f->state = IAVF_VLAN_ACTIVE;
764+ f->state = IAVF_VLAN_ADD;
765+ iavf_schedule_aq_request(adapter,
766+ IAVF_FLAG_AQ_ADD_VLAN_FILTER);
764767 }
765768
766769 clearout:
drivers/net/ethernet/intel/igc/igc.h+2−0
@@ -781,6 +781,8 @@ int igc_ptp_hwtstamp_set(struct net_device *netdev, · 780 unmodified lines
781781 struct kernel_hwtstamp_config *config,
782782 struct netlink_ext_ack *extack);
783783 void igc_ptp_tx_hang(struct igc_adapter *adapter);
784+void igc_ptp_clear_xsk_tx_tstamp_queue(struct igc_adapter *adapter,
785+ u16 queue_id);
784786 void igc_ptp_read(struct igc_adapter *adapter, struct timespec64 *ts);
785787 void igc_ptp_tx_tstamp_event(struct igc_adapter *adapter);
786788
drivers/net/ethernet/intel/igc/igc_main.c+9−5
@@ -264,6 +264,13 @@ static void igc_clean_tx_ring(struct igc_ring *tx_ring) · 263 unmodified lines
264264 /* reset next_to_use and next_to_clean */
265265 tx_ring->next_to_use = 0;
266266 tx_ring->next_to_clean = 0;
267+
268+ /* Clear any lingering XSK TX timestamp requests */
269+ if (test_bit(IGC_RING_FLAG_TX_HWTSTAMP, &tx_ring->flags)) {
270+ struct igc_adapter *adapter = netdev_priv(tx_ring->netdev);
271+
272+ igc_ptp_clear_xsk_tx_tstamp_queue(adapter, tx_ring->queue_index);
273+ }
267274 }
268275
269276 /**
@@ -1730,11 +1737,8 @@ static netdev_tx_t igc_xmit_frame(struct sk_buff *skb, · 1460 unmodified lines
17301737 /* The minimum packet size with TCTL.PSP set is 17 so pad the skb
17311738 * in order to meet this minimum size requirement.
17321739 */
1733− if (skb->len < 17) {
1734− if (skb_padto(skb, 17))
1735− return NETDEV_TX_OK;
1736− skb->len = 17;
1737− }
1740+ if (skb_put_padto(skb, 17))
1741+ return NETDEV_TX_OK;
17381742
17391743 return igc_xmit_frame_ring(skb, igc_tx_queue_mapping(adapter, skb));
17401744 }
drivers/net/ethernet/intel/igc/igc_ptp.c+33−0
@@ -577,6 +577,39 @@ static void igc_ptp_clear_tx_tstamp(struct igc_adapter *adapter) · 576 unmodified lines
577577 spin_unlock_irqrestore(&adapter->ptp_tx_lock, flags);
578578 }
579579
580+/**
581+ * igc_ptp_clear_xsk_tx_tstamp_queue - Clear pending XSK TX timestamps for a queue
582+ * @adapter: Board private structure
583+ * @queue_id: TX queue index to clear timestamps for
584+ *
585+ * Iterates over all TX timestamp registers and releases any pending
586+ * timestamp requests associated with the given TX queue. This is
587+ * called when an XDP pool is being disabled to ensure no stale
588+ * timestamp references remain.
589+ */
590+void igc_ptp_clear_xsk_tx_tstamp_queue(struct igc_adapter *adapter, u16 queue_id)
591+{
592+ unsigned long flags;
593+ int i;
594+
595+ spin_lock_irqsave(&adapter->ptp_tx_lock, flags);
596+
597+ for (i = 0; i < IGC_MAX_TX_TSTAMP_REGS; i++) {
598+ struct igc_tx_timestamp_request *tstamp = &adapter->tx_tstamp[i];
599+
600+ if (tstamp->buffer_type != IGC_TX_BUFFER_TYPE_XSK)
601+ continue;
602+ if (tstamp->xsk_queue_index != queue_id)
603+ continue;
604+ if (!tstamp->xsk_tx_buffer)
605+ continue;
606+
607+ igc_ptp_free_tx_buffer(adapter, tstamp);
608+ }
609+
610+ spin_unlock_irqrestore(&adapter->ptp_tx_lock, flags);
611+}
612+
580613 static void igc_ptp_disable_tx_timestamp(struct igc_adapter *adapter)
581614 {
582615 struct igc_hw *hw = &adapter->hw;
drivers/net/ethernet/intel/libie/fwlog.c+36−13
@@ -433,17 +433,21 @@ libie_debugfs_module_write(struct file *filp, const char __user *buf, · 432 unmodified lines
433433 module = libie_find_module_by_dentry(fwlog->debugfs_modules, dentry);
434434 if (module < 0) {
435435 dev_info(dev, "unknown module\n");
436− return -EINVAL;
436+ count = -EINVAL;
437+ goto free_cmd_buf;
437438 }
438439
439440 cnt = sscanf(cmd_buf, "%s", user_val);
440− if (cnt != 1)
441− return -EINVAL;
441+ if (cnt != 1) {
442+ count = -EINVAL;
443+ goto free_cmd_buf;
444+ }
442445
443446 log_level = sysfs_match_string(libie_fwlog_level_string, user_val);
444447 if (log_level < 0) {
445448 dev_info(dev, "unknown log level '%s'\n", user_val);
446− return -EINVAL;
449+ count = -EINVAL;
450+ goto free_cmd_buf;
447451 }
448452
449453 if (module != LIBIE_AQC_FW_LOG_ID_MAX) {
@@ -458,6 +462,9 @@ libie_debugfs_module_write(struct file *filp, const char __user *buf, · 8 unmodified lines
458462 fwlog->cfg.module_entries[i].log_level = log_level;
459463 }
460464
465+free_cmd_buf:
466+ kfree(cmd_buf);
467+
461468 return count;
462469 }
463470
@@ -515,23 +522,31 @@ libie_debugfs_nr_messages_write(struct file *filp, const char __user *buf, · 51 unmodified lines
515522 return PTR_ERR(cmd_buf);
516523
517524 ret = sscanf(cmd_buf, "%s", user_val);
518− if (ret != 1)
519− return -EINVAL;
525+ if (ret != 1) {
526+ count = -EINVAL;
527+ goto free_cmd_buf;
528+ }
520529
521530 ret = kstrtos16(user_val, 0, &nr_messages);
522− if (ret)
523− return ret;
531+ if (ret) {
532+ count = ret;
533+ goto free_cmd_buf;
534+ }
524535
525536 if (nr_messages < LIBIE_AQC_FW_LOG_MIN_RESOLUTION ||
526537 nr_messages > LIBIE_AQC_FW_LOG_MAX_RESOLUTION) {
527538 dev_err(dev, "Invalid FW log number of messages %d, value must be between %d - %d\n",
528539 nr_messages, LIBIE_AQC_FW_LOG_MIN_RESOLUTION,
529540 LIBIE_AQC_FW_LOG_MAX_RESOLUTION);
530− return -EINVAL;
541+ count = -EINVAL;
542+ goto free_cmd_buf;
531543 }
532544
533545 fwlog->cfg.log_resolution = nr_messages;
534546
547+free_cmd_buf:
548+ kfree(cmd_buf);
549+
535550 return count;
536551 }
537552
@@ -588,8 +603,10 @@ libie_debugfs_enable_write(struct file *filp, const char __user *buf, · 50 unmodified lines
588603 return PTR_ERR(cmd_buf);
589604
590605 ret = sscanf(cmd_buf, "%s", user_val);
591− if (ret != 1)
592− return -EINVAL;
606+ if (ret != 1) {
607+ ret = -EINVAL;
608+ goto free_cmd_buf;
609+ }
593610
594611 ret = kstrtobool(user_val, &enable);
595612 if (ret)
@@ -624,6 +641,8 @@ enable_write_error: · 28 unmodified lines
624641 */
625642 if (WARN_ON(ret != (ssize_t)count && ret >= 0))
626643 ret = -EIO;
644+free_cmd_buf:
645+ kfree(cmd_buf);
627646
628647 return ret;
629648 }
@@ -682,8 +701,10 @@ libie_debugfs_log_size_write(struct file *filp, const char __user *buf, · 52 unmodified lines
682701 return PTR_ERR(cmd_buf);
683702
684703 ret = sscanf(cmd_buf, "%s", user_val);
685− if (ret != 1)
686− return -EINVAL;
704+ if (ret != 1) {
705+ ret = -EINVAL;
706+ goto free_cmd_buf;
707+ }
687708
688709 index = sysfs_match_string(libie_fwlog_log_size, user_val);
689710 if (index < 0) {
@@ -712,6 +733,8 @@ log_size_write_error: · 22 unmodified lines
712733 */
713734 if (WARN_ON(ret != (ssize_t)count && ret >= 0))
714735 ret = -EIO;
736+free_cmd_buf:
737+ kfree(cmd_buf);
715738
716739 return ret;
717740 }
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c+2−2
@@ -5016,7 +5016,7 @@ static int mvpp2_bm_switch_buffers(struct mvpp2 *priv, bool percpu) · 5015 unmodified lines
50165016 if (priv->percpu_pools)
50175017 numbufs = port->nrxqs * 2;
50185018
5019− if (change_percpu)
5019+ if (change_percpu && priv->global_tx_fc)
50205020 mvpp2_bm_pool_update_priv_fc(priv, false);
50215021
50225022 for (i = 0; i < numbufs; i++)
@@ -5041,7 +5041,7 @@ static int mvpp2_bm_switch_buffers(struct mvpp2 *priv, bool percpu) · 18 unmodified lines
50415041 mvpp2_open(port->dev);
50425042 }
50435043
5044− if (change_percpu)
5044+ if (change_percpu && priv->global_tx_fc)
50455045 mvpp2_bm_pool_update_priv_fc(priv, true);
50465046
50475047 return 0;
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h+1−0
@@ -287,6 +287,7 @@ struct mlx5e_ipsec_sa_entry { · 286 unmodified lines
287287 struct mlx5e_ipsec_dwork *dwork;
288288 struct mlx5e_ipsec_limits limits;
289289 u32 rx_mapped_id;
290+ u8 ctx[MLX5_ST_SZ_BYTES(ipsec_aso)];
290291 };
291292
292293 struct mlx5_accel_pol_xfrm_attrs {
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c+22−28
@@ -310,10 +310,11 @@ static void mlx5e_ipsec_aso_update(struct mlx5e_ipsec_sa_entry *sa_entry, · 309 unmodified lines
310310 mlx5e_ipsec_aso_query(sa_entry, data);
311311 }
312312
313−static void mlx5e_ipsec_update_esn_state(struct mlx5e_ipsec_sa_entry *sa_entry,
314− u32 mode_param)
313+static void
314+mlx5e_ipsec_update_esn_state(struct mlx5e_ipsec_sa_entry *sa_entry,
315+ u32 mode_param,
316+ struct mlx5_accel_esp_xfrm_attrs *attrs)
315317 {
316− struct mlx5_accel_esp_xfrm_attrs attrs = {};
317318 struct mlx5_wqe_aso_ctrl_seg data = {};
318319
319320 if (mode_param < MLX5E_IPSEC_ESN_SCOPE_MID) {
@@ -323,18 +324,7 @@ static void mlx5e_ipsec_update_esn_state(struct mlx5e_ipsec_sa_entry *sa_entry, · 3 unmodified lines
323324 sa_entry->esn_state.overlap = 1;
324325 }
325326
326− mlx5e_ipsec_build_accel_xfrm_attrs(sa_entry, &attrs);
327−
328− /* It is safe to execute the modify below unlocked since the only flows
329− * that could affect this HW object, are create, destroy and this work.
330− *
331− * Creation flow can't co-exist with this modify work, the destruction
332− * flow would cancel this work, and this work is a single entity that
333− * can't conflict with it self.
334− */
335− spin_unlock_bh(&sa_entry->x->lock);
336− mlx5_accel_esp_modify_xfrm(sa_entry, &attrs);
337− spin_lock_bh(&sa_entry->x->lock);
327+ mlx5e_ipsec_build_accel_xfrm_attrs(sa_entry, attrs);
338328
339329 data.data_offset_condition_operand =
340330 MLX5_IPSEC_ASO_REMOVE_FLOW_PKT_CNT_OFFSET;
@@ -370,20 +360,18 @@ static void mlx5e_ipsec_aso_update_soft(struct mlx5e_ipsec_sa_entry *sa_entry, · 29 unmodified lines
370360 static void mlx5e_ipsec_handle_limits(struct mlx5e_ipsec_sa_entry *sa_entry)
371361 {
372362 struct mlx5_accel_esp_xfrm_attrs *attrs = &sa_entry->attrs;
373− struct mlx5e_ipsec *ipsec = sa_entry->ipsec;
374− struct mlx5e_ipsec_aso *aso = ipsec->aso;
375363 bool soft_arm, hard_arm;
376364 u64 hard_cnt;
377365
378366 lockdep_assert_held(&sa_entry->x->lock);
379367
380− soft_arm = !MLX5_GET(ipsec_aso, aso->ctx, soft_lft_arm);
381− hard_arm = !MLX5_GET(ipsec_aso, aso->ctx, hard_lft_arm);
368+ soft_arm = !MLX5_GET(ipsec_aso, sa_entry->ctx, soft_lft_arm);
369+ hard_arm = !MLX5_GET(ipsec_aso, sa_entry->ctx, hard_lft_arm);
382370 if (!soft_arm && !hard_arm)
383371 /* It is not lifetime event */
384372 return;
385373
386− hard_cnt = MLX5_GET(ipsec_aso, aso->ctx, remove_flow_pkt_cnt);
374+ hard_cnt = MLX5_GET(ipsec_aso, sa_entry->ctx, remove_flow_pkt_cnt);
387375 if (!hard_cnt || hard_arm) {
388376 /* It is possible to see packet counter equal to zero without
389377 * hard limit event armed. Such situation can be if packet
@@ -453,11 +441,11 @@ static void mlx5e_ipsec_handle_event(struct work_struct *_work) · 63 unmodified lines
453441 struct mlx5e_ipsec_work *work =
454442 container_of(_work, struct mlx5e_ipsec_work, work);
455443 struct mlx5e_ipsec_sa_entry *sa_entry = work->data;
444+ struct mlx5_accel_esp_xfrm_attrs tmp = {};
456445 struct mlx5_accel_esp_xfrm_attrs *attrs;
457− struct mlx5e_ipsec_aso *aso;
446+ bool need_modify = false;
458447 int ret;
459448
460− aso = sa_entry->ipsec->aso;
461449 attrs = &sa_entry->attrs;
462450
463451 spin_lock_bh(&sa_entry->x->lock);
@@ -465,18 +453,22 @@ static void mlx5e_ipsec_handle_event(struct work_struct *_work) · 1 unmodified line
465453 if (ret)
466454 goto unlock;
467455
456+ if (attrs->lft.soft_packet_limit != XFRM_INF)
457+ mlx5e_ipsec_handle_limits(sa_entry);
458+
468459 if (attrs->replay_esn.trigger &&
469− !MLX5_GET(ipsec_aso, aso->ctx, esn_event_arm)) {
470− u32 mode_param = MLX5_GET(ipsec_aso, aso->ctx, mode_parameter);
460+ !MLX5_GET(ipsec_aso, sa_entry->ctx, esn_event_arm)) {
461+ u32 mode_param = MLX5_GET(ipsec_aso, sa_entry->ctx,
462+ mode_parameter);
471463
472− mlx5e_ipsec_update_esn_state(sa_entry, mode_param);
464+ mlx5e_ipsec_update_esn_state(sa_entry, mode_param, &tmp);
465+ need_modify = true;
473466 }
474467
475− if (attrs->lft.soft_packet_limit != XFRM_INF)
476− mlx5e_ipsec_handle_limits(sa_entry);
477−
478468 unlock:
479469 spin_unlock_bh(&sa_entry->x->lock);
470+ if (need_modify)
471+ mlx5_accel_esp_modify_xfrm(sa_entry, &tmp);
480472 kfree(work);
481473 }
482474
@@ -629,6 +621,8 @@ int mlx5e_ipsec_aso_query(struct mlx5e_ipsec_sa_entry *sa_entry, · 146 unmodified lines
629621 /* We are in atomic context */
630622 udelay(10);
631623 } while (ret && time_is_after_jiffies(expires));
624+ if (!ret)
625+ memcpy(sa_entry->ctx, aso->ctx, MLX5_ST_SZ_BYTES(ipsec_aso));
632626 spin_unlock_bh(&aso->lock);
633627 return ret;
634628 }
drivers/net/ethernet/mellanox/mlx5/core/esw/qos.c+9−14
@@ -1489,24 +1489,24 @@ out: · 1488 unmodified lines
14891489 return err;
14901490 }
14911491
1492−static u32 mlx5_esw_qos_lag_link_speed_get_locked(struct mlx5_core_dev *mdev)
1492+static u32 mlx5_esw_qos_lag_link_speed_get(struct mlx5_core_dev *mdev,
1493+ bool take_rtnl)
14931494 {
14941495 struct ethtool_link_ksettings lksettings;
14951496 struct net_device *slave, *master;
14961497 u32 speed = SPEED_UNKNOWN;
14971498
1498− /* Lock ensures a stable reference to master and slave netdevice
1499− * while port speed of master is queried.
1500− */
1501− ASSERT_RTNL();
1502−
15031499 slave = mlx5_uplink_netdev_get(mdev);
15041500 if (!slave)
15051501 goto out;
15061502
1503+ if (take_rtnl)
1504+ rtnl_lock();
15071505 master = netdev_master_upper_dev_get(slave);
15081506 if (master && !__ethtool_get_link_ksettings(master, &lksettings))
15091507 speed = lksettings.base.speed;
1508+ if (take_rtnl)
1509+ rtnl_unlock();
15101510
15111511 out:
15121512 mlx5_uplink_netdev_put(mdev, slave);
@@ -1514,20 +1514,15 @@ out: · 1 unmodified line
15141514 }
15151515
15161516 static int mlx5_esw_qos_max_link_speed_get(struct mlx5_core_dev *mdev, u32 *link_speed_max,
1517− bool hold_rtnl_lock, struct netlink_ext_ack *extack)
1517+ bool take_rtnl,
1518+ struct netlink_ext_ack *extack)
15181519 {
15191520 int err;
15201521
15211522 if (!mlx5_lag_is_active(mdev))
15221523 goto skip_lag;
15231524
1524− if (hold_rtnl_lock)
1525− rtnl_lock();
1526−
1527− *link_speed_max = mlx5_esw_qos_lag_link_speed_get_locked(mdev);
1528−
1529− if (hold_rtnl_lock)
1530− rtnl_unlock();
1525+ *link_speed_max = mlx5_esw_qos_lag_link_speed_get(mdev, take_rtnl);
15311526
15321527 if (*link_speed_max != (u32)SPEED_UNKNOWN)
15331528 return 0;
drivers/net/ethernet/microsoft/mana/hw_channel.c+3−3
@@ -814,9 +814,6 @@ void mana_hwc_destroy_channel(struct gdma_context *gc) · 813 unmodified lines
814814 gc->max_num_cqs = 0;
815815 }
816816
817− kfree(hwc->caller_ctx);
818− hwc->caller_ctx = NULL;
819−
820817 if (hwc->txq)
821818 mana_hwc_destroy_wq(hwc, hwc->txq);
822819
@@ -826,6 +823,9 @@ void mana_hwc_destroy_channel(struct gdma_context *gc) · 3 unmodified lines
826823 if (hwc->cq)
827824 mana_hwc_destroy_cq(hwc->gdma_dev->gdma_context, hwc->cq);
828825
826+ kfree(hwc->caller_ctx);
827+ hwc->caller_ctx = NULL;
828+
829829 mana_gd_free_res_map(&hwc->inflight_msg_res);
830830
831831 hwc->num_inflight_msg = 0;
drivers/net/ethernet/ti/icssg/icssg_common.c+5−0
@@ -1075,6 +1075,11 @@ static int emac_rx_packet(struct prueth_emac *emac, u32 flow_id, u32 *xdp_state) · 1074 unmodified lines
10751075 xdp_prepare_buff(&xdp, pa, PRUETH_HEADROOM, pkt_len, false);
10761076
10771077 *xdp_state = emac_run_xdp(emac, &xdp, &pkt_len);
1078+ if (*xdp_state == ICSSG_XDP_CONSUMED) {
1079+ page_pool_recycle_direct(pool, page);
1080+ goto requeue;
1081+ }
1082+
10781083 if (*xdp_state != ICSSG_XDP_PASS)
10791084 goto requeue;
10801085 headroom = xdp.data - xdp.data_hard_start;
drivers/net/netdevsim/netdev.c+4−1
@@ -109,8 +109,11 @@ static int nsim_forward_skb(struct net_device *tx_dev, · 108 unmodified lines
109109 int ret;
110110
111111 ret = __dev_forward_skb(rx_dev, skb);
112− if (ret)
112+ if (ret) {
113+ if (psp_ext)
114+ __skb_ext_put(psp_ext);
113115 return ret;
116+ }
114117
115118 nsim_psp_handle_ext(skb, psp_ext);
116119
drivers/net/usb/aqc111.c+6−6
@@ -1395,14 +1395,14 @@ static int aqc111_suspend(struct usb_interface *intf, pm_message_t message) · 1394 unmodified lines
13951395 aqc111_write16_cmd_nopm(dev, AQ_ACCESS_MAC,
13961396 SFR_MEDIUM_STATUS_MODE, 2, &reg16);
13971397
1398− aqc111_write_cmd(dev, AQ_WOL_CFG, 0, 0,
1399− WOL_CFG_SIZE, &wol_cfg);
1400− aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0,
1401− &aqc111_data->phy_cfg);
1398+ aqc111_write_cmd_nopm(dev, AQ_WOL_CFG, 0, 0,
1399+ WOL_CFG_SIZE, &wol_cfg);
1400+ aqc111_write32_cmd_nopm(dev, AQ_PHY_OPS, 0, 0,
1401+ &aqc111_data->phy_cfg);
14021402 } else {
14031403 aqc111_data->phy_cfg |= AQ_LOW_POWER;
1404− aqc111_write32_cmd(dev, AQ_PHY_OPS, 0, 0,
1405− &aqc111_data->phy_cfg);
1404+ aqc111_write32_cmd_nopm(dev, AQ_PHY_OPS, 0, 0,
1405+ &aqc111_data->phy_cfg);
14061406
14071407 /* Disable RX path */
14081408 aqc111_read16_cmd_nopm(dev, AQ_ACCESS_MAC,
drivers/net/usb/cdc_ncm.c+6−4
@@ -1656,6 +1656,7 @@ int cdc_ncm_rx_verify_ndp16(struct sk_buff *skb_in, int ndpoffset) · 1655 unmodified lines
16561656 struct usbnet *dev = netdev_priv(skb_in->dev);
16571657 struct usb_cdc_ncm_ndp16 *ndp16;
16581658 int ret = -EINVAL;
1659+ size_t ndp_len;
16591660
16601661 if ((ndpoffset + sizeof(struct usb_cdc_ncm_ndp16)) > skb_in->len) {
16611662 netif_dbg(dev, rx_err, dev->net, "invalid NDP offset <%u>\n",
@@ -1675,8 +1676,8 @@ int cdc_ncm_rx_verify_ndp16(struct sk_buff *skb_in, int ndpoffset) · 13 unmodified lines
16751676 sizeof(struct usb_cdc_ncm_dpe16));
16761677 ret--; /* we process NDP entries except for the last one */
16771678
1678− if ((sizeof(struct usb_cdc_ncm_ndp16) +
1679− ret * (sizeof(struct usb_cdc_ncm_dpe16))) > skb_in->len) {
1679+ ndp_len = struct_size_t(struct usb_cdc_ncm_ndp16, dpe16, ret);
1680+ if (ndpoffset + ndp_len > skb_in->len) {
16801681 netif_dbg(dev, rx_err, dev->net, "Invalid nframes = %d\n", ret);
16811682 ret = -EINVAL;
16821683 }
@@ -1692,6 +1693,7 @@ int cdc_ncm_rx_verify_ndp32(struct sk_buff *skb_in, int ndpoffset) · 9 unmodified lines
16921693 struct usbnet *dev = netdev_priv(skb_in->dev);
16931694 struct usb_cdc_ncm_ndp32 *ndp32;
16941695 int ret = -EINVAL;
1696+ size_t ndp_len;
16951697
16961698 if ((ndpoffset + sizeof(struct usb_cdc_ncm_ndp32)) > skb_in->len) {
16971699 netif_dbg(dev, rx_err, dev->net, "invalid NDP offset <%u>\n",
@@ -1711,8 +1713,8 @@ int cdc_ncm_rx_verify_ndp32(struct sk_buff *skb_in, int ndpoffset) · 13 unmodified lines
17111713 sizeof(struct usb_cdc_ncm_dpe32));
17121714 ret--; /* we process NDP entries except for the last one */
17131715
1714− if ((sizeof(struct usb_cdc_ncm_ndp32) +
1715− ret * (sizeof(struct usb_cdc_ncm_dpe32))) > skb_in->len) {
1716+ ndp_len = struct_size_t(struct usb_cdc_ncm_ndp32, dpe32, ret);
1717+ if (ndpoffset + ndp_len > skb_in->len) {
17161718 netif_dbg(dev, rx_err, dev->net, "Invalid nframes = %d\n", ret);
17171719 ret = -EINVAL;
17181720 }
drivers/net/wireless/ath/ath9k/channel.c+2−4
@@ -1006,7 +1006,7 @@ static void ath_scan_send_probe(struct ath_softc *sc, · 1005 unmodified lines
10061006 skb_set_queue_mapping(skb, IEEE80211_AC_VO);
10071007
10081008 if (!ieee80211_tx_prepare_skb(sc->hw, vif, skb, band, NULL))
1009− goto error;
1009+ return;
10101010
10111011 txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO];
10121012 if (ath_tx_start(sc->hw, skb, &txctl))
@@ -1119,10 +1119,8 @@ ath_chanctx_send_vif_ps_frame(struct ath_softc *sc, struct ath_vif *avp, · 106 unmodified lines
11191119
11201120 skb->priority = 7;
11211121 skb_set_queue_mapping(skb, IEEE80211_AC_VO);
1122− if (!ieee80211_tx_prepare_skb(sc->hw, vif, skb, band, &sta)) {
1123− dev_kfree_skb_any(skb);
1122+ if (!ieee80211_tx_prepare_skb(sc->hw, vif, skb, band, &sta))
11241123 return false;
1125− }
11261124 break;
11271125 default:
11281126 return false;
drivers/net/wireless/mediatek/mt76/scan.c+1−3
@@ -63,10 +63,8 @@ mt76_scan_send_probe(struct mt76_dev *dev, struct cfg80211_ssid *ssid) · 62 unmodified lines
6363
6464 rcu_read_lock();
6565
66− if (!ieee80211_tx_prepare_skb(phy->hw, vif, skb, band, NULL)) {
67− ieee80211_free_txskb(phy->hw, skb);
66+ if (!ieee80211_tx_prepare_skb(phy->hw, vif, skb, band, NULL))
6867 goto out;
69− }
7068
7169 info = IEEE80211_SKB_CB(skb);
7270 if (req->no_cck)
drivers/net/wireless/ti/wlcore/tx.c+1−1
@@ -210,7 +210,7 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct wl12xx_vif *wlvif, · 209 unmodified lines
210210 if (skb_headroom(skb) < (total_len - skb->len) &&
211211 pskb_expand_head(skb, (total_len - skb->len), 0, GFP_ATOMIC)) {
212212 wl1271_free_tx_id(wl, id);
213− return -EAGAIN;
213+ return -ENOMEM;
214214 }
215215 desc = skb_push(skb, total_len - skb->len);
216216
drivers/net/wireless/virtual/mac80211_hwsim.c+1−2
@@ -3021,7 +3021,6 @@ static void hw_scan_work(struct work_struct *work) · 3020 unmodified lines
30213021 hwsim->tmp_chan->band,
30223022 NULL)) {
30233023 rcu_read_unlock();
3024− kfree_skb(probe);
30253024 continue;
30263025 }
30273026
@@ -6489,7 +6488,7 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info) · 3461 unmodified lines
64896488 if (info->attrs[HWSIM_ATTR_PMSR_SUPPORT]) {
64906489 struct cfg80211_pmsr_capabilities *pmsr_capa;
64916490
6492− pmsr_capa = kmalloc_obj(*pmsr_capa);
6491+ pmsr_capa = kzalloc_obj(*pmsr_capa);
64936492 if (!pmsr_capa) {
64946493 ret = -ENOMEM;
64956494 goto out_free;
drivers/nfc/nxp-nci/i2c.c+2−2
@@ -47,8 +47,8 @@ static int nxp_nci_i2c_set_mode(void *phy_id, · 46 unmodified lines
4747 {
4848 struct nxp_nci_i2c_phy *phy = (struct nxp_nci_i2c_phy *) phy_id;
4949
50− gpiod_set_value(phy->gpiod_fw, (mode == NXP_NCI_MODE_FW) ? 1 : 0);
51− gpiod_set_value(phy->gpiod_en, (mode != NXP_NCI_MODE_COLD) ? 1 : 0);
50+ gpiod_set_value_cansleep(phy->gpiod_fw, (mode == NXP_NCI_MODE_FW) ? 1 : 0);
51+ gpiod_set_value_cansleep(phy->gpiod_en, (mode != NXP_NCI_MODE_COLD) ? 1 : 0);
5252 usleep_range(10000, 15000);
5353
5454 if (mode == NXP_NCI_MODE_COLD)
drivers/nvdimm/bus.c+3−2
@@ -486,14 +486,15 @@ EXPORT_SYMBOL_GPL(nd_synchronize); · 485 unmodified lines
486486 static void nd_async_device_register(void *d, async_cookie_t cookie)
487487 {
488488 struct device *dev = d;
489+ struct device *parent = dev->parent;
489490
490491 if (device_add(dev) != 0) {
491492 dev_err(dev, "%s: failed\n", __func__);
492493 put_device(dev);
493494 }
494495 put_device(dev);
495− if (dev->parent)
496− put_device(dev->parent);
496+ if (parent)
497+ put_device(parent);
497498 }
498499
499500 static void nd_async_device_unregister(void *d, async_cookie_t cookie)
drivers/pci/endpoint/functions/pci-epf-test.c+5−0
@@ -894,6 +894,11 @@ static void pci_epf_test_bar_subrange_setup(struct pci_epf_test *epf_test, · 893 unmodified lines
894894 dev_err(&epf->dev, "pci_epc_set_bar() failed: %d\n", ret);
895895 bar->submap = old_submap;
896896 bar->num_submap = old_nsub;
897+ ret = pci_epc_set_bar(epc, epf->func_no, epf->vfunc_no, bar);
898+ if (ret)
899+ dev_warn(&epf->dev, "Failed to restore the original BAR mapping: %d\n",
900+ ret);
901+
897902 kfree(submap);
898903 goto err;
899904 }
drivers/pci/pwrctrl/core.c+41−13
@@ -268,6 +268,46 @@ err_power_off: · 267 unmodified lines
268268 }
269269 EXPORT_SYMBOL_GPL(pci_pwrctrl_power_on_devices);
270270
271+/*
272+ * Check whether the pwrctrl device really needs to be created or not. The
273+ * pwrctrl device will only be created if the node satisfies below requirements:
274+ *
275+ * 1. Presence of compatible property with "pci" prefix to match against the
276+ * pwrctrl driver (AND)
277+ * 2. At least one of the power supplies defined in the devicetree node of the
278+ * device (OR) in the remote endpoint parent node to indicate pwrctrl
279+ * requirement.
280+ */
281+static bool pci_pwrctrl_is_required(struct device_node *np)
282+{
283+ struct device_node *endpoint;
284+ const char *compat;
285+ int ret;
286+
287+ ret = of_property_read_string(np, "compatible", &compat);
288+ if (ret < 0)
289+ return false;
290+
291+ if (!strstarts(compat, "pci"))
292+ return false;
293+
294+ if (of_pci_supply_present(np))
295+ return true;
296+
297+ if (of_graph_is_present(np)) {
298+ for_each_endpoint_of_node(np, endpoint) {
299+ struct device_node *remote __free(device_node) =
300+ of_graph_get_remote_port_parent(endpoint);
301+ if (remote) {
302+ if (of_pci_supply_present(remote))
303+ return true;
304+ }
305+ }
306+ }
307+
308+ return false;
309+}
310+
271311 static int pci_pwrctrl_create_device(struct device_node *np,
272312 struct device *parent)
273313 {
@@ -287,19 +327,7 @@ static int pci_pwrctrl_create_device(struct device_node *np, · 13 unmodified lines
287327 return 0;
288328 }
289329
290− /*
291− * Sanity check to make sure that the node has the compatible property
292− * to allow driver binding.
293− */
294− if (!of_property_present(np, "compatible"))
295− return 0;
296−
297− /*
298− * Check whether the pwrctrl device really needs to be created or not.
299− * This is decided based on at least one of the power supplies defined
300− * in the devicetree node of the device or the graph property.
301− */
302− if (!of_pci_supply_present(np) && !of_graph_is_present(np)) {
330+ if (!pci_pwrctrl_is_required(np)) {
303331 dev_dbg(parent, "Skipping OF node: %s\n", np->name);
304332 return 0;
305333 }
drivers/pmdomain/bcm/bcm2835-power.c+4−8
@@ -9,6 +9,7 @@ · 8 unmodified lines
99 #include <linux/clk.h>
1010 #include <linux/delay.h>
1111 #include <linux/io.h>
12+#include <linux/iopoll.h>
1213 #include <linux/mfd/bcm2835-pm.h>
1314 #include <linux/module.h>
1415 #include <linux/platform_device.h>
@@ -153,7 +154,6 @@ struct bcm2835_power { · 138 unmodified lines
153154 static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable)
154155 {
155156 void __iomem *base = power->asb;
156− u64 start;
157157 u32 val;
158158
159159 switch (reg) {
@@ -166,8 +166,6 @@ static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable · 6 unmodified lines
166166 break;
167167 }
168168
169− start = ktime_get_ns();
170−
171169 /* Enable the module's async AXI bridges. */
172170 if (enable) {
173171 val = readl(base + reg) & ~ASB_REQ_STOP;
@@ -176,11 +174,9 @@ static int bcm2835_asb_control(struct bcm2835_power *power, u32 reg, bool enable · 2 unmodified lines
176174 }
177175 writel(PM_PASSWORD | val, base + reg);
178176
179− while (!!(readl(base + reg) & ASB_ACK) == enable) {
180− cpu_relax();
181− if (ktime_get_ns() - start >= 1000)
182− return -ETIMEDOUT;
183− }
177+ if (readl_poll_timeout_atomic(base + reg, val,
178+ !!(val & ASB_ACK) != enable, 0, 5))
179+ return -ETIMEDOUT;
184180
185181 return 0;
186182 }
drivers/pmdomain/mediatek/mtk-pm-domains.c+1−1
@@ -1203,7 +1203,7 @@ static int scpsys_probe(struct platform_device *pdev) · 1202 unmodified lines
12031203 scpsys->soc_data = soc;
12041204
12051205 scpsys->pd_data.domains = scpsys->domains;
1206− scpsys->pd_data.num_domains = soc->num_domains;
1206+ scpsys->pd_data.num_domains = num_domains;
12071207
12081208 parent = dev->parent;
12091209 if (!parent) {
drivers/resctrl/mpam_devices.c+2−0
@@ -1428,6 +1428,7 @@ static void mpam_reprogram_ris_partid(struct mpam_msc_ris *ris, u16 partid, · 1427 unmodified lines
14281428 static int mpam_restore_mbwu_state(void *_ris)
14291429 {
14301430 int i;
1431+ u64 val;
14311432 struct mon_read mwbu_arg;
14321433 struct mpam_msc_ris *ris = _ris;
14331434 struct mpam_class *class = ris->vmsc->comp->class;
@@ -1437,6 +1438,7 @@ static int mpam_restore_mbwu_state(void *_ris) · 3 unmodified lines
14371438 mwbu_arg.ris = ris;
14381439 mwbu_arg.ctx = &ris->mbwu_state[i].cfg;
14391440 mwbu_arg.type = mpam_msmon_choose_counter(class);
1441+ mwbu_arg.val = &val;
14401442
14411443 __ris_msmon_read(&mwbu_arg);
14421444 }
drivers/resctrl/test_mpam_devices.c+15−7
@@ -322,9 +322,17 @@ static void test_mpam_enable_merge_features(struct kunit *test) · 321 unmodified lines
322322 mutex_unlock(&mpam_list_lock);
323323 }
324324
325+static void __test_mpam_reset_msc_bitmap(struct mpam_msc *msc, u16 reg, u16 wd)
326+{
327+ /* Avoid warnings when running with CONFIG_DEBUG_PREEMPT */
328+ guard(preempt)();
329+
330+ mpam_reset_msc_bitmap(msc, reg, wd);
331+}
332+
325333 static void test_mpam_reset_msc_bitmap(struct kunit *test)
326334 {
327− char __iomem *buf = kunit_kzalloc(test, SZ_16K, GFP_KERNEL);
335+ char __iomem *buf = (__force char __iomem *)kunit_kzalloc(test, SZ_16K, GFP_KERNEL);
328336 struct mpam_msc fake_msc = {};
329337 u32 *test_result;
330338
@@ -339,33 +347,33 @@ static void test_mpam_reset_msc_bitmap(struct kunit *test) · 8 unmodified lines
339347 mutex_init(&fake_msc.part_sel_lock);
340348 mutex_lock(&fake_msc.part_sel_lock);
341349
342− test_result = (u32 *)(buf + MPAMCFG_CPBM);
350+ test_result = (__force u32 *)(buf + MPAMCFG_CPBM);
343351
344− mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 0);
352+ __test_mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 0);
345353 KUNIT_EXPECT_EQ(test, test_result[0], 0);
346354 KUNIT_EXPECT_EQ(test, test_result[1], 0);
347355 test_result[0] = 0;
348356 test_result[1] = 0;
349357
350− mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 1);
358+ __test_mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 1);
351359 KUNIT_EXPECT_EQ(test, test_result[0], 1);
352360 KUNIT_EXPECT_EQ(test, test_result[1], 0);
353361 test_result[0] = 0;
354362 test_result[1] = 0;
355363
356− mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 16);
364+ __test_mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 16);
357365 KUNIT_EXPECT_EQ(test, test_result[0], 0xffff);
358366 KUNIT_EXPECT_EQ(test, test_result[1], 0);
359367 test_result[0] = 0;
360368 test_result[1] = 0;
361369
362− mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 32);
370+ __test_mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 32);
363371 KUNIT_EXPECT_EQ(test, test_result[0], 0xffffffff);
364372 KUNIT_EXPECT_EQ(test, test_result[1], 0);
365373 test_result[0] = 0;
366374 test_result[1] = 0;
367375
368− mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 33);
376+ __test_mpam_reset_msc_bitmap(&fake_msc, MPAMCFG_CPBM, 33);
369377 KUNIT_EXPECT_EQ(test, test_result[0], 0xffffffff);
370378 KUNIT_EXPECT_EQ(test, test_result[1], 1);
371379 test_result[0] = 0;
drivers/reset/reset-rzg2l-usbphy-ctrl.c+3−0
@@ -136,6 +136,9 @@ static int rzg2l_usbphy_ctrl_set_pwrrdy(struct regmap_field *pwrrdy, · 135 unmodified lines
136136 {
137137 u32 val = power_on ? 0 : 1;
138138
139+ if (!pwrrdy)
140+ return 0;
141+
139142 /* The initialization path guarantees that the mask is 1 bit long. */
140143 return regmap_field_update_bits(pwrrdy, 1, val);
141144 }
drivers/slimbus/qcom-ngd-ctrl.c+2−4
@@ -1535,10 +1535,8 @@ static int of_qcom_slim_ngd_register(struct device *parent, · 1534 unmodified lines
15351535 ngd->id = id;
15361536 ngd->pdev->dev.parent = parent;
15371537
1538− ret = driver_set_override(&ngd->pdev->dev,
1539− &ngd->pdev->driver_override,
1540− QCOM_SLIM_NGD_DRV_NAME,
1541− strlen(QCOM_SLIM_NGD_DRV_NAME));
1538+ ret = device_set_driver_override(&ngd->pdev->dev,
1539+ QCOM_SLIM_NGD_DRV_NAME);
15421540 if (ret) {
15431541 platform_device_put(ngd->pdev);
15441542 kfree(ngd);
drivers/soc/fsl/qbman/qman.c+22−2
@@ -1827,6 +1827,8 @@ EXPORT_SYMBOL(qman_create_fq); · 1826 unmodified lines
18271827
18281828 void qman_destroy_fq(struct qman_fq *fq)
18291829 {
1830+ int leaked;
1831+
18301832 /*
18311833 * We don't need to lock the FQ as it is a pre-condition that the FQ be
18321834 * quiesced. Instead, run some checks.
@@ -1834,11 +1836,29 @@ void qman_destroy_fq(struct qman_fq *fq) · 1 unmodified line
18341836 switch (fq->state) {
18351837 case qman_fq_state_parked:
18361838 case qman_fq_state_oos:
1837− if (fq_isset(fq, QMAN_FQ_FLAG_DYNAMIC_FQID))
1838− qman_release_fqid(fq->fqid);
1839+ /*
1840+ * There's a race condition here on releasing the fqid,
1841+ * setting the fq_table to NULL, and freeing the fqid.
1842+ * To prevent it, this order should be respected:
1843+ */
1844+ if (fq_isset(fq, QMAN_FQ_FLAG_DYNAMIC_FQID)) {
1845+ leaked = qman_shutdown_fq(fq->fqid);
1846+ if (leaked)
1847+ pr_debug("FQID %d leaked\n", fq->fqid);
1848+ }
18391849
18401850 DPAA_ASSERT(fq_table[fq->idx]);
18411851 fq_table[fq->idx] = NULL;
1852+
1853+ if (fq_isset(fq, QMAN_FQ_FLAG_DYNAMIC_FQID) && !leaked) {
1854+ /*
1855+ * fq_table[fq->idx] should be set to null before
1856+ * freeing fq->fqid otherwise it could by allocated by
1857+ * qman_alloc_fqid() while still being !NULL
1858+ */
1859+ smp_wmb();
1860+ gen_pool_free(qm_fqalloc, fq->fqid | DPAA_GENALLOC_OFF, 1);
1861+ }
18421862 return;
18431863 default:
18441864 break;
drivers/soc/fsl/qe/qmc.c+2−2
@@ -1790,8 +1790,8 @@ static int qmc_qe_init_resources(struct qmc *qmc, struct platform_device *pdev) · 1789 unmodified lines
17901790 return -EINVAL;
17911791 qmc->dpram_offset = res->start - qe_muram_dma(qe_muram_addr(0));
17921792 qmc->dpram = devm_ioremap_resource(qmc->dev, res);
1793− if (IS_ERR(qmc->scc_pram))
1794− return PTR_ERR(qmc->scc_pram);
1793+ if (IS_ERR(qmc->dpram))
1794+ return PTR_ERR(qmc->dpram);
17951795
17961796 return 0;
17971797 }
drivers/soc/microchip/mpfs-sys-controller.c+9−4
@@ -142,8 +142,10 @@ static int mpfs_sys_controller_probe(struct platform_device *pdev) · 141 unmodified lines
142142
143143 sys_controller->flash = of_get_mtd_device_by_node(np);
144144 of_node_put(np);
145− if (IS_ERR(sys_controller->flash))
146− return dev_err_probe(dev, PTR_ERR(sys_controller->flash), "Failed to get flash\n");
145+ if (IS_ERR(sys_controller->flash)) {
146+ ret = dev_err_probe(dev, PTR_ERR(sys_controller->flash), "Failed to get flash\n");
147+ goto out_free;
148+ }
147149
148150 no_flash:
149151 sys_controller->client.dev = dev;
@@ -155,8 +157,7 @@ no_flash: · 5 unmodified lines
155157 if (IS_ERR(sys_controller->chan)) {
156158 ret = dev_err_probe(dev, PTR_ERR(sys_controller->chan),
157159 "Failed to get mbox channel\n");
158− kfree(sys_controller);
159− return ret;
160+ goto out_free;
160161 }
161162
162163 init_completion(&sys_controller->c);
@@ -174,6 +175,10 @@ no_flash: · 11 unmodified lines
174175 dev_info(&pdev->dev, "Registered MPFS system controller\n");
175176
176177 return 0;
178+
179+out_free:
180+ kfree(sys_controller);
181+ return ret;
177182 }
178183
179184 static void mpfs_sys_controller_remove(struct platform_device *pdev)
drivers/soc/rockchip/grf.c+1−0
@@ -231,6 +231,7 @@ static int __init rockchip_grf_init(void) · 230 unmodified lines
231231 grf = syscon_node_to_regmap(np);
232232 if (IS_ERR(grf)) {
233233 pr_err("%s: could not get grf syscon\n", __func__);
234+ of_node_put(np);
234235 return PTR_ERR(grf);
235236 }
236237
drivers/spi/spi-amlogic-spifc-a4.c+7−39
@@ -1083,14 +1083,6 @@ static int aml_sfc_clk_init(struct aml_sfc *sfc) · 1082 unmodified lines
10831083 return clk_set_rate(sfc->core_clk, SFC_BUS_DEFAULT_CLK);
10841084 }
10851085
1086−static int aml_sfc_disable_clk(struct aml_sfc *sfc)
1087−{
1088− clk_disable_unprepare(sfc->core_clk);
1089− clk_disable_unprepare(sfc->gate_clk);
1090−
1091− return 0;
1092−}
1093−
10941086 static int aml_sfc_probe(struct platform_device *pdev)
10951087 {
10961088 struct device_node *np = pdev->dev.of_node;
@@ -1141,16 +1133,12 @@ static int aml_sfc_probe(struct platform_device *pdev) · 44 unmodified lines
11411133
11421134 /* Enable Amlogic flash controller spi mode */
11431135 ret = regmap_write(sfc->regmap_base, SFC_SPI_CFG, SPI_MODE_EN);
1144− if (ret) {
1145− dev_err(dev, "failed to enable SPI mode\n");
1146− goto err_out;
1147− }
1136+ if (ret)
1137+ return dev_err_probe(dev, ret, "failed to enable SPI mode\n");
11481138
11491139 ret = dma_set_mask(sfc->dev, DMA_BIT_MASK(32));
1150− if (ret) {
1151− dev_err(sfc->dev, "failed to set dma mask\n");
1152− goto err_out;
1153− }
1140+ if (ret)
1141+ return dev_err_probe(sfc->dev, ret, "failed to set dma mask\n");
11541142
11551143 sfc->ecc_eng.dev = &pdev->dev;
11561144 sfc->ecc_eng.integration = NAND_ECC_ENGINE_INTEGRATION_PIPELINED;
@@ -1158,10 +1146,8 @@ static int aml_sfc_probe(struct platform_device *pdev) · 1 unmodified line
11581146 sfc->ecc_eng.priv = sfc;
11591147
11601148 ret = nand_ecc_register_on_host_hw_engine(&sfc->ecc_eng);
1161− if (ret) {
1162− dev_err(&pdev->dev, "failed to register Aml host ecc engine.\n");
1163− goto err_out;
1164− }
1149+ if (ret)
1150+ return dev_err_probe(&pdev->dev, ret, "failed to register Aml host ecc engine.\n");
11651151
11661152 ret = of_property_read_u32(np, "amlogic,rx-adj", &val);
11671153 if (!ret)
@@ -1177,24 +1163,7 @@ static int aml_sfc_probe(struct platform_device *pdev) · 9 unmodified lines
11771163 ctrl->min_speed_hz = SFC_MIN_FREQUENCY;
11781164 ctrl->num_chipselect = SFC_MAX_CS_NUM;
11791165
1180− ret = devm_spi_register_controller(dev, ctrl);
1181− if (ret)
1182− goto err_out;
1183−
1184− return 0;
1185−
1186−err_out:
1187− aml_sfc_disable_clk(sfc);
1188−
1189− return ret;
1190−}
1191−
1192−static void aml_sfc_remove(struct platform_device *pdev)
1193−{
1194− struct spi_controller *ctlr = platform_get_drvdata(pdev);
1195− struct aml_sfc *sfc = spi_controller_get_devdata(ctlr);
1196−
1197− aml_sfc_disable_clk(sfc);
1166+ return devm_spi_register_controller(dev, ctrl);
11981167 }
11991168
12001169 static const struct of_device_id aml_sfc_of_match[] = {
@@ -1212,7 +1181,6 @@ static struct platform_driver aml_sfc_driver = { · 11 unmodified lines
12121181 .of_match_table = aml_sfc_of_match,
12131182 },
12141183 .probe = aml_sfc_probe,
1215− .remove = aml_sfc_remove,
12161184 };
12171185 module_platform_driver(aml_sfc_driver);
12181186
drivers/spi/spi-amlogic-spisg.c+4−8
@@ -729,9 +729,9 @@ static int aml_spisg_probe(struct platform_device *pdev) · 728 unmodified lines
729729 };
730730
731731 if (of_property_read_bool(dev->of_node, "spi-slave"))
732− ctlr = spi_alloc_target(dev, sizeof(*spisg));
732+ ctlr = devm_spi_alloc_target(dev, sizeof(*spisg));
733733 else
734− ctlr = spi_alloc_host(dev, sizeof(*spisg));
734+ ctlr = devm_spi_alloc_host(dev, sizeof(*spisg));
735735 if (!ctlr)
736736 return -ENOMEM;
737737
@@ -750,10 +750,8 @@ static int aml_spisg_probe(struct platform_device *pdev) · 12 unmodified lines
750750 return dev_err_probe(dev, PTR_ERR(spisg->map), "regmap init failed\n");
751751
752752 irq = platform_get_irq(pdev, 0);
753− if (irq < 0) {
754− ret = irq;
755− goto out_controller;
756− }
753+ if (irq < 0)
754+ return irq;
757755
758756 ret = device_reset_optional(dev);
759757 if (ret)
@@ -817,8 +815,6 @@ out_clk: · 57 unmodified lines
817815 if (spisg->core)
818816 clk_disable_unprepare(spisg->core);
819817 clk_disable_unprepare(spisg->pclk);
820−out_controller:
821− spi_controller_put(ctlr);
822818
823819 return ret;
824820 }
drivers/spi/spi-axiado.c+11−20
@@ -765,30 +765,22 @@ static int ax_spi_probe(struct platform_device *pdev) · 764 unmodified lines
765765 platform_set_drvdata(pdev, ctlr);
766766
767767 xspi->regs = devm_platform_ioremap_resource(pdev, 0);
768− if (IS_ERR(xspi->regs)) {
769− ret = PTR_ERR(xspi->regs);
770− goto remove_ctlr;
771− }
768+ if (IS_ERR(xspi->regs))
769+ return PTR_ERR(xspi->regs);
772770
773771 xspi->pclk = devm_clk_get(&pdev->dev, "pclk");
774− if (IS_ERR(xspi->pclk)) {
775− dev_err(&pdev->dev, "pclk clock not found.\n");
776− ret = PTR_ERR(xspi->pclk);
777− goto remove_ctlr;
778− }
772+ if (IS_ERR(xspi->pclk))
773+ return dev_err_probe(&pdev->dev, PTR_ERR(xspi->pclk),
774+ "pclk clock not found.\n");
779775
780776 xspi->ref_clk = devm_clk_get(&pdev->dev, "ref");
781− if (IS_ERR(xspi->ref_clk)) {
782− dev_err(&pdev->dev, "ref clock not found.\n");
783− ret = PTR_ERR(xspi->ref_clk);
784− goto remove_ctlr;
785− }
777+ if (IS_ERR(xspi->ref_clk))
778+ return dev_err_probe(&pdev->dev, PTR_ERR(xspi->ref_clk),
779+ "ref clock not found.\n");
786780
787781 ret = clk_prepare_enable(xspi->pclk);
788− if (ret) {
789− dev_err(&pdev->dev, "Unable to enable APB clock.\n");
790− goto remove_ctlr;
791− }
782+ if (ret)
783+ return dev_err_probe(&pdev->dev, ret, "Unable to enable APB clock.\n");
792784
793785 ret = clk_prepare_enable(xspi->ref_clk);
794786 if (ret) {
@@ -869,8 +861,7 @@ clk_dis_all: · 74 unmodified lines
869861 clk_disable_unprepare(xspi->ref_clk);
870862 clk_dis_apb:
871863 clk_disable_unprepare(xspi->pclk);
872−remove_ctlr:
873− spi_controller_put(ctlr);
864+
874865 return ret;
875866 }
876867
drivers/spi/spi-geni-qcom.c+7−6
@@ -359,9 +359,9 @@ static int setup_fifo_params(struct spi_device *spi_slv, · 358 unmodified lines
359359 writel((spi_slv->mode & SPI_LOOP) ? LOOPBACK_ENABLE : 0, se->base + SE_SPI_LOOPBACK);
360360 if (cs_changed)
361361 writel(chipselect, se->base + SE_SPI_DEMUX_SEL);
362− if (mode_changed & SE_SPI_CPHA)
362+ if (mode_changed & SPI_CPHA)
363363 writel((spi_slv->mode & SPI_CPHA) ? CPHA : 0, se->base + SE_SPI_CPHA);
364− if (mode_changed & SE_SPI_CPOL)
364+ if (mode_changed & SPI_CPOL)
365365 writel((spi_slv->mode & SPI_CPOL) ? CPOL : 0, se->base + SE_SPI_CPOL);
366366 if ((mode_changed & SPI_CS_HIGH) || (cs_changed && (spi_slv->mode & SPI_CS_HIGH)))
367367 writel((spi_slv->mode & SPI_CS_HIGH) ? BIT(chipselect) : 0, se->base + SE_SPI_DEMUX_OUTPUT_INV);
@@ -906,10 +906,13 @@ static irqreturn_t geni_spi_isr(int irq, void *data) · 538 unmodified lines
906906 struct spi_controller *spi = data;
907907 struct spi_geni_master *mas = spi_controller_get_devdata(spi);
908908 struct geni_se *se = &mas->se;
909− u32 m_irq;
909+ u32 m_irq, dma_tx_status, dma_rx_status;
910910
911911 m_irq = readl(se->base + SE_GENI_M_IRQ_STATUS);
912− if (!m_irq)
912+ dma_tx_status = readl_relaxed(se->base + SE_DMA_TX_IRQ_STAT);
913+ dma_rx_status = readl_relaxed(se->base + SE_DMA_RX_IRQ_STAT);
914+
915+ if (!m_irq && !dma_tx_status && !dma_rx_status)
913916 return IRQ_NONE;
914917
915918 if (m_irq & (M_CMD_OVERRUN_EN | M_ILLEGAL_CMD_EN | M_CMD_FAILURE_EN |
@@ -957,8 +960,6 @@ static irqreturn_t geni_spi_isr(int irq, void *data) · 41 unmodified lines
957960 }
958961 } else if (mas->cur_xfer_mode == GENI_SE_DMA) {
959962 const struct spi_transfer *xfer = mas->cur_xfer;
960− u32 dma_tx_status = readl_relaxed(se->base + SE_DMA_TX_IRQ_STAT);
961− u32 dma_rx_status = readl_relaxed(se->base + SE_DMA_RX_IRQ_STAT);
962963
963964 if (dma_tx_status)
964965 writel(dma_tx_status, se->base + SE_DMA_TX_IRQ_CLR);
drivers/spi/spi.c+12−13
@@ -3049,6 +3049,8 @@ static void spi_controller_release(struct device *dev) · 3048 unmodified lines
30493049 struct spi_controller *ctlr;
30503050
30513051 ctlr = container_of(dev, struct spi_controller, dev);
3052+
3053+ free_percpu(ctlr->pcpu_statistics);
30523054 kfree(ctlr);
30533055 }
30543056
@@ -3192,6 +3194,12 @@ struct spi_controller *__spi_alloc_controller(struct device *dev, · 137 unmodified lines
31923194 if (!ctlr)
31933195 return NULL;
31943196
3197+ ctlr->pcpu_statistics = spi_alloc_pcpu_stats(NULL);
3198+ if (!ctlr->pcpu_statistics) {
3199+ kfree(ctlr);
3200+ return NULL;
3201+ }
3202+
31953203 device_initialize(&ctlr->dev);
31963204 INIT_LIST_HEAD(&ctlr->queue);
31973205 spin_lock_init(&ctlr->queue_lock);
@@ -3480,17 +3488,8 @@ int spi_register_controller(struct spi_controller *ctlr) · 282 unmodified lines
34803488 dev_info(dev, "controller is unqueued, this is deprecated\n");
34813489 } else if (ctlr->transfer_one || ctlr->transfer_one_message) {
34823490 status = spi_controller_initialize_queue(ctlr);
3483− if (status) {
3484− device_del(&ctlr->dev);
3485− goto free_bus_id;
3486− }
3487− }
3488− /* Add statistics */
3489− ctlr->pcpu_statistics = spi_alloc_pcpu_stats(dev);
3490− if (!ctlr->pcpu_statistics) {
3491− dev_err(dev, "Error allocating per-cpu statistics\n");
3492− status = -ENOMEM;
3493− goto destroy_queue;
3491+ if (status)
3492+ goto del_ctrl;
34943493 }
34953494
34963495 mutex_lock(&board_lock);
@@ -3504,8 +3503,8 @@ int spi_register_controller(struct spi_controller *ctlr) · 7 unmodified lines
35043503 acpi_register_spi_devices(ctlr);
35053504 return status;
35063505
3507−destroy_queue:
3508− spi_destroy_queue(ctlr);
3506+del_ctrl:
3507+ device_del(&ctlr->dev);
35093508 free_bus_id:
35103509 mutex_lock(&board_lock);
35113510 idr_remove(&spi_controller_idr, ctlr->bus_num);
drivers/tee/tee_shm.c+0−27
@@ -23,29 +23,11 @@ struct tee_shm_dma_mem { · 22 unmodified lines
2323 struct page *page;
2424 };
2525
26−static void shm_put_kernel_pages(struct page **pages, size_t page_count)
27−{
28− size_t n;
29−
30− for (n = 0; n < page_count; n++)
31− put_page(pages[n]);
32−}
33−
34−static void shm_get_kernel_pages(struct page **pages, size_t page_count)
35−{
36− size_t n;
37−
38− for (n = 0; n < page_count; n++)
39− get_page(pages[n]);
40−}
41−
4226 static void release_registered_pages(struct tee_shm *shm)
4327 {
4428 if (shm->pages) {
4529 if (shm->flags & TEE_SHM_USER_MAPPED)
4630 unpin_user_pages(shm->pages, shm->num_pages);
47− else
48− shm_put_kernel_pages(shm->pages, shm->num_pages);
4931
5032 kfree(shm->pages);
5133 }
@@ -477,13 +459,6 @@ register_shm_helper(struct tee_context *ctx, struct iov_iter *iter, u32 flags, · 425 unmodified lines
477459 goto err_put_shm_pages;
478460 }
479461
480− /*
481− * iov_iter_extract_kvec_pages does not get reference on the pages,
482− * get a reference on them.
483− */
484− if (iov_iter_is_kvec(iter))
485− shm_get_kernel_pages(shm->pages, num_pages);
486−
487462 shm->offset = off;
488463 shm->size = len;
489464 shm->num_pages = num_pages;
@@ -499,8 +474,6 @@ register_shm_helper(struct tee_context *ctx, struct iov_iter *iter, u32 flags, · 9 unmodified lines
499474 err_put_shm_pages:
500475 if (!iov_iter_is_kvec(iter))
501476 unpin_user_pages(shm->pages, shm->num_pages);
502− else
503− shm_put_kernel_pages(shm->pages, shm->num_pages);
504477 err_free_shm_pages:
505478 kfree(shm->pages);
506479 err_free_shm:
drivers/tty/serial/8250/8250.h+25−0
@@ -175,7 +175,9 @@ static unsigned int __maybe_unused serial_icr_read(struct uart_8250_port *up, · 174 unmodified lines
175175 return value;
176176 }
177177
178+void serial8250_clear_fifos(struct uart_8250_port *p);
178179 void serial8250_clear_and_reinit_fifos(struct uart_8250_port *p);
180+void serial8250_fifo_wait_for_lsr_thre(struct uart_8250_port *up, unsigned int count);
179181
180182 void serial8250_rpm_get(struct uart_8250_port *p);
181183 void serial8250_rpm_put(struct uart_8250_port *p);
@@ -400,6 +402,26 @@ static inline bool serial8250_tx_dma_running(struct uart_8250_port *p) · 218 unmodified lines
400402
401403 return dma && dma->tx_running;
402404 }
405+
406+static inline void serial8250_tx_dma_pause(struct uart_8250_port *p)
407+{
408+ struct uart_8250_dma *dma = p->dma;
409+
410+ if (!dma->tx_running)
411+ return;
412+
413+ dmaengine_pause(dma->txchan);
414+}
415+
416+static inline void serial8250_tx_dma_resume(struct uart_8250_port *p)
417+{
418+ struct uart_8250_dma *dma = p->dma;
419+
420+ if (!dma->tx_running)
421+ return;
422+
423+ dmaengine_resume(dma->txchan);
424+}
403425 #else
404426 static inline int serial8250_tx_dma(struct uart_8250_port *p)
405427 {
@@ -421,6 +443,9 @@ static inline bool serial8250_tx_dma_running(struct uart_8250_port *p) · 15 unmodified lines
421443 {
422444 return false;
423445 }
446+
447+static inline void serial8250_tx_dma_pause(struct uart_8250_port *p) { }
448+static inline void serial8250_tx_dma_resume(struct uart_8250_port *p) { }
424449 #endif
425450
426451 static inline int ns16550a_goto_highspeed(struct uart_8250_port *up)
drivers/tty/serial/8250/8250_dma.c+15−0
@@ -162,7 +162,22 @@ void serial8250_tx_dma_flush(struct uart_8250_port *p) · 161 unmodified lines
162162 */
163163 dma->tx_size = 0;
164164
165+ /*
166+ * We can't use `dmaengine_terminate_sync` because `uart_flush_buffer` is
167+ * holding the uart port spinlock.
168+ */
165169 dmaengine_terminate_async(dma->txchan);
170+
171+ /*
172+ * The callback might or might not run. If it doesn't run, we need to ensure
173+ * that `tx_running` is cleared so that we can schedule new transactions.
174+ * If it does run, then the zombie callback will clear `tx_running` again
175+ * and perform a no-op since `tx_size` was cleared above.
176+ *
177+ * In either case, we ASSUME the DMA transaction will terminate before we
178+ * issue a new `serial8250_tx_dma`.
179+ */
180+ dma->tx_running = 0;
166181 }
167182
168183 int serial8250_rx_dma(struct uart_8250_port *p)
drivers/tty/serial/8250/8250_dw.c+235−61
@@ -9,10 +9,14 @@ · 8 unmodified lines
99 * LCR is written whilst busy. If it is, then a busy detect interrupt is
1010 * raised, the LCR needs to be rewritten and the uart status register read.
1111 */
12+#include <linux/bitfield.h>
13+#include <linux/bits.h>
14+#include <linux/cleanup.h>
1215 #include <linux/clk.h>
1316 #include <linux/delay.h>
1417 #include <linux/device.h>
1518 #include <linux/io.h>
19+#include <linux/lockdep.h>
1620 #include <linux/mod_devicetable.h>
1721 #include <linux/module.h>
1822 #include <linux/notifier.h>
@@ -40,8 +44,12 @@ · 21 unmodified lines
4044 #define RZN1_UART_RDMACR 0x110 /* DMA Control Register Receive Mode */
4145
4246 /* DesignWare specific register fields */
47+#define DW_UART_IIR_IID GENMASK(3, 0)
48+
4349 #define DW_UART_MCR_SIRE BIT(6)
4450
51+#define DW_UART_USR_BUSY BIT(0)
52+
4553 /* Renesas specific register fields */
4654 #define RZN1_UART_xDMACR_DMA_EN BIT(0)
4755 #define RZN1_UART_xDMACR_1_WORD_BURST (0 << 1)
@@ -56,6 +64,13 @@ · 8 unmodified lines
5664 #define DW_UART_QUIRK_IS_DMA_FC BIT(3)
5765 #define DW_UART_QUIRK_APMC0D08 BIT(4)
5866 #define DW_UART_QUIRK_CPR_VALUE BIT(5)
67+#define DW_UART_QUIRK_IER_KICK BIT(6)
68+
69+/*
70+ * Number of consecutive IIR_NO_INT interrupts required to trigger interrupt
71+ * storm prevention code.
72+ */
73+#define DW_UART_QUIRK_IER_KICK_THRES 4
5974
6075 struct dw8250_platform_data {
6176 u8 usr_reg;
@@ -77,6 +92,9 @@ struct dw8250_data { · 15 unmodified lines
7792
7893 unsigned int skip_autocfg:1;
7994 unsigned int uart_16550_compatible:1;
95+ unsigned int in_idle:1;
96+
97+ u8 no_int_count;
8098 };
8199
82100 static inline struct dw8250_data *to_dw8250_data(struct dw8250_port_data *data)
@@ -107,78 +125,167 @@ static inline u32 dw8250_modify_msr(struct uart_port *p, unsigned int offset, u3 · 24 unmodified lines
107125 return value;
108126 }
109127
128+static void dw8250_idle_exit(struct uart_port *p)
129+{
130+ struct dw8250_data *d = to_dw8250_data(p->private_data);
131+ struct uart_8250_port *up = up_to_u8250p(p);
132+
133+ if (d->uart_16550_compatible)
134+ return;
135+
136+ if (up->capabilities & UART_CAP_FIFO)
137+ serial_port_out(p, UART_FCR, up->fcr);
138+ serial_port_out(p, UART_MCR, up->mcr);
139+ serial_port_out(p, UART_IER, up->ier);
140+
141+ /* DMA Rx is restarted by IRQ handler as needed. */
142+ if (up->dma)
143+ serial8250_tx_dma_resume(up);
144+
145+ d->in_idle = 0;
146+}
147+
110148 /*
111− * This function is being called as part of the uart_port::serial_out()
112− * routine. Hence, it must not call serial_port_out() or serial_out()
113− * against the modified registers here, i.e. LCR.
149+ * Ensure BUSY is not asserted. If DW UART is configured with
150+ * !uart_16550_compatible, the writes to LCR, DLL, and DLH fail while
151+ * BUSY is asserted.
152+ *
153+ * Context: port's lock must be held
114154 */
115−static void dw8250_force_idle(struct uart_port *p)
155+static int dw8250_idle_enter(struct uart_port *p)
116156 {
157+ struct dw8250_data *d = to_dw8250_data(p->private_data);
158+ unsigned int usr_reg = d->pdata ? d->pdata->usr_reg : DW_UART_USR;
117159 struct uart_8250_port *up = up_to_u8250p(p);
118− unsigned int lsr;
160+ int retries;
161+ u32 lsr;
119162
120− /*
121− * The following call currently performs serial_out()
122− * against the FCR register. Because it differs to LCR
123− * there will be no infinite loop, but if it ever gets
124− * modified, we might need a new custom version of it
125− * that avoids infinite recursion.
126− */
127− serial8250_clear_and_reinit_fifos(up);
163+ lockdep_assert_held_once(&p->lock);
164+
165+ if (d->uart_16550_compatible)
166+ return 0;
167+
168+ d->in_idle = 1;
169+
170+ /* Prevent triggering interrupt from RBR filling */
171+ serial_port_out(p, UART_IER, 0);
172+
173+ if (up->dma) {
174+ serial8250_rx_dma_flush(up);
175+ if (serial8250_tx_dma_running(up))
176+ serial8250_tx_dma_pause(up);
177+ }
128178
129179 /*
130− * With PSLVERR_RESP_EN parameter set to 1, the device generates an
131− * error response when an attempt to read an empty RBR with FIFO
132− * enabled.
180+ * Wait until Tx becomes empty + one extra frame time to ensure all bits
181+ * have been sent on the wire.
182+ *
183+ * FIXME: frame_time delay is too long with very low baudrates.
133184 */
134− if (up->fcr & UART_FCR_ENABLE_FIFO) {
135− lsr = serial_port_in(p, UART_LSR);
136− if (!(lsr & UART_LSR_DR))
137− return;
185+ serial8250_fifo_wait_for_lsr_thre(up, p->fifosize);
186+ ndelay(p->frame_time);
187+
188+ serial_port_out(p, UART_MCR, up->mcr | UART_MCR_LOOP);
189+
190+ retries = 4; /* Arbitrary limit, 2 was always enough in tests */
191+ do {
192+ serial8250_clear_fifos(up);
193+ if (!(serial_port_in(p, usr_reg) & DW_UART_USR_BUSY))
194+ break;
195+ /* FIXME: frame_time delay is too long with very low baudrates. */
196+ ndelay(p->frame_time);
197+ } while (--retries);
198+
199+ lsr = serial_lsr_in(up);
200+ if (lsr & UART_LSR_DR) {
201+ serial_port_in(p, UART_RX);
202+ up->lsr_saved_flags = 0;
203+ }
204+
205+ /* Now guaranteed to have BUSY deasserted? Just sanity check */
206+ if (serial_port_in(p, usr_reg) & DW_UART_USR_BUSY) {
207+ dw8250_idle_exit(p);
208+ return -EBUSY;
138209 }
139210
140− serial_port_in(p, UART_RX);
211+ return 0;
212+}
213+
214+static void dw8250_set_divisor(struct uart_port *p, unsigned int baud,
215+ unsigned int quot, unsigned int quot_frac)
216+{
217+ struct uart_8250_port *up = up_to_u8250p(p);
218+ int ret;
219+
220+ ret = dw8250_idle_enter(p);
221+ if (ret < 0)
222+ return;
223+
224+ serial_port_out(p, UART_LCR, up->lcr | UART_LCR_DLAB);
225+ if (!(serial_port_in(p, UART_LCR) & UART_LCR_DLAB))
226+ goto idle_failed;
227+
228+ serial_dl_write(up, quot);
229+ serial_port_out(p, UART_LCR, up->lcr);
230+
231+idle_failed:
232+ dw8250_idle_exit(p);
141233 }
142234
143235 /*
144236 * This function is being called as part of the uart_port::serial_out()
145− * routine. Hence, it must not call serial_port_out() or serial_out()
146− * against the modified registers here, i.e. LCR.
237+ * routine. Hence, special care must be taken when serial_port_out() or
238+ * serial_out() against the modified registers here, i.e. LCR (d->in_idle is
239+ * used to break recursion loop).
147240 */
148241 static void dw8250_check_lcr(struct uart_port *p, unsigned int offset, u32 value)
149242 {
150243 struct dw8250_data *d = to_dw8250_data(p->private_data);
151− void __iomem *addr = p->membase + (offset << p->regshift);
152− int tries = 1000;
244+ u32 lcr;
245+ int ret;
153246
154247 if (offset != UART_LCR || d->uart_16550_compatible)
155248 return;
156249
250+ lcr = serial_port_in(p, UART_LCR);
251+
157252 /* Make sure LCR write wasn't ignored */
158− while (tries--) {
159− u32 lcr = serial_port_in(p, offset);
253+ if ((value & ~UART_LCR_SPAR) == (lcr & ~UART_LCR_SPAR))
254+ return;
160255
161− if ((value & ~UART_LCR_SPAR) == (lcr & ~UART_LCR_SPAR))
162− return;
256+ if (d->in_idle)
257+ goto write_err;
163258
164− dw8250_force_idle(p);
259+ ret = dw8250_idle_enter(p);
260+ if (ret < 0)
261+ goto write_err;
165262
166−#ifdef CONFIG_64BIT
167− if (p->type == PORT_OCTEON)
168− __raw_writeq(value & 0xff, addr);
169− else
170−#endif
171− if (p->iotype == UPIO_MEM32)
172− writel(value, addr);
173− else if (p->iotype == UPIO_MEM32BE)
174− iowrite32be(value, addr);
175− else
176− writeb(value, addr);
177− }
263+ serial_port_out(p, UART_LCR, value);
264+ dw8250_idle_exit(p);
265+ return;
266+
267+write_err:
178268 /*
179269 * FIXME: this deadlocks if port->lock is already held
180270 * dev_err(p->dev, "Couldn't set LCR to %d\n", value);
181271 */
272+ return; /* Silences "label at the end of compound statement" */
273+}
274+
275+/*
276+ * With BUSY, LCR writes can be very expensive (IRQ + complex retry logic).
277+ * If the write does not change the value of the LCR register, skip it entirely.
278+ */
279+static bool dw8250_can_skip_reg_write(struct uart_port *p, unsigned int offset, u32 value)
280+{
281+ struct dw8250_data *d = to_dw8250_data(p->private_data);
282+ u32 lcr;
283+
284+ if (offset != UART_LCR || d->uart_16550_compatible)
285+ return false;
286+
287+ lcr = serial_port_in(p, offset);
288+ return lcr == value;
182289 }
183290
184291 /* Returns once the transmitter is empty or we run out of retries */
@@ -207,12 +314,18 @@ static void dw8250_tx_wait_empty(struct uart_port *p) · 22 unmodified lines
207314
208315 static void dw8250_serial_out(struct uart_port *p, unsigned int offset, u32 value)
209316 {
317+ if (dw8250_can_skip_reg_write(p, offset, value))
318+ return;
319+
210320 writeb(value, p->membase + (offset << p->regshift));
211321 dw8250_check_lcr(p, offset, value);
212322 }
213323
214324 static void dw8250_serial_out38x(struct uart_port *p, unsigned int offset, u32 value)
215325 {
326+ if (dw8250_can_skip_reg_write(p, offset, value))
327+ return;
328+
216329 /* Allow the TX to drain before we reconfigure */
217330 if (offset == UART_LCR)
218331 dw8250_tx_wait_empty(p);
@@ -237,6 +350,9 @@ static u32 dw8250_serial_inq(struct uart_port *p, unsigned int offset) · 18 unmodified lines
237350
238351 static void dw8250_serial_outq(struct uart_port *p, unsigned int offset, u32 value)
239352 {
353+ if (dw8250_can_skip_reg_write(p, offset, value))
354+ return;
355+
240356 value &= 0xff;
241357 __raw_writeq(value, p->membase + (offset << p->regshift));
242358 /* Read back to ensure register write ordering. */
@@ -248,6 +364,9 @@ static void dw8250_serial_outq(struct uart_port *p, unsigned int offset, u32 val · 5 unmodified lines
248364
249365 static void dw8250_serial_out32(struct uart_port *p, unsigned int offset, u32 value)
250366 {
367+ if (dw8250_can_skip_reg_write(p, offset, value))
368+ return;
369+
251370 writel(value, p->membase + (offset << p->regshift));
252371 dw8250_check_lcr(p, offset, value);
253372 }
@@ -261,6 +380,9 @@ static u32 dw8250_serial_in32(struct uart_port *p, unsigned int offset) · 7 unmodified lines
261380
262381 static void dw8250_serial_out32be(struct uart_port *p, unsigned int offset, u32 value)
263382 {
383+ if (dw8250_can_skip_reg_write(p, offset, value))
384+ return;
385+
264386 iowrite32be(value, p->membase + (offset << p->regshift));
265387 dw8250_check_lcr(p, offset, value);
266388 }
@@ -272,6 +394,29 @@ static u32 dw8250_serial_in32be(struct uart_port *p, unsigned int offset) · 5 unmodified lines
272394 return dw8250_modify_msr(p, offset, value);
273395 }
274396
397+/*
398+ * INTC10EE UART can IRQ storm while reporting IIR_NO_INT. Inducing IIR value
399+ * change has been observed to break the storm.
400+ *
401+ * If Tx is empty (THRE asserted), we use here IER_THRI to cause IIR_NO_INT ->
402+ * IIR_THRI transition.
403+ */
404+static void dw8250_quirk_ier_kick(struct uart_port *p)
405+{
406+ struct uart_8250_port *up = up_to_u8250p(p);
407+ u32 lsr;
408+
409+ if (up->ier & UART_IER_THRI)
410+ return;
411+
412+ lsr = serial_lsr_in(up);
413+ if (!(lsr & UART_LSR_THRE))
414+ return;
415+
416+ serial_port_out(p, UART_IER, up->ier | UART_IER_THRI);
417+ serial_port_in(p, UART_LCR); /* safe, no side-effects */
418+ serial_port_out(p, UART_IER, up->ier);
419+}
275420
276421 static int dw8250_handle_irq(struct uart_port *p)
277422 {
@@ -281,7 +426,31 @@ static int dw8250_handle_irq(struct uart_port *p) · 3 unmodified lines
281426 bool rx_timeout = (iir & 0x3f) == UART_IIR_RX_TIMEOUT;
282427 unsigned int quirks = d->pdata->quirks;
283428 unsigned int status;
284− unsigned long flags;
429+
430+ guard(uart_port_lock_irqsave)(p);
431+
432+ switch (FIELD_GET(DW_UART_IIR_IID, iir)) {
433+ case UART_IIR_NO_INT:
434+ if (d->uart_16550_compatible || up->dma)
435+ return 0;
436+
437+ if (quirks & DW_UART_QUIRK_IER_KICK &&
438+ d->no_int_count == (DW_UART_QUIRK_IER_KICK_THRES - 1))
439+ dw8250_quirk_ier_kick(p);
440+ d->no_int_count = (d->no_int_count + 1) % DW_UART_QUIRK_IER_KICK_THRES;
441+
442+ return 0;
443+
444+ case UART_IIR_BUSY:
445+ /* Clear the USR */
446+ serial_port_in(p, d->pdata->usr_reg);
447+
448+ d->no_int_count = 0;
449+
450+ return 1;
451+ }
452+
453+ d->no_int_count = 0;
285454
286455 /*
287456 * There are ways to get Designware-based UARTs into a state where
@@ -294,20 +463,15 @@ static int dw8250_handle_irq(struct uart_port *p) · 6 unmodified lines
294463 * so we limit the workaround only to non-DMA mode.
295464 */
296465 if (!up->dma && rx_timeout) {
297− uart_port_lock_irqsave(p, &flags);
298466 status = serial_lsr_in(up);
299467
300468 if (!(status & (UART_LSR_DR | UART_LSR_BI)))
301469 serial_port_in(p, UART_RX);
302−
303− uart_port_unlock_irqrestore(p, flags);
304470 }
305471
306472 /* Manually stop the Rx DMA transfer when acting as flow controller */
307473 if (quirks & DW_UART_QUIRK_IS_DMA_FC && up->dma && up->dma->rx_running && rx_timeout) {
308− uart_port_lock_irqsave(p, &flags);
309474 status = serial_lsr_in(up);
310− uart_port_unlock_irqrestore(p, flags);
311475
312476 if (status & (UART_LSR_DR | UART_LSR_BI)) {
313477 dw8250_writel_ext(p, RZN1_UART_RDMACR, 0);
@@ -315,17 +479,9 @@ static int dw8250_handle_irq(struct uart_port *p) · 1 unmodified line
315479 }
316480 }
317481
318− if (serial8250_handle_irq(p, iir))
319− return 1;
320−
321− if ((iir & UART_IIR_BUSY) == UART_IIR_BUSY) {
322− /* Clear the USR */
323− serial_port_in(p, d->pdata->usr_reg);
324−
325− return 1;
326− }
482+ serial8250_handle_irq_locked(p, iir);
327483
328− return 0;
484+ return 1;
329485 }
330486
331487 static void dw8250_clk_work_cb(struct work_struct *work)
@@ -527,6 +683,14 @@ static void dw8250_reset_control_assert(void *data) · 195 unmodified lines
527683 reset_control_assert(data);
528684 }
529685
686+static void dw8250_shutdown(struct uart_port *port)
687+{
688+ struct dw8250_data *d = to_dw8250_data(port->private_data);
689+
690+ serial8250_do_shutdown(port);
691+ d->no_int_count = 0;
692+}
693+
530694 static int dw8250_probe(struct platform_device *pdev)
531695 {
532696 struct uart_8250_port uart = {}, *up = &uart;
@@ -545,8 +709,10 @@ static int dw8250_probe(struct platform_device *pdev) · 12 unmodified lines
545709 p->type = PORT_8250;
546710 p->flags = UPF_FIXED_PORT;
547711 p->dev = dev;
712+
548713 p->set_ldisc = dw8250_set_ldisc;
549714 p->set_termios = dw8250_set_termios;
715+ p->set_divisor = dw8250_set_divisor;
550716
551717 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
552718 if (!data)
@@ -654,10 +820,12 @@ static int dw8250_probe(struct platform_device *pdev) · 101 unmodified lines
654820 dw8250_quirks(p, data);
655821
656822 /* If the Busy Functionality is not implemented, don't handle it */
657− if (data->uart_16550_compatible)
823+ if (data->uart_16550_compatible) {
658824 p->handle_irq = NULL;
659− else if (data->pdata)
825+ } else if (data->pdata) {
660826 p->handle_irq = dw8250_handle_irq;
827+ p->shutdown = dw8250_shutdown;
828+ }
661829
662830 dw8250_setup_dma_filter(p, data);
663831
@@ -789,6 +957,11 @@ static const struct dw8250_platform_data dw8250_skip_set_rate_data = { · 125 unmodified lines
789957 .quirks = DW_UART_QUIRK_SKIP_SET_RATE,
790958 };
791959
960+static const struct dw8250_platform_data dw8250_intc10ee = {
961+ .usr_reg = DW_UART_USR,
962+ .quirks = DW_UART_QUIRK_IER_KICK,
963+};
964+
792965 static const struct of_device_id dw8250_of_match[] = {
793966 { .compatible = "snps,dw-apb-uart", .data = &dw8250_dw_apb },
794967 { .compatible = "cavium,octeon-3860-uart", .data = &dw8250_octeon_3860_data },
@@ -818,7 +991,7 @@ static const struct acpi_device_id dw8250_acpi_match[] = { · 23 unmodified lines
818991 { "INT33C5", (kernel_ulong_t)&dw8250_dw_apb },
819992 { "INT3434", (kernel_ulong_t)&dw8250_dw_apb },
820993 { "INT3435", (kernel_ulong_t)&dw8250_dw_apb },
821− { "INTC10EE", (kernel_ulong_t)&dw8250_dw_apb },
994+ { "INTC10EE", (kernel_ulong_t)&dw8250_intc10ee },
822995 { },
823996 };
824997 MODULE_DEVICE_TABLE(acpi, dw8250_acpi_match);
@@ -836,6 +1009,7 @@ static struct platform_driver dw8250_platform_driver = { · 11 unmodified lines
8361009
8371010 module_platform_driver(dw8250_platform_driver);
8381011
1012+MODULE_IMPORT_NS("SERIAL_8250");
8391013 MODULE_AUTHOR("Jamie Iles");
8401014 MODULE_LICENSE("GPL");
8411015 MODULE_DESCRIPTION("Synopsys DesignWare 8250 serial port driver");
drivers/tty/serial/8250/8250_pci.c+17−0
@@ -137,6 +137,8 @@ struct serial_private { · 136 unmodified lines
137137 };
138138
139139 #define PCI_DEVICE_ID_HPE_PCI_SERIAL 0x37e
140+#define PCIE_VENDOR_ID_ASIX 0x125B
141+#define PCIE_DEVICE_ID_AX99100 0x9100
140142
141143 static const struct pci_device_id pci_use_msi[] = {
142144 { PCI_DEVICE_SUB(PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9900,
@@ -149,6 +151,8 @@ static const struct pci_device_id pci_use_msi[] = { · 6 unmodified lines
149151 0xA000, 0x1000) },
150152 { PCI_DEVICE_SUB(PCI_VENDOR_ID_HP_3PAR, PCI_DEVICE_ID_HPE_PCI_SERIAL,
151153 PCI_ANY_ID, PCI_ANY_ID) },
154+ { PCI_DEVICE_SUB(PCIE_VENDOR_ID_ASIX, PCIE_DEVICE_ID_AX99100,
155+ 0xA000, 0x1000) },
152156 { }
153157 };
154158
@@ -920,6 +924,7 @@ static int pci_netmos_init(struct pci_dev *dev) · 765 unmodified lines
920924 case PCI_DEVICE_ID_NETMOS_9912:
921925 case PCI_DEVICE_ID_NETMOS_9922:
922926 case PCI_DEVICE_ID_NETMOS_9900:
927+ case PCIE_DEVICE_ID_AX99100:
923928 num_serial = pci_netmos_9900_numports(dev);
924929 break;
925930
@@ -2544,6 +2549,14 @@ static struct pci_serial_quirk pci_serial_quirks[] = { · 1618 unmodified lines
25442549 .init = pci_netmos_init,
25452550 .setup = pci_netmos_9900_setup,
25462551 },
2552+ {
2553+ .vendor = PCIE_VENDOR_ID_ASIX,
2554+ .device = PCI_ANY_ID,
2555+ .subvendor = PCI_ANY_ID,
2556+ .subdevice = PCI_ANY_ID,
2557+ .init = pci_netmos_init,
2558+ .setup = pci_netmos_9900_setup,
2559+ },
25472560 /*
25482561 * EndRun Technologies
25492562 */
@@ -6065,6 +6078,10 @@ static const struct pci_device_id serial_pci_tbl[] = { · 3515 unmodified lines
60656078 0xA000, 0x3002,
60666079 0, 0, pbn_NETMOS9900_2s_115200 },
60676080
6081+ { PCIE_VENDOR_ID_ASIX, PCIE_DEVICE_ID_AX99100,
6082+ 0xA000, 0x1000,
6083+ 0, 0, pbn_b0_1_115200 },
6084+
60686085 /*
60696086 * Best Connectivity and Rosewill PCI Multi I/O cards
60706087 */
drivers/tty/serial/8250/8250_port.c+45−30
@@ -18,6 +18,7 @@ · 17 unmodified lines
1818 #include <linux/irq.h>
1919 #include <linux/console.h>
2020 #include <linux/gpio/consumer.h>
21+#include <linux/lockdep.h>
2122 #include <linux/sysrq.h>
2223 #include <linux/delay.h>
2324 #include <linux/platform_device.h>
@@ -488,7 +489,7 @@ serial_port_out_sync(struct uart_port *p, int offset, int value) · 464 unmodified lines
488489 /*
489490 * FIFO support.
490491 */
491−static void serial8250_clear_fifos(struct uart_8250_port *p)
492+void serial8250_clear_fifos(struct uart_8250_port *p)
492493 {
493494 if (p->capabilities & UART_CAP_FIFO) {
494495 serial_out(p, UART_FCR, UART_FCR_ENABLE_FIFO);
@@ -497,6 +498,7 @@ static void serial8250_clear_fifos(struct uart_8250_port *p) · 2 unmodified lines
497498 serial_out(p, UART_FCR, 0);
498499 }
499500 }
501+EXPORT_SYMBOL_NS_GPL(serial8250_clear_fifos, "SERIAL_8250");
500502
501503 static enum hrtimer_restart serial8250_em485_handle_start_tx(struct hrtimer *t);
502504 static enum hrtimer_restart serial8250_em485_handle_stop_tx(struct hrtimer *t);
@@ -1782,20 +1784,16 @@ static bool handle_rx_dma(struct uart_8250_port *up, unsigned int iir) · 1279 unmodified lines
17821784 }
17831785
17841786 /*
1785− * This handles the interrupt from one port.
1787+ * Context: port's lock must be held by the caller.
17861788 */
1787−int serial8250_handle_irq(struct uart_port *port, unsigned int iir)
1789+void serial8250_handle_irq_locked(struct uart_port *port, unsigned int iir)
17881790 {
17891791 struct uart_8250_port *up = up_to_u8250p(port);
17901792 struct tty_port *tport = &port->state->port;
17911793 bool skip_rx = false;
1792− unsigned long flags;
17931794 u16 status;
17941795
1795− if (iir & UART_IIR_NO_INT)
1796− return 0;
1797−
1798− uart_port_lock_irqsave(port, &flags);
1796+ lockdep_assert_held_once(&port->lock);
17991797
18001798 status = serial_lsr_in(up);
18011799
@@ -1828,8 +1826,19 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) · 26 unmodified lines
18281826 else if (!up->dma->tx_running)
18291827 __stop_tx(up);
18301828 }
1829+}
1830+EXPORT_SYMBOL_NS_GPL(serial8250_handle_irq_locked, "SERIAL_8250");
1831+
1832+/*
1833+ * This handles the interrupt from one port.
1834+ */
1835+int serial8250_handle_irq(struct uart_port *port, unsigned int iir)
1836+{
1837+ if (iir & UART_IIR_NO_INT)
1838+ return 0;
18311839
1832− uart_unlock_and_check_sysrq_irqrestore(port, flags);
1840+ guard(uart_port_lock_irqsave)(port);
1841+ serial8250_handle_irq_locked(port, iir);
18331842
18341843 return 1;
18351844 }
@@ -2147,8 +2156,7 @@ static void serial8250_THRE_test(struct uart_port *port) · 311 unmodified lines
21472156 if (up->port.flags & UPF_NO_THRE_TEST)
21482157 return;
21492158
2150− if (port->irqflags & IRQF_SHARED)
2151− disable_irq_nosync(port->irq);
2159+ disable_irq(port->irq);
21522160
21532161 /*
21542162 * Test for UARTs that do not reassert THRE when the transmitter is idle and the interrupt
@@ -2170,8 +2178,7 @@ static void serial8250_THRE_test(struct uart_port *port) · 15 unmodified lines
21702178 serial_port_out(port, UART_IER, 0);
21712179 }
21722180
2173− if (port->irqflags & IRQF_SHARED)
2174− enable_irq(port->irq);
2181+ enable_irq(port->irq);
21752182
21762183 /*
21772184 * If the interrupt is not reasserted, or we otherwise don't trust the iir, setup a timer to
@@ -2350,6 +2357,7 @@ static int serial8250_startup(struct uart_port *port) · 172 unmodified lines
23502357 void serial8250_do_shutdown(struct uart_port *port)
23512358 {
23522359 struct uart_8250_port *up = up_to_u8250p(port);
2360+ u32 lcr;
23532361
23542362 serial8250_rpm_get(up);
23552363 /*
@@ -2376,13 +2384,13 @@ void serial8250_do_shutdown(struct uart_port *port) · 20 unmodified lines
23762384 port->mctrl &= ~TIOCM_OUT2;
23772385
23782386 serial8250_set_mctrl(port, port->mctrl);
2387+
2388+ /* Disable break condition */
2389+ lcr = serial_port_in(port, UART_LCR);
2390+ lcr &= ~UART_LCR_SBC;
2391+ serial_port_out(port, UART_LCR, lcr);
23792392 }
23802393
2381− /*
2382− * Disable break condition and FIFOs
2383− */
2384− serial_port_out(port, UART_LCR,
2385− serial_port_in(port, UART_LCR) & ~UART_LCR_SBC);
23862394 serial8250_clear_fifos(up);
23872395
23882396 rsa_disable(up);
@@ -2392,6 +2400,12 @@ void serial8250_do_shutdown(struct uart_port *port) · 3 unmodified lines
23922400 * the IRQ chain.
23932401 */
23942402 serial_port_in(port, UART_RX);
2403+ /*
2404+ * LCR writes on DW UART can trigger late (unmaskable) IRQs.
2405+ * Handle them before releasing the handler.
2406+ */
2407+ synchronize_irq(port->irq);
2408+
23952409 serial8250_rpm_put(up);
23962410
23972411 up->ops->release_irq(up);
@@ -3185,6 +3199,17 @@ void serial8250_set_defaults(struct uart_8250_port *up) · 787 unmodified lines
31853199 }
31863200 EXPORT_SYMBOL_GPL(serial8250_set_defaults);
31873201
3202+void serial8250_fifo_wait_for_lsr_thre(struct uart_8250_port *up, unsigned int count)
3203+{
3204+ unsigned int i;
3205+
3206+ for (i = 0; i < count; i++) {
3207+ if (wait_for_lsr(up, UART_LSR_THRE))
3208+ return;
3209+ }
3210+}
3211+EXPORT_SYMBOL_NS_GPL(serial8250_fifo_wait_for_lsr_thre, "SERIAL_8250");
3212+
31883213 #ifdef CONFIG_SERIAL_8250_CONSOLE
31893214
31903215 static void serial8250_console_putchar(struct uart_port *port, unsigned char ch)
@@ -3226,16 +3251,6 @@ static void serial8250_console_restore(struct uart_8250_port *up) · 35 unmodified lines
32263251 serial8250_out_MCR(up, up->mcr | UART_MCR_DTR | UART_MCR_RTS);
32273252 }
32283253
3229−static void fifo_wait_for_lsr(struct uart_8250_port *up, unsigned int count)
3230−{
3231− unsigned int i;
3232−
3233− for (i = 0; i < count; i++) {
3234− if (wait_for_lsr(up, UART_LSR_THRE))
3235− return;
3236− }
3237−}
3238−
32393254 /*
32403255 * Print a string to the serial port using the device FIFO
32413256 *
@@ -3254,7 +3269,7 @@ static void serial8250_console_fifo_write(struct uart_8250_port *up, · 12 unmodified lines
32543269
32553270 while (s != end) {
32563271 /* Allow timeout for each byte of a possibly full FIFO */
3257− fifo_wait_for_lsr(up, fifosize);
3272+ serial8250_fifo_wait_for_lsr_thre(up, fifosize);
32583273
32593274 for (i = 0; i < fifosize && s != end; ++i) {
32603275 if (*s == '\n' && !cr_sent) {
@@ -3272,7 +3287,7 @@ static void serial8250_console_fifo_write(struct uart_8250_port *up, · 11 unmodified lines
32723287 * Allow timeout for each byte written since the caller will only wait
32733288 * for UART_LSR_BOTH_EMPTY using the timeout of a single character
32743289 */
3275− fifo_wait_for_lsr(up, tx_count);
3290+ serial8250_fifo_wait_for_lsr_thre(up, tx_count);
32763291 }
32773292
32783293 /*
drivers/tty/serial/serial_core.c+4−1
@@ -643,7 +643,10 @@ static unsigned int uart_write_room(struct tty_struct *tty) · 642 unmodified lines
643643 unsigned int ret;
644644
645645 port = uart_port_ref_lock(state, &flags);
646− ret = kfifo_avail(&state->port.xmit_fifo);
646+ if (!state->port.xmit_buf)
647+ ret = 0;
648+ else
649+ ret = kfifo_avail(&state->port.xmit_fifo);
647650 uart_port_unlock_deref(port, flags);
648651 return ret;
649652 }
drivers/tty/serial/uartlite.c+1−0
@@ -878,6 +878,7 @@ of_err: · 877 unmodified lines
878878 pm_runtime_use_autosuspend(&pdev->dev);
879879 pm_runtime_set_autosuspend_delay(&pdev->dev, UART_AUTOSUSPEND_TIMEOUT);
880880 pm_runtime_set_active(&pdev->dev);
881+ pm_runtime_get_noresume(&pdev->dev);
881882 pm_runtime_enable(&pdev->dev);
882883
883884 ret = ulite_assign(&pdev->dev, id, res->start, irq, pdata);
drivers/tty/vt/vt.c+8−0
@@ -1339,6 +1339,8 @@ struct vc_data *vc_deallocate(unsigned int currcons) · 1338 unmodified lines
13391339 kfree(vc->vc_saved_screen);
13401340 vc->vc_saved_screen = NULL;
13411341 }
1342+ vc_uniscr_free(vc->vc_saved_uni_lines);
1343+ vc->vc_saved_uni_lines = NULL;
13421344 }
13431345 return vc;
13441346 }
@@ -1884,6 +1886,8 @@ static void enter_alt_screen(struct vc_data *vc) · 539 unmodified lines
18841886 vc->vc_saved_screen = kmemdup((u16 *)vc->vc_origin, size, GFP_KERNEL);
18851887 if (vc->vc_saved_screen == NULL)
18861888 return;
1889+ vc->vc_saved_uni_lines = vc->vc_uni_lines;
1890+ vc->vc_uni_lines = NULL;
18871891 vc->vc_saved_rows = vc->vc_rows;
18881892 vc->vc_saved_cols = vc->vc_cols;
18891893 save_cur(vc);
@@ -1905,6 +1909,8 @@ static void leave_alt_screen(struct vc_data *vc) · 15 unmodified lines
19051909 dest = ((u16 *)vc->vc_origin) + r * vc->vc_cols;
19061910 memcpy(dest, src, 2 * cols);
19071911 }
1912+ vc_uniscr_set(vc, vc->vc_saved_uni_lines);
1913+ vc->vc_saved_uni_lines = NULL;
19081914 restore_cur(vc);
19091915 /* Update the entire screen */
19101916 if (con_should_update(vc))
@@ -2227,6 +2233,8 @@ static void reset_terminal(struct vc_data *vc, int do_clear) · 316 unmodified lines
22272233 if (vc->vc_saved_screen != NULL) {
22282234 kfree(vc->vc_saved_screen);
22292235 vc->vc_saved_screen = NULL;
2236+ vc_uniscr_free(vc->vc_saved_uni_lines);
2237+ vc->vc_saved_uni_lines = NULL;
22302238 vc->vc_saved_rows = 0;
22312239 vc->vc_saved_cols = 0;
22322240 }
fs/binfmt_elf_fdpic.c+6−0
@@ -595,6 +595,12 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm, · 594 unmodified lines
595595 #ifdef ELF_HWCAP2
596596 nitems++;
597597 #endif
598+#ifdef ELF_HWCAP3
599+ nitems++;
600+#endif
601+#ifdef ELF_HWCAP4
602+ nitems++;
603+#endif
598604
599605 csp = sp;
600606 sp -= nitems * 2 * sizeof(unsigned long);
fs/btrfs/backref.c+28−0
@@ -1393,6 +1393,13 @@ static int find_parent_nodes(struct btrfs_backref_walk_ctx *ctx, · 1392 unmodified lines
13931393 .indirect_missing_keys = PREFTREE_INIT
13941394 };
13951395
1396+ if (unlikely(!root)) {
1397+ btrfs_err(ctx->fs_info,
1398+ "missing extent root for extent at bytenr %llu",
1399+ ctx->bytenr);
1400+ return -EUCLEAN;
1401+ }
1402+
13961403 /* Roots ulist is not needed when using a sharedness check context. */
13971404 if (sc)
13981405 ASSERT(ctx->roots == NULL);
@@ -2204,6 +2211,13 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical, · 805 unmodified lines
22042211 struct btrfs_extent_item *ei;
22052212 struct btrfs_key key;
22062213
2214+ if (unlikely(!extent_root)) {
2215+ btrfs_err(fs_info,
2216+ "missing extent root for extent at bytenr %llu",
2217+ logical);
2218+ return -EUCLEAN;
2219+ }
2220+
22072221 key.objectid = logical;
22082222 if (btrfs_fs_incompat(fs_info, SKINNY_METADATA))
22092223 key.type = BTRFS_METADATA_ITEM_KEY;
@@ -2851,6 +2865,13 @@ int btrfs_backref_iter_start(struct btrfs_backref_iter *iter, u64 bytenr) · 641 unmodified lines
28512865 struct btrfs_key key;
28522866 int ret;
28532867
2868+ if (unlikely(!extent_root)) {
2869+ btrfs_err(fs_info,
2870+ "missing extent root for extent at bytenr %llu",
2871+ bytenr);
2872+ return -EUCLEAN;
2873+ }
2874+
28542875 key.objectid = bytenr;
28552876 key.type = BTRFS_METADATA_ITEM_KEY;
28562877 key.offset = (u64)-1;
@@ -2987,6 +3008,13 @@ int btrfs_backref_iter_next(struct btrfs_backref_iter *iter) · 130 unmodified lines
29873008
29883009 /* We're at keyed items, there is no inline item, go to the next one */
29893010 extent_root = btrfs_extent_root(iter->fs_info, iter->bytenr);
3011+ if (unlikely(!extent_root)) {
3012+ btrfs_err(iter->fs_info,
3013+ "missing extent root for extent at bytenr %llu",
3014+ iter->bytenr);
3015+ return -EUCLEAN;
3016+ }
3017+
29903018 ret = btrfs_next_item(extent_root, iter->path);
29913019 if (ret)
29923020 return ret;
fs/btrfs/block-group.c+36−0
@@ -739,6 +739,12 @@ static int load_extent_tree_free(struct btrfs_caching_control *caching_ctl) · 738 unmodified lines
739739
740740 last = max_t(u64, block_group->start, BTRFS_SUPER_INFO_OFFSET);
741741 extent_root = btrfs_extent_root(fs_info, last);
742+ if (unlikely(!extent_root)) {
743+ btrfs_err(fs_info,
744+ "missing extent root for block group at offset %llu",
745+ block_group->start);
746+ return -EUCLEAN;
747+ }
742748
743749 #ifdef CONFIG_BTRFS_DEBUG
744750 /*
@@ -1061,6 +1067,11 @@ static int remove_block_group_item(struct btrfs_trans_handle *trans, · 316 unmodified lines
10611067 int ret;
10621068
10631069 root = btrfs_block_group_root(fs_info);
1070+ if (unlikely(!root)) {
1071+ btrfs_err(fs_info, "missing block group root");
1072+ return -EUCLEAN;
1073+ }
1074+
10641075 key.objectid = block_group->start;
10651076 key.type = BTRFS_BLOCK_GROUP_ITEM_KEY;
10661077 key.offset = block_group->length;
@@ -1349,6 +1360,11 @@ struct btrfs_trans_handle *btrfs_start_trans_remove_block_group( · 282 unmodified lines
13491360 struct btrfs_chunk_map *map;
13501361 unsigned int num_items;
13511362
1363+ if (unlikely(!root)) {
1364+ btrfs_err(fs_info, "missing block group root");
1365+ return ERR_PTR(-EUCLEAN);
1366+ }
1367+
13521368 map = btrfs_find_chunk_map(fs_info, chunk_offset, 1);
13531369 ASSERT(map != NULL);
13541370 ASSERT(map->start == chunk_offset);
@@ -2140,6 +2156,11 @@ static int find_first_block_group(struct btrfs_fs_info *fs_info, · 785 unmodified lines
21402156 int ret;
21412157 struct btrfs_key found_key;
21422158
2159+ if (unlikely(!root)) {
2160+ btrfs_err(fs_info, "missing block group root");
2161+ return -EUCLEAN;
2162+ }
2163+
21432164 btrfs_for_each_slot(root, key, &found_key, path, ret) {
21442165 if (found_key.objectid >= key->objectid &&
21452166 found_key.type == BTRFS_BLOCK_GROUP_ITEM_KEY) {
@@ -2713,6 +2734,11 @@ static int insert_block_group_item(struct btrfs_trans_handle *trans, · 567 unmodified lines
27132734 size_t size;
27142735 int ret;
27152736
2737+ if (unlikely(!root)) {
2738+ btrfs_err(fs_info, "missing block group root");
2739+ return -EUCLEAN;
2740+ }
2741+
27162742 spin_lock(&block_group->lock);
27172743 btrfs_set_stack_block_group_v2_used(&bgi, block_group->used);
27182744 btrfs_set_stack_block_group_v2_chunk_objectid(&bgi, block_group->global_root_id);
@@ -3048,6 +3074,11 @@ int btrfs_inc_block_group_ro(struct btrfs_block_group *cache, · 329 unmodified lines
30483074 int ret;
30493075 bool dirty_bg_running;
30503076
3077+ if (unlikely(!root)) {
3078+ btrfs_err(fs_info, "missing block group root");
3079+ return -EUCLEAN;
3080+ }
3081+
30513082 /*
30523083 * This can only happen when we are doing read-only scrub on read-only
30533084 * mount.
@@ -3192,6 +3223,11 @@ static int update_block_group_item(struct btrfs_trans_handle *trans, · 138 unmodified lines
31923223 u64 used, remap_bytes;
31933224 u32 identity_remap_count;
31943225
3226+ if (unlikely(!root)) {
3227+ btrfs_err(fs_info, "missing block group root");
3228+ return -EUCLEAN;
3229+ }
3230+
31953231 /*
31963232 * Block group items update can be triggered out of commit transaction
31973233 * critical section, thus we need a consistent view of used bytes.
fs/btrfs/compression.c+8−3
@@ -320,10 +320,16 @@ void btrfs_submit_compressed_write(struct btrfs_ordered_extent *ordered, · 319 unmodified lines
320320
321321 ASSERT(IS_ALIGNED(ordered->file_offset, fs_info->sectorsize));
322322 ASSERT(IS_ALIGNED(ordered->num_bytes, fs_info->sectorsize));
323− ASSERT(cb->writeback);
323+ /*
324+ * This flag determines if we should clear the writeback flag from the
325+ * page cache. But this function is only utilized by encoded writes, it
326+ * never goes through the page cache.
327+ */
328+ ASSERT(!cb->writeback);
324329
325330 cb->start = ordered->file_offset;
326331 cb->len = ordered->num_bytes;
332+ ASSERT(cb->bbio.bio.bi_iter.bi_size == ordered->disk_num_bytes);
327333 cb->compressed_len = ordered->disk_num_bytes;
328334 cb->bbio.bio.bi_iter.bi_sector = ordered->disk_bytenr >> SECTOR_SHIFT;
329335 cb->bbio.ordered = ordered;
@@ -345,8 +351,7 @@ struct compressed_bio *btrfs_alloc_compressed_write(struct btrfs_inode *inode, · 15 unmodified lines
345351 cb = alloc_compressed_bio(inode, start, REQ_OP_WRITE, end_bbio_compressed_write);
346352 cb->start = start;
347353 cb->len = len;
348− cb->writeback = true;
349−
354+ cb->writeback = false;
350355 return cb;
351356 }
352357
fs/btrfs/disk-io.c+17−3
@@ -1591,7 +1591,7 @@ static int find_newest_super_backup(struct btrfs_fs_info *info) · 1590 unmodified lines
15911591 * this will bump the backup pointer by one when it is
15921592 * done
15931593 */
1594−static void backup_super_roots(struct btrfs_fs_info *info)
1594+static int backup_super_roots(struct btrfs_fs_info *info)
15951595 {
15961596 const int next_backup = info->backup_root_index;
15971597 struct btrfs_root_backup *root_backup;
@@ -1623,6 +1623,15 @@ static void backup_super_roots(struct btrfs_fs_info *info) · 25 unmodified lines
16231623 struct btrfs_root *extent_root = btrfs_extent_root(info, 0);
16241624 struct btrfs_root *csum_root = btrfs_csum_root(info, 0);
16251625
1626+ if (unlikely(!extent_root)) {
1627+ btrfs_err(info, "missing extent root for extent at bytenr 0");
1628+ return -EUCLEAN;
1629+ }
1630+ if (unlikely(!csum_root)) {
1631+ btrfs_err(info, "missing csum root for extent at bytenr 0");
1632+ return -EUCLEAN;
1633+ }
1634+
16261635 btrfs_set_backup_extent_root(root_backup,
16271636 extent_root->node->start);
16281637 btrfs_set_backup_extent_root_gen(root_backup,
@@ -1670,6 +1679,8 @@ static void backup_super_roots(struct btrfs_fs_info *info) · 41 unmodified lines
16701679 memcpy(&info->super_copy->super_roots,
16711680 &info->super_for_commit->super_roots,
16721681 sizeof(*root_backup) * BTRFS_NUM_BACKUP_ROOTS);
1682+
1683+ return 0;
16731684 }
16741685
16751686 /*
@@ -4051,8 +4062,11 @@ int write_all_supers(struct btrfs_fs_info *fs_info, int max_mirrors) · 2375 unmodified lines
40514062 * not from fsync where the tree roots in fs_info have not
40524063 * been consistent on disk.
40534064 */
4054− if (max_mirrors == 0)
4055− backup_super_roots(fs_info);
4065+ if (max_mirrors == 0) {
4066+ ret = backup_super_roots(fs_info);
4067+ if (ret < 0)
4068+ return ret;
4069+ }
40564070
40574071 sb = fs_info->super_for_commit;
40584072 dev_item = &sb->dev_item;
fs/btrfs/extent-tree.c+93−5
@@ -75,6 +75,12 @@ int btrfs_lookup_data_extent(struct btrfs_fs_info *fs_info, u64 start, u64 len) · 74 unmodified lines
7575 struct btrfs_key key;
7676 BTRFS_PATH_AUTO_FREE(path);
7777
78+ if (unlikely(!root)) {
79+ btrfs_err(fs_info,
80+ "missing extent root for extent at bytenr %llu", start);
81+ return -EUCLEAN;
82+ }
83+
7884 path = btrfs_alloc_path();
7985 if (!path)
8086 return -ENOMEM;
@@ -131,6 +137,12 @@ search_again: · 50 unmodified lines
131137 key.offset = offset;
132138
133139 extent_root = btrfs_extent_root(fs_info, bytenr);
140+ if (unlikely(!extent_root)) {
141+ btrfs_err(fs_info,
142+ "missing extent root for extent at bytenr %llu", bytenr);
143+ return -EUCLEAN;
144+ }
145+
134146 ret = btrfs_search_slot(NULL, extent_root, &key, path, 0, 0);
135147 if (ret < 0)
136148 return ret;
@@ -436,6 +448,12 @@ static noinline int lookup_extent_data_ref(struct btrfs_trans_handle *trans, · 299 unmodified lines
436448 int recow;
437449 int ret;
438450
451+ if (unlikely(!root)) {
452+ btrfs_err(trans->fs_info,
453+ "missing extent root for extent at bytenr %llu", bytenr);
454+ return -EUCLEAN;
455+ }
456+
439457 key.objectid = bytenr;
440458 if (parent) {
441459 key.type = BTRFS_SHARED_DATA_REF_KEY;
@@ -510,6 +528,12 @@ static noinline int insert_extent_data_ref(struct btrfs_trans_handle *trans, · 68 unmodified lines
510528 u32 num_refs;
511529 int ret;
512530
531+ if (unlikely(!root)) {
532+ btrfs_err(trans->fs_info,
533+ "missing extent root for extent at bytenr %llu", bytenr);
534+ return -EUCLEAN;
535+ }
536+
513537 key.objectid = bytenr;
514538 if (node->parent) {
515539 key.type = BTRFS_SHARED_DATA_REF_KEY;
@@ -668,6 +692,12 @@ static noinline int lookup_tree_block_ref(struct btrfs_trans_handle *trans, · 152 unmodified lines
668692 struct btrfs_key key;
669693 int ret;
670694
695+ if (unlikely(!root)) {
696+ btrfs_err(trans->fs_info,
697+ "missing extent root for extent at bytenr %llu", bytenr);
698+ return -EUCLEAN;
699+ }
700+
671701 key.objectid = bytenr;
672702 if (parent) {
673703 key.type = BTRFS_SHARED_BLOCK_REF_KEY;
@@ -692,6 +722,12 @@ static noinline int insert_tree_block_ref(struct btrfs_trans_handle *trans, · 18 unmodified lines
692722 struct btrfs_key key;
693723 int ret;
694724
725+ if (unlikely(!root)) {
726+ btrfs_err(trans->fs_info,
727+ "missing extent root for extent at bytenr %llu", bytenr);
728+ return -EUCLEAN;
729+ }
730+
695731 key.objectid = bytenr;
696732 if (node->parent) {
697733 key.type = BTRFS_SHARED_BLOCK_REF_KEY;
@@ -782,6 +818,12 @@ int lookup_inline_extent_backref(struct btrfs_trans_handle *trans, · 84 unmodified lines
782818 bool skinny_metadata = btrfs_fs_incompat(fs_info, SKINNY_METADATA);
783819 int needed;
784820
821+ if (unlikely(!root)) {
822+ btrfs_err(fs_info,
823+ "missing extent root for extent at bytenr %llu", bytenr);
824+ return -EUCLEAN;
825+ }
826+
785827 key.objectid = bytenr;
786828 key.type = BTRFS_EXTENT_ITEM_KEY;
787829 key.offset = num_bytes;
@@ -1680,6 +1722,12 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans, · 892 unmodified lines
16801722 }
16811723
16821724 root = btrfs_extent_root(fs_info, key.objectid);
1725+ if (unlikely(!root)) {
1726+ btrfs_err(fs_info,
1727+ "missing extent root for extent at bytenr %llu",
1728+ key.objectid);
1729+ return -EUCLEAN;
1730+ }
16831731 again:
16841732 ret = btrfs_search_slot(trans, root, &key, path, 0, 1);
16851733 if (ret < 0) {
@@ -1926,8 +1974,15 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans, · 240 unmodified lines
19261974 struct btrfs_root *csum_root;
19271975
19281976 csum_root = btrfs_csum_root(fs_info, head->bytenr);
1929− ret = btrfs_del_csums(trans, csum_root, head->bytenr,
1930− head->num_bytes);
1977+ if (unlikely(!csum_root)) {
1978+ btrfs_err(fs_info,
1979+ "missing csum root for extent at bytenr %llu",
1980+ head->bytenr);
1981+ ret = -EUCLEAN;
1982+ } else {
1983+ ret = btrfs_del_csums(trans, csum_root, head->bytenr,
1984+ head->num_bytes);
1985+ }
19311986 }
19321987 }
19331988
@@ -2379,6 +2434,12 @@ static noinline int check_committed_ref(struct btrfs_inode *inode, · 445 unmodified lines
23792434 int type;
23802435 int ret;
23812436
2437+ if (unlikely(!extent_root)) {
2438+ btrfs_err(fs_info,
2439+ "missing extent root for extent at bytenr %llu", bytenr);
2440+ return -EUCLEAN;
2441+ }
2442+
23822443 key.objectid = bytenr;
23832444 key.type = BTRFS_EXTENT_ITEM_KEY;
23842445 key.offset = (u64)-1;
@@ -3093,6 +3154,15 @@ static int do_free_extent_accounting(struct btrfs_trans_handle *trans, · 708 unmodified lines
30933154 struct btrfs_root *csum_root;
30943155
30953156 csum_root = btrfs_csum_root(trans->fs_info, bytenr);
3157+ if (unlikely(!csum_root)) {
3158+ ret = -EUCLEAN;
3159+ btrfs_abort_transaction(trans, ret);
3160+ btrfs_err(trans->fs_info,
3161+ "missing csum root for extent at bytenr %llu",
3162+ bytenr);
3163+ return ret;
3164+ }
3165+
30963166 ret = btrfs_del_csums(trans, csum_root, bytenr, num_bytes);
30973167 if (unlikely(ret)) {
30983168 btrfs_abort_transaction(trans, ret);
@@ -3222,7 +3292,11 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans, · 123 unmodified lines
32223292 u64 delayed_ref_root = href->owning_root;
32233293
32243294 extent_root = btrfs_extent_root(info, bytenr);
3225− ASSERT(extent_root);
3295+ if (unlikely(!extent_root)) {
3296+ btrfs_err(info,
3297+ "missing extent root for extent at bytenr %llu", bytenr);
3298+ return -EUCLEAN;
3299+ }
32263300
32273301 path = btrfs_alloc_path();
32283302 if (!path)
@@ -4939,11 +5013,18 @@ static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans, · 1710 unmodified lines
49395013 size += btrfs_extent_inline_ref_size(BTRFS_EXTENT_OWNER_REF_KEY);
49405014 size += btrfs_extent_inline_ref_size(type);
49415015
5016+ extent_root = btrfs_extent_root(fs_info, ins->objectid);
5017+ if (unlikely(!extent_root)) {
5018+ btrfs_err(fs_info,
5019+ "missing extent root for extent at bytenr %llu",
5020+ ins->objectid);
5021+ return -EUCLEAN;
5022+ }
5023+
49425024 path = btrfs_alloc_path();
49435025 if (!path)
49445026 return -ENOMEM;
49455027
4946− extent_root = btrfs_extent_root(fs_info, ins->objectid);
49475028 ret = btrfs_insert_empty_item(trans, extent_root, path, ins, size);
49485029 if (ret) {
49495030 btrfs_free_path(path);
@@ -5019,11 +5100,18 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, · 69 unmodified lines
50195100 size += sizeof(*block_info);
50205101 }
50215102
5103+ extent_root = btrfs_extent_root(fs_info, extent_key.objectid);
5104+ if (unlikely(!extent_root)) {
5105+ btrfs_err(fs_info,
5106+ "missing extent root for extent at bytenr %llu",
5107+ extent_key.objectid);
5108+ return -EUCLEAN;
5109+ }
5110+
50225111 path = btrfs_alloc_path();
50235112 if (!path)
50245113 return -ENOMEM;
50255114
5026− extent_root = btrfs_extent_root(fs_info, extent_key.objectid);
50275115 ret = btrfs_insert_empty_item(trans, extent_root, path, &extent_key,
50285116 size);
50295117 if (ret) {
fs/btrfs/file-item.c+7−0
@@ -308,6 +308,13 @@ static int search_csum_tree(struct btrfs_fs_info *fs_info, · 307 unmodified lines
308308 /* Current item doesn't contain the desired range, search again */
309309 btrfs_release_path(path);
310310 csum_root = btrfs_csum_root(fs_info, disk_bytenr);
311+ if (unlikely(!csum_root)) {
312+ btrfs_err(fs_info,
313+ "missing csum root for extent at bytenr %llu",
314+ disk_bytenr);
315+ return -EUCLEAN;
316+ }
317+
311318 item = btrfs_lookup_csum(NULL, csum_root, path, disk_bytenr, 0);
312319 if (IS_ERR(item)) {
313320 ret = PTR_ERR(item);
fs/btrfs/free-space-tree.c+8−1
@@ -1073,6 +1073,14 @@ static int populate_free_space_tree(struct btrfs_trans_handle *trans, · 1072 unmodified lines
10731073 if (ret)
10741074 return ret;
10751075
1076+ extent_root = btrfs_extent_root(trans->fs_info, block_group->start);
1077+ if (unlikely(!extent_root)) {
1078+ btrfs_err(trans->fs_info,
1079+ "missing extent root for block group at offset %llu",
1080+ block_group->start);
1081+ return -EUCLEAN;
1082+ }
1083+
10761084 mutex_lock(&block_group->free_space_lock);
10771085
10781086 /*
@@ -1086,7 +1094,6 @@ static int populate_free_space_tree(struct btrfs_trans_handle *trans, · 7 unmodified lines
10861094 key.type = BTRFS_EXTENT_ITEM_KEY;
10871095 key.offset = 0;
10881096
1089− extent_root = btrfs_extent_root(trans->fs_info, key.objectid);
10901097 ret = btrfs_search_slot_for_read(extent_root, &key, path, 1, 0);
10911098 if (ret < 0)
10921099 goto out_locked;
fs/btrfs/inode.c+20−5
@@ -2012,6 +2012,13 @@ static int can_nocow_file_extent(struct btrfs_path *path, · 2011 unmodified lines
20122012 */
20132013
20142014 csum_root = btrfs_csum_root(root->fs_info, io_start);
2015+ if (unlikely(!csum_root)) {
2016+ btrfs_err(root->fs_info,
2017+ "missing csum root for extent at bytenr %llu", io_start);
2018+ ret = -EUCLEAN;
2019+ goto out;
2020+ }
2021+
20152022 ret = btrfs_lookup_csums_list(csum_root, io_start,
20162023 io_start + args->file_extent.num_bytes - 1,
20172024 NULL, nowait);
@@ -2749,10 +2756,17 @@ static int add_pending_csums(struct btrfs_trans_handle *trans, · 731 unmodified lines
27492756 int ret;
27502757
27512758 list_for_each_entry(sum, list, list) {
2752− trans->adding_csums = true;
2753− if (!csum_root)
2759+ if (!csum_root) {
27542760 csum_root = btrfs_csum_root(trans->fs_info,
27552761 sum->logical);
2762+ if (unlikely(!csum_root)) {
2763+ btrfs_err(trans->fs_info,
2764+ "missing csum root for extent at bytenr %llu",
2765+ sum->logical);
2766+ return -EUCLEAN;
2767+ }
2768+ }
2769+ trans->adding_csums = true;
27562770 ret = btrfs_csum_file_blocks(trans, csum_root, sum);
27572771 trans->adding_csums = false;
27582772 if (ret)
@@ -9874,6 +9888,7 @@ ssize_t btrfs_do_encoded_write(struct kiocb *iocb, struct iov_iter *from, · 7115 unmodified lines
98749888 int compression;
98759889 size_t orig_count;
98769890 const u32 min_folio_size = btrfs_min_folio_size(fs_info);
9891+ const u32 blocksize = fs_info->sectorsize;
98779892 u64 start, end;
98789893 u64 num_bytes, ram_bytes, disk_num_bytes;
98799894 struct btrfs_key ins;
@@ -9984,9 +9999,9 @@ ssize_t btrfs_do_encoded_write(struct kiocb *iocb, struct iov_iter *from, · 104 unmodified lines
99849999 ret = -EFAULT;
998510000 goto out_cb;
998610001 }
9987− if (bytes < min_folio_size)
9988− folio_zero_range(folio, bytes, min_folio_size - bytes);
9989− ret = bio_add_folio(&cb->bbio.bio, folio, folio_size(folio), 0);
10002+ if (!IS_ALIGNED(bytes, blocksize))
10003+ folio_zero_range(folio, bytes, round_up(bytes, blocksize) - bytes);
10004+ ret = bio_add_folio(&cb->bbio.bio, folio, round_up(bytes, blocksize), 0);
999010005 if (unlikely(!ret)) {
999110006 folio_put(folio);
999210007 ret = -EINVAL;
fs/btrfs/ioctl.c+9−3
@@ -3617,7 +3617,8 @@ static long btrfs_ioctl_qgroup_assign(struct file *file, void __user *arg) · 3616 unmodified lines
36173617 }
36183618 }
36193619
3620− trans = btrfs_join_transaction(root);
3620+ /* 2 BTRFS_QGROUP_RELATION_KEY items. */
3621+ trans = btrfs_start_transaction(root, 2);
36213622 if (IS_ERR(trans)) {
36223623 ret = PTR_ERR(trans);
36233624 goto out;
@@ -3689,7 +3690,11 @@ static long btrfs_ioctl_qgroup_create(struct file *file, void __user *arg) · 65 unmodified lines
36893690 goto out;
36903691 }
36913692
3692− trans = btrfs_join_transaction(root);
3693+ /*
3694+ * 1 BTRFS_QGROUP_INFO_KEY item.
3695+ * 1 BTRFS_QGROUP_LIMIT_KEY item.
3696+ */
3697+ trans = btrfs_start_transaction(root, 2);
36933698 if (IS_ERR(trans)) {
36943699 ret = PTR_ERR(trans);
36953700 goto out;
@@ -3738,7 +3743,8 @@ static long btrfs_ioctl_qgroup_limit(struct file *file, void __user *arg) · 42 unmodified lines
37383743 goto drop_write;
37393744 }
37403745
3741− trans = btrfs_join_transaction(root);
3746+ /* 1 BTRFS_QGROUP_LIMIT_KEY item. */
3747+ trans = btrfs_start_transaction(root, 1);
37423748 if (IS_ERR(trans)) {
37433749 ret = PTR_ERR(trans);
37443750 goto out;
fs/btrfs/lzo.c+2−2
@@ -429,7 +429,7 @@ static void copy_compressed_segment(struct compressed_bio *cb, · 428 unmodified lines
429429 int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb)
430430 {
431431 struct workspace *workspace = list_entry(ws, struct workspace, list);
432− const struct btrfs_fs_info *fs_info = cb->bbio.inode->root->fs_info;
432+ struct btrfs_fs_info *fs_info = cb->bbio.inode->root->fs_info;
433433 const u32 sectorsize = fs_info->sectorsize;
434434 struct folio_iter fi;
435435 char *kaddr;
@@ -447,7 +447,7 @@ int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb) · 11 unmodified lines
447447 /* There must be a compressed folio and matches the sectorsize. */
448448 if (unlikely(!fi.folio))
449449 return -EINVAL;
450− ASSERT(folio_size(fi.folio) == sectorsize);
450+ ASSERT(folio_size(fi.folio) == btrfs_min_folio_size(fs_info));
451451 kaddr = kmap_local_folio(fi.folio, 0);
452452 len_in = read_compress_length(kaddr);
453453 kunmap_local(kaddr);
fs/btrfs/qgroup.c+8−0
@@ -3739,6 +3739,14 @@ static int qgroup_rescan_leaf(struct btrfs_trans_handle *trans, · 3738 unmodified lines
37393739 mutex_lock(&fs_info->qgroup_rescan_lock);
37403740 extent_root = btrfs_extent_root(fs_info,
37413741 fs_info->qgroup_rescan_progress.objectid);
3742+ if (unlikely(!extent_root)) {
3743+ btrfs_err(fs_info,
3744+ "missing extent root for extent at bytenr %llu",
3745+ fs_info->qgroup_rescan_progress.objectid);
3746+ mutex_unlock(&fs_info->qgroup_rescan_lock);
3747+ return -EUCLEAN;
3748+ }
3749+
37423750 ret = btrfs_search_slot_for_read(extent_root,
37433751 &fs_info->qgroup_rescan_progress,
37443752 path, 1, 0);
fs/btrfs/raid56.c+10−2
@@ -2297,8 +2297,7 @@ void raid56_parity_recover(struct bio *bio, struct btrfs_io_context *bioc, · 2296 unmodified lines
22972297 static void fill_data_csums(struct btrfs_raid_bio *rbio)
22982298 {
22992299 struct btrfs_fs_info *fs_info = rbio->bioc->fs_info;
2300− struct btrfs_root *csum_root = btrfs_csum_root(fs_info,
2301− rbio->bioc->full_stripe_logical);
2300+ struct btrfs_root *csum_root;
23022301 const u64 start = rbio->bioc->full_stripe_logical;
23032302 const u32 len = (rbio->nr_data * rbio->stripe_nsectors) <<
23042303 fs_info->sectorsize_bits;
@@ -2331,6 +2330,15 @@ static void fill_data_csums(struct btrfs_raid_bio *rbio) · 26 unmodified lines
23312330 goto error;
23322331 }
23332332
2333+ csum_root = btrfs_csum_root(fs_info, rbio->bioc->full_stripe_logical);
2334+ if (unlikely(!csum_root)) {
2335+ btrfs_err(fs_info,
2336+ "missing csum root for extent at bytenr %llu",
2337+ rbio->bioc->full_stripe_logical);
2338+ ret = -EUCLEAN;
2339+ goto error;
2340+ }
2341+
23342342 ret = btrfs_lookup_csums_bitmap(csum_root, NULL, start, start + len - 1,
23352343 rbio->csum_buf, rbio->csum_bitmap);
23362344 if (ret < 0)
fs/btrfs/relocation.c+32−7
@@ -4185,6 +4185,8 @@ static int move_existing_remap(struct btrfs_fs_info *fs_info, · 4184 unmodified lines
41854185 dest_addr = ins.objectid;
41864186 dest_length = ins.offset;
41874187
4188+ dest_bg = btrfs_lookup_block_group(fs_info, dest_addr);
4189+
41884190 if (!is_data && !IS_ALIGNED(dest_length, fs_info->nodesize)) {
41894191 u64 new_length = ALIGN_DOWN(dest_length, fs_info->nodesize);
41904192
@@ -4295,15 +4297,12 @@ static int move_existing_remap(struct btrfs_fs_info *fs_info, · 104 unmodified lines
42954297 if (unlikely(ret))
42964298 goto end;
42974299
4298− dest_bg = btrfs_lookup_block_group(fs_info, dest_addr);
4299−
43004300 adjust_block_group_remap_bytes(trans, dest_bg, dest_length);
43014301
43024302 mutex_lock(&dest_bg->free_space_lock);
43034303 bg_needs_free_space = test_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE,
43044304 &dest_bg->runtime_flags);
43054305 mutex_unlock(&dest_bg->free_space_lock);
4306− btrfs_put_block_group(dest_bg);
43074306
43084307 if (bg_needs_free_space) {
43094308 ret = btrfs_add_block_group_free_space(trans, dest_bg);
@@ -4333,13 +4332,13 @@ end: · 23 unmodified lines
43334332 btrfs_end_transaction(trans);
43344333 }
43354334 } else {
4336− dest_bg = btrfs_lookup_block_group(fs_info, dest_addr);
43374335 btrfs_free_reserved_bytes(dest_bg, dest_length, 0);
4338− btrfs_put_block_group(dest_bg);
43394336
43404337 ret = btrfs_commit_transaction(trans);
43414338 }
43424339
4340+ btrfs_put_block_group(dest_bg);
4341+
43434342 return ret;
43444343 }
43454344
@@ -4954,6 +4953,12 @@ static int do_remap_reloc_trans(struct btrfs_fs_info *fs_info, · 608 unmodified lines
49544953 struct btrfs_space_info *sinfo = src_bg->space_info;
49554954
49564955 extent_root = btrfs_extent_root(fs_info, src_bg->start);
4956+ if (unlikely(!extent_root)) {
4957+ btrfs_err(fs_info,
4958+ "missing extent root for block group at offset %llu",
4959+ src_bg->start);
4960+ return -EUCLEAN;
4961+ }
49574962
49584963 trans = btrfs_start_transaction(extent_root, 0);
49594964 if (IS_ERR(trans))
@@ -5306,6 +5311,13 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start, · 346 unmodified lines
53065311 int ret;
53075312 bool bg_is_ro = false;
53085313
5314+ if (unlikely(!extent_root)) {
5315+ btrfs_err(fs_info,
5316+ "missing extent root for block group at offset %llu",
5317+ group_start);
5318+ return -EUCLEAN;
5319+ }
5320+
53095321 /*
53105322 * This only gets set if we had a half-deleted snapshot on mount. We
53115323 * cannot allow relocation to start while we're still trying to clean up
@@ -5536,12 +5548,17 @@ int btrfs_recover_relocation(struct btrfs_fs_info *fs_info) · 224 unmodified lines
55365548 goto out;
55375549 }
55385550
5551+ rc->extent_root = btrfs_extent_root(fs_info, 0);
5552+ if (unlikely(!rc->extent_root)) {
5553+ btrfs_err(fs_info, "missing extent root for extent at bytenr 0");
5554+ ret = -EUCLEAN;
5555+ goto out;
5556+ }
5557+
55395558 ret = reloc_chunk_start(fs_info);
55405559 if (ret < 0)
55415560 goto out_end;
55425561
5543− rc->extent_root = btrfs_extent_root(fs_info, 0);
5544−
55455562 set_reloc_control(rc);
55465563
55475564 trans = btrfs_join_transaction(rc->extent_root);
@@ -5636,6 +5653,14 @@ int btrfs_reloc_clone_csums(struct btrfs_ordered_extent *ordered) · 88 unmodified lines
56365653 LIST_HEAD(list);
56375654 int ret;
56385655
5656+ if (unlikely(!csum_root)) {
5657+ btrfs_mark_ordered_extent_error(ordered);
5658+ btrfs_err(fs_info,
5659+ "missing csum root for extent at bytenr %llu",
5660+ disk_bytenr);
5661+ return -EUCLEAN;
5662+ }
5663+
56395664 ret = btrfs_lookup_csums_list(csum_root, disk_bytenr,
56405665 disk_bytenr + ordered->num_bytes - 1,
56415666 &list, false);
fs/btrfs/tree-checker.c+18−1
@@ -1284,10 +1284,27 @@ static int check_root_item(struct extent_buffer *leaf, struct btrfs_key *key, · 1283 unmodified lines
12841284 }
12851285 if (unlikely(btrfs_root_drop_level(&ri) >= BTRFS_MAX_LEVEL)) {
12861286 generic_err(leaf, slot,
1287− "invalid root level, have %u expect [0, %u]",
1287+ "invalid root drop_level, have %u expect [0, %u]",
12881288 btrfs_root_drop_level(&ri), BTRFS_MAX_LEVEL - 1);
12891289 return -EUCLEAN;
12901290 }
1291+ /*
1292+ * If drop_progress.objectid is non-zero, a btrfs_drop_snapshot() was
1293+ * interrupted and the resume point was recorded in drop_progress and
1294+ * drop_level. In that case drop_level must be >= 1: level 0 is the
1295+ * leaf level and drop_snapshot never saves a checkpoint there (it
1296+ * only records checkpoints at internal node levels in DROP_REFERENCE
1297+ * stage). A zero drop_level combined with a non-zero drop_progress
1298+ * objectid indicates on-disk corruption and would cause a BUG_ON in
1299+ * merge_reloc_root() and btrfs_drop_snapshot() at mount time.
1300+ */
1301+ if (unlikely(btrfs_disk_key_objectid(&ri.drop_progress) != 0 &&
1302+ btrfs_root_drop_level(&ri) == 0)) {
1303+ generic_err(leaf, slot,
1304+ "invalid root drop_level 0 with non-zero drop_progress objectid %llu",
1305+ btrfs_disk_key_objectid(&ri.drop_progress));
1306+ return -EUCLEAN;
1307+ }
12911308
12921309 /* Flags check */
12931310 if (unlikely(btrfs_root_flags(&ri) & ~valid_root_flags)) {
fs/btrfs/tree-log.c+27−0
@@ -984,6 +984,13 @@ static noinline int replay_one_extent(struct walk_control *wc) · 983 unmodified lines
984984
985985 sums = list_first_entry(&ordered_sums, struct btrfs_ordered_sum, list);
986986 csum_root = btrfs_csum_root(fs_info, sums->logical);
987+ if (unlikely(!csum_root)) {
988+ btrfs_err(fs_info,
989+ "missing csum root for extent at bytenr %llu",
990+ sums->logical);
991+ ret = -EUCLEAN;
992+ }
993+
987994 if (!ret) {
988995 ret = btrfs_del_csums(trans, csum_root, sums->logical,
989996 sums->len);
@@ -4890,6 +4897,13 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, · 3900 unmodified lines
48904897 }
48914898
48924899 csum_root = btrfs_csum_root(trans->fs_info, disk_bytenr);
4900+ if (unlikely(!csum_root)) {
4901+ btrfs_err(trans->fs_info,
4902+ "missing csum root for extent at bytenr %llu",
4903+ disk_bytenr);
4904+ return -EUCLEAN;
4905+ }
4906+
48934907 disk_bytenr += extent_offset;
48944908 ret = btrfs_lookup_csums_list(csum_root, disk_bytenr,
48954909 disk_bytenr + extent_num_bytes - 1,
@@ -5086,6 +5100,13 @@ static int log_extent_csums(struct btrfs_trans_handle *trans, · 190 unmodified lines
50865100 /* block start is already adjusted for the file extent offset. */
50875101 block_start = btrfs_extent_map_block_start(em);
50885102 csum_root = btrfs_csum_root(trans->fs_info, block_start);
5103+ if (unlikely(!csum_root)) {
5104+ btrfs_err(trans->fs_info,
5105+ "missing csum root for extent at bytenr %llu",
5106+ block_start);
5107+ return -EUCLEAN;
5108+ }
5109+
50895110 ret = btrfs_lookup_csums_list(csum_root, block_start + csum_offset,
50905111 block_start + csum_offset + csum_len - 1,
50915112 &ordered_sums, false);
@@ -6195,6 +6216,7 @@ static int log_conflicting_inodes(struct btrfs_trans_handle *trans, · 1103 unmodified lines
61956216 struct btrfs_root *root,
61966217 struct btrfs_log_ctx *ctx)
61976218 {
6219+ const bool orig_log_new_dentries = ctx->log_new_dentries;
61986220 int ret = 0;
61996221
62006222 /*
@@ -6256,7 +6278,11 @@ static int log_conflicting_inodes(struct btrfs_trans_handle *trans, · 55 unmodified lines
62566278 * dir index key range logged for the directory. So we
62576279 * must make sure the deletion is recorded.
62586280 */
6281+ ctx->log_new_dentries = false;
62596282 ret = btrfs_log_inode(trans, inode, LOG_INODE_ALL, ctx);
6283+ if (!ret && ctx->log_new_dentries)
6284+ ret = log_new_dir_dentries(trans, inode, ctx);
6285+
62606286 btrfs_add_delayed_iput(inode);
62616287 if (ret)
62626288 break;
@@ -6291,6 +6317,7 @@ static int log_conflicting_inodes(struct btrfs_trans_handle *trans, · 28 unmodified lines
62916317 break;
62926318 }
62936319
6320+ ctx->log_new_dentries = orig_log_new_dentries;
62946321 ctx->logging_conflict_inodes = false;
62956322 if (ret)
62966323 free_conflicting_inodes(ctx);
fs/btrfs/volumes.c+18−9
@@ -3587,7 +3587,7 @@ int btrfs_relocate_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset, bool v · 3586 unmodified lines
35873587
35883588 /* step one, relocate all the extents inside this chunk */
35893589 btrfs_scrub_pause(fs_info);
3590− ret = btrfs_relocate_block_group(fs_info, chunk_offset, true);
3590+ ret = btrfs_relocate_block_group(fs_info, chunk_offset, verbose);
35913591 btrfs_scrub_continue(fs_info);
35923592 if (ret) {
35933593 /*
@@ -4277,20 +4277,29 @@ static int balance_remap_chunks(struct btrfs_fs_info *fs_info, struct btrfs_path · 683 unmodified lines
42774277 end:
42784278 while (!list_empty(chunks)) {
42794279 bool is_unused;
4280+ struct btrfs_block_group *bg;
42804281
42814282 rci = list_first_entry(chunks, struct remap_chunk_info, list);
42824283
4283− spin_lock(&rci->bg->lock);
4284− is_unused = !btrfs_is_block_group_used(rci->bg);
4285− spin_unlock(&rci->bg->lock);
4284+ bg = rci->bg;
4285+ if (bg) {
4286+ /*
4287+ * This is a bit racy and the 'used' status can change
4288+ * but this is not a problem as later functions will
4289+ * verify it again.
4290+ */
4291+ spin_lock(&bg->lock);
4292+ is_unused = !btrfs_is_block_group_used(bg);
4293+ spin_unlock(&bg->lock);
42864294
4287− if (is_unused)
4288− btrfs_mark_bg_unused(rci->bg);
4295+ if (is_unused)
4296+ btrfs_mark_bg_unused(bg);
42894297
4290− if (rci->made_ro)
4291− btrfs_dec_block_group_ro(rci->bg);
4298+ if (rci->made_ro)
4299+ btrfs_dec_block_group_ro(bg);
42924300
4293− btrfs_put_block_group(rci->bg);
4301+ btrfs_put_block_group(bg);
4302+ }
42944303
42954304 list_del(&rci->list);
42964305 kfree(rci);
fs/btrfs/zoned.c+11−2
@@ -337,7 +337,10 @@ int btrfs_get_dev_zone_info_all_devices(struct btrfs_fs_info *fs_info) · 336 unmodified lines
337337 if (!btrfs_fs_incompat(fs_info, ZONED))
338338 return 0;
339339
340− mutex_lock(&fs_devices->device_list_mutex);
340+ /*
341+ * No need to take the device_list mutex here, we're still in the mount
342+ * path and devices cannot be added to or removed from the list yet.
343+ */
341344 list_for_each_entry(device, &fs_devices->devices, dev_list) {
342345 /* We can skip reading of zone info for missing devices */
343346 if (!device->bdev)
@@ -347,7 +350,6 @@ int btrfs_get_dev_zone_info_all_devices(struct btrfs_fs_info *fs_info) · 3 unmodified lines
347350 if (ret)
348351 break;
349352 }
350− mutex_unlock(&fs_devices->device_list_mutex);
351353
352354 return ret;
353355 }
@@ -1259,6 +1261,13 @@ static int calculate_alloc_pointer(struct btrfs_block_group *cache, · 905 unmodified lines
12591261 key.offset = 0;
12601262
12611263 root = btrfs_extent_root(fs_info, key.objectid);
1264+ if (unlikely(!root)) {
1265+ btrfs_err(fs_info,
1266+ "missing extent root for extent at bytenr %llu",
1267+ key.objectid);
1268+ return -EUCLEAN;
1269+ }
1270+
12621271 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
12631272 /* We should not find the exact match */
12641273 if (unlikely(!ret))
fs/btrfs/zstd.c+1−1
@@ -600,7 +600,7 @@ int zstd_decompress_bio(struct list_head *ws, struct compressed_bio *cb) · 599 unmodified lines
600600 bio_first_folio(&fi, &cb->bbio.bio, 0);
601601 if (unlikely(!fi.folio))
602602 return -EINVAL;
603− ASSERT(folio_size(fi.folio) == blocksize);
603+ ASSERT(folio_size(fi.folio) == min_folio_size);
604604
605605 stream = zstd_init_dstream(
606606 ZSTD_BTRFS_MAX_INPUT, workspace->mem, workspace->size);
fs/nfsd/export.c+54−9
@@ -36,19 +36,30 @@ · 35 unmodified lines
3636 * second map contains a reference to the entry in the first map.
3737 */
3838
39+static struct workqueue_struct *nfsd_export_wq;
40+
3941 #define EXPKEY_HASHBITS 8
4042 #define EXPKEY_HASHMAX (1 << EXPKEY_HASHBITS)
4143 #define EXPKEY_HASHMASK (EXPKEY_HASHMAX -1)
4244
43−static void expkey_put(struct kref *ref)
45+static void expkey_release(struct work_struct *work)
4446 {
45− struct svc_expkey *key = container_of(ref, struct svc_expkey, h.ref);
47+ struct svc_expkey *key = container_of(to_rcu_work(work),
48+ struct svc_expkey, ek_rwork);
4649
4750 if (test_bit(CACHE_VALID, &key->h.flags) &&
4851 !test_bit(CACHE_NEGATIVE, &key->h.flags))
4952 path_put(&key->ek_path);
5053 auth_domain_put(key->ek_client);
51− kfree_rcu(key, ek_rcu);
54+ kfree(key);
55+}
56+
57+static void expkey_put(struct kref *ref)
58+{
59+ struct svc_expkey *key = container_of(ref, struct svc_expkey, h.ref);
60+
61+ INIT_RCU_WORK(&key->ek_rwork, expkey_release);
62+ queue_rcu_work(nfsd_export_wq, &key->ek_rwork);
5263 }
5364
5465 static int expkey_upcall(struct cache_detail *cd, struct cache_head *h)
@@ -353,11 +364,13 @@ static void export_stats_destroy(struct export_stats *stats) · 298 unmodified lines
353364 EXP_STATS_COUNTERS_NUM);
354365 }
355366
356−static void svc_export_release(struct rcu_head *rcu_head)
367+static void svc_export_release(struct work_struct *work)
357368 {
358− struct svc_export *exp = container_of(rcu_head, struct svc_export,
359− ex_rcu);
369+ struct svc_export *exp = container_of(to_rcu_work(work),
370+ struct svc_export, ex_rwork);
360371
372+ path_put(&exp->ex_path);
373+ auth_domain_put(exp->ex_client);
361374 nfsd4_fslocs_free(&exp->ex_fslocs);
362375 export_stats_destroy(exp->ex_stats);
363376 kfree(exp->ex_stats);
@@ -369,9 +382,8 @@ static void svc_export_put(struct kref *ref) · 5 unmodified lines
369382 {
370383 struct svc_export *exp = container_of(ref, struct svc_export, h.ref);
371384
372− path_put(&exp->ex_path);
373− auth_domain_put(exp->ex_client);
374− call_rcu(&exp->ex_rcu, svc_export_release);
385+ INIT_RCU_WORK(&exp->ex_rwork, svc_export_release);
386+ queue_rcu_work(nfsd_export_wq, &exp->ex_rwork);
375387 }
376388
377389 static int svc_export_upcall(struct cache_detail *cd, struct cache_head *h)
@@ -1479,6 +1491,36 @@ const struct seq_operations nfs_exports_op = { · 1101 unmodified lines
14791491 .show = e_show,
14801492 };
14811493
1494+/**
1495+ * nfsd_export_wq_init - allocate the export release workqueue
1496+ *
1497+ * Called once at module load. The workqueue runs deferred svc_export and
1498+ * svc_expkey release work scheduled by queue_rcu_work() in the cache put
1499+ * callbacks.
1500+ *
1501+ * Return values:
1502+ * %0: workqueue allocated
1503+ * %-ENOMEM: allocation failed
1504+ */
1505+int nfsd_export_wq_init(void)
1506+{
1507+ nfsd_export_wq = alloc_workqueue("nfsd_export", WQ_UNBOUND, 0);
1508+ if (!nfsd_export_wq)
1509+ return -ENOMEM;
1510+ return 0;
1511+}
1512+
1513+/**
1514+ * nfsd_export_wq_shutdown - drain and free the export release workqueue
1515+ *
1516+ * Called once at module unload. Per-namespace teardown in
1517+ * nfsd_export_shutdown() has already drained all deferred work.
1518+ */
1519+void nfsd_export_wq_shutdown(void)
1520+{
1521+ destroy_workqueue(nfsd_export_wq);
1522+}
1523+
14821524 /*
14831525 * Initialize the exports module.
14841526 */
@@ -1540,6 +1582,9 @@ nfsd_export_shutdown(struct net *net) · 55 unmodified lines
15401582
15411583 cache_unregister_net(nn->svc_expkey_cache, net);
15421584 cache_unregister_net(nn->svc_export_cache, net);
1585+ /* Drain deferred export and expkey release work. */
1586+ rcu_barrier();
1587+ flush_workqueue(nfsd_export_wq);
15431588 cache_destroy_net(nn->svc_expkey_cache, net);
15441589 cache_destroy_net(nn->svc_export_cache, net);
15451590 svcauth_unix_purge(net);
fs/nfsd/export.h+5−2
@@ -7,6 +7,7 @@ · 6 unmodified lines
77
88 #include <linux/sunrpc/cache.h>
99 #include <linux/percpu_counter.h>
10+#include <linux/workqueue.h>
1011 #include <uapi/linux/nfsd/export.h>
1112 #include <linux/nfs4.h>
1213
@@ -75,7 +76,7 @@ struct svc_export { · 62 unmodified lines
7576 u32 ex_layout_types;
7677 struct nfsd4_deviceid_map *ex_devid_map;
7778 struct cache_detail *cd;
78− struct rcu_head ex_rcu;
79+ struct rcu_work ex_rwork;
7980 unsigned long ex_xprtsec_modes;
8081 struct export_stats *ex_stats;
8182 };
@@ -92,7 +93,7 @@ struct svc_expkey { · 10 unmodified lines
9293 u32 ek_fsid[6];
9394
9495 struct path ek_path;
95− struct rcu_head ek_rcu;
96+ struct rcu_work ek_rwork;
9697 };
9798
9899 #define EX_ISSYNC(exp) (!((exp)->ex_flags & NFSEXP_ASYNC))
@@ -110,6 +111,8 @@ __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp, · 11 unmodified lines
110111 /*
111112 * Function declarations
112113 */
114+int nfsd_export_wq_init(void);
115+void nfsd_export_wq_shutdown(void);
113116 int nfsd_export_init(struct net *);
114117 void nfsd_export_shutdown(struct net *);
115118 void nfsd_export_flush(struct net *);
fs/nfsd/nfs4xdr.c+7−2
@@ -6281,9 +6281,14 @@ nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op) · 6280 unmodified lines
62816281 int len = xdr->buf->len - (op_status_offset + XDR_UNIT);
62826282
62836283 so->so_replay.rp_status = op->status;
6284− so->so_replay.rp_buflen = len;
6285− read_bytes_from_xdr_buf(xdr->buf, op_status_offset + XDR_UNIT,
6284+ if (len <= NFSD4_REPLAY_ISIZE) {
6285+ so->so_replay.rp_buflen = len;
6286+ read_bytes_from_xdr_buf(xdr->buf,
6287+ op_status_offset + XDR_UNIT,
62866288 so->so_replay.rp_buf, len);
6289+ } else {
6290+ so->so_replay.rp_buflen = 0;
6291+ }
62876292 }
62886293 status:
62896294 op->status = nfsd4_map_status(op->status,
fs/nfsd/nfsctl.c+19−3
@@ -149,9 +149,19 @@ static int exports_net_open(struct net *net, struct file *file) · 148 unmodified lines
149149
150150 seq = file->private_data;
151151 seq->private = nn->svc_export_cache;
152+ get_net(net);
152153 return 0;
153154 }
154155
156+static int exports_release(struct inode *inode, struct file *file)
157+{
158+ struct seq_file *seq = file->private_data;
159+ struct cache_detail *cd = seq->private;
160+
161+ put_net(cd->net);
162+ return seq_release(inode, file);
163+}
164+
155165 static int exports_nfsd_open(struct inode *inode, struct file *file)
156166 {
157167 return exports_net_open(inode->i_sb->s_fs_info, file);
@@ -161,7 +171,7 @@ static const struct file_operations exports_nfsd_operations = { · 3 unmodified lines
161171 .open = exports_nfsd_open,
162172 .read = seq_read,
163173 .llseek = seq_lseek,
164− .release = seq_release,
174+ .release = exports_release,
165175 };
166176
167177 static int export_features_show(struct seq_file *m, void *v)
@@ -1376,7 +1386,7 @@ static const struct proc_ops exports_proc_ops = { · 1208 unmodified lines
13761386 .proc_open = exports_proc_open,
13771387 .proc_read = seq_read,
13781388 .proc_lseek = seq_lseek,
1379− .proc_release = seq_release,
1389+ .proc_release = exports_release,
13801390 };
13811391
13821392 static int create_proc_exports_entry(void)
@@ -2259,9 +2269,12 @@ static int __init init_nfsd(void) · 876 unmodified lines
22592269 if (retval)
22602270 goto out_free_pnfs;
22612271 nfsd_lockd_init(); /* lockd->nfsd callbacks */
2272+ retval = nfsd_export_wq_init();
2273+ if (retval)
2274+ goto out_free_lockd;
22622275 retval = register_pernet_subsys(&nfsd_net_ops);
22632276 if (retval < 0)
2264− goto out_free_lockd;
2277+ goto out_free_export_wq;
22652278 retval = register_cld_notifier();
22662279 if (retval)
22672280 goto out_free_subsys;
@@ -2290,6 +2303,8 @@ out_free_cld: · 22 unmodified lines
22902303 unregister_cld_notifier();
22912304 out_free_subsys:
22922305 unregister_pernet_subsys(&nfsd_net_ops);
2306+out_free_export_wq:
2307+ nfsd_export_wq_shutdown();
22932308 out_free_lockd:
22942309 nfsd_lockd_shutdown();
22952310 nfsd_drc_slab_free();
@@ -2310,6 +2325,7 @@ static void __exit exit_nfsd(void) · 14 unmodified lines
23102325 nfsd4_destroy_laundry_wq();
23112326 unregister_cld_notifier();
23122327 unregister_pernet_subsys(&nfsd_net_ops);
2328+ nfsd_export_wq_shutdown();
23132329 nfsd_drc_slab_free();
23142330 nfsd_lockd_shutdown();
23152331 nfsd4_free_slabs();
fs/nfsd/state.h+12−5
@@ -541,11 +541,18 @@ struct nfs4_client_reclaim { · 540 unmodified lines
541541 struct xdr_netobj cr_princhash;
542542 };
543543
544−/* A reasonable value for REPLAY_ISIZE was estimated as follows:
545− * The OPEN response, typically the largest, requires
546− * 4(status) + 8(stateid) + 20(changeinfo) + 4(rflags) + 8(verifier) +
547− * 4(deleg. type) + 8(deleg. stateid) + 4(deleg. recall flag) +
548− * 20(deleg. space limit) + ~32(deleg. ace) = 112 bytes
544+/*
545+ * REPLAY_ISIZE is sized for an OPEN response with delegation:
546+ * 4(status) + 8(stateid) + 20(changeinfo) + 4(rflags) +
547+ * 8(verifier) + 4(deleg. type) + 8(deleg. stateid) +
548+ * 4(deleg. recall flag) + 20(deleg. space limit) +
549+ * ~32(deleg. ace) = 112 bytes
550+ *
551+ * Some responses can exceed this. A LOCK denial includes the conflicting
552+ * lock owner, which can be up to 1024 bytes (NFS4_OPAQUE_LIMIT). Responses
553+ * larger than REPLAY_ISIZE are not cached in rp_ibuf; only rp_status is
554+ * saved. Enlarging this constant increases the size of every
555+ * nfs4_stateowner.
549556 */
550557
551558 #define NFSD4_REPLAY_ISIZE 112
fs/smb/client/cifsglob.h+6−0
@@ -2386,4 +2386,10 @@ static inline int cifs_open_create_options(unsigned int oflags, int opts) · 2385 unmodified lines
23862386 return opts;
23872387 }
23882388
2389+/*
2390+ * The number of blocks is not related to (i_size / i_blksize), but instead
2391+ * 512 byte (2**9) size is required for calculating num blocks.
2392+ */
2393+#define CIFS_INO_BLOCKS(size) DIV_ROUND_UP_ULL((u64)(size), 512)
2394+
23892395 #endif /* _CIFS_GLOB_H */
fs/smb/client/connect.c+4−0
@@ -1955,6 +1955,10 @@ static int match_session(struct cifs_ses *ses, · 1954 unmodified lines
19551955 case Kerberos:
19561956 if (!uid_eq(ctx->cred_uid, ses->cred_uid))
19571957 return 0;
1958+ if (strncmp(ses->user_name ?: "",
1959+ ctx->username ?: "",
1960+ CIFS_MAX_USERNAME_LEN))
1961+ return 0;
19581962 break;
19591963 case NTLMv2:
19601964 case RawNTLMSSP:
fs/smb/client/file.c+0−1
@@ -993,7 +993,6 @@ static int cifs_do_truncate(const unsigned int xid, struct dentry *dentry) · 992 unmodified lines
993993 if (!rc) {
994994 netfs_resize_file(&cinode->netfs, 0, true);
995995 cifs_setsize(inode, 0);
996− inode->i_blocks = 0;
997996 }
998997 }
999998 if (cfile)
fs/smb/client/inode.c+6−15
@@ -219,13 +219,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr, · 218 unmodified lines
219219 */
220220 if (is_size_safe_to_change(cifs_i, fattr->cf_eof, from_readdir)) {
221221 i_size_write(inode, fattr->cf_eof);
222−
223− /*
224− * i_blocks is not related to (i_size / i_blksize),
225− * but instead 512 byte (2**9) size is required for
226− * calculating num blocks.
227− */
228− inode->i_blocks = (512 - 1 + fattr->cf_bytes) >> 9;
222+ inode->i_blocks = CIFS_INO_BLOCKS(fattr->cf_bytes);
229223 }
230224
231225 if (S_ISLNK(fattr->cf_mode) && fattr->cf_symlink_target) {
@@ -3015,6 +3009,11 @@ void cifs_setsize(struct inode *inode, loff_t offset) · 2783 unmodified lines
30153009 {
30163010 spin_lock(&inode->i_lock);
30173011 i_size_write(inode, offset);
3012+ /*
3013+ * Until we can query the server for actual allocation size,
3014+ * this is best estimate we have for blocks allocated for a file.
3015+ */
3016+ inode->i_blocks = CIFS_INO_BLOCKS(offset);
30183017 spin_unlock(&inode->i_lock);
30193018 inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode));
30203019 truncate_pagecache(inode, offset);
@@ -3087,14 +3086,6 @@ set_size_out: · 66 unmodified lines
30873086 if (rc == 0) {
30883087 netfs_resize_file(&cifsInode->netfs, size, true);
30893088 cifs_setsize(inode, size);
3090− /*
3091− * i_blocks is not related to (i_size / i_blksize), but instead
3092− * 512 byte (2**9) size is required for calculating num blocks.
3093− * Until we can query the server for actual allocation size,
3094− * this is best estimate we have for blocks allocated for a file
3095− * Number of blocks must be rounded up so size 1 is not 0 blocks
3096− */
3097− inode->i_blocks = (512 - 1 + size) >> 9;
30983089 }
30993090
31003091 return rc;
fs/smb/client/smb1transport.c+1−1
@@ -460,7 +460,7 @@ check_smb_hdr(struct smb_hdr *smb) · 459 unmodified lines
460460 return 0;
461461
462462 /*
463− * Windows NT server returns error resposne (e.g. STATUS_DELETE_PENDING
463+ * Windows NT server returns error response (e.g. STATUS_DELETE_PENDING
464464 * or STATUS_OBJECT_NAME_NOT_FOUND or ERRDOS/ERRbadfile or any other)
465465 * for some TRANS2 requests without the RESPONSE flag set in header.
466466 */
fs/smb/client/smb2ops.c+4−16
@@ -1497,6 +1497,7 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon, · 1496 unmodified lines
14971497 {
14981498 struct smb2_file_network_open_info file_inf;
14991499 struct inode *inode;
1500+ u64 asize;
15001501 int rc;
15011502
15021503 rc = __SMB2_close(xid, tcon, cfile->fid.persistent_fid,
@@ -1520,14 +1521,9 @@ smb2_close_getattr(const unsigned int xid, struct cifs_tcon *tcon, · 17 unmodified lines
15201521 inode_set_atime_to_ts(inode,
15211522 cifs_NTtimeToUnix(file_inf.LastAccessTime));
15221523
1523− /*
1524− * i_blocks is not related to (i_size / i_blksize),
1525− * but instead 512 byte (2**9) size is required for
1526− * calculating num blocks.
1527− */
1528− if (le64_to_cpu(file_inf.AllocationSize) > 4096)
1529− inode->i_blocks =
1530− (512 - 1 + le64_to_cpu(file_inf.AllocationSize)) >> 9;
1524+ asize = le64_to_cpu(file_inf.AllocationSize);
1525+ if (asize > 4096)
1526+ inode->i_blocks = CIFS_INO_BLOCKS(asize);
15311527
15321528 /* End of file and Attributes should not have to be updated on close */
15331529 spin_unlock(&inode->i_lock);
@@ -2204,14 +2200,6 @@ smb2_duplicate_extents(const unsigned int xid, · 670 unmodified lines
22042200 rc = smb2_set_file_size(xid, tcon, trgtfile, dest_off + len, false);
22052201 if (rc)
22062202 goto duplicate_extents_out;
2207−
2208− /*
2209− * Although also could set plausible allocation size (i_blocks)
2210− * here in addition to setting the file size, in reflink
2211− * it is likely that the target file is sparse. Its allocation
2212− * size will be queried on next revalidate, but it is important
2213− * to make sure that file's cached size is updated immediately
2214− */
22152203 netfs_resize_file(netfs_inode(inode), dest_off + len, true);
22162204 cifs_setsize(inode, dest_off + len);
22172205 }
fs/smb/server/mgmt/tree_connect.c+6−3
@@ -102,8 +102,10 @@ out_error: · 101 unmodified lines
102102
103103 void ksmbd_tree_connect_put(struct ksmbd_tree_connect *tcon)
104104 {
105− if (atomic_dec_and_test(&tcon->refcount))
105+ if (atomic_dec_and_test(&tcon->refcount)) {
106+ ksmbd_share_config_put(tcon->share_conf);
106107 kfree(tcon);
108+ }
107109 }
108110
109111 static int __ksmbd_tree_conn_disconnect(struct ksmbd_session *sess,
@@ -113,10 +115,11 @@ static int __ksmbd_tree_conn_disconnect(struct ksmbd_session *sess, · 3 unmodified lines
113115
114116 ret = ksmbd_ipc_tree_disconnect_request(sess->id, tree_conn->id);
115117 ksmbd_release_tree_conn_id(sess, tree_conn->id);
116− ksmbd_share_config_put(tree_conn->share_conf);
117118 ksmbd_counter_dec(KSMBD_COUNTER_TREE_CONNS);
118− if (atomic_dec_and_test(&tree_conn->refcount))
119+ if (atomic_dec_and_test(&tree_conn->refcount)) {
120+ ksmbd_share_config_put(tree_conn->share_conf);
119121 kfree(tree_conn);
122+ }
120123 return ret;
121124 }
122125
fs/smb/server/smb2pdu.c+12−5
@@ -126,6 +126,8 @@ int smb2_get_ksmbd_tcon(struct ksmbd_work *work) · 125 unmodified lines
126126 pr_err("The first operation in the compound does not have tcon\n");
127127 return -EINVAL;
128128 }
129+ if (work->tcon->t_state != TREE_CONNECTED)
130+ return -ENOENT;
129131 if (tree_id != UINT_MAX && work->tcon->id != tree_id) {
130132 pr_err("tree id(%u) is different with id(%u) in first operation\n",
131133 tree_id, work->tcon->id);
@@ -1948,6 +1950,7 @@ out_err: · 1816 unmodified lines
19481950 }
19491951 }
19501952 smb2_set_err_rsp(work);
1953+ conn->binding = false;
19511954 } else {
19521955 unsigned int iov_len;
19531956
@@ -2828,7 +2831,11 @@ static int parse_durable_handle_context(struct ksmbd_work *work, · 874 unmodified lines
28282831 goto out;
28292832 }
28302833
2831− dh_info->fp->conn = conn;
2834+ if (dh_info->fp->conn) {
2835+ ksmbd_put_durable_fd(dh_info->fp);
2836+ err = -EBADF;
2837+ goto out;
2838+ }
28322839 dh_info->reconnected = true;
28332840 goto out;
28342841 }
@@ -5452,7 +5459,6 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work, · 2617 unmodified lines
54525459 struct smb2_query_info_req *req,
54535460 struct smb2_query_info_rsp *rsp)
54545461 {
5455− struct ksmbd_session *sess = work->sess;
54565462 struct ksmbd_conn *conn = work->conn;
54575463 struct ksmbd_share_config *share = work->tcon->share_conf;
54585464 int fsinfoclass = 0;
@@ -5589,10 +5595,11 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work, · 130 unmodified lines
55895595
55905596 info = (struct object_id_info *)(rsp->Buffer);
55915597
5592− if (!user_guest(sess->user))
5593− memcpy(info->objid, user_passkey(sess->user), 16);
5598+ if (path.mnt->mnt_sb->s_uuid_len == 16)
5599+ memcpy(info->objid, path.mnt->mnt_sb->s_uuid.b,
5600+ path.mnt->mnt_sb->s_uuid_len);
55945601 else
5595− memset(info->objid, 0, 16);
5602+ memcpy(info->objid, &stfs.f_fsid, sizeof(stfs.f_fsid));
55965603
55975604 info->extended_info.magic = cpu_to_le32(EXTENDED_INFO_MAGIC);
55985605 info->extended_info.version = cpu_to_le32(1);
fs/tests/exec_kunit.c+0−3
@@ -94,9 +94,6 @@ static const struct bprm_stack_limits_result bprm_stack_limits_results[] = { · 93 unmodified lines
9494 { { .p = ULONG_MAX, .rlim_stack.rlim_cur = 4 * (_STK_LIM / 4 * 3 + sizeof(void *)),
9595 .argc = 0, .envc = 0 },
9696 .expected_argmin = ULONG_MAX - (_STK_LIM / 4 * 3) + sizeof(void *) },
97− { { .p = ULONG_MAX, .rlim_stack.rlim_cur = 4 * (_STK_LIM / 4 * + sizeof(void *)),
98− .argc = 0, .envc = 0 },
99− .expected_argmin = ULONG_MAX - (_STK_LIM / 4 * 3) + sizeof(void *) },
10097 { { .p = ULONG_MAX, .rlim_stack.rlim_cur = 4 * _STK_LIM,
10198 .argc = 0, .envc = 0 },
10299 .expected_argmin = ULONG_MAX - (_STK_LIM / 4 * 3) + sizeof(void *) },
include/hyperv/hvgdk_mini.h+2−1
@@ -477,7 +477,6 @@ union hv_vp_assist_msr_contents { /* HV_REGISTER_VP_ASSIST_PAGE */ · 476 unmodified lines
477477 #define HVCALL_NOTIFY_PARTITION_EVENT 0x0087
478478 #define HVCALL_ENTER_SLEEP_STATE 0x0084
479479 #define HVCALL_NOTIFY_PORT_RING_EMPTY 0x008b
480−#define HVCALL_SCRUB_PARTITION 0x008d
481480 #define HVCALL_REGISTER_INTERCEPT_RESULT 0x0091
482481 #define HVCALL_ASSERT_VIRTUAL_INTERRUPT 0x0094
483482 #define HVCALL_CREATE_PORT 0x0095
@@ -1121,6 +1120,8 @@ enum hv_register_name { · 637 unmodified lines
11211120 HV_X64_REGISTER_MSR_MTRR_FIX4KF8000 = 0x0008007A,
11221121
11231122 HV_X64_REGISTER_REG_PAGE = 0x0009001C,
1123+#elif defined(CONFIG_ARM64)
1124+ HV_ARM64_REGISTER_SINT_RESERVED_INTERRUPT_ID = 0x00070001,
11241125 #endif
11251126 };
11261127
include/linux/auxvec.h+1−1
@@ -4,6 +4,6 @@ · 3 unmodified lines
44
55 #include <uapi/linux/auxvec.h>
66
7−#define AT_VECTOR_SIZE_BASE 22 /* NEW_AUX_ENT entries in auxiliary table */
7+#define AT_VECTOR_SIZE_BASE 24 /* NEW_AUX_ENT entries in auxiliary table */
88 /* number of "#define AT_.*" above, minus {AT_NULL, AT_IGNORE, AT_NOTELF} */
99 #endif /* _LINUX_AUXVEC_H */
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
include/linux/console_struct.h+1−0
@@ -160,6 +160,7 @@ struct vc_data { · 159 unmodified lines
160160 struct uni_pagedict **uni_pagedict_loc; /* [!] Location of uni_pagedict variable for this console */
161161 u32 **vc_uni_lines; /* unicode screen content */
162162 u16 *vc_saved_screen;
163+ u32 **vc_saved_uni_lines;
163164 unsigned int vc_saved_cols;
164165 unsigned int vc_saved_rows;
165166 /* additional information is in vt_kern.h */
include/linux/device.h+54−0
@@ -483,6 +483,8 @@ struct device_physical_location { · 482 unmodified lines
483483 * on. This shrinks the "Board Support Packages" (BSPs) and
484484 * minimizes board-specific #ifdefs in drivers.
485485 * @driver_data: Private pointer for driver specific info.
486+ * @driver_override: Driver name to force a match. Do not touch directly; use
487+ * device_set_driver_override() instead.
486488 * @links: Links to suppliers and consumers of this device.
487489 * @power: For device power management.
488490 * See Documentation/driver-api/pm/devices.rst for details.
@@ -576,6 +578,10 @@ struct device { · 87 unmodified lines
576578 core doesn't touch it */
577579 void *driver_data; /* Driver data, set and get with
578580 dev_set_drvdata/dev_get_drvdata */
581+ struct {
582+ const char *name;
583+ spinlock_t lock;
584+ } driver_override;
579585 struct mutex mutex; /* mutex to synchronize calls to
580586 * its driver.
581587 */
@@ -701,6 +707,54 @@ struct device_link { · 119 unmodified lines
701707
702708 #define kobj_to_dev(__kobj) container_of_const(__kobj, struct device, kobj)
703709
710+int __device_set_driver_override(struct device *dev, const char *s, size_t len);
711+
712+/**
713+ * device_set_driver_override() - Helper to set or clear driver override.
714+ * @dev: Device to change
715+ * @s: NUL-terminated string, new driver name to force a match, pass empty
716+ * string to clear it ("" or "\n", where the latter is only for sysfs
717+ * interface).
718+ *
719+ * Helper to set or clear driver override of a device.
720+ *
721+ * Returns: 0 on success or a negative error code on failure.
722+ */
723+static inline int device_set_driver_override(struct device *dev, const char *s)
724+{
725+ return __device_set_driver_override(dev, s, s ? strlen(s) : 0);
726+}
727+
728+/**
729+ * device_has_driver_override() - Check if a driver override has been set.
730+ * @dev: device to check
731+ *
732+ * Returns true if a driver override has been set for this device.
733+ */
734+static inline bool device_has_driver_override(struct device *dev)
735+{
736+ guard(spinlock)(&dev->driver_override.lock);
737+ return !!dev->driver_override.name;
738+}
739+
740+/**
741+ * device_match_driver_override() - Match a driver against the device's driver_override.
742+ * @dev: device to check
743+ * @drv: driver to match against
744+ *
745+ * Returns > 0 if a driver override is set and matches the given driver, 0 if a
746+ * driver override is set but does not match, or < 0 if a driver override is not
747+ * set at all.
748+ */
749+static inline int device_match_driver_override(struct device *dev,
750+ const struct device_driver *drv)
751+{
752+ guard(spinlock)(&dev->driver_override.lock);
753+ if (dev->driver_override.name)
754+ return !strcmp(dev->driver_override.name, drv->name);
755+ return -1;
756+}
757+
704758 /**
705759 * device_iommu_mapped - Returns true when the device DMA is translated
706760 * by an IOMMU
include/linux/device/bus.h+4−0
@@ -65,6 +65,9 @@ struct fwnode_handle; · 64 unmodified lines
6565 * this bus.
6666 * @pm: Power management operations of this bus, callback the specific
6767 * device driver's pm-ops.
68+ * @driver_override: Set to true if this bus supports the driver_override
69+ * mechanism, which allows userspace to force a specific
70+ * driver to bind to a device via a sysfs attribute.
6871 * @need_parent_lock: When probing or removing a device on this bus, the
6972 * device core should lock the device's parent.
7073 *
@@ -106,6 +109,7 @@ struct bus_type { · 35 unmodified lines
106109
107110 const struct dev_pm_ops *pm;
108111
112+ bool driver_override;
109113 bool need_parent_lock;
110114 };
111115
include/linux/etherdevice.h+2−1
@@ -42,7 +42,8 @@ extern const struct header_ops eth_header_ops; · 41 unmodified lines
4242
4343 int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type,
4444 const void *daddr, const void *saddr, unsigned len);
45−int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr);
45+int eth_header_parse(const struct sk_buff *skb, const struct net_device *dev,
46+ unsigned char *haddr);
4647 int eth_header_cache(const struct neighbour *neigh, struct hh_cache *hh,
4748 __be16 type);
4849 void eth_header_cache_update(struct hh_cache *hh, const struct net_device *dev,
include/linux/hid.h+1−0
@@ -682,6 +682,7 @@ struct hid_device { · 681 unmodified lines
682682 __s32 battery_charge_status;
683683 enum hid_battery_status battery_status;
684684 bool battery_avoid_query;
685+ bool battery_present;
685686 ktime_t battery_ratelimit_time;
686687 #endif
687688
include/linux/if_ether.h+2−1
@@ -40,7 +40,8 @@ static inline struct ethhdr *inner_eth_hdr(const struct sk_buff *skb) · 39 unmodified lines
4040 return (struct ethhdr *)skb_inner_mac_header(skb);
4141 }
4242
43−int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr);
43+int eth_header_parse(const struct sk_buff *skb, const struct net_device *dev,
44+ unsigned char *haddr);
4445
4546 extern ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len);
4647
include/linux/io-pgtable.h+8−2
@@ -53,7 +53,7 @@ struct iommu_flush_ops { · 52 unmodified lines
5353 * tables.
5454 * @ias: Input address (iova) size, in bits.
5555 * @oas: Output address (paddr) size, in bits.
56− * @coherent_walk A flag to indicate whether or not page table walks made
56+ * @coherent_walk: A flag to indicate whether or not page table walks made
5757 * by the IOMMU are coherent with the CPU caches.
5858 * @tlb: TLB management callbacks for this set of tables.
5959 * @iommu_dev: The device representing the DMA configuration for the
@@ -136,6 +136,7 @@ struct io_pgtable_cfg { · 76 unmodified lines
136136 void (*free)(void *cookie, void *pages, size_t size);
137137
138138 /* Low-level data specific to the table format */
139+ /* private: */
139140 union {
140141 struct {
141142 u64 ttbr;
@@ -203,6 +204,9 @@ struct arm_lpae_io_pgtable_walk_data { · 61 unmodified lines
203204 * @unmap_pages: Unmap a range of virtually contiguous pages of the same size.
204205 * @iova_to_phys: Translate iova to physical address.
205206 * @pgtable_walk: (optional) Perform a page table walk for a given iova.
207+ * @read_and_clear_dirty: Record dirty info per IOVA. If an IOVA is dirty,
208+ * clear its dirty state from the PTE unless the
209+ * IOMMU_DIRTY_NO_CLEAR flag is passed in.
206210 *
207211 * These functions map directly onto the iommu_ops member functions with
208212 * the same names.
@@ -231,7 +235,9 @@ struct io_pgtable_ops { · 22 unmodified lines
231235 * the configuration actually provided by the allocator (e.g. the
232236 * pgsize_bitmap may be restricted).
233237 * @cookie: An opaque token provided by the IOMMU driver and passed back to
234− * the callback routines in cfg->tlb.
238+ * the callback routines.
239+ *
240+ * Returns: Pointer to the &struct io_pgtable_ops for this set of page tables.
235241 */
236242 struct io_pgtable_ops *alloc_io_pgtable_ops(enum io_pgtable_fmt fmt,
237243 struct io_pgtable_cfg *cfg,
include/linux/io_uring_types.h+3−0
@@ -541,6 +541,7 @@ enum { · 540 unmodified lines
541541 REQ_F_BL_NO_RECYCLE_BIT,
542542 REQ_F_BUFFERS_COMMIT_BIT,
543543 REQ_F_BUF_NODE_BIT,
544+ REQ_F_BUF_MORE_BIT,
544545 REQ_F_HAS_METADATA_BIT,
545546 REQ_F_IMPORT_BUFFER_BIT,
546547 REQ_F_SQE_COPIED_BIT,
@@ -626,6 +627,8 @@ enum { · 79 unmodified lines
626627 REQ_F_BUFFERS_COMMIT = IO_REQ_FLAG(REQ_F_BUFFERS_COMMIT_BIT),
627628 /* buf node is valid */
628629 REQ_F_BUF_NODE = IO_REQ_FLAG(REQ_F_BUF_NODE_BIT),
630+ /* incremental buffer consumption, more space available */
631+ REQ_F_BUF_MORE = IO_REQ_FLAG(REQ_F_BUF_MORE_BIT),
629632 /* request has read/write metadata assigned */
630633 REQ_F_HAS_METADATA = IO_REQ_FLAG(REQ_F_HAS_METADATA_BIT),
631634 /*
include/linux/local_lock_internal.h+1−1
@@ -315,7 +315,7 @@ do { \ · 314 unmodified lines
315315
316316 #endif /* CONFIG_PREEMPT_RT */
317317
318−#if defined(WARN_CONTEXT_ANALYSIS)
318+#if defined(WARN_CONTEXT_ANALYSIS) && !defined(__CHECKER__)
319319 /*
320320 * Because the compiler only knows about the base per-CPU variable, use this
321321 * helper function to make the compiler think we lock/unlock the @base variable,
include/linux/netdevice.h+5−4
@@ -311,7 +311,9 @@ struct header_ops { · 310 unmodified lines
311311 int (*create) (struct sk_buff *skb, struct net_device *dev,
312312 unsigned short type, const void *daddr,
313313 const void *saddr, unsigned int len);
314− int (*parse)(const struct sk_buff *skb, unsigned char *haddr);
314+ int (*parse)(const struct sk_buff *skb,
315+ const struct net_device *dev,
316+ unsigned char *haddr);
315317 int (*cache)(const struct neighbour *neigh, struct hh_cache *hh, __be16 type);
316318 void (*cache_update)(struct hh_cache *hh,
317319 const struct net_device *dev,
@@ -2155,6 +2157,7 @@ struct net_device { · 1837 unmodified lines
21552157 unsigned long state;
21562158 unsigned int flags;
21572159 unsigned short hard_header_len;
2160+ enum netdev_stat_type pcpu_stat_type:8;
21582161 netdev_features_t features;
21592162 struct inet6_dev __rcu *ip6_ptr;
21602163 __cacheline_group_end(net_device_read_txrx);
@@ -2404,8 +2407,6 @@ struct net_device { · 243 unmodified lines
24042407 void *ml_priv;
24052408 enum netdev_ml_priv_type ml_priv_type;
24062409
2407− enum netdev_stat_type pcpu_stat_type:8;
2408−
24092410 #if IS_ENABLED(CONFIG_GARP)
24102411 struct garp_port __rcu *garp_port;
24112412 #endif
@@ -3446,7 +3447,7 @@ static inline int dev_parse_header(const struct sk_buff *skb, · 1034 unmodified lines
34463447
34473448 if (!dev->header_ops || !dev->header_ops->parse)
34483449 return 0;
3449− return dev->header_ops->parse(skb, haddr);
3450+ return dev->header_ops->parse(skb, dev, haddr);
34503451 }
34513452
34523453 static inline __be16 dev_parse_header_protocol(const struct sk_buff *skb)
include/linux/platform_device.h+0−5
@@ -31,11 +31,6 @@ struct platform_device { · 30 unmodified lines
3131 struct resource *resource;
3232
3333 const struct platform_device_id *id_entry;
34− /*
35− * Driver name to force a match. Do not set directly, because core
36− * frees it. Use driver_set_override() to set or clear it.
37− */
38− const char *driver_override;
3934
4035 /* MFD cell pointer */
4136 struct mfd_cell *mfd_cell;
include/linux/serial_8250.h+1−0
@@ -195,6 +195,7 @@ void serial8250_do_set_mctrl(struct uart_port *port, unsigned int mctrl); · 194 unmodified lines
195195 void serial8250_do_set_divisor(struct uart_port *port, unsigned int baud,
196196 unsigned int quot);
197197 int fsl8250_handle_irq(struct uart_port *port);
198+void serial8250_handle_irq_locked(struct uart_port *port, unsigned int iir);
198199 int serial8250_handle_irq(struct uart_port *port, unsigned int iir);
199200 u16 serial8250_rx_chars(struct uart_8250_port *up, u16 lsr);
200201 void serial8250_read_char(struct uart_8250_port *up, u16 lsr);
include/net/ip_tunnels.h+23−7
@@ -665,13 +665,29 @@ static inline int iptunnel_pull_offloads(struct sk_buff *skb) · 664 unmodified lines
665665 static inline void iptunnel_xmit_stats(struct net_device *dev, int pkt_len)
666666 {
667667 if (pkt_len > 0) {
668− struct pcpu_sw_netstats *tstats = get_cpu_ptr(dev->tstats);
669−
670− u64_stats_update_begin(&tstats->syncp);
671− u64_stats_add(&tstats->tx_bytes, pkt_len);
672− u64_stats_inc(&tstats->tx_packets);
673− u64_stats_update_end(&tstats->syncp);
674− put_cpu_ptr(tstats);
668+ if (dev->pcpu_stat_type == NETDEV_PCPU_STAT_DSTATS) {
669+ struct pcpu_dstats *dstats = get_cpu_ptr(dev->dstats);
670+
671+ u64_stats_update_begin(&dstats->syncp);
672+ u64_stats_add(&dstats->tx_bytes, pkt_len);
673+ u64_stats_inc(&dstats->tx_packets);
674+ u64_stats_update_end(&dstats->syncp);
675+ put_cpu_ptr(dstats);
676+ return;
677+ }
678+ if (dev->pcpu_stat_type == NETDEV_PCPU_STAT_TSTATS) {
679+ struct pcpu_sw_netstats *tstats = get_cpu_ptr(dev->tstats);
680+
681+ u64_stats_update_begin(&tstats->syncp);
682+ u64_stats_add(&tstats->tx_bytes, pkt_len);
683+ u64_stats_inc(&tstats->tx_packets);
684+ u64_stats_update_end(&tstats->syncp);
685+ put_cpu_ptr(tstats);
686+ return;
687+ }
688+ pr_err_once("iptunnel_xmit_stats pcpu_stat_type=%d\n",
689+ dev->pcpu_stat_type);
690+ WARN_ON_ONCE(1);
675691 return;
676692 }
677693
include/net/mac80211.h+3−1
@@ -7407,7 +7407,9 @@ void ieee80211_report_wowlan_wakeup(struct ieee80211_vif *vif, · 7406 unmodified lines
74077407 * @band: the band to transmit on
74087408 * @sta: optional pointer to get the station to send the frame to
74097409 *
7410− * Return: %true if the skb was prepared, %false otherwise
7410+ * Return: %true if the skb was prepared, %false otherwise.
7411+ * On failure, the skb is freed by this function; callers must not
7412+ * free it again.
74117413 *
74127414 * Note: must be called under RCU lock
74137415 */
include/net/netfilter/nf_tables.h+2−4
@@ -277,8 +277,6 @@ struct nft_userdata { · 276 unmodified lines
277277 unsigned char data[];
278278 };
279279
280−#define NFT_SET_ELEM_INTERNAL_LAST 0x1
281−
282280 /* placeholder structure for opaque set element backend representation. */
283281 struct nft_elem_priv { };
284282
@@ -288,7 +286,6 @@ struct nft_elem_priv { }; · 3 unmodified lines
288286 * @key: element key
289287 * @key_end: closing element key
290288 * @data: element data
291− * @flags: flags
292289 * @priv: element private data and extensions
293290 */
294291 struct nft_set_elem {
@@ -304,7 +301,6 @@ struct nft_set_elem { · 9 unmodified lines
304301 u32 buf[NFT_DATA_VALUE_MAXLEN / sizeof(u32)];
305302 struct nft_data val;
306303 } data;
307− u32 flags;
308304 struct nft_elem_priv *priv;
309305 };
310306
@@ -878,6 +874,8 @@ struct nft_elem_priv *nft_set_elem_init(const struct nft_set *set, · 567 unmodified lines
878874 u64 timeout, u64 expiration, gfp_t gfp);
879875 int nft_set_elem_expr_clone(const struct nft_ctx *ctx, struct nft_set *set,
880876 struct nft_expr *expr_array[]);
877+void nft_set_elem_expr_destroy(const struct nft_ctx *ctx,
878+ struct nft_set_elem_expr *elem_expr);
881879 void nft_set_elem_destroy(const struct nft_set *set,
882880 const struct nft_elem_priv *elem_priv,
883881 bool destroy_expr);
include/net/sch_generic.h+33−0
@@ -716,6 +716,34 @@ void qdisc_destroy(struct Qdisc *qdisc); · 715 unmodified lines
716716 void qdisc_put(struct Qdisc *qdisc);
717717 void qdisc_put_unlocked(struct Qdisc *qdisc);
718718 void qdisc_tree_reduce_backlog(struct Qdisc *qdisc, int n, int len);
719+
720+static inline void dev_reset_queue(struct net_device *dev,
721+ struct netdev_queue *dev_queue,
722+ void *_unused)
723+{
724+ struct Qdisc *qdisc;
725+ bool nolock;
726+
727+ qdisc = rtnl_dereference(dev_queue->qdisc_sleeping);
728+ if (!qdisc)
729+ return;
730+
731+ nolock = qdisc->flags & TCQ_F_NOLOCK;
732+
733+ if (nolock)
734+ spin_lock_bh(&qdisc->seqlock);
735+ spin_lock_bh(qdisc_lock(qdisc));
736+
737+ qdisc_reset(qdisc);
738+
739+ spin_unlock_bh(qdisc_lock(qdisc));
740+ if (nolock) {
741+ clear_bit(__QDISC_STATE_MISSED, &qdisc->state);
742+ clear_bit(__QDISC_STATE_DRAINING, &qdisc->state);
743+ spin_unlock_bh(&qdisc->seqlock);
744+ }
745+}
746+
719747 #ifdef CONFIG_NET_SCHED
720748 int qdisc_offload_dump_helper(struct Qdisc *q, enum tc_setup_type type,
721749 void *type_data);
@@ -1429,6 +1457,11 @@ void mini_qdisc_pair_init(struct mini_Qdisc_pair *miniqp, struct Qdisc *qdisc, · 707 unmodified lines
14291457 void mini_qdisc_pair_block_init(struct mini_Qdisc_pair *miniqp,
14301458 struct tcf_block *block);
14311459
1460+static inline bool mini_qdisc_pair_inited(struct mini_Qdisc_pair *miniqp)
1461+{
1462+ return !!miniqp->p_miniq;
1463+}
1464+
14321465 void mq_change_real_num_tx(struct Qdisc *sch, unsigned int new_real_tx);
14331466
14341467 int sch_frag_xmit_hook(struct sk_buff *skb, int (*xmit)(struct sk_buff *skb));
include/net/udp_tunnel.h+1−1
@@ -52,7 +52,7 @@ int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg, · 51 unmodified lines
5252 static inline int udp_sock_create6(struct net *net, struct udp_port_cfg *cfg,
5353 struct socket **sockp)
5454 {
55− return 0;
55+ return -EPFNOSUPPORT;
5656 }
5757 #endif
5858
include/trace/events/task.h+5−2
@@ -38,19 +38,22 @@ TRACE_EVENT(task_rename, · 37 unmodified lines
3838 TP_ARGS(task, comm),
3939
4040 TP_STRUCT__entry(
41+ __field( pid_t, pid)
4142 __array( char, oldcomm, TASK_COMM_LEN)
4243 __array( char, newcomm, TASK_COMM_LEN)
4344 __field( short, oom_score_adj)
4445 ),
4546
4647 TP_fast_assign(
48+ __entry->pid = task->pid;
4749 memcpy(entry->oldcomm, task->comm, TASK_COMM_LEN);
4850 strscpy(entry->newcomm, comm, TASK_COMM_LEN);
4951 __entry->oom_score_adj = task->signal->oom_score_adj;
5052 ),
5153
52− TP_printk("oldcomm=%s newcomm=%s oom_score_adj=%hd",
53− __entry->oldcomm, __entry->newcomm, __entry->oom_score_adj)
54+ TP_printk("pid=%d oldcomm=%s newcomm=%s oom_score_adj=%hd",
55+ __entry->pid, __entry->oldcomm,
56+ __entry->newcomm, __entry->oom_score_adj)
5457 );
5558
5659 /**
io_uring/kbuf.c+11−3
@@ -34,6 +34,10 @@ struct io_provide_buf { · 33 unmodified lines
3434
3535 static bool io_kbuf_inc_commit(struct io_buffer_list *bl, int len)
3636 {
37+ /* No data consumed, return false early to avoid consuming the buffer */
38+ if (!len)
39+ return false;
40+
3741 while (len) {
3842 struct io_uring_buf *buf;
3943 u32 buf_len, this_len;
@@ -212,7 +216,8 @@ static struct io_br_sel io_ring_buffer_select(struct io_kiocb *req, size_t *len, · 172 unmodified lines
212216 sel.addr = u64_to_user_ptr(READ_ONCE(buf->addr));
213217
214218 if (io_should_commit(req, issue_flags)) {
215− io_kbuf_commit(req, sel.buf_list, *len, 1);
219+ if (!io_kbuf_commit(req, sel.buf_list, *len, 1))
220+ req->flags |= REQ_F_BUF_MORE;
216221 sel.buf_list = NULL;
217222 }
218223 return sel;
@@ -345,7 +350,8 @@ int io_buffers_select(struct io_kiocb *req, struct buf_sel_arg *arg, · 126 unmodified lines
345350 */
346351 if (ret > 0) {
347352 req->flags |= REQ_F_BUFFERS_COMMIT | REQ_F_BL_NO_RECYCLE;
348− io_kbuf_commit(req, sel->buf_list, arg->out_len, ret);
353+ if (!io_kbuf_commit(req, sel->buf_list, arg->out_len, ret))
354+ req->flags |= REQ_F_BUF_MORE;
349355 }
350356 } else {
351357 ret = io_provided_buffers_select(req, &arg->out_len, sel->buf_list, arg->iovs);
@@ -391,8 +397,10 @@ static inline bool __io_put_kbuf_ring(struct io_kiocb *req, · 39 unmodified lines
391397
392398 if (bl)
393399 ret = io_kbuf_commit(req, bl, len, nr);
400+ if (ret && (req->flags & REQ_F_BUF_MORE))
401+ ret = false;
394402
395− req->flags &= ~REQ_F_BUFFER_RING;
403+ req->flags &= ~(REQ_F_BUFFER_RING | REQ_F_BUF_MORE);
396404 return ret;
397405 }
398406
io_uring/poll.c+7−2
@@ -272,6 +272,7 @@ static int io_poll_check_events(struct io_kiocb *req, io_tw_token_t tw) · 271 unmodified lines
272272 atomic_andnot(IO_POLL_RETRY_FLAG, &req->poll_refs);
273273 v &= ~IO_POLL_RETRY_FLAG;
274274 }
275+ v &= IO_POLL_REF_MASK;
275276 }
276277
277278 /* the mask was stashed in __io_poll_execute */
@@ -304,8 +305,13 @@ static int io_poll_check_events(struct io_kiocb *req, io_tw_token_t tw) · 26 unmodified lines
304305 return IOU_POLL_REMOVE_POLL_USE_RES;
305306 }
306307 } else {
307− int ret = io_poll_issue(req, tw);
308+ int ret;
308309
310+ /* multiple refs and HUP, ensure we loop once more */
311+ if ((req->cqe.res & (POLLHUP | POLLRDHUP)) && v != 1)
312+ v--;
313+
314+ ret = io_poll_issue(req, tw);
309315 if (ret == IOU_COMPLETE)
310316 return IOU_POLL_REMOVE_POLL_USE_RES;
311317 else if (ret == IOU_REQUEUE)
@@ -321,7 +327,6 @@ static int io_poll_check_events(struct io_kiocb *req, io_tw_token_t tw) · 9 unmodified lines
321327 * Release all references, retry if someone tried to restart
322328 * task_work while we were executing it.
323329 */
324− v &= IO_POLL_REF_MASK;
325330 } while (atomic_sub_return(v, &req->poll_refs) & IO_POLL_REF_MASK);
326331
327332 io_napi_add(req);
kernel/bpf/btf.c+20−4
@@ -1787,7 +1787,16 @@ static void btf_free_id(struct btf *btf) · 1786 unmodified lines
17871787 * of the _bh() version.
17881788 */
17891789 spin_lock_irqsave(&btf_idr_lock, flags);
1790− idr_remove(&btf_idr, btf->id);
1790+ if (btf->id) {
1791+ idr_remove(&btf_idr, btf->id);
1792+ /*
1793+ * Clear the id here to make this function idempotent, since it will get
1794+ * called a couple of times for module BTFs: on module unload, and then
1795+ * the final btf_put(). btf_alloc_id() starts IDs with 1, so we can use
1796+ * 0 as sentinel value.
1797+ */
1798+ WRITE_ONCE(btf->id, 0);
1799+ }
17911800 spin_unlock_irqrestore(&btf_idr_lock, flags);
17921801 }
17931802
@@ -8115,7 +8124,7 @@ static void bpf_btf_show_fdinfo(struct seq_file *m, struct file *filp) · 6321 unmodified lines
81158124 {
81168125 const struct btf *btf = filp->private_data;
81178126
8118− seq_printf(m, "btf_id:\t%u\n", btf->id);
8127+ seq_printf(m, "btf_id:\t%u\n", READ_ONCE(btf->id));
81198128 }
81208129 #endif
81218130
@@ -8197,7 +8206,7 @@ int btf_get_info_by_fd(const struct btf *btf, · 75 unmodified lines
81978206 if (copy_from_user(&info, uinfo, info_copy))
81988207 return -EFAULT;
81998208
8200− info.id = btf->id;
8209+ info.id = READ_ONCE(btf->id);
82018210 ubtf = u64_to_user_ptr(info.btf);
82028211 btf_copy = min_t(u32, btf->data_size, info.btf_size);
82038212 if (copy_to_user(ubtf, btf->data, btf_copy))
@@ -8260,7 +8269,7 @@ int btf_get_fd_by_id(u32 id) · 56 unmodified lines
82608269
82618270 u32 btf_obj_id(const struct btf *btf)
82628271 {
8263− return btf->id;
8272+ return READ_ONCE(btf->id);
82648273 }
82658274
82668275 bool btf_is_kernel(const struct btf *btf)
@@ -8382,6 +8391,13 @@ static int btf_module_notify(struct notifier_block *nb, unsigned long op, · 115 unmodified lines
83828391 if (btf_mod->module != module)
83838392 continue;
83848393
8394+ /*
8395+ * For modules, we do the freeing of BTF IDR as soon as
8396+ * module goes away to disable BTF discovery, since the
8397+ * btf_try_get_module() on such BTFs will fail. This may
8398+ * be called again on btf_put(), but it's ok to do so.
8399+ */
8400+ btf_free_id(btf_mod->btf);
83858401 list_del(&btf_mod->list);
83868402 if (btf_mod->sysfs_attr)
83878403 sysfs_remove_bin_file(btf_kobj, btf_mod->sysfs_attr);
kernel/bpf/core.c+35−8
@@ -1422,6 +1422,27 @@ static int bpf_jit_blind_insn(const struct bpf_insn *from, · 1421 unmodified lines
14221422 *to++ = BPF_ALU64_IMM(BPF_XOR, BPF_REG_AX, imm_rnd);
14231423 *to++ = BPF_STX_MEM(from->code, from->dst_reg, BPF_REG_AX, from->off);
14241424 break;
1425+
1426+ case BPF_ST | BPF_PROBE_MEM32 | BPF_DW:
1427+ case BPF_ST | BPF_PROBE_MEM32 | BPF_W:
1428+ case BPF_ST | BPF_PROBE_MEM32 | BPF_H:
1429+ case BPF_ST | BPF_PROBE_MEM32 | BPF_B:
1430+ *to++ = BPF_ALU64_IMM(BPF_MOV, BPF_REG_AX, imm_rnd ^
1431+ from->imm);
1432+ *to++ = BPF_ALU64_IMM(BPF_XOR, BPF_REG_AX, imm_rnd);
1433+ /*
1434+ * Cannot use BPF_STX_MEM() macro here as it
1435+ * hardcodes BPF_MEM mode, losing PROBE_MEM32
1436+ * and breaking arena addressing in the JIT.
1437+ */
1438+ *to++ = (struct bpf_insn) {
1439+ .code = BPF_STX | BPF_PROBE_MEM32 |
1440+ BPF_SIZE(from->code),
1441+ .dst_reg = from->dst_reg,
1442+ .src_reg = BPF_REG_AX,
1443+ .off = from->off,
1444+ };
1445+ break;
14251446 }
14261447 out:
14271448 return to - to_buff;
@@ -1736,6 +1757,12 @@ bool bpf_opcode_in_insntable(u8 code) · 308 unmodified lines
17361757 }
17371758
17381759 #ifndef CONFIG_BPF_JIT_ALWAYS_ON
1760+/* Absolute value of s32 without undefined behavior for S32_MIN */
1761+static u32 abs_s32(s32 x)
1762+{
1763+ return x >= 0 ? (u32)x : -(u32)x;
1764+}
1765+
17391766 /**
17401767 * ___bpf_prog_run - run eBPF program on a given context
17411768 * @regs: is the array of MAX_BPF_EXT_REG eBPF pseudo-registers
@@ -1900,8 +1927,8 @@ select_insn: · 158 unmodified lines
19001927 DST = do_div(AX, (u32) SRC);
19011928 break;
19021929 case 1:
1903− AX = abs((s32)DST);
1904− AX = do_div(AX, abs((s32)SRC));
1930+ AX = abs_s32((s32)DST);
1931+ AX = do_div(AX, abs_s32((s32)SRC));
19051932 if ((s32)DST < 0)
19061933 DST = (u32)-AX;
19071934 else
@@ -1928,8 +1955,8 @@ select_insn: · 20 unmodified lines
19281955 DST = do_div(AX, (u32) IMM);
19291956 break;
19301957 case 1:
1931− AX = abs((s32)DST);
1932− AX = do_div(AX, abs((s32)IMM));
1958+ AX = abs_s32((s32)DST);
1959+ AX = do_div(AX, abs_s32((s32)IMM));
19331960 if ((s32)DST < 0)
19341961 DST = (u32)-AX;
19351962 else
@@ -1955,8 +1982,8 @@ select_insn: · 19 unmodified lines
19551982 DST = (u32) AX;
19561983 break;
19571984 case 1:
1958− AX = abs((s32)DST);
1959− do_div(AX, abs((s32)SRC));
1985+ AX = abs_s32((s32)DST);
1986+ do_div(AX, abs_s32((s32)SRC));
19601987 if (((s32)DST < 0) == ((s32)SRC < 0))
19611988 DST = (u32)AX;
19621989 else
@@ -1982,8 +2009,8 @@ select_insn: · 19 unmodified lines
19822009 DST = (u32) AX;
19832010 break;
19842011 case 1:
1985− AX = abs((s32)DST);
1986− do_div(AX, abs((s32)IMM));
2012+ AX = abs_s32((s32)DST);
2013+ do_div(AX, abs_s32((s32)IMM));
19872014 if (((s32)DST < 0) == ((s32)IMM < 0))
19882015 DST = (u32)AX;
19892016 else
kernel/bpf/verifier.c+25−8
@@ -15910,6 +15910,13 @@ static void scalar_byte_swap(struct bpf_reg_state *dst_reg, struct bpf_insn *ins · 15909 unmodified lines
1591015910 /* Apply bswap if alu64 or switch between big-endian and little-endian machines */
1591115911 bool need_bswap = alu64 || (to_le == is_big_endian);
1591215912
15913+ /*
15914+ * If the register is mutated, manually reset its scalar ID to break
15915+ * any existing ties and avoid incorrect bounds propagation.
15916+ */
15917+ if (need_bswap || insn->imm == 16 || insn->imm == 32)
15918+ dst_reg->id = 0;
15919+
1591315920 if (need_bswap) {
1591415921 if (insn->imm == 16)
1591515922 dst_reg->var_off = tnum_bswap16(dst_reg->var_off);
@@ -15992,7 +15999,7 @@ static int maybe_fork_scalars(struct bpf_verifier_env *env, struct bpf_insn *ins · 76 unmodified lines
1599215999 else
1599316000 return 0;
1599416001
15995− branch = push_stack(env, env->insn_idx + 1, env->insn_idx, false);
16002+ branch = push_stack(env, env->insn_idx, env->insn_idx, false);
1599616003 if (IS_ERR(branch))
1599716004 return PTR_ERR(branch);
1599816005
@@ -17408,6 +17415,12 @@ static void sync_linked_regs(struct bpf_verifier_env *env, struct bpf_verifier_s · 1409 unmodified lines
1740817415 continue;
1740917416 if ((reg->id & ~BPF_ADD_CONST) != (known_reg->id & ~BPF_ADD_CONST))
1741017417 continue;
17418+ /*
17419+ * Skip mixed 32/64-bit links: the delta relationship doesn't
17420+ * hold across different ALU widths.
17421+ */
17422+ if (((reg->id ^ known_reg->id) & BPF_ADD_CONST) == BPF_ADD_CONST)
17423+ continue;
1741117424 if ((!(reg->id & BPF_ADD_CONST) && !(known_reg->id & BPF_ADD_CONST)) ||
1741217425 reg->off == known_reg->off) {
1741317426 s32 saved_subreg_def = reg->subreg_def;
@@ -17435,7 +17448,7 @@ static void sync_linked_regs(struct bpf_verifier_env *env, struct bpf_verifier_s · 21 unmodified lines
1743517448 scalar32_min_max_add(reg, &fake_reg);
1743617449 scalar_min_max_add(reg, &fake_reg);
1743717450 reg->var_off = tnum_add(reg->var_off, fake_reg.var_off);
17438− if (known_reg->id & BPF_ADD_CONST32)
17451+ if ((reg->id | known_reg->id) & BPF_ADD_CONST32)
1743917452 zext_32_to_64(reg);
1744017453 reg_bounds_sync(reg);
1744117454 }
@@ -19863,11 +19876,14 @@ static bool regsafe(struct bpf_verifier_env *env, struct bpf_reg_state *rold, · 2421 unmodified lines
1986319876 * Also verify that new value satisfies old value range knowledge.
1986419877 */
1986519878
19866− /* ADD_CONST mismatch: different linking semantics */
19867− if ((rold->id & BPF_ADD_CONST) && !(rcur->id & BPF_ADD_CONST))
19868− return false;
19869−
19870− if (rold->id && !(rold->id & BPF_ADD_CONST) && (rcur->id & BPF_ADD_CONST))
19879+ /*
19880+ * ADD_CONST flags must match exactly: BPF_ADD_CONST32 and
19881+ * BPF_ADD_CONST64 have different linking semantics in
19882+ * sync_linked_regs() (alu32 zero-extends, alu64 does not),
19883+ * so pruning across different flag types is unsafe.
19884+ */
19885+ if (rold->id &&
19886+ (rold->id & BPF_ADD_CONST) != (rcur->id & BPF_ADD_CONST))
1987119887 return false;
1987219888
1987319889 /* Both have offset linkage: offsets must match */
@@ -20904,7 +20920,8 @@ static int process_bpf_exit_full(struct bpf_verifier_env *env, · 1030 unmodified lines
2090420920 * state when it exits.
2090520921 */
2090620922 int err = check_resource_leak(env, exception_exit,
20907− !env->cur_state->curframe,
20923+ exception_exit || !env->cur_state->curframe,
20924+ exception_exit ? "bpf_throw" :
2090820925 "BPF_EXIT instruction in main prog");
2090920926 if (err)
2091020927 return err;
kernel/crash_dump_dm_crypt.c+2−2
@@ -168,8 +168,8 @@ static int read_key_from_user_keying(struct dm_crypt_key *dm_key) · 167 unmodified lines
168168
169169 memcpy(dm_key->data, ukp->data, ukp->datalen);
170170 dm_key->key_size = ukp->datalen;
171− kexec_dprintk("Get dm crypt key (size=%u) %s: %8ph\n", dm_key->key_size,
172− dm_key->key_desc, dm_key->data);
171+ kexec_dprintk("Get dm crypt key (size=%u) %s\n", dm_key->key_size,
172+ dm_key->key_desc);
173173
174174 out:
175175 up_read(&key->sem);
kernel/events/core.c+8−11
@@ -4813,7 +4813,7 @@ static void __perf_event_read(void *info) · 4812 unmodified lines
48134813 struct perf_event *sub, *event = data->event;
48144814 struct perf_event_context *ctx = event->ctx;
48154815 struct perf_cpu_context *cpuctx = this_cpu_ptr(&perf_cpu_context);
4816− struct pmu *pmu = event->pmu;
4816+ struct pmu *pmu;
48174817
48184818 /*
48194819 * If this is a task context, we need to check whether it is
@@ -4825,7 +4825,7 @@ static void __perf_event_read(void *info) · 5 unmodified lines
48254825 if (ctx->task && cpuctx->task_ctx != ctx)
48264826 return;
48274827
4828− raw_spin_lock(&ctx->lock);
4828+ guard(raw_spinlock)(&ctx->lock);
48294829 ctx_time_update_event(ctx, event);
48304830
48314831 perf_event_update_time(event);
@@ -4833,25 +4833,22 @@ static void __perf_event_read(void *info) · 1 unmodified line
48334833 perf_event_update_sibling_time(event);
48344834
48354835 if (event->state != PERF_EVENT_STATE_ACTIVE)
4836− goto unlock;
4836+ return;
48374837
48384838 if (!data->group) {
4839− pmu->read(event);
4839+ perf_pmu_read(event);
48404840 data->ret = 0;
4841− goto unlock;
4841+ return;
48424842 }
48434843
4844+ pmu = event->pmu_ctx->pmu;
48444845 pmu->start_txn(pmu, PERF_PMU_TXN_READ);
48454846
4846− pmu->read(event);
4847−
4847+ perf_pmu_read(event);
48484848 for_each_sibling_event(sub, event)
48494849 perf_pmu_read(sub);
48504850
48514851 data->ret = pmu->commit_txn(pmu);
4852−
4853−unlock:
4854− raw_spin_unlock(&ctx->lock);
48554852 }
48564853
48574854 static inline u64 perf_event_count(struct perf_event *event, bool self)
@@ -14744,7 +14741,7 @@ inherit_event(struct perf_event *parent_event, · 9886 unmodified lines
1474414741 get_ctx(child_ctx);
1474514742 child_event->ctx = child_ctx;
1474614743
14747− pmu_ctx = find_get_pmu_context(child_event->pmu, child_ctx, child_event);
14744+ pmu_ctx = find_get_pmu_context(parent_event->pmu_ctx->pmu, child_ctx, child_event);
1474814745 if (IS_ERR(pmu_ctx)) {
1474914746 free_event(child_event);
1475014747 return ERR_CAST(pmu_ctx);
kernel/sched/idle.c+21−9
@@ -161,6 +161,14 @@ static int call_cpuidle(struct cpuidle_driver *drv, struct cpuidle_device *dev, · 160 unmodified lines
161161 return cpuidle_enter(drv, dev, next_state);
162162 }
163163
164+static void idle_call_stop_or_retain_tick(bool stop_tick)
165+{
166+ if (stop_tick || tick_nohz_tick_stopped())
167+ tick_nohz_idle_stop_tick();
168+ else
169+ tick_nohz_idle_retain_tick();
170+}
171+
164172 /**
165173 * cpuidle_idle_call - the main idle function
166174 *
@@ -170,7 +178,7 @@ static int call_cpuidle(struct cpuidle_driver *drv, struct cpuidle_device *dev, · 3 unmodified lines
170178 * set, and it returns with polling set. If it ever stops polling, it
171179 * must clear the polling bit.
172180 */
173−static void cpuidle_idle_call(void)
181+static void cpuidle_idle_call(bool stop_tick)
174182 {
175183 struct cpuidle_device *dev = cpuidle_get_device();
176184 struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev);
@@ -186,7 +194,7 @@ static void cpuidle_idle_call(void) · 9 unmodified lines
186194 }
187195
188196 if (cpuidle_not_available(drv, dev)) {
189− tick_nohz_idle_stop_tick();
197+ idle_call_stop_or_retain_tick(stop_tick);
190198
191199 default_idle_call();
192200 goto exit_idle;
@@ -222,17 +230,19 @@ static void cpuidle_idle_call(void) · 29 unmodified lines
222230 next_state = cpuidle_find_deepest_state(drv, dev, max_latency_ns);
223231 call_cpuidle(drv, dev, next_state);
224232 } else if (drv->state_count > 1) {
225− bool stop_tick = true;
233+ /*
234+ * stop_tick is expected to be true by default by cpuidle
235+ * governors, which allows them to select idle states with
236+ * target residency above the tick period length.
237+ */
238+ stop_tick = true;
226239
227240 /*
228241 * Ask the cpuidle framework to choose a convenient idle state.
229242 */
230243 next_state = cpuidle_select(drv, dev, &stop_tick);
231244
232− if (stop_tick || tick_nohz_tick_stopped())
233− tick_nohz_idle_stop_tick();
234− else
235− tick_nohz_idle_retain_tick();
245+ idle_call_stop_or_retain_tick(stop_tick);
236246
237247 entered_state = call_cpuidle(drv, dev, next_state);
238248 /*
@@ -240,7 +250,7 @@ static void cpuidle_idle_call(void) · 1 unmodified line
240250 */
241251 cpuidle_reflect(dev, entered_state);
242252 } else {
243− tick_nohz_idle_retain_tick();
253+ idle_call_stop_or_retain_tick(stop_tick);
244254
245255 /*
246256 * If there is only a single idle state (or none), there is
@@ -268,6 +278,7 @@ exit_idle: · 21 unmodified lines
268278 static void do_idle(void)
269279 {
270280 int cpu = smp_processor_id();
281+ bool got_tick = false;
271282
272283 /*
273284 * Check if we need to update blocked load
@@ -338,8 +349,9 @@ static void do_idle(void) · 64 unmodified lines
338349 tick_nohz_idle_restart_tick();
339350 cpu_idle_poll();
340351 } else {
341− cpuidle_idle_call();
352+ cpuidle_idle_call(got_tick);
342353 }
354+ got_tick = tick_nohz_idle_got_tick();
343355 arch_cpu_idle_exit();
344356 }
345357
kernel/trace/ftrace.c+2−2
@@ -6606,9 +6606,9 @@ int update_ftrace_direct_mod(struct ftrace_ops *ops, struct ftrace_hash *hash, b · 6605 unmodified lines
66066606 if (!orig_hash)
66076607 goto unlock;
66086608
6609− /* Enable the tmp_ops to have the same functions as the direct ops */
6609+ /* Enable the tmp_ops to have the same functions as the hash object. */
66106610 ftrace_ops_init(&tmp_ops);
6611− tmp_ops.func_hash = ops->func_hash;
6611+ tmp_ops.func_hash->filter_hash = hash;
66126612
66136613 err = register_ftrace_function_nolock(&tmp_ops);
66146614 if (err)
kernel/trace/ring_buffer.c+1−1
@@ -2053,7 +2053,7 @@ static void rb_meta_validate_events(struct ring_buffer_per_cpu *cpu_buffer) · 2052 unmodified lines
20532053
20542054 entries += ret;
20552055 entry_bytes += local_read(&head_page->page->commit);
2056− local_set(&cpu_buffer->head_page->entries, ret);
2056+ local_set(&head_page->entries, ret);
20572057
20582058 if (head_page == cpu_buffer->commit_page)
20592059 break;
kernel/trace/trace.c+27−9
@@ -555,7 +555,7 @@ static bool update_marker_trace(struct trace_array *tr, int enabled) · 554 unmodified lines
555555 lockdep_assert_held(&event_mutex);
556556
557557 if (enabled) {
558− if (!list_empty(&tr->marker_list))
558+ if (tr->trace_flags & TRACE_ITER(COPY_MARKER))
559559 return false;
560560
561561 list_add_rcu(&tr->marker_list, &marker_copies);
@@ -563,10 +563,10 @@ static bool update_marker_trace(struct trace_array *tr, int enabled) · 1 unmodified line
563563 return true;
564564 }
565565
566− if (list_empty(&tr->marker_list))
566+ if (!(tr->trace_flags & TRACE_ITER(COPY_MARKER)))
567567 return false;
568568
569− list_del_init(&tr->marker_list);
569+ list_del_rcu(&tr->marker_list);
570570 tr->trace_flags &= ~TRACE_ITER(COPY_MARKER);
571571 return true;
572572 }
@@ -6783,6 +6783,23 @@ char *trace_user_fault_read(struct trace_user_buf_info *tinfo, · 6210 unmodified lines
67836783 */
67846784
67856785 do {
6786+ /*
6787+ * It is possible that something is trying to migrate this
6788+ * task. What happens then, is when preemption is enabled,
6789+ * the migration thread will preempt this task, try to
6790+ * migrate it, fail, then let it run again. That will
6791+ * cause this to loop again and never succeed.
6792+ * On failures, enabled and disable preemption with
6793+ * migration enabled, to allow the migration thread to
6794+ * migrate this task.
6795+ */
6796+ if (trys) {
6797+ preempt_enable_notrace();
6798+ preempt_disable_notrace();
6799+ cpu = smp_processor_id();
6800+ buffer = per_cpu_ptr(tinfo->tbuf, cpu)->buf;
6801+ }
6802+
67866803 /*
67876804 * If for some reason, copy_from_user() always causes a context
67886805 * switch, this would then cause an infinite loop.
@@ -9744,18 +9761,19 @@ static int __remove_instance(struct trace_array *tr) · 2955 unmodified lines
97449761
97459762 list_del(&tr->list);
97469763
9747− /* Disable all the flags that were enabled coming in */
9748− for (i = 0; i < TRACE_FLAGS_MAX_SIZE; i++) {
9749− if ((1ULL << i) & ZEROED_TRACE_FLAGS)
9750− set_tracer_flag(tr, 1ULL << i, 0);
9751− }
9752−
97539764 if (printk_trace == tr)
97549765 update_printk_trace(&global_trace);
97559766
9767+ /* Must be done before disabling all the flags */
97569768 if (update_marker_trace(tr, 0))
97579769 synchronize_rcu();
97589770
9771+ /* Disable all the flags that were enabled coming in */
9772+ for (i = 0; i < TRACE_FLAGS_MAX_SIZE; i++) {
9773+ if ((1ULL << i) & ZEROED_TRACE_FLAGS)
9774+ set_tracer_flag(tr, 1ULL << i, 0);
9775+ }
9776+
97599777 tracing_set_nop(tr);
97609778 clear_ftrace_function_probes(tr);
97619779 event_trace_del_tracer(tr);
lib/bootconfig.c+2−1
@@ -723,7 +723,8 @@ static int __init xbc_parse_kv(char **k, char *v, int op) · 722 unmodified lines
723723 if (op == ':') {
724724 unsigned short nidx = child->next;
725725
726− xbc_init_node(child, v, XBC_VALUE);
726+ if (xbc_init_node(child, v, XBC_VALUE) < 0)
727+ return xbc_parse_error("Failed to override value", v);
727728 child->next = nidx; /* keep subkeys */
728729 goto array;
729730 }
lib/crypto/Makefile+3−0
@@ -55,6 +55,9 @@ libaes-$(CONFIG_SPARC) += sparc/aes_asm.o · 54 unmodified lines
5555 libaes-$(CONFIG_X86) += x86/aes-aesni.o
5656 endif # CONFIG_CRYPTO_LIB_AES_ARCH
5757
58+# clean-files must be defined unconditionally
59+clean-files += powerpc/aesp8-ppc.S
60+
5861 ################################################################################
5962
6063 obj-$(CONFIG_CRYPTO_LIB_AESCFB) += libaescfb.o
mm/huge_memory.c+2−1
@@ -2797,7 +2797,8 @@ int move_pages_huge_pmd(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd, pm · 2796 unmodified lines
27972797 _dst_pmd = pmd_mkwrite(pmd_mkdirty(_dst_pmd), dst_vma);
27982798 } else {
27992799 src_pmdval = pmdp_huge_clear_flush(src_vma, src_addr, src_pmd);
2800− _dst_pmd = folio_mk_pmd(src_folio, dst_vma->vm_page_prot);
2800+ _dst_pmd = move_soft_dirty_pmd(src_pmdval);
2801+ _dst_pmd = clear_uffd_wp_pmd(_dst_pmd);
28012802 }
28022803 set_pmd_at(mm, dst_addr, dst_pmd, _dst_pmd);
28032804
mm/rmap.c+17−4
@@ -1955,7 +1955,14 @@ static inline unsigned int folio_unmap_pte_batch(struct folio *folio, · 1954 unmodified lines
19551955 if (userfaultfd_wp(vma))
19561956 return 1;
19571957
1958− return folio_pte_batch(folio, pvmw->pte, pte, max_nr);
1958+ /*
1959+ * If unmap fails, we need to restore the ptes. To avoid accidentally
1960+ * upgrading write permissions for ptes that were not originally
1961+ * writable, and to avoid losing the soft-dirty bit, use the
1962+ * appropriate FPB flags.
1963+ */
1964+ return folio_pte_batch_flags(folio, vma, pvmw->pte, &pte, max_nr,
1965+ FPB_RESPECT_WRITE | FPB_RESPECT_SOFT_DIRTY);
19591966 }
19601967
19611968 /*
@@ -2443,11 +2450,17 @@ static bool try_to_migrate_one(struct folio *folio, struct vm_area_struct *vma, · 481 unmodified lines
24432450 __maybe_unused pmd_t pmdval;
24442451
24452452 if (flags & TTU_SPLIT_HUGE_PMD) {
2453+ /*
2454+ * split_huge_pmd_locked() might leave the
2455+ * folio mapped through PTEs. Retry the walk
2456+ * so we can detect this scenario and properly
2457+ * abort the walk.
2458+ */
24462459 split_huge_pmd_locked(vma, pvmw.address,
24472460 pvmw.pmd, true);
2448− ret = false;
2449− page_vma_mapped_walk_done(&pvmw);
2450− break;
2461+ flags &= ~TTU_SPLIT_HUGE_PMD;
2462+ page_vma_mapped_walk_restart(&pvmw);
2463+ continue;
24512464 }
24522465 #ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION
24532466 pmdval = pmdp_get(pvmw.pmd);
net/atm/lec.c+47−25
@@ -154,10 +154,19 @@ static void lec_handle_bridge(struct sk_buff *skb, struct net_device *dev) · 153 unmodified lines
154154 /* 0x01 is topology change */
155155
156156 priv = netdev_priv(dev);
157− atm_force_charge(priv->lecd, skb2->truesize);
158− sk = sk_atm(priv->lecd);
159− skb_queue_tail(&sk->sk_receive_queue, skb2);
160− sk->sk_data_ready(sk);
157+ struct atm_vcc *vcc;
158+
159+ rcu_read_lock();
160+ vcc = rcu_dereference(priv->lecd);
161+ if (vcc) {
162+ atm_force_charge(vcc, skb2->truesize);
163+ sk = sk_atm(vcc);
164+ skb_queue_tail(&sk->sk_receive_queue, skb2);
165+ sk->sk_data_ready(sk);
166+ } else {
167+ dev_kfree_skb(skb2);
168+ }
169+ rcu_read_unlock();
161170 }
162171 }
163172 #endif /* IS_ENABLED(CONFIG_BRIDGE) */
@@ -216,7 +225,7 @@ static netdev_tx_t lec_start_xmit(struct sk_buff *skb, · 52 unmodified lines
216225 int is_rdesc;
217226
218227 pr_debug("called\n");
219− if (!priv->lecd) {
228+ if (!rcu_access_pointer(priv->lecd)) {
220229 pr_info("%s:No lecd attached\n", dev->name);
221230 dev->stats.tx_errors++;
222231 netif_stop_queue(dev);
@@ -449,10 +458,19 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) · 226 unmodified lines
449458 break;
450459 skb2->len = sizeof(struct atmlec_msg);
451460 skb_copy_to_linear_data(skb2, mesg, sizeof(*mesg));
452− atm_force_charge(priv->lecd, skb2->truesize);
453− sk = sk_atm(priv->lecd);
454− skb_queue_tail(&sk->sk_receive_queue, skb2);
455− sk->sk_data_ready(sk);
461+ struct atm_vcc *vcc;
462+
463+ rcu_read_lock();
464+ vcc = rcu_dereference(priv->lecd);
465+ if (vcc) {
466+ atm_force_charge(vcc, skb2->truesize);
467+ sk = sk_atm(vcc);
468+ skb_queue_tail(&sk->sk_receive_queue, skb2);
469+ sk->sk_data_ready(sk);
470+ } else {
471+ dev_kfree_skb(skb2);
472+ }
473+ rcu_read_unlock();
456474 }
457475 }
458476 #endif /* IS_ENABLED(CONFIG_BRIDGE) */
@@ -468,23 +486,16 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_buff *skb) · 9 unmodified lines
468486
469487 static void lec_atm_close(struct atm_vcc *vcc)
470488 {
471− struct sk_buff *skb;
472489 struct net_device *dev = (struct net_device *)vcc->proto_data;
473490 struct lec_priv *priv = netdev_priv(dev);
474491
475− priv->lecd = NULL;
492+ rcu_assign_pointer(priv->lecd, NULL);
493+ synchronize_rcu();
476494 /* Do something needful? */
477495
478496 netif_stop_queue(dev);
479497 lec_arp_destroy(priv);
480498
481− if (skb_peek(&sk_atm(vcc)->sk_receive_queue))
482− pr_info("%s closing with messages pending\n", dev->name);
483− while ((skb = skb_dequeue(&sk_atm(vcc)->sk_receive_queue))) {
484− atm_return(vcc, skb->truesize);
485− dev_kfree_skb(skb);
486− }
487−
488499 pr_info("%s: Shut down!\n", dev->name);
489500 module_put(THIS_MODULE);
490501 }
@@ -510,12 +521,14 @@ send_to_lecd(struct lec_priv *priv, atmlec_msg_type type, · 19 unmodified lines
510521 const unsigned char *mac_addr, const unsigned char *atm_addr,
511522 struct sk_buff *data)
512523 {
524+ struct atm_vcc *vcc;
513525 struct sock *sk;
514526 struct sk_buff *skb;
515527 struct atmlec_msg *mesg;
516528
517− if (!priv || !priv->lecd)
529+ if (!priv || !rcu_access_pointer(priv->lecd))
518530 return -1;
531+
519532 skb = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC);
520533 if (!skb)
521534 return -1;
@@ -532,18 +545,27 @@ send_to_lecd(struct lec_priv *priv, atmlec_msg_type type, · 10 unmodified lines
532545 if (atm_addr)
533546 memcpy(&mesg->content.normal.atm_addr, atm_addr, ATM_ESA_LEN);
534547
535− atm_force_charge(priv->lecd, skb->truesize);
536− sk = sk_atm(priv->lecd);
548+ rcu_read_lock();
549+ vcc = rcu_dereference(priv->lecd);
550+ if (!vcc) {
551+ rcu_read_unlock();
552+ kfree_skb(skb);
553+ return -1;
554+ }
555+
556+ atm_force_charge(vcc, skb->truesize);
557+ sk = sk_atm(vcc);
537558 skb_queue_tail(&sk->sk_receive_queue, skb);
538559 sk->sk_data_ready(sk);
539560
540561 if (data != NULL) {
541562 pr_debug("about to send %d bytes of data\n", data->len);
542− atm_force_charge(priv->lecd, data->truesize);
563+ atm_force_charge(vcc, data->truesize);
543564 skb_queue_tail(&sk->sk_receive_queue, data);
544565 sk->sk_data_ready(sk);
545566 }
546567
568+ rcu_read_unlock();
547569 return 0;
548570 }
549571
@@ -618,7 +640,7 @@ static void lec_push(struct atm_vcc *vcc, struct sk_buff *skb) · 68 unmodified lines
618640
619641 atm_return(vcc, skb->truesize);
620642 if (*(__be16 *) skb->data == htons(priv->lecid) ||
621− !priv->lecd || !(dev->flags & IFF_UP)) {
643+ !rcu_access_pointer(priv->lecd) || !(dev->flags & IFF_UP)) {
622644 /*
623645 * Probably looping back, or if lecd is missing,
624646 * lecd has gone down
@@ -753,12 +775,12 @@ static int lecd_attach(struct atm_vcc *vcc, int arg) · 128 unmodified lines
753775 priv = netdev_priv(dev_lec[i]);
754776 } else {
755777 priv = netdev_priv(dev_lec[i]);
756− if (priv->lecd)
778+ if (rcu_access_pointer(priv->lecd))
757779 return -EADDRINUSE;
758780 }
759781 lec_arp_init(priv);
760782 priv->itfnum = i; /* LANE2 addition */
761− priv->lecd = vcc;
783+ rcu_assign_pointer(priv->lecd, vcc);
762784 vcc->dev = &lecatm_dev;
763785 vcc_insert_socket(sk_atm(vcc));
764786
net/atm/lec.h+1−1
@@ -91,7 +91,7 @@ struct lec_priv { · 90 unmodified lines
9191 */
9292 spinlock_t lec_arp_lock;
9393 struct atm_vcc *mcast_vcc; /* Default Multicast Send VCC */
94− struct atm_vcc *lecd;
94+ struct atm_vcc __rcu *lecd;
9595 struct delayed_work lec_arp_work; /* C10 */
9696 unsigned int maximum_unknown_frame_count;
9797 /*
net/batman-adv/bat_iv_ogm.c+3−0
@@ -473,6 +473,9 @@ batadv_iv_ogm_can_aggregate(const struct batadv_ogm_packet *new_bat_ogm_packet, · 472 unmodified lines
473473 if (aggregated_bytes > max_bytes)
474474 return false;
475475
476+ if (skb_tailroom(forw_packet->skb) < packet_len)
477+ return false;
478+
476479 if (packet_num >= BATADV_MAX_AGGREGATION_PACKETS)
477480 return false;
478481
net/bluetooth/hci_conn.c+2−2
@@ -1944,6 +1944,8 @@ static bool hci_le_set_cig_params(struct hci_conn *conn, struct bt_iso_qos *qos) · 1943 unmodified lines
19441944 return false;
19451945
19461946 done:
1947+ conn->iso_qos = *qos;
1948+
19471949 if (hci_cmd_sync_queue(hdev, set_cig_params_sync,
19481950 UINT_PTR(qos->ucast.cig), NULL) < 0)
19491951 return false;
@@ -2013,8 +2015,6 @@ struct hci_conn *hci_bind_cis(struct hci_dev *hdev, bdaddr_t *dst, · 63 unmodified lines
20132015 }
20142016
20152017 hci_conn_hold(cis);
2016−
2017− cis->iso_qos = *qos;
20182018 cis->state = BT_BOUND;
20192019
20202020 return cis;
net/bluetooth/hci_sync.c+1−1
@@ -6627,8 +6627,8 @@ static int hci_le_create_conn_sync(struct hci_dev *hdev, void *data) · 6626 unmodified lines
66276627 * state.
66286628 */
66296629 if (hci_dev_test_flag(hdev, HCI_LE_SCAN)) {
6630− hci_scan_disable_sync(hdev);
66316630 hci_dev_set_flag(hdev, HCI_LE_SCAN_INTERRUPTED);
6631+ hci_scan_disable_sync(hdev);
66326632 }
66336633
66346634 /* Update random address, but set require_privacy to false so
net/bluetooth/hidp/core.c+14−2
@@ -986,7 +986,8 @@ static void session_free(struct kref *ref) · 985 unmodified lines
986986 skb_queue_purge(&session->intr_transmit);
987987 fput(session->intr_sock->file);
988988 fput(session->ctrl_sock->file);
989− l2cap_conn_put(session->conn);
989+ if (session->conn)
990+ l2cap_conn_put(session->conn);
990991 kfree(session);
991992 }
992993
@@ -1164,6 +1165,15 @@ static void hidp_session_remove(struct l2cap_conn *conn, · 171 unmodified lines
11641165
11651166 down_write(&hidp_session_sem);
11661167
1168+ /* Drop L2CAP reference immediately to indicate that
1169+ * l2cap_unregister_user() shall not be called as it is already
1170+ * considered removed.
1171+ */
1172+ if (session->conn) {
1173+ l2cap_conn_put(session->conn);
1174+ session->conn = NULL;
1175+ }
1176+
11671177 hidp_session_terminate(session);
11681178
11691179 cancel_work_sync(&session->dev_init);
@@ -1301,7 +1311,9 @@ static int hidp_session_thread(void *arg) · 131 unmodified lines
13011311 * Instead, this call has the same semantics as if user-space tried to
13021312 * delete the session.
13031313 */
1304− l2cap_unregister_user(session->conn, &session->user);
1314+ if (session->conn)
1315+ l2cap_unregister_user(session->conn, &session->user);
1316+
13051317 hidp_session_put(session);
13061318
13071319 module_put_and_kthread_exit(0);
net/bluetooth/l2cap_core.c+31−20
@@ -1678,17 +1678,15 @@ static void l2cap_info_timeout(struct work_struct *work) · 1677 unmodified lines
16781678
16791679 int l2cap_register_user(struct l2cap_conn *conn, struct l2cap_user *user)
16801680 {
1681− struct hci_dev *hdev = conn->hcon->hdev;
16821681 int ret;
16831682
16841683 /* We need to check whether l2cap_conn is registered. If it is not, we
1685− * must not register the l2cap_user. l2cap_conn_del() is unregisters
1686− * l2cap_conn objects, but doesn't provide its own locking. Instead, it
1687− * relies on the parent hci_conn object to be locked. This itself relies
1688− * on the hci_dev object to be locked. So we must lock the hci device
1689− * here, too. */
1684+ * must not register the l2cap_user. l2cap_conn_del() unregisters
1685+ * l2cap_conn objects under conn->lock, and we use the same lock here
1686+ * to protect access to conn->users and conn->hchan.
1687+ */
16901688
1691− hci_dev_lock(hdev);
1689+ mutex_lock(&conn->lock);
16921690
16931691 if (!list_empty(&user->list)) {
16941692 ret = -EINVAL;
@@ -1709,16 +1707,14 @@ int l2cap_register_user(struct l2cap_conn *conn, struct l2cap_user *user) · 14 unmodified lines
17091707 ret = 0;
17101708
17111709 out_unlock:
1712− hci_dev_unlock(hdev);
1710+ mutex_unlock(&conn->lock);
17131711 return ret;
17141712 }
17151713 EXPORT_SYMBOL(l2cap_register_user);
17161714
17171715 void l2cap_unregister_user(struct l2cap_conn *conn, struct l2cap_user *user)
17181716 {
1719− struct hci_dev *hdev = conn->hcon->hdev;
1720−
1721− hci_dev_lock(hdev);
1717+ mutex_lock(&conn->lock);
17221718
17231719 if (list_empty(&user->list))
17241720 goto out_unlock;
@@ -1727,7 +1723,7 @@ void l2cap_unregister_user(struct l2cap_conn *conn, struct l2cap_user *user) · 2 unmodified lines
17271723 user->remove(conn, user);
17281724
17291725 out_unlock:
1730− hci_dev_unlock(hdev);
1726+ mutex_unlock(&conn->lock);
17311727 }
17321728 EXPORT_SYMBOL(l2cap_unregister_user);
17331729
@@ -4616,7 +4612,8 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, · 2882 unmodified lines
46164612
46174613 switch (type) {
46184614 case L2CAP_IT_FEAT_MASK:
4619− conn->feat_mask = get_unaligned_le32(rsp->data);
4615+ if (cmd_len >= sizeof(*rsp) + sizeof(u32))
4616+ conn->feat_mask = get_unaligned_le32(rsp->data);
46204617
46214618 if (conn->feat_mask & L2CAP_FEAT_FIXED_CHAN) {
46224619 struct l2cap_info_req req;
@@ -4635,7 +4632,8 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, · 12 unmodified lines
46354632 break;
46364633
46374634 case L2CAP_IT_FIXED_CHAN:
4638− conn->remote_fixed_chan = rsp->data[0];
4635+ if (cmd_len >= sizeof(*rsp) + sizeof(rsp->data[0]))
4636+ conn->remote_fixed_chan = rsp->data[0];
46394637 conn->info_state |= L2CAP_INFO_FEAT_MASK_REQ_DONE;
46404638 conn->info_ident = 0;
46414639
@@ -5059,7 +5057,7 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, · 417 unmodified lines
50595057 u16 mtu, mps;
50605058 __le16 psm;
50615059 u8 result, rsp_len = 0;
5062− int i, num_scid;
5060+ int i, num_scid = 0;
50635061 bool defer = false;
50645062
50655063 if (!enable_ecred)
@@ -5072,6 +5070,14 @@ static inline int l2cap_ecred_conn_req(struct l2cap_conn *conn, · 6 unmodified lines
50725070 goto response;
50735071 }
50745072
5073+ /* Check if there are no pending channels with the same ident */
5074+ __l2cap_chan_list_id(conn, cmd->ident, l2cap_ecred_list_defer,
5075+ &num_scid);
5076+ if (num_scid) {
5077+ result = L2CAP_CR_LE_INVALID_PARAMS;
5078+ goto response;
5079+ }
5080+
50755081 cmd_len -= sizeof(*req);
50765082 num_scid = cmd_len / sizeof(u16);
50775083
@@ -5424,7 +5430,7 @@ static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn, · 346 unmodified lines
54245430 u8 *data)
54255431 {
54265432 struct l2cap_chan *chan, *tmp;
5427− struct l2cap_ecred_conn_rsp *rsp = (void *) data;
5433+ struct l2cap_ecred_reconf_rsp *rsp = (void *)data;
54285434 u16 result;
54295435
54305436 if (cmd_len < sizeof(*rsp))
@@ -5432,7 +5438,7 @@ static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn, · 1 unmodified line
54325438
54335439 result = __le16_to_cpu(rsp->result);
54345440
5435− BT_DBG("result 0x%4.4x", rsp->result);
5441+ BT_DBG("result 0x%4.4x", result);
54365442
54375443 if (!result)
54385444 return 0;
@@ -6662,8 +6668,10 @@ static int l2cap_ecred_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb) · 1223 unmodified lines
66626668 return -ENOBUFS;
66636669 }
66646670
6665− if (chan->imtu < skb->len) {
6666− BT_ERR("Too big LE L2CAP PDU");
6671+ if (skb->len > chan->imtu) {
6672+ BT_ERR("Too big LE L2CAP PDU: len %u > %u", skb->len,
6673+ chan->imtu);
6674+ l2cap_send_disconn_req(chan, ECONNRESET);
66676675 return -ENOBUFS;
66686676 }
66696677
@@ -6689,7 +6697,9 @@ static int l2cap_ecred_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb) · 19 unmodified lines
66896697 sdu_len, skb->len, chan->imtu);
66906698
66916699 if (sdu_len > chan->imtu) {
6692− BT_ERR("Too big LE L2CAP SDU length received");
6700+ BT_ERR("Too big LE L2CAP SDU length: len %u > %u",
6701+ skb->len, sdu_len);
6702+ l2cap_send_disconn_req(chan, ECONNRESET);
66936703 err = -EMSGSIZE;
66946704 goto failed;
66956705 }
@@ -6725,6 +6735,7 @@ static int l2cap_ecred_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb) · 29 unmodified lines
67256735
67266736 if (chan->sdu->len + skb->len > chan->sdu_len) {
67276737 BT_ERR("Too much LE L2CAP data received");
6738+ l2cap_send_disconn_req(chan, ECONNRESET);
67286739 err = -EINVAL;
67296740 goto failed;
67306741 }
net/bluetooth/mgmt.c+2−5
@@ -2195,10 +2195,7 @@ static void set_mesh_complete(struct hci_dev *hdev, void *data, int err) · 2194 unmodified lines
21952195 sk = cmd->sk;
21962196
21972197 if (status) {
2198− mgmt_cmd_status(cmd->sk, hdev->id, MGMT_OP_SET_MESH_RECEIVER,
2199− status);
2200− mgmt_pending_foreach(MGMT_OP_SET_MESH_RECEIVER, hdev, true,
2201− cmd_status_rsp, &status);
2198+ mgmt_cmd_status(cmd->sk, hdev->id, cmd->opcode, status);
22022199 goto done;
22032200 }
22042201
@@ -5377,7 +5374,7 @@ static void mgmt_add_adv_patterns_monitor_complete(struct hci_dev *hdev, · 3172 unmodified lines
53775374
53785375 mgmt_cmd_complete(cmd->sk, cmd->hdev->id, cmd->opcode,
53795376 mgmt_status(status), &rp, sizeof(rp));
5380− mgmt_pending_remove(cmd);
5377+ mgmt_pending_free(cmd);
53815378
53825379 hci_dev_unlock(hdev);
53835380 bt_dev_dbg(hdev, "add monitor %d complete, status %d",
net/bluetooth/smp.c+1−1
@@ -2743,7 +2743,7 @@ static int smp_cmd_public_key(struct l2cap_conn *conn, struct sk_buff *skb) · 2742 unmodified lines
27432743 if (!test_bit(SMP_FLAG_DEBUG_KEY, &smp->flags) &&
27442744 !crypto_memneq(key, smp->local_pk, 64)) {
27452745 bt_dev_err(hdev, "Remote and local public keys are identical");
2746− return SMP_UNSPECIFIED;
2746+ return SMP_DHKEY_CHECK_FAILED;
27472747 }
27482748
27492749 memcpy(smp->remote_pk, key, 64);
net/bridge/br_cfm.c+2−2
@@ -576,7 +576,7 @@ static void mep_delete_implementation(struct net_bridge *br, · 575 unmodified lines
576576
577577 /* Empty and free peer MEP list */
578578 hlist_for_each_entry_safe(peer_mep, n_store, &mep->peer_mep_list, head) {
579− cancel_delayed_work_sync(&peer_mep->ccm_rx_dwork);
579+ disable_delayed_work_sync(&peer_mep->ccm_rx_dwork);
580580 hlist_del_rcu(&peer_mep->head);
581581 kfree_rcu(peer_mep, rcu);
582582 }
@@ -732,7 +732,7 @@ int br_cfm_cc_peer_mep_remove(struct net_bridge *br, const u32 instance, · 149 unmodified lines
732732 return -ENOENT;
733733 }
734734
735− cc_peer_disable(peer_mep);
735+ disable_delayed_work_sync(&peer_mep->ccm_rx_dwork);
736736
737737 hlist_del_rcu(&peer_mep->head);
738738 kfree_rcu(peer_mep, rcu);
net/ethernet/eth.c+3−6
@@ -193,14 +193,11 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev) · 192 unmodified lines
193193 }
194194 EXPORT_SYMBOL(eth_type_trans);
195195
196−/**
197− * eth_header_parse - extract hardware address from packet
198− * @skb: packet to extract header from
199− * @haddr: destination buffer
200− */
201−int eth_header_parse(const struct sk_buff *skb, unsigned char *haddr)
196+int eth_header_parse(const struct sk_buff *skb, const struct net_device *dev,
197+ unsigned char *haddr)
202198 {
203199 const struct ethhdr *eth = eth_hdr(skb);
200+
204201 memcpy(haddr, eth->h_source, ETH_ALEN);
205202 return ETH_ALEN;
206203 }
net/ipv4/icmp.c+3−1
@@ -1079,10 +1079,12 @@ out: · 1078 unmodified lines
10791079
10801080 static bool icmp_tag_validation(int proto)
10811081 {
1082+ const struct net_protocol *ipprot;
10821083 bool ok;
10831084
10841085 rcu_read_lock();
1085− ok = rcu_dereference(inet_protos[proto])->icmp_strict_tag_validation;
1086+ ipprot = rcu_dereference(inet_protos[proto]);
1087+ ok = ipprot ? ipprot->icmp_strict_tag_validation : false;
10861088 rcu_read_unlock();
10871089 return ok;
10881090 }
net/ipv4/ip_gre.c+2−1
@@ -919,7 +919,8 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev, · 918 unmodified lines
919919 return -(t->hlen + sizeof(*iph));
920920 }
921921
922−static int ipgre_header_parse(const struct sk_buff *skb, unsigned char *haddr)
922+static int ipgre_header_parse(const struct sk_buff *skb, const struct net_device *dev,
923+ unsigned char *haddr)
923924 {
924925 const struct iphdr *iph = (const struct iphdr *) skb_mac_header(skb);
925926 memcpy(haddr, &iph->saddr, 4);
net/ipv6/exthdrs.c+4−0
@@ -379,6 +379,10 @@ static int ipv6_srh_rcv(struct sk_buff *skb) · 378 unmodified lines
379379 hdr = (struct ipv6_sr_hdr *)skb_transport_header(skb);
380380
381381 idev = __in6_dev_get(skb->dev);
382+ if (!idev) {
383+ kfree_skb(skb);
384+ return -1;
385+ }
382386
383387 accept_seg6 = min(READ_ONCE(net->ipv6.devconf_all->seg6_enabled),
384388 READ_ONCE(idev->cnf.seg6_enabled));
net/ipv6/seg6_hmac.c+2−0
@@ -184,6 +184,8 @@ bool seg6_hmac_validate_skb(struct sk_buff *skb) · 183 unmodified lines
184184 int require_hmac;
185185
186186 idev = __in6_dev_get(skb->dev);
187+ if (!idev)
188+ return false;
187189
188190 srh = (struct ipv6_sr_hdr *)skb_transport_header(skb);
189191
net/mac80211/cfg.c+6−6
@@ -1904,12 +1904,6 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev, · 1903 unmodified lines
19041904
19051905 __sta_info_flush(sdata, true, link_id, NULL);
19061906
1907− ieee80211_remove_link_keys(link, &keys);
1908− if (!list_empty(&keys)) {
1909− synchronize_net();
1910− ieee80211_free_key_list(local, &keys);
1911− }
1912−
19131907 ieee80211_stop_mbssid(sdata);
19141908 RCU_INIT_POINTER(link_conf->tx_bss_conf, NULL);
19151909
@@ -1921,6 +1915,12 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev, · 5 unmodified lines
19211915 ieee80211_link_info_change_notify(sdata, link,
19221916 BSS_CHANGED_BEACON_ENABLED);
19231917
1918+ ieee80211_remove_link_keys(link, &keys);
1919+ if (!list_empty(&keys)) {
1920+ synchronize_net();
1921+ ieee80211_free_key_list(local, &keys);
1922+ }
1923+
19241924 if (sdata->wdev.links[link_id].cac_started) {
19251925 chandef = link_conf->chanreq.oper;
19261926 wiphy_hrtimer_work_cancel(wiphy, &link->dfs_cac_timer_work);
net/mac80211/chan.c+4−2
@@ -561,14 +561,16 @@ static void ieee80211_chan_bw_change(struct ieee80211_local *local, · 560 unmodified lines
561561 rcu_read_lock();
562562 list_for_each_entry_rcu(sta, &local->sta_list,
563563 list) {
564− struct ieee80211_sub_if_data *sdata = sta->sdata;
564+ struct ieee80211_sub_if_data *sdata;
565565 enum ieee80211_sta_rx_bandwidth new_sta_bw;
566566 unsigned int link_id;
567567
568568 if (!ieee80211_sdata_running(sta->sdata))
569569 continue;
570570
571− for (link_id = 0; link_id < ARRAY_SIZE(sta->sdata->link); link_id++) {
571+ sdata = get_bss_sdata(sta->sdata);
572+
573+ for (link_id = 0; link_id < ARRAY_SIZE(sdata->link); link_id++) {
572574 struct ieee80211_link_data *link =
573575 rcu_dereference(sdata->link[link_id]);
574576 struct ieee80211_bss_conf *link_conf;
net/mac80211/debugfs.c+5−9
@@ -320,7 +320,6 @@ static ssize_t aql_enable_read(struct file *file, char __user *user_buf, · 319 unmodified lines
320320 static ssize_t aql_enable_write(struct file *file, const char __user *user_buf,
321321 size_t count, loff_t *ppos)
322322 {
323− bool aql_disabled = static_key_false(&aql_disable.key);
324323 char buf[3];
325324 size_t len;
326325
@@ -335,15 +334,12 @@ static ssize_t aql_enable_write(struct file *file, const char __user *user_buf, · 8 unmodified lines
335334 if (len > 0 && buf[len - 1] == '\n')
336335 buf[len - 1] = 0;
337336
338− if (buf[0] == '0' && buf[1] == '\0') {
339− if (!aql_disabled)
340− static_branch_inc(&aql_disable);
341− } else if (buf[0] == '1' && buf[1] == '\0') {
342− if (aql_disabled)
343− static_branch_dec(&aql_disable);
344− } else {
337+ if (buf[0] == '0' && buf[1] == '\0')
338+ static_branch_enable(&aql_disable);
339+ else if (buf[0] == '1' && buf[1] == '\0')
340+ static_branch_disable(&aql_disable);
341+ else
345342 return -EINVAL;
346− }
347343
348344 return count;
349345 }
net/mac80211/mesh.c+3−0
@@ -79,6 +79,9 @@ bool mesh_matches_local(struct ieee80211_sub_if_data *sdata, · 78 unmodified lines
7979 * - MDA enabled
8080 * - Power management control on fc
8181 */
82+ if (!ie->mesh_config)
83+ return false;
84+
8285 if (!(ifmsh->mesh_id_len == ie->mesh_id_len &&
8386 memcmp(ifmsh->mesh_id, ie->mesh_id, ie->mesh_id_len) == 0 &&
8487 (ifmsh->mesh_pp_id == ie->mesh_config->meshconf_psel) &&
net/mac80211/sta_info.c+5−2
@@ -2782,7 +2782,9 @@ static void sta_set_link_sinfo(struct sta_info *sta, · 2781 unmodified lines
27822782 }
27832783
27842784 link_sinfo->inactive_time =
2785− jiffies_to_msecs(jiffies - ieee80211_sta_last_active(sta, link_id));
2785+ jiffies_delta_to_msecs(jiffies -
2786+ ieee80211_sta_last_active(sta,
2787+ link_id));
27862788
27872789 if (!(link_sinfo->filled & (BIT_ULL(NL80211_STA_INFO_TX_BYTES64) |
27882790 BIT_ULL(NL80211_STA_INFO_TX_BYTES)))) {
@@ -3015,7 +3017,8 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo, · 226 unmodified lines
30153017 sinfo->connected_time = ktime_get_seconds() - sta->last_connected;
30163018 sinfo->assoc_at = sta->assoc_at;
30173019 sinfo->inactive_time =
3018− jiffies_to_msecs(jiffies - ieee80211_sta_last_active(sta, -1));
3020+ jiffies_delta_to_msecs(jiffies -
3021+ ieee80211_sta_last_active(sta, -1));
30193022
30203023 if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_TX_BYTES64) |
30213024 BIT_ULL(NL80211_STA_INFO_TX_BYTES)))) {
net/mac80211/tdls.c+1−1
@@ -1449,7 +1449,7 @@ int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev, · 1448 unmodified lines
14491449 }
14501450
14511451 sta = sta_info_get(sdata, peer);
1452− if (!sta)
1452+ if (!sta || !sta->sta.tdls)
14531453 return -ENOLINK;
14541454
14551455 iee80211_tdls_recalc_chanctx(sdata, sta);
net/mac80211/tx.c+3−1
@@ -1899,8 +1899,10 @@ bool ieee80211_tx_prepare_skb(struct ieee80211_hw *hw, · 1898 unmodified lines
18991899 struct ieee80211_tx_data tx;
19001900 struct sk_buff *skb2;
19011901
1902− if (ieee80211_tx_prepare(sdata, &tx, NULL, skb) == TX_DROP)
1902+ if (ieee80211_tx_prepare(sdata, &tx, NULL, skb) == TX_DROP) {
1903+ kfree_skb(skb);
19031904 return false;
1905+ }
19041906
19051907 info->band = band;
19061908 info->control.vif = vif;
net/mac802154/iface.c+3−1
@@ -469,7 +469,9 @@ static int mac802154_header_create(struct sk_buff *skb, · 468 unmodified lines
469469 }
470470
471471 static int
472−mac802154_header_parse(const struct sk_buff *skb, unsigned char *haddr)
472+mac802154_header_parse(const struct sk_buff *skb,
473+ const struct net_device *dev,
474+ unsigned char *haddr)
473475 {
474476 struct ieee802154_hdr hdr;
475477
net/mpls/af_mpls.c+1−0
@@ -2854,6 +2854,7 @@ out_unregister_rtnl_af: · 2853 unmodified lines
28542854 rtnl_af_unregister(&mpls_af_ops);
28552855 out_unregister_dev_type:
28562856 dev_remove_pack(&mpls_packet_type);
2857+ unregister_netdevice_notifier(&mpls_dev_notifier);
28572858 out_unregister_pernet:
28582859 unregister_pernet_subsys(&mpls_net_ops);
28592860 goto out;
net/mptcp/pm_kernel.c+1−1
@@ -838,7 +838,7 @@ static struct lock_class_key mptcp_keys[2]; · 837 unmodified lines
838838 static int mptcp_pm_nl_create_listen_socket(struct sock *sk,
839839 struct mptcp_pm_addr_entry *entry)
840840 {
841− bool is_ipv6 = sk->sk_family == AF_INET6;
841+ bool is_ipv6 = entry->addr.family == AF_INET6;
842842 int addrlen = sizeof(struct sockaddr_in);
843843 struct sockaddr_storage addr;
844844 struct sock *newsk, *ssk;
net/netfilter/nf_bpf_link.c+1−1
@@ -170,7 +170,7 @@ static int bpf_nf_link_update(struct bpf_link *link, struct bpf_prog *new_prog, · 169 unmodified lines
170170
171171 static const struct bpf_link_ops bpf_nf_link_lops = {
172172 .release = bpf_nf_link_release,
173− .dealloc = bpf_nf_link_dealloc,
173+ .dealloc_deferred = bpf_nf_link_dealloc,
174174 .detach = bpf_nf_link_detach,
175175 .show_fdinfo = bpf_nf_link_show_info,
176176 .fill_link_info = bpf_nf_link_fill_link_info,
net/netfilter/nf_conntrack_h323_asn1.c+4−0
@@ -331,6 +331,8 @@ static int decode_int(struct bitstr *bs, const struct field_t *f, · 330 unmodified lines
331331 if (nf_h323_error_boundary(bs, 0, 2))
332332 return H323_ERROR_BOUND;
333333 len = get_bits(bs, 2) + 1;
334+ if (nf_h323_error_boundary(bs, len, 0))
335+ return H323_ERROR_BOUND;
334336 BYTE_ALIGN(bs);
335337 if (base && (f->attr & DECODE)) { /* timeToLive */
336338 unsigned int v = get_uint(bs, len) + f->lb;
@@ -922,6 +924,8 @@ int DecodeQ931(unsigned char *buf, size_t sz, Q931 *q931) · 585 unmodified lines
922924 break;
923925 p++;
924926 len--;
927+ if (len <= 0)
928+ break;
925929 return DecodeH323_UserInformation(buf, p, len,
926930 &q931->UUIE);
927931 }
net/netfilter/nf_conntrack_netlink.c+26−2
@@ -3212,7 +3212,7 @@ ctnetlink_exp_ct_dump_table(struct sk_buff *skb, struct netlink_callback *cb) · 3211 unmodified lines
32123212 {
32133213 struct nfgenmsg *nfmsg = nlmsg_data(cb->nlh);
32143214 struct nf_conn *ct = cb->data;
3215− struct nf_conn_help *help = nfct_help(ct);
3215+ struct nf_conn_help *help;
32163216 u_int8_t l3proto = nfmsg->nfgen_family;
32173217 unsigned long last_id = cb->args[1];
32183218 struct nf_conntrack_expect *exp;
@@ -3220,6 +3220,10 @@ ctnetlink_exp_ct_dump_table(struct sk_buff *skb, struct netlink_callback *cb) · 1 unmodified line
32203220 if (cb->args[0])
32213221 return 0;
32223222
3223+ help = nfct_help(ct);
3224+ if (!help)
3225+ return 0;
3226+
32233227 rcu_read_lock();
32243228
32253229 restart:
@@ -3249,6 +3253,24 @@ out: · 23 unmodified lines
32493253 return skb->len;
32503254 }
32513255
3256+static int ctnetlink_dump_exp_ct_start(struct netlink_callback *cb)
3257+{
3258+ struct nf_conn *ct = cb->data;
3259+
3260+ if (!refcount_inc_not_zero(&ct->ct_general.use))
3261+ return -ENOENT;
3262+ return 0;
3263+}
3264+
3265+static int ctnetlink_dump_exp_ct_done(struct netlink_callback *cb)
3266+{
3267+ struct nf_conn *ct = cb->data;
3268+
3269+ if (ct)
3270+ nf_ct_put(ct);
3271+ return 0;
3272+}
3273+
32523274 static int ctnetlink_dump_exp_ct(struct net *net, struct sock *ctnl,
32533275 struct sk_buff *skb,
32543276 const struct nlmsghdr *nlh,
@@ -3264,6 +3286,8 @@ static int ctnetlink_dump_exp_ct(struct net *net, struct sock *ctnl, · 9 unmodified lines
32643286 struct nf_conntrack_zone zone;
32653287 struct netlink_dump_control c = {
32663288 .dump = ctnetlink_exp_ct_dump_table,
3289+ .start = ctnetlink_dump_exp_ct_start,
3290+ .done = ctnetlink_dump_exp_ct_done,
32673291 };
32683292
32693293 err = ctnetlink_parse_tuple(cda, &tuple, CTA_EXPECT_MASTER,
@@ -3465,7 +3489,7 @@ ctnetlink_change_expect(struct nf_conntrack_expect *x, · 195 unmodified lines
34653489
34663490 #if IS_ENABLED(CONFIG_NF_NAT)
34673491 static const struct nla_policy exp_nat_nla_policy[CTA_EXPECT_NAT_MAX+1] = {
3468− [CTA_EXPECT_NAT_DIR] = { .type = NLA_U32 },
3492+ [CTA_EXPECT_NAT_DIR] = NLA_POLICY_MAX(NLA_BE32, IP_CT_DIR_REPLY),
34693493 [CTA_EXPECT_NAT_TUPLE] = { .type = NLA_NESTED },
34703494 };
34713495 #endif
net/netfilter/nf_conntrack_proto_sctp.c+2−1
@@ -582,7 +582,8 @@ nla_put_failure: · 581 unmodified lines
582582 }
583583
584584 static const struct nla_policy sctp_nla_policy[CTA_PROTOINFO_SCTP_MAX+1] = {
585− [CTA_PROTOINFO_SCTP_STATE] = { .type = NLA_U8 },
585+ [CTA_PROTOINFO_SCTP_STATE] = NLA_POLICY_MAX(NLA_U8,
586+ SCTP_CONNTRACK_HEARTBEAT_SENT),
586587 [CTA_PROTOINFO_SCTP_VTAG_ORIGINAL] = { .type = NLA_U32 },
587588 [CTA_PROTOINFO_SCTP_VTAG_REPLY] = { .type = NLA_U32 },
588589 };
net/netfilter/nf_conntrack_sip.c+5−1
@@ -1534,11 +1534,12 @@ static int sip_help_tcp(struct sk_buff *skb, unsigned int protoff, · 1533 unmodified lines
15341534 {
15351535 struct tcphdr *th, _tcph;
15361536 unsigned int dataoff, datalen;
1537− unsigned int matchoff, matchlen, clen;
1537+ unsigned int matchoff, matchlen;
15381538 unsigned int msglen, origlen;
15391539 const char *dptr, *end;
15401540 s16 diff, tdiff = 0;
15411541 int ret = NF_ACCEPT;
1542+ unsigned long clen;
15421543 bool term;
15431544
15441545 if (ctinfo != IP_CT_ESTABLISHED &&
@@ -1573,6 +1574,9 @@ static int sip_help_tcp(struct sk_buff *skb, unsigned int protoff, · 28 unmodified lines
15731574 if (dptr + matchoff == end)
15741575 break;
15751576
1577+ if (clen > datalen)
1578+ break;
1579+
15761580 term = false;
15771581 for (; end + strlen("\r\n\r\n") <= dptr + datalen; end++) {
15781582 if (end[0] == '\r' && end[1] == '\n' &&
net/netfilter/nf_flow_table_ip.c+1−0
@@ -738,6 +738,7 @@ static int nf_flow_encap_push(struct sk_buff *skb, · 737 unmodified lines
738738 switch (tuple->encap[i].proto) {
739739 case htons(ETH_P_8021Q):
740740 case htons(ETH_P_8021AD):
741+ skb_reset_mac_header(skb);
741742 if (skb_vlan_push(skb, tuple->encap[i].proto,
742743 tuple->encap[i].id) < 0)
743744 return -1;
net/netfilter/nf_tables_api.c+7−19
@@ -6744,8 +6744,8 @@ static void __nft_set_elem_expr_destroy(const struct nft_ctx *ctx, · 6743 unmodified lines
67446744 }
67456745 }
67466746
6747−static void nft_set_elem_expr_destroy(const struct nft_ctx *ctx,
6748− struct nft_set_elem_expr *elem_expr)
6747+void nft_set_elem_expr_destroy(const struct nft_ctx *ctx,
6748+ struct nft_set_elem_expr *elem_expr)
67496749 {
67506750 struct nft_expr *expr;
67516751 u32 size;
@@ -7156,8 +7156,7 @@ static u32 nft_set_maxsize(const struct nft_set *set) · 404 unmodified lines
71567156 }
71577157
71587158 static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,
7159− const struct nlattr *attr, u32 nlmsg_flags,
7160− bool last)
7159+ const struct nlattr *attr, u32 nlmsg_flags)
71617160 {
71627161 struct nft_expr *expr_array[NFT_SET_EXPR_MAX] = {};
71637162 struct nlattr *nla[NFTA_SET_ELEM_MAX + 1];
@@ -7444,11 +7443,6 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set, · 280 unmodified lines
74447443 if (flags)
74457444 *nft_set_ext_flags(ext) = flags;
74467445
7447− if (last)
7448− elem.flags = NFT_SET_ELEM_INTERNAL_LAST;
7449− else
7450− elem.flags = 0;
7451−
74527446 if (obj)
74537447 *nft_set_ext_obj(ext) = obj;
74547448
@@ -7613,8 +7607,7 @@ static int nf_tables_newsetelem(struct sk_buff *skb, · 158 unmodified lines
76137607 nft_ctx_init(&ctx, net, skb, info->nlh, family, table, NULL, nla);
76147608
76157609 nla_for_each_nested(attr, nla[NFTA_SET_ELEM_LIST_ELEMENTS], rem) {
7616− err = nft_add_set_elem(&ctx, set, attr, info->nlh->nlmsg_flags,
7617− nla_is_last(attr, rem));
7610+ err = nft_add_set_elem(&ctx, set, attr, info->nlh->nlmsg_flags);
76187611 if (err < 0) {
76197612 NL_SET_BAD_ATTR(extack, attr);
76207613 return err;
@@ -7738,7 +7731,7 @@ static void nft_trans_elems_destroy_abort(const struct nft_ctx *ctx, · 117 unmodified lines
77387731 }
77397732
77407733 static int nft_del_setelem(struct nft_ctx *ctx, struct nft_set *set,
7741− const struct nlattr *attr, bool last)
7734+ const struct nlattr *attr)
77427735 {
77437736 struct nlattr *nla[NFTA_SET_ELEM_MAX + 1];
77447737 struct nft_set_ext_tmpl tmpl;
@@ -7806,11 +7799,6 @@ static int nft_del_setelem(struct nft_ctx *ctx, struct nft_set *set, · 61 unmodified lines
78067799 if (flags)
78077800 *nft_set_ext_flags(ext) = flags;
78087801
7809− if (last)
7810− elem.flags = NFT_SET_ELEM_INTERNAL_LAST;
7811− else
7812− elem.flags = 0;
7813−
78147802 trans = nft_trans_elem_alloc(ctx, NFT_MSG_DELSETELEM, set);
78157803 if (trans == NULL)
78167804 goto fail_trans;
@@ -7961,8 +7949,7 @@ static int nf_tables_delsetelem(struct sk_buff *skb, · 144 unmodified lines
79617949 return nft_set_flush(&ctx, set, genmask);
79627950
79637951 nla_for_each_nested(attr, nla[NFTA_SET_ELEM_LIST_ELEMENTS], rem) {
7964− err = nft_del_setelem(&ctx, set, attr,
7965− nla_is_last(attr, rem));
7952+ err = nft_del_setelem(&ctx, set, attr);
79667953 if (err == -ENOENT &&
79677954 NFNL_MSG_TYPE(info->nlh->nlmsg_type) == NFT_MSG_DESTROYSETELEM)
79687955 continue;
@@ -9216,6 +9203,7 @@ static int nf_tables_newflowtable(struct sk_buff *skb, · 1247 unmodified lines
92169203 return 0;
92179204
92189205 err_flowtable_hooks:
9206+ synchronize_rcu();
92199207 nft_trans_destroy(trans);
92209208 err_flowtable_trans:
92219209 nft_hooks_destroy(&flowtable->hook_list);
net/netfilter/nfnetlink_osf.c+13−0
@@ -302,7 +302,9 @@ static int nfnl_osf_add_callback(struct sk_buff *skb, · 301 unmodified lines
302302 {
303303 struct nf_osf_user_finger *f;
304304 struct nf_osf_finger *kf = NULL, *sf;
305+ unsigned int tot_opt_len = 0;
305306 int err = 0;
307+ int i;
306308
307309 if (!capable(CAP_NET_ADMIN))
308310 return -EPERM;
@@ -318,6 +320,17 @@ static int nfnl_osf_add_callback(struct sk_buff *skb, · 9 unmodified lines
318320 if (f->opt_num > ARRAY_SIZE(f->opt))
319321 return -EINVAL;
320322
323+ for (i = 0; i < f->opt_num; i++) {
324+ if (!f->opt[i].length || f->opt[i].length > MAX_IPOPTLEN)
325+ return -EINVAL;
326+ if (f->opt[i].kind == OSFOPT_MSS && f->opt[i].length < 4)
327+ return -EINVAL;
328+
329+ tot_opt_len += f->opt[i].length;
330+ if (tot_opt_len > MAX_IPOPTLEN)
331+ return -EINVAL;
332+ }
333+
321334 if (!memchr(f->genre, 0, MAXGENRELEN) ||
322335 !memchr(f->subtype, 0, MAXGENRELEN) ||
323336 !memchr(f->version, 0, MAXGENRELEN))
net/netfilter/nft_ct.c+4−0
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 #include <net/netfilter/nf_conntrack_l4proto.h>
2424 #include <net/netfilter/nf_conntrack_expect.h>
2525 #include <net/netfilter/nf_conntrack_seqadj.h>
26+#include "nf_internals.h"
2627
2728 struct nft_ct_helper_obj {
2829 struct nf_conntrack_helper *helper4;
@@ -543,6 +544,7 @@ static void __nft_ct_set_destroy(const struct nft_ctx *ctx, struct nft_ct *priv) · 514 unmodified lines
543544 #endif
544545 #ifdef CONFIG_NF_CONNTRACK_ZONES
545546 case NFT_CT_ZONE:
547+ nf_queue_nf_hook_drop(ctx->net);
546548 mutex_lock(&nft_ct_pcpu_mutex);
547549 if (--nft_ct_pcpu_template_refcnt == 0)
548550 nft_ct_tmpl_put_pcpu();
@@ -1015,6 +1017,7 @@ static void nft_ct_timeout_obj_destroy(const struct nft_ctx *ctx, · 466 unmodified lines
10151017 struct nft_ct_timeout_obj *priv = nft_obj_data(obj);
10161018 struct nf_ct_timeout *timeout = priv->timeout;
10171019
1020+ nf_queue_nf_hook_drop(ctx->net);
10181021 nf_ct_untimeout(ctx->net, timeout);
10191022 nf_ct_netns_put(ctx->net, ctx->family);
10201023 kfree(priv->timeout);
@@ -1147,6 +1150,7 @@ static void nft_ct_helper_obj_destroy(const struct nft_ctx *ctx, · 126 unmodified lines
11471150 {
11481151 struct nft_ct_helper_obj *priv = nft_obj_data(obj);
11491152
1153+ nf_queue_nf_hook_drop(ctx->net);
11501154 if (priv->helper4)
11511155 nf_conntrack_helper_put(priv->helper4);
11521156 if (priv->helper6)
net/netfilter/nft_dynset.c+9−1
@@ -30,18 +30,26 @@ static int nft_dynset_expr_setup(const struct nft_dynset *priv, · 29 unmodified lines
3030 const struct nft_set_ext *ext)
3131 {
3232 struct nft_set_elem_expr *elem_expr = nft_set_ext_expr(ext);
33+ struct nft_ctx ctx = {
34+ .net = read_pnet(&priv->set->net),
35+ .family = priv->set->table->family,
36+ };
3337 struct nft_expr *expr;
3438 int i;
3539
3640 for (i = 0; i < priv->num_exprs; i++) {
3741 expr = nft_setelem_expr_at(elem_expr, elem_expr->size);
3842 if (nft_expr_clone(expr, priv->expr_array[i], GFP_ATOMIC) < 0)
39− return -1;
43+ goto err_out;
4044
4145 elem_expr->size += priv->expr_array[i]->ops->size;
4246 }
4347
4448 return 0;
49+err_out:
50+ nft_set_elem_expr_destroy(&ctx, elem_expr);
51+
52+ return -1;
4553 }
4654
4755 struct nft_elem_priv *nft_dynset_new(struct nft_set *set,
net/netfilter/nft_set_rbtree.c+10−61
@@ -304,19 +304,10 @@ static void nft_rbtree_set_start_cookie(struct nft_rbtree *priv, · 303 unmodified lines
304304 priv->start_rbe_cookie = (unsigned long)rbe;
305305 }
306306
307−static void nft_rbtree_set_start_cookie_open(struct nft_rbtree *priv,
308− const struct nft_rbtree_elem *rbe,
309− unsigned long open_interval)
310−{
311− priv->start_rbe_cookie = (unsigned long)rbe | open_interval;
312−}
313−
314−#define NFT_RBTREE_OPEN_INTERVAL 1UL
315−
316307 static bool nft_rbtree_cmp_start_cookie(struct nft_rbtree *priv,
317308 const struct nft_rbtree_elem *rbe)
318309 {
319− return (priv->start_rbe_cookie & ~NFT_RBTREE_OPEN_INTERVAL) == (unsigned long)rbe;
310+ return priv->start_rbe_cookie == (unsigned long)rbe;
320311 }
321312
322313 static bool nft_rbtree_insert_same_interval(const struct net *net,
@@ -346,14 +337,13 @@ static bool nft_rbtree_insert_same_interval(const struct net *net, · 23 unmodified lines
346337
347338 static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set,
348339 struct nft_rbtree_elem *new,
349− struct nft_elem_priv **elem_priv, u64 tstamp, bool last)
340+ struct nft_elem_priv **elem_priv, u64 tstamp)
350341 {
351342 struct nft_rbtree_elem *rbe, *rbe_le = NULL, *rbe_ge = NULL, *rbe_prev;
352343 struct rb_node *node, *next, *parent, **p, *first = NULL;
353344 struct nft_rbtree *priv = nft_set_priv(set);
354345 u8 cur_genmask = nft_genmask_cur(net);
355346 u8 genmask = nft_genmask_next(net);
356− unsigned long open_interval = 0;
357347 int d;
358348
359349 /* Descend the tree to search for an existing element greater than the
@@ -459,18 +449,10 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set, · 99 unmodified lines
459449 }
460450 }
461451
462− if (nft_rbtree_interval_null(set, new)) {
452+ if (nft_rbtree_interval_null(set, new))
453+ priv->start_rbe_cookie = 0;
454+ else if (nft_rbtree_interval_start(new) && priv->start_rbe_cookie)
463455 priv->start_rbe_cookie = 0;
464− } else if (nft_rbtree_interval_start(new) && priv->start_rbe_cookie) {
465− if (nft_set_is_anonymous(set)) {
466− priv->start_rbe_cookie = 0;
467− } else if (priv->start_rbe_cookie & NFT_RBTREE_OPEN_INTERVAL) {
468− /* Previous element is an open interval that partially
469− * overlaps with an existing non-open interval.
470− */
471− return -ENOTEMPTY;
472− }
473− }
474456
475457 /* - new start element matching existing start element: full overlap
476458 * reported as -EEXIST, cleared by caller if NLM_F_EXCL is not given.
@@ -478,27 +460,7 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set, · 1 unmodified line
478460 if (rbe_ge && !nft_rbtree_cmp(set, new, rbe_ge) &&
479461 nft_rbtree_interval_start(rbe_ge) == nft_rbtree_interval_start(new)) {
480462 *elem_priv = &rbe_ge->priv;
481−
482− /* - Corner case: new start element of open interval (which
483− * comes as last element in the batch) overlaps the start of
484− * an existing interval with an end element: partial overlap.
485− */
486− node = rb_first(&priv->root);
487− rbe = __nft_rbtree_next_active(node, genmask);
488− if (rbe && nft_rbtree_interval_end(rbe)) {
489− rbe = nft_rbtree_next_active(rbe, genmask);
490− if (rbe &&
491− nft_rbtree_interval_start(rbe) &&
492− !nft_rbtree_cmp(set, new, rbe)) {
493− if (last)
494− return -ENOTEMPTY;
495−
496− /* Maybe open interval? */
497− open_interval = NFT_RBTREE_OPEN_INTERVAL;
498− }
499− }
500− nft_rbtree_set_start_cookie_open(priv, rbe_ge, open_interval);
501−
463+ nft_rbtree_set_start_cookie(priv, rbe_ge);
502464 return -EEXIST;
503465 }
504466
@@ -553,12 +515,6 @@ static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set, · 48 unmodified lines
553515 nft_rbtree_interval_end(rbe_ge) && nft_rbtree_interval_end(new))
554516 return -ENOTEMPTY;
555517
556− /* - start element overlaps an open interval but end element is new:
557− * partial overlap, reported as -ENOEMPTY.
558− */
559− if (!rbe_ge && priv->start_rbe_cookie && nft_rbtree_interval_end(new))
560− return -ENOTEMPTY;
561−
562518 /* Accepted element: pick insertion point depending on key value */
563519 parent = NULL;
564520 p = &priv->root.rb_node;
@@ -668,7 +624,6 @@ static int nft_rbtree_insert(const struct net *net, const struct nft_set *set, · 103 unmodified lines
668624 struct nft_elem_priv **elem_priv)
669625 {
670626 struct nft_rbtree_elem *rbe = nft_elem_priv_cast(elem->priv);
671− bool last = !!(elem->flags & NFT_SET_ELEM_INTERNAL_LAST);
672627 struct nft_rbtree *priv = nft_set_priv(set);
673628 u64 tstamp = nft_net_tstamp(net);
674629 int err;
@@ -685,12 +640,8 @@ static int nft_rbtree_insert(const struct net *net, const struct nft_set *set, · 10 unmodified lines
685640 cond_resched();
686641
687642 write_lock_bh(&priv->lock);
688− err = __nft_rbtree_insert(net, set, rbe, elem_priv, tstamp, last);
643+ err = __nft_rbtree_insert(net, set, rbe, elem_priv, tstamp);
689644 write_unlock_bh(&priv->lock);
690−
691− if (nft_rbtree_interval_end(rbe))
692− priv->start_rbe_cookie = 0;
693−
694645 } while (err == -EAGAIN);
695646
696647 return err;
@@ -778,7 +729,6 @@ nft_rbtree_deactivate(const struct net *net, const struct nft_set *set, · 81 unmodified lines
778729 const struct nft_set_elem *elem)
779730 {
780731 struct nft_rbtree_elem *rbe, *this = nft_elem_priv_cast(elem->priv);
781− bool last = !!(elem->flags & NFT_SET_ELEM_INTERNAL_LAST);
782732 struct nft_rbtree *priv = nft_set_priv(set);
783733 const struct rb_node *parent = priv->root.rb_node;
784734 u8 genmask = nft_genmask_next(net);
@@ -819,10 +769,9 @@ nft_rbtree_deactivate(const struct net *net, const struct nft_set *set, · 34 unmodified lines
819769 continue;
820770 }
821771
822− if (nft_rbtree_interval_start(rbe)) {
823− if (!last)
824− nft_rbtree_set_start_cookie(priv, rbe);
825− } else if (!nft_rbtree_deactivate_same_interval(net, priv, rbe))
772+ if (nft_rbtree_interval_start(rbe))
773+ nft_rbtree_set_start_cookie(priv, rbe);
774+ else if (!nft_rbtree_deactivate_same_interval(net, priv, rbe))
826775 return NULL;
827776
828777 nft_rbtree_flush(net, set, &rbe->priv);
net/netfilter/xt_CT.c+4−0
@@ -16,6 +16,7 @@ · 15 unmodified lines
1616 #include <net/netfilter/nf_conntrack_ecache.h>
1717 #include <net/netfilter/nf_conntrack_timeout.h>
1818 #include <net/netfilter/nf_conntrack_zones.h>
19+#include "nf_internals.h"
1920
2021 static inline int xt_ct_target(struct sk_buff *skb, struct nf_conn *ct)
2122 {
@@ -283,6 +284,9 @@ static void xt_ct_tg_destroy(const struct xt_tgdtor_param *par, · 261 unmodified lines
283284 struct nf_conn_help *help;
284285
285286 if (ct) {
287+ if (info->helper[0] || info->timeout[0])
288+ nf_queue_nf_hook_drop(par->net);
289+
286290 help = nfct_help(ct);
287291 xt_ct_put_helper(help);
288292
net/netfilter/xt_time.c+2−2
@@ -223,13 +223,13 @@ time_mt(const struct sk_buff *skb, struct xt_action_param *par) · 222 unmodified lines
223223
224224 localtime_2(&current_time, stamp);
225225
226− if (!(info->weekdays_match & (1 << current_time.weekday)))
226+ if (!(info->weekdays_match & (1U << current_time.weekday)))
227227 return false;
228228
229229 /* Do not spend time computing monthday if all days match anyway */
230230 if (info->monthdays_match != XT_TIME_ALL_MONTHDAYS) {
231231 localtime_3(&current_time, stamp);
232− if (!(info->monthdays_match & (1 << current_time.monthday)))
232+ if (!(info->monthdays_match & (1U << current_time.monthday)))
233233 return false;
234234 }
235235
net/phonet/af_phonet.c+4−1
@@ -129,9 +129,12 @@ static int pn_header_create(struct sk_buff *skb, struct net_device *dev, · 128 unmodified lines
129129 return 1;
130130 }
131131
132−static int pn_header_parse(const struct sk_buff *skb, unsigned char *haddr)
132+static int pn_header_parse(const struct sk_buff *skb,
133+ const struct net_device *dev,
134+ unsigned char *haddr)
133135 {
134136 const u8 *media = skb_mac_header(skb);
137+
135138 *haddr = *media;
136139 return 1;
137140 }
net/rose/af_rose.c+5−0
@@ -811,6 +811,11 @@ static int rose_connect(struct socket *sock, struct sockaddr_unsized *uaddr, int · 810 unmodified lines
811811 goto out_release;
812812 }
813813
814+ if (sk->sk_state == TCP_SYN_SENT) {
815+ err = -EALREADY;
816+ goto out_release;
817+ }
818+
814819 sk->sk_state = TCP_CLOSE;
815820 sock->state = SS_UNCONNECTED;
816821
net/sched/sch_generic.c+0−27
@@ -1288,33 +1288,6 @@ static void dev_deactivate_queue(struct net_device *dev, · 1287 unmodified lines
12881288 }
12891289 }
12901290
1291−static void dev_reset_queue(struct net_device *dev,
1292− struct netdev_queue *dev_queue,
1293− void *_unused)
1294−{
1295− struct Qdisc *qdisc;
1296− bool nolock;
1297−
1298− qdisc = rtnl_dereference(dev_queue->qdisc_sleeping);
1299− if (!qdisc)
1300− return;
1301−
1302− nolock = qdisc->flags & TCQ_F_NOLOCK;
1303−
1304− if (nolock)
1305− spin_lock_bh(&qdisc->seqlock);
1306− spin_lock_bh(qdisc_lock(qdisc));
1307−
1308− qdisc_reset(qdisc);
1309−
1310− spin_unlock_bh(qdisc_lock(qdisc));
1311− if (nolock) {
1312− clear_bit(__QDISC_STATE_MISSED, &qdisc->state);
1313− clear_bit(__QDISC_STATE_DRAINING, &qdisc->state);
1314− spin_unlock_bh(&qdisc->seqlock);
1315− }
1316−}
1317−
13181291 static bool some_qdisc_is_busy(struct net_device *dev)
13191292 {
13201293 unsigned int i;
net/sched/sch_ingress.c+8−6
@@ -113,14 +113,15 @@ static void ingress_destroy(struct Qdisc *sch) · 112 unmodified lines
113113 {
114114 struct ingress_sched_data *q = qdisc_priv(sch);
115115 struct net_device *dev = qdisc_dev(sch);
116− struct bpf_mprog_entry *entry = rtnl_dereference(dev->tcx_ingress);
116+ struct bpf_mprog_entry *entry;
117117
118118 if (sch->parent != TC_H_INGRESS)
119119 return;
120120
121121 tcf_block_put_ext(q->block, sch, &q->block_info);
122122
123− if (entry) {
123+ if (mini_qdisc_pair_inited(&q->miniqp)) {
124+ entry = rtnl_dereference(dev->tcx_ingress);
124125 tcx_miniq_dec(entry);
125126 if (!tcx_entry_is_active(entry)) {
126127 tcx_entry_update(dev, NULL, true);
@@ -290,10 +291,9 @@ static int clsact_init(struct Qdisc *sch, struct nlattr *opt, · 163 unmodified lines
290291
291292 static void clsact_destroy(struct Qdisc *sch)
292293 {
294+ struct bpf_mprog_entry *ingress_entry, *egress_entry;
293295 struct clsact_sched_data *q = qdisc_priv(sch);
294296 struct net_device *dev = qdisc_dev(sch);
295− struct bpf_mprog_entry *ingress_entry = rtnl_dereference(dev->tcx_ingress);
296− struct bpf_mprog_entry *egress_entry = rtnl_dereference(dev->tcx_egress);
297297
298298 if (sch->parent != TC_H_CLSACT)
299299 return;
@@ -301,7 +301,8 @@ static void clsact_destroy(struct Qdisc *sch) · 1 unmodified line
301301 tcf_block_put_ext(q->ingress_block, sch, &q->ingress_block_info);
302302 tcf_block_put_ext(q->egress_block, sch, &q->egress_block_info);
303303
304− if (ingress_entry) {
304+ if (mini_qdisc_pair_inited(&q->miniqp_ingress)) {
305+ ingress_entry = rtnl_dereference(dev->tcx_ingress);
305306 tcx_miniq_dec(ingress_entry);
306307 if (!tcx_entry_is_active(ingress_entry)) {
307308 tcx_entry_update(dev, NULL, true);
@@ -309,7 +310,8 @@ static void clsact_destroy(struct Qdisc *sch) · 1 unmodified line
309310 }
310311 }
311312
312− if (egress_entry) {
313+ if (mini_qdisc_pair_inited(&q->miniqp_egress)) {
314+ egress_entry = rtnl_dereference(dev->tcx_egress);
313315 tcx_miniq_dec(egress_entry);
314316 if (!tcx_entry_is_active(egress_entry)) {
315317 tcx_entry_update(dev, NULL, false);
net/sched/sch_teql.c+2−5
@@ -146,15 +146,12 @@ teql_destroy(struct Qdisc *sch) · 145 unmodified lines
146146 master->slaves = NEXT_SLAVE(q);
147147 if (q == master->slaves) {
148148 struct netdev_queue *txq;
149− spinlock_t *root_lock;
150149
151150 txq = netdev_get_tx_queue(master->dev, 0);
152151 master->slaves = NULL;
153152
154− root_lock = qdisc_root_sleeping_lock(rtnl_dereference(txq->qdisc));
155− spin_lock_bh(root_lock);
156− qdisc_reset(rtnl_dereference(txq->qdisc));
157− spin_unlock_bh(root_lock);
153+ dev_reset_queue(master->dev,
154+ txq, NULL);
158155 }
159156 }
160157 skb_queue_purge(&dat->q);
net/shaper/shaper.c+93−65
@@ -36,29 +36,26 @@ static struct net_shaper_binding *net_shaper_binding_from_ctx(void *ctx) · 35 unmodified lines
3636 return &((struct net_shaper_nl_ctx *)ctx)->binding;
3737 }
3838
39−static void net_shaper_lock(struct net_shaper_binding *binding)
39+static struct net_shaper_hierarchy *
40+net_shaper_hierarchy(struct net_shaper_binding *binding)
4041 {
41− switch (binding->type) {
42− case NET_SHAPER_BINDING_TYPE_NETDEV:
43− netdev_lock(binding->netdev);
44− break;
45− }
46−}
42+ /* Pairs with WRITE_ONCE() in net_shaper_hierarchy_setup. */
43+ if (binding->type == NET_SHAPER_BINDING_TYPE_NETDEV)
44+ return READ_ONCE(binding->netdev->net_shaper_hierarchy);
4745
48−static void net_shaper_unlock(struct net_shaper_binding *binding)
49−{
50− switch (binding->type) {
51− case NET_SHAPER_BINDING_TYPE_NETDEV:
52− netdev_unlock(binding->netdev);
53− break;
54− }
46+ /* No other type supported yet. */
47+ return NULL;
5548 }
5649
5750 static struct net_shaper_hierarchy *
58−net_shaper_hierarchy(struct net_shaper_binding *binding)
51+net_shaper_hierarchy_rcu(struct net_shaper_binding *binding)
5952 {
60− /* Pairs with WRITE_ONCE() in net_shaper_hierarchy_setup. */
61− if (binding->type == NET_SHAPER_BINDING_TYPE_NETDEV)
53+ /* Readers look up the device and take a ref, then take RCU lock
54+ * later at which point netdev may have been unregistered and flushed.
55+ * READ_ONCE() pairs with WRITE_ONCE() in net_shaper_hierarchy_setup.
56+ */
57+ if (binding->type == NET_SHAPER_BINDING_TYPE_NETDEV &&
58+ READ_ONCE(binding->netdev->reg_state) <= NETREG_REGISTERED)
6259 return READ_ONCE(binding->netdev->net_shaper_hierarchy);
6360
6461 /* No other type supported yet. */
@@ -204,12 +201,49 @@ static int net_shaper_ctx_setup(const struct genl_info *info, int type, · 139 unmodified lines
204201 return 0;
205202 }
206203
204+/* Like net_shaper_ctx_setup(), but for "write" handlers (never for dumps!)
205+ * Acquires the lock protecting the hierarchy (instance lock for netdev).
206+ */
207+static int net_shaper_ctx_setup_lock(const struct genl_info *info, int type,
208+ struct net_shaper_nl_ctx *ctx)
209+{
210+ struct net *ns = genl_info_net(info);
211+ struct net_device *dev;
212+ int ifindex;
213+
214+ if (GENL_REQ_ATTR_CHECK(info, type))
215+ return -EINVAL;
216+
217+ ifindex = nla_get_u32(info->attrs[type]);
218+ dev = netdev_get_by_index_lock(ns, ifindex);
219+ if (!dev) {
220+ NL_SET_BAD_ATTR(info->extack, info->attrs[type]);
221+ return -ENOENT;
222+ }
223+
224+ if (!dev->netdev_ops->net_shaper_ops) {
225+ NL_SET_BAD_ATTR(info->extack, info->attrs[type]);
226+ netdev_unlock(dev);
227+ return -EOPNOTSUPP;
228+ }
229+
230+ ctx->binding.type = NET_SHAPER_BINDING_TYPE_NETDEV;
231+ ctx->binding.netdev = dev;
232+ return 0;
233+}
234+
207235 static void net_shaper_ctx_cleanup(struct net_shaper_nl_ctx *ctx)
208236 {
209237 if (ctx->binding.type == NET_SHAPER_BINDING_TYPE_NETDEV)
210238 netdev_put(ctx->binding.netdev, &ctx->dev_tracker);
211239 }
212240
241+static void net_shaper_ctx_cleanup_unlock(struct net_shaper_nl_ctx *ctx)
242+{
243+ if (ctx->binding.type == NET_SHAPER_BINDING_TYPE_NETDEV)
244+ netdev_unlock(ctx->binding.netdev);
245+}
246+
213247 static u32 net_shaper_handle_to_index(const struct net_shaper_handle *handle)
214248 {
215249 return FIELD_PREP(NET_SHAPER_SCOPE_MASK, handle->scope) |
@@ -251,9 +285,10 @@ static struct net_shaper * · 35 unmodified lines
251285 net_shaper_lookup(struct net_shaper_binding *binding,
252286 const struct net_shaper_handle *handle)
253287 {
254− struct net_shaper_hierarchy *hierarchy = net_shaper_hierarchy(binding);
255288 u32 index = net_shaper_handle_to_index(handle);
289+ struct net_shaper_hierarchy *hierarchy;
256290
291+ hierarchy = net_shaper_hierarchy_rcu(binding);
257292 if (!hierarchy || xa_get_mark(&hierarchy->shapers, index,
258293 NET_SHAPER_NOT_VALID))
259294 return NULL;
@@ -262,7 +297,7 @@ net_shaper_lookup(struct net_shaper_binding *binding, · 2 unmodified lines
262297 }
263298
264299 /* Allocate on demand the per device shaper's hierarchy container.
265− * Called under the net shaper lock
300+ * Called under the lock protecting the hierarchy (instance lock for netdev)
266301 */
267302 static struct net_shaper_hierarchy *
268303 net_shaper_hierarchy_setup(struct net_shaper_binding *binding)
@@ -681,6 +716,22 @@ void net_shaper_nl_post_doit(const struct genl_split_ops *ops, · 412 unmodified lines
681716 net_shaper_generic_post(info);
682717 }
683718
719+int net_shaper_nl_pre_doit_write(const struct genl_split_ops *ops,
720+ struct sk_buff *skb, struct genl_info *info)
721+{
722+ struct net_shaper_nl_ctx *ctx = (struct net_shaper_nl_ctx *)info->ctx;
723+
724+ BUILD_BUG_ON(sizeof(*ctx) > sizeof(info->ctx));
725+
726+ return net_shaper_ctx_setup_lock(info, NET_SHAPER_A_IFINDEX, ctx);
727+}
728+
729+void net_shaper_nl_post_doit_write(const struct genl_split_ops *ops,
730+ struct sk_buff *skb, struct genl_info *info)
731+{
732+ net_shaper_ctx_cleanup_unlock((struct net_shaper_nl_ctx *)info->ctx);
733+}
734+
684735 int net_shaper_nl_pre_dumpit(struct netlink_callback *cb)
685736 {
686737 struct net_shaper_nl_ctx *ctx = (struct net_shaper_nl_ctx *)cb->ctx;
@@ -778,17 +829,19 @@ int net_shaper_nl_get_dumpit(struct sk_buff *skb, · 91 unmodified lines
778829
779830 /* Don't error out dumps performed before any set operation. */
780831 binding = net_shaper_binding_from_ctx(ctx);
781− hierarchy = net_shaper_hierarchy(binding);
782− if (!hierarchy)
783− return 0;
784832
785833 rcu_read_lock();
834+ hierarchy = net_shaper_hierarchy_rcu(binding);
835+ if (!hierarchy)
836+ goto out_unlock;
837+
786838 for (; (shaper = xa_find(&hierarchy->shapers, &ctx->start_index,
787839 U32_MAX, XA_PRESENT)); ctx->start_index++) {
788840 ret = net_shaper_fill_one(skb, binding, shaper, info);
789841 if (ret)
790842 break;
791843 }
844+out_unlock:
792845 rcu_read_unlock();
793846
794847 return ret;
@@ -806,45 +859,38 @@ int net_shaper_nl_set_doit(struct sk_buff *skb, struct genl_info *info) · 11 unmodified lines
806859
807860 binding = net_shaper_binding_from_ctx(info->ctx);
808861
809− net_shaper_lock(binding);
810862 ret = net_shaper_parse_info(binding, info->attrs, info, &shaper,
811863 &exists);
812864 if (ret)
813− goto unlock;
865+ return ret;
814866
815867 if (!exists)
816868 net_shaper_default_parent(&shaper.handle, &shaper.parent);
817869
818870 hierarchy = net_shaper_hierarchy_setup(binding);
819− if (!hierarchy) {
820− ret = -ENOMEM;
821− goto unlock;
822− }
871+ if (!hierarchy)
872+ return -ENOMEM;
823873
824874 /* The 'set' operation can't create node-scope shapers. */
825875 handle = shaper.handle;
826876 if (handle.scope == NET_SHAPER_SCOPE_NODE &&
827− !net_shaper_lookup(binding, &handle)) {
828− ret = -ENOENT;
829− goto unlock;
830− }
877+ !net_shaper_lookup(binding, &handle))
878+ return -ENOENT;
831879
832880 ret = net_shaper_pre_insert(binding, &handle, info->extack);
833881 if (ret)
834− goto unlock;
882+ return ret;
835883
836884 ops = net_shaper_ops(binding);
837885 ret = ops->set(binding, &shaper, info->extack);
838886 if (ret) {
839887 net_shaper_rollback(binding);
840− goto unlock;
888+ return ret;
841889 }
842890
843891 net_shaper_commit(binding, 1, &shaper);
844892
845−unlock:
846− net_shaper_unlock(binding);
847− return ret;
893+ return 0;
848894 }
849895
850896 static int __net_shaper_delete(struct net_shaper_binding *binding,
@@ -1072,35 +1118,26 @@ int net_shaper_nl_delete_doit(struct sk_buff *skb, struct genl_info *info) · 221 unmodified lines
10721118
10731119 binding = net_shaper_binding_from_ctx(info->ctx);
10741120
1075− net_shaper_lock(binding);
10761121 ret = net_shaper_parse_handle(info->attrs[NET_SHAPER_A_HANDLE], info,
10771122 &handle);
10781123 if (ret)
1079− goto unlock;
1124+ return ret;
10801125
10811126 hierarchy = net_shaper_hierarchy(binding);
1082− if (!hierarchy) {
1083− ret = -ENOENT;
1084− goto unlock;
1085− }
1127+ if (!hierarchy)
1128+ return -ENOENT;
10861129
10871130 shaper = net_shaper_lookup(binding, &handle);
1088− if (!shaper) {
1089− ret = -ENOENT;
1090− goto unlock;
1091− }
1131+ if (!shaper)
1132+ return -ENOENT;
10921133
10931134 if (handle.scope == NET_SHAPER_SCOPE_NODE) {
10941135 ret = net_shaper_pre_del_node(binding, shaper, info->extack);
10951136 if (ret)
1096− goto unlock;
1137+ return ret;
10971138 }
10981139
1099− ret = __net_shaper_delete(binding, shaper, info->extack);
1100−
1101−unlock:
1102− net_shaper_unlock(binding);
1103− return ret;
1140+ return __net_shaper_delete(binding, shaper, info->extack);
11041141 }
11051142
11061143 static int net_shaper_group_send_reply(struct net_shaper_binding *binding,
@@ -1149,21 +1186,17 @@ int net_shaper_nl_group_doit(struct sk_buff *skb, struct genl_info *info) · 42 unmodified lines
11491186 if (!net_shaper_ops(binding)->group)
11501187 return -EOPNOTSUPP;
11511188
1152− net_shaper_lock(binding);
11531189 leaves_count = net_shaper_list_len(info, NET_SHAPER_A_LEAVES);
11541190 if (!leaves_count) {
11551191 NL_SET_BAD_ATTR(info->extack,
11561192 info->attrs[NET_SHAPER_A_LEAVES]);
1157− ret = -EINVAL;
1158− goto unlock;
1193+ return -EINVAL;
11591194 }
11601195
11611196 leaves = kcalloc(leaves_count, sizeof(struct net_shaper) +
11621197 sizeof(struct net_shaper *), GFP_KERNEL);
1163− if (!leaves) {
1164− ret = -ENOMEM;
1165− goto unlock;
1166− }
1198+ if (!leaves)
1199+ return -ENOMEM;
11671200 old_nodes = (void *)&leaves[leaves_count];
11681201
11691202 ret = net_shaper_parse_node(binding, info->attrs, info, &node);
@@ -1240,9 +1273,6 @@ int net_shaper_nl_group_doit(struct sk_buff *skb, struct genl_info *info) · 70 unmodified lines
12401273
12411274 free_leaves:
12421275 kfree(leaves);
1243−
1244−unlock:
1245− net_shaper_unlock(binding);
12461276 return ret;
12471277
12481278 free_msg:
@@ -1352,14 +1382,12 @@ static void net_shaper_flush(struct net_shaper_binding *binding) · 103 unmodified lines
13521382 if (!hierarchy)
13531383 return;
13541384
1355− net_shaper_lock(binding);
13561385 xa_lock(&hierarchy->shapers);
13571386 xa_for_each(&hierarchy->shapers, index, cur) {
13581387 __xa_erase(&hierarchy->shapers, index);
13591388 kfree(cur);
13601389 }
13611390 xa_unlock(&hierarchy->shapers);
1362− net_shaper_unlock(binding);
13631391
13641392 kfree(hierarchy);
13651393 }
net/shaper/shaper_nl_gen.c+6−6
@@ -99,27 +99,27 @@ static const struct genl_split_ops net_shaper_nl_ops[] = { · 98 unmodified lines
9999 },
100100 {
101101 .cmd = NET_SHAPER_CMD_SET,
102− .pre_doit = net_shaper_nl_pre_doit,
102+ .pre_doit = net_shaper_nl_pre_doit_write,
103103 .doit = net_shaper_nl_set_doit,
104− .post_doit = net_shaper_nl_post_doit,
104+ .post_doit = net_shaper_nl_post_doit_write,
105105 .policy = net_shaper_set_nl_policy,
106106 .maxattr = NET_SHAPER_A_IFINDEX,
107107 .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
108108 },
109109 {
110110 .cmd = NET_SHAPER_CMD_DELETE,
111− .pre_doit = net_shaper_nl_pre_doit,
111+ .pre_doit = net_shaper_nl_pre_doit_write,
112112 .doit = net_shaper_nl_delete_doit,
113− .post_doit = net_shaper_nl_post_doit,
113+ .post_doit = net_shaper_nl_post_doit_write,
114114 .policy = net_shaper_delete_nl_policy,
115115 .maxattr = NET_SHAPER_A_IFINDEX,
116116 .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
117117 },
118118 {
119119 .cmd = NET_SHAPER_CMD_GROUP,
120− .pre_doit = net_shaper_nl_pre_doit,
120+ .pre_doit = net_shaper_nl_pre_doit_write,
121121 .doit = net_shaper_nl_group_doit,
122− .post_doit = net_shaper_nl_post_doit,
122+ .post_doit = net_shaper_nl_post_doit_write,
123123 .policy = net_shaper_group_nl_policy,
124124 .maxattr = NET_SHAPER_A_LEAVES,
125125 .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
net/shaper/shaper_nl_gen.h+5−0
@@ -18,12 +18,17 @@ extern const struct nla_policy net_shaper_leaf_info_nl_policy[NET_SHAPER_A_WEIGH · 17 unmodified lines
1818
1919 int net_shaper_nl_pre_doit(const struct genl_split_ops *ops,
2020 struct sk_buff *skb, struct genl_info *info);
21+int net_shaper_nl_pre_doit_write(const struct genl_split_ops *ops,
22+ struct sk_buff *skb, struct genl_info *info);
2123 int net_shaper_nl_cap_pre_doit(const struct genl_split_ops *ops,
2224 struct sk_buff *skb, struct genl_info *info);
2325 void
2426 net_shaper_nl_post_doit(const struct genl_split_ops *ops, struct sk_buff *skb,
2527 struct genl_info *info);
2628 void
29+net_shaper_nl_post_doit_write(const struct genl_split_ops *ops,
30+ struct sk_buff *skb, struct genl_info *info);
31+void
2732 net_shaper_nl_cap_post_doit(const struct genl_split_ops *ops,
2833 struct sk_buff *skb, struct genl_info *info);
2934 int net_shaper_nl_pre_dumpit(struct netlink_callback *cb);
net/smc/af_smc.c+17−6
@@ -131,7 +131,14 @@ static struct sock *smc_tcp_syn_recv_sock(const struct sock *sk, · 130 unmodified lines
131131 struct smc_sock *smc;
132132 struct sock *child;
133133
134− smc = smc_clcsock_user_data(sk);
134+ rcu_read_lock();
135+ smc = smc_clcsock_user_data_rcu(sk);
136+ if (!smc || !refcount_inc_not_zero(&smc->sk.sk_refcnt)) {
137+ rcu_read_unlock();
138+ smc = NULL;
139+ goto drop;
140+ }
141+ rcu_read_unlock();
135142
136143 if (READ_ONCE(sk->sk_ack_backlog) + atomic_read(&smc->queued_smc_hs) >
137144 sk->sk_max_ack_backlog)
@@ -153,11 +160,14 @@ static struct sock *smc_tcp_syn_recv_sock(const struct sock *sk, · 15 unmodified lines
153160 if (inet_csk(child)->icsk_af_ops == inet_csk(sk)->icsk_af_ops)
154161 inet_csk(child)->icsk_af_ops = smc->ori_af_ops;
155162 }
163+ sock_put(&smc->sk);
156164 return child;
157165
158166 drop:
159167 dst_release(dst);
160168 tcp_listendrop(sk);
169+ if (smc)
170+ sock_put(&smc->sk);
161171 return NULL;
162172 }
163173
@@ -254,7 +264,7 @@ static void smc_fback_restore_callbacks(struct smc_sock *smc) · 90 unmodified lines
254264 struct sock *clcsk = smc->clcsock->sk;
255265
256266 write_lock_bh(&clcsk->sk_callback_lock);
257− clcsk->sk_user_data = NULL;
267+ rcu_assign_sk_user_data(clcsk, NULL);
258268
259269 smc_clcsock_restore_cb(&clcsk->sk_state_change, &smc->clcsk_state_change);
260270 smc_clcsock_restore_cb(&clcsk->sk_data_ready, &smc->clcsk_data_ready);
@@ -902,7 +912,7 @@ static void smc_fback_replace_callbacks(struct smc_sock *smc) · 641 unmodified lines
902912 struct sock *clcsk = smc->clcsock->sk;
903913
904914 write_lock_bh(&clcsk->sk_callback_lock);
905− clcsk->sk_user_data = (void *)((uintptr_t)smc | SK_USER_DATA_NOCOPY);
915+ __rcu_assign_sk_user_data_with_flags(clcsk, smc, SK_USER_DATA_NOCOPY);
906916
907917 smc_clcsock_replace_cb(&clcsk->sk_state_change, smc_fback_state_change,
908918 &smc->clcsk_state_change);
@@ -2665,8 +2675,8 @@ int smc_listen(struct socket *sock, int backlog) · 1756 unmodified lines
26652675 * smc-specific sk_data_ready function
26662676 */
26672677 write_lock_bh(&smc->clcsock->sk->sk_callback_lock);
2668− smc->clcsock->sk->sk_user_data =
2669− (void *)((uintptr_t)smc | SK_USER_DATA_NOCOPY);
2678+ __rcu_assign_sk_user_data_with_flags(smc->clcsock->sk, smc,
2679+ SK_USER_DATA_NOCOPY);
26702680 smc_clcsock_replace_cb(&smc->clcsock->sk->sk_data_ready,
26712681 smc_clcsock_data_ready, &smc->clcsk_data_ready);
26722682 write_unlock_bh(&smc->clcsock->sk->sk_callback_lock);
@@ -2687,10 +2697,11 @@ int smc_listen(struct socket *sock, int backlog) · 14 unmodified lines
26872697 write_lock_bh(&smc->clcsock->sk->sk_callback_lock);
26882698 smc_clcsock_restore_cb(&smc->clcsock->sk->sk_data_ready,
26892699 &smc->clcsk_data_ready);
2690− smc->clcsock->sk->sk_user_data = NULL;
2700+ rcu_assign_sk_user_data(smc->clcsock->sk, NULL);
26912701 write_unlock_bh(&smc->clcsock->sk->sk_callback_lock);
26922702 goto out;
26932703 }
2704+ sock_set_flag(sk, SOCK_RCU_FREE);
26942705 sk->sk_max_ack_backlog = backlog;
26952706 sk->sk_ack_backlog = 0;
26962707 sk->sk_state = SMC_LISTEN;
net/smc/smc.h+5−0
@@ -346,6 +346,11 @@ static inline struct smc_sock *smc_clcsock_user_data(const struct sock *clcsk) · 345 unmodified lines
346346 ((uintptr_t)clcsk->sk_user_data & ~SK_USER_DATA_NOCOPY);
347347 }
348348
349+static inline struct smc_sock *smc_clcsock_user_data_rcu(const struct sock *clcsk)
350+{
351+ return (struct smc_sock *)rcu_dereference_sk_user_data(clcsk);
352+}
353+
349354 /* save target_cb in saved_cb, and replace target_cb with new_cb */
350355 static inline void smc_clcsock_replace_cb(void (**target_cb)(struct sock *),
351356 void (*new_cb)(struct sock *),
net/smc/smc_close.c+1−1
@@ -218,7 +218,7 @@ again: · 217 unmodified lines
218218 write_lock_bh(&smc->clcsock->sk->sk_callback_lock);
219219 smc_clcsock_restore_cb(&smc->clcsock->sk->sk_data_ready,
220220 &smc->clcsk_data_ready);
221− smc->clcsock->sk->sk_user_data = NULL;
221+ rcu_assign_sk_user_data(smc->clcsock->sk, NULL);
222222 write_unlock_bh(&smc->clcsock->sk->sk_callback_lock);
223223 rc = kernel_sock_shutdown(smc->clcsock, SHUT_RDWR);
224224 }
net/sunrpc/cache.c+21−5
@@ -1062,14 +1062,25 @@ static int cache_release(struct inode *inode, struct file *filp, · 1061 unmodified lines
10621062 struct cache_reader *rp = filp->private_data;
10631063
10641064 if (rp) {
1065+ struct cache_request *rq = NULL;
1066+
10651067 spin_lock(&queue_lock);
10661068 if (rp->offset) {
10671069 struct cache_queue *cq;
1068− for (cq= &rp->q; &cq->list != &cd->queue;
1069− cq = list_entry(cq->list.next, struct cache_queue, list))
1070+ for (cq = &rp->q; &cq->list != &cd->queue;
1071+ cq = list_entry(cq->list.next,
1072+ struct cache_queue, list))
10701073 if (!cq->reader) {
1071− container_of(cq, struct cache_request, q)
1072− ->readers--;
1074+ struct cache_request *cr =
1075+ container_of(cq,
1076+ struct cache_request, q);
1077+ cr->readers--;
1078+ if (cr->readers == 0 &&
1079+ !test_bit(CACHE_PENDING,
1080+ &cr->item->flags)) {
1081+ list_del(&cr->q.list);
1082+ rq = cr;
1083+ }
10731084 break;
10741085 }
10751086 rp->offset = 0;
@@ -1077,9 +1088,14 @@ static int cache_release(struct inode *inode, struct file *filp, · 1 unmodified line
10771088 list_del(&rp->q.list);
10781089 spin_unlock(&queue_lock);
10791090
1091+ if (rq) {
1092+ cache_put(rq->item, cd);
1093+ kfree(rq->buf);
1094+ kfree(rq);
1095+ }
1096+
10801097 filp->private_data = NULL;
10811098 kfree(rp);
1082−
10831099 }
10841100 if (filp->f_mode & FMODE_WRITE) {
10851101 atomic_dec(&cd->writers);
net/unix/af_unix.c+2−0
@@ -1958,6 +1958,8 @@ static void unix_detach_fds(struct scm_cookie *scm, struct sk_buff *skb) · 1957 unmodified lines
19581958 static void unix_peek_fds(struct scm_cookie *scm, struct sk_buff *skb)
19591959 {
19601960 scm->fp = scm_fp_dup(UNIXCB(skb).fp);
1961+
1962+ unix_peek_fpl(scm->fp);
19611963 }
19621964
19631965 static void unix_destruct_scm(struct sk_buff *skb)
net/unix/af_unix.h+1−0
@@ -29,6 +29,7 @@ void unix_del_edges(struct scm_fp_list *fpl); · 28 unmodified lines
2929 void unix_update_edges(struct unix_sock *receiver);
3030 int unix_prepare_fpl(struct scm_fp_list *fpl);
3131 void unix_destroy_fpl(struct scm_fp_list *fpl);
32+void unix_peek_fpl(struct scm_fp_list *fpl);
3233 void unix_schedule_gc(struct user_struct *user);
3334
3435 /* SOCK_DIAG */
net/unix/garbage.c+51−28
@@ -318,6 +318,25 @@ void unix_destroy_fpl(struct scm_fp_list *fpl) · 317 unmodified lines
318318 unix_free_vertices(fpl);
319319 }
320320
321+static bool gc_in_progress;
322+static seqcount_t unix_peek_seq = SEQCNT_ZERO(unix_peek_seq);
323+
324+void unix_peek_fpl(struct scm_fp_list *fpl)
325+{
326+ static DEFINE_SPINLOCK(unix_peek_lock);
327+
328+ if (!fpl || !fpl->count_unix)
329+ return;
330+
331+ if (!READ_ONCE(gc_in_progress))
332+ return;
333+
334+ /* Invalidate the final refcnt check in unix_vertex_dead(). */
335+ spin_lock(&unix_peek_lock);
336+ raw_write_seqcount_barrier(&unix_peek_seq);
337+ spin_unlock(&unix_peek_lock);
338+}
339+
321340 static bool unix_vertex_dead(struct unix_vertex *vertex)
322341 {
323342 struct unix_edge *edge;
@@ -351,6 +370,36 @@ static bool unix_vertex_dead(struct unix_vertex *vertex) · 27 unmodified lines
351370 return true;
352371 }
353372
373+static LIST_HEAD(unix_visited_vertices);
374+static unsigned long unix_vertex_grouped_index = UNIX_VERTEX_INDEX_MARK2;
375+
376+static bool unix_scc_dead(struct list_head *scc, bool fast)
377+{
378+ struct unix_vertex *vertex;
379+ bool scc_dead = true;
380+ unsigned int seq;
381+
382+ seq = read_seqcount_begin(&unix_peek_seq);
383+
384+ list_for_each_entry_reverse(vertex, scc, scc_entry) {
385+ /* Don't restart DFS from this vertex. */
386+ list_move_tail(&vertex->entry, &unix_visited_vertices);
387+
388+ /* Mark vertex as off-stack for __unix_walk_scc(). */
389+ if (!fast)
390+ vertex->index = unix_vertex_grouped_index;
391+
392+ if (scc_dead)
393+ scc_dead = unix_vertex_dead(vertex);
394+ }
395+
396+ /* If MSG_PEEK intervened, defer this SCC to the next round. */
397+ if (read_seqcount_retry(&unix_peek_seq, seq))
398+ return false;
399+
400+ return scc_dead;
401+}
402+
354403 static void unix_collect_skb(struct list_head *scc, struct sk_buff_head *hitlist)
355404 {
356405 struct unix_vertex *vertex;
@@ -404,9 +453,6 @@ static bool unix_scc_cyclic(struct list_head *scc) · 47 unmodified lines
404453 return false;
405454 }
406455
407−static LIST_HEAD(unix_visited_vertices);
408−static unsigned long unix_vertex_grouped_index = UNIX_VERTEX_INDEX_MARK2;
409−
410456 static unsigned long __unix_walk_scc(struct unix_vertex *vertex,
411457 unsigned long *last_index,
412458 struct sk_buff_head *hitlist)
@@ -474,9 +520,7 @@ prev_vertex: · 61 unmodified lines
474520 }
475521
476522 if (vertex->index == vertex->scc_index) {
477− struct unix_vertex *v;
478523 struct list_head scc;
479− bool scc_dead = true;
480524
481525 /* SCC finalised.
482526 *
@@ -485,18 +529,7 @@ prev_vertex: · 2 unmodified lines
485529 */
486530 __list_cut_position(&scc, &vertex_stack, &vertex->scc_entry);
487531
488− list_for_each_entry_reverse(v, &scc, scc_entry) {
489− /* Don't restart DFS from this vertex in unix_walk_scc(). */
490− list_move_tail(&v->entry, &unix_visited_vertices);
491−
492− /* Mark vertex as off-stack. */
493− v->index = unix_vertex_grouped_index;
494−
495− if (scc_dead)
496− scc_dead = unix_vertex_dead(v);
497− }
498−
499− if (scc_dead) {
532+ if (unix_scc_dead(&scc, false)) {
500533 unix_collect_skb(&scc, hitlist);
501534 } else {
502535 if (unix_vertex_max_scc_index < vertex->scc_index)
@@ -550,19 +583,11 @@ static void unix_walk_scc_fast(struct sk_buff_head *hitlist) · 47 unmodified lines
550583 while (!list_empty(&unix_unvisited_vertices)) {
551584 struct unix_vertex *vertex;
552585 struct list_head scc;
553− bool scc_dead = true;
554586
555587 vertex = list_first_entry(&unix_unvisited_vertices, typeof(*vertex), entry);
556588 list_add(&scc, &vertex->scc_entry);
557589
558− list_for_each_entry_reverse(vertex, &scc, scc_entry) {
559− list_move_tail(&vertex->entry, &unix_visited_vertices);
560−
561− if (scc_dead)
562− scc_dead = unix_vertex_dead(vertex);
563− }
564−
565− if (scc_dead) {
590+ if (unix_scc_dead(&scc, true)) {
566591 cyclic_sccs--;
567592 unix_collect_skb(&scc, hitlist);
568593 }
@@ -577,8 +602,6 @@ static void unix_walk_scc_fast(struct sk_buff_head *hitlist) · 8 unmodified lines
577602 cyclic_sccs ? UNIX_GRAPH_CYCLIC : UNIX_GRAPH_NOT_CYCLIC);
578603 }
579604
580−static bool gc_in_progress;
581−
582605 static void unix_gc(struct work_struct *work)
583606 {
584607 struct sk_buff_head hitlist;
net/wireless/pmsr.c+1−0
@@ -664,6 +664,7 @@ void cfg80211_pmsr_wdev_down(struct wireless_dev *wdev) · 663 unmodified lines
664664 }
665665 spin_unlock_bh(&wdev->pmsr_lock);
666666
667+ cancel_work_sync(&wdev->pmsr_free_wk);
667668 if (found)
668669 cfg80211_pmsr_process_abort(wdev);
669670
scripts/livepatch/klp-build+4−5
@@ -285,15 +285,14 @@ set_module_name() { · 284 unmodified lines
285285 # application from appending it with '+' due to a dirty git working tree.
286286 set_kernelversion() {
287287 local file="$SRC/scripts/setlocalversion"
288− local localversion
288+ local kernelrelease
289289
290290 stash_file "$file"
291291
292− localversion="$(cd "$SRC" && make --no-print-directory kernelversion)"
293− localversion="$(cd "$SRC" && KERNELVERSION="$localversion" ./scripts/setlocalversion)"
294− [[ -z "$localversion" ]] && die "setlocalversion failed"
292+ kernelrelease="$(cd "$SRC" && make syncconfig &>/dev/null && make -s kernelrelease)"
293+ [[ -z "$kernelrelease" ]] && die "failed to get kernel version"
295294
296− sed -i "2i echo $localversion; exit 0" scripts/setlocalversion
295+ sed -i "2i echo $kernelrelease; exit 0" scripts/setlocalversion
297296 }
298297
299298 get_patch_files() {
sound/soc/samsung/i2s.c+3−3
@@ -1360,10 +1360,10 @@ static int i2s_create_secondary_device(struct samsung_i2s_priv *priv) · 1359 unmodified lines
13601360 if (!pdev_sec)
13611361 return -ENOMEM;
13621362
1363− pdev_sec->driver_override = kstrdup("samsung-i2s", GFP_KERNEL);
1364− if (!pdev_sec->driver_override) {
1363+ ret = device_set_driver_override(&pdev_sec->dev, "samsung-i2s");
1364+ if (ret) {
13651365 platform_device_put(pdev_sec);
1366− return -ENOMEM;
1366+ return ret;
13671367 }
13681368
13691369 ret = platform_device_add(pdev_sec);
tools/bootconfig/main.c+5−2
@@ -162,8 +162,11 @@ static int load_xbc_file(const char *path, char **buf) · 161 unmodified lines
162162 if (fd < 0)
163163 return -errno;
164164 ret = fstat(fd, &stat);
165− if (ret < 0)
166− return -errno;
165+ if (ret < 0) {
166+ ret = -errno;
167+ close(fd);
168+ return ret;
169+ }
167170
168171 ret = load_xbc_fd(fd, buf, stat.st_size);
169172
tools/objtool/check.c+2−3
@@ -2184,12 +2184,11 @@ static void mark_func_jump_tables(struct objtool_file *file, · 2183 unmodified lines
21842184 last = insn;
21852185
21862186 /*
2187− * Store back-pointers for unconditional forward jumps such
2187+ * Store back-pointers for forward jumps such
21882188 * that find_jump_table() can back-track using those and
21892189 * avoid some potentially confusing code.
21902190 */
2191− if (insn->type == INSN_JUMP_UNCONDITIONAL && insn->jump_dest &&
2192− insn->offset > last->offset &&
2191+ if (insn->jump_dest &&
21932192 insn->jump_dest->offset > insn->offset &&
21942193 !insn->jump_dest->first_jump_src) {
21952194
tools/objtool/elf.c+3−20
@@ -16,7 +16,6 @@ · 15 unmodified lines
1616 #include <string.h>
1717 #include <unistd.h>
1818 #include <errno.h>
19−#include <libgen.h>
2019 #include <ctype.h>
2120 #include <linux/align.h>
2221 #include <linux/kernel.h>
@@ -1189,7 +1188,7 @@ err: · 1166 unmodified lines
11891188 struct elf *elf_create_file(GElf_Ehdr *ehdr, const char *name)
11901189 {
11911190 struct section *null, *symtab, *strtab, *shstrtab;
1192− char *dir, *base, *tmp_name;
1191+ char *tmp_name;
11931192 struct symbol *sym;
11941193 struct elf *elf;
11951194
@@ -1203,29 +1202,13 @@ struct elf *elf_create_file(GElf_Ehdr *ehdr, const char *name) · 7 unmodified lines
12031202
12041203 INIT_LIST_HEAD(&elf->sections);
12051204
1206− dir = strdup(name);
1207− if (!dir) {
1208− ERROR_GLIBC("strdup");
1209− return NULL;
1210− }
1211−
1212− dir = dirname(dir);
1213−
1214− base = strdup(name);
1215− if (!base) {
1216− ERROR_GLIBC("strdup");
1217− return NULL;
1218− }
1219−
1220− base = basename(base);
1221−
1222− tmp_name = malloc(256);
1205+ tmp_name = malloc(strlen(name) + 8);
12231206 if (!tmp_name) {
12241207 ERROR_GLIBC("malloc");
12251208 return NULL;
12261209 }
12271210
1228− snprintf(tmp_name, 256, "%s/%s.XXXXXX", dir, base);
1211+ sprintf(tmp_name, "%s.XXXXXX", name);
12291212
12301213 elf->fd = mkstemp(tmp_name);
12311214 if (elf->fd == -1) {
tools/objtool/klp-diff.c+2−1
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 #include <objtool/util.h>
1515 #include <arch/special.h>
1616
17+#include <linux/align.h>
1718 #include <linux/objtool_types.h>
1819 #include <linux/livepatch_external.h>
1920 #include <linux/stringify.h>
@@ -560,7 +561,7 @@ static struct symbol *__clone_symbol(struct elf *elf, struct symbol *patched_sym · 540 unmodified lines
560561 }
561562
562563 if (!is_sec_sym(patched_sym))
563− offset = sec_size(out_sec);
564+ offset = ALIGN(sec_size(out_sec), out_sec->sh.sh_addralign);
564565
565566 if (patched_sym->len || is_sec_sym(patched_sym)) {
566567 void *data = NULL;
tools/testing/selftests/bpf/Makefile+1−1
@@ -409,7 +409,7 @@ $(RESOLVE_BTFIDS): $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/resolve_btfids \ · 408 unmodified lines
409409 CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" \
410410 LIBBPF_INCLUDE=$(HOST_INCLUDE_DIR) \
411411 EXTRA_LDFLAGS='$(SAN_LDFLAGS) $(EXTRA_LDFLAGS)' \
412− HOSTPKG_CONFIG=$(PKG_CONFIG) \
412+ HOSTPKG_CONFIG='$(PKG_CONFIG)' \
413413 OUTPUT=$(HOST_BUILD_DIR)/resolve_btfids/ BPFOBJ=$(HOST_BPFOBJ)
414414
415415 # Get Clang's default includes on this system, as opposed to those seen by
tools/testing/selftests/bpf/progs/exceptions_fail.c+53−3
@@ -8,6 +8,11 @@ · 7 unmodified lines
88 #include "bpf_experimental.h"
99
1010 extern void bpf_rcu_read_lock(void) __ksym;
11+extern void bpf_rcu_read_unlock(void) __ksym;
12+extern void bpf_preempt_disable(void) __ksym;
13+extern void bpf_preempt_enable(void) __ksym;
14+extern void bpf_local_irq_save(unsigned long *) __ksym;
15+extern void bpf_local_irq_restore(unsigned long *) __ksym;
1116
1217 #define private(name) SEC(".bss." #name) __hidden __attribute__((aligned(8)))
1318
@@ -131,7 +136,7 @@ int reject_subprog_with_lock(void *ctx) · 117 unmodified lines
131136 }
132137
133138 SEC("?tc")
134−__failure __msg("BPF_EXIT instruction in main prog cannot be used inside bpf_rcu_read_lock-ed region")
139+__failure __msg("bpf_throw cannot be used inside bpf_rcu_read_lock-ed region")
135140 int reject_with_rcu_read_lock(void *ctx)
136141 {
137142 bpf_rcu_read_lock();
@@ -147,11 +152,13 @@ __noinline static int throwing_subprog(struct __sk_buff *ctx) · 9 unmodified lines
147152 }
148153
149154 SEC("?tc")
150−__failure __msg("BPF_EXIT instruction in main prog cannot be used inside bpf_rcu_read_lock-ed region")
155+__failure __msg("bpf_throw cannot be used inside bpf_rcu_read_lock-ed region")
151156 int reject_subprog_with_rcu_read_lock(void *ctx)
152157 {
153158 bpf_rcu_read_lock();
154− return throwing_subprog(ctx);
159+ throwing_subprog(ctx);
160+ bpf_rcu_read_unlock();
161+ return 0;
155162 }
156163
157164 static bool rbless(struct bpf_rb_node *n1, const struct bpf_rb_node *n2)
@@ -346,4 +353,47 @@ int reject_exception_throw_cb_diff(struct __sk_buff *ctx) · 188 unmodified lines
346353 return 0;
347354 }
348355
356+__noinline static int always_throws(void)
357+{
358+ bpf_throw(0);
359+ return 0;
360+}
361+
362+__noinline static int rcu_lock_then_throw(void)
363+{
364+ bpf_rcu_read_lock();
365+ bpf_throw(0);
366+ return 0;
367+}
368+
369+SEC("?tc")
370+__failure __msg("bpf_throw cannot be used inside bpf_rcu_read_lock-ed region")
371+int reject_subprog_rcu_lock_throw(void *ctx)
372+{
373+ rcu_lock_then_throw();
374+ return 0;
375+}
376+
377+SEC("?tc")
378+__failure __msg("bpf_throw cannot be used inside bpf_preempt_disable-ed region")
379+int reject_subprog_throw_preempt_lock(void *ctx)
380+{
381+ bpf_preempt_disable();
382+ always_throws();
383+ bpf_preempt_enable();
384+ return 0;
385+}
386+
387+SEC("?tc")
388+__failure __msg("bpf_throw cannot be used inside bpf_local_irq_save-ed region")
389+int reject_subprog_throw_irq_lock(void *ctx)
390+{
391+ unsigned long flags;
392+
393+ bpf_local_irq_save(&flags);
394+ always_throws();
395+ bpf_local_irq_restore(&flags);
396+ return 0;
397+}
398+
349399 char _license[] SEC("license") = "GPL";
tools/testing/selftests/bpf/progs/verifier_bounds.c+94−0
@@ -2037,4 +2037,98 @@ __naked void signed_unsigned_intersection32_case2(void *ctx) · 2036 unmodified lines
20372037 : __clobber_all);
20382038 }
20392039
2040+SEC("socket")
2041+__description("maybe_fork_scalars: OR with constant rejects OOB")
2042+__failure __msg("invalid access to map value")
2043+__naked void or_scalar_fork_rejects_oob(void)
2044+{
2045+ asm volatile (" \
2046+ r1 = 0; \
2047+ *(u64*)(r10 - 8) = r1; \
2048+ r2 = r10; \
2049+ r2 += -8; \
2050+ r1 = %[map_hash_8b] ll; \
2051+ call %[bpf_map_lookup_elem]; \
2052+ if r0 == 0 goto l0_%=; \
2053+ r9 = r0; \
2054+ r6 = *(u64*)(r9 + 0); \
2055+ r6 s>>= 63; \
2056+ r6 |= 8; \
2057+ /* r6 is -1 (current) or 8 (pushed) */ \
2058+ if r6 s< 0 goto l0_%=; \
2059+ /* pushed path: r6 = 8, OOB for value_size=8 */ \
2060+ r9 += r6; \
2061+ r0 = *(u8*)(r9 + 0); \
2062+l0_%=: r0 = 0; \
2063+ exit; \
2064+" :
2065+ : __imm(bpf_map_lookup_elem),
2066+ __imm_addr(map_hash_8b)
2067+ : __clobber_all);
2068+}
2069+
2070+SEC("socket")
2071+__description("maybe_fork_scalars: AND with constant still works")
2072+__success __retval(0)
2073+__naked void and_scalar_fork_still_works(void)
2074+{
2075+ asm volatile (" \
2076+ r1 = 0; \
2077+ *(u64*)(r10 - 8) = r1; \
2078+ r2 = r10; \
2079+ r2 += -8; \
2080+ r1 = %[map_hash_8b] ll; \
2081+ call %[bpf_map_lookup_elem]; \
2082+ if r0 == 0 goto l0_%=; \
2083+ r9 = r0; \
2084+ r6 = *(u64*)(r9 + 0); \
2085+ r6 s>>= 63; \
2086+ r6 &= 4; \
2087+ /* \
2088+ * r6 is 0 (pushed, 0&4==0) or 4 (current) \
2089+ * both within value_size=8 \
2090+ */ \
2091+ if r6 s< 0 goto l0_%=; \
2092+ r9 += r6; \
2093+ r0 = *(u8*)(r9 + 0); \
2094+l0_%=: r0 = 0; \
2095+ exit; \
2096+" :
2097+ : __imm(bpf_map_lookup_elem),
2098+ __imm_addr(map_hash_8b)
2099+ : __clobber_all);
2100+}
2101+
2102+SEC("socket")
2103+__description("maybe_fork_scalars: OR with constant allows in-bounds")
2104+__success __retval(0)
2105+__naked void or_scalar_fork_allows_inbounds(void)
2106+{
2107+ asm volatile (" \
2108+ r1 = 0; \
2109+ *(u64*)(r10 - 8) = r1; \
2110+ r2 = r10; \
2111+ r2 += -8; \
2112+ r1 = %[map_hash_8b] ll; \
2113+ call %[bpf_map_lookup_elem]; \
2114+ if r0 == 0 goto l0_%=; \
2115+ r9 = r0; \
2116+ r6 = *(u64*)(r9 + 0); \
2117+ r6 s>>= 63; \
2118+ r6 |= 4; \
2119+ /* \
2120+ * r6 is -1 (current) or 4 (pushed) \
2121+ * pushed path: r6 = 4, within value_size=8 \
2122+ */ \
2123+ if r6 s< 0 goto l0_%=; \
2124+ r9 += r6; \
2125+ r0 = *(u8*)(r9 + 0); \
2126+l0_%=: r0 = 0; \
2127+ exit; \
2128+" :
2129+ : __imm(bpf_map_lookup_elem),
2130+ __imm_addr(map_hash_8b)
2131+ : __clobber_all);
2132+}
2133+
20402134 char _license[] SEC("license") = "GPL";
tools/testing/selftests/bpf/progs/verifier_bswap.c+22−0
@@ -91,6 +91,28 @@ BSWAP_RANGE_TEST(le32_range, "le32", 0x3f00, 0x3f0000) · 90 unmodified lines
9191 BSWAP_RANGE_TEST(le64_range, "le64", 0x3f00, 0x3f000000000000)
9292 #endif
9393
94+SEC("socket")
95+__description("BSWAP, reset reg id")
96+__failure __msg("math between fp pointer and register with unbounded min value is not allowed")
97+__naked void bswap_reset_reg_id(void)
98+{
99+ asm volatile (" \
100+ call %[bpf_ktime_get_ns]; \
101+ r1 = r0; \
102+ r0 = be16 r0; \
103+ if r0 != 1 goto l0_%=; \
104+ r2 = r10; \
105+ r2 += -512; \
106+ r2 += r1; \
107+ *(u8 *)(r2 + 0) = 0; \
108+l0_%=: \
109+ r0 = 0; \
110+ exit; \
111+" :
112+ : __imm(bpf_ktime_get_ns)
113+ : __clobber_all);
114+}
115+
94116 #else
95117
96118 SEC("socket")
tools/testing/selftests/bpf/progs/verifier_linked_scalars.c+108−0
@@ -348,6 +348,114 @@ l0_%=: \ · 347 unmodified lines
348348 : __clobber_all);
349349 }
350350
351+/*
352+ * Test that sync_linked_regs() checks reg->id (the linked target register)
353+ * for BPF_ADD_CONST32 rather than known_reg->id (the branch register).
354+ */
355+SEC("socket")
356+__success
357+__naked void scalars_alu32_zext_linked_reg(void)
358+{
359+ asm volatile (" \
360+ call %[bpf_get_prandom_u32]; \
361+ w6 = w0; /* r6 in [0, 0xFFFFFFFF] */ \
362+ r7 = r6; /* linked: same id as r6 */ \
363+ w7 += 1; /* alu32: r7.id |= BPF_ADD_CONST32 */ \
364+ r8 = 0xFFFFffff ll; \
365+ if r6 < r8 goto l0_%=; \
366+ /* r6 in [0xFFFFFFFF, 0xFFFFFFFF] */ \
367+ /* sync_linked_regs: known_reg=r6, reg=r7 */ \
368+ /* CPU: w7 = (u32)(0xFFFFFFFF + 1) = 0, zext -> r7 = 0 */ \
369+ /* With fix: r7 64-bit = [0, 0] (zext applied) */ \
370+ /* Without fix: r7 64-bit = [0x100000000] (no zext) */ \
371+ r7 >>= 32; \
372+ if r7 == 0 goto l0_%=; \
373+ r0 /= 0; /* unreachable with fix */ \
374+l0_%=: \
375+ r0 = 0; \
376+ exit; \
377+" :
378+ : __imm(bpf_get_prandom_u32)
379+ : __clobber_all);
380+}
381+
382+/*
383+ * Test that sync_linked_regs() skips propagation when one register used
384+ * alu32 (BPF_ADD_CONST32) and the other used alu64 (BPF_ADD_CONST64).
385+ * The delta relationship doesn't hold across different ALU widths.
386+ */
387+SEC("socket")
388+__failure __msg("div by zero")
389+__naked void scalars_alu32_alu64_cross_type(void)
390+{
391+ asm volatile (" \
392+ call %[bpf_get_prandom_u32]; \
393+ w6 = w0; /* r6 in [0, 0xFFFFFFFF] */ \
394+ r7 = r6; /* linked: same id as r6 */ \
395+ w7 += 1; /* alu32: BPF_ADD_CONST32, delta = 1 */ \
396+ r8 = r6; /* linked: same id as r6 */ \
397+ r8 += 2; /* alu64: BPF_ADD_CONST64, delta = 2 */ \
398+ r9 = 0xFFFFffff ll; \
399+ if r7 < r9 goto l0_%=; \
400+ /* r7 = 0xFFFFFFFF */ \
401+ /* sync: known_reg=r7 (ADD_CONST32), reg=r8 (ADD_CONST64) */ \
402+ /* Without fix: r8 = zext(0xFFFFFFFF + 1) = 0 */ \
403+ /* With fix: r8 stays [2, 0x100000001] (r8 >= 2) */ \
404+ if r8 > 0 goto l1_%=; \
405+ goto l0_%=; \
406+l1_%=: \
407+ r0 /= 0; /* div by zero */ \
408+l0_%=: \
409+ r0 = 0; \
410+ exit; \
411+" :
412+ : __imm(bpf_get_prandom_u32)
413+ : __clobber_all);
414+}
415+
416+/*
417+ * Test that regsafe() prevents pruning when two paths reach the same program
418+ * point with linked registers carrying different ADD_CONST flags (one
419+ * BPF_ADD_CONST32 from alu32, another BPF_ADD_CONST64 from alu64).
420+ */
421+SEC("socket")
422+__failure __msg("div by zero")
423+__flag(BPF_F_TEST_STATE_FREQ)
424+__naked void scalars_alu32_alu64_regsafe_pruning(void)
425+{
426+ asm volatile (" \
427+ call %[bpf_get_prandom_u32]; \
428+ w6 = w0; /* r6 in [0, 0xFFFFFFFF] */ \
429+ r7 = r6; /* linked: same id as r6 */ \
430+ /* Get another random value for the path branch */ \
431+ call %[bpf_get_prandom_u32]; \
432+ if r0 > 0 goto l_pathb_%=; \
433+ /* Path A: alu32 */ \
434+ w7 += 1; /* BPF_ADD_CONST32, delta = 1 */\
435+ goto l_merge_%=; \
436+l_pathb_%=: \
437+ /* Path B: alu64 */ \
438+ r7 += 1; /* BPF_ADD_CONST64, delta = 1 */\
439+l_merge_%=: \
440+ /* Merge point: regsafe() compares path B against cached path A. */ \
441+ /* Narrow r6 to trigger sync_linked_regs for r7 */ \
442+ r9 = 0xFFFFffff ll; \
443+ if r6 < r9 goto l0_%=; \
444+ /* r6 = 0xFFFFFFFF */ \
445+ /* sync: r7 = 0xFFFFFFFF + 1 = 0x100000000 */ \
446+ /* Path A: zext -> r7 = 0 */ \
447+ /* Path B: no zext -> r7 = 0x100000000 */ \
448+ r7 >>= 32; \
449+ if r7 == 0 goto l0_%=; \
450+ r0 /= 0; /* div by zero on path B */ \
451+l0_%=: \
452+ r0 = 0; \
453+ exit; \
454+" :
455+ : __imm(bpf_get_prandom_u32)
456+ : __clobber_all);
457+}
458+
351459 SEC("socket")
352460 __success
353461 void alu32_negative_offset(void)
tools/testing/selftests/bpf/progs/verifier_sdiv.c+58−0
@@ -1209,6 +1209,64 @@ __naked void smod32_ri_divisor_neg_1(void) · 1208 unmodified lines
12091209 : __clobber_all);
12101210 }
12111211
1212+SEC("socket")
1213+__description("SDIV32, INT_MIN divided by 2, imm")
1214+__success __success_unpriv __retval(-1073741824)
1215+__naked void sdiv32_int_min_div_2_imm(void)
1216+{
1217+ asm volatile (" \
1218+ w0 = %[int_min]; \
1219+ w0 s/= 2; \
1220+ exit; \
1221+" :
1222+ : __imm_const(int_min, INT_MIN)
1223+ : __clobber_all);
1224+}
1225+
1226+SEC("socket")
1227+__description("SDIV32, INT_MIN divided by 2, reg")
1228+__success __success_unpriv __retval(-1073741824)
1229+__naked void sdiv32_int_min_div_2_reg(void)
1230+{
1231+ asm volatile (" \
1232+ w0 = %[int_min]; \
1233+ w1 = 2; \
1234+ w0 s/= w1; \
1235+ exit; \
1236+" :
1237+ : __imm_const(int_min, INT_MIN)
1238+ : __clobber_all);
1239+}
1240+
1241+SEC("socket")
1242+__description("SMOD32, INT_MIN modulo 2, imm")
1243+__success __success_unpriv __retval(0)
1244+__naked void smod32_int_min_mod_2_imm(void)
1245+{
1246+ asm volatile (" \
1247+ w0 = %[int_min]; \
1248+ w0 s%%= 2; \
1249+ exit; \
1250+" :
1251+ : __imm_const(int_min, INT_MIN)
1252+ : __clobber_all);
1253+}
1254+
1255+SEC("socket")
1256+__description("SMOD32, INT_MIN modulo -2, imm")
1257+__success __success_unpriv __retval(0)
1258+__naked void smod32_int_min_mod_neg2_imm(void)
1259+{
1260+ asm volatile (" \
1261+ w0 = %[int_min]; \
1262+ w0 s%%= -2; \
1263+ exit; \
1264+" :
1265+ : __imm_const(int_min, INT_MIN)
1266+ : __clobber_all);
1267+}
1268+
1269+
12121270 #else
12131271
12141272 SEC("socket")
tools/testing/selftests/hid/progs/hid_bpf_helpers.h+12−0
@@ -6,8 +6,10 @@ · 5 unmodified lines
66 #define __HID_BPF_HELPERS_H
77
88 /* "undefine" structs and enums in vmlinux.h, because we "override" them below */
9+#define bpf_wq bpf_wq___not_used
910 #define hid_bpf_ctx hid_bpf_ctx___not_used
1011 #define hid_bpf_ops hid_bpf_ops___not_used
12+#define hid_device hid_device___not_used
1113 #define hid_report_type hid_report_type___not_used
1214 #define hid_class_request hid_class_request___not_used
1315 #define hid_bpf_attach_flags hid_bpf_attach_flags___not_used
@@ -27,8 +29,10 @@ · 13 unmodified lines
2729
2830 #include "vmlinux.h"
2931
32+#undef bpf_wq
3033 #undef hid_bpf_ctx
3134 #undef hid_bpf_ops
35+#undef hid_device
3236 #undef hid_report_type
3337 #undef hid_class_request
3438 #undef hid_bpf_attach_flags
@@ -55,6 +59,14 @@ enum hid_report_type { · 20 unmodified lines
5559 HID_REPORT_TYPES,
5660 };
5761
62+struct hid_device {
63+ unsigned int id;
64+} __attribute__((preserve_access_index));
65+
66+struct bpf_wq {
67+ __u64 __opaque[2];
68+};
69+
5870 struct hid_bpf_ctx {
5971 struct hid_device *hid;
6072 __u32 allocated_size;