History

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

Conflicts: drivers/net/can/dev.c commit 03f16c5075b2 ("can: dev: can_restart: fix use after free bug") commit 3e77f70e7345 ("can: dev: move driver related infrastructure into separate subdir") Code move. drivers/net/dsa/b53/b53_common.c commit 8e4052c32d6b ("net: dsa: b53: fix an off by one in checking "vlan->vid"") commit b7a9e0da2d1c ("net: switchdev: remove vid_begin -> vid_end range from VLAN objects") Field rename.

Jakub Kicinski committed 5 years ago

Commit 0fe2f272 parents 7b8fc01 75439bc285 files · +3212 −1446Browse files

Unified · Split

285 files
  1. .mailmap +2 −0
  2. Documentation/admin-guide/kernel-parameters.txt +4 −0
  3. Documentation/firmware-guide/acpi/apei/einj.rst +2 −2
  4. Documentation/networking/tls-offload.rst +3 −0
  5. MAINTAINERS +5 −4
  6. Makefile +1 −1
  7. arch/arm/xen/enlighten.c +1 −1
  8. arch/arm64/Kconfig +0 −2
  9. arch/arm64/include/asm/atomic.h +5 −5
  10. arch/arm64/include/asm/processor.h +1 −2
  11. arch/arm64/kernel/asm-offsets.c +1 −1
  12. arch/arm64/kernel/entry-ftrace.S +6 −6
  13. arch/arm64/kernel/entry.S +7 −7
  14. arch/arm64/kernel/perf_event.c +2 −39
  15. arch/arm64/kernel/probes/kprobes_trampoline.S +3 −3
  16. arch/arm64/kernel/signal.c +0 −7
  17. arch/arm64/kernel/syscall.c +2 −8
  18. arch/arm64/mm/init.c +18 −15
  19. arch/ia64/include/asm/sparsemem.h +1 −0
  20. arch/mips/boot/compressed/decompress.c +2 −1
  21. arch/mips/cavium-octeon/octeon-irq.c +1 −1
  22. arch/mips/kernel/binfmt_elfn32.c +7 −0
  23. arch/mips/kernel/binfmt_elfo32.c +7 −0
  24. arch/mips/kernel/relocate.c +8 −2
  25. arch/powerpc/include/asm/vdso/gettimeofday.h +15 −1
  26. arch/powerpc/kernel/vmlinux.lds.S +8 −0
  27. arch/riscv/Kconfig +4 −2
  28. arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts +2 −0
  29. arch/riscv/configs/defconfig +2 −0
  30. arch/riscv/include/asm/pgtable.h +0 −1
  31. arch/riscv/include/asm/vdso.h +1 −1
  32. arch/riscv/kernel/cacheinfo.c +10 −1
  33. arch/riscv/kernel/entry.S +13 −11
  34. arch/riscv/kernel/setup.c +13 −11
  35. arch/riscv/kernel/stacktrace.c +2 −3
  36. arch/riscv/kernel/time.c +3 −0
  37. arch/riscv/kernel/vdso.c +1 −1
  38. arch/riscv/mm/init.c +14 −2
  39. arch/riscv/mm/kasan_init.c +2 −2
  40. arch/x86/hyperv/hv_init.c +26 −3
  41. arch/x86/xen/enlighten_hvm.c +12 −3
  42. arch/x86/xen/smp_hvm.c +19 −10
  43. crypto/asymmetric_keys/public_key.c +2 −1
  44. crypto/xor.c +2 −0
  45. drivers/acpi/internal.h +1 −1
  46. drivers/acpi/scan.c +14 −1
  47. drivers/crypto/Kconfig +1 −0
  48. drivers/dma-buf/heaps/cma_heap.c +3 −0
  49. drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c +36 −17
  50. drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 −1
  51. drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 −0
  52. drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +46 −2
  53. drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h +1 −1
  54. drivers/gpu/drm/amd/amdgpu/soc15.c +2 −1
  55. drivers/gpu/drm/amd/amdkfd/kfd_crat.c +7 −4
  56. drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +9 −133
  57. drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +0 −38
  58. drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c +1 −53
  59. drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.h +1 −4
  60. drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +7 −1
  61. drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.c +1 −1
  62. drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c +2 −2
  63. drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c +1 −0
  64. drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c +6 −5
  65. drivers/gpu/drm/drm_plane.c +8 −1
  66. drivers/gpu/drm/i915/Makefile +1 −0
  67. drivers/gpu/drm/i915/display/icl_dsi.c +0 −4
  68. drivers/gpu/drm/i915/display/intel_panel.c +5 −4
  69. drivers/gpu/drm/i915/display/vlv_dsi.c +13 −3
  70. drivers/gpu/drm/i915/gt/gen7_renderclear.c +94 −63
  71. drivers/gpu/drm/i915/gt/intel_ring_submission.c +4 −2
  72. drivers/gpu/drm/i915/gvt/display.c +57 −24
  73. drivers/gpu/drm/i915/gvt/vgpu.c +2 −3
  74. drivers/gpu/drm/i915/i915_drv.c +4 −0
  75. drivers/gpu/drm/i915/i915_mitigations.c +146 −0
  76. drivers/gpu/drm/i915/i915_mitigations.h +13 −0
  77. drivers/gpu/drm/nouveau/dispnv50/Kbuild +1 −0
  78. drivers/gpu/drm/nouveau/dispnv50/core.c +1 −0
  79. drivers/gpu/drm/nouveau/dispnv50/curs.c +1 −0
  80. drivers/gpu/drm/nouveau/dispnv50/disp.c +2 −2
  81. drivers/gpu/drm/nouveau/dispnv50/disp.h +1 −1
  82. drivers/gpu/drm/nouveau/dispnv50/wimm.c +1 −0
  83. drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c +1 −1
  84. drivers/gpu/drm/nouveau/dispnv50/wndw.c +1 −0
  85. drivers/gpu/drm/nouveau/dispnv50/wndw.h +8 −0
  86. drivers/gpu/drm/nouveau/dispnv50/wndwc57e.c +5 −5
  87. drivers/gpu/drm/nouveau/dispnv50/wndwc67e.c +106 −0
  88. drivers/gpu/drm/nouveau/include/nvif/cl0080.h +1 −0
  89. drivers/gpu/drm/nouveau/include/nvif/class.h +5 −0
  90. drivers/gpu/drm/nouveau/include/nvkm/core/device.h +1 −0
  91. drivers/gpu/drm/nouveau/include/nvkm/engine/disp.h +1 −0
  92. drivers/gpu/drm/nouveau/include/nvkm/subdev/devinit.h +1 −0
  93. drivers/gpu/drm/nouveau/include/nvkm/subdev/fb.h +2 −0
  94. drivers/gpu/drm/nouveau/include/nvkm/subdev/gpio.h +1 −0
  95. drivers/gpu/drm/nouveau/include/nvkm/subdev/i2c.h +1 −0
  96. drivers/gpu/drm/nouveau/include/nvkm/subdev/mc.h +1 −0
  97. drivers/gpu/drm/nouveau/nouveau_backlight.c +1 −0
  98. drivers/gpu/drm/nouveau/nvif/disp.c +1 −0
  99. drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +78 −9
  100. drivers/gpu/drm/nouveau/nvkm/engine/device/user.c +1 −0
  101. drivers/gpu/drm/nouveau/nvkm/engine/disp/Kbuild +3 −0
  102. drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c +27 −6
  103. drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c +46 −0
  104. drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h +4 −0
  105. drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.h +2 −0
  106. drivers/gpu/drm/nouveau/nvkm/engine/disp/rootga102.c +52 −0
  107. drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.h +1 −0
  108. drivers/gpu/drm/nouveau/nvkm/engine/disp/sorga102.c +140 −0
  109. drivers/gpu/drm/nouveau/nvkm/engine/disp/sortu102.c +1 −1
  110. drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c +1 −1
  111. drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c +1 −1
  112. drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowramin.c +3 −0
  113. drivers/gpu/drm/nouveau/nvkm/subdev/devinit/Kbuild +1 −0
  114. drivers/gpu/drm/nouveau/nvkm/subdev/devinit/ga100.c +76 −0
  115. drivers/gpu/drm/nouveau/nvkm/subdev/devinit/priv.h +1 −0
  116. drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c +1 −1
  117. drivers/gpu/drm/nouveau/nvkm/subdev/fb/Kbuild +3 −0
  118. drivers/gpu/drm/nouveau/nvkm/subdev/fb/ga100.c +40 −0
  119. drivers/gpu/drm/nouveau/nvkm/subdev/fb/ga102.c +40 −0
  120. drivers/gpu/drm/nouveau/nvkm/subdev/fb/gv100.c +1 −1
  121. drivers/gpu/drm/nouveau/nvkm/subdev/fb/priv.h +2 −0
  122. drivers/gpu/drm/nouveau/nvkm/subdev/fb/ram.h +1 −0
  123. drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramga102.c +40 −0
  124. drivers/gpu/drm/nouveau/nvkm/subdev/gpio/Kbuild +1 −0
  125. drivers/gpu/drm/nouveau/nvkm/subdev/gpio/ga102.c +118 −0
  126. drivers/gpu/drm/nouveau/nvkm/subdev/i2c/Kbuild +1 −0
  127. drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.h +7 −0
  128. drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxg94.c +7 −3
  129. drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c +11 −6
  130. drivers/gpu/drm/nouveau/nvkm/subdev/i2c/gk110.c +45 −0
  131. drivers/gpu/drm/nouveau/nvkm/subdev/i2c/gm200.c +7 −0
  132. drivers/gpu/drm/nouveau/nvkm/subdev/i2c/pad.h +1 −1
  133. drivers/gpu/drm/nouveau/nvkm/subdev/i2c/priv.h +4 −0
  134. drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c +7 −3
  135. drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c +7 −3
  136. drivers/gpu/drm/nouveau/nvkm/subdev/mc/Kbuild +1 −0
  137. drivers/gpu/drm/nouveau/nvkm/subdev/mc/ga100.c +74 −0
  138. drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c +3 −3
  139. drivers/gpu/drm/ttm/ttm_pool.c +11 −11
  140. drivers/infiniband/core/cma_configfs.c +3 −1
  141. drivers/infiniband/core/restrack.c +1 −0
  142. drivers/infiniband/core/ucma.c +72 −63
  143. drivers/infiniband/core/umem.c +1 −1
  144. drivers/infiniband/hw/mlx5/main.c +2 −2
  145. drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +1 −1
  146. drivers/infiniband/hw/usnic/usnic_ib_verbs.c +3 −0
  147. drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c +2 −0
  148. drivers/iommu/intel/iommu.c +0 −1
  149. drivers/iommu/intel/svm.c +20 −2
  150. drivers/md/Kconfig +2 −0
  151. drivers/md/dm-bufio.c +6 −0
  152. drivers/md/dm-crypt.c +152 −18
  153. drivers/md/dm-integrity.c +50 −12
  154. drivers/md/dm-raid.c +3 −3
  155. drivers/md/dm-snap.c +24 −0
  156. drivers/md/dm.c +1 −1
  157. drivers/net/can/dev/dev.c +2 −2
  158. drivers/net/can/usb/peak_usb/pcan_usb_fd.c +4 −4
  159. drivers/net/can/vxcan.c +4 −2
  160. drivers/net/dsa/b53/b53_common.c +1 −1
  161. drivers/net/dsa/mv88e6xxx/global1_vtu.c +4 −0
  162. drivers/net/ethernet/broadcom/bcmsysport.c +4 −2
  163. drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +6 −0
  164. drivers/net/ethernet/mscc/ocelot.c +18 −5
  165. drivers/net/ethernet/mscc/ocelot_net.c +1 −3
  166. drivers/net/ethernet/renesas/sh_eth.c +28 −2
  167. drivers/net/mdio/mdio-bitbang.c +4 −2
  168. drivers/net/usb/cdc_ncm.c +11 −1
  169. drivers/nvme/host/core.c +8 −3
  170. drivers/nvme/host/tcp.c +2 −2
  171. drivers/nvme/target/rdma.c +8 −8
  172. drivers/perf/arm_pmu.c +0 −5
  173. drivers/scsi/mpt3sas/Kconfig +1 −1
  174. drivers/scsi/qedi/qedi_main.c +2 −2
  175. drivers/scsi/scsi_debug.c +3 −2
  176. drivers/scsi/sd.c +3 −3
  177. drivers/scsi/ufs/ufshcd.c +10 −14
  178. drivers/spi/spi-cadence.c +4 −2
  179. drivers/spi/spi-fsl-spi.c +2 −3
  180. drivers/tty/serial/sifive.c +1 −0
  181. drivers/xen/events/events_base.c +0 −10
  182. drivers/xen/platform-pci.c +7 −1
  183. drivers/xen/privcmd.c +19 −6
  184. drivers/xen/xenbus/xenbus.h +1 −0
  185. drivers/xen/xenbus/xenbus_comms.c +0 −8
  186. drivers/xen/xenbus/xenbus_probe.c +67 −14
  187. fs/cachefiles/rdwr.c +0 −2
  188. fs/cifs/connect.c +1 −1
  189. fs/cifs/dfs_cache.c +2 −1
  190. fs/cifs/fs_context.c +1 −3
  191. fs/cifs/smb2pdu.c +1 −1
  192. fs/cifs/smb2pdu.h +1 −1
  193. fs/ext4/ext4_jbd2.c +0 −17
  194. fs/ext4/ext4_jbd2.h +0 −5
  195. fs/ext4/fast_commit.c +18 −17
  196. fs/ext4/file.c +5 −2
  197. fs/ext4/inode.c +5 −1
  198. fs/ext4/ioctl.c +3 −0
  199. fs/ext4/namei.c +17 −10
  200. fs/ext4/resize.c +16 −4
  201. fs/ext4/super.c +118 −72
  202. fs/ext4/xattr.c +4 −1
  203. fs/io_uring.c +41 −5
  204. fs/namespace.c +5 −2
  205. fs/nfsd/nfs3xdr.c +6 −1
  206. fs/proc/task_mmu.c +30 −23
  207. include/asm-generic/bitops/atomic.h +3 −3
  208. include/linux/compiler-gcc.h +6 −0
  209. include/linux/dm-bufio.h +1 −0
  210. include/linux/kasan.h +5 −1
  211. include/linux/mdio-bitbang.h +3 −0
  212. include/linux/memcontrol.h +1 −1
  213. include/linux/perf/arm_pmu.h +0 −2
  214. include/linux/usb/usbnet.h +2 −0
  215. include/net/cfg80211.h +4 −1
  216. include/net/inet_connection_sock.h +3 −0
  217. include/net/mac80211.h +1 −0
  218. include/net/sock.h +12 −5
  219. include/trace/events/sunrpc.h +53 −6
  220. include/xen/xenbus.h +1 −1
  221. kernel/bpf/bpf_inode_storage.c +6 −3
  222. kernel/bpf/bpf_task_storage.c +4 −1
  223. kernel/bpf/btf.c +1 −1
  224. kernel/bpf/cgroup.c +3 −2
  225. kernel/bpf/helpers.c +1 −1
  226. kernel/bpf/syscall.c +4 −2
  227. kernel/bpf/verifier.c +5 −3
  228. kernel/signal.c +3 −0
  229. lib/iov_iter.c +1 −1
  230. mm/hugetlb.c +1 −1
  231. mm/kasan/init.c +2 −1
  232. mm/memory-failure.c +1 −1
  233. mm/mempolicy.c +1 −1
  234. mm/page_alloc.c +16 −15
  235. mm/process_vm_access.c +1 −0
  236. mm/slub.c +1 −1
  237. mm/vmalloc.c +3 −1
  238. mm/vmscan.c +2 −0
  239. net/bpf/test_run.c +2 −1
  240. net/core/dev.c +5 −0
  241. net/core/devlink.c +2 −2
  242. net/core/gen_estimator.c +7 −4
  243. net/core/skbuff.c +5 −1
  244. net/ipv4/inet_connection_sock.c +1 −0
  245. net/ipv4/netfilter/ipt_rpfilter.c +1 −1
  246. net/ipv4/tcp.c +1 −0
  247. net/ipv4/tcp_input.c +3 −3
  248. net/ipv4/tcp_ipv4.c +15 −14
  249. net/ipv4/tcp_output.c +1 −0
  250. net/ipv4/tcp_timer.c +15 −21
  251. net/ipv4/udp.c +2 −1
  252. net/ipv6/addrconf.c +2 −1
  253. net/mac80211/debugfs.c +20 −24
  254. net/mac80211/rx.c +2 −0
  255. net/mac80211/tx.c +17 −14
  256. net/nfc/nci/core.c +1 −1
  257. net/sched/cls_flower.c +13 −9
  258. net/sched/cls_tcindex.c +6 −2
  259. net/sched/sch_api.c +2 −1
  260. net/sunrpc/svc_xprt.c +2 −2
  261. net/wireless/reg.c +10 −1
  262. net/xdp/xsk.c +2 −2
  263. security/lsm_audit.c +5 −2
  264. tools/bootconfig/scripts/bconf2ftrace.sh +1 −0
  265. tools/bootconfig/scripts/ftrace2bconf.sh +4 −0
  266. tools/include/linux/build_bug.h +0 −5
  267. tools/include/uapi/linux/kvm.h +2 −0
  268. tools/lib/bpf/btf.c +0 −5
  269. tools/lib/perf/tests/test-cpumap.c +1 −1
  270. tools/lib/perf/tests/test-evlist.c +4 −3
  271. tools/lib/perf/tests/test-evsel.c +1 −1
  272. tools/lib/perf/tests/test-threadmap.c +1 −1
  273. tools/perf/examples/bpf/5sec.c +1 −1
  274. tools/perf/tests/shell/stat+shadow_stat.sh +14 −16
  275. tools/perf/util/header.c +8 −0
  276. tools/perf/util/machine.c +2 −2
  277. tools/perf/util/session.c +1 −1
  278. tools/perf/util/stat-shadow.c +189 −177
  279. tools/testing/selftests/arm64/fp/fpsimd-test.S +1 −1
  280. tools/testing/selftests/arm64/fp/sve-test.S +1 −1
  281. tools/testing/selftests/bpf/prog_tests/test_local_storage.c +26 −70
  282. tools/testing/selftests/bpf/progs/local_storage.c +35 −27
  283. tools/testing/selftests/bpf/test_verifier.c +11 −1
  284. tools/testing/selftests/bpf/verifier/spill_fill.c +30 −0
  285. tools/testing/selftests/net/fib_tests.sh +0 −1
.mailmap+2−0
@@ -55,6 +55,8 @@ Bart Van Assche <bvanassche@acm.org> <bart.vanassche@wdc.com> · 54 unmodified lines
5555 Ben Gardner <bgardner@wabtec.com>
5656 Ben M Cahill <ben.m.cahill@intel.com>
5757 Björn Steinbrink <B.Steinbrink@gmx.de>
58+Björn Töpel <bjorn@kernel.org> <bjorn.topel@gmail.com>
59+Björn Töpel <bjorn@kernel.org> <bjorn.topel@intel.com>
5860 Boris Brezillon <bbrezillon@kernel.org> <b.brezillon.dev@gmail.com>
5961 Boris Brezillon <bbrezillon@kernel.org> <b.brezillon@overkiz.com>
6062 Boris Brezillon <bbrezillon@kernel.org> <boris.brezillon@bootlin.com>
Documentation/admin-guide/kernel-parameters.txt+4−0
@@ -5972,6 +5972,10 @@ · 5971 unmodified lines
59725972 This option is obsoleted by the "nopv" option, which
59735973 has equivalent effect for XEN platform.
59745974
5975+ xen_no_vector_callback
5976+ [KNL,X86,XEN] Disable the vector callback for Xen
5977+ event channel interrupts.
5978+
59755979 xen_scrub_pages= [XEN]
59765980 Boolean option to control scrubbing pages before giving them back
59775981 to Xen, for use by other domains. Can be also changed at runtime
Documentation/firmware-guide/acpi/apei/einj.rst+2−2
@@ -50,8 +50,8 @@ The following files belong to it: · 49 unmodified lines
5050 0x00000010 Memory Uncorrectable non-fatal
5151 0x00000020 Memory Uncorrectable fatal
5252 0x00000040 PCI Express Correctable
53− 0x00000080 PCI Express Uncorrectable fatal
54− 0x00000100 PCI Express Uncorrectable non-fatal
53+ 0x00000080 PCI Express Uncorrectable non-fatal
54+ 0x00000100 PCI Express Uncorrectable fatal
5555 0x00000200 Platform Correctable
5656 0x00000400 Platform Uncorrectable non-fatal
5757 0x00000800 Platform Uncorrectable fatal
Documentation/networking/tls-offload.rst+3−0
@@ -534,3 +534,6 @@ offload. Hence, TLS TX device feature flag requires TX csum offload being set. · 533 unmodified lines
534534 Disabling the latter implies clearing the former. Disabling TX checksum offload
535535 should not affect old connections, and drivers should make sure checksum
536536 calculation does not break for them.
537+Similarly, device-offloaded TLS decryption implies doing RXCSUM. If the user
538+does not want to enable RX csum offload, TLS RX device feature is disabled
539+as well.
MAINTAINERS+5−4
@@ -906,7 +906,7 @@ AMD KFD · 905 unmodified lines
906906 M: Felix Kuehling <Felix.Kuehling@amd.com>
907907 L: amd-gfx@lists.freedesktop.org
908908 S: Supported
909−T: git git://people.freedesktop.org/~agd5f/linux
909+T: git https://gitlab.freedesktop.org/agd5f/linux.git
910910 F: drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd*.[ch]
911911 F: drivers/gpu/drm/amd/amdkfd/
912912 F: drivers/gpu/drm/amd/include/cik_structs.h
@@ -3334,7 +3334,7 @@ F: arch/riscv/net/ · 2421 unmodified lines
33343334 X: arch/riscv/net/bpf_jit_comp64.c
33353335
33363336 BPF JIT for RISC-V (64-bit)
3337−M: Björn Töpel <bjorn.topel@gmail.com>
3337+M: Björn Töpel <bjorn@kernel.org>
33383338 L: netdev@vger.kernel.org
33393339 L: bpf@vger.kernel.org
33403340 S: Maintained
@@ -14827,7 +14827,7 @@ M: Alex Deucher <alexander.deucher@amd.com> · 11486 unmodified lines
1482714827 M: Christian König <christian.koenig@amd.com>
1482814828 L: amd-gfx@lists.freedesktop.org
1482914829 S: Supported
14830−T: git git://people.freedesktop.org/~agd5f/linux
14830+T: git https://gitlab.freedesktop.org/agd5f/linux.git
1483114831 F: drivers/gpu/drm/amd/
1483214832 F: drivers/gpu/drm/radeon/
1483314833 F: include/uapi/drm/amdgpu_drm.h
@@ -16328,6 +16328,7 @@ M: Pekka Enberg <penberg@kernel.org> · 1494 unmodified lines
1632816328 M: David Rientjes <rientjes@google.com>
1632916329 M: Joonsoo Kim <iamjoonsoo.kim@lge.com>
1633016330 M: Andrew Morton <akpm@linux-foundation.org>
16331+M: Vlastimil Babka <vbabka@suse.cz>
1633116332 L: linux-mm@kvack.org
1633216333 S: Maintained
1633316334 F: include/linux/sl?b*.h
@@ -19430,7 +19431,7 @@ F: drivers/net/ethernet/*/*/*xdp* · 3096 unmodified lines
1943019431 K: (?:\b|_)xdp(?:\b|_)
1943119432
1943219433 XDP SOCKETS (AF_XDP)
19433−M: Björn Töpel <bjorn.topel@intel.com>
19434+M: Björn Töpel <bjorn@kernel.org>
1943419435 M: Magnus Karlsson <magnus.karlsson@intel.com>
1943519436 R: Jonathan Lemon <jonathan.lemon@gmail.com>
1943619437 L: netdev@vger.kernel.org
Makefile+1−1
@@ -2,7 +2,7 @@ · 1 unmodified line
22 VERSION = 5
33 PATCHLEVEL = 11
44 SUBLEVEL = 0
5−EXTRAVERSION = -rc3
5+EXTRAVERSION = -rc4
66 NAME = Kleptomaniac Octopus
77
88 # *DOCUMENTATION*
arch/arm/xen/enlighten.c+1−1
@@ -371,7 +371,7 @@ static int __init xen_guest_init(void) · 370 unmodified lines
371371 }
372372 gnttab_init();
373373 if (!xen_initial_domain())
374− xenbus_probe(NULL);
374+ xenbus_probe();
375375
376376 /*
377377 * Making sure board specific code will not set up ops for
arch/arm64/Kconfig+0−2
@@ -174,8 +174,6 @@ config ARM64 · 173 unmodified lines
174174 select HAVE_NMI
175175 select HAVE_PATA_PLATFORM
176176 select HAVE_PERF_EVENTS
177− select HAVE_PERF_EVENTS_NMI if ARM64_PSEUDO_NMI && HW_PERF_EVENTS
178− select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI
179177 select HAVE_PERF_REGS
180178 select HAVE_PERF_USER_STACK_DUMP
181179 select HAVE_REGS_AND_STACK_ACCESS_API
arch/arm64/include/asm/atomic.h+5−5
@@ -17,7 +17,7 @@ · 16 unmodified lines
1717 #include <asm/lse.h>
1818
1919 #define ATOMIC_OP(op) \
20−static inline void arch_##op(int i, atomic_t *v) \
20+static __always_inline void arch_##op(int i, atomic_t *v) \
2121 { \
2222 __lse_ll_sc_body(op, i, v); \
2323 }
@@ -32,7 +32,7 @@ ATOMIC_OP(atomic_sub) · 8 unmodified lines
3232 #undef ATOMIC_OP
3333
3434 #define ATOMIC_FETCH_OP(name, op) \
35−static inline int arch_##op##name(int i, atomic_t *v) \
35+static __always_inline int arch_##op##name(int i, atomic_t *v) \
3636 { \
3737 return __lse_ll_sc_body(op##name, i, v); \
3838 }
@@ -56,7 +56,7 @@ ATOMIC_FETCH_OPS(atomic_sub_return) · 17 unmodified lines
5656 #undef ATOMIC_FETCH_OPS
5757
5858 #define ATOMIC64_OP(op) \
59−static inline void arch_##op(long i, atomic64_t *v) \
59+static __always_inline void arch_##op(long i, atomic64_t *v) \
6060 { \
6161 __lse_ll_sc_body(op, i, v); \
6262 }
@@ -71,7 +71,7 @@ ATOMIC64_OP(atomic64_sub) · 8 unmodified lines
7171 #undef ATOMIC64_OP
7272
7373 #define ATOMIC64_FETCH_OP(name, op) \
74−static inline long arch_##op##name(long i, atomic64_t *v) \
74+static __always_inline long arch_##op##name(long i, atomic64_t *v) \
7575 { \
7676 return __lse_ll_sc_body(op##name, i, v); \
7777 }
@@ -94,7 +94,7 @@ ATOMIC64_FETCH_OPS(atomic64_sub_return) · 16 unmodified lines
9494 #undef ATOMIC64_FETCH_OP
9595 #undef ATOMIC64_FETCH_OPS
9696
97−static inline long arch_atomic64_dec_if_positive(atomic64_t *v)
97+static __always_inline long arch_atomic64_dec_if_positive(atomic64_t *v)
9898 {
9999 return __lse_ll_sc_body(atomic64_dec_if_positive, v);
100100 }
arch/arm64/include/asm/processor.h+1−2
@@ -94,8 +94,7 @@ · 93 unmodified lines
9494 #endif /* CONFIG_ARM64_FORCE_52BIT */
9595
9696 extern phys_addr_t arm64_dma_phys_limit;
97−extern phys_addr_t arm64_dma32_phys_limit;
98−#define ARCH_LOW_ADDRESS_LIMIT ((arm64_dma_phys_limit ? : arm64_dma32_phys_limit) - 1)
97+#define ARCH_LOW_ADDRESS_LIMIT (arm64_dma_phys_limit - 1)
9998
10099 struct debug_info {
101100 #ifdef CONFIG_HAVE_HW_BREAKPOINT
arch/arm64/kernel/asm-offsets.c+1−1
@@ -75,7 +75,7 @@ int main(void) · 74 unmodified lines
7575 DEFINE(S_SDEI_TTBR1, offsetof(struct pt_regs, sdei_ttbr1));
7676 DEFINE(S_PMR_SAVE, offsetof(struct pt_regs, pmr_save));
7777 DEFINE(S_STACKFRAME, offsetof(struct pt_regs, stackframe));
78− DEFINE(S_FRAME_SIZE, sizeof(struct pt_regs));
78+ DEFINE(PT_REGS_SIZE, sizeof(struct pt_regs));
7979 BLANK();
8080 #ifdef CONFIG_COMPAT
8181 DEFINE(COMPAT_SIGFRAME_REGS_OFFSET, offsetof(struct compat_sigframe, uc.uc_mcontext.arm_r0));
arch/arm64/kernel/entry-ftrace.S+6−6
@@ -35,7 +35,7 @@ · 34 unmodified lines
3535 */
3636 .macro ftrace_regs_entry, allregs=0
3737 /* Make room for pt_regs, plus a callee frame */
38− sub sp, sp, #(S_FRAME_SIZE + 16)
38+ sub sp, sp, #(PT_REGS_SIZE + 16)
3939
4040 /* Save function arguments (and x9 for simplicity) */
4141 stp x0, x1, [sp, #S_X0]
@@ -61,15 +61,15 @@ · 19 unmodified lines
6161 .endif
6262
6363 /* Save the callsite's SP and LR */
64− add x10, sp, #(S_FRAME_SIZE + 16)
64+ add x10, sp, #(PT_REGS_SIZE + 16)
6565 stp x9, x10, [sp, #S_LR]
6666
6767 /* Save the PC after the ftrace callsite */
6868 str x30, [sp, #S_PC]
6969
7070 /* Create a frame record for the callsite above pt_regs */
71− stp x29, x9, [sp, #S_FRAME_SIZE]
72− add x29, sp, #S_FRAME_SIZE
71+ stp x29, x9, [sp, #PT_REGS_SIZE]
72+ add x29, sp, #PT_REGS_SIZE
7373
7474 /* Create our frame record within pt_regs. */
7575 stp x29, x30, [sp, #S_STACKFRAME]
@@ -120,7 +120,7 @@ ftrace_common_return: · 44 unmodified lines
120120 ldr x9, [sp, #S_PC]
121121
122122 /* Restore the callsite's SP */
123− add sp, sp, #S_FRAME_SIZE + 16
123+ add sp, sp, #PT_REGS_SIZE + 16
124124
125125 ret x9
126126 SYM_CODE_END(ftrace_common)
@@ -130,7 +130,7 @@ SYM_CODE_START(ftrace_graph_caller) · 3 unmodified lines
130130 ldr x0, [sp, #S_PC]
131131 sub x0, x0, #AARCH64_INSN_SIZE // ip (callsite's BL insn)
132132 add x1, sp, #S_LR // parent_ip (callsite's LR)
133− ldr x2, [sp, #S_FRAME_SIZE] // parent fp (callsite's FP)
133+ ldr x2, [sp, #PT_REGS_SIZE] // parent fp (callsite's FP)
134134 bl prepare_ftrace_return
135135 b ftrace_common_return
136136 SYM_CODE_END(ftrace_graph_caller)
arch/arm64/kernel/entry.S+7−7
@@ -75,7 +75,7 @@ alternative_else_nop_endif · 74 unmodified lines
7575 .endif
7676 #endif
7777
78− sub sp, sp, #S_FRAME_SIZE
78+ sub sp, sp, #PT_REGS_SIZE
7979 #ifdef CONFIG_VMAP_STACK
8080 /*
8181 * Test whether the SP has overflowed, without corrupting a GPR.
@@ -96,7 +96,7 @@ alternative_else_nop_endif · 14 unmodified lines
9696 * userspace, and can clobber EL0 registers to free up GPRs.
9797 */
9898
99− /* Stash the original SP (minus S_FRAME_SIZE) in tpidr_el0. */
99+ /* Stash the original SP (minus PT_REGS_SIZE) in tpidr_el0. */
100100 msr tpidr_el0, x0
101101
102102 /* Recover the original x0 value and stash it in tpidrro_el0 */
@@ -253,7 +253,7 @@ alternative_else_nop_endif · 150 unmodified lines
253253
254254 scs_load tsk, x20
255255 .else
256− add x21, sp, #S_FRAME_SIZE
256+ add x21, sp, #PT_REGS_SIZE
257257 get_current_task tsk
258258 .endif /* \el == 0 */
259259 mrs x22, elr_el1
@@ -377,7 +377,7 @@ alternative_else_nop_endif · 117 unmodified lines
377377 ldp x26, x27, [sp, #16 * 13]
378378 ldp x28, x29, [sp, #16 * 14]
379379 ldr lr, [sp, #S_LR]
380− add sp, sp, #S_FRAME_SIZE // restore sp
380+ add sp, sp, #PT_REGS_SIZE // restore sp
381381
382382 .if \el == 0
383383 alternative_insn eret, nop, ARM64_UNMAP_KERNEL_AT_EL0
@@ -580,12 +580,12 @@ __bad_stack: · 196 unmodified lines
580580
581581 /*
582582 * Store the original GPRs to the new stack. The orginal SP (minus
583− * S_FRAME_SIZE) was stashed in tpidr_el0 by kernel_ventry.
583+ * PT_REGS_SIZE) was stashed in tpidr_el0 by kernel_ventry.
584584 */
585− sub sp, sp, #S_FRAME_SIZE
585+ sub sp, sp, #PT_REGS_SIZE
586586 kernel_entry 1
587587 mrs x0, tpidr_el0
588− add x0, x0, #S_FRAME_SIZE
588+ add x0, x0, #PT_REGS_SIZE
589589 str x0, [sp, #S_SP]
590590
591591 /* Stash the regs for handle_bad_stack */
arch/arm64/kernel/perf_event.c+2−39
@@ -23,8 +23,6 @@ · 22 unmodified lines
2323 #include <linux/platform_device.h>
2424 #include <linux/sched_clock.h>
2525 #include <linux/smp.h>
26−#include <linux/nmi.h>
27−#include <linux/cpufreq.h>
2826
2927 /* ARMv8 Cortex-A53 specific event types. */
3028 #define ARMV8_A53_PERFCTR_PREF_LINEFILL 0xC2
@@ -1250,21 +1248,10 @@ static struct platform_driver armv8_pmu_driver = { · 1219 unmodified lines
12501248
12511249 static int __init armv8_pmu_driver_init(void)
12521250 {
1253− int ret;
1254−
12551251 if (acpi_disabled)
1256− ret = platform_driver_register(&armv8_pmu_driver);
1252+ return platform_driver_register(&armv8_pmu_driver);
12571253 else
1258− ret = arm_pmu_acpi_probe(armv8_pmuv3_init);
1259−
1260− /*
1261− * Try to re-initialize lockup detector after PMU init in
1262− * case PMU events are triggered via NMIs.
1263− */
1264− if (ret == 0 && arm_pmu_irq_is_nmi())
1265− lockup_detector_init();
1266−
1267− return ret;
1254+ return arm_pmu_acpi_probe(armv8_pmuv3_init);
12681255 }
12691256 device_initcall(armv8_pmu_driver_init)
12701257
@@ -1322,27 +1309,3 @@ void arch_perf_update_userpage(struct perf_event *event, · 51 unmodified lines
13221309 userpg->cap_user_time_zero = 1;
13231310 userpg->cap_user_time_short = 1;
13241311 }
1325−
1326−#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF
1327−/*
1328− * Safe maximum CPU frequency in case a particular platform doesn't implement
1329− * cpufreq driver. Although, architecture doesn't put any restrictions on
1330− * maximum frequency but 5 GHz seems to be safe maximum given the available
1331− * Arm CPUs in the market which are clocked much less than 5 GHz. On the other
1332− * hand, we can't make it much higher as it would lead to a large hard-lockup
1333− * detection timeout on parts which are running slower (eg. 1GHz on
1334− * Developerbox) and doesn't possess a cpufreq driver.
1335− */
1336−#define SAFE_MAX_CPU_FREQ 5000000000UL // 5 GHz
1337−u64 hw_nmi_get_sample_period(int watchdog_thresh)
1338−{
1339− unsigned int cpu = smp_processor_id();
1340− unsigned long max_cpu_freq;
1341−
1342− max_cpu_freq = cpufreq_get_hw_max_freq(cpu) * 1000UL;
1343− if (!max_cpu_freq)
1344− max_cpu_freq = SAFE_MAX_CPU_FREQ;
1345−
1346− return (u64)max_cpu_freq * watchdog_thresh;
1347−}
1348−#endif
arch/arm64/kernel/probes/kprobes_trampoline.S+3−3
@@ -25,7 +25,7 @@ · 24 unmodified lines
2525 stp x24, x25, [sp, #S_X24]
2626 stp x26, x27, [sp, #S_X26]
2727 stp x28, x29, [sp, #S_X28]
28− add x0, sp, #S_FRAME_SIZE
28+ add x0, sp, #PT_REGS_SIZE
2929 stp lr, x0, [sp, #S_LR]
3030 /*
3131 * Construct a useful saved PSTATE
@@ -62,7 +62,7 @@ · 30 unmodified lines
6262 .endm
6363
6464 SYM_CODE_START(kretprobe_trampoline)
65− sub sp, sp, #S_FRAME_SIZE
65+ sub sp, sp, #PT_REGS_SIZE
6666
6767 save_all_base_regs
6868
@@ -76,7 +76,7 @@ SYM_CODE_START(kretprobe_trampoline) · 7 unmodified lines
7676
7777 restore_all_base_regs
7878
79− add sp, sp, #S_FRAME_SIZE
79+ add sp, sp, #PT_REGS_SIZE
8080 ret
8181
8282 SYM_CODE_END(kretprobe_trampoline)
arch/arm64/kernel/signal.c+0−7
@@ -914,13 +914,6 @@ static void do_signal(struct pt_regs *regs) · 913 unmodified lines
914914 asmlinkage void do_notify_resume(struct pt_regs *regs,
915915 unsigned long thread_flags)
916916 {
917− /*
918− * The assembly code enters us with IRQs off, but it hasn't
919− * informed the tracing code of that for efficiency reasons.
920− * Update the trace code with the current status.
921− */
922− trace_hardirqs_off();
923−
924917 do {
925918 if (thread_flags & _TIF_NEED_RESCHED) {
926919 /* Unmask Debug and SError for the next task */
arch/arm64/kernel/syscall.c+2−8
@@ -9,6 +9,7 @@ · 8 unmodified lines
99
1010 #include <asm/daifflags.h>
1111 #include <asm/debug-monitors.h>
12+#include <asm/exception.h>
1213 #include <asm/fpsimd.h>
1314 #include <asm/syscall.h>
1415 #include <asm/thread_info.h>
@@ -165,15 +166,8 @@ static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, · 150 unmodified lines
165166 if (!has_syscall_work(flags) && !IS_ENABLED(CONFIG_DEBUG_RSEQ)) {
166167 local_daif_mask();
167168 flags = current_thread_info()->flags;
168− if (!has_syscall_work(flags) && !(flags & _TIF_SINGLESTEP)) {
169− /*
170− * We're off to userspace, where interrupts are
171− * always enabled after we restore the flags from
172− * the SPSR.
173− */
174− trace_hardirqs_on();
169+ if (!has_syscall_work(flags) && !(flags & _TIF_SINGLESTEP))
175170 return;
176− }
177171 local_daif_restore(DAIF_PROCCTX);
178172 }
179173
arch/arm64/mm/init.c+18−15
@@ -53,13 +53,13 @@ s64 memstart_addr __ro_after_init = -1; · 52 unmodified lines
5353 EXPORT_SYMBOL(memstart_addr);
5454
5555 /*
56− * We create both ZONE_DMA and ZONE_DMA32. ZONE_DMA covers the first 1G of
57− * memory as some devices, namely the Raspberry Pi 4, have peripherals with
58− * this limited view of the memory. ZONE_DMA32 will cover the rest of the 32
59− * bit addressable memory area.
56+ * If the corresponding config options are enabled, we create both ZONE_DMA
57+ * and ZONE_DMA32. By default ZONE_DMA covers the 32-bit addressable memory
58+ * unless restricted on specific platforms (e.g. 30-bit on Raspberry Pi 4).
59+ * In such case, ZONE_DMA32 covers the rest of the 32-bit addressable memory,
60+ * otherwise it is empty.
6061 */
6162 phys_addr_t arm64_dma_phys_limit __ro_after_init;
62−phys_addr_t arm64_dma32_phys_limit __ro_after_init;
6363
6464 #ifdef CONFIG_KEXEC_CORE
6565 /*
@@ -84,7 +84,7 @@ static void __init reserve_crashkernel(void) · 18 unmodified lines
8484
8585 if (crash_base == 0) {
8686 /* Current arm64 boot protocol requires 2MB alignment */
87− crash_base = memblock_find_in_range(0, arm64_dma32_phys_limit,
87+ crash_base = memblock_find_in_range(0, arm64_dma_phys_limit,
8888 crash_size, SZ_2M);
8989 if (crash_base == 0) {
9090 pr_warn("cannot allocate crashkernel (size:0x%llx)\n",
@@ -196,6 +196,7 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) · 105 unmodified lines
196196 unsigned long max_zone_pfns[MAX_NR_ZONES] = {0};
197197 unsigned int __maybe_unused acpi_zone_dma_bits;
198198 unsigned int __maybe_unused dt_zone_dma_bits;
199+ phys_addr_t __maybe_unused dma32_phys_limit = max_zone_phys(32);
199200
200201 #ifdef CONFIG_ZONE_DMA
201202 acpi_zone_dma_bits = fls64(acpi_iort_dma_get_max_cpu_address());
@@ -205,8 +206,12 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) · 3 unmodified lines
205206 max_zone_pfns[ZONE_DMA] = PFN_DOWN(arm64_dma_phys_limit);
206207 #endif
207208 #ifdef CONFIG_ZONE_DMA32
208− max_zone_pfns[ZONE_DMA32] = PFN_DOWN(arm64_dma32_phys_limit);
209+ max_zone_pfns[ZONE_DMA32] = PFN_DOWN(dma32_phys_limit);
210+ if (!arm64_dma_phys_limit)
211+ arm64_dma_phys_limit = dma32_phys_limit;
209212 #endif
213+ if (!arm64_dma_phys_limit)
214+ arm64_dma_phys_limit = PHYS_MASK + 1;
210215 max_zone_pfns[ZONE_NORMAL] = max;
211216
212217 free_area_init(max_zone_pfns);
@@ -394,16 +399,9 @@ void __init arm64_memblock_init(void) · 181 unmodified lines
394399
395400 early_init_fdt_scan_reserved_mem();
396401
397− if (IS_ENABLED(CONFIG_ZONE_DMA32))
398− arm64_dma32_phys_limit = max_zone_phys(32);
399− else
400− arm64_dma32_phys_limit = PHYS_MASK + 1;
401−
402402 reserve_elfcorehdr();
403403
404404 high_memory = __va(memblock_end_of_DRAM() - 1) + 1;
405−
406− dma_contiguous_reserve(arm64_dma32_phys_limit);
407405 }
408406
409407 void __init bootmem_init(void)
@@ -438,6 +436,11 @@ void __init bootmem_init(void) · 28 unmodified lines
438436 sparse_init();
439437 zone_sizes_init(min, max);
440438
439+ /*
440+ * Reserve the CMA area after arm64_dma_phys_limit was initialised.
441+ */
442+ dma_contiguous_reserve(arm64_dma_phys_limit);
443+
441444 /*
442445 * request_standard_resources() depends on crashkernel's memory being
443446 * reserved, so do it here.
@@ -455,7 +458,7 @@ void __init bootmem_init(void) · 11 unmodified lines
455458 void __init mem_init(void)
456459 {
457460 if (swiotlb_force == SWIOTLB_FORCE ||
458− max_pfn > PFN_DOWN(arm64_dma_phys_limit ? : arm64_dma32_phys_limit))
461+ max_pfn > PFN_DOWN(arm64_dma_phys_limit))
459462 swiotlb_init(1);
460463 else
461464 swiotlb_force = SWIOTLB_NO_FORCE;
arch/ia64/include/asm/sparsemem.h+1−0
@@ -3,6 +3,7 @@ · 2 unmodified lines
33 #define _ASM_IA64_SPARSEMEM_H
44
55 #ifdef CONFIG_SPARSEMEM
6+#include <asm/page.h>
67 /*
78 * SECTION_SIZE_BITS 2^N: how big each section will be
89 * MAX_PHYSMEM_BITS 2^N: how much memory we can have in that space
arch/mips/boot/compressed/decompress.c+2−1
@@ -13,6 +13,7 @@ · 12 unmodified lines
1313 #include <linux/libfdt.h>
1414
1515 #include <asm/addrspace.h>
16+#include <asm/unaligned.h>
1617
1718 /*
1819 * These two variables specify the free mem region
@@ -117,7 +118,7 @@ void decompress_kernel(unsigned long boot_heap_start) · 98 unmodified lines
117118 dtb_size = fdt_totalsize((void *)&__appended_dtb);
118119
119120 /* last four bytes is always image size in little endian */
120− image_size = le32_to_cpup((void *)&__image_end - 4);
121+ image_size = get_unaligned_le32((void *)&__image_end - 4);
121122
122123 /* copy dtb to where the booted kernel will expect it */
123124 memcpy((void *)VMLINUX_LOAD_ADDRESS_ULL + image_size,
arch/mips/cavium-octeon/octeon-irq.c+1−1
@@ -1444,7 +1444,7 @@ static void octeon_irq_setup_secondary_ciu2(void) · 1443 unmodified lines
14441444 static int __init octeon_irq_init_ciu(
14451445 struct device_node *ciu_node, struct device_node *parent)
14461446 {
1447− unsigned int i, r;
1447+ int i, r;
14481448 struct irq_chip *chip;
14491449 struct irq_chip *chip_edge;
14501450 struct irq_chip *chip_mbox;
arch/mips/kernel/binfmt_elfn32.c+7−0
@@ -103,4 +103,11 @@ jiffies_to_old_timeval32(unsigned long jiffies, struct old_timeval32 *value) · 102 unmodified lines
103103 #undef ns_to_kernel_old_timeval
104104 #define ns_to_kernel_old_timeval ns_to_old_timeval32
105105
106+/*
107+ * Some data types as stored in coredump.
108+ */
109+#define user_long_t compat_long_t
110+#define user_siginfo_t compat_siginfo_t
111+#define copy_siginfo_to_external copy_siginfo_to_external32
112+
106113 #include "../../../fs/binfmt_elf.c"
arch/mips/kernel/binfmt_elfo32.c+7−0
@@ -106,4 +106,11 @@ jiffies_to_old_timeval32(unsigned long jiffies, struct old_timeval32 *value) · 105 unmodified lines
106106 #undef ns_to_kernel_old_timeval
107107 #define ns_to_kernel_old_timeval ns_to_old_timeval32
108108
109+/*
110+ * Some data types as stored in coredump.
111+ */
112+#define user_long_t compat_long_t
113+#define user_siginfo_t compat_siginfo_t
114+#define copy_siginfo_to_external copy_siginfo_to_external32
115+
109116 #include "../../../fs/binfmt_elf.c"
arch/mips/kernel/relocate.c+8−2
@@ -187,8 +187,14 @@ static int __init relocate_exception_table(long offset) · 186 unmodified lines
187187 static inline __init unsigned long rotate_xor(unsigned long hash,
188188 const void *area, size_t size)
189189 {
190− size_t i;
191− unsigned long *ptr = (unsigned long *)area;
190+ const typeof(hash) *ptr = PTR_ALIGN(area, sizeof(hash));
191+ size_t diff, i;
192+
193+ diff = (void *)ptr - area;
194+ if (unlikely(size < diff + sizeof(hash)))
195+ return hash;
196+
197+ size = ALIGN_DOWN(size - diff, sizeof(hash));
192198
193199 for (i = 0; i < size / sizeof(hash); i++) {
194200 /* Rotate by odd number of bits and XOR. */
arch/powerpc/include/asm/vdso/gettimeofday.h+15−1
@@ -103,6 +103,8 @@ int gettimeofday_fallback(struct __kernel_old_timeval *_tv, struct timezone *_tz · 102 unmodified lines
103103 return do_syscall_2(__NR_gettimeofday, (unsigned long)_tv, (unsigned long)_tz);
104104 }
105105
106+#ifdef __powerpc64__
107+
106108 static __always_inline
107109 int clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
108110 {
@@ -115,10 +117,22 @@ int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts) · 6 unmodified lines
115117 return do_syscall_2(__NR_clock_getres, _clkid, (unsigned long)_ts);
116118 }
117119
118−#ifdef CONFIG_VDSO32
120+#else
119121
120122 #define BUILD_VDSO32 1
121123
124+static __always_inline
125+int clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
126+{
127+ return do_syscall_2(__NR_clock_gettime64, _clkid, (unsigned long)_ts);
128+}
129+
130+static __always_inline
131+int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
132+{
133+ return do_syscall_2(__NR_clock_getres_time64, _clkid, (unsigned long)_ts);
134+}
135+
122136 static __always_inline
123137 int clock_gettime32_fallback(clockid_t _clkid, struct old_timespec32 *_ts)
124138 {
arch/powerpc/kernel/vmlinux.lds.S+8−0
@@ -187,6 +187,12 @@ SECTIONS · 186 unmodified lines
187187 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
188188 _sinittext = .;
189189 INIT_TEXT
190+
191+ /*
192+ *.init.text might be RO so we must ensure this section ends on
193+ * a page boundary.
194+ */
195+ . = ALIGN(PAGE_SIZE);
190196 _einittext = .;
191197 #ifdef CONFIG_PPC64
192198 *(.tramp.ftrace.init);
@@ -200,6 +206,8 @@ SECTIONS · 7 unmodified lines
200206 EXIT_TEXT
201207 }
202208
209+ . = ALIGN(PAGE_SIZE);
210+
203211 INIT_DATA_SECTION(16)
204212
205213 . = ALIGN(8);
arch/riscv/Kconfig+4−2
@@ -137,7 +137,7 @@ config PA_BITS · 136 unmodified lines
137137
138138 config PAGE_OFFSET
139139 hex
140− default 0xC0000000 if 32BIT && MAXPHYSMEM_2GB
140+ default 0xC0000000 if 32BIT && MAXPHYSMEM_1GB
141141 default 0x80000000 if 64BIT && !MMU
142142 default 0xffffffff80000000 if 64BIT && MAXPHYSMEM_2GB
143143 default 0xffffffe000000000 if 64BIT && MAXPHYSMEM_128GB
@@ -247,10 +247,12 @@ config MODULE_SECTIONS · 103 unmodified lines
247247
248248 choice
249249 prompt "Maximum Physical Memory"
250− default MAXPHYSMEM_2GB if 32BIT
250+ default MAXPHYSMEM_1GB if 32BIT
251251 default MAXPHYSMEM_2GB if 64BIT && CMODEL_MEDLOW
252252 default MAXPHYSMEM_128GB if 64BIT && CMODEL_MEDANY
253253
254+ config MAXPHYSMEM_1GB
255+ bool "1GiB"
254256 config MAXPHYSMEM_2GB
255257 bool "2GiB"
256258 config MAXPHYSMEM_128GB
arch/riscv/boot/dts/sifive/hifive-unleashed-a00.dts+2−0
@@ -88,7 +88,9 @@ · 87 unmodified lines
8888 phy-mode = "gmii";
8989 phy-handle = <&phy0>;
9090 phy0: ethernet-phy@0 {
91+ compatible = "ethernet-phy-id0007.0771";
9192 reg = <0>;
93+ reset-gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
9294 };
9395 };
9496
arch/riscv/configs/defconfig+2−0
@@ -64,6 +64,8 @@ CONFIG_HW_RANDOM=y · 63 unmodified lines
6464 CONFIG_HW_RANDOM_VIRTIO=y
6565 CONFIG_SPI=y
6666 CONFIG_SPI_SIFIVE=y
67+CONFIG_GPIOLIB=y
68+CONFIG_GPIO_SIFIVE=y
6769 # CONFIG_PTP_1588_CLOCK is not set
6870 CONFIG_POWER_RESET=y
6971 CONFIG_DRM=y
arch/riscv/include/asm/pgtable.h+0−1
@@ -99,7 +99,6 @@ · 98 unmodified lines
9999 | _PAGE_DIRTY)
100100
101101 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
102−#define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL | _PAGE_EXEC)
103102 #define PAGE_KERNEL_READ __pgprot(_PAGE_KERNEL & ~_PAGE_WRITE)
104103 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL | _PAGE_EXEC)
105104 #define PAGE_KERNEL_READ_EXEC __pgprot((_PAGE_KERNEL & ~_PAGE_WRITE) \
arch/riscv/include/asm/vdso.h+1−1
@@ -10,7 +10,7 @@ · 9 unmodified lines
1010
1111 #include <linux/types.h>
1212
13−#ifndef GENERIC_TIME_VSYSCALL
13+#ifndef CONFIG_GENERIC_TIME_VSYSCALL
1414 struct vdso_data {
1515 };
1616 #endif
arch/riscv/kernel/cacheinfo.c+10−1
@@ -26,7 +26,16 @@ cache_get_priv_group(struct cacheinfo *this_leaf) · 25 unmodified lines
2626
2727 static struct cacheinfo *get_cacheinfo(u32 level, enum cache_type type)
2828 {
29− struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(smp_processor_id());
29+ /*
30+ * Using raw_smp_processor_id() elides a preemptability check, but this
31+ * is really indicative of a larger problem: the cacheinfo UABI assumes
32+ * that cores have a homonogenous view of the cache hierarchy. That
33+ * happens to be the case for the current set of RISC-V systems, but
34+ * likely won't be true in general. Since there's no way to provide
35+ * correct information for these systems via the current UABI we're
36+ * just eliding the check for now.
37+ */
38+ struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(raw_smp_processor_id());
3039 struct cacheinfo *this_leaf;
3140 int index;
3241
arch/riscv/kernel/entry.S+13−11
@@ -124,15 +124,15 @@ skip_context_tracking: · 123 unmodified lines
124124 REG_L a1, (a1)
125125 jr a1
126126 1:
127−#ifdef CONFIG_TRACE_IRQFLAGS
128− call trace_hardirqs_on
129−#endif
130127 /*
131128 * Exceptions run with interrupts enabled or disabled depending on the
132129 * state of SR_PIE in m/sstatus.
133130 */
134131 andi t0, s1, SR_PIE
135132 beqz t0, 1f
133+#ifdef CONFIG_TRACE_IRQFLAGS
134+ call trace_hardirqs_on
135+#endif
136136 csrs CSR_STATUS, SR_IE
137137
138138 1:
@@ -155,6 +155,15 @@ skip_context_tracking: · 16 unmodified lines
155155 tail do_trap_unknown
156156
157157 handle_syscall:
158+#ifdef CONFIG_RISCV_M_MODE
159+ /*
160+ * When running is M-Mode (no MMU config), MPIE does not get set.
161+ * As a result, we need to force enable interrupts here because
162+ * handle_exception did not do set SR_IE as it always sees SR_PIE
163+ * being cleared.
164+ */
165+ csrs CSR_STATUS, SR_IE
166+#endif
158167 #if defined(CONFIG_TRACE_IRQFLAGS) || defined(CONFIG_CONTEXT_TRACKING)
159168 /* Recover a0 - a7 for system calls */
160169 REG_L a0, PT_A0(sp)
@@ -186,14 +195,7 @@ check_syscall_nr: · 25 unmodified lines
186195 * Syscall number held in a7.
187196 * If syscall number is above allowed value, redirect to ni_syscall.
188197 */
189− bge a7, t0, 1f
190− /*
191− * Check if syscall is rejected by tracer, i.e., a7 == -1.
192− * If yes, we pretend it was executed.
193− */
194− li t1, -1
195− beq a7, t1, ret_from_syscall_rejected
196− blt a7, t1, 1f
198+ bgeu a7, t0, 1f
197199 /* Call syscall */
198200 la s0, sys_call_table
199201 slli t0, a7, RISCV_LGPTR
arch/riscv/kernel/setup.c+13−11
@@ -127,7 +127,9 @@ static void __init init_resources(void) · 126 unmodified lines
127127 {
128128 struct memblock_region *region = NULL;
129129 struct resource *res = NULL;
130− int ret = 0;
130+ struct resource *mem_res = NULL;
131+ size_t mem_res_sz = 0;
132+ int ret = 0, i = 0;
131133
132134 code_res.start = __pa_symbol(_text);
133135 code_res.end = __pa_symbol(_etext) - 1;
@@ -145,16 +147,17 @@ static void __init init_resources(void) · 11 unmodified lines
145147 bss_res.end = __pa_symbol(__bss_stop) - 1;
146148 bss_res.flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
147149
150+ mem_res_sz = (memblock.memory.cnt + memblock.reserved.cnt) * sizeof(*mem_res);
151+ mem_res = memblock_alloc(mem_res_sz, SMP_CACHE_BYTES);
152+ if (!mem_res)
153+ panic("%s: Failed to allocate %zu bytes\n", __func__, mem_res_sz);
148154 /*
149155 * Start by adding the reserved regions, if they overlap
150156 * with /memory regions, insert_resource later on will take
151157 * care of it.
152158 */
153159 for_each_reserved_mem_region(region) {
154− res = memblock_alloc(sizeof(struct resource), SMP_CACHE_BYTES);
155− if (!res)
156− panic("%s: Failed to allocate %zu bytes\n", __func__,
157− sizeof(struct resource));
160+ res = &mem_res[i++];
158161
159162 res->name = "Reserved";
160163 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
@@ -171,8 +174,10 @@ static void __init init_resources(void) · 10 unmodified lines
171174 * Ignore any other reserved regions within
172175 * system memory.
173176 */
174− if (memblock_is_memory(res->start))
177+ if (memblock_is_memory(res->start)) {
178+ memblock_free((phys_addr_t) res, sizeof(struct resource));
175179 continue;
180+ }
176181
177182 ret = add_resource(&iomem_resource, res);
178183 if (ret < 0)
@@ -181,10 +186,7 @@ static void __init init_resources(void) · 2 unmodified lines
181186
182187 /* Add /memory regions to the resource tree */
183188 for_each_mem_region(region) {
184− res = memblock_alloc(sizeof(struct resource), SMP_CACHE_BYTES);
185− if (!res)
186− panic("%s: Failed to allocate %zu bytes\n", __func__,
187− sizeof(struct resource));
189+ res = &mem_res[i++];
188190
189191 if (unlikely(memblock_is_nomap(region))) {
190192 res->name = "Reserved";
@@ -205,9 +207,9 @@ static void __init init_resources(void) · 14 unmodified lines
205207 return;
206208
207209 error:
208− memblock_free((phys_addr_t) res, sizeof(struct resource));
209210 /* Better an empty resource tree than an inconsistent one */
210211 release_child_resources(&iomem_resource);
212+ memblock_free((phys_addr_t) mem_res, mem_res_sz);
211213 }
212214
213215
arch/riscv/kernel/stacktrace.c+2−3
@@ -14,7 +14,7 @@ · 13 unmodified lines
1414
1515 #include <asm/stacktrace.h>
1616
17−register unsigned long sp_in_global __asm__("sp");
17+register const unsigned long sp_in_global __asm__("sp");
1818
1919 #ifdef CONFIG_FRAME_POINTER
2020
@@ -28,9 +28,8 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs, · 7 unmodified lines
2828 sp = user_stack_pointer(regs);
2929 pc = instruction_pointer(regs);
3030 } else if (task == NULL || task == current) {
31− const register unsigned long current_sp = sp_in_global;
3231 fp = (unsigned long)__builtin_frame_address(0);
33− sp = current_sp;
32+ sp = sp_in_global;
3433 pc = (unsigned long)walk_stackframe;
3534 } else {
3635 /* task blocked in __switch_to */
arch/riscv/kernel/time.c+3−0
@@ -4,6 +4,7 @@ · 3 unmodified lines
44 * Copyright (C) 2017 SiFive
55 */
66
7+#include <linux/of_clk.h>
78 #include <linux/clocksource.h>
89 #include <linux/delay.h>
910 #include <asm/sbi.h>
@@ -24,6 +25,8 @@ void __init time_init(void) · 14 unmodified lines
2425 riscv_timebase = prop;
2526
2627 lpj_fine = riscv_timebase / HZ;
28+
29+ of_clk_init(NULL);
2730 timer_probe();
2831 }
2932
arch/riscv/kernel/vdso.c+1−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
1212 #include <linux/binfmts.h>
1313 #include <linux/err.h>
1414 #include <asm/page.h>
15−#ifdef GENERIC_TIME_VSYSCALL
15+#ifdef CONFIG_GENERIC_TIME_VSYSCALL
1616 #include <vdso/datapage.h>
1717 #else
1818 #include <asm/vdso.h>
arch/riscv/mm/init.c+14−2
@@ -157,9 +157,10 @@ disable: · 156 unmodified lines
157157 void __init setup_bootmem(void)
158158 {
159159 phys_addr_t mem_start = 0;
160− phys_addr_t start, end = 0;
160+ phys_addr_t start, dram_end, end = 0;
161161 phys_addr_t vmlinux_end = __pa_symbol(&_end);
162162 phys_addr_t vmlinux_start = __pa_symbol(&_start);
163+ phys_addr_t max_mapped_addr = __pa(~(ulong)0);
163164 u64 i;
164165
165166 /* Find the memory region containing the kernel */
@@ -181,7 +182,18 @@ void __init setup_bootmem(void) · 15 unmodified lines
181182 /* Reserve from the start of the kernel to the end of the kernel */
182183 memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start);
183184
184− max_pfn = PFN_DOWN(memblock_end_of_DRAM());
185+ dram_end = memblock_end_of_DRAM();
186+
187+ /*
188+ * memblock allocator is not aware of the fact that last 4K bytes of
189+ * the addressable memory can not be mapped because of IS_ERR_VALUE
190+ * macro. Make sure that last 4k bytes are not usable by memblock
191+ * if end of dram is equal to maximum addressable memory.
192+ */
193+ if (max_mapped_addr == (dram_end - 1))
194+ memblock_set_current_limit(max_mapped_addr - 4096);
195+
196+ max_pfn = PFN_DOWN(dram_end);
185197 max_low_pfn = max_pfn;
186198 dma32_phys_limit = min(4UL * SZ_1G, (unsigned long)PFN_PHYS(max_low_pfn));
187199 set_max_mapnr(max_low_pfn);
arch/riscv/mm/kasan_init.c+2−2
@@ -93,8 +93,8 @@ void __init kasan_init(void) · 92 unmodified lines
9393 VMALLOC_END));
9494
9595 for_each_mem_range(i, &_start, &_end) {
96− void *start = (void *)_start;
97− void *end = (void *)_end;
96+ void *start = (void *)__va(_start);
97+ void *end = (void *)__va(_end);
9898
9999 if (start >= end)
100100 break;
arch/x86/hyperv/hv_init.c+26−3
@@ -315,6 +315,25 @@ static struct syscore_ops hv_syscore_ops = { · 314 unmodified lines
315315 .resume = hv_resume,
316316 };
317317
318+static void (* __initdata old_setup_percpu_clockev)(void);
319+
320+static void __init hv_stimer_setup_percpu_clockev(void)
321+{
322+ /*
323+ * Ignore any errors in setting up stimer clockevents
324+ * as we can run with the LAPIC timer as a fallback.
325+ */
326+ (void)hv_stimer_alloc();
327+
328+ /*
329+ * Still register the LAPIC timer, because the direct-mode STIMER is
330+ * not supported by old versions of Hyper-V. This also allows users
331+ * to switch to LAPIC timer via /sys, if they want to.
332+ */
333+ if (old_setup_percpu_clockev)
334+ old_setup_percpu_clockev();
335+}
336+
318337 /*
319338 * This function is to be invoked early in the boot sequence after the
320339 * hypervisor has been detected.
@@ -393,10 +412,14 @@ void __init hyperv_init(void) · 72 unmodified lines
393412 wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
394413
395414 /*
396− * Ignore any errors in setting up stimer clockevents
397− * as we can run with the LAPIC timer as a fallback.
415+ * hyperv_init() is called before LAPIC is initialized: see
416+ * apic_intr_mode_init() -> x86_platform.apic_post_init() and
417+ * apic_bsp_setup() -> setup_local_APIC(). The direct-mode STIMER
418+ * depends on LAPIC, so hv_stimer_alloc() should be called from
419+ * x86_init.timers.setup_percpu_clockev.
398420 */
399− (void)hv_stimer_alloc();
421+ old_setup_percpu_clockev = x86_init.timers.setup_percpu_clockev;
422+ x86_init.timers.setup_percpu_clockev = hv_stimer_setup_percpu_clockev;
400423
401424 hv_apic_init();
402425
arch/x86/xen/enlighten_hvm.c+12−3
@@ -164,10 +164,10 @@ static int xen_cpu_up_prepare_hvm(unsigned int cpu) · 163 unmodified lines
164164 else
165165 per_cpu(xen_vcpu_id, cpu) = cpu;
166166 rc = xen_vcpu_setup(cpu);
167− if (rc)
167+ if (rc || !xen_have_vector_callback)
168168 return rc;
169169
170− if (xen_have_vector_callback && xen_feature(XENFEAT_hvm_safe_pvclock))
170+ if (xen_feature(XENFEAT_hvm_safe_pvclock))
171171 xen_setup_timer(cpu);
172172
173173 rc = xen_smp_intr_init(cpu);
@@ -188,6 +188,8 @@ static int xen_cpu_dead_hvm(unsigned int cpu) · 14 unmodified lines
188188 return 0;
189189 }
190190
191+static bool no_vector_callback __initdata;
192+
191193 static void __init xen_hvm_guest_init(void)
192194 {
193195 if (xen_pv_domain())
@@ -207,7 +209,7 @@ static void __init xen_hvm_guest_init(void) · 13 unmodified lines
207209
208210 xen_panic_handler_init();
209211
210− if (xen_feature(XENFEAT_hvm_callback_vector))
212+ if (!no_vector_callback && xen_feature(XENFEAT_hvm_callback_vector))
211213 xen_have_vector_callback = 1;
212214
213215 xen_hvm_smp_init();
@@ -233,6 +235,13 @@ static __init int xen_parse_nopv(char *arg) · 19 unmodified lines
233235 }
234236 early_param("xen_nopv", xen_parse_nopv);
235237
238+static __init int xen_parse_no_vector_callback(char *arg)
239+{
240+ no_vector_callback = true;
241+ return 0;
242+}
243+early_param("xen_no_vector_callback", xen_parse_no_vector_callback);
244+
236245 bool __init xen_hvm_need_lapic(void)
237246 {
238247 if (xen_pv_domain())
arch/x86/xen/smp_hvm.c+19−10
@@ -33,9 +33,11 @@ static void __init xen_hvm_smp_prepare_cpus(unsigned int max_cpus) · 32 unmodified lines
3333 int cpu;
3434
3535 native_smp_prepare_cpus(max_cpus);
36− WARN_ON(xen_smp_intr_init(0));
3736
38− xen_init_lock_cpu(0);
37+ if (xen_have_vector_callback) {
38+ WARN_ON(xen_smp_intr_init(0));
39+ xen_init_lock_cpu(0);
40+ }
3941
4042 for_each_possible_cpu(cpu) {
4143 if (cpu == 0)
@@ -50,9 +52,11 @@ static void __init xen_hvm_smp_prepare_cpus(unsigned int max_cpus) · 8 unmodified lines
5052 static void xen_hvm_cpu_die(unsigned int cpu)
5153 {
5254 if (common_cpu_die(cpu) == 0) {
53− xen_smp_intr_free(cpu);
54− xen_uninit_lock_cpu(cpu);
55− xen_teardown_timer(cpu);
55+ if (xen_have_vector_callback) {
56+ xen_smp_intr_free(cpu);
57+ xen_uninit_lock_cpu(cpu);
58+ xen_teardown_timer(cpu);
59+ }
5660 }
5761 }
5862 #else
@@ -64,14 +68,19 @@ static void xen_hvm_cpu_die(unsigned int cpu) · 5 unmodified lines
6468
6569 void __init xen_hvm_smp_init(void)
6670 {
67− if (!xen_have_vector_callback)
71+ smp_ops.smp_prepare_boot_cpu = xen_hvm_smp_prepare_boot_cpu;
72+ smp_ops.smp_prepare_cpus = xen_hvm_smp_prepare_cpus;
73+ smp_ops.smp_cpus_done = xen_smp_cpus_done;
74+ smp_ops.cpu_die = xen_hvm_cpu_die;
75+
76+ if (!xen_have_vector_callback) {
77+#ifdef CONFIG_PARAVIRT_SPINLOCKS
78+ nopvspin = true;
79+#endif
6880 return;
81+ }
6982
70− smp_ops.smp_prepare_cpus = xen_hvm_smp_prepare_cpus;
7183 smp_ops.smp_send_reschedule = xen_smp_send_reschedule;
72− smp_ops.cpu_die = xen_hvm_cpu_die;
7384 smp_ops.send_call_func_ipi = xen_smp_send_call_function_ipi;
7485 smp_ops.send_call_func_single_ipi = xen_smp_send_call_function_single_ipi;
75− smp_ops.smp_prepare_boot_cpu = xen_hvm_smp_prepare_boot_cpu;
76− smp_ops.smp_cpus_done = xen_smp_cpus_done;
7786 }
crypto/asymmetric_keys/public_key.c+2−1
@@ -356,7 +356,8 @@ int public_key_verify_signature(const struct public_key *pkey, · 355 unmodified lines
356356 if (ret)
357357 goto error_free_key;
358358
359− if (strcmp(sig->pkey_algo, "sm2") == 0 && sig->data_size) {
359+ if (sig->pkey_algo && strcmp(sig->pkey_algo, "sm2") == 0 &&
360+ sig->data_size) {
360361 ret = cert_sig_digest_update(sig, tfm);
361362 if (ret)
362363 goto error_free_key;
crypto/xor.c+2−0
@@ -107,6 +107,8 @@ do_xor_speed(struct xor_block_template *tmpl, void *b1, void *b2) · 106 unmodified lines
107107 preempt_enable();
108108
109109 // bytes/ns == GB/s, multiply by 1000 to get MB/s [not MiB/s]
110+ if (!min)
111+ min = 1;
110112 speed = (1000 * REPS * BENCH_SIZE) / (unsigned int)ktime_to_ns(min);
111113 tmpl->speed = speed;
112114
drivers/acpi/internal.h+1−1
@@ -97,7 +97,7 @@ void acpi_scan_table_handler(u32 event, void *table, void *context); · 96 unmodified lines
9797 extern struct list_head acpi_bus_id_list;
9898
9999 struct acpi_device_bus_id {
100− char bus_id[15];
100+ const char *bus_id;
101101 unsigned int instance_no;
102102 struct list_head node;
103103 };
drivers/acpi/scan.c+14−1
@@ -486,6 +486,7 @@ static void acpi_device_del(struct acpi_device *device) · 485 unmodified lines
486486 acpi_device_bus_id->instance_no--;
487487 else {
488488 list_del(&acpi_device_bus_id->node);
489+ kfree_const(acpi_device_bus_id->bus_id);
489490 kfree(acpi_device_bus_id);
490491 }
491492 break;
@@ -674,7 +675,14 @@ int acpi_device_add(struct acpi_device *device, · 182 unmodified lines
674675 }
675676 if (!found) {
676677 acpi_device_bus_id = new_bus_id;
677− strcpy(acpi_device_bus_id->bus_id, acpi_device_hid(device));
678+ acpi_device_bus_id->bus_id =
679+ kstrdup_const(acpi_device_hid(device), GFP_KERNEL);
680+ if (!acpi_device_bus_id->bus_id) {
681+ pr_err(PREFIX "Memory allocation error for bus id\n");
682+ result = -ENOMEM;
683+ goto err_free_new_bus_id;
684+ }
685+
678686 acpi_device_bus_id->instance_no = 0;
679687 list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list);
680688 }
@@ -709,6 +717,11 @@ int acpi_device_add(struct acpi_device *device, · 28 unmodified lines
709717 if (device->parent)
710718 list_del(&device->node);
711719 list_del(&device->wakeup_list);
720+
721+ err_free_new_bus_id:
722+ if (!found)
723+ kfree(new_bus_id);
724+
712725 mutex_unlock(&acpi_device_lock);
713726
714727 err_detach:
drivers/crypto/Kconfig+1−0
@@ -366,6 +366,7 @@ if CRYPTO_DEV_OMAP · 365 unmodified lines
366366 config CRYPTO_DEV_OMAP_SHAM
367367 tristate "Support for OMAP MD5/SHA1/SHA2 hw accelerator"
368368 depends on ARCH_OMAP2PLUS
369+ select CRYPTO_ENGINE
369370 select CRYPTO_SHA1
370371 select CRYPTO_MD5
371372 select CRYPTO_SHA256
drivers/dma-buf/heaps/cma_heap.c+3−0
@@ -251,6 +251,9 @@ static void cma_heap_dma_buf_release(struct dma_buf *dmabuf) · 250 unmodified lines
251251 buffer->vaddr = NULL;
252252 }
253253
254+ /* free page list */
255+ kfree(buffer->pages);
256+ /* release memory */
254257 cma_release(cma_heap->cma, buffer->cma_pages, buffer->pagecount);
255258 kfree(buffer);
256259 }
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c+36−17
@@ -112,6 +112,7 @@ int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev) · 111 unmodified lines
112112 union igp_info {
113113 struct atom_integrated_system_info_v1_11 v11;
114114 struct atom_integrated_system_info_v1_12 v12;
115+ struct atom_integrated_system_info_v2_1 v21;
115116 };
116117
117118 union umc_info {
@@ -209,24 +210,42 @@ amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev, · 91 unmodified lines
209210 if (adev->flags & AMD_IS_APU) {
210211 igp_info = (union igp_info *)
211212 (mode_info->atom_context->bios + data_offset);
212− switch (crev) {
213− case 11:
214− mem_channel_number = igp_info->v11.umachannelnumber;
215− /* channel width is 64 */
216− if (vram_width)
217− *vram_width = mem_channel_number * 64;
218− mem_type = igp_info->v11.memorytype;
219− if (vram_type)
220− *vram_type = convert_atom_mem_type_to_vram_type(adev, mem_type);
213+ switch (frev) {
214+ case 1:
215+ switch (crev) {
216+ case 11:
217+ case 12:
218+ mem_channel_number = igp_info->v11.umachannelnumber;
219+ if (!mem_channel_number)
220+ mem_channel_number = 1;
221+ /* channel width is 64 */
222+ if (vram_width)
223+ *vram_width = mem_channel_number * 64;
224+ mem_type = igp_info->v11.memorytype;
225+ if (vram_type)
226+ *vram_type = convert_atom_mem_type_to_vram_type(adev, mem_type);
227+ break;
228+ default:
229+ return -EINVAL;
230+ }
221231 break;
222− case 12:
223− mem_channel_number = igp_info->v12.umachannelnumber;
224− /* channel width is 64 */
225− if (vram_width)
226− *vram_width = mem_channel_number * 64;
227− mem_type = igp_info->v12.memorytype;
228− if (vram_type)
229− *vram_type = convert_atom_mem_type_to_vram_type(adev, mem_type);
232+ case 2:
233+ switch (crev) {
234+ case 1:
235+ case 2:
236+ mem_channel_number = igp_info->v21.umachannelnumber;
237+ if (!mem_channel_number)
238+ mem_channel_number = 1;
239+ /* channel width is 64 */
240+ if (vram_width)
241+ *vram_width = mem_channel_number * 64;
242+ mem_type = igp_info->v21.memorytype;
243+ if (vram_type)
244+ *vram_type = convert_atom_mem_type_to_vram_type(adev, mem_type);
245+ break;
246+ default:
247+ return -EINVAL;
248+ }
230249 break;
231250 default:
232251 return -EINVAL;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c+1−1
@@ -3034,7 +3034,7 @@ bool amdgpu_device_asic_has_dc_support(enum amd_asic_type asic_type) · 3033 unmodified lines
30343034 #endif
30353035 default:
30363036 if (amdgpu_dc > 0)
3037− DRM_INFO("Display Core has been requested via kernel parameter "
3037+ DRM_INFO_ONCE("Display Core has been requested via kernel parameter "
30383038 "but isn't supported by ASIC, ignoring\n");
30393039 return false;
30403040 }
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c+2−0
@@ -1085,6 +1085,8 @@ static const struct pci_device_id pciidlist[] = { · 1084 unmodified lines
10851085
10861086 /* Renoir */
10871087 {0x1002, 0x1636, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RENOIR|AMD_IS_APU},
1088+ {0x1002, 0x1638, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RENOIR|AMD_IS_APU},
1089+ {0x1002, 0x164C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RENOIR|AMD_IS_APU},
10881090
10891091 /* Navi12 */
10901092 {0x1002, 0x7360, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_NAVI12},
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c+46−2
@@ -99,6 +99,10 @@ · 98 unmodified lines
9999 #define mmGCR_GENERAL_CNTL_Sienna_Cichlid 0x1580
100100 #define mmGCR_GENERAL_CNTL_Sienna_Cichlid_BASE_IDX 0
101101
102+#define mmGOLDEN_TSC_COUNT_UPPER_Vangogh 0x0025
103+#define mmGOLDEN_TSC_COUNT_UPPER_Vangogh_BASE_IDX 1
104+#define mmGOLDEN_TSC_COUNT_LOWER_Vangogh 0x0026
105+#define mmGOLDEN_TSC_COUNT_LOWER_Vangogh_BASE_IDX 1
102106 #define mmSPI_CONFIG_CNTL_1_Vangogh 0x2441
103107 #define mmSPI_CONFIG_CNTL_1_Vangogh_BASE_IDX 1
104108 #define mmVGT_TF_MEMORY_BASE_HI_Vangogh 0x2261
@@ -160,6 +164,9 @@ · 55 unmodified lines
160164 #define mmGCVM_L2_CGTT_CLK_CTRL_Sienna_Cichlid 0x15db
161165 #define mmGCVM_L2_CGTT_CLK_CTRL_Sienna_Cichlid_BASE_IDX 0
162166
167+#define mmGC_THROTTLE_CTRL_Sienna_Cichlid 0x2030
168+#define mmGC_THROTTLE_CTRL_Sienna_Cichlid_BASE_IDX 0
169+
163170 MODULE_FIRMWARE("amdgpu/navi10_ce.bin");
164171 MODULE_FIRMWARE("amdgpu/navi10_pfp.bin");
165172 MODULE_FIRMWARE("amdgpu/navi10_me.bin");
@@ -3324,6 +3331,7 @@ static void gfx_v10_0_ring_emit_de_meta(struct amdgpu_ring *ring, bool resume); · 3158 unmodified lines
33243331 static void gfx_v10_0_ring_emit_frame_cntl(struct amdgpu_ring *ring, bool start, bool secure);
33253332 static u32 gfx_v10_3_get_disabled_sa(struct amdgpu_device *adev);
33263333 static void gfx_v10_3_program_pbb_mode(struct amdgpu_device *adev);
3334+static void gfx_v10_3_set_power_brake_sequence(struct amdgpu_device *adev);
33273335
33283336 static void gfx10_kiq_set_resources(struct amdgpu_ring *kiq_ring, uint64_t queue_mask)
33293337 {
@@ -7192,6 +7200,9 @@ static int gfx_v10_0_hw_init(void *handle) · 3862 unmodified lines
71927200 if (adev->asic_type == CHIP_SIENNA_CICHLID)
71937201 gfx_v10_3_program_pbb_mode(adev);
71947202
7203+ if (adev->asic_type >= CHIP_SIENNA_CICHLID)
7204+ gfx_v10_3_set_power_brake_sequence(adev);
7205+
71957206 return r;
71967207 }
71977208
@@ -7377,8 +7388,16 @@ static uint64_t gfx_v10_0_get_gpu_clock_counter(struct amdgpu_device *adev) · 179 unmodified lines
73777388
73787389 amdgpu_gfx_off_ctrl(adev, false);
73797390 mutex_lock(&adev->gfx.gpu_clock_mutex);
7380− clock = (uint64_t)RREG32_SOC15(SMUIO, 0, mmGOLDEN_TSC_COUNT_LOWER) |
7381− ((uint64_t)RREG32_SOC15(SMUIO, 0, mmGOLDEN_TSC_COUNT_UPPER) << 32ULL);
7391+ switch (adev->asic_type) {
7392+ case CHIP_VANGOGH:
7393+ clock = (uint64_t)RREG32_SOC15(SMUIO, 0, mmGOLDEN_TSC_COUNT_LOWER_Vangogh) |
7394+ ((uint64_t)RREG32_SOC15(SMUIO, 0, mmGOLDEN_TSC_COUNT_UPPER_Vangogh) << 32ULL);
7395+ break;
7396+ default:
7397+ clock = (uint64_t)RREG32_SOC15(SMUIO, 0, mmGOLDEN_TSC_COUNT_LOWER) |
7398+ ((uint64_t)RREG32_SOC15(SMUIO, 0, mmGOLDEN_TSC_COUNT_UPPER) << 32ULL);
7399+ break;
7400+ }
73827401 mutex_unlock(&adev->gfx.gpu_clock_mutex);
73837402 amdgpu_gfx_off_ctrl(adev, true);
73847403 return clock;
@@ -9169,6 +9188,31 @@ static void gfx_v10_3_program_pbb_mode(struct amdgpu_device *adev) · 1784 unmodified lines
91699188 }
91709189 }
91719190
9191+static void gfx_v10_3_set_power_brake_sequence(struct amdgpu_device *adev)
9192+{
9193+ WREG32_SOC15(GC, 0, mmGRBM_GFX_INDEX,
9194+ (0x1 << GRBM_GFX_INDEX__SA_BROADCAST_WRITES__SHIFT) |
9195+ (0x1 << GRBM_GFX_INDEX__INSTANCE_BROADCAST_WRITES__SHIFT) |
9196+ (0x1 << GRBM_GFX_INDEX__SE_BROADCAST_WRITES__SHIFT));
9197+
9198+ WREG32_SOC15(GC, 0, mmGC_CAC_IND_INDEX, ixPWRBRK_STALL_PATTERN_CTRL);
9199+ WREG32_SOC15(GC, 0, mmGC_CAC_IND_DATA,
9200+ (0x1 << PWRBRK_STALL_PATTERN_CTRL__PWRBRK_STEP_INTERVAL__SHIFT) |
9201+ (0x12 << PWRBRK_STALL_PATTERN_CTRL__PWRBRK_BEGIN_STEP__SHIFT) |
9202+ (0x13 << PWRBRK_STALL_PATTERN_CTRL__PWRBRK_END_STEP__SHIFT) |
9203+ (0xf << PWRBRK_STALL_PATTERN_CTRL__PWRBRK_THROTTLE_PATTERN_BIT_NUMS__SHIFT));
9204+
9205+ WREG32_SOC15(GC, 0, mmGC_THROTTLE_CTRL_Sienna_Cichlid,
9206+ (0x1 << GC_THROTTLE_CTRL__PWRBRK_STALL_EN__SHIFT) |
9207+ (0x1 << GC_THROTTLE_CTRL__PATTERN_MODE__SHIFT) |
9208+ (0x5 << GC_THROTTLE_CTRL__RELEASE_STEP_INTERVAL__SHIFT));
9209+
9210+ WREG32_SOC15(GC, 0, mmDIDT_IND_INDEX, ixDIDT_SQ_THROTTLE_CTRL);
9211+
9212+ WREG32_SOC15(GC, 0, mmDIDT_IND_DATA,
9213+ (0x1 << DIDT_SQ_THROTTLE_CTRL__PWRBRK_STALL_EN__SHIFT));
9214+}
9215+
91729216 const struct amdgpu_ip_block_version gfx_v10_0_ip_block =
91739217 {
91749218 .type = AMD_IP_BLOCK_TYPE_GFX,
drivers/gpu/drm/amd/amdgpu/psp_gfx_if.h+1−1
@@ -47,7 +47,7 @@ enum psp_gfx_crtl_cmd_id · 46 unmodified lines
4747 GFX_CTRL_CMD_ID_DISABLE_INT = 0x00060000, /* disable PSP-to-Gfx interrupt */
4848 GFX_CTRL_CMD_ID_MODE1_RST = 0x00070000, /* trigger the Mode 1 reset */
4949 GFX_CTRL_CMD_ID_GBR_IH_SET = 0x00080000, /* set Gbr IH_RB_CNTL registers */
50− GFX_CTRL_CMD_ID_CONSUME_CMD = 0x000A0000, /* send interrupt to psp for updating write pointer of vf */
50+ GFX_CTRL_CMD_ID_CONSUME_CMD = 0x00090000, /* send interrupt to psp for updating write pointer of vf */
5151 GFX_CTRL_CMD_ID_DESTROY_GPCOM_RING = 0x000C0000, /* destroy GPCOM ring */
5252
5353 GFX_CTRL_CMD_ID_MAX = 0x000F0000, /* max command ID */
drivers/gpu/drm/amd/amdgpu/soc15.c+2−1
@@ -1239,7 +1239,8 @@ static int soc15_common_early_init(void *handle) · 1238 unmodified lines
12391239 break;
12401240 case CHIP_RENOIR:
12411241 adev->asic_funcs = &soc15_asic_funcs;
1242− if (adev->pdev->device == 0x1636)
1242+ if ((adev->pdev->device == 0x1636) ||
1243+ (adev->pdev->device == 0x164c))
12431244 adev->apu_flags |= AMD_APU_IS_RENOIR;
12441245 else
12451246 adev->apu_flags |= AMD_APU_IS_GREEN_SARDINE;
drivers/gpu/drm/amd/amdkfd/kfd_crat.c+7−4
@@ -1040,11 +1040,14 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size) · 1039 unmodified lines
10401040 (struct crat_subtype_iolink *)sub_type_hdr);
10411041 if (ret < 0)
10421042 return ret;
1043− crat_table->length += (sub_type_hdr->length * entries);
1044− crat_table->total_entries += entries;
10451043
1046− sub_type_hdr = (typeof(sub_type_hdr))((char *)sub_type_hdr +
1047− sub_type_hdr->length * entries);
1044+ if (entries) {
1045+ crat_table->length += (sub_type_hdr->length * entries);
1046+ crat_table->total_entries += entries;
1047+
1048+ sub_type_hdr = (typeof(sub_type_hdr))((char *)sub_type_hdr +
1049+ sub_type_hdr->length * entries);
1050+ }
10481051 #else
10491052 pr_info("IO link not available for non x86 platforms\n");
10501053 #endif
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c+9−133
@@ -939,41 +939,6 @@ static void mmhub_read_system_context(struct amdgpu_device *adev, struct dc_phy_ · 938 unmodified lines
939939 }
940940 #endif
941941
942−#ifdef CONFIG_DEBUG_FS
943−static int create_crtc_crc_properties(struct amdgpu_display_manager *dm)
944−{
945− dm->crc_win_x_start_property =
946− drm_property_create_range(adev_to_drm(dm->adev),
947− DRM_MODE_PROP_ATOMIC,
948− "AMD_CRC_WIN_X_START", 0, U16_MAX);
949− if (!dm->crc_win_x_start_property)
950− return -ENOMEM;
951−
952− dm->crc_win_y_start_property =
953− drm_property_create_range(adev_to_drm(dm->adev),
954− DRM_MODE_PROP_ATOMIC,
955− "AMD_CRC_WIN_Y_START", 0, U16_MAX);
956− if (!dm->crc_win_y_start_property)
957− return -ENOMEM;
958−
959− dm->crc_win_x_end_property =
960− drm_property_create_range(adev_to_drm(dm->adev),
961− DRM_MODE_PROP_ATOMIC,
962− "AMD_CRC_WIN_X_END", 0, U16_MAX);
963− if (!dm->crc_win_x_end_property)
964− return -ENOMEM;
965−
966− dm->crc_win_y_end_property =
967− drm_property_create_range(adev_to_drm(dm->adev),
968− DRM_MODE_PROP_ATOMIC,
969− "AMD_CRC_WIN_Y_END", 0, U16_MAX);
970− if (!dm->crc_win_y_end_property)
971− return -ENOMEM;
972−
973− return 0;
974−}
975−#endif
976−
977942 static int amdgpu_dm_init(struct amdgpu_device *adev)
978943 {
979944 struct dc_init_data init_data;
@@ -1120,10 +1085,6 @@ static int amdgpu_dm_init(struct amdgpu_device *adev) · 140 unmodified lines
11201085
11211086 dc_init_callbacks(adev->dm.dc, &init_params);
11221087 }
1123−#endif
1124−#ifdef CONFIG_DEBUG_FS
1125− if (create_crtc_crc_properties(&adev->dm))
1126− DRM_ERROR("amdgpu: failed to create crc property.\n");
11271088 #endif
11281089 if (amdgpu_dm_initialize_drm_device(adev)) {
11291090 DRM_ERROR(
@@ -5333,64 +5294,12 @@ dm_crtc_duplicate_state(struct drm_crtc *crtc) · 4203 unmodified lines
53335294 state->crc_src = cur->crc_src;
53345295 state->cm_has_degamma = cur->cm_has_degamma;
53355296 state->cm_is_degamma_srgb = cur->cm_is_degamma_srgb;
5336−#ifdef CONFIG_DEBUG_FS
5337− state->crc_window = cur->crc_window;
5338−#endif
5297+
53395298 /* TODO Duplicate dc_stream after objects are stream object is flattened */
53405299
53415300 return &state->base;
53425301 }
53435302
5344−#ifdef CONFIG_DEBUG_FS
5345−static int amdgpu_dm_crtc_atomic_set_property(struct drm_crtc *crtc,
5346− struct drm_crtc_state *crtc_state,
5347− struct drm_property *property,
5348− uint64_t val)
5349−{
5350− struct drm_device *dev = crtc->dev;
5351− struct amdgpu_device *adev = drm_to_adev(dev);
5352− struct dm_crtc_state *dm_new_state =
5353− to_dm_crtc_state(crtc_state);
5354−
5355− if (property == adev->dm.crc_win_x_start_property)
5356− dm_new_state->crc_window.x_start = val;
5357− else if (property == adev->dm.crc_win_y_start_property)
5358− dm_new_state->crc_window.y_start = val;
5359− else if (property == adev->dm.crc_win_x_end_property)
5360− dm_new_state->crc_window.x_end = val;
5361− else if (property == adev->dm.crc_win_y_end_property)
5362− dm_new_state->crc_window.y_end = val;
5363− else
5364− return -EINVAL;
5365−
5366− return 0;
5367−}
5368−
5369−static int amdgpu_dm_crtc_atomic_get_property(struct drm_crtc *crtc,
5370− const struct drm_crtc_state *state,
5371− struct drm_property *property,
5372− uint64_t *val)
5373−{
5374− struct drm_device *dev = crtc->dev;
5375− struct amdgpu_device *adev = drm_to_adev(dev);
5376− struct dm_crtc_state *dm_state =
5377− to_dm_crtc_state(state);
5378−
5379− if (property == adev->dm.crc_win_x_start_property)
5380− *val = dm_state->crc_window.x_start;
5381− else if (property == adev->dm.crc_win_y_start_property)
5382− *val = dm_state->crc_window.y_start;
5383− else if (property == adev->dm.crc_win_x_end_property)
5384− *val = dm_state->crc_window.x_end;
5385− else if (property == adev->dm.crc_win_y_end_property)
5386− *val = dm_state->crc_window.y_end;
5387− else
5388− return -EINVAL;
5389−
5390− return 0;
5391−}
5392−#endif
5393−
53945303 static inline int dm_set_vupdate_irq(struct drm_crtc *crtc, bool enable)
53955304 {
53965305 enum dc_irq_source irq_source;
@@ -5457,10 +5366,6 @@ static const struct drm_crtc_funcs amdgpu_dm_crtc_funcs = { · 60 unmodified lines
54575366 .enable_vblank = dm_enable_vblank,
54585367 .disable_vblank = dm_disable_vblank,
54595368 .get_vblank_timestamp = drm_crtc_vblank_helper_get_vblank_timestamp,
5460−#ifdef CONFIG_DEBUG_FS
5461− .atomic_set_property = amdgpu_dm_crtc_atomic_set_property,
5462− .atomic_get_property = amdgpu_dm_crtc_atomic_get_property,
5463−#endif
54645369 };
54655370
54665371 static enum drm_connector_status
@@ -6662,25 +6567,6 @@ static int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm, · 1195 unmodified lines
66626567 return 0;
66636568 }
66646569
6665−#ifdef CONFIG_DEBUG_FS
6666−static void attach_crtc_crc_properties(struct amdgpu_display_manager *dm,
6667− struct amdgpu_crtc *acrtc)
6668−{
6669− drm_object_attach_property(&acrtc->base.base,
6670− dm->crc_win_x_start_property,
6671− 0);
6672− drm_object_attach_property(&acrtc->base.base,
6673− dm->crc_win_y_start_property,
6674− 0);
6675− drm_object_attach_property(&acrtc->base.base,
6676− dm->crc_win_x_end_property,
6677− 0);
6678− drm_object_attach_property(&acrtc->base.base,
6679− dm->crc_win_y_end_property,
6680− 0);
6681−}
6682−#endif
6683−
66846570 static int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm,
66856571 struct drm_plane *plane,
66866572 uint32_t crtc_index)
@@ -6728,9 +6614,7 @@ static int amdgpu_dm_crtc_init(struct amdgpu_display_manager *dm, · 41 unmodified lines
67286614 drm_crtc_enable_color_mgmt(&acrtc->base, MAX_COLOR_LUT_ENTRIES,
67296615 true, MAX_COLOR_LUT_ENTRIES);
67306616 drm_mode_crtc_set_gamma_size(&acrtc->base, MAX_COLOR_LEGACY_LUT_ENTRIES);
6731−#ifdef CONFIG_DEBUG_FS
6732− attach_crtc_crc_properties(dm, acrtc);
6733−#endif
6617+
67346618 return 0;
67356619
67366620 fail:
@@ -8367,7 +8251,6 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) · 1630 unmodified lines
83678251 */
83688252 for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
83698253 struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
8370− bool configure_crc = false;
83718254
83728255 dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
83738256
@@ -8377,27 +8260,20 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) · 3 unmodified lines
83778260 dc_stream_retain(dm_new_crtc_state->stream);
83788261 acrtc->dm_irq_params.stream = dm_new_crtc_state->stream;
83798262 manage_dm_interrupts(adev, acrtc, true);
8380− }
8381− if (IS_ENABLED(CONFIG_DEBUG_FS) && new_crtc_state->active &&
8382− amdgpu_dm_is_valid_crc_source(dm_new_crtc_state->crc_src)) {
8263+
8264+#ifdef CONFIG_DEBUG_FS
83838265 /**
83848266 * Frontend may have changed so reapply the CRC capture
83858267 * settings for the stream.
83868268 */
83878269 dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
8388− dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);
83898270
8390− if (amdgpu_dm_crc_window_is_default(dm_new_crtc_state)) {
8391− if (!old_crtc_state->active || drm_atomic_crtc_needs_modeset(new_crtc_state))
8392− configure_crc = true;
8393− } else {
8394− if (amdgpu_dm_crc_window_changed(dm_new_crtc_state, dm_old_crtc_state))
8395− configure_crc = true;
8396− }
8397−
8398− if (configure_crc)
8271+ if (amdgpu_dm_is_valid_crc_source(dm_new_crtc_state->crc_src)) {
83998272 amdgpu_dm_crtc_configure_crc_source(
8400− crtc, dm_new_crtc_state, dm_new_crtc_state->crc_src);
8273+ crtc, dm_new_crtc_state,
8274+ dm_new_crtc_state->crc_src);
8275+ }
8276+#endif
84018277 }
84028278 }
84038279
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h+0−38
@@ -336,32 +336,6 @@ struct amdgpu_display_manager { · 335 unmodified lines
336336 */
337337 const struct gpu_info_soc_bounding_box_v1_0 *soc_bounding_box;
338338
339−#ifdef CONFIG_DEBUG_FS
340− /**
341− * @crc_win_x_start_property:
342− *
343− * X start of the crc calculation window
344− */
345− struct drm_property *crc_win_x_start_property;
346− /**
347− * @crc_win_y_start_property:
348− *
349− * Y start of the crc calculation window
350− */
351− struct drm_property *crc_win_y_start_property;
352− /**
353− * @crc_win_x_end_property:
354− *
355− * X end of the crc calculation window
356− */
357− struct drm_property *crc_win_x_end_property;
358− /**
359− * @crc_win_y_end_property:
360− *
361− * Y end of the crc calculation window
362− */
363− struct drm_property *crc_win_y_end_property;
364−#endif
365339 /**
366340 * @mst_encoders:
367341 *
@@ -448,15 +422,6 @@ struct dm_plane_state { · 80 unmodified lines
448422 struct dc_plane_state *dc_state;
449423 };
450424
451−#ifdef CONFIG_DEBUG_FS
452−struct crc_rec {
453− uint16_t x_start;
454− uint16_t y_start;
455− uint16_t x_end;
456− uint16_t y_end;
457− };
458−#endif
459−
460425 struct dm_crtc_state {
461426 struct drm_crtc_state base;
462427 struct dc_stream_state *stream;
@@ -479,9 +444,6 @@ struct dm_crtc_state { · 16 unmodified lines
479444 struct dc_info_packet vrr_infopacket;
480445
481446 int abm_level;
482−#ifdef CONFIG_DEBUG_FS
483− struct crc_rec crc_window;
484−#endif
485447 };
486448
487449 #define to_dm_crtc_state(x) container_of(x, struct dm_crtc_state, base)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.c+1−53
@@ -81,41 +81,6 @@ const char *const *amdgpu_dm_crtc_get_crc_sources(struct drm_crtc *crtc, · 80 unmodified lines
8181 return pipe_crc_sources;
8282 }
8383
84−static void amdgpu_dm_set_crc_window_default(struct dm_crtc_state *dm_crtc_state)
85−{
86− dm_crtc_state->crc_window.x_start = 0;
87− dm_crtc_state->crc_window.y_start = 0;
88− dm_crtc_state->crc_window.x_end = 0;
89− dm_crtc_state->crc_window.y_end = 0;
90−}
91−
92−bool amdgpu_dm_crc_window_is_default(struct dm_crtc_state *dm_crtc_state)
93−{
94− bool ret = true;
95−
96− if ((dm_crtc_state->crc_window.x_start != 0) ||
97− (dm_crtc_state->crc_window.y_start != 0) ||
98− (dm_crtc_state->crc_window.x_end != 0) ||
99− (dm_crtc_state->crc_window.y_end != 0))
100− ret = false;
101−
102− return ret;
103−}
104−
105−bool amdgpu_dm_crc_window_changed(struct dm_crtc_state *dm_new_crtc_state,
106− struct dm_crtc_state *dm_old_crtc_state)
107−{
108− bool ret = false;
109−
110− if ((dm_new_crtc_state->crc_window.x_start != dm_old_crtc_state->crc_window.x_start) ||
111− (dm_new_crtc_state->crc_window.y_start != dm_old_crtc_state->crc_window.y_start) ||
112− (dm_new_crtc_state->crc_window.x_end != dm_old_crtc_state->crc_window.x_end) ||
113− (dm_new_crtc_state->crc_window.y_end != dm_old_crtc_state->crc_window.y_end))
114− ret = true;
115−
116− return ret;
117−}
118−
11984 int
12085 amdgpu_dm_crtc_verify_crc_source(struct drm_crtc *crtc, const char *src_name,
12186 size_t *values_cnt)
@@ -140,7 +105,6 @@ int amdgpu_dm_crtc_configure_crc_source(struct drm_crtc *crtc, · 18 unmodified lines
140105 struct dc_stream_state *stream_state = dm_crtc_state->stream;
141106 bool enable = amdgpu_dm_is_valid_crc_source(source);
142107 int ret = 0;
143− struct crc_params *crc_window = NULL, tmp_window;
144108
145109 /* Configuration will be deferred to stream enable. */
146110 if (!stream_state)
@@ -150,24 +114,8 @@ int amdgpu_dm_crtc_configure_crc_source(struct drm_crtc *crtc, · 3 unmodified lines
150114
151115 /* Enable CRTC CRC generation if necessary. */
152116 if (dm_is_crc_source_crtc(source) || source == AMDGPU_DM_PIPE_CRC_SOURCE_NONE) {
153− if (!enable)
154− amdgpu_dm_set_crc_window_default(dm_crtc_state);
155−
156− if (!amdgpu_dm_crc_window_is_default(dm_crtc_state)) {
157− crc_window = &tmp_window;
158−
159− tmp_window.windowa_x_start = dm_crtc_state->crc_window.x_start;
160− tmp_window.windowa_y_start = dm_crtc_state->crc_window.y_start;
161− tmp_window.windowa_x_end = dm_crtc_state->crc_window.x_end;
162− tmp_window.windowa_y_end = dm_crtc_state->crc_window.y_end;
163− tmp_window.windowb_x_start = dm_crtc_state->crc_window.x_start;
164− tmp_window.windowb_y_start = dm_crtc_state->crc_window.y_start;
165− tmp_window.windowb_x_end = dm_crtc_state->crc_window.x_end;
166− tmp_window.windowb_y_end = dm_crtc_state->crc_window.y_end;
167− }
168−
169117 if (!dc_stream_configure_crc(stream_state->ctx->dc,
170− stream_state, crc_window, enable, enable)) {
118+ stream_state, NULL, enable, enable)) {
171119 ret = -EINVAL;
172120 goto unlock;
173121 }
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_crc.h+1−4
@@ -46,13 +46,10 @@ static inline bool amdgpu_dm_is_valid_crc_source(enum amdgpu_dm_pipe_crc_source · 45 unmodified lines
4646 }
4747
4848 /* amdgpu_dm_crc.c */
49−bool amdgpu_dm_crc_window_is_default(struct dm_crtc_state *dm_crtc_state);
50−bool amdgpu_dm_crc_window_changed(struct dm_crtc_state *dm_new_crtc_state,
51− struct dm_crtc_state *dm_old_crtc_state);
49+#ifdef CONFIG_DEBUG_FS
5250 int amdgpu_dm_crtc_configure_crc_source(struct drm_crtc *crtc,
5351 struct dm_crtc_state *dm_crtc_state,
5452 enum amdgpu_dm_pipe_crc_source source);
55−#ifdef CONFIG_DEBUG_FS
5653 int amdgpu_dm_crtc_set_crc_source(struct drm_crtc *crtc, const char *src_name);
5754 int amdgpu_dm_crtc_verify_crc_source(struct drm_crtc *crtc,
5855 const char *src_name,
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c+7−1
@@ -3992,7 +3992,7 @@ bool dc_link_dp_set_test_pattern( · 3991 unmodified lines
39923992 unsigned int cust_pattern_size)
39933993 {
39943994 struct pipe_ctx *pipes = link->dc->current_state->res_ctx.pipe_ctx;
3995− struct pipe_ctx *pipe_ctx = &pipes[0];
3995+ struct pipe_ctx *pipe_ctx = NULL;
39963996 unsigned int lane;
39973997 unsigned int i;
39983998 unsigned char link_qual_pattern[LANE_COUNT_DP_MAX] = {0};
@@ -4002,12 +4002,18 @@ bool dc_link_dp_set_test_pattern( · 3 unmodified lines
40024002 memset(&training_pattern, 0, sizeof(training_pattern));
40034003
40044004 for (i = 0; i < MAX_PIPES; i++) {
4005+ if (pipes[i].stream == NULL)
4006+ continue;
4007+
40054008 if (pipes[i].stream->link == link && !pipes[i].top_pipe && !pipes[i].prev_odm_pipe) {
40064009 pipe_ctx = &pipes[i];
40074010 break;
40084011 }
40094012 }
40104013
4014+ if (pipe_ctx == NULL)
4015+ return false;
4016+
40114017 /* Reset CRTC Test Pattern if it is currently running and request is VideoMode */
40124018 if (link->test_pattern_enabled && test_pattern ==
40134019 DP_TEST_PATTERN_VIDEO_MODE) {
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_mpc.c+1−1
@@ -470,7 +470,7 @@ void mpc1_cursor_lock(struct mpc *mpc, int opp_id, bool lock) · 469 unmodified lines
470470 unsigned int mpc1_get_mpc_out_mux(struct mpc *mpc, int opp_id)
471471 {
472472 struct dcn10_mpc *mpc10 = TO_DCN10_MPC(mpc);
473− uint32_t val = 0;
473+ uint32_t val = 0xf;
474474
475475 if (opp_id < MAX_OPP && REG(MUX[opp_id]))
476476 REG_GET(MUX[opp_id], MPC_OUT_MUX, &val);
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c+2−2
@@ -608,8 +608,8 @@ static const struct dc_debug_options debug_defaults_drv = { · 607 unmodified lines
608608 .disable_pplib_clock_request = false,
609609 .disable_pplib_wm_range = false,
610610 .pplib_wm_report_mode = WM_REPORT_DEFAULT,
611− .pipe_split_policy = MPC_SPLIT_DYNAMIC,
612− .force_single_disp_pipe_split = true,
611+ .pipe_split_policy = MPC_SPLIT_AVOID,
612+ .force_single_disp_pipe_split = false,
613613 .disable_dcc = DCC_ENABLE,
614614 .voltage_align_fclk = true,
615615 .disable_stereo_support = true,
drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c+1−0
@@ -1731,6 +1731,7 @@ static struct resource_funcs dcn301_res_pool_funcs = { · 1730 unmodified lines
17311731 .populate_dml_pipes = dcn30_populate_dml_pipes_from_context,
17321732 .acquire_idle_pipe_for_layer = dcn20_acquire_idle_pipe_for_layer,
17331733 .add_stream_to_ctx = dcn30_add_stream_to_ctx,
1734+ .add_dsc_to_stream_resource = dcn20_add_dsc_to_stream_resource,
17341735 .remove_stream_from_ctx = dcn20_remove_stream_from_ctx,
17351736 .populate_dml_writeback_from_context = dcn30_populate_dml_writeback_from_context,
17361737 .set_mcif_arb_params = dcn30_set_mcif_arb_params,
drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c+6−5
@@ -2635,14 +2635,15 @@ static void dml20v2_DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndP · 2634 unmodified lines
26352635 }
26362636
26372637 if (mode_lib->vba.DRAMClockChangeSupportsVActive &&
2638− mode_lib->vba.MinActiveDRAMClockChangeMargin > 60 &&
2639− mode_lib->vba.PrefetchMode[mode_lib->vba.VoltageLevel][mode_lib->vba.maxMpcComb] == 0) {
2638+ mode_lib->vba.MinActiveDRAMClockChangeMargin > 60) {
26402639 mode_lib->vba.DRAMClockChangeWatermark += 25;
26412640
26422641 for (k = 0; k < mode_lib->vba.NumberOfActivePlanes; ++k) {
2643− if (mode_lib->vba.DRAMClockChangeWatermark >
2644− dml_max(mode_lib->vba.StutterEnterPlusExitWatermark, mode_lib->vba.UrgentWatermark))
2645− mode_lib->vba.MinTTUVBlank[k] += 25;
2642+ if (mode_lib->vba.PrefetchMode[mode_lib->vba.VoltageLevel][mode_lib->vba.maxMpcComb] == 0) {
2643+ if (mode_lib->vba.DRAMClockChangeWatermark >
2644+ dml_max(mode_lib->vba.StutterEnterPlusExitWatermark, mode_lib->vba.UrgentWatermark))
2645+ mode_lib->vba.MinTTUVBlank[k] += 25;
2646+ }
26462647 }
26472648
26482649 mode_lib->vba.DRAMClockChangeSupport[0][0] = dm_dram_clock_change_vactive;
drivers/gpu/drm/drm_plane.c+8−1
@@ -1163,7 +1163,14 @@ retry: · 1162 unmodified lines
11631163 if (ret)
11641164 goto out;
11651165
1166− if (old_fb->format != fb->format) {
1166+ /*
1167+ * Only check the FOURCC format code, excluding modifiers. This is
1168+ * enough for all legacy drivers. Atomic drivers have their own
1169+ * checks in their ->atomic_check implementation, which will
1170+ * return -EINVAL if any hw or driver constraint is violated due
1171+ * to modifier changes.
1172+ */
1173+ if (old_fb->format->format != fb->format->format) {
11671174 DRM_DEBUG_KMS("Page flip is not allowed to change frame buffer format.\n");
11681175 ret = -EINVAL;
11691176 goto out;
drivers/gpu/drm/i915/Makefile+1−0
@@ -38,6 +38,7 @@ i915-y += i915_drv.o \ · 37 unmodified lines
3838 i915_config.o \
3939 i915_irq.o \
4040 i915_getparam.o \
41+ i915_mitigations.o \
4142 i915_params.o \
4243 i915_pci.o \
4344 i915_scatterlist.o \
drivers/gpu/drm/i915/display/icl_dsi.c+0−4
@@ -1616,10 +1616,6 @@ static void gen11_dsi_get_power_domains(struct intel_encoder *encoder, · 1615 unmodified lines
16161616
16171617 get_dsi_io_power_domains(i915,
16181618 enc_to_intel_dsi(encoder));
1619−
1620− if (crtc_state->dsc.compression_enable)
1621− intel_display_power_get(i915,
1622− intel_dsc_power_domain(crtc_state));
16231619 }
16241620
16251621 static bool gen11_dsi_get_hw_state(struct intel_encoder *encoder,
drivers/gpu/drm/i915/display/intel_panel.c+5−4
@@ -1650,16 +1650,13 @@ static int lpt_setup_backlight(struct intel_connector *connector, enum pipe unus · 1649 unmodified lines
16501650 val = pch_get_backlight(connector);
16511651 else
16521652 val = lpt_get_backlight(connector);
1653− val = intel_panel_compute_brightness(connector, val);
1654− panel->backlight.level = clamp(val, panel->backlight.min,
1655− panel->backlight.max);
16561653
16571654 if (cpu_mode) {
16581655 drm_dbg_kms(&dev_priv->drm,
16591656 "CPU backlight register was enabled, switching to PCH override\n");
16601657
16611658 /* Write converted CPU PWM value to PCH override register */
1662− lpt_set_backlight(connector->base.state, panel->backlight.level);
1659+ lpt_set_backlight(connector->base.state, val);
16631660 intel_de_write(dev_priv, BLC_PWM_PCH_CTL1,
16641661 pch_ctl1 | BLM_PCH_OVERRIDE_ENABLE);
16651662
@@ -1667,6 +1664,10 @@ static int lpt_setup_backlight(struct intel_connector *connector, enum pipe unus · 1 unmodified line
16671664 cpu_ctl2 & ~BLM_PWM_ENABLE);
16681665 }
16691666
1667+ val = intel_panel_compute_brightness(connector, val);
1668+ panel->backlight.level = clamp(val, panel->backlight.min,
1669+ panel->backlight.max);
1670+
16701671 return 0;
16711672 }
16721673
drivers/gpu/drm/i915/display/vlv_dsi.c+13−3
@@ -812,10 +812,20 @@ static void intel_dsi_pre_enable(struct intel_atomic_state *state, · 811 unmodified lines
812812 intel_dsi_prepare(encoder, pipe_config);
813813
814814 intel_dsi_vbt_exec_sequence(intel_dsi, MIPI_SEQ_POWER_ON);
815− intel_dsi_msleep(intel_dsi, intel_dsi->panel_on_delay);
816815
817− /* Deassert reset */
818− intel_dsi_vbt_exec_sequence(intel_dsi, MIPI_SEQ_DEASSERT_RESET);
816+ /*
817+ * Give the panel time to power-on and then deassert its reset.
818+ * Depending on the VBT MIPI sequences version the deassert-seq
819+ * may contain the necessary delay, intel_dsi_msleep() will skip
820+ * the delay in that case. If there is no deassert-seq, then an
821+ * unconditional msleep is used to give the panel time to power-on.
822+ */
823+ if (dev_priv->vbt.dsi.sequence[MIPI_SEQ_DEASSERT_RESET]) {
824+ intel_dsi_msleep(intel_dsi, intel_dsi->panel_on_delay);
825+ intel_dsi_vbt_exec_sequence(intel_dsi, MIPI_SEQ_DEASSERT_RESET);
826+ } else {
827+ msleep(intel_dsi->panel_on_delay);
828+ }
819829
820830 if (IS_GEMINILAKE(dev_priv)) {
821831 glk_cold_boot = glk_dsi_enable_io(encoder);
drivers/gpu/drm/i915/gt/gen7_renderclear.c+94−63
@@ -7,8 +7,6 @@ · 6 unmodified lines
77 #include "i915_drv.h"
88 #include "intel_gpu_commands.h"
99
10−#define MAX_URB_ENTRIES 64
11−#define STATE_SIZE (4 * 1024)
1210 #define GT3_INLINE_DATA_DELAYS 0x1E00
1311 #define batch_advance(Y, CS) GEM_BUG_ON((Y)->end != (CS))
1412
@@ -34,38 +32,59 @@ struct batch_chunk { · 19 unmodified lines
3432 };
3533
3634 struct batch_vals {
37− u32 max_primitives;
38− u32 max_urb_entries;
39− u32 cmd_size;
40− u32 state_size;
35+ u32 max_threads;
4136 u32 state_start;
42− u32 batch_size;
37+ u32 surface_start;
4338 u32 surface_height;
4439 u32 surface_width;
45− u32 scratch_size;
46− u32 max_size;
40+ u32 size;
4741 };
4842
43+static inline int num_primitives(const struct batch_vals *bv)
44+{
45+ /*
46+ * We need to saturate the GPU with work in order to dispatch
47+ * a shader on every HW thread, and clear the thread-local registers.
48+ * In short, we have to dispatch work faster than the shaders can
49+ * run in order to fill the EU and occupy each HW thread.
50+ */
51+ return bv->max_threads;
52+}
53+
4954 static void
5055 batch_get_defaults(struct drm_i915_private *i915, struct batch_vals *bv)
5156 {
5257 if (IS_HASWELL(i915)) {
53− bv->max_primitives = 280;
54− bv->max_urb_entries = MAX_URB_ENTRIES;
58+ switch (INTEL_INFO(i915)->gt) {
59+ default:
60+ case 1:
61+ bv->max_threads = 70;
62+ break;
63+ case 2:
64+ bv->max_threads = 140;
65+ break;
66+ case 3:
67+ bv->max_threads = 280;
68+ break;
69+ }
5570 bv->surface_height = 16 * 16;
5671 bv->surface_width = 32 * 2 * 16;
5772 } else {
58− bv->max_primitives = 128;
59− bv->max_urb_entries = MAX_URB_ENTRIES / 2;
73+ switch (INTEL_INFO(i915)->gt) {
74+ default:
75+ case 1: /* including vlv */
76+ bv->max_threads = 36;
77+ break;
78+ case 2:
79+ bv->max_threads = 128;
80+ break;
81+ }
6082 bv->surface_height = 16 * 8;
6183 bv->surface_width = 32 * 16;
6284 }
63− bv->cmd_size = bv->max_primitives * 4096;
64− bv->state_size = STATE_SIZE;
65− bv->state_start = bv->cmd_size;
66− bv->batch_size = bv->cmd_size + bv->state_size;
67− bv->scratch_size = bv->surface_height * bv->surface_width;
68− bv->max_size = bv->batch_size + bv->scratch_size;
85+ bv->state_start = round_up(SZ_1K + num_primitives(bv) * 64, SZ_4K);
86+ bv->surface_start = bv->state_start + SZ_4K;
87+ bv->size = bv->surface_start + bv->surface_height * bv->surface_width;
6988 }
7089
7190 static void batch_init(struct batch_chunk *bc,
@@ -155,7 +174,8 @@ static u32 · 83 unmodified lines
155174 gen7_fill_binding_table(struct batch_chunk *state,
156175 const struct batch_vals *bv)
157176 {
158− u32 surface_start = gen7_fill_surface_state(state, bv->batch_size, bv);
177+ u32 surface_start =
178+ gen7_fill_surface_state(state, bv->surface_start, bv);
159179 u32 *cs = batch_alloc_items(state, 32, 8);
160180 u32 offset = batch_offset(state, cs);
161181
@@ -214,9 +234,9 @@ static void · 52 unmodified lines
214234 gen7_emit_state_base_address(struct batch_chunk *batch,
215235 u32 surface_state_base)
216236 {
217− u32 *cs = batch_alloc_items(batch, 0, 12);
237+ u32 *cs = batch_alloc_items(batch, 0, 10);
218238
219− *cs++ = STATE_BASE_ADDRESS | (12 - 2);
239+ *cs++ = STATE_BASE_ADDRESS | (10 - 2);
220240 /* general */
221241 *cs++ = batch_addr(batch) | BASE_ADDRESS_MODIFY;
222242 /* surface */
@@ -233,8 +253,6 @@ gen7_emit_state_base_address(struct batch_chunk *batch, · 10 unmodified lines
233253 *cs++ = BASE_ADDRESS_MODIFY;
234254 *cs++ = 0;
235255 *cs++ = BASE_ADDRESS_MODIFY;
236− *cs++ = 0;
237− *cs++ = 0;
238256 batch_advance(batch, cs);
239257 }
240258
@@ -244,8 +262,7 @@ gen7_emit_vfe_state(struct batch_chunk *batch, · 3 unmodified lines
244262 u32 urb_size, u32 curbe_size,
245263 u32 mode)
246264 {
247− u32 urb_entries = bv->max_urb_entries;
248− u32 threads = bv->max_primitives - 1;
265+ u32 threads = bv->max_threads - 1;
249266 u32 *cs = batch_alloc_items(batch, 32, 8);
250267
251268 *cs++ = MEDIA_VFE_STATE | (8 - 2);
@@ -254,7 +271,7 @@ gen7_emit_vfe_state(struct batch_chunk *batch, · 2 unmodified lines
254271 *cs++ = 0;
255272
256273 /* number of threads & urb entries for GPGPU vs Media Mode */
257− *cs++ = threads << 16 | urb_entries << 8 | mode << 2;
274+ *cs++ = threads << 16 | 1 << 8 | mode << 2;
258275
259276 *cs++ = 0;
260277
@@ -293,17 +310,12 @@ gen7_emit_media_object(struct batch_chunk *batch, · 32 unmodified lines
293310 {
294311 unsigned int x_offset = (media_object_index % 16) * 64;
295312 unsigned int y_offset = (media_object_index / 16) * 16;
296− unsigned int inline_data_size;
297− unsigned int media_batch_size;
298− unsigned int i;
313+ unsigned int pkt = 6 + 3;
299314 u32 *cs;
300315
301− inline_data_size = 112 * 8;
302− media_batch_size = inline_data_size + 6;
303−
304− cs = batch_alloc_items(batch, 8, media_batch_size);
316+ cs = batch_alloc_items(batch, 8, pkt);
305317
306− *cs++ = MEDIA_OBJECT | (media_batch_size - 2);
318+ *cs++ = MEDIA_OBJECT | (pkt - 2);
307319
308320 /* interface descriptor offset */
309321 *cs++ = 0;
@@ -317,25 +329,44 @@ gen7_emit_media_object(struct batch_chunk *batch, · 7 unmodified lines
317329 *cs++ = 0;
318330
319331 /* inline */
320− *cs++ = (y_offset << 16) | (x_offset);
332+ *cs++ = y_offset << 16 | x_offset;
321333 *cs++ = 0;
322334 *cs++ = GT3_INLINE_DATA_DELAYS;
323− for (i = 3; i < inline_data_size; i++)
324− *cs++ = 0;
325335
326336 batch_advance(batch, cs);
327337 }
328338
329339 static void gen7_emit_pipeline_flush(struct batch_chunk *batch)
330340 {
331− u32 *cs = batch_alloc_items(batch, 0, 5);
341+ u32 *cs = batch_alloc_items(batch, 0, 4);
332342
333− *cs++ = GFX_OP_PIPE_CONTROL(5);
334− *cs++ = PIPE_CONTROL_STATE_CACHE_INVALIDATE |
335− PIPE_CONTROL_GLOBAL_GTT_IVB;
343+ *cs++ = GFX_OP_PIPE_CONTROL(4);
344+ *cs++ = PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH |
345+ PIPE_CONTROL_DEPTH_CACHE_FLUSH |
346+ PIPE_CONTROL_DC_FLUSH_ENABLE |
347+ PIPE_CONTROL_CS_STALL;
336348 *cs++ = 0;
337349 *cs++ = 0;
350+
351+ batch_advance(batch, cs);
352+}
353+
354+static void gen7_emit_pipeline_invalidate(struct batch_chunk *batch)
355+{
356+ u32 *cs = batch_alloc_items(batch, 0, 8);
357+
358+ /* ivb: Stall before STATE_CACHE_INVALIDATE */
359+ *cs++ = GFX_OP_PIPE_CONTROL(4);
360+ *cs++ = PIPE_CONTROL_STALL_AT_SCOREBOARD |
361+ PIPE_CONTROL_CS_STALL;
362+ *cs++ = 0;
363+ *cs++ = 0;
364+
365+ *cs++ = GFX_OP_PIPE_CONTROL(4);
366+ *cs++ = PIPE_CONTROL_STATE_CACHE_INVALIDATE;
338367 *cs++ = 0;
368+ *cs++ = 0;
369+
339370 batch_advance(batch, cs);
340371 }
341372
@@ -344,34 +375,34 @@ static void emit_batch(struct i915_vma * const vma, · 2 unmodified lines
344375 const struct batch_vals *bv)
345376 {
346377 struct drm_i915_private *i915 = vma->vm->i915;
347− unsigned int desc_count = 64;
348− const u32 urb_size = 112;
378+ const unsigned int desc_count = 1;
379+ const unsigned int urb_size = 1;
349380 struct batch_chunk cmds, state;
350− u32 interface_descriptor;
381+ u32 descriptors;
351382 unsigned int i;
352383
353− batch_init(&cmds, vma, start, 0, bv->cmd_size);
354− batch_init(&state, vma, start, bv->state_start, bv->state_size);
384+ batch_init(&cmds, vma, start, 0, bv->state_start);
385+ batch_init(&state, vma, start, bv->state_start, SZ_4K);
355386
356− interface_descriptor =
357− gen7_fill_interface_descriptor(&state, bv,
358− IS_HASWELL(i915) ?
359− &cb_kernel_hsw :
360− &cb_kernel_ivb,
361− desc_count);
362− gen7_emit_pipeline_flush(&cmds);
387+ descriptors = gen7_fill_interface_descriptor(&state, bv,
388+ IS_HASWELL(i915) ?
389+ &cb_kernel_hsw :
390+ &cb_kernel_ivb,
391+ desc_count);
392+
393+ gen7_emit_pipeline_invalidate(&cmds);
363394 batch_add(&cmds, PIPELINE_SELECT | PIPELINE_SELECT_MEDIA);
364395 batch_add(&cmds, MI_NOOP);
365− gen7_emit_state_base_address(&cmds, interface_descriptor);
396+ gen7_emit_pipeline_invalidate(&cmds);
397+
366398 gen7_emit_pipeline_flush(&cmds);
399+ gen7_emit_state_base_address(&cmds, descriptors);
400+ gen7_emit_pipeline_invalidate(&cmds);
367401
368402 gen7_emit_vfe_state(&cmds, bv, urb_size - 1, 0, 0);
403+ gen7_emit_interface_descriptor_load(&cmds, descriptors, desc_count);
369404
370− gen7_emit_interface_descriptor_load(&cmds,
371− interface_descriptor,
372− desc_count);
373−
374− for (i = 0; i < bv->max_primitives; i++)
405+ for (i = 0; i < num_primitives(bv); i++)
375406 gen7_emit_media_object(&cmds, i);
376407
377408 batch_add(&cmds, MI_BATCH_BUFFER_END);
@@ -385,15 +416,15 @@ int gen7_setup_clear_gpr_bb(struct intel_engine_cs * const engine, · 7 unmodified lines
385416
386417 batch_get_defaults(engine->i915, &bv);
387418 if (!vma)
388− return bv.max_size;
419+ return bv.size;
389420
390− GEM_BUG_ON(vma->obj->base.size < bv.max_size);
421+ GEM_BUG_ON(vma->obj->base.size < bv.size);
391422
392423 batch = i915_gem_object_pin_map(vma->obj, I915_MAP_WC);
393424 if (IS_ERR(batch))
394425 return PTR_ERR(batch);
395426
396− emit_batch(vma, memset(batch, 0, bv.max_size), &bv);
427+ emit_batch(vma, memset(batch, 0, bv.size), &bv);
397428
398429 i915_gem_object_flush_map(vma->obj);
399430 __i915_gem_object_release_map(vma->obj);
drivers/gpu/drm/i915/gt/intel_ring_submission.c+4−2
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232 #include "gen6_ppgtt.h"
3333 #include "gen7_renderclear.h"
3434 #include "i915_drv.h"
35+#include "i915_mitigations.h"
3536 #include "intel_breadcrumbs.h"
3637 #include "intel_context.h"
3738 #include "intel_gt.h"
@@ -886,7 +887,8 @@ static int switch_context(struct i915_request *rq) · 848 unmodified lines
886887 GEM_BUG_ON(HAS_EXECLISTS(engine->i915));
887888
888889 if (engine->wa_ctx.vma && ce != engine->kernel_context) {
889− if (engine->wa_ctx.vma->private != ce) {
890+ if (engine->wa_ctx.vma->private != ce &&
891+ i915_mitigate_clear_residuals()) {
890892 ret = clear_residuals(rq);
891893 if (ret)
892894 return ret;
@@ -1290,7 +1292,7 @@ int intel_ring_submission_setup(struct intel_engine_cs *engine) · 397 unmodified lines
12901292
12911293 GEM_BUG_ON(timeline->hwsp_ggtt != engine->status_page.vma);
12921294
1293− if (IS_HASWELL(engine->i915) && engine->class == RENDER_CLASS) {
1295+ if (IS_GEN(engine->i915, 7) && engine->class == RENDER_CLASS) {
12941296 err = gen7_ctx_switch_bb_init(engine);
12951297 if (err)
12961298 goto err_ring_unpin;
drivers/gpu/drm/i915/gvt/display.c+57−24
@@ -217,6 +217,15 @@ static void emulate_monitor_status_change(struct intel_vgpu *vgpu) · 216 unmodified lines
217217 DDI_BUF_CTL_ENABLE);
218218 vgpu_vreg_t(vgpu, DDI_BUF_CTL(port)) |= DDI_BUF_IS_IDLE;
219219 }
220+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &=
221+ ~(PORTA_HOTPLUG_ENABLE | PORTA_HOTPLUG_STATUS_MASK);
222+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &=
223+ ~(PORTB_HOTPLUG_ENABLE | PORTB_HOTPLUG_STATUS_MASK);
224+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &=
225+ ~(PORTC_HOTPLUG_ENABLE | PORTC_HOTPLUG_STATUS_MASK);
226+ /* No hpd_invert set in vgpu vbt, need to clear invert mask */
227+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &= ~BXT_DDI_HPD_INVERT_MASK;
228+ vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) &= ~BXT_DE_PORT_HOTPLUG_MASK;
220229
221230 vgpu_vreg_t(vgpu, BXT_P_CR_GT_DISP_PWRON) &= ~(BIT(0) | BIT(1));
222231 vgpu_vreg_t(vgpu, BXT_PORT_CL1CM_DW0(DPIO_PHY0)) &=
@@ -273,6 +282,8 @@ static void emulate_monitor_status_change(struct intel_vgpu *vgpu) · 50 unmodified lines
273282 vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_EDP)) |=
274283 (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DP_SST |
275284 TRANS_DDI_FUNC_ENABLE);
285+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |=
286+ PORTA_HOTPLUG_ENABLE;
276287 vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |=
277288 GEN8_DE_PORT_HOTPLUG(HPD_PORT_A);
278289 }
@@ -301,6 +312,8 @@ static void emulate_monitor_status_change(struct intel_vgpu *vgpu) · 22 unmodified lines
301312 (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DP_SST |
302313 (PORT_B << TRANS_DDI_PORT_SHIFT) |
303314 TRANS_DDI_FUNC_ENABLE);
315+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |=
316+ PORTB_HOTPLUG_ENABLE;
304317 vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |=
305318 GEN8_DE_PORT_HOTPLUG(HPD_PORT_B);
306319 }
@@ -329,6 +342,8 @@ static void emulate_monitor_status_change(struct intel_vgpu *vgpu) · 22 unmodified lines
329342 (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DP_SST |
330343 (PORT_B << TRANS_DDI_PORT_SHIFT) |
331344 TRANS_DDI_FUNC_ENABLE);
345+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |=
346+ PORTC_HOTPLUG_ENABLE;
332347 vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |=
333348 GEN8_DE_PORT_HOTPLUG(HPD_PORT_C);
334349 }
@@ -661,44 +676,62 @@ void intel_vgpu_emulate_hotplug(struct intel_vgpu *vgpu, bool connected) · 326 unmodified lines
661676 PORTD_HOTPLUG_STATUS_MASK;
662677 intel_vgpu_trigger_virtual_event(vgpu, DP_D_HOTPLUG);
663678 } else if (IS_BROXTON(i915)) {
664− if (connected) {
665− if (intel_vgpu_has_monitor_on_port(vgpu, PORT_A)) {
679+ if (intel_vgpu_has_monitor_on_port(vgpu, PORT_A)) {
680+ if (connected) {
666681 vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |=
667682 GEN8_DE_PORT_HOTPLUG(HPD_PORT_A);
683+ } else {
684+ vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) &=
685+ ~GEN8_DE_PORT_HOTPLUG(HPD_PORT_A);
668686 }
669− if (intel_vgpu_has_monitor_on_port(vgpu, PORT_B)) {
670− vgpu_vreg_t(vgpu, SFUSE_STRAP) |=
671− SFUSE_STRAP_DDIB_DETECTED;
687+ vgpu_vreg_t(vgpu, GEN8_DE_PORT_IIR) |=
688+ GEN8_DE_PORT_HOTPLUG(HPD_PORT_A);
689+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &=
690+ ~PORTA_HOTPLUG_STATUS_MASK;
691+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |=
692+ PORTA_HOTPLUG_LONG_DETECT;
693+ intel_vgpu_trigger_virtual_event(vgpu, DP_A_HOTPLUG);
694+ }
695+ if (intel_vgpu_has_monitor_on_port(vgpu, PORT_B)) {
696+ if (connected) {
672697 vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |=
673698 GEN8_DE_PORT_HOTPLUG(HPD_PORT_B);
674− }
675− if (intel_vgpu_has_monitor_on_port(vgpu, PORT_C)) {
676699 vgpu_vreg_t(vgpu, SFUSE_STRAP) |=
677− SFUSE_STRAP_DDIC_DETECTED;
678− vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |=
679− GEN8_DE_PORT_HOTPLUG(HPD_PORT_C);
680− }
681− } else {
682− if (intel_vgpu_has_monitor_on_port(vgpu, PORT_A)) {
700+ SFUSE_STRAP_DDIB_DETECTED;
701+ } else {
683702 vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) &=
684− ~GEN8_DE_PORT_HOTPLUG(HPD_PORT_A);
685− }
686− if (intel_vgpu_has_monitor_on_port(vgpu, PORT_B)) {
703+ ~GEN8_DE_PORT_HOTPLUG(HPD_PORT_B);
687704 vgpu_vreg_t(vgpu, SFUSE_STRAP) &=
688705 ~SFUSE_STRAP_DDIB_DETECTED;
689− vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) &=
690− ~GEN8_DE_PORT_HOTPLUG(HPD_PORT_B);
691706 }
692− if (intel_vgpu_has_monitor_on_port(vgpu, PORT_C)) {
693− vgpu_vreg_t(vgpu, SFUSE_STRAP) &=
694− ~SFUSE_STRAP_DDIC_DETECTED;
707+ vgpu_vreg_t(vgpu, GEN8_DE_PORT_IIR) |=
708+ GEN8_DE_PORT_HOTPLUG(HPD_PORT_B);
709+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &=
710+ ~PORTB_HOTPLUG_STATUS_MASK;
711+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |=
712+ PORTB_HOTPLUG_LONG_DETECT;
713+ intel_vgpu_trigger_virtual_event(vgpu, DP_B_HOTPLUG);
714+ }
715+ if (intel_vgpu_has_monitor_on_port(vgpu, PORT_C)) {
716+ if (connected) {
717+ vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |=
718+ GEN8_DE_PORT_HOTPLUG(HPD_PORT_C);
719+ vgpu_vreg_t(vgpu, SFUSE_STRAP) |=
720+ SFUSE_STRAP_DDIC_DETECTED;
721+ } else {
695722 vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) &=
696723 ~GEN8_DE_PORT_HOTPLUG(HPD_PORT_C);
724+ vgpu_vreg_t(vgpu, SFUSE_STRAP) &=
725+ ~SFUSE_STRAP_DDIC_DETECTED;
697726 }
727+ vgpu_vreg_t(vgpu, GEN8_DE_PORT_IIR) |=
728+ GEN8_DE_PORT_HOTPLUG(HPD_PORT_C);
729+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &=
730+ ~PORTC_HOTPLUG_STATUS_MASK;
731+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |=
732+ PORTC_HOTPLUG_LONG_DETECT;
733+ intel_vgpu_trigger_virtual_event(vgpu, DP_C_HOTPLUG);
698734 }
699− vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |=
700− PORTB_HOTPLUG_STATUS_MASK;
701− intel_vgpu_trigger_virtual_event(vgpu, DP_B_HOTPLUG);
702735 }
703736 }
704737
drivers/gpu/drm/i915/gvt/vgpu.c+2−3
@@ -437,10 +437,9 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt, · 436 unmodified lines
437437 if (ret)
438438 goto out_clean_sched_policy;
439439
440− if (IS_BROADWELL(dev_priv))
440+ if (IS_BROADWELL(dev_priv) || IS_BROXTON(dev_priv))
441441 ret = intel_gvt_hypervisor_set_edid(vgpu, PORT_B);
442− /* FixMe: Re-enable APL/BXT once vfio_edid enabled */
443− else if (!IS_BROXTON(dev_priv))
442+ else
444443 ret = intel_gvt_hypervisor_set_edid(vgpu, PORT_D);
445444 if (ret)
446445 goto out_clean_sched_policy;
drivers/gpu/drm/i915/i915_drv.c+4−0
@@ -1047,6 +1047,8 @@ static void intel_shutdown_encoders(struct drm_i915_private *dev_priv) · 1046 unmodified lines
10471047
10481048 void i915_driver_shutdown(struct drm_i915_private *i915)
10491049 {
1050+ disable_rpm_wakeref_asserts(&i915->runtime_pm);
1051+
10501052 i915_gem_suspend(i915);
10511053
10521054 drm_kms_helper_poll_disable(&i915->drm);
@@ -1060,6 +1062,8 @@ void i915_driver_shutdown(struct drm_i915_private *i915) · 7 unmodified lines
10601062
10611063 intel_suspend_encoders(i915);
10621064 intel_shutdown_encoders(i915);
1065+
1066+ enable_rpm_wakeref_asserts(&i915->runtime_pm);
10631067 }
10641068
10651069 static bool suspend_to_idle(struct drm_i915_private *dev_priv)
drivers/gpu/drm/i915/i915_mitigations.c+146−0
@@ -0,0 +1,146 @@
1+// SPDX-License-Identifier: MIT
2+/*
3+ * Copyright © 2021 Intel Corporation
4+ */
5+
6+#include <linux/kernel.h>
7+#include <linux/moduleparam.h>
8+#include <linux/slab.h>
9+#include <linux/string.h>
10+
11+#include "i915_drv.h"
12+#include "i915_mitigations.h"
13+
14+static unsigned long mitigations __read_mostly = ~0UL;
15+
16+enum {
17+ CLEAR_RESIDUALS = 0,
18+};
19+
20+static const char * const names[] = {
21+ [CLEAR_RESIDUALS] = "residuals",
22+};
23+
24+bool i915_mitigate_clear_residuals(void)
25+{
26+ return READ_ONCE(mitigations) & BIT(CLEAR_RESIDUALS);
27+}
28+
29+static int mitigations_set(const char *val, const struct kernel_param *kp)
30+{
31+ unsigned long new = ~0UL;
32+ char *str, *sep, *tok;
33+ bool first = true;
34+ int err = 0;
35+
36+ BUILD_BUG_ON(ARRAY_SIZE(names) >= BITS_PER_TYPE(mitigations));
37+
38+ str = kstrdup(val, GFP_KERNEL);
39+ if (!str)
40+ return -ENOMEM;
41+
42+ for (sep = str; (tok = strsep(&sep, ","));) {
43+ bool enable = true;
44+ int i;
45+
46+ /* Be tolerant of leading/trailing whitespace */
47+ tok = strim(tok);
48+
49+ if (first) {
50+ first = false;
51+
52+ if (!strcmp(tok, "auto"))
53+ continue;
54+
55+ new = 0;
56+ if (!strcmp(tok, "off"))
57+ continue;
58+ }
59+
60+ if (*tok == '!') {
61+ enable = !enable;
62+ tok++;
63+ }
64+
65+ if (!strncmp(tok, "no", 2)) {
66+ enable = !enable;
67+ tok += 2;
68+ }
69+
70+ if (*tok == '\0')
71+ continue;
72+
73+ for (i = 0; i < ARRAY_SIZE(names); i++) {
74+ if (!strcmp(tok, names[i])) {
75+ if (enable)
76+ new |= BIT(i);
77+ else
78+ new &= ~BIT(i);
79+ break;
80+ }
81+ }
82+ if (i == ARRAY_SIZE(names)) {
83+ pr_err("Bad \"%s.mitigations=%s\", '%s' is unknown\n",
84+ DRIVER_NAME, val, tok);
85+ err = -EINVAL;
86+ break;
87+ }
88+ }
89+ kfree(str);
90+ if (err)
91+ return err;
92+
93+ WRITE_ONCE(mitigations, new);
94+ return 0;
95+}
96+
97+static int mitigations_get(char *buffer, const struct kernel_param *kp)
98+{
99+ unsigned long local = READ_ONCE(mitigations);
100+ int count, i;
101+ bool enable;
102+
103+ if (!local)
104+ return scnprintf(buffer, PAGE_SIZE, "%s\n", "off");
105+
106+ if (local & BIT(BITS_PER_LONG - 1)) {
107+ count = scnprintf(buffer, PAGE_SIZE, "%s,", "auto");
108+ enable = false;
109+ } else {
110+ enable = true;
111+ count = 0;
112+ }
113+
114+ for (i = 0; i < ARRAY_SIZE(names); i++) {
115+ if ((local & BIT(i)) != enable)
116+ continue;
117+
118+ count += scnprintf(buffer + count, PAGE_SIZE - count,
119+ "%s%s,", enable ? "" : "!", names[i]);
120+ }
121+
122+ buffer[count - 1] = '\n';
123+ return count;
124+}
125+
126+static const struct kernel_param_ops ops = {
127+ .set = mitigations_set,
128+ .get = mitigations_get,
129+};
130+
131+module_param_cb_unsafe(mitigations, &ops, NULL, 0600);
132+MODULE_PARM_DESC(mitigations,
133+"Selectively enable security mitigations for all Intel® GPUs in the system.\n"
134+"\n"
135+" auto -- enables all mitigations required for the platform [default]\n"
136+" off -- disables all mitigations\n"
137+"\n"
138+"Individual mitigations can be enabled by passing a comma-separated string,\n"
139+"e.g. mitigations=residuals to enable only clearing residuals or\n"
140+"mitigations=auto,noresiduals to disable only the clear residual mitigation.\n"
141+"Either '!' or 'no' may be used to switch from enabling the mitigation to\n"
142+"disabling it.\n"
143+"\n"
144+"Active mitigations for Ivybridge, Baytrail, Haswell:\n"
145+" residuals -- clear all thread-local registers between contexts"
146+);
drivers/gpu/drm/i915/i915_mitigations.h+13−0
@@ -0,0 +1,13 @@
1+/* SPDX-License-Identifier: MIT */
2+/*
3+ * Copyright © 2021 Intel Corporation
4+ */
5+
6+#ifndef __I915_MITIGATIONS_H__
7+#define __I915_MITIGATIONS_H__
8+
9+#include <linux/types.h>
10+
11+bool i915_mitigate_clear_residuals(void);
12+
13+#endif /* __I915_MITIGATIONS_H__ */
drivers/gpu/drm/nouveau/dispnv50/Kbuild+1−0
@@ -37,6 +37,7 @@ nouveau-y += dispnv50/wimmc37b.o · 36 unmodified lines
3737 nouveau-y += dispnv50/wndw.o
3838 nouveau-y += dispnv50/wndwc37e.o
3939 nouveau-y += dispnv50/wndwc57e.o
40+nouveau-y += dispnv50/wndwc67e.o
4041
4142 nouveau-y += dispnv50/base.o
4243 nouveau-y += dispnv50/base507c.o
drivers/gpu/drm/nouveau/dispnv50/core.c+1−0
@@ -42,6 +42,7 @@ nv50_core_new(struct nouveau_drm *drm, struct nv50_core **pcore) · 41 unmodified lines
4242 int version;
4343 int (*new)(struct nouveau_drm *, s32, struct nv50_core **);
4444 } cores[] = {
45+ { GA102_DISP_CORE_CHANNEL_DMA, 0, corec57d_new },
4546 { TU102_DISP_CORE_CHANNEL_DMA, 0, corec57d_new },
4647 { GV100_DISP_CORE_CHANNEL_DMA, 0, corec37d_new },
4748 { GP102_DISP_CORE_CHANNEL_DMA, 0, core917d_new },
drivers/gpu/drm/nouveau/dispnv50/curs.c+1−0
@@ -31,6 +31,7 @@ nv50_curs_new(struct nouveau_drm *drm, int head, struct nv50_wndw **pwndw) · 30 unmodified lines
3131 int version;
3232 int (*new)(struct nouveau_drm *, int, s32, struct nv50_wndw **);
3333 } curses[] = {
34+ { GA102_DISP_CURSOR, 0, cursc37a_new },
3435 { TU102_DISP_CURSOR, 0, cursc37a_new },
3536 { GV100_DISP_CURSOR, 0, cursc37a_new },
3637 { GK104_DISP_CURSOR, 0, curs907a_new },
drivers/gpu/drm/nouveau/dispnv50/disp.c+2−2
@@ -222,7 +222,7 @@ nv50_dmac_wait(struct nvif_push *push, u32 size) · 221 unmodified lines
222222
223223 int
224224 nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
225− const s32 *oclass, u8 head, void *data, u32 size, u64 syncbuf,
225+ const s32 *oclass, u8 head, void *data, u32 size, s64 syncbuf,
226226 struct nv50_dmac *dmac)
227227 {
228228 struct nouveau_cli *cli = (void *)device->object.client;
@@ -271,7 +271,7 @@ nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp, · 42 unmodified lines
271271 if (ret)
272272 return ret;
273273
274− if (!syncbuf)
274+ if (syncbuf < 0)
275275 return 0;
276276
277277 ret = nvif_object_ctor(&dmac->base.user, "kmsSyncCtxDma", NV50_DISP_HANDLE_SYNCBUF,
drivers/gpu/drm/nouveau/dispnv50/disp.h+1−1
@@ -95,7 +95,7 @@ struct nv50_outp_atom { · 94 unmodified lines
9595
9696 int nv50_dmac_create(struct nvif_device *device, struct nvif_object *disp,
9797 const s32 *oclass, u8 head, void *data, u32 size,
98− u64 syncbuf, struct nv50_dmac *dmac);
98+ s64 syncbuf, struct nv50_dmac *dmac);
9999 void nv50_dmac_destroy(struct nv50_dmac *);
100100
101101 /*
drivers/gpu/drm/nouveau/dispnv50/wimm.c+1−0
@@ -31,6 +31,7 @@ nv50_wimm_init(struct nouveau_drm *drm, struct nv50_wndw *wndw) · 30 unmodified lines
3131 int version;
3232 int (*init)(struct nouveau_drm *, s32, struct nv50_wndw *);
3333 } wimms[] = {
34+ { GA102_DISP_WINDOW_IMM_CHANNEL_DMA, 0, wimmc37b_init },
3435 { TU102_DISP_WINDOW_IMM_CHANNEL_DMA, 0, wimmc37b_init },
3536 { GV100_DISP_WINDOW_IMM_CHANNEL_DMA, 0, wimmc37b_init },
3637 {}
drivers/gpu/drm/nouveau/dispnv50/wimmc37b.c+1−1
@@ -76,7 +76,7 @@ wimmc37b_init_(const struct nv50_wimm_func *func, struct nouveau_drm *drm, · 75 unmodified lines
7676 int ret;
7777
7878 ret = nv50_dmac_create(&drm->client.device, &disp->disp->object,
79− &oclass, 0, &args, sizeof(args), 0,
79+ &oclass, 0, &args, sizeof(args), -1,
8080 &wndw->wimm);
8181 if (ret) {
8282 NV_ERROR(drm, "wimm%04x allocation failed: %d\n", oclass, ret);
drivers/gpu/drm/nouveau/dispnv50/wndw.c+1−0
@@ -784,6 +784,7 @@ nv50_wndw_new(struct nouveau_drm *drm, enum drm_plane_type type, int index, · 783 unmodified lines
784784 int (*new)(struct nouveau_drm *, enum drm_plane_type,
785785 int, s32, struct nv50_wndw **);
786786 } wndws[] = {
787+ { GA102_DISP_WINDOW_CHANNEL_DMA, 0, wndwc67e_new },
787788 { TU102_DISP_WINDOW_CHANNEL_DMA, 0, wndwc57e_new },
788789 { GV100_DISP_WINDOW_CHANNEL_DMA, 0, wndwc37e_new },
789790 {}
drivers/gpu/drm/nouveau/dispnv50/wndw.h+8−0
@@ -129,6 +129,14 @@ int wndwc37e_update(struct nv50_wndw *, u32 *); · 128 unmodified lines
129129
130130 int wndwc57e_new(struct nouveau_drm *, enum drm_plane_type, int, s32,
131131 struct nv50_wndw **);
132+bool wndwc57e_ilut(struct nv50_wndw *, struct nv50_wndw_atom *, int);
133+int wndwc57e_ilut_set(struct nv50_wndw *, struct nv50_wndw_atom *);
134+int wndwc57e_ilut_clr(struct nv50_wndw *);
135+int wndwc57e_csc_set(struct nv50_wndw *, struct nv50_wndw_atom *);
136+int wndwc57e_csc_clr(struct nv50_wndw *);
137+
138+int wndwc67e_new(struct nouveau_drm *, enum drm_plane_type, int, s32,
139+ struct nv50_wndw **);
132140
133141 int nv50_wndw_new(struct nouveau_drm *, enum drm_plane_type, int index,
134142 struct nv50_wndw **);
drivers/gpu/drm/nouveau/dispnv50/wndwc57e.c+5−5
@@ -80,7 +80,7 @@ wndwc57e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw) · 79 unmodified lines
8080 return 0;
8181 }
8282
83−static int
83+int
8484 wndwc57e_csc_clr(struct nv50_wndw *wndw)
8585 {
8686 struct nvif_push *push = wndw->wndw.push;
@@ -98,7 +98,7 @@ wndwc57e_csc_clr(struct nv50_wndw *wndw) · 11 unmodified lines
9898 return 0;
9999 }
100100
101−static int
101+int
102102 wndwc57e_csc_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
103103 {
104104 struct nvif_push *push = wndw->wndw.push;
@@ -111,7 +111,7 @@ wndwc57e_csc_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw) · 6 unmodified lines
111111 return 0;
112112 }
113113
114−static int
114+int
115115 wndwc57e_ilut_clr(struct nv50_wndw *wndw)
116116 {
117117 struct nvif_push *push = wndw->wndw.push;
@@ -124,7 +124,7 @@ wndwc57e_ilut_clr(struct nv50_wndw *wndw) · 6 unmodified lines
124124 return 0;
125125 }
126126
127−static int
127+int
128128 wndwc57e_ilut_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
129129 {
130130 struct nvif_push *push = wndw->wndw.push;
@@ -179,7 +179,7 @@ wndwc57e_ilut_load(struct drm_color_lut *in, int size, void __iomem *mem) · 48 unmodified lines
179179 writew(readw(mem - 4), mem + 4);
180180 }
181181
182−static bool
182+bool
183183 wndwc57e_ilut(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw, int size)
184184 {
185185 if (size = size ? size : 1024, size != 256 && size != 1024)
drivers/gpu/drm/nouveau/dispnv50/wndwc67e.c+106−0
@@ -0,0 +1,106 @@
1+/*
2+ * Copyright 2021 Red Hat Inc.
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a
5+ * copy of this software and associated documentation files (the "Software"),
6+ * to deal in the Software without restriction, including without limitation
7+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+ * and/or sell copies of the Software, and to permit persons to whom the
9+ * Software is furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+ * OTHER DEALINGS IN THE SOFTWARE.
21+ */
22+#include "wndw.h"
23+#include "atom.h"
24+
25+#include <nvif/pushc37b.h>
26+
27+#include <nvhw/class/clc57e.h>
28+
29+static int
30+wndwc67e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
31+{
32+ struct nvif_push *push = wndw->wndw.push;
33+ int ret;
34+
35+ if ((ret = PUSH_WAIT(push, 17)))
36+ return ret;
37+
38+ PUSH_MTHD(push, NVC57E, SET_PRESENT_CONTROL,
39+ NVVAL(NVC57E, SET_PRESENT_CONTROL, MIN_PRESENT_INTERVAL, asyw->image.interval) |
40+ NVVAL(NVC57E, SET_PRESENT_CONTROL, BEGIN_MODE, asyw->image.mode) |
41+ NVDEF(NVC57E, SET_PRESENT_CONTROL, TIMESTAMP_MODE, DISABLE));
42+
43+ PUSH_MTHD(push, NVC57E, SET_SIZE,
44+ NVVAL(NVC57E, SET_SIZE, WIDTH, asyw->image.w) |
45+ NVVAL(NVC57E, SET_SIZE, HEIGHT, asyw->image.h),
46+
47+ SET_STORAGE,
48+ NVVAL(NVC57E, SET_STORAGE, BLOCK_HEIGHT, asyw->image.blockh),
49+
50+ SET_PARAMS,
51+ NVVAL(NVC57E, SET_PARAMS, FORMAT, asyw->image.format) |
52+ NVDEF(NVC57E, SET_PARAMS, CLAMP_BEFORE_BLEND, DISABLE) |
53+ NVDEF(NVC57E, SET_PARAMS, SWAP_UV, DISABLE) |
54+ NVDEF(NVC57E, SET_PARAMS, FMT_ROUNDING_MODE, ROUND_TO_NEAREST),
55+
56+ SET_PLANAR_STORAGE(0),
57+ NVVAL(NVC57E, SET_PLANAR_STORAGE, PITCH, asyw->image.blocks[0]) |
58+ NVVAL(NVC57E, SET_PLANAR_STORAGE, PITCH, asyw->image.pitch[0] >> 6));
59+
60+ PUSH_MTHD(push, NVC57E, SET_CONTEXT_DMA_ISO(0), asyw->image.handle, 1);
61+ PUSH_MTHD(push, NVC57E, SET_OFFSET(0), asyw->image.offset[0] >> 8);
62+
63+ PUSH_MTHD(push, NVC57E, SET_POINT_IN(0),
64+ NVVAL(NVC57E, SET_POINT_IN, X, asyw->state.src_x >> 16) |
65+ NVVAL(NVC57E, SET_POINT_IN, Y, asyw->state.src_y >> 16));
66+
67+ PUSH_MTHD(push, NVC57E, SET_SIZE_IN,
68+ NVVAL(NVC57E, SET_SIZE_IN, WIDTH, asyw->state.src_w >> 16) |
69+ NVVAL(NVC57E, SET_SIZE_IN, HEIGHT, asyw->state.src_h >> 16));
70+
71+ PUSH_MTHD(push, NVC57E, SET_SIZE_OUT,
72+ NVVAL(NVC57E, SET_SIZE_OUT, WIDTH, asyw->state.crtc_w) |
73+ NVVAL(NVC57E, SET_SIZE_OUT, HEIGHT, asyw->state.crtc_h));
74+ return 0;
75+}
76+
77+static const struct nv50_wndw_func
78+wndwc67e = {
79+ .acquire = wndwc37e_acquire,
80+ .release = wndwc37e_release,
81+ .sema_set = wndwc37e_sema_set,
82+ .sema_clr = wndwc37e_sema_clr,
83+ .ntfy_set = wndwc37e_ntfy_set,
84+ .ntfy_clr = wndwc37e_ntfy_clr,
85+ .ntfy_reset = corec37d_ntfy_init,
86+ .ntfy_wait_begun = base507c_ntfy_wait_begun,
87+ .ilut = wndwc57e_ilut,
88+ .ilut_identity = true,
89+ .ilut_size = 1024,
90+ .xlut_set = wndwc57e_ilut_set,
91+ .xlut_clr = wndwc57e_ilut_clr,
92+ .csc = base907c_csc,
93+ .csc_set = wndwc57e_csc_set,
94+ .csc_clr = wndwc57e_csc_clr,
95+ .image_set = wndwc67e_image_set,
96+ .image_clr = wndwc37e_image_clr,
97+ .blend_set = wndwc37e_blend_set,
98+ .update = wndwc37e_update,
99+};
100+
101+int
102+wndwc67e_new(struct nouveau_drm *drm, enum drm_plane_type type, int index,
103+ s32 oclass, struct nv50_wndw **pwndw)
104+{
105+ return wndwc37e_new_(&wndwc67e, drm, type, index, oclass, BIT(index >> 1), pwndw);
106+}
drivers/gpu/drm/nouveau/include/nvif/cl0080.h+1−0
@@ -33,6 +33,7 @@ struct nv_device_info_v0 { · 32 unmodified lines
3333 #define NV_DEVICE_INFO_V0_PASCAL 0x0a
3434 #define NV_DEVICE_INFO_V0_VOLTA 0x0b
3535 #define NV_DEVICE_INFO_V0_TURING 0x0c
36+#define NV_DEVICE_INFO_V0_AMPERE 0x0d
3637 __u8 family;
3738 __u8 pad06[2];
3839 __u64 ram_size;
drivers/gpu/drm/nouveau/include/nvif/class.h+5−0
@@ -88,6 +88,7 @@ · 87 unmodified lines
8888 #define GP102_DISP /* cl5070.h */ 0x00009870
8989 #define GV100_DISP /* cl5070.h */ 0x0000c370
9090 #define TU102_DISP /* cl5070.h */ 0x0000c570
91+#define GA102_DISP /* cl5070.h */ 0x0000c670
9192
9293 #define GV100_DISP_CAPS 0x0000c373
9394
@@ -103,6 +104,7 @@ · 9 unmodified lines
103104 #define GK104_DISP_CURSOR /* cl507a.h */ 0x0000917a
104105 #define GV100_DISP_CURSOR /* cl507a.h */ 0x0000c37a
105106 #define TU102_DISP_CURSOR /* cl507a.h */ 0x0000c57a
107+#define GA102_DISP_CURSOR /* cl507a.h */ 0x0000c67a
106108
107109 #define NV50_DISP_OVERLAY /* cl507b.h */ 0x0000507b
108110 #define G82_DISP_OVERLAY /* cl507b.h */ 0x0000827b
@@ -112,6 +114,7 @@ · 3 unmodified lines
112114
113115 #define GV100_DISP_WINDOW_IMM_CHANNEL_DMA /* clc37b.h */ 0x0000c37b
114116 #define TU102_DISP_WINDOW_IMM_CHANNEL_DMA /* clc37b.h */ 0x0000c57b
117+#define GA102_DISP_WINDOW_IMM_CHANNEL_DMA /* clc37b.h */ 0x0000c67b
115118
116119 #define NV50_DISP_BASE_CHANNEL_DMA /* cl507c.h */ 0x0000507c
117120 #define G82_DISP_BASE_CHANNEL_DMA /* cl507c.h */ 0x0000827c
@@ -135,6 +138,7 @@ · 17 unmodified lines
135138 #define GP102_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000987d
136139 #define GV100_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000c37d
137140 #define TU102_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000c57d
141+#define GA102_DISP_CORE_CHANNEL_DMA /* cl507d.h */ 0x0000c67d
138142
139143 #define NV50_DISP_OVERLAY_CHANNEL_DMA /* cl507e.h */ 0x0000507e
140144 #define G82_DISP_OVERLAY_CHANNEL_DMA /* cl507e.h */ 0x0000827e
@@ -145,6 +149,7 @@ · 4 unmodified lines
145149
146150 #define GV100_DISP_WINDOW_CHANNEL_DMA /* clc37e.h */ 0x0000c37e
147151 #define TU102_DISP_WINDOW_CHANNEL_DMA /* clc37e.h */ 0x0000c57e
152+#define GA102_DISP_WINDOW_CHANNEL_DMA /* clc37e.h */ 0x0000c67e
148153
149154 #define NV50_TESLA 0x00005097
150155 #define G82_TESLA 0x00008297
drivers/gpu/drm/nouveau/include/nvkm/core/device.h+1−0
@@ -120,6 +120,7 @@ struct nvkm_device { · 119 unmodified lines
120120 GP100 = 0x130,
121121 GV100 = 0x140,
122122 TU100 = 0x160,
123+ GA100 = 0x170,
123124 } card_type;
124125 u32 chipset;
125126 u8 chiprev;
drivers/gpu/drm/nouveau/include/nvkm/engine/disp.h+1−0
@@ -37,4 +37,5 @@ int gp100_disp_new(struct nvkm_device *, int, struct nvkm_disp **); · 36 unmodified lines
3737 int gp102_disp_new(struct nvkm_device *, int, struct nvkm_disp **);
3838 int gv100_disp_new(struct nvkm_device *, int, struct nvkm_disp **);
3939 int tu102_disp_new(struct nvkm_device *, int, struct nvkm_disp **);
40+int ga102_disp_new(struct nvkm_device *, int, struct nvkm_disp **);
4041 #endif
drivers/gpu/drm/nouveau/include/nvkm/subdev/devinit.h+1−0
@@ -32,4 +32,5 @@ int gm107_devinit_new(struct nvkm_device *, int, struct nvkm_devinit **); · 31 unmodified lines
3232 int gm200_devinit_new(struct nvkm_device *, int, struct nvkm_devinit **);
3333 int gv100_devinit_new(struct nvkm_device *, int, struct nvkm_devinit **);
3434 int tu102_devinit_new(struct nvkm_device *, int, struct nvkm_devinit **);
35+int ga100_devinit_new(struct nvkm_device *, int, struct nvkm_devinit **);
3536 #endif
drivers/gpu/drm/nouveau/include/nvkm/subdev/fb.h+2−0
@@ -86,6 +86,8 @@ int gp100_fb_new(struct nvkm_device *, int, struct nvkm_fb **); · 85 unmodified lines
8686 int gp102_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
8787 int gp10b_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
8888 int gv100_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
89+int ga100_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
90+int ga102_fb_new(struct nvkm_device *, int, struct nvkm_fb **);
8991
9092 #include <subdev/bios.h>
9193 #include <subdev/bios/ramcfg.h>
drivers/gpu/drm/nouveau/include/nvkm/subdev/gpio.h+1−0
@@ -37,4 +37,5 @@ int nv50_gpio_new(struct nvkm_device *, int, struct nvkm_gpio **); · 36 unmodified lines
3737 int g94_gpio_new(struct nvkm_device *, int, struct nvkm_gpio **);
3838 int gf119_gpio_new(struct nvkm_device *, int, struct nvkm_gpio **);
3939 int gk104_gpio_new(struct nvkm_device *, int, struct nvkm_gpio **);
40+int ga102_gpio_new(struct nvkm_device *, int, struct nvkm_gpio **);
4041 #endif
drivers/gpu/drm/nouveau/include/nvkm/subdev/i2c.h+1−0
@@ -92,6 +92,7 @@ int g94_i2c_new(struct nvkm_device *, int, struct nvkm_i2c **); · 91 unmodified lines
9292 int gf117_i2c_new(struct nvkm_device *, int, struct nvkm_i2c **);
9393 int gf119_i2c_new(struct nvkm_device *, int, struct nvkm_i2c **);
9494 int gk104_i2c_new(struct nvkm_device *, int, struct nvkm_i2c **);
95+int gk110_i2c_new(struct nvkm_device *, int, struct nvkm_i2c **);
9596 int gm200_i2c_new(struct nvkm_device *, int, struct nvkm_i2c **);
9697
9798 static inline int
drivers/gpu/drm/nouveau/include/nvkm/subdev/mc.h+1−0
@@ -32,4 +32,5 @@ int gk20a_mc_new(struct nvkm_device *, int, struct nvkm_mc **); · 31 unmodified lines
3232 int gp100_mc_new(struct nvkm_device *, int, struct nvkm_mc **);
3333 int gp10b_mc_new(struct nvkm_device *, int, struct nvkm_mc **);
3434 int tu102_mc_new(struct nvkm_device *, int, struct nvkm_mc **);
35+int ga100_mc_new(struct nvkm_device *, int, struct nvkm_mc **);
3536 #endif
drivers/gpu/drm/nouveau/nouveau_backlight.c+1−0
@@ -256,6 +256,7 @@ nouveau_backlight_init(struct drm_connector *connector) · 255 unmodified lines
256256 case NV_DEVICE_INFO_V0_PASCAL:
257257 case NV_DEVICE_INFO_V0_VOLTA:
258258 case NV_DEVICE_INFO_V0_TURING:
259+ case NV_DEVICE_INFO_V0_AMPERE: //XXX: not confirmed
259260 ret = nv50_backlight_init(nv_encoder, &props, &ops);
260261 break;
261262 default:
drivers/gpu/drm/nouveau/nvif/disp.c+1−0
@@ -35,6 +35,7 @@ nvif_disp_ctor(struct nvif_device *device, const char *name, s32 oclass, · 34 unmodified lines
3535 struct nvif_disp *disp)
3636 {
3737 static const struct nvif_mclass disps[] = {
38+ { GA102_DISP, -1 },
3839 { TU102_DISP, -1 },
3940 { GV100_DISP, -1 },
4041 { GP102_DISP, -1 },
drivers/gpu/drm/nouveau/nvkm/engine/device/base.c+78−9
@@ -1815,7 +1815,7 @@ nvf0_chipset = { · 1814 unmodified lines
18151815 .fb = gk110_fb_new,
18161816 .fuse = gf100_fuse_new,
18171817 .gpio = gk104_gpio_new,
1818− .i2c = gk104_i2c_new,
1818+ .i2c = gk110_i2c_new,
18191819 .ibus = gk104_ibus_new,
18201820 .iccsense = gf100_iccsense_new,
18211821 .imem = nv50_instmem_new,
@@ -1853,7 +1853,7 @@ nvf1_chipset = { · 31 unmodified lines
18531853 .fb = gk110_fb_new,
18541854 .fuse = gf100_fuse_new,
18551855 .gpio = gk104_gpio_new,
1856− .i2c = gk104_i2c_new,
1856+ .i2c = gk110_i2c_new,
18571857 .ibus = gk104_ibus_new,
18581858 .iccsense = gf100_iccsense_new,
18591859 .imem = nv50_instmem_new,
@@ -1891,7 +1891,7 @@ nv106_chipset = { · 31 unmodified lines
18911891 .fb = gk110_fb_new,
18921892 .fuse = gf100_fuse_new,
18931893 .gpio = gk104_gpio_new,
1894− .i2c = gk104_i2c_new,
1894+ .i2c = gk110_i2c_new,
18951895 .ibus = gk104_ibus_new,
18961896 .iccsense = gf100_iccsense_new,
18971897 .imem = nv50_instmem_new,
@@ -1929,7 +1929,7 @@ nv108_chipset = { · 31 unmodified lines
19291929 .fb = gk110_fb_new,
19301930 .fuse = gf100_fuse_new,
19311931 .gpio = gk104_gpio_new,
1932− .i2c = gk104_i2c_new,
1932+ .i2c = gk110_i2c_new,
19331933 .ibus = gk104_ibus_new,
19341934 .iccsense = gf100_iccsense_new,
19351935 .imem = nv50_instmem_new,
@@ -1967,7 +1967,7 @@ nv117_chipset = { · 31 unmodified lines
19671967 .fb = gm107_fb_new,
19681968 .fuse = gm107_fuse_new,
19691969 .gpio = gk104_gpio_new,
1970− .i2c = gk104_i2c_new,
1970+ .i2c = gk110_i2c_new,
19711971 .ibus = gk104_ibus_new,
19721972 .iccsense = gf100_iccsense_new,
19731973 .imem = nv50_instmem_new,
@@ -2003,7 +2003,7 @@ nv118_chipset = { · 29 unmodified lines
20032003 .fb = gm107_fb_new,
20042004 .fuse = gm107_fuse_new,
20052005 .gpio = gk104_gpio_new,
2006− .i2c = gk104_i2c_new,
2006+ .i2c = gk110_i2c_new,
20072007 .ibus = gk104_ibus_new,
20082008 .iccsense = gf100_iccsense_new,
20092009 .imem = nv50_instmem_new,
@@ -2652,6 +2652,61 @@ nv168_chipset = { · 642 unmodified lines
26522652 .sec2 = tu102_sec2_new,
26532653 };
26542654
2655+static const struct nvkm_device_chip
2656+nv170_chipset = {
2657+ .name = "GA100",
2658+ .bar = tu102_bar_new,
2659+ .bios = nvkm_bios_new,
2660+ .devinit = ga100_devinit_new,
2661+ .fb = ga100_fb_new,
2662+ .gpio = gk104_gpio_new,
2663+ .i2c = gm200_i2c_new,
2664+ .ibus = gm200_ibus_new,
2665+ .imem = nv50_instmem_new,
2666+ .mc = ga100_mc_new,
2667+ .mmu = tu102_mmu_new,
2668+ .pci = gp100_pci_new,
2669+ .timer = gk20a_timer_new,
2670+};
2671+
2672+static const struct nvkm_device_chip
2673+nv172_chipset = {
2674+ .name = "GA102",
2675+ .bar = tu102_bar_new,
2676+ .bios = nvkm_bios_new,
2677+ .devinit = ga100_devinit_new,
2678+ .fb = ga102_fb_new,
2679+ .gpio = ga102_gpio_new,
2680+ .i2c = gm200_i2c_new,
2681+ .ibus = gm200_ibus_new,
2682+ .imem = nv50_instmem_new,
2683+ .mc = ga100_mc_new,
2684+ .mmu = tu102_mmu_new,
2685+ .pci = gp100_pci_new,
2686+ .timer = gk20a_timer_new,
2687+ .disp = ga102_disp_new,
2688+ .dma = gv100_dma_new,
2689+};
2690+
2691+static const struct nvkm_device_chip
2692+nv174_chipset = {
2693+ .name = "GA104",
2694+ .bar = tu102_bar_new,
2695+ .bios = nvkm_bios_new,
2696+ .devinit = ga100_devinit_new,
2697+ .fb = ga102_fb_new,
2698+ .gpio = ga102_gpio_new,
2699+ .i2c = gm200_i2c_new,
2700+ .ibus = gm200_ibus_new,
2701+ .imem = nv50_instmem_new,
2702+ .mc = ga100_mc_new,
2703+ .mmu = tu102_mmu_new,
2704+ .pci = gp100_pci_new,
2705+ .timer = gk20a_timer_new,
2706+ .disp = ga102_disp_new,
2707+ .dma = gv100_dma_new,
2708+};
2709+
26552710 static int
26562711 nvkm_device_event_ctor(struct nvkm_object *object, void *data, u32 size,
26572712 struct nvkm_notify *notify)
@@ -3063,6 +3118,7 @@ nvkm_device_ctor(const struct nvkm_device_func *func, · 405 unmodified lines
30633118 case 0x130: device->card_type = GP100; break;
30643119 case 0x140: device->card_type = GV100; break;
30653120 case 0x160: device->card_type = TU100; break;
3121+ case 0x170: device->card_type = GA100; break;
30663122 default:
30673123 break;
30683124 }
@@ -3160,10 +3216,23 @@ nvkm_device_ctor(const struct nvkm_device_func *func, · 91 unmodified lines
31603216 case 0x166: device->chip = &nv166_chipset; break;
31613217 case 0x167: device->chip = &nv167_chipset; break;
31623218 case 0x168: device->chip = &nv168_chipset; break;
3219+ case 0x172: device->chip = &nv172_chipset; break;
3220+ case 0x174: device->chip = &nv174_chipset; break;
31633221 default:
3164− nvdev_error(device, "unknown chipset (%08x)\n", boot0);
3165− ret = -ENODEV;
3166− goto done;
3222+ if (nvkm_boolopt(device->cfgopt, "NvEnableUnsupportedChipsets", false)) {
3223+ switch (device->chipset) {
3224+ case 0x170: device->chip = &nv170_chipset; break;
3225+ default:
3226+ break;
3227+ }
3228+ }
3229+
3230+ if (!device->chip) {
3231+ nvdev_error(device, "unknown chipset (%08x)\n", boot0);
3232+ ret = -ENODEV;
3233+ goto done;
3234+ }
3235+ break;
31673236 }
31683237
31693238 nvdev_info(device, "NVIDIA %s (%08x)\n",
drivers/gpu/drm/nouveau/nvkm/engine/device/user.c+1−0
@@ -176,6 +176,7 @@ nvkm_udevice_info(struct nvkm_udevice *udev, void *data, u32 size) · 175 unmodified lines
176176 case GP100: args->v0.family = NV_DEVICE_INFO_V0_PASCAL; break;
177177 case GV100: args->v0.family = NV_DEVICE_INFO_V0_VOLTA; break;
178178 case TU100: args->v0.family = NV_DEVICE_INFO_V0_TURING; break;
179+ case GA100: args->v0.family = NV_DEVICE_INFO_V0_AMPERE; break;
179180 default:
180181 args->v0.family = 0;
181182 break;
drivers/gpu/drm/nouveau/nvkm/engine/disp/Kbuild+3−0
@@ -17,6 +17,7 @@ nvkm-y += nvkm/engine/disp/gp100.o · 16 unmodified lines
1717 nvkm-y += nvkm/engine/disp/gp102.o
1818 nvkm-y += nvkm/engine/disp/gv100.o
1919 nvkm-y += nvkm/engine/disp/tu102.o
20+nvkm-y += nvkm/engine/disp/ga102.o
2021 nvkm-y += nvkm/engine/disp/vga.o
2122
2223 nvkm-y += nvkm/engine/disp/head.o
@@ -42,6 +43,7 @@ nvkm-y += nvkm/engine/disp/sorgm200.o · 19 unmodified lines
4243 nvkm-y += nvkm/engine/disp/sorgp100.o
4344 nvkm-y += nvkm/engine/disp/sorgv100.o
4445 nvkm-y += nvkm/engine/disp/sortu102.o
46+nvkm-y += nvkm/engine/disp/sorga102.o
4547
4648 nvkm-y += nvkm/engine/disp/outp.o
4749 nvkm-y += nvkm/engine/disp/dp.o
@@ -75,6 +77,7 @@ nvkm-y += nvkm/engine/disp/rootgp100.o · 27 unmodified lines
7577 nvkm-y += nvkm/engine/disp/rootgp102.o
7678 nvkm-y += nvkm/engine/disp/rootgv100.o
7779 nvkm-y += nvkm/engine/disp/roottu102.o
80+nvkm-y += nvkm/engine/disp/rootga102.o
7881
7982 nvkm-y += nvkm/engine/disp/capsgv100.o
8083
drivers/gpu/drm/nouveau/nvkm/engine/disp/dp.c+27−6
@@ -33,6 +33,12 @@ · 32 unmodified lines
3333
3434 #include <nvif/event.h>
3535
36+/* IED scripts are no longer used by UEFI/RM from Ampere, but have been updated for
37+ * the x86 option ROM. However, the relevant VBIOS table versions weren't modified,
38+ * so we're unable to detect this in a nice way.
39+ */
40+#define AMPERE_IED_HACK(disp) ((disp)->engine.subdev.device->card_type >= GA100)
41+
3642 struct lt_state {
3743 struct nvkm_dp *dp;
3844 u8 stat[6];
@@ -238,6 +244,19 @@ nvkm_dp_train_links(struct nvkm_dp *dp) · 199 unmodified lines
238244 dp->dpcd[DPCD_RC02] &= ~DPCD_RC02_TPS3_SUPPORTED;
239245 lt.pc2 = dp->dpcd[DPCD_RC02] & DPCD_RC02_TPS3_SUPPORTED;
240246
247+ if (AMPERE_IED_HACK(disp) && (lnkcmp = lt.dp->info.script[0])) {
248+ /* Execute BeforeLinkTraining script from DP Info table. */
249+ while (ior->dp.bw < nvbios_rd08(bios, lnkcmp))
250+ lnkcmp += 3;
251+ lnkcmp = nvbios_rd16(bios, lnkcmp + 1);
252+
253+ nvbios_init(&dp->outp.disp->engine.subdev, lnkcmp,
254+ init.outp = &dp->outp.info;
255+ init.or = ior->id;
256+ init.link = ior->asy.link;
257+ );
258+ }
259+
241260 /* Set desired link configuration on the source. */
242261 if ((lnkcmp = lt.dp->info.lnkcmp)) {
243262 if (dp->version < 0x30) {
@@ -316,12 +335,14 @@ nvkm_dp_train_init(struct nvkm_dp *dp) · 72 unmodified lines
316335 );
317336 }
318337
319− /* Execute BeforeLinkTraining script from DP Info table. */
320− nvbios_init(&dp->outp.disp->engine.subdev, dp->info.script[0],
321− init.outp = &dp->outp.info;
322− init.or = dp->outp.ior->id;
323− init.link = dp->outp.ior->asy.link;
324− );
338+ if (!AMPERE_IED_HACK(dp->outp.disp)) {
339+ /* Execute BeforeLinkTraining script from DP Info table. */
340+ nvbios_init(&dp->outp.disp->engine.subdev, dp->info.script[0],
341+ init.outp = &dp->outp.info;
342+ init.or = dp->outp.ior->id;
343+ init.link = dp->outp.ior->asy.link;
344+ );
345+ }
325346 }
326347
327348 static const struct dp_rates {
drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c+46−0
@@ -0,0 +1,46 @@
1+/*
2+ * Copyright 2021 Red Hat Inc.
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a
5+ * copy of this software and associated documentation files (the "Software"),
6+ * to deal in the Software without restriction, including without limitation
7+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+ * and/or sell copies of the Software, and to permit persons to whom the
9+ * Software is furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+ * OTHER DEALINGS IN THE SOFTWARE.
21+ */
22+#include "nv50.h"
23+#include "head.h"
24+#include "ior.h"
25+#include "channv50.h"
26+#include "rootnv50.h"
27+
28+static const struct nv50_disp_func
29+ga102_disp = {
30+ .init = tu102_disp_init,
31+ .fini = gv100_disp_fini,
32+ .intr = gv100_disp_intr,
33+ .uevent = &gv100_disp_chan_uevent,
34+ .super = gv100_disp_super,
35+ .root = &ga102_disp_root_oclass,
36+ .wndw = { .cnt = gv100_disp_wndw_cnt },
37+ .head = { .cnt = gv100_head_cnt, .new = gv100_head_new },
38+ .sor = { .cnt = gv100_sor_cnt, .new = ga102_sor_new },
39+ .ramht_size = 0x2000,
40+};
41+
42+int
43+ga102_disp_new(struct nvkm_device *device, int index, struct nvkm_disp **pdisp)
44+{
45+ return nv50_disp_new_(&ga102_disp, device, index, pdisp);
46+}
drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h+4−0
@@ -150,6 +150,8 @@ void gv100_sor_dp_audio(struct nvkm_ior *, int, bool); · 149 unmodified lines
150150 void gv100_sor_dp_audio_sym(struct nvkm_ior *, int, u16, u32);
151151 void gv100_sor_dp_watermark(struct nvkm_ior *, int, u8);
152152
153+void tu102_sor_dp_vcpi(struct nvkm_ior *, int, u8, u8, u16, u16);
154+
153155 void g84_hdmi_ctrl(struct nvkm_ior *, int, bool, u8, u8, u8 *, u8 , u8 *, u8);
154156 void gt215_hdmi_ctrl(struct nvkm_ior *, int, bool, u8, u8, u8 *, u8 , u8 *, u8);
155157 void gf119_hdmi_ctrl(struct nvkm_ior *, int, bool, u8, u8, u8 *, u8 , u8 *, u8);
@@ -207,4 +209,6 @@ int gv100_sor_cnt(struct nvkm_disp *, unsigned long *); · 51 unmodified lines
207209 int gv100_sor_new(struct nvkm_disp *, int);
208210
209211 int tu102_sor_new(struct nvkm_disp *, int);
212+
213+int ga102_sor_new(struct nvkm_disp *, int);
210214 #endif
drivers/gpu/drm/nouveau/nvkm/engine/disp/nv50.h+2−0
@@ -86,6 +86,8 @@ void gv100_disp_intr(struct nv50_disp *); · 85 unmodified lines
8686 void gv100_disp_super(struct work_struct *);
8787 int gv100_disp_wndw_cnt(struct nvkm_disp *, unsigned long *);
8888
89+int tu102_disp_init(struct nv50_disp *);
90+
8991 void nv50_disp_dptmds_war_2(struct nv50_disp *, struct dcb_output *);
9092 void nv50_disp_dptmds_war_3(struct nv50_disp *, struct dcb_output *);
9193 void nv50_disp_update_sppll1(struct nv50_disp *);
drivers/gpu/drm/nouveau/nvkm/engine/disp/rootga102.c+52−0
@@ -0,0 +1,52 @@
1+/*
2+ * Copyright 2021 Red Hat Inc.
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a
5+ * copy of this software and associated documentation files (the "Software"),
6+ * to deal in the Software without restriction, including without limitation
7+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+ * and/or sell copies of the Software, and to permit persons to whom the
9+ * Software is furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+ * OTHER DEALINGS IN THE SOFTWARE.
21+ */
22+#include "rootnv50.h"
23+#include "channv50.h"
24+
25+#include <nvif/class.h>
26+
27+static const struct nv50_disp_root_func
28+ga102_disp_root = {
29+ .user = {
30+ {{-1,-1,GV100_DISP_CAPS }, gv100_disp_caps_new },
31+ {{0,0,GA102_DISP_CURSOR }, gv100_disp_curs_new },
32+ {{0,0,GA102_DISP_WINDOW_IMM_CHANNEL_DMA}, gv100_disp_wimm_new },
33+ {{0,0,GA102_DISP_CORE_CHANNEL_DMA }, gv100_disp_core_new },
34+ {{0,0,GA102_DISP_WINDOW_CHANNEL_DMA }, gv100_disp_wndw_new },
35+ {}
36+ },
37+};
38+
39+static int
40+ga102_disp_root_new(struct nvkm_disp *disp, const struct nvkm_oclass *oclass,
41+ void *data, u32 size, struct nvkm_object **pobject)
42+{
43+ return nv50_disp_root_new_(&ga102_disp_root, disp, oclass, data, size, pobject);
44+}
45+
46+const struct nvkm_disp_oclass
47+ga102_disp_root_oclass = {
48+ .base.oclass = GA102_DISP,
49+ .base.minver = -1,
50+ .base.maxver = -1,
51+ .ctor = ga102_disp_root_new,
52+};
drivers/gpu/drm/nouveau/nvkm/engine/disp/rootnv50.h+1−0
@@ -41,4 +41,5 @@ extern const struct nvkm_disp_oclass gp100_disp_root_oclass; · 40 unmodified lines
4141 extern const struct nvkm_disp_oclass gp102_disp_root_oclass;
4242 extern const struct nvkm_disp_oclass gv100_disp_root_oclass;
4343 extern const struct nvkm_disp_oclass tu102_disp_root_oclass;
44+extern const struct nvkm_disp_oclass ga102_disp_root_oclass;
4445 #endif
drivers/gpu/drm/nouveau/nvkm/engine/disp/sorga102.c+140−0
@@ -0,0 +1,140 @@
1+/*
2+ * Copyright 2021 Red Hat Inc.
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a
5+ * copy of this software and associated documentation files (the "Software"),
6+ * to deal in the Software without restriction, including without limitation
7+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+ * and/or sell copies of the Software, and to permit persons to whom the
9+ * Software is furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+ * OTHER DEALINGS IN THE SOFTWARE.
21+ */
22+#include "ior.h"
23+
24+#include <subdev/timer.h>
25+
26+static int
27+ga102_sor_dp_links(struct nvkm_ior *sor, struct nvkm_i2c_aux *aux)
28+{
29+ struct nvkm_device *device = sor->disp->engine.subdev.device;
30+ const u32 soff = nv50_ior_base(sor);
31+ const u32 loff = nv50_sor_link(sor);
32+ u32 dpctrl = 0x00000000;
33+ u32 clksor = 0x00000000;
34+
35+ switch (sor->dp.bw) {
36+ case 0x06: clksor |= 0x00000000; break;
37+ case 0x0a: clksor |= 0x00040000; break;
38+ case 0x14: clksor |= 0x00080000; break;
39+ case 0x1e: clksor |= 0x000c0000; break;
40+ default:
41+ WARN_ON(1);
42+ return -EINVAL;
43+ }
44+
45+ dpctrl |= ((1 << sor->dp.nr) - 1) << 16;
46+ if (sor->dp.mst)
47+ dpctrl |= 0x40000000;
48+ if (sor->dp.ef)
49+ dpctrl |= 0x00004000;
50+
51+ nvkm_mask(device, 0x612300 + soff, 0x007c0000, clksor);
52+
53+ /*XXX*/
54+ nvkm_msec(device, 40, NVKM_DELAY);
55+ nvkm_mask(device, 0x612300 + soff, 0x00030000, 0x00010000);
56+ nvkm_mask(device, 0x61c10c + loff, 0x00000003, 0x00000001);
57+
58+ nvkm_mask(device, 0x61c10c + loff, 0x401f4000, dpctrl);
59+ return 0;
60+}
61+
62+static void
63+ga102_sor_clock(struct nvkm_ior *sor)
64+{
65+ struct nvkm_device *device = sor->disp->engine.subdev.device;
66+ u32 div2 = 0;
67+ if (sor->asy.proto == TMDS) {
68+ if (sor->tmds.high_speed)
69+ div2 = 1;
70+ }
71+ nvkm_wr32(device, 0x00ec08 + (sor->id * 0x10), 0x00000000);
72+ nvkm_wr32(device, 0x00ec04 + (sor->id * 0x10), div2);
73+}
74+
75+static const struct nvkm_ior_func
76+ga102_sor_hda = {
77+ .route = {
78+ .get = gm200_sor_route_get,
79+ .set = gm200_sor_route_set,
80+ },
81+ .state = gv100_sor_state,
82+ .power = nv50_sor_power,
83+ .clock = ga102_sor_clock,
84+ .hdmi = {
85+ .ctrl = gv100_hdmi_ctrl,
86+ .scdc = gm200_hdmi_scdc,
87+ },
88+ .dp = {
89+ .lanes = { 0, 1, 2, 3 },
90+ .links = ga102_sor_dp_links,
91+ .power = g94_sor_dp_power,
92+ .pattern = gm107_sor_dp_pattern,
93+ .drive = gm200_sor_dp_drive,
94+ .vcpi = tu102_sor_dp_vcpi,
95+ .audio = gv100_sor_dp_audio,
96+ .audio_sym = gv100_sor_dp_audio_sym,
97+ .watermark = gv100_sor_dp_watermark,
98+ },
99+ .hda = {
100+ .hpd = gf119_hda_hpd,
101+ .eld = gf119_hda_eld,
102+ .device_entry = gv100_hda_device_entry,
103+ },
104+};
105+
106+static const struct nvkm_ior_func
107+ga102_sor = {
108+ .route = {
109+ .get = gm200_sor_route_get,
110+ .set = gm200_sor_route_set,
111+ },
112+ .state = gv100_sor_state,
113+ .power = nv50_sor_power,
114+ .clock = ga102_sor_clock,
115+ .hdmi = {
116+ .ctrl = gv100_hdmi_ctrl,
117+ .scdc = gm200_hdmi_scdc,
118+ },
119+ .dp = {
120+ .lanes = { 0, 1, 2, 3 },
121+ .links = ga102_sor_dp_links,
122+ .power = g94_sor_dp_power,
123+ .pattern = gm107_sor_dp_pattern,
124+ .drive = gm200_sor_dp_drive,
125+ .vcpi = tu102_sor_dp_vcpi,
126+ .audio = gv100_sor_dp_audio,
127+ .audio_sym = gv100_sor_dp_audio_sym,
128+ .watermark = gv100_sor_dp_watermark,
129+ },
130+};
131+
132+int
133+ga102_sor_new(struct nvkm_disp *disp, int id)
134+{
135+ struct nvkm_device *device = disp->engine.subdev.device;
136+ u32 hda = nvkm_rd32(device, 0x08a15c);
137+ if (hda & BIT(id))
138+ return nvkm_ior_new_(&ga102_sor_hda, disp, SOR, id);
139+ return nvkm_ior_new_(&ga102_sor, disp, SOR, id);
140+}
drivers/gpu/drm/nouveau/nvkm/engine/disp/sortu102.c+1−1
@@ -23,7 +23,7 @@ · 22 unmodified lines
2323
2424 #include <subdev/timer.h>
2525
26−static void
26+void
2727 tu102_sor_dp_vcpi(struct nvkm_ior *sor, int head,
2828 u8 slot, u8 slot_nr, u16 pbn, u16 aligned)
2929 {
drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c+1−1
@@ -28,7 +28,7 @@ · 27 unmodified lines
2828 #include <core/gpuobj.h>
2929 #include <subdev/timer.h>
3030
31−static int
31+int
3232 tu102_disp_init(struct nv50_disp *disp)
3333 {
3434 struct nvkm_device *device = disp->base.engine.subdev.device;
drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c+1−1
@@ -75,7 +75,7 @@ shadow_image(struct nvkm_bios *bios, int idx, u32 offset, struct shadow *mthd) · 74 unmodified lines
7575 nvkm_debug(subdev, "%08x: type %02x, %d bytes\n",
7676 image.base, image.type, image.size);
7777
78− if (!shadow_fetch(bios, mthd, image.size)) {
78+ if (!shadow_fetch(bios, mthd, image.base + image.size)) {
7979 nvkm_debug(subdev, "%08x: fetch failed\n", image.base);
8080 return 0;
8181 }
drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowramin.c+3−0
@@ -64,6 +64,9 @@ pramin_init(struct nvkm_bios *bios, const char *name) · 63 unmodified lines
6464 return NULL;
6565
6666 /* we can't get the bios image pointer without PDISP */
67+ if (device->card_type >= GA100)
68+ addr = device->chipset == 0x170; /*XXX: find the fuse reg for this */
69+ else
6770 if (device->card_type >= GM100)
6871 addr = nvkm_rd32(device, 0x021c04);
6972 else
drivers/gpu/drm/nouveau/nvkm/subdev/devinit/Kbuild+1−0
@@ -15,3 +15,4 @@ nvkm-y += nvkm/subdev/devinit/gm107.o · 14 unmodified lines
1515 nvkm-y += nvkm/subdev/devinit/gm200.o
1616 nvkm-y += nvkm/subdev/devinit/gv100.o
1717 nvkm-y += nvkm/subdev/devinit/tu102.o
18+nvkm-y += nvkm/subdev/devinit/ga100.o
drivers/gpu/drm/nouveau/nvkm/subdev/devinit/ga100.c+76−0
@@ -0,0 +1,76 @@
1+/*
2+ * Copyright 2021 Red Hat Inc.
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a
5+ * copy of this software and associated documentation files (the "Software"),
6+ * to deal in the Software without restriction, including without limitation
7+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+ * and/or sell copies of the Software, and to permit persons to whom the
9+ * Software is furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+ * OTHER DEALINGS IN THE SOFTWARE.
21+ */
22+#include "nv50.h"
23+
24+#include <subdev/bios.h>
25+#include <subdev/bios/pll.h>
26+#include <subdev/clk/pll.h>
27+
28+static int
29+ga100_devinit_pll_set(struct nvkm_devinit *init, u32 type, u32 freq)
30+{
31+ struct nvkm_subdev *subdev = &init->subdev;
32+ struct nvkm_device *device = subdev->device;
33+ struct nvbios_pll info;
34+ int head = type - PLL_VPLL0;
35+ int N, fN, M, P;
36+ int ret;
37+
38+ ret = nvbios_pll_parse(device->bios, type, &info);
39+ if (ret)
40+ return ret;
41+
42+ ret = gt215_pll_calc(subdev, &info, freq, &N, &fN, &M, &P);
43+ if (ret < 0)
44+ return ret;
45+
46+ switch (info.type) {
47+ case PLL_VPLL0:
48+ case PLL_VPLL1:
49+ case PLL_VPLL2:
50+ case PLL_VPLL3:
51+ nvkm_wr32(device, 0x00ef00 + (head * 0x40), 0x02080004);
52+ nvkm_wr32(device, 0x00ef18 + (head * 0x40), (N << 16) | fN);
53+ nvkm_wr32(device, 0x00ef04 + (head * 0x40), (P << 16) | M);
54+ nvkm_wr32(device, 0x00e9c0 + (head * 0x04), 0x00000001);
55+ break;
56+ default:
57+ nvkm_warn(subdev, "%08x/%dKhz unimplemented\n", type, freq);
58+ ret = -EINVAL;
59+ break;
60+ }
61+
62+ return ret;
63+}
64+
65+static const struct nvkm_devinit_func
66+ga100_devinit = {
67+ .init = nv50_devinit_init,
68+ .post = tu102_devinit_post,
69+ .pll_set = ga100_devinit_pll_set,
70+};
71+
72+int
73+ga100_devinit_new(struct nvkm_device *device, int index, struct nvkm_devinit **pinit)
74+{
75+ return nv50_devinit_new_(&ga100_devinit, device, index, pinit);
76+}
drivers/gpu/drm/nouveau/nvkm/subdev/devinit/priv.h+1−0
@@ -19,4 +19,5 @@ void nvkm_devinit_ctor(const struct nvkm_devinit_func *, struct nvkm_device *, · 18 unmodified lines
1919 int index, struct nvkm_devinit *);
2020
2121 int nv04_devinit_post(struct nvkm_devinit *, bool);
22+int tu102_devinit_post(struct nvkm_devinit *, bool);
2223 #endif
drivers/gpu/drm/nouveau/nvkm/subdev/devinit/tu102.c+1−1
@@ -65,7 +65,7 @@ tu102_devinit_pll_set(struct nvkm_devinit *init, u32 type, u32 freq) · 64 unmodified lines
6565 return ret;
6666 }
6767
68−static int
68+int
6969 tu102_devinit_post(struct nvkm_devinit *base, bool post)
7070 {
7171 struct nv50_devinit *init = nv50_devinit(base);
drivers/gpu/drm/nouveau/nvkm/subdev/fb/Kbuild+3−0
@@ -32,6 +32,8 @@ nvkm-y += nvkm/subdev/fb/gp100.o · 31 unmodified lines
3232 nvkm-y += nvkm/subdev/fb/gp102.o
3333 nvkm-y += nvkm/subdev/fb/gp10b.o
3434 nvkm-y += nvkm/subdev/fb/gv100.o
35+nvkm-y += nvkm/subdev/fb/ga100.o
36+nvkm-y += nvkm/subdev/fb/ga102.o
3537
3638 nvkm-y += nvkm/subdev/fb/ram.o
3739 nvkm-y += nvkm/subdev/fb/ramnv04.o
@@ -52,6 +54,7 @@ nvkm-y += nvkm/subdev/fb/ramgk104.o · 14 unmodified lines
5254 nvkm-y += nvkm/subdev/fb/ramgm107.o
5355 nvkm-y += nvkm/subdev/fb/ramgm200.o
5456 nvkm-y += nvkm/subdev/fb/ramgp100.o
57+nvkm-y += nvkm/subdev/fb/ramga102.o
5558 nvkm-y += nvkm/subdev/fb/sddr2.o
5659 nvkm-y += nvkm/subdev/fb/sddr3.o
5760 nvkm-y += nvkm/subdev/fb/gddr3.o
drivers/gpu/drm/nouveau/nvkm/subdev/fb/ga100.c+40−0
@@ -0,0 +1,40 @@
1+/*
2+ * Copyright 2021 Red Hat Inc.
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a
5+ * copy of this software and associated documentation files (the "Software"),
6+ * to deal in the Software without restriction, including without limitation
7+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+ * and/or sell copies of the Software, and to permit persons to whom the
9+ * Software is furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+ * OTHER DEALINGS IN THE SOFTWARE.
21+ */
22+#include "gf100.h"
23+#include "ram.h"
24+
25+static const struct nvkm_fb_func
26+ga100_fb = {
27+ .dtor = gf100_fb_dtor,
28+ .oneinit = gf100_fb_oneinit,
29+ .init = gp100_fb_init,
30+ .init_page = gv100_fb_init_page,
31+ .init_unkn = gp100_fb_init_unkn,
32+ .ram_new = gp100_ram_new,
33+ .default_bigpage = 16,
34+};
35+
36+int
37+ga100_fb_new(struct nvkm_device *device, int index, struct nvkm_fb **pfb)
38+{
39+ return gp102_fb_new_(&ga100_fb, device, index, pfb);
40+}
drivers/gpu/drm/nouveau/nvkm/subdev/fb/ga102.c+40−0
@@ -0,0 +1,40 @@
1+/*
2+ * Copyright 2021 Red Hat Inc.
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a
5+ * copy of this software and associated documentation files (the "Software"),
6+ * to deal in the Software without restriction, including without limitation
7+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+ * and/or sell copies of the Software, and to permit persons to whom the
9+ * Software is furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+ * OTHER DEALINGS IN THE SOFTWARE.
21+ */
22+#include "gf100.h"
23+#include "ram.h"
24+
25+static const struct nvkm_fb_func
26+ga102_fb = {
27+ .dtor = gf100_fb_dtor,
28+ .oneinit = gf100_fb_oneinit,
29+ .init = gp100_fb_init,
30+ .init_page = gv100_fb_init_page,
31+ .init_unkn = gp100_fb_init_unkn,
32+ .ram_new = ga102_ram_new,
33+ .default_bigpage = 16,
34+};
35+
36+int
37+ga102_fb_new(struct nvkm_device *device, int index, struct nvkm_fb **pfb)
38+{
39+ return gp102_fb_new_(&ga102_fb, device, index, pfb);
40+}
drivers/gpu/drm/nouveau/nvkm/subdev/fb/gv100.c+1−1
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 #include "gf100.h"
2323 #include "ram.h"
2424
25−static int
25+int
2626 gv100_fb_init_page(struct nvkm_fb *fb)
2727 {
2828 return (fb->page == 16) ? 0 : -EINVAL;
drivers/gpu/drm/nouveau/nvkm/subdev/fb/priv.h+2−0
@@ -82,4 +82,6 @@ int gp102_fb_new_(const struct nvkm_fb_func *, struct nvkm_device *, int, · 81 unmodified lines
8282 struct nvkm_fb **);
8383 bool gp102_fb_vpr_scrub_required(struct nvkm_fb *);
8484 int gp102_fb_vpr_scrub(struct nvkm_fb *);
85+
86+int gv100_fb_init_page(struct nvkm_fb *);
8587 #endif
drivers/gpu/drm/nouveau/nvkm/subdev/fb/ram.h+1−0
@@ -70,4 +70,5 @@ int gk104_ram_new(struct nvkm_fb *, struct nvkm_ram **); · 69 unmodified lines
7070 int gm107_ram_new(struct nvkm_fb *, struct nvkm_ram **);
7171 int gm200_ram_new(struct nvkm_fb *, struct nvkm_ram **);
7272 int gp100_ram_new(struct nvkm_fb *, struct nvkm_ram **);
73+int ga102_ram_new(struct nvkm_fb *, struct nvkm_ram **);
7374 #endif
drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramga102.c+40−0
@@ -0,0 +1,40 @@
1+/*
2+ * Copyright 2021 Red Hat Inc.
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a
5+ * copy of this software and associated documentation files (the "Software"),
6+ * to deal in the Software without restriction, including without limitation
7+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+ * and/or sell copies of the Software, and to permit persons to whom the
9+ * Software is furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+ * OTHER DEALINGS IN THE SOFTWARE.
21+ */
22+#include "ram.h"
23+
24+#include <subdev/bios.h>
25+#include <subdev/bios/init.h>
26+#include <subdev/bios/rammap.h>
27+
28+static const struct nvkm_ram_func
29+ga102_ram = {
30+};
31+
32+int
33+ga102_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
34+{
35+ struct nvkm_device *device = fb->subdev.device;
36+ enum nvkm_ram_type type = nvkm_fb_bios_memtype(device->bios);
37+ u32 size = nvkm_rd32(device, 0x1183a4);
38+
39+ return nvkm_ram_new_(&ga102_ram, fb, type, (u64)size << 20, pram);
40+}
drivers/gpu/drm/nouveau/nvkm/subdev/gpio/Kbuild+1−0
@@ -5,3 +5,4 @@ nvkm-y += nvkm/subdev/gpio/nv50.o · 4 unmodified lines
55 nvkm-y += nvkm/subdev/gpio/g94.o
66 nvkm-y += nvkm/subdev/gpio/gf119.o
77 nvkm-y += nvkm/subdev/gpio/gk104.o
8+nvkm-y += nvkm/subdev/gpio/ga102.o
drivers/gpu/drm/nouveau/nvkm/subdev/gpio/ga102.c+118−0
@@ -0,0 +1,118 @@
1+/*
2+ * Copyright 2021 Red Hat Inc.
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a
5+ * copy of this software and associated documentation files (the "Software"),
6+ * to deal in the Software without restriction, including without limitation
7+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+ * and/or sell copies of the Software, and to permit persons to whom the
9+ * Software is furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+ * OTHER DEALINGS IN THE SOFTWARE.
21+ */
22+#include "priv.h"
23+
24+static void
25+ga102_gpio_reset(struct nvkm_gpio *gpio, u8 match)
26+{
27+ struct nvkm_device *device = gpio->subdev.device;
28+ struct nvkm_bios *bios = device->bios;
29+ u8 ver, len;
30+ u16 entry;
31+ int ent = -1;
32+
33+ while ((entry = dcb_gpio_entry(bios, 0, ++ent, &ver, &len))) {
34+ u32 data = nvbios_rd32(bios, entry);
35+ u8 line = (data & 0x0000003f);
36+ u8 defs = !!(data & 0x00000080);
37+ u8 func = (data & 0x0000ff00) >> 8;
38+ u8 unk0 = (data & 0x00ff0000) >> 16;
39+ u8 unk1 = (data & 0x1f000000) >> 24;
40+
41+ if ( func == DCB_GPIO_UNUSED ||
42+ (match != DCB_GPIO_UNUSED && match != func))
43+ continue;
44+
45+ nvkm_gpio_set(gpio, 0, func, line, defs);
46+
47+ nvkm_mask(device, 0x021200 + (line * 4), 0xff, unk0);
48+ if (unk1--)
49+ nvkm_mask(device, 0x00d740 + (unk1 * 4), 0xff, line);
50+ }
51+}
52+
53+static int
54+ga102_gpio_drive(struct nvkm_gpio *gpio, int line, int dir, int out)
55+{
56+ struct nvkm_device *device = gpio->subdev.device;
57+ u32 data = ((dir ^ 1) << 13) | (out << 12);
58+ nvkm_mask(device, 0x021200 + (line * 4), 0x00003000, data);
59+ nvkm_mask(device, 0x00d604, 0x00000001, 0x00000001); /* update? */
60+ return 0;
61+}
62+
63+static int
64+ga102_gpio_sense(struct nvkm_gpio *gpio, int line)
65+{
66+ struct nvkm_device *device = gpio->subdev.device;
67+ return !!(nvkm_rd32(device, 0x021200 + (line * 4)) & 0x00004000);
68+}
69+
70+static void
71+ga102_gpio_intr_stat(struct nvkm_gpio *gpio, u32 *hi, u32 *lo)
72+{
73+ struct nvkm_device *device = gpio->subdev.device;
74+ u32 intr0 = nvkm_rd32(device, 0x021640);
75+ u32 intr1 = nvkm_rd32(device, 0x02164c);
76+ u32 stat0 = nvkm_rd32(device, 0x021648) & intr0;
77+ u32 stat1 = nvkm_rd32(device, 0x021654) & intr1;
78+ *lo = (stat1 & 0xffff0000) | (stat0 >> 16);
79+ *hi = (stat1 << 16) | (stat0 & 0x0000ffff);
80+ nvkm_wr32(device, 0x021640, intr0);
81+ nvkm_wr32(device, 0x02164c, intr1);
82+}
83+
84+static void
85+ga102_gpio_intr_mask(struct nvkm_gpio *gpio, u32 type, u32 mask, u32 data)
86+{
87+ struct nvkm_device *device = gpio->subdev.device;
88+ u32 inte0 = nvkm_rd32(device, 0x021648);
89+ u32 inte1 = nvkm_rd32(device, 0x021654);
90+ if (type & NVKM_GPIO_LO)
91+ inte0 = (inte0 & ~(mask << 16)) | (data << 16);
92+ if (type & NVKM_GPIO_HI)
93+ inte0 = (inte0 & ~(mask & 0xffff)) | (data & 0xffff);
94+ mask >>= 16;
95+ data >>= 16;
96+ if (type & NVKM_GPIO_LO)
97+ inte1 = (inte1 & ~(mask << 16)) | (data << 16);
98+ if (type & NVKM_GPIO_HI)
99+ inte1 = (inte1 & ~mask) | data;
100+ nvkm_wr32(device, 0x021648, inte0);
101+ nvkm_wr32(device, 0x021654, inte1);
102+}
103+
104+static const struct nvkm_gpio_func
105+ga102_gpio = {
106+ .lines = 32,
107+ .intr_stat = ga102_gpio_intr_stat,
108+ .intr_mask = ga102_gpio_intr_mask,
109+ .drive = ga102_gpio_drive,
110+ .sense = ga102_gpio_sense,
111+ .reset = ga102_gpio_reset,
112+};
113+
114+int
115+ga102_gpio_new(struct nvkm_device *device, int index, struct nvkm_gpio **pgpio)
116+{
117+ return nvkm_gpio_new_(&ga102_gpio, device, index, pgpio);
118+}
drivers/gpu/drm/nouveau/nvkm/subdev/i2c/Kbuild+1−0
@@ -7,6 +7,7 @@ nvkm-y += nvkm/subdev/i2c/g94.o · 6 unmodified lines
77 nvkm-y += nvkm/subdev/i2c/gf117.o
88 nvkm-y += nvkm/subdev/i2c/gf119.o
99 nvkm-y += nvkm/subdev/i2c/gk104.o
10+nvkm-y += nvkm/subdev/i2c/gk110.o
1011 nvkm-y += nvkm/subdev/i2c/gm200.o
1112
1213 nvkm-y += nvkm/subdev/i2c/pad.o
drivers/gpu/drm/nouveau/nvkm/subdev/i2c/aux.h+7−0
@@ -3,6 +3,13 @@ · 2 unmodified lines
33 #define __NVKM_I2C_AUX_H__
44 #include "pad.h"
55
6+static inline void
7+nvkm_i2c_aux_autodpcd(struct nvkm_i2c *i2c, int aux, bool enable)
8+{
9+ if (i2c->func->aux_autodpcd)
10+ i2c->func->aux_autodpcd(i2c, aux, false);
11+}
12+
613 struct nvkm_i2c_aux_func {
714 bool address_only;
815 int (*xfer)(struct nvkm_i2c_aux *, bool retry, u8 type,
drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxg94.c+7−3
@@ -77,7 +77,8 @@ g94_i2c_aux_xfer(struct nvkm_i2c_aux *obj, bool retry, · 76 unmodified lines
7777 u8 type, u32 addr, u8 *data, u8 *size)
7878 {
7979 struct g94_i2c_aux *aux = g94_i2c_aux(obj);
80− struct nvkm_device *device = aux->base.pad->i2c->subdev.device;
80+ struct nvkm_i2c *i2c = aux->base.pad->i2c;
81+ struct nvkm_device *device = i2c->subdev.device;
8182 const u32 base = aux->ch * 0x50;
8283 u32 ctrl, stat, timeout, retries = 0;
8384 u32 xbuf[4] = {};
@@ -96,6 +97,8 @@ g94_i2c_aux_xfer(struct nvkm_i2c_aux *obj, bool retry, · 12 unmodified lines
9697 goto out;
9798 }
9899
100+ nvkm_i2c_aux_autodpcd(i2c, aux->ch, false);
101+
99102 if (!(type & 1)) {
100103 memcpy(xbuf, data, *size);
101104 for (i = 0; i < 16; i += 4) {
@@ -128,7 +131,7 @@ g94_i2c_aux_xfer(struct nvkm_i2c_aux *obj, bool retry, · 26 unmodified lines
128131 if (!timeout--) {
129132 AUX_ERR(&aux->base, "timeout %08x", ctrl);
130133 ret = -EIO;
131− goto out;
134+ goto out_err;
132135 }
133136 } while (ctrl & 0x00010000);
134137 ret = 0;
@@ -154,7 +157,8 @@ g94_i2c_aux_xfer(struct nvkm_i2c_aux *obj, bool retry, · 19 unmodified lines
154157 memcpy(data, xbuf, *size);
155158 *size = stat & 0x0000001f;
156159 }
157−
160+out_err:
161+ nvkm_i2c_aux_autodpcd(i2c, aux->ch, true);
158162 out:
159163 g94_i2c_aux_fini(aux);
160164 return ret < 0 ? ret : (stat & 0x000f0000) >> 16;
drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm200.c+11−6
@@ -33,7 +33,7 @@ static void · 32 unmodified lines
3333 gm200_i2c_aux_fini(struct gm200_i2c_aux *aux)
3434 {
3535 struct nvkm_device *device = aux->base.pad->i2c->subdev.device;
36− nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x00310000, 0x00000000);
36+ nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x00710000, 0x00000000);
3737 }
3838
3939 static int
@@ -54,10 +54,10 @@ gm200_i2c_aux_init(struct gm200_i2c_aux *aux) · 14 unmodified lines
5454 AUX_ERR(&aux->base, "begin idle timeout %08x", ctrl);
5555 return -EBUSY;
5656 }
57− } while (ctrl & 0x03010000);
57+ } while (ctrl & 0x07010000);
5858
5959 /* set some magic, and wait up to 1ms for it to appear */
60− nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x00300000, ureq);
60+ nvkm_mask(device, 0x00d954 + (aux->ch * 0x50), 0x00700000, ureq);
6161 timeout = 1000;
6262 do {
6363 ctrl = nvkm_rd32(device, 0x00d954 + (aux->ch * 0x50));
@@ -67,7 +67,7 @@ gm200_i2c_aux_init(struct gm200_i2c_aux *aux) · 3 unmodified lines
6767 gm200_i2c_aux_fini(aux);
6868 return -EBUSY;
6969 }
70− } while ((ctrl & 0x03000000) != urep);
70+ } while ((ctrl & 0x07000000) != urep);
7171
7272 return 0;
7373 }
@@ -77,7 +77,8 @@ gm200_i2c_aux_xfer(struct nvkm_i2c_aux *obj, bool retry, · 3 unmodified lines
7777 u8 type, u32 addr, u8 *data, u8 *size)
7878 {
7979 struct gm200_i2c_aux *aux = gm200_i2c_aux(obj);
80− struct nvkm_device *device = aux->base.pad->i2c->subdev.device;
80+ struct nvkm_i2c *i2c = aux->base.pad->i2c;
81+ struct nvkm_device *device = i2c->subdev.device;
8182 const u32 base = aux->ch * 0x50;
8283 u32 ctrl, stat, timeout, retries = 0;
8384 u32 xbuf[4] = {};
@@ -96,6 +97,8 @@ gm200_i2c_aux_xfer(struct nvkm_i2c_aux *obj, bool retry, · 12 unmodified lines
9697 goto out;
9798 }
9899
100+ nvkm_i2c_aux_autodpcd(i2c, aux->ch, false);
101+
99102 if (!(type & 1)) {
100103 memcpy(xbuf, data, *size);
101104 for (i = 0; i < 16; i += 4) {
@@ -128,7 +131,7 @@ gm200_i2c_aux_xfer(struct nvkm_i2c_aux *obj, bool retry, · 26 unmodified lines
128131 if (!timeout--) {
129132 AUX_ERR(&aux->base, "timeout %08x", ctrl);
130133 ret = -EIO;
131− goto out;
134+ goto out_err;
132135 }
133136 } while (ctrl & 0x00010000);
134137 ret = 0;
@@ -155,6 +158,8 @@ gm200_i2c_aux_xfer(struct nvkm_i2c_aux *obj, bool retry, · 20 unmodified lines
155158 *size = stat & 0x0000001f;
156159 }
157160
161+out_err:
162+ nvkm_i2c_aux_autodpcd(i2c, aux->ch, true);
158163 out:
159164 gm200_i2c_aux_fini(aux);
160165 return ret < 0 ? ret : (stat & 0x000f0000) >> 16;
drivers/gpu/drm/nouveau/nvkm/subdev/i2c/gk110.c+45−0
@@ -0,0 +1,45 @@
1+/*
2+ * Copyright 2021 Red Hat Inc.
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a
5+ * copy of this software and associated documentation files (the "Software"),
6+ * to deal in the Software without restriction, including without limitation
7+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+ * and/or sell copies of the Software, and to permit persons to whom the
9+ * Software is furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+ * OTHER DEALINGS IN THE SOFTWARE.
21+ */
22+#include "priv.h"
23+#include "pad.h"
24+
25+static void
26+gk110_aux_autodpcd(struct nvkm_i2c *i2c, int aux, bool enable)
27+{
28+ nvkm_mask(i2c->subdev.device, 0x00e4f8 + (aux * 0x50), 0x00010000, enable << 16);
29+}
30+
31+static const struct nvkm_i2c_func
32+gk110_i2c = {
33+ .pad_x_new = gf119_i2c_pad_x_new,
34+ .pad_s_new = gf119_i2c_pad_s_new,
35+ .aux = 4,
36+ .aux_stat = gk104_aux_stat,
37+ .aux_mask = gk104_aux_mask,
38+ .aux_autodpcd = gk110_aux_autodpcd,
39+};
40+
41+int
42+gk110_i2c_new(struct nvkm_device *device, int index, struct nvkm_i2c **pi2c)
43+{
44+ return nvkm_i2c_new_(&gk110_i2c, device, index, pi2c);
45+}
drivers/gpu/drm/nouveau/nvkm/subdev/i2c/gm200.c+7−0
@@ -24,6 +24,12 @@ · 23 unmodified lines
2424 #include "priv.h"
2525 #include "pad.h"
2626
27+static void
28+gm200_aux_autodpcd(struct nvkm_i2c *i2c, int aux, bool enable)
29+{
30+ nvkm_mask(i2c->subdev.device, 0x00d968 + (aux * 0x50), 0x00010000, enable << 16);
31+}
32+
2733 static const struct nvkm_i2c_func
2834 gm200_i2c = {
2935 .pad_x_new = gf119_i2c_pad_x_new,
@@ -31,6 +37,7 @@ gm200_i2c = { · 1 unmodified line
3137 .aux = 8,
3238 .aux_stat = gk104_aux_stat,
3339 .aux_mask = gk104_aux_mask,
40+ .aux_autodpcd = gm200_aux_autodpcd,
3441 };
3542
3643 int
drivers/gpu/drm/nouveau/nvkm/subdev/i2c/pad.h+1−1
@@ -1,7 +1,7 @@
11 /* SPDX-License-Identifier: MIT */
22 #ifndef __NVKM_I2C_PAD_H__
33 #define __NVKM_I2C_PAD_H__
4−#include <subdev/i2c.h>
4+#include "priv.h"
55
66 struct nvkm_i2c_pad {
77 const struct nvkm_i2c_pad_func *func;
drivers/gpu/drm/nouveau/nvkm/subdev/i2c/priv.h+4−0
@@ -23,6 +23,10 @@ struct nvkm_i2c_func { · 22 unmodified lines
2323 /* mask on/off interrupt types for a given set of auxch
2424 */
2525 void (*aux_mask)(struct nvkm_i2c *, u32, u32, u32);
26+
27+ /* enable/disable HW-initiated DPCD reads
28+ */
29+ void (*aux_autodpcd)(struct nvkm_i2c *, int aux, bool enable);
2630 };
2731
2832 void g94_aux_stat(struct nvkm_i2c *, u32 *, u32 *, u32 *, u32 *);
drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gf100.c+7−3
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222 * Authors: Ben Skeggs
2323 */
2424 #include "priv.h"
25+#include <subdev/timer.h>
2526
2627 static void
2728 gf100_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
@@ -31,7 +32,6 @@ gf100_ibus_intr_hub(struct nvkm_subdev *ibus, int i) · 3 unmodified lines
3132 u32 data = nvkm_rd32(device, 0x122124 + (i * 0x0400));
3233 u32 stat = nvkm_rd32(device, 0x122128 + (i * 0x0400));
3334 nvkm_debug(ibus, "HUB%d: %06x %08x (%08x)\n", i, addr, data, stat);
34− nvkm_mask(device, 0x122128 + (i * 0x0400), 0x00000200, 0x00000000);
3535 }
3636
3737 static void
@@ -42,7 +42,6 @@ gf100_ibus_intr_rop(struct nvkm_subdev *ibus, int i) · 4 unmodified lines
4242 u32 data = nvkm_rd32(device, 0x124124 + (i * 0x0400));
4343 u32 stat = nvkm_rd32(device, 0x124128 + (i * 0x0400));
4444 nvkm_debug(ibus, "ROP%d: %06x %08x (%08x)\n", i, addr, data, stat);
45− nvkm_mask(device, 0x124128 + (i * 0x0400), 0x00000200, 0x00000000);
4645 }
4746
4847 static void
@@ -53,7 +52,6 @@ gf100_ibus_intr_gpc(struct nvkm_subdev *ibus, int i) · 4 unmodified lines
5352 u32 data = nvkm_rd32(device, 0x128124 + (i * 0x0400));
5453 u32 stat = nvkm_rd32(device, 0x128128 + (i * 0x0400));
5554 nvkm_debug(ibus, "GPC%d: %06x %08x (%08x)\n", i, addr, data, stat);
56− nvkm_mask(device, 0x128128 + (i * 0x0400), 0x00000200, 0x00000000);
5755 }
5856
5957 void
@@ -90,6 +88,12 @@ gf100_ibus_intr(struct nvkm_subdev *ibus) · 30 unmodified lines
9088 intr1 &= ~stat;
9189 }
9290 }
91+
92+ nvkm_mask(device, 0x121c4c, 0x0000003f, 0x00000002);
93+ nvkm_msec(device, 2000,
94+ if (!(nvkm_rd32(device, 0x121c4c) & 0x0000003f))
95+ break;
96+ );
9397 }
9498
9599 static int
drivers/gpu/drm/nouveau/nvkm/subdev/ibus/gk104.c+7−3
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222 * Authors: Ben Skeggs
2323 */
2424 #include "priv.h"
25+#include <subdev/timer.h>
2526
2627 static void
2728 gk104_ibus_intr_hub(struct nvkm_subdev *ibus, int i)
@@ -31,7 +32,6 @@ gk104_ibus_intr_hub(struct nvkm_subdev *ibus, int i) · 3 unmodified lines
3132 u32 data = nvkm_rd32(device, 0x122124 + (i * 0x0800));
3233 u32 stat = nvkm_rd32(device, 0x122128 + (i * 0x0800));
3334 nvkm_debug(ibus, "HUB%d: %06x %08x (%08x)\n", i, addr, data, stat);
34− nvkm_mask(device, 0x122128 + (i * 0x0800), 0x00000200, 0x00000000);
3535 }
3636
3737 static void
@@ -42,7 +42,6 @@ gk104_ibus_intr_rop(struct nvkm_subdev *ibus, int i) · 4 unmodified lines
4242 u32 data = nvkm_rd32(device, 0x124124 + (i * 0x0800));
4343 u32 stat = nvkm_rd32(device, 0x124128 + (i * 0x0800));
4444 nvkm_debug(ibus, "ROP%d: %06x %08x (%08x)\n", i, addr, data, stat);
45− nvkm_mask(device, 0x124128 + (i * 0x0800), 0x00000200, 0x00000000);
4645 }
4746
4847 static void
@@ -53,7 +52,6 @@ gk104_ibus_intr_gpc(struct nvkm_subdev *ibus, int i) · 4 unmodified lines
5352 u32 data = nvkm_rd32(device, 0x128124 + (i * 0x0800));
5453 u32 stat = nvkm_rd32(device, 0x128128 + (i * 0x0800));
5554 nvkm_debug(ibus, "GPC%d: %06x %08x (%08x)\n", i, addr, data, stat);
56− nvkm_mask(device, 0x128128 + (i * 0x0800), 0x00000200, 0x00000000);
5755 }
5856
5957 void
@@ -90,6 +88,12 @@ gk104_ibus_intr(struct nvkm_subdev *ibus) · 30 unmodified lines
9088 intr1 &= ~stat;
9189 }
9290 }
91+
92+ nvkm_mask(device, 0x12004c, 0x0000003f, 0x00000002);
93+ nvkm_msec(device, 2000,
94+ if (!(nvkm_rd32(device, 0x12004c) & 0x0000003f))
95+ break;
96+ );
9397 }
9498
9599 static int
drivers/gpu/drm/nouveau/nvkm/subdev/mc/Kbuild+1−0
@@ -14,3 +14,4 @@ nvkm-y += nvkm/subdev/mc/gk20a.o · 13 unmodified lines
1414 nvkm-y += nvkm/subdev/mc/gp100.o
1515 nvkm-y += nvkm/subdev/mc/gp10b.o
1616 nvkm-y += nvkm/subdev/mc/tu102.o
17+nvkm-y += nvkm/subdev/mc/ga100.o
drivers/gpu/drm/nouveau/nvkm/subdev/mc/ga100.c+74−0
@@ -0,0 +1,74 @@
1+/*
2+ * Copyright 2021 Red Hat Inc.
3+ *
4+ * Permission is hereby granted, free of charge, to any person obtaining a
5+ * copy of this software and associated documentation files (the "Software"),
6+ * to deal in the Software without restriction, including without limitation
7+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+ * and/or sell copies of the Software, and to permit persons to whom the
9+ * Software is furnished to do so, subject to the following conditions:
10+ *
11+ * The above copyright notice and this permission notice shall be included in
12+ * all copies or substantial portions of the Software.
13+ *
14+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20+ * OTHER DEALINGS IN THE SOFTWARE.
21+ */
22+#include "priv.h"
23+
24+static void
25+ga100_mc_intr_unarm(struct nvkm_mc *mc)
26+{
27+ nvkm_wr32(mc->subdev.device, 0xb81610, 0x00000004);
28+}
29+
30+static void
31+ga100_mc_intr_rearm(struct nvkm_mc *mc)
32+{
33+ nvkm_wr32(mc->subdev.device, 0xb81608, 0x00000004);
34+}
35+
36+static void
37+ga100_mc_intr_mask(struct nvkm_mc *mc, u32 mask, u32 intr)
38+{
39+ nvkm_wr32(mc->subdev.device, 0xb81210, mask & intr );
40+ nvkm_wr32(mc->subdev.device, 0xb81410, mask & ~(mask & intr));
41+}
42+
43+static u32
44+ga100_mc_intr_stat(struct nvkm_mc *mc)
45+{
46+ u32 intr_top = nvkm_rd32(mc->subdev.device, 0xb81600), intr = 0x00000000;
47+ if (intr_top & 0x00000004)
48+ intr = nvkm_mask(mc->subdev.device, 0xb81010, 0x00000000, 0x00000000);
49+ return intr;
50+}
51+
52+static void
53+ga100_mc_init(struct nvkm_mc *mc)
54+{
55+ nv50_mc_init(mc);
56+ nvkm_wr32(mc->subdev.device, 0xb81210, 0xffffffff);
57+}
58+
59+static const struct nvkm_mc_func
60+ga100_mc = {
61+ .init = ga100_mc_init,
62+ .intr = gp100_mc_intr,
63+ .intr_unarm = ga100_mc_intr_unarm,
64+ .intr_rearm = ga100_mc_intr_rearm,
65+ .intr_mask = ga100_mc_intr_mask,
66+ .intr_stat = ga100_mc_intr_stat,
67+ .reset = gk104_mc_reset,
68+};
69+
70+int
71+ga100_mc_new(struct nvkm_device *device, int index, struct nvkm_mc **pmc)
72+{
73+ return nvkm_mc_new_(&ga100_mc, device, index, pmc);
74+}
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/base.c+3−3
@@ -316,9 +316,9 @@ nvkm_mmu_vram(struct nvkm_mmu *mmu) · 315 unmodified lines
316316 {
317317 struct nvkm_device *device = mmu->subdev.device;
318318 struct nvkm_mm *mm = &device->fb->ram->vram;
319− const u32 sizeN = nvkm_mm_heap_size(mm, NVKM_RAM_MM_NORMAL);
320− const u32 sizeU = nvkm_mm_heap_size(mm, NVKM_RAM_MM_NOMAP);
321− const u32 sizeM = nvkm_mm_heap_size(mm, NVKM_RAM_MM_MIXED);
319+ const u64 sizeN = nvkm_mm_heap_size(mm, NVKM_RAM_MM_NORMAL);
320+ const u64 sizeU = nvkm_mm_heap_size(mm, NVKM_RAM_MM_NOMAP);
321+ const u64 sizeM = nvkm_mm_heap_size(mm, NVKM_RAM_MM_MIXED);
322322 u8 type = NVKM_MEM_KIND * !!mmu->func->kind;
323323 u8 heap = NVKM_MEM_VRAM;
324324 int heapM, heapN, heapU;
drivers/gpu/drm/ttm/ttm_pool.c+11−11
@@ -66,7 +66,7 @@ static struct ttm_pool_type global_uncached[MAX_ORDER]; · 65 unmodified lines
6666 static struct ttm_pool_type global_dma32_write_combined[MAX_ORDER];
6767 static struct ttm_pool_type global_dma32_uncached[MAX_ORDER];
6868
69−static spinlock_t shrinker_lock;
69+static struct mutex shrinker_lock;
7070 static struct list_head shrinker_list;
7171 static struct shrinker mm_shrinker;
7272
@@ -190,7 +190,7 @@ static int ttm_pool_map(struct ttm_pool *pool, unsigned int order, · 117 unmodified lines
190190 size_t size = (1ULL << order) * PAGE_SIZE;
191191
192192 addr = dma_map_page(pool->dev, p, 0, size, DMA_BIDIRECTIONAL);
193− if (dma_mapping_error(pool->dev, **dma_addr))
193+ if (dma_mapping_error(pool->dev, addr))
194194 return -EFAULT;
195195 }
196196
@@ -249,9 +249,9 @@ static void ttm_pool_type_init(struct ttm_pool_type *pt, struct ttm_pool *pool, · 52 unmodified lines
249249 spin_lock_init(&pt->lock);
250250 INIT_LIST_HEAD(&pt->pages);
251251
252− spin_lock(&shrinker_lock);
252+ mutex_lock(&shrinker_lock);
253253 list_add_tail(&pt->shrinker_list, &shrinker_list);
254− spin_unlock(&shrinker_lock);
254+ mutex_unlock(&shrinker_lock);
255255 }
256256
257257 /* Remove a pool_type from the global shrinker list and free all pages */
@@ -259,9 +259,9 @@ static void ttm_pool_type_fini(struct ttm_pool_type *pt) · 1 unmodified line
259259 {
260260 struct page *p, *tmp;
261261
262− spin_lock(&shrinker_lock);
262+ mutex_lock(&shrinker_lock);
263263 list_del(&pt->shrinker_list);
264− spin_unlock(&shrinker_lock);
264+ mutex_unlock(&shrinker_lock);
265265
266266 list_for_each_entry_safe(p, tmp, &pt->pages, lru)
267267 ttm_pool_free_page(pt->pool, pt->caching, pt->order, p);
@@ -302,7 +302,7 @@ static unsigned int ttm_pool_shrink(void) · 34 unmodified lines
302302 unsigned int num_freed;
303303 struct page *p;
304304
305− spin_lock(&shrinker_lock);
305+ mutex_lock(&shrinker_lock);
306306 pt = list_first_entry(&shrinker_list, typeof(*pt), shrinker_list);
307307
308308 p = ttm_pool_type_take(pt);
@@ -314,7 +314,7 @@ static unsigned int ttm_pool_shrink(void) · 5 unmodified lines
314314 }
315315
316316 list_move_tail(&pt->shrinker_list, &shrinker_list);
317− spin_unlock(&shrinker_lock);
317+ mutex_unlock(&shrinker_lock);
318318
319319 return num_freed;
320320 }
@@ -564,7 +564,7 @@ int ttm_pool_debugfs(struct ttm_pool *pool, struct seq_file *m) · 243 unmodified lines
564564 {
565565 unsigned int i;
566566
567− spin_lock(&shrinker_lock);
567+ mutex_lock(&shrinker_lock);
568568
569569 seq_puts(m, "\t ");
570570 for (i = 0; i < MAX_ORDER; ++i)
@@ -600,7 +600,7 @@ int ttm_pool_debugfs(struct ttm_pool *pool, struct seq_file *m) · 29 unmodified lines
600600 seq_printf(m, "\ntotal\t: %8lu of %8lu\n",
601601 atomic_long_read(&allocated_pages), page_pool_size);
602602
603− spin_unlock(&shrinker_lock);
603+ mutex_unlock(&shrinker_lock);
604604
605605 return 0;
606606 }
@@ -644,7 +644,7 @@ int ttm_pool_mgr_init(unsigned long num_pages) · 37 unmodified lines
644644 if (!page_pool_size)
645645 page_pool_size = num_pages;
646646
647− spin_lock_init(&shrinker_lock);
647+ mutex_init(&shrinker_lock);
648648 INIT_LIST_HEAD(&shrinker_list);
649649
650650 for (i = 0; i < MAX_ORDER; ++i) {
drivers/infiniband/core/cma_configfs.c+3−1
@@ -131,8 +131,10 @@ static ssize_t default_roce_mode_store(struct config_item *item, · 130 unmodified lines
131131 return ret;
132132
133133 gid_type = ib_cache_gid_parse_type_str(buf);
134− if (gid_type < 0)
134+ if (gid_type < 0) {
135+ cma_configfs_params_put(cma_dev);
135136 return -EINVAL;
137+ }
136138
137139 ret = cma_set_default_gid_type(cma_dev, group->port_num, gid_type);
138140
drivers/infiniband/core/restrack.c+1−0
@@ -254,6 +254,7 @@ void rdma_restrack_add(struct rdma_restrack_entry *res) · 253 unmodified lines
254254 } else {
255255 ret = xa_alloc_cyclic(&rt->xa, &res->id, res, xa_limit_32b,
256256 &rt->next_id, GFP_KERNEL);
257+ ret = (ret < 0) ? ret : 0;
257258 }
258259
259260 out:
drivers/infiniband/core/ucma.c+72−63
@@ -95,8 +95,6 @@ struct ucma_context { · 94 unmodified lines
9595 u64 uid;
9696
9797 struct list_head list;
98− /* sync between removal event and id destroy, protected by file mut */
99− int destroying;
10098 struct work_struct close_work;
10199 };
102100
@@ -122,7 +120,7 @@ static DEFINE_XARRAY_ALLOC(ctx_table); · 19 unmodified lines
122120 static DEFINE_XARRAY_ALLOC(multicast_table);
123121
124122 static const struct file_operations ucma_fops;
125−static int __destroy_id(struct ucma_context *ctx);
123+static int ucma_destroy_private_ctx(struct ucma_context *ctx);
126124
127125 static inline struct ucma_context *_ucma_find_context(int id,
128126 struct ucma_file *file)
@@ -179,19 +177,14 @@ static void ucma_close_id(struct work_struct *work) · 50 unmodified lines
179177
180178 /* once all inflight tasks are finished, we close all underlying
181179 * resources. The context is still alive till its explicit destryoing
182− * by its creator.
180+ * by its creator. This puts back the xarray's reference.
183181 */
184182 ucma_put_ctx(ctx);
185183 wait_for_completion(&ctx->comp);
186184 /* No new events will be generated after destroying the id. */
187185 rdma_destroy_id(ctx->cm_id);
188186
189− /*
190− * At this point ctx->ref is zero so the only place the ctx can be is in
191− * a uevent or in __destroy_id(). Since the former doesn't touch
192− * ctx->cm_id and the latter sync cancels this, there is no races with
193− * this store.
194− */
187+ /* Reading the cm_id without holding a positive ref is not allowed */
195188 ctx->cm_id = NULL;
196189 }
197190
@@ -204,7 +197,6 @@ static struct ucma_context *ucma_alloc_ctx(struct ucma_file *file) · 6 unmodified lines
204197 return NULL;
205198
206199 INIT_WORK(&ctx->close_work, ucma_close_id);
207− refcount_set(&ctx->ref, 1);
208200 init_completion(&ctx->comp);
209201 /* So list_del() will work if we don't do ucma_finish_ctx() */
210202 INIT_LIST_HEAD(&ctx->list);
@@ -218,6 +210,13 @@ static struct ucma_context *ucma_alloc_ctx(struct ucma_file *file) · 7 unmodified lines
218210 return ctx;
219211 }
220212
213+static void ucma_set_ctx_cm_id(struct ucma_context *ctx,
214+ struct rdma_cm_id *cm_id)
215+{
216+ refcount_set(&ctx->ref, 1);
217+ ctx->cm_id = cm_id;
218+}
219+
221220 static void ucma_finish_ctx(struct ucma_context *ctx)
222221 {
223222 lockdep_assert_held(&ctx->file->mut);
@@ -303,7 +302,7 @@ static int ucma_connect_event_handler(struct rdma_cm_id *cm_id, · 79 unmodified lines
303302 ctx = ucma_alloc_ctx(listen_ctx->file);
304303 if (!ctx)
305304 goto err_backlog;
306− ctx->cm_id = cm_id;
305+ ucma_set_ctx_cm_id(ctx, cm_id);
307306
308307 uevent = ucma_create_uevent(listen_ctx, event);
309308 if (!uevent)
@@ -321,8 +320,7 @@ static int ucma_connect_event_handler(struct rdma_cm_id *cm_id, · 11 unmodified lines
321320 return 0;
322321
323322 err_alloc:
324− xa_erase(&ctx_table, ctx->id);
325− kfree(ctx);
323+ ucma_destroy_private_ctx(ctx);
326324 err_backlog:
327325 atomic_inc(&listen_ctx->backlog);
328326 /* Returning error causes the new ID to be destroyed */
@@ -356,8 +354,12 @@ static int ucma_event_handler(struct rdma_cm_id *cm_id, · 27 unmodified lines
356354 wake_up_interruptible(&ctx->file->poll_wait);
357355 }
358356
359− if (event->event == RDMA_CM_EVENT_DEVICE_REMOVAL && !ctx->destroying)
360− queue_work(system_unbound_wq, &ctx->close_work);
357+ if (event->event == RDMA_CM_EVENT_DEVICE_REMOVAL) {
358+ xa_lock(&ctx_table);
359+ if (xa_load(&ctx_table, ctx->id) == ctx)
360+ queue_work(system_unbound_wq, &ctx->close_work);
361+ xa_unlock(&ctx_table);
362+ }
361363 return 0;
362364 }
363365
@@ -461,13 +463,12 @@ static ssize_t ucma_create_id(struct ucma_file *file, const char __user *inbuf, · 97 unmodified lines
461463 ret = PTR_ERR(cm_id);
462464 goto err1;
463465 }
464− ctx->cm_id = cm_id;
466+ ucma_set_ctx_cm_id(ctx, cm_id);
465467
466468 resp.id = ctx->id;
467469 if (copy_to_user(u64_to_user_ptr(cmd.response),
468470 &resp, sizeof(resp))) {
469− xa_erase(&ctx_table, ctx->id);
470− __destroy_id(ctx);
471+ ucma_destroy_private_ctx(ctx);
471472 return -EFAULT;
472473 }
473474
@@ -477,8 +478,7 @@ static ssize_t ucma_create_id(struct ucma_file *file, const char __user *inbuf, · 3 unmodified lines
477478 return 0;
478479
479480 err1:
480− xa_erase(&ctx_table, ctx->id);
481− kfree(ctx);
481+ ucma_destroy_private_ctx(ctx);
482482 return ret;
483483 }
484484
@@ -516,68 +516,73 @@ static void ucma_cleanup_mc_events(struct ucma_multicast *mc) · 31 unmodified lines
516516 rdma_unlock_handler(mc->ctx->cm_id);
517517 }
518518
519−/*
520− * ucma_free_ctx is called after the underlying rdma CM-ID is destroyed. At
521− * this point, no new events will be reported from the hardware. However, we
522− * still need to cleanup the UCMA context for this ID. Specifically, there
523− * might be events that have not yet been consumed by the user space software.
524− * mutex. After that we release them as needed.
525− */
526−static int ucma_free_ctx(struct ucma_context *ctx)
519+static int ucma_cleanup_ctx_events(struct ucma_context *ctx)
527520 {
528521 int events_reported;
529522 struct ucma_event *uevent, *tmp;
530523 LIST_HEAD(list);
531524
532− ucma_cleanup_multicast(ctx);
533−
534− /* Cleanup events not yet reported to the user. */
525+ /* Cleanup events not yet reported to the user.*/
535526 mutex_lock(&ctx->file->mut);
536527 list_for_each_entry_safe(uevent, tmp, &ctx->file->event_list, list) {
537− if (uevent->ctx == ctx || uevent->conn_req_ctx == ctx)
528+ if (uevent->ctx != ctx)
529+ continue;
530+
531+ if (uevent->resp.event == RDMA_CM_EVENT_CONNECT_REQUEST &&
532+ xa_cmpxchg(&ctx_table, uevent->conn_req_ctx->id,
533+ uevent->conn_req_ctx, XA_ZERO_ENTRY,
534+ GFP_KERNEL) == uevent->conn_req_ctx) {
538535 list_move_tail(&uevent->list, &list);
536+ continue;
537+ }
538+ list_del(&uevent->list);
539+ kfree(uevent);
539540 }
540541 list_del(&ctx->list);
541542 events_reported = ctx->events_reported;
542543 mutex_unlock(&ctx->file->mut);
543544
544545 /*
545− * If this was a listening ID then any connections spawned from it
546− * that have not been delivered to userspace are cleaned up too.
547− * Must be done outside any locks.
546+ * If this was a listening ID then any connections spawned from it that
547+ * have not been delivered to userspace are cleaned up too. Must be done
548+ * outside any locks.
548549 */
549550 list_for_each_entry_safe(uevent, tmp, &list, list) {
550− list_del(&uevent->list);
551− if (uevent->resp.event == RDMA_CM_EVENT_CONNECT_REQUEST &&
552− uevent->conn_req_ctx != ctx)
553− __destroy_id(uevent->conn_req_ctx);
551+ ucma_destroy_private_ctx(uevent->conn_req_ctx);
554552 kfree(uevent);
555553 }
556−
557− mutex_destroy(&ctx->mutex);
558− kfree(ctx);
559554 return events_reported;
560555 }
561556
562−static int __destroy_id(struct ucma_context *ctx)
557+/*
558+ * When this is called the xarray must have a XA_ZERO_ENTRY in the ctx->id (ie
559+ * the ctx is not public to the user). This either because:
560+ * - ucma_finish_ctx() hasn't been called
561+ * - xa_cmpxchg() succeed to remove the entry (only one thread can succeed)
562+ */
563+static int ucma_destroy_private_ctx(struct ucma_context *ctx)
563564 {
565+ int events_reported;
566+
564567 /*
565− * If the refcount is already 0 then ucma_close_id() has already
566− * destroyed the cm_id, otherwise holding the refcount keeps cm_id
567− * valid. Prevent queue_work() from being called.
568+ * Destroy the underlying cm_id. New work queuing is prevented now by
569+ * the removal from the xarray. Once the work is cancled ref will either
570+ * be 0 because the work ran to completion and consumed the ref from the
571+ * xarray, or it will be positive because we still have the ref from the
572+ * xarray. This can also be 0 in cases where cm_id was never set
568573 */
569− if (refcount_inc_not_zero(&ctx->ref)) {
570− rdma_lock_handler(ctx->cm_id);
571− ctx->destroying = 1;
572− rdma_unlock_handler(ctx->cm_id);
573− ucma_put_ctx(ctx);
574− }
575−
576574 cancel_work_sync(&ctx->close_work);
577− /* At this point it's guaranteed that there is no inflight closing task */
578− if (ctx->cm_id)
575+ if (refcount_read(&ctx->ref))
579576 ucma_close_id(&ctx->close_work);
580− return ucma_free_ctx(ctx);
577+
578+ events_reported = ucma_cleanup_ctx_events(ctx);
579+ ucma_cleanup_multicast(ctx);
580+
581+ WARN_ON(xa_cmpxchg(&ctx_table, ctx->id, XA_ZERO_ENTRY, NULL,
582+ GFP_KERNEL) != NULL);
583+ mutex_destroy(&ctx->mutex);
584+ kfree(ctx);
585+ return events_reported;
581586 }
582587
583588 static ssize_t ucma_destroy_id(struct ucma_file *file, const char __user *inbuf,
@@ -596,14 +601,17 @@ static ssize_t ucma_destroy_id(struct ucma_file *file, const char __user *inbuf, · 12 unmodified lines
596601
597602 xa_lock(&ctx_table);
598603 ctx = _ucma_find_context(cmd.id, file);
599− if (!IS_ERR(ctx))
600− __xa_erase(&ctx_table, ctx->id);
604+ if (!IS_ERR(ctx)) {
605+ if (__xa_cmpxchg(&ctx_table, ctx->id, ctx, XA_ZERO_ENTRY,
606+ GFP_KERNEL) != ctx)
607+ ctx = ERR_PTR(-ENOENT);
608+ }
601609 xa_unlock(&ctx_table);
602610
603611 if (IS_ERR(ctx))
604612 return PTR_ERR(ctx);
605613
606− resp.events_reported = __destroy_id(ctx);
614+ resp.events_reported = ucma_destroy_private_ctx(ctx);
607615 if (copy_to_user(u64_to_user_ptr(cmd.response),
608616 &resp, sizeof(resp)))
609617 ret = -EFAULT;
@@ -1777,15 +1785,16 @@ static int ucma_close(struct inode *inode, struct file *filp) · 1167 unmodified lines
17771785 * prevented by this being a FD release function. The list_add_tail() in
17781786 * ucma_connect_event_handler() can run concurrently, however it only
17791787 * adds to the list *after* a listening ID. By only reading the first of
1780− * the list, and relying on __destroy_id() to block
1788+ * the list, and relying on ucma_destroy_private_ctx() to block
17811789 * ucma_connect_event_handler(), no additional locking is needed.
17821790 */
17831791 while (!list_empty(&file->ctx_list)) {
17841792 struct ucma_context *ctx = list_first_entry(
17851793 &file->ctx_list, struct ucma_context, list);
17861794
1787− xa_erase(&ctx_table, ctx->id);
1788− __destroy_id(ctx);
1795+ WARN_ON(xa_cmpxchg(&ctx_table, ctx->id, ctx, XA_ZERO_ENTRY,
1796+ GFP_KERNEL) != ctx);
1797+ ucma_destroy_private_ctx(ctx);
17891798 }
17901799 kfree(file);
17911800 return 0;
drivers/infiniband/core/umem.c+1−1
@@ -135,7 +135,7 @@ unsigned long ib_umem_find_best_pgsz(struct ib_umem *umem, · 134 unmodified lines
135135 */
136136 if (mask)
137137 pgsz_bitmap &= GENMASK(count_trailing_zeros(mask), 0);
138− return rounddown_pow_of_two(pgsz_bitmap);
138+ return pgsz_bitmap ? rounddown_pow_of_two(pgsz_bitmap) : 0;
139139 }
140140 EXPORT_SYMBOL(ib_umem_find_best_pgsz);
141141
drivers/infiniband/hw/mlx5/main.c+2−2
@@ -3956,7 +3956,7 @@ static int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev) · 3955 unmodified lines
39563956
39573957 err = set_has_smi_cap(dev);
39583958 if (err)
3959− return err;
3959+ goto err_mp;
39603960
39613961 if (!mlx5_core_mp_enabled(mdev)) {
39623962 for (i = 1; i <= dev->num_ports; i++) {
@@ -4319,7 +4319,7 @@ static int mlx5_ib_stage_bfrag_init(struct mlx5_ib_dev *dev) · 356 unmodified lines
43194319
43204320 err = mlx5_alloc_bfreg(dev->mdev, &dev->fp_bfreg, false, true);
43214321 if (err)
4322− mlx5_free_bfreg(dev->mdev, &dev->fp_bfreg);
4322+ mlx5_free_bfreg(dev->mdev, &dev->bfreg);
43234323
43244324 return err;
43254325 }
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c+1−1
@@ -434,9 +434,9 @@ static void ocrdma_dealloc_ucontext_pd(struct ocrdma_ucontext *uctx) · 433 unmodified lines
434434 pr_err("%s(%d) Freeing in use pdid=0x%x.\n",
435435 __func__, dev->id, pd->id);
436436 }
437− kfree(uctx->cntxt_pd);
438437 uctx->cntxt_pd = NULL;
439438 _ocrdma_dealloc_pd(dev, pd);
439+ kfree(pd);
440440 }
441441
442442 static struct ocrdma_pd *ocrdma_get_ucontext_pd(struct ocrdma_ucontext *uctx)
drivers/infiniband/hw/usnic/usnic_ib_verbs.c+3−0
@@ -214,6 +214,7 @@ find_free_vf_and_create_qp_grp(struct usnic_ib_dev *us_ibdev, · 213 unmodified lines
214214
215215 }
216216 usnic_uiom_free_dev_list(dev_list);
217+ dev_list = NULL;
217218 }
218219
219220 /* Try to find resources on an unused vf */
@@ -239,6 +240,8 @@ find_free_vf_and_create_qp_grp(struct usnic_ib_dev *us_ibdev, · 19 unmodified lines
239240 qp_grp_check:
240241 if (IS_ERR_OR_NULL(qp_grp)) {
241242 usnic_err("Failed to allocate qp_grp\n");
243+ if (usnic_ib_share_vf)
244+ usnic_uiom_free_dev_list(dev_list);
242245 return ERR_PTR(qp_grp ? PTR_ERR(qp_grp) : -ENOMEM);
243246 }
244247 return qp_grp;
drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c+2−0
@@ -325,7 +325,9 @@ static struct arm_smmu_device *qcom_smmu_create(struct arm_smmu_device *smmu, · 324 unmodified lines
325325 }
326326
327327 static const struct of_device_id __maybe_unused qcom_smmu_impl_of_match[] = {
328+ { .compatible = "qcom,msm8998-smmu-v2" },
328329 { .compatible = "qcom,sc7180-smmu-500" },
330+ { .compatible = "qcom,sdm630-smmu-v2" },
329331 { .compatible = "qcom,sdm845-smmu-500" },
330332 { .compatible = "qcom,sm8150-smmu-500" },
331333 { .compatible = "qcom,sm8250-smmu-500" },
drivers/iommu/intel/iommu.c+0−1
@@ -38,7 +38,6 @@ · 37 unmodified lines
3838 #include <linux/dmi.h>
3939 #include <linux/pci-ats.h>
4040 #include <linux/memblock.h>
41−#include <linux/dma-map-ops.h>
4241 #include <linux/dma-direct.h>
4342 #include <linux/crash_dump.h>
4443 #include <linux/numa.h>
drivers/iommu/intel/svm.c+20−2
@@ -118,8 +118,10 @@ void intel_svm_check(struct intel_iommu *iommu) · 117 unmodified lines
118118 iommu->flags |= VTD_FLAG_SVM_CAPABLE;
119119 }
120120
121−static void intel_flush_svm_range_dev (struct intel_svm *svm, struct intel_svm_dev *sdev,
122− unsigned long address, unsigned long pages, int ih)
121+static void __flush_svm_range_dev(struct intel_svm *svm,
122+ struct intel_svm_dev *sdev,
123+ unsigned long address,
124+ unsigned long pages, int ih)
123125 {
124126 struct qi_desc desc;
125127
@@ -170,6 +172,22 @@ static void intel_flush_svm_range_dev (struct intel_svm *svm, struct intel_svm_d · 44 unmodified lines
170172 }
171173 }
172174
175+static void intel_flush_svm_range_dev(struct intel_svm *svm,
176+ struct intel_svm_dev *sdev,
177+ unsigned long address,
178+ unsigned long pages, int ih)
179+{
180+ unsigned long shift = ilog2(__roundup_pow_of_two(pages));
181+ unsigned long align = (1ULL << (VTD_PAGE_SHIFT + shift));
182+ unsigned long start = ALIGN_DOWN(address, align);
183+ unsigned long end = ALIGN(address + (pages << VTD_PAGE_SHIFT), align);
184+
185+ while (start < end) {
186+ __flush_svm_range_dev(svm, sdev, start, align >> VTD_PAGE_SHIFT, ih);
187+ start += align;
188+ }
189+}
190+
173191 static void intel_flush_svm_range(struct intel_svm *svm, unsigned long address,
174192 unsigned long pages, int ih)
175193 {
drivers/md/Kconfig+2−0
@@ -605,6 +605,7 @@ config DM_INTEGRITY · 604 unmodified lines
605605 select BLK_DEV_INTEGRITY
606606 select DM_BUFIO
607607 select CRYPTO
608+ select CRYPTO_SKCIPHER
608609 select ASYNC_XOR
609610 help
610611 This device-mapper target emulates a block device that has
@@ -622,6 +623,7 @@ config DM_ZONED · 11 unmodified lines
622623 tristate "Drive-managed zoned block device target support"
623624 depends on BLK_DEV_DM
624625 depends on BLK_DEV_ZONED
626+ select CRC32
625627 help
626628 This device-mapper target takes a host-managed or host-aware zoned
627629 block device and exposes most of its capacity as a regular block
drivers/md/dm-bufio.c+6−0
@@ -1534,6 +1534,12 @@ sector_t dm_bufio_get_device_size(struct dm_bufio_client *c) · 1533 unmodified lines
15341534 }
15351535 EXPORT_SYMBOL_GPL(dm_bufio_get_device_size);
15361536
1537+struct dm_io_client *dm_bufio_get_dm_io_client(struct dm_bufio_client *c)
1538+{
1539+ return c->dm_io;
1540+}
1541+EXPORT_SYMBOL_GPL(dm_bufio_get_dm_io_client);
1542+
15371543 sector_t dm_bufio_get_block_number(struct dm_buffer *b)
15381544 {
15391545 return b->block;
drivers/md/dm-crypt.c+152−18
@@ -1454,13 +1454,16 @@ static int crypt_convert_block_skcipher(struct crypt_config *cc, · 1453 unmodified lines
14541454 static void kcryptd_async_done(struct crypto_async_request *async_req,
14551455 int error);
14561456
1457−static void crypt_alloc_req_skcipher(struct crypt_config *cc,
1457+static int crypt_alloc_req_skcipher(struct crypt_config *cc,
14581458 struct convert_context *ctx)
14591459 {
14601460 unsigned key_index = ctx->cc_sector & (cc->tfms_count - 1);
14611461
1462− if (!ctx->r.req)
1463− ctx->r.req = mempool_alloc(&cc->req_pool, GFP_NOIO);
1462+ if (!ctx->r.req) {
1463+ ctx->r.req = mempool_alloc(&cc->req_pool, in_interrupt() ? GFP_ATOMIC : GFP_NOIO);
1464+ if (!ctx->r.req)
1465+ return -ENOMEM;
1466+ }
14641467
14651468 skcipher_request_set_tfm(ctx->r.req, cc->cipher_tfm.tfms[key_index]);
14661469
@@ -1471,13 +1474,18 @@ static void crypt_alloc_req_skcipher(struct crypt_config *cc, · 4 unmodified lines
14711474 skcipher_request_set_callback(ctx->r.req,
14721475 CRYPTO_TFM_REQ_MAY_BACKLOG,
14731476 kcryptd_async_done, dmreq_of_req(cc, ctx->r.req));
1477+
1478+ return 0;
14741479 }
14751480
1476−static void crypt_alloc_req_aead(struct crypt_config *cc,
1481+static int crypt_alloc_req_aead(struct crypt_config *cc,
14771482 struct convert_context *ctx)
14781483 {
1479− if (!ctx->r.req_aead)
1480− ctx->r.req_aead = mempool_alloc(&cc->req_pool, GFP_NOIO);
1484+ if (!ctx->r.req) {
1485+ ctx->r.req = mempool_alloc(&cc->req_pool, in_interrupt() ? GFP_ATOMIC : GFP_NOIO);
1486+ if (!ctx->r.req)
1487+ return -ENOMEM;
1488+ }
14811489
14821490 aead_request_set_tfm(ctx->r.req_aead, cc->cipher_tfm.tfms_aead[0]);
14831491
@@ -1488,15 +1496,17 @@ static void crypt_alloc_req_aead(struct crypt_config *cc, · 4 unmodified lines
14881496 aead_request_set_callback(ctx->r.req_aead,
14891497 CRYPTO_TFM_REQ_MAY_BACKLOG,
14901498 kcryptd_async_done, dmreq_of_req(cc, ctx->r.req_aead));
1499+
1500+ return 0;
14911501 }
14921502
1493−static void crypt_alloc_req(struct crypt_config *cc,
1503+static int crypt_alloc_req(struct crypt_config *cc,
14941504 struct convert_context *ctx)
14951505 {
14961506 if (crypt_integrity_aead(cc))
1497− crypt_alloc_req_aead(cc, ctx);
1507+ return crypt_alloc_req_aead(cc, ctx);
14981508 else
1499− crypt_alloc_req_skcipher(cc, ctx);
1509+ return crypt_alloc_req_skcipher(cc, ctx);
15001510 }
15011511
15021512 static void crypt_free_req_skcipher(struct crypt_config *cc,
@@ -1529,17 +1539,28 @@ static void crypt_free_req(struct crypt_config *cc, void *req, struct bio *base_ · 26 unmodified lines
15291539 * Encrypt / decrypt data from one bio to another one (can be the same one)
15301540 */
15311541 static blk_status_t crypt_convert(struct crypt_config *cc,
1532− struct convert_context *ctx, bool atomic)
1542+ struct convert_context *ctx, bool atomic, bool reset_pending)
15331543 {
15341544 unsigned int tag_offset = 0;
15351545 unsigned int sector_step = cc->sector_size >> SECTOR_SHIFT;
15361546 int r;
15371547
1538− atomic_set(&ctx->cc_pending, 1);
1548+ /*
1549+ * if reset_pending is set we are dealing with the bio for the first time,
1550+ * else we're continuing to work on the previous bio, so don't mess with
1551+ * the cc_pending counter
1552+ */
1553+ if (reset_pending)
1554+ atomic_set(&ctx->cc_pending, 1);
15391555
15401556 while (ctx->iter_in.bi_size && ctx->iter_out.bi_size) {
15411557
1542− crypt_alloc_req(cc, ctx);
1558+ r = crypt_alloc_req(cc, ctx);
1559+ if (r) {
1560+ complete(&ctx->restart);
1561+ return BLK_STS_DEV_RESOURCE;
1562+ }
1563+
15431564 atomic_inc(&ctx->cc_pending);
15441565
15451566 if (crypt_integrity_aead(cc))
@@ -1553,7 +1574,25 @@ static blk_status_t crypt_convert(struct crypt_config *cc, · 7 unmodified lines
15531574 * but the driver request queue is full, let's wait.
15541575 */
15551576 case -EBUSY:
1556− wait_for_completion(&ctx->restart);
1577+ if (in_interrupt()) {
1578+ if (try_wait_for_completion(&ctx->restart)) {
1579+ /*
1580+ * we don't have to block to wait for completion,
1581+ * so proceed
1582+ */
1583+ } else {
1584+ /*
1585+ * we can't wait for completion without blocking
1586+ * exit and continue processing in a workqueue
1587+ */
1588+ ctx->r.req = NULL;
1589+ ctx->cc_sector += sector_step;
1590+ tag_offset++;
1591+ return BLK_STS_DEV_RESOURCE;
1592+ }
1593+ } else {
1594+ wait_for_completion(&ctx->restart);
1595+ }
15571596 reinit_completion(&ctx->restart);
15581597 fallthrough;
15591598 /*
@@ -1691,6 +1730,12 @@ static void crypt_inc_pending(struct dm_crypt_io *io) · 131 unmodified lines
16911730 atomic_inc(&io->io_pending);
16921731 }
16931732
1733+static void kcryptd_io_bio_endio(struct work_struct *work)
1734+{
1735+ struct dm_crypt_io *io = container_of(work, struct dm_crypt_io, work);
1736+ bio_endio(io->base_bio);
1737+}
1738+
16941739 /*
16951740 * One of the bios was finished. Check for completion of
16961741 * the whole request and correctly clean up the buffer.
@@ -1713,7 +1758,23 @@ static void crypt_dec_pending(struct dm_crypt_io *io) · 16 unmodified lines
17131758 kfree(io->integrity_metadata);
17141759
17151760 base_bio->bi_status = error;
1716− bio_endio(base_bio);
1761+
1762+ /*
1763+ * If we are running this function from our tasklet,
1764+ * we can't call bio_endio() here, because it will call
1765+ * clone_endio() from dm.c, which in turn will
1766+ * free the current struct dm_crypt_io structure with
1767+ * our tasklet. In this case we need to delay bio_endio()
1768+ * execution to after the tasklet is done and dequeued.
1769+ */
1770+ if (tasklet_trylock(&io->tasklet)) {
1771+ tasklet_unlock(&io->tasklet);
1772+ bio_endio(base_bio);
1773+ return;
1774+ }
1775+
1776+ INIT_WORK(&io->work, kcryptd_io_bio_endio);
1777+ queue_work(cc->io_queue, &io->work);
17171778 }
17181779
17191780 /*
@@ -1945,6 +2006,37 @@ static bool kcryptd_crypt_write_inline(struct crypt_config *cc, · 225 unmodified lines
19452006 }
19462007 }
19472008
2009+static void kcryptd_crypt_write_continue(struct work_struct *work)
2010+{
2011+ struct dm_crypt_io *io = container_of(work, struct dm_crypt_io, work);
2012+ struct crypt_config *cc = io->cc;
2013+ struct convert_context *ctx = &io->ctx;
2014+ int crypt_finished;
2015+ sector_t sector = io->sector;
2016+ blk_status_t r;
2017+
2018+ wait_for_completion(&ctx->restart);
2019+ reinit_completion(&ctx->restart);
2020+
2021+ r = crypt_convert(cc, &io->ctx, true, false);
2022+ if (r)
2023+ io->error = r;
2024+ crypt_finished = atomic_dec_and_test(&ctx->cc_pending);
2025+ if (!crypt_finished && kcryptd_crypt_write_inline(cc, ctx)) {
2026+ /* Wait for completion signaled by kcryptd_async_done() */
2027+ wait_for_completion(&ctx->restart);
2028+ crypt_finished = 1;
2029+ }
2030+
2031+ /* Encryption was already finished, submit io now */
2032+ if (crypt_finished) {
2033+ kcryptd_crypt_write_io_submit(io, 0);
2034+ io->sector = sector;
2035+ }
2036+
2037+ crypt_dec_pending(io);
2038+}
2039+
19482040 static void kcryptd_crypt_write_convert(struct dm_crypt_io *io)
19492041 {
19502042 struct crypt_config *cc = io->cc;
@@ -1973,7 +2065,17 @@ static void kcryptd_crypt_write_convert(struct dm_crypt_io *io) · 22 unmodified lines
19732065
19742066 crypt_inc_pending(io);
19752067 r = crypt_convert(cc, ctx,
1976− test_bit(DM_CRYPT_NO_WRITE_WORKQUEUE, &cc->flags));
2068+ test_bit(DM_CRYPT_NO_WRITE_WORKQUEUE, &cc->flags), true);
2069+ /*
2070+ * Crypto API backlogged the request, because its queue was full
2071+ * and we're in softirq context, so continue from a workqueue
2072+ * (TODO: is it actually possible to be in softirq in the write path?)
2073+ */
2074+ if (r == BLK_STS_DEV_RESOURCE) {
2075+ INIT_WORK(&io->work, kcryptd_crypt_write_continue);
2076+ queue_work(cc->crypt_queue, &io->work);
2077+ return;
2078+ }
19772079 if (r)
19782080 io->error = r;
19792081 crypt_finished = atomic_dec_and_test(&ctx->cc_pending);
@@ -1998,6 +2100,25 @@ static void kcryptd_crypt_read_done(struct dm_crypt_io *io) · 18 unmodified lines
19982100 crypt_dec_pending(io);
19992101 }
20002102
2103+static void kcryptd_crypt_read_continue(struct work_struct *work)
2104+{
2105+ struct dm_crypt_io *io = container_of(work, struct dm_crypt_io, work);
2106+ struct crypt_config *cc = io->cc;
2107+ blk_status_t r;
2108+
2109+ wait_for_completion(&io->ctx.restart);
2110+ reinit_completion(&io->ctx.restart);
2111+
2112+ r = crypt_convert(cc, &io->ctx, true, false);
2113+ if (r)
2114+ io->error = r;
2115+
2116+ if (atomic_dec_and_test(&io->ctx.cc_pending))
2117+ kcryptd_crypt_read_done(io);
2118+
2119+ crypt_dec_pending(io);
2120+}
2121+
20012122 static void kcryptd_crypt_read_convert(struct dm_crypt_io *io)
20022123 {
20032124 struct crypt_config *cc = io->cc;
@@ -2009,7 +2130,16 @@ static void kcryptd_crypt_read_convert(struct dm_crypt_io *io) · 5 unmodified lines
20092130 io->sector);
20102131
20112132 r = crypt_convert(cc, &io->ctx,
2012− test_bit(DM_CRYPT_NO_READ_WORKQUEUE, &cc->flags));
2133+ test_bit(DM_CRYPT_NO_READ_WORKQUEUE, &cc->flags), true);
2134+ /*
2135+ * Crypto API backlogged the request, because its queue was full
2136+ * and we're in softirq context, so continue from a workqueue
2137+ */
2138+ if (r == BLK_STS_DEV_RESOURCE) {
2139+ INIT_WORK(&io->work, kcryptd_crypt_read_continue);
2140+ queue_work(cc->crypt_queue, &io->work);
2141+ return;
2142+ }
20132143 if (r)
20142144 io->error = r;
20152145
@@ -2091,8 +2221,12 @@ static void kcryptd_queue_crypt(struct dm_crypt_io *io) · 75 unmodified lines
20912221
20922222 if ((bio_data_dir(io->base_bio) == READ && test_bit(DM_CRYPT_NO_READ_WORKQUEUE, &cc->flags)) ||
20932223 (bio_data_dir(io->base_bio) == WRITE && test_bit(DM_CRYPT_NO_WRITE_WORKQUEUE, &cc->flags))) {
2094− if (in_irq()) {
2095− /* Crypto API's "skcipher_walk_first() refuses to work in hard IRQ context */
2224+ /*
2225+ * in_irq(): Crypto API's skcipher_walk_first() refuses to work in hard IRQ context.
2226+ * irqs_disabled(): the kernel may run some IO completion from the idle thread, but
2227+ * it is being executed with irqs disabled.
2228+ */
2229+ if (in_irq() || irqs_disabled()) {
20962230 tasklet_init(&io->tasklet, kcryptd_crypt_tasklet, (unsigned long)&io->work);
20972231 tasklet_schedule(&io->tasklet);
20982232 return;
drivers/md/dm-integrity.c+50−12
@@ -1379,12 +1379,52 @@ thorough_test: · 1378 unmodified lines
13791379 #undef MAY_BE_HASH
13801380 }
13811381
1382−static void dm_integrity_flush_buffers(struct dm_integrity_c *ic)
1382+struct flush_request {
1383+ struct dm_io_request io_req;
1384+ struct dm_io_region io_reg;
1385+ struct dm_integrity_c *ic;
1386+ struct completion comp;
1387+};
1388+
1389+static void flush_notify(unsigned long error, void *fr_)
1390+{
1391+ struct flush_request *fr = fr_;
1392+ if (unlikely(error != 0))
1393+ dm_integrity_io_error(fr->ic, "flusing disk cache", -EIO);
1394+ complete(&fr->comp);
1395+}
1396+
1397+static void dm_integrity_flush_buffers(struct dm_integrity_c *ic, bool flush_data)
13831398 {
13841399 int r;
1400+
1401+ struct flush_request fr;
1402+
1403+ if (!ic->meta_dev)
1404+ flush_data = false;
1405+ if (flush_data) {
1406+ fr.io_req.bi_op = REQ_OP_WRITE,
1407+ fr.io_req.bi_op_flags = REQ_PREFLUSH | REQ_SYNC,
1408+ fr.io_req.mem.type = DM_IO_KMEM,
1409+ fr.io_req.mem.ptr.addr = NULL,
1410+ fr.io_req.notify.fn = flush_notify,
1411+ fr.io_req.notify.context = &fr;
1412+ fr.io_req.client = dm_bufio_get_dm_io_client(ic->bufio),
1413+ fr.io_reg.bdev = ic->dev->bdev,
1414+ fr.io_reg.sector = 0,
1415+ fr.io_reg.count = 0,
1416+ fr.ic = ic;
1417+ init_completion(&fr.comp);
1418+ r = dm_io(&fr.io_req, 1, &fr.io_reg, NULL);
1419+ BUG_ON(r);
1420+ }
1421+
13851422 r = dm_bufio_write_dirty_buffers(ic->bufio);
13861423 if (unlikely(r))
13871424 dm_integrity_io_error(ic, "writing tags", r);
1425+
1426+ if (flush_data)
1427+ wait_for_completion(&fr.comp);
13881428 }
13891429
13901430 static void sleep_on_endio_wait(struct dm_integrity_c *ic)
@@ -2110,7 +2150,7 @@ offload_to_thread: · 719 unmodified lines
21102150
21112151 if (unlikely(dio->op == REQ_OP_DISCARD) && likely(ic->mode != 'D')) {
21122152 integrity_metadata(&dio->work);
2113− dm_integrity_flush_buffers(ic);
2153+ dm_integrity_flush_buffers(ic, false);
21142154
21152155 dio->in_flight = (atomic_t)ATOMIC_INIT(1);
21162156 dio->completion = NULL;
@@ -2195,7 +2235,7 @@ static void integrity_commit(struct work_struct *w) · 78 unmodified lines
21952235 flushes = bio_list_get(&ic->flush_bio_list);
21962236 if (unlikely(ic->mode != 'J')) {
21972237 spin_unlock_irq(&ic->endio_wait.lock);
2198− dm_integrity_flush_buffers(ic);
2238+ dm_integrity_flush_buffers(ic, true);
21992239 goto release_flush_bios;
22002240 }
22012241
@@ -2409,7 +2449,7 @@ skip_io: · 207 unmodified lines
24092449 complete_journal_op(&comp);
24102450 wait_for_completion_io(&comp.comp);
24112451
2412− dm_integrity_flush_buffers(ic);
2452+ dm_integrity_flush_buffers(ic, true);
24132453 }
24142454
24152455 static void integrity_writer(struct work_struct *w)
@@ -2451,7 +2491,7 @@ static void recalc_write_super(struct dm_integrity_c *ic) · 35 unmodified lines
24512491 {
24522492 int r;
24532493
2454− dm_integrity_flush_buffers(ic);
2494+ dm_integrity_flush_buffers(ic, false);
24552495 if (dm_integrity_failed(ic))
24562496 return;
24572497
@@ -2654,7 +2694,7 @@ static void bitmap_flush_work(struct work_struct *work) · 196 unmodified lines
26542694 unsigned long limit;
26552695 struct bio *bio;
26562696
2657− dm_integrity_flush_buffers(ic);
2697+ dm_integrity_flush_buffers(ic, false);
26582698
26592699 range.logical_sector = 0;
26602700 range.n_sectors = ic->provided_data_sectors;
@@ -2663,9 +2703,7 @@ static void bitmap_flush_work(struct work_struct *work) · 2 unmodified lines
26632703 add_new_range_and_wait(ic, &range);
26642704 spin_unlock_irq(&ic->endio_wait.lock);
26652705
2666− dm_integrity_flush_buffers(ic);
2667− if (ic->meta_dev)
2668− blkdev_issue_flush(ic->dev->bdev, GFP_NOIO);
2706+ dm_integrity_flush_buffers(ic, true);
26692707
26702708 limit = ic->provided_data_sectors;
26712709 if (ic->sb->flags & cpu_to_le32(SB_FLAG_RECALCULATING)) {
@@ -2934,11 +2972,11 @@ static void dm_integrity_postsuspend(struct dm_target *ti) · 262 unmodified lines
29342972 if (ic->meta_dev)
29352973 queue_work(ic->writer_wq, &ic->writer_work);
29362974 drain_workqueue(ic->writer_wq);
2937− dm_integrity_flush_buffers(ic);
2975+ dm_integrity_flush_buffers(ic, true);
29382976 }
29392977
29402978 if (ic->mode == 'B') {
2941− dm_integrity_flush_buffers(ic);
2979+ dm_integrity_flush_buffers(ic, true);
29422980 #if 1
29432981 /* set to 0 to test bitmap replay code */
29442982 init_journal(ic, 0, ic->journal_sections, 0);
@@ -3754,7 +3792,7 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv) · 809 unmodified lines
37543792 unsigned extra_args;
37553793 struct dm_arg_set as;
37563794 static const struct dm_arg _args[] = {
3757− {0, 9, "Invalid number of feature args"},
3795+ {0, 15, "Invalid number of feature args"},
37583796 };
37593797 unsigned journal_sectors, interleave_sectors, buffer_sectors, journal_watermark, sync_msec;
37603798 bool should_write_sb;
drivers/md/dm-raid.c+3−3
@@ -3729,10 +3729,10 @@ static void raid_io_hints(struct dm_target *ti, struct queue_limits *limits) · 3728 unmodified lines
37293729 blk_limits_io_opt(limits, chunk_size_bytes * mddev_data_stripes(rs));
37303730
37313731 /*
3732− * RAID1 and RAID10 personalities require bio splitting,
3733− * RAID0/4/5/6 don't and process large discard bios properly.
3732+ * RAID0 and RAID10 personalities require bio splitting,
3733+ * RAID1/4/5/6 don't and process large discard bios properly.
37343734 */
3735− if (rs_is_raid1(rs) || rs_is_raid10(rs)) {
3735+ if (rs_is_raid0(rs) || rs_is_raid10(rs)) {
37363736 limits->discard_granularity = chunk_size_bytes;
37373737 limits->max_discard_sectors = rs->md.chunk_sectors;
37383738 }
drivers/md/dm-snap.c+24−0
@@ -141,6 +141,11 @@ struct dm_snapshot { · 140 unmodified lines
141141 * for them to be committed.
142142 */
143143 struct bio_list bios_queued_during_merge;
144+
145+ /*
146+ * Flush data after merge.
147+ */
148+ struct bio flush_bio;
144149 };
145150
146151 /*
@@ -1121,6 +1126,17 @@ shut: · 974 unmodified lines
11211126
11221127 static void error_bios(struct bio *bio);
11231128
1129+static int flush_data(struct dm_snapshot *s)
1130+{
1131+ struct bio *flush_bio = &s->flush_bio;
1132+
1133+ bio_reset(flush_bio);
1134+ bio_set_dev(flush_bio, s->origin->bdev);
1135+ flush_bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
1136+
1137+ return submit_bio_wait(flush_bio);
1138+}
1139+
11241140 static void merge_callback(int read_err, unsigned long write_err, void *context)
11251141 {
11261142 struct dm_snapshot *s = context;
@@ -1134,6 +1150,11 @@ static void merge_callback(int read_err, unsigned long write_err, void *context) · 7 unmodified lines
11341150 goto shut;
11351151 }
11361152
1153+ if (flush_data(s) < 0) {
1154+ DMERR("Flush after merge failed: shutting down merge");
1155+ goto shut;
1156+ }
1157+
11371158 if (s->store->type->commit_merge(s->store,
11381159 s->num_merging_chunks) < 0) {
11391160 DMERR("Write error in exception store: shutting down merge");
@@ -1318,6 +1339,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) · 178 unmodified lines
13181339 s->first_merging_chunk = 0;
13191340 s->num_merging_chunks = 0;
13201341 bio_list_init(&s->bios_queued_during_merge);
1342+ bio_init(&s->flush_bio, NULL, 0);
13211343
13221344 /* Allocate hash table for COW data */
13231345 if (init_hash_tables(s)) {
@@ -1504,6 +1526,8 @@ static void snapshot_dtr(struct dm_target *ti) · 180 unmodified lines
15041526
15051527 dm_exception_store_destroy(s->store);
15061528
1529+ bio_uninit(&s->flush_bio);
1530+
15071531 dm_put_device(ti, s->cow);
15081532
15091533 dm_put_device(ti, s->origin);
drivers/md/dm.c+1−1
@@ -562,7 +562,7 @@ static int dm_blk_ioctl(struct block_device *bdev, fmode_t mode, · 561 unmodified lines
562562 * subset of the parent bdev; require extra privileges.
563563 */
564564 if (!capable(CAP_SYS_RAWIO)) {
565− DMWARN_LIMIT(
565+ DMDEBUG_LIMIT(
566566 "%s: sending ioctl %x to DM device without required privilege.",
567567 current->comm, cmd);
568568 r = -ENOIOCTLCMD;
drivers/net/can/dev/dev.c+2−2
@@ -153,11 +153,11 @@ static void can_restart(struct net_device *dev) · 152 unmodified lines
153153
154154 cf->can_id |= CAN_ERR_RESTARTED;
155155
156− netif_rx_ni(skb);
157−
158156 stats->rx_packets++;
159157 stats->rx_bytes += cf->len;
160158
159+ netif_rx_ni(skb);
160+
161161 restart:
162162 netdev_dbg(dev, "restarted\n");
163163 priv->can_stats.restarts++;
drivers/net/can/usb/peak_usb/pcan_usb_fd.c+4−4
@@ -514,11 +514,11 @@ static int pcan_usb_fd_decode_canmsg(struct pcan_usb_fd_if *usb_if, · 513 unmodified lines
514514 else
515515 memcpy(cfd->data, rm->d, cfd->len);
516516
517− peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(rm->ts_low));
518−
519517 netdev->stats.rx_packets++;
520518 netdev->stats.rx_bytes += cfd->len;
521519
520+ peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(rm->ts_low));
521+
522522 return 0;
523523 }
524524
@@ -580,11 +580,11 @@ static int pcan_usb_fd_decode_status(struct pcan_usb_fd_if *usb_if, · 55 unmodified lines
580580 if (!skb)
581581 return -ENOMEM;
582582
583− peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(sm->ts_low));
584−
585583 netdev->stats.rx_packets++;
586584 netdev->stats.rx_bytes += cf->len;
587585
586+ peak_usb_netif_rx(skb, &usb_if->time_ref, le32_to_cpu(sm->ts_low));
587+
588588 return 0;
589589 }
590590
drivers/net/can/vxcan.c+4−2
@@ -39,6 +39,7 @@ static netdev_tx_t vxcan_xmit(struct sk_buff *skb, struct net_device *dev) · 38 unmodified lines
3939 struct net_device *peer;
4040 struct canfd_frame *cfd = (struct canfd_frame *)skb->data;
4141 struct net_device_stats *peerstats, *srcstats = &dev->stats;
42+ u8 len;
4243
4344 if (can_dropped_invalid_skb(dev, skb))
4445 return NETDEV_TX_OK;
@@ -61,12 +62,13 @@ static netdev_tx_t vxcan_xmit(struct sk_buff *skb, struct net_device *dev) · 16 unmodified lines
6162 skb->dev = peer;
6263 skb->ip_summed = CHECKSUM_UNNECESSARY;
6364
65+ len = cfd->len;
6466 if (netif_rx_ni(skb) == NET_RX_SUCCESS) {
6567 srcstats->tx_packets++;
66− srcstats->tx_bytes += cfd->len;
68+ srcstats->tx_bytes += len;
6769 peerstats = &peer->stats;
6870 peerstats->rx_packets++;
69− peerstats->rx_bytes += cfd->len;
71+ peerstats->rx_bytes += len;
7072 }
7173
7274 out_unlock:
drivers/net/dsa/b53/b53_common.c+1−1
@@ -1400,7 +1400,7 @@ static int b53_vlan_prepare(struct dsa_switch *ds, int port, · 1399 unmodified lines
14001400 !(vlan->flags & BRIDGE_VLAN_INFO_UNTAGGED))
14011401 return -EINVAL;
14021402
1403− if (vlan->vid > dev->num_vlans)
1403+ if (vlan->vid >= dev->num_vlans)
14041404 return -ERANGE;
14051405
14061406 b53_enable_vlan(dev, true, ds->vlan_filtering);
drivers/net/dsa/mv88e6xxx/global1_vtu.c+4−0
@@ -351,6 +351,10 @@ int mv88e6250_g1_vtu_getnext(struct mv88e6xxx_chip *chip, · 350 unmodified lines
351351 if (err)
352352 return err;
353353
354+ err = mv88e6185_g1_stu_data_read(chip, entry);
355+ if (err)
356+ return err;
357+
354358 /* VTU DBNum[3:0] are located in VTU Operation 3:0
355359 * VTU DBNum[5:4] are located in VTU Operation 9:8
356360 */
drivers/net/ethernet/broadcom/bcmsysport.c+4−2
@@ -2495,8 +2495,10 @@ static int bcm_sysport_probe(struct platform_device *pdev) · 2494 unmodified lines
24952495 priv = netdev_priv(dev);
24962496
24972497 priv->clk = devm_clk_get_optional(&pdev->dev, "sw_sysport");
2498− if (IS_ERR(priv->clk))
2499− return PTR_ERR(priv->clk);
2498+ if (IS_ERR(priv->clk)) {
2499+ ret = PTR_ERR(priv->clk);
2500+ goto err_free_netdev;
2501+ }
25002502
25012503 /* Allocate number of TX rings */
25022504 priv->tx_rings = devm_kcalloc(&pdev->dev, txq,
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c+6−0
@@ -469,6 +469,9 @@ int rvu_mbox_handler_cgx_mac_addr_set(struct rvu *rvu, · 468 unmodified lines
469469 int pf = rvu_get_pf(req->hdr.pcifunc);
470470 u8 cgx_id, lmac_id;
471471
472+ if (!is_cgx_config_permitted(rvu, req->hdr.pcifunc))
473+ return -EPERM;
474+
472475 rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
473476
474477 cgx_lmac_addr_set(cgx_id, lmac_id, req->mac_addr);
@@ -485,6 +488,9 @@ int rvu_mbox_handler_cgx_mac_addr_get(struct rvu *rvu, · 10 unmodified lines
485488 int rc = 0, i;
486489 u64 cfg;
487490
491+ if (!is_cgx_config_permitted(rvu, req->hdr.pcifunc))
492+ return -EPERM;
493+
488494 rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
489495
490496 rsp->hdr.rc = rc;
drivers/net/ethernet/mscc/ocelot.c+18−5
@@ -60,14 +60,27 @@ int ocelot_mact_learn(struct ocelot *ocelot, int port, · 59 unmodified lines
6060 const unsigned char mac[ETH_ALEN],
6161 unsigned int vid, enum macaccess_entry_type type)
6262 {
63+ u32 cmd = ANA_TABLES_MACACCESS_VALID |
64+ ANA_TABLES_MACACCESS_DEST_IDX(port) |
65+ ANA_TABLES_MACACCESS_ENTRYTYPE(type) |
66+ ANA_TABLES_MACACCESS_MAC_TABLE_CMD(MACACCESS_CMD_LEARN);
67+ unsigned int mc_ports;
68+
69+ /* Set MAC_CPU_COPY if the CPU port is used by a multicast entry */
70+ if (type == ENTRYTYPE_MACv4)
71+ mc_ports = (mac[1] << 8) | mac[2];
72+ else if (type == ENTRYTYPE_MACv6)
73+ mc_ports = (mac[0] << 8) | mac[1];
74+ else
75+ mc_ports = 0;
76+
77+ if (mc_ports & BIT(ocelot->num_phys_ports))
78+ cmd |= ANA_TABLES_MACACCESS_MAC_CPU_COPY;
79+
6380 ocelot_mact_select(ocelot, mac, vid);
6481
6582 /* Issue a write command */
66− ocelot_write(ocelot, ANA_TABLES_MACACCESS_VALID |
67− ANA_TABLES_MACACCESS_DEST_IDX(port) |
68− ANA_TABLES_MACACCESS_ENTRYTYPE(type) |
69− ANA_TABLES_MACACCESS_MAC_TABLE_CMD(MACACCESS_CMD_LEARN),
70− ANA_TABLES_MACACCESS);
83+ ocelot_write(ocelot, cmd, ANA_TABLES_MACACCESS);
7184
7285 return ocelot_mact_wait_for_completion(ocelot);
7386 }
drivers/net/ethernet/mscc/ocelot_net.c+1−3
@@ -1153,10 +1153,8 @@ static int ocelot_netdevice_event(struct notifier_block *unused, · 1152 unmodified lines
11531153 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
11541154 int ret = 0;
11551155
1156− if (!ocelot_netdevice_dev_check(dev))
1157− return 0;
1158−
11591156 if (event == NETDEV_PRECHANGEUPPER &&
1157+ ocelot_netdevice_dev_check(dev) &&
11601158 netif_is_lag_master(info->upper_dev)) {
11611159 struct netdev_lag_upper_info *lag_upper_info = info->upper_info;
11621160 struct netlink_ext_ack *extack;
drivers/net/ethernet/renesas/sh_eth.c+28−2
@@ -2606,10 +2606,10 @@ static int sh_eth_close(struct net_device *ndev) · 2605 unmodified lines
26062606 /* Free all the skbuffs in the Rx queue and the DMA buffer. */
26072607 sh_eth_ring_free(ndev);
26082608
2609− pm_runtime_put_sync(&mdp->pdev->dev);
2610−
26112609 mdp->is_opened = 0;
26122610
2611+ pm_runtime_put(&mdp->pdev->dev);
2612+
26132613 return 0;
26142614 }
26152615
@@ -3034,6 +3034,28 @@ static int sh_mdio_release(struct sh_eth_private *mdp) · 418 unmodified lines
30343034 return 0;
30353035 }
30363036
3037+static int sh_mdiobb_read(struct mii_bus *bus, int phy, int reg)
3038+{
3039+ int res;
3040+
3041+ pm_runtime_get_sync(bus->parent);
3042+ res = mdiobb_read(bus, phy, reg);
3043+ pm_runtime_put(bus->parent);
3044+
3045+ return res;
3046+}
3047+
3048+static int sh_mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val)
3049+{
3050+ int res;
3051+
3052+ pm_runtime_get_sync(bus->parent);
3053+ res = mdiobb_write(bus, phy, reg, val);
3054+ pm_runtime_put(bus->parent);
3055+
3056+ return res;
3057+}
3058+
30373059 /* MDIO bus init function */
30383060 static int sh_mdio_init(struct sh_eth_private *mdp,
30393061 struct sh_eth_plat_data *pd)
@@ -3058,6 +3080,10 @@ static int sh_mdio_init(struct sh_eth_private *mdp, · 18 unmodified lines
30583080 if (!mdp->mii_bus)
30593081 return -ENOMEM;
30603082
3083+ /* Wrap accessors with Runtime PM-aware ops */
3084+ mdp->mii_bus->read = sh_mdiobb_read;
3085+ mdp->mii_bus->write = sh_mdiobb_write;
3086+
30613087 /* Hook up MII support for ethtool */
30623088 mdp->mii_bus->name = "sh_mii";
30633089 mdp->mii_bus->parent = dev;
drivers/net/mdio/mdio-bitbang.c+4−2
@@ -149,7 +149,7 @@ static int mdiobb_cmd_addr(struct mdiobb_ctrl *ctrl, int phy, u32 addr) · 148 unmodified lines
149149 return dev_addr;
150150 }
151151
152−static int mdiobb_read(struct mii_bus *bus, int phy, int reg)
152+int mdiobb_read(struct mii_bus *bus, int phy, int reg)
153153 {
154154 struct mdiobb_ctrl *ctrl = bus->priv;
155155 int ret, i;
@@ -180,8 +180,9 @@ static int mdiobb_read(struct mii_bus *bus, int phy, int reg) · 24 unmodified lines
180180 mdiobb_get_bit(ctrl);
181181 return ret;
182182 }
183+EXPORT_SYMBOL(mdiobb_read);
183184
184−static int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val)
185+int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val)
185186 {
186187 struct mdiobb_ctrl *ctrl = bus->priv;
187188
@@ -201,6 +202,7 @@ static int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val) · 13 unmodified lines
201202 mdiobb_get_bit(ctrl);
202203 return 0;
203204 }
205+EXPORT_SYMBOL(mdiobb_write);
204206
205207 struct mii_bus *alloc_mdio_bitbang(struct mdiobb_ctrl *ctrl)
206208 {
drivers/net/usb/cdc_ncm.c+11−1
@@ -1827,6 +1827,15 @@ cdc_ncm_speed_change(struct usbnet *dev, · 1826 unmodified lines
18271827 uint32_t rx_speed = le32_to_cpu(data->DLBitRRate);
18281828 uint32_t tx_speed = le32_to_cpu(data->ULBitRate);
18291829
1830+ /* if the speed hasn't changed, don't report it.
1831+ * RTL8156 shipped before 2021 sends notification about every 32ms.
1832+ */
1833+ if (dev->rx_speed == rx_speed && dev->tx_speed == tx_speed)
1834+ return;
1835+
1836+ dev->rx_speed = rx_speed;
1837+ dev->tx_speed = tx_speed;
1838+
18301839 /*
18311840 * Currently the USB-NET API does not support reporting the actual
18321841 * device speed. Do print it instead.
@@ -1867,7 +1876,8 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb) · 34 unmodified lines
18671876 * USB_CDC_NOTIFY_NETWORK_CONNECTION notification shall be
18681877 * sent by device after USB_CDC_NOTIFY_SPEED_CHANGE.
18691878 */
1870− usbnet_link_change(dev, !!event->wValue, 0);
1879+ if (netif_carrier_ok(dev->net) != !!event->wValue)
1880+ usbnet_link_change(dev, !!event->wValue, 0);
18711881 break;
18721882
18731883 case USB_CDC_NOTIFY_SPEED_CHANGE:
drivers/nvme/host/core.c+8−3
@@ -2856,6 +2856,11 @@ static const struct attribute_group *nvme_subsys_attrs_groups[] = { · 2855 unmodified lines
28562856 NULL,
28572857 };
28582858
2859+static inline bool nvme_discovery_ctrl(struct nvme_ctrl *ctrl)
2860+{
2861+ return ctrl->opts && ctrl->opts->discovery_nqn;
2862+}
2863+
28592864 static bool nvme_validate_cntlid(struct nvme_subsystem *subsys,
28602865 struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
28612866 {
@@ -2875,7 +2880,7 @@ static bool nvme_validate_cntlid(struct nvme_subsystem *subsys, · 13 unmodified lines
28752880 }
28762881
28772882 if ((id->cmic & NVME_CTRL_CMIC_MULTI_CTRL) ||
2878− (ctrl->opts && ctrl->opts->discovery_nqn))
2883+ nvme_discovery_ctrl(ctrl))
28792884 continue;
28802885
28812886 dev_err(ctrl->device,
@@ -3144,7 +3149,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) · 262 unmodified lines
31443149 goto out_free;
31453150 }
31463151
3147− if (!ctrl->opts->discovery_nqn && !ctrl->kas) {
3152+ if (!nvme_discovery_ctrl(ctrl) && !ctrl->kas) {
31483153 dev_err(ctrl->device,
31493154 "keep-alive support is mandatory for fabrics\n");
31503155 ret = -EINVAL;
@@ -3184,7 +3189,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) · 33 unmodified lines
31843189 if (ret < 0)
31853190 return ret;
31863191
3187− if (!ctrl->identified) {
3192+ if (!ctrl->identified && !nvme_discovery_ctrl(ctrl)) {
31883193 ret = nvme_hwmon_init(ctrl);
31893194 if (ret < 0)
31903195 return ret;
drivers/nvme/host/tcp.c+2−2
@@ -201,7 +201,7 @@ static inline size_t nvme_tcp_req_cur_offset(struct nvme_tcp_request *req) · 200 unmodified lines
201201
202202 static inline size_t nvme_tcp_req_cur_length(struct nvme_tcp_request *req)
203203 {
204− return min_t(size_t, req->iter.bvec->bv_len - req->iter.iov_offset,
204+ return min_t(size_t, iov_iter_single_seg_count(&req->iter),
205205 req->pdu_len - req->pdu_sent);
206206 }
207207
@@ -286,7 +286,7 @@ static inline void nvme_tcp_queue_request(struct nvme_tcp_request *req, · 78 unmodified lines
286286 * directly, otherwise queue io_work. Also, only do that if we
287287 * are on the same cpu, so we don't introduce contention.
288288 */
289− if (queue->io_cpu == smp_processor_id() &&
289+ if (queue->io_cpu == __smp_processor_id() &&
290290 sync && empty && mutex_trylock(&queue->send_mutex)) {
291291 queue->more_requests = !last;
292292 nvme_tcp_send_all(queue);
drivers/nvme/target/rdma.c+8−8
@@ -1220,6 +1220,14 @@ nvmet_rdma_find_get_device(struct rdma_cm_id *cm_id) · 1219 unmodified lines
12201220 }
12211221 ndev->inline_data_size = nport->inline_data_size;
12221222 ndev->inline_page_count = inline_page_count;
1223+
1224+ if (nport->pi_enable && !(cm_id->device->attrs.device_cap_flags &
1225+ IB_DEVICE_INTEGRITY_HANDOVER)) {
1226+ pr_warn("T10-PI is not supported by device %s. Disabling it\n",
1227+ cm_id->device->name);
1228+ nport->pi_enable = false;
1229+ }
1230+
12231231 ndev->device = cm_id->device;
12241232 kref_init(&ndev->ref);
12251233
@@ -1855,14 +1863,6 @@ static int nvmet_rdma_enable_port(struct nvmet_rdma_port *port) · 629 unmodified lines
18551863 goto out_destroy_id;
18561864 }
18571865
1858− if (port->nport->pi_enable &&
1859− !(cm_id->device->attrs.device_cap_flags &
1860− IB_DEVICE_INTEGRITY_HANDOVER)) {
1861− pr_err("T10-PI is not supported for %pISpcs\n", addr);
1862− ret = -EINVAL;
1863− goto out_destroy_id;
1864− }
1865−
18661866 port->cm_id = cm_id;
18671867 return 0;
18681868
drivers/perf/arm_pmu.c+0−5
@@ -726,11 +726,6 @@ static int armpmu_get_cpu_irq(struct arm_pmu *pmu, int cpu) · 725 unmodified lines
726726 return per_cpu(hw_events->irq, cpu);
727727 }
728728
729−bool arm_pmu_irq_is_nmi(void)
730−{
731− return has_nmi;
732−}
733−
734729 /*
735730 * PMU hardware loses all context when a CPU goes offline.
736731 * When a CPU is hotplugged back in, since some hardware registers are
drivers/scsi/mpt3sas/Kconfig+1−1
@@ -79,5 +79,5 @@ config SCSI_MPT2SAS · 78 unmodified lines
7979 select SCSI_MPT3SAS
8080 depends on PCI && SCSI
8181 help
82− Dummy config option for backwards compatiblity: configure the MPT3SAS
82+ Dummy config option for backwards compatibility: configure the MPT3SAS
8383 driver instead.
drivers/scsi/qedi/qedi_main.c+2−2
@@ -2245,7 +2245,7 @@ qedi_show_boot_tgt_info(struct qedi_ctx *qedi, int type, · 2244 unmodified lines
22452245 chap_name);
22462246 break;
22472247 case ISCSI_BOOT_TGT_CHAP_SECRET:
2248− rc = sprintf(buf, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN,
2248+ rc = sprintf(buf, "%.*s\n", NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN,
22492249 chap_secret);
22502250 break;
22512251 case ISCSI_BOOT_TGT_REV_CHAP_NAME:
@@ -2253,7 +2253,7 @@ qedi_show_boot_tgt_info(struct qedi_ctx *qedi, int type, · 1 unmodified line
22532253 mchap_name);
22542254 break;
22552255 case ISCSI_BOOT_TGT_REV_CHAP_SECRET:
2256− rc = sprintf(buf, "%.*s\n", NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN,
2256+ rc = sprintf(buf, "%.*s\n", NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN,
22572257 mchap_secret);
22582258 break;
22592259 case ISCSI_BOOT_TGT_FLAGS:
drivers/scsi/scsi_debug.c+3−2
@@ -6740,7 +6740,7 @@ static int __init scsi_debug_init(void) · 6739 unmodified lines
67406740 k = sdeb_zbc_model_str(sdeb_zbc_model_s);
67416741 if (k < 0) {
67426742 ret = k;
6743− goto free_vm;
6743+ goto free_q_arr;
67446744 }
67456745 sdeb_zbc_model = k;
67466746 switch (sdeb_zbc_model) {
@@ -6753,7 +6753,8 @@ static int __init scsi_debug_init(void) · 6 unmodified lines
67536753 break;
67546754 default:
67556755 pr_err("Invalid ZBC model\n");
6756− return -EINVAL;
6756+ ret = -EINVAL;
6757+ goto free_q_arr;
67576758 }
67586759 }
67596760 if (sdeb_zbc_model != BLK_ZONED_NONE) {
drivers/scsi/sd.c+3−3
@@ -984,8 +984,10 @@ static blk_status_t sd_setup_write_zeroes_cmnd(struct scsi_cmnd *cmd) · 983 unmodified lines
984984 }
985985 }
986986
987− if (sdp->no_write_same)
987+ if (sdp->no_write_same) {
988+ rq->rq_flags |= RQF_QUIET;
988989 return BLK_STS_TARGET;
990+ }
989991
990992 if (sdkp->ws16 || lba > 0xffffffff || nr_blocks > 0xffff)
991993 return sd_setup_write_same16_cmnd(cmd, false);
@@ -3510,10 +3512,8 @@ static int sd_probe(struct device *dev) · 2518 unmodified lines
35103512 static int sd_remove(struct device *dev)
35113513 {
35123514 struct scsi_disk *sdkp;
3513− dev_t devt;
35143515
35153516 sdkp = dev_get_drvdata(dev);
3516− devt = disk_devt(sdkp->disk);
35173517 scsi_autopm_get_device(sdkp->device);
35183518
35193519 async_synchronize_full_domain(&scsi_sd_pm_domain);
drivers/scsi/ufs/ufshcd.c+10−14
@@ -289,7 +289,8 @@ static inline void ufshcd_wb_config(struct ufs_hba *hba) · 288 unmodified lines
289289 if (ret)
290290 dev_err(hba->dev, "%s: En WB flush during H8: failed: %d\n",
291291 __func__, ret);
292− ufshcd_wb_toggle_flush(hba, true);
292+ if (!(hba->quirks & UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL))
293+ ufshcd_wb_toggle_flush(hba, true);
293294 }
294295
295296 static void ufshcd_scsi_unblock_requests(struct ufs_hba *hba)
@@ -5436,9 +5437,6 @@ static int ufshcd_wb_toggle_flush_during_h8(struct ufs_hba *hba, bool set) · 5140 unmodified lines
54365437
54375438 static inline void ufshcd_wb_toggle_flush(struct ufs_hba *hba, bool enable)
54385439 {
5439− if (hba->quirks & UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL)
5440− return;
5441−
54425440 if (enable)
54435441 ufshcd_wb_buf_flush_enable(hba);
54445442 else
@@ -6661,19 +6659,16 @@ static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd) · 1216 unmodified lines
66616659 {
66626660 struct Scsi_Host *host;
66636661 struct ufs_hba *hba;
6664− unsigned int tag;
66656662 u32 pos;
66666663 int err;
6667− u8 resp = 0xF;
6668− struct ufshcd_lrb *lrbp;
6664+ u8 resp = 0xF, lun;
66696665 unsigned long flags;
66706666
66716667 host = cmd->device->host;
66726668 hba = shost_priv(host);
6673− tag = cmd->request->tag;
66746669
6675− lrbp = &hba->lrb[tag];
6676− err = ufshcd_issue_tm_cmd(hba, lrbp->lun, 0, UFS_LOGICAL_RESET, &resp);
6670+ lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
6671+ err = ufshcd_issue_tm_cmd(hba, lun, 0, UFS_LOGICAL_RESET, &resp);
66776672 if (err || resp != UPIU_TASK_MANAGEMENT_FUNC_COMPL) {
66786673 if (!err)
66796674 err = resp;
@@ -6682,7 +6677,7 @@ static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd) · 2 unmodified lines
66826677
66836678 /* clear the commands that were pending for corresponding LUN */
66846679 for_each_set_bit(pos, &hba->outstanding_reqs, hba->nutrs) {
6685− if (hba->lrb[pos].lun == lrbp->lun) {
6680+ if (hba->lrb[pos].lun == lun) {
66866681 err = ufshcd_clear_cmd(hba, pos);
66876682 if (err)
66886683 break;
@@ -8698,6 +8693,8 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) · 2009 unmodified lines
86988693 ufshcd_wb_need_flush(hba));
86998694 }
87008695
8696+ flush_work(&hba->eeh_work);
8697+
87018698 if (req_dev_pwr_mode != hba->curr_dev_pwr_mode) {
87028699 if (!ufshcd_is_runtime_pm(pm_op))
87038700 /* ensure that bkops is disabled */
@@ -8710,8 +8707,6 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op) · 6 unmodified lines
87108707 }
87118708 }
87128709
8713− flush_work(&hba->eeh_work);
8714−
87158710 /*
87168711 * In the case of DeepSleep, the device is expected to remain powered
87178712 * with the link off, so do not check for bkops.
@@ -8938,7 +8933,8 @@ int ufshcd_system_suspend(struct ufs_hba *hba) · 220 unmodified lines
89388933 if ((ufs_get_pm_lvl_to_dev_pwr_mode(hba->spm_lvl) ==
89398934 hba->curr_dev_pwr_mode) &&
89408935 (ufs_get_pm_lvl_to_link_pwr_state(hba->spm_lvl) ==
8941− hba->uic_link_state))
8936+ hba->uic_link_state) &&
8937+ !hba->dev_info.b_rpm_dev_flush_capable)
89428938 goto out;
89438939
89448940 if (pm_runtime_suspended(hba->dev)) {
drivers/spi/spi-cadence.c+4−2
@@ -115,6 +115,7 @@ struct cdns_spi { · 114 unmodified lines
115115 void __iomem *regs;
116116 struct clk *ref_clk;
117117 struct clk *pclk;
118+ unsigned int clk_rate;
118119 u32 speed_hz;
119120 const u8 *txbuf;
120121 u8 *rxbuf;
@@ -250,7 +251,7 @@ static void cdns_spi_config_clock_freq(struct spi_device *spi, · 129 unmodified lines
250251 u32 ctrl_reg, baud_rate_val;
251252 unsigned long frequency;
252253
253− frequency = clk_get_rate(xspi->ref_clk);
254+ frequency = xspi->clk_rate;
254255
255256 ctrl_reg = cdns_spi_read(xspi, CDNS_SPI_CR);
256257
@@ -558,8 +559,9 @@ static int cdns_spi_probe(struct platform_device *pdev) · 301 unmodified lines
558559 master->auto_runtime_pm = true;
559560 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
560561
562+ xspi->clk_rate = clk_get_rate(xspi->ref_clk);
561563 /* Set to default valid value */
562− master->max_speed_hz = clk_get_rate(xspi->ref_clk) / 4;
564+ master->max_speed_hz = xspi->clk_rate / 4;
563565 xspi->speed_hz = master->max_speed_hz;
564566
565567 master->bits_per_word_mask = SPI_BPW_MASK(8);
drivers/spi/spi-fsl-spi.c+2−3
@@ -115,14 +115,13 @@ static void fsl_spi_chipselect(struct spi_device *spi, int value) · 114 unmodified lines
115115 {
116116 struct mpc8xxx_spi *mpc8xxx_spi = spi_master_get_devdata(spi->master);
117117 struct fsl_spi_platform_data *pdata;
118− bool pol = spi->mode & SPI_CS_HIGH;
119118 struct spi_mpc8xxx_cs *cs = spi->controller_state;
120119
121120 pdata = spi->dev.parent->parent->platform_data;
122121
123122 if (value == BITBANG_CS_INACTIVE) {
124123 if (pdata->cs_control)
125− pdata->cs_control(spi, !pol);
124+ pdata->cs_control(spi, false);
126125 }
127126
128127 if (value == BITBANG_CS_ACTIVE) {
@@ -134,7 +133,7 @@ static void fsl_spi_chipselect(struct spi_device *spi, int value) · 5 unmodified lines
134133 fsl_spi_change_mode(spi);
135134
136135 if (pdata->cs_control)
137− pdata->cs_control(spi, pol);
136+ pdata->cs_control(spi, true);
138137 }
139138 }
140139
drivers/tty/serial/sifive.c+1−0
@@ -1000,6 +1000,7 @@ static int sifive_serial_probe(struct platform_device *pdev) · 999 unmodified lines
10001000 /* Set up clock divider */
10011001 ssp->clkin_rate = clk_get_rate(ssp->clk);
10021002 ssp->baud_rate = SIFIVE_DEFAULT_BAUD_RATE;
1003+ ssp->port.uartclk = ssp->baud_rate * 16;
10031004 __ssp_update_div(ssp);
10041005
10051006 platform_set_drvdata(pdev, ssp);
drivers/xen/events/events_base.c+0−10
@@ -2060,16 +2060,6 @@ static struct irq_chip xen_percpu_chip __read_mostly = { · 2059 unmodified lines
20602060 .irq_ack = ack_dynirq,
20612061 };
20622062
2063−int xen_set_callback_via(uint64_t via)
2064−{
2065− struct xen_hvm_param a;
2066− a.domid = DOMID_SELF;
2067− a.index = HVM_PARAM_CALLBACK_IRQ;
2068− a.value = via;
2069− return HYPERVISOR_hvm_op(HVMOP_set_param, &a);
2070−}
2071−EXPORT_SYMBOL_GPL(xen_set_callback_via);
2072−
20732063 #ifdef CONFIG_XEN_PVHVM
20742064 /* Vector callbacks are better than PCI interrupts to receive event
20752065 * channel notifications because we can receive vector callbacks on any
drivers/xen/platform-pci.c+7−1
@@ -132,6 +132,13 @@ static int platform_pci_probe(struct pci_dev *pdev, · 131 unmodified lines
132132 dev_warn(&pdev->dev, "request_irq failed err=%d\n", ret);
133133 goto out;
134134 }
135+ /*
136+ * It doesn't strictly *have* to run on CPU0 but it sure
137+ * as hell better process the event channel ports delivered
138+ * to CPU0.
139+ */
140+ irq_set_affinity(pdev->irq, cpumask_of(0));
141+
135142 callback_via = get_callback_via(pdev);
136143 ret = xen_set_callback_via(callback_via);
137144 if (ret) {
@@ -149,7 +156,6 @@ static int platform_pci_probe(struct pci_dev *pdev, · 11 unmodified lines
149156 ret = gnttab_init();
150157 if (ret)
151158 goto grant_out;
152− xenbus_probe(NULL);
153159 return 0;
154160 grant_out:
155161 gnttab_free_auto_xlat_frames();
drivers/xen/privcmd.c+19−6
@@ -717,14 +717,15 @@ static long privcmd_ioctl_restrict(struct file *file, void __user *udata) · 716 unmodified lines
717717 return 0;
718718 }
719719
720−static long privcmd_ioctl_mmap_resource(struct file *file, void __user *udata)
720+static long privcmd_ioctl_mmap_resource(struct file *file,
721+ struct privcmd_mmap_resource __user *udata)
721722 {
722723 struct privcmd_data *data = file->private_data;
723724 struct mm_struct *mm = current->mm;
724725 struct vm_area_struct *vma;
725726 struct privcmd_mmap_resource kdata;
726727 xen_pfn_t *pfns = NULL;
727− struct xen_mem_acquire_resource xdata;
728+ struct xen_mem_acquire_resource xdata = { };
728729 int rc;
729730
730731 if (copy_from_user(&kdata, udata, sizeof(kdata)))
@@ -734,6 +735,22 @@ static long privcmd_ioctl_mmap_resource(struct file *file, void __user *udata) · 3 unmodified lines
734735 if (data->domid != DOMID_INVALID && data->domid != kdata.dom)
735736 return -EPERM;
736737
738+ /* Both fields must be set or unset */
739+ if (!!kdata.addr != !!kdata.num)
740+ return -EINVAL;
741+
742+ xdata.domid = kdata.dom;
743+ xdata.type = kdata.type;
744+ xdata.id = kdata.id;
745+
746+ if (!kdata.addr && !kdata.num) {
747+ /* Query the size of the resource. */
748+ rc = HYPERVISOR_memory_op(XENMEM_acquire_resource, &xdata);
749+ if (rc)
750+ return rc;
751+ return __put_user(xdata.nr_frames, &udata->num);
752+ }
753+
737754 mmap_write_lock(mm);
738755
739756 vma = find_vma(mm, kdata.addr);
@@ -768,10 +785,6 @@ static long privcmd_ioctl_mmap_resource(struct file *file, void __user *udata) · 28 unmodified lines
768785 } else
769786 vma->vm_private_data = PRIV_VMA_LOCKED;
770787
771− memset(&xdata, 0, sizeof(xdata));
772− xdata.domid = kdata.dom;
773− xdata.type = kdata.type;
774− xdata.id = kdata.id;
775788 xdata.frame = kdata.idx;
776789 xdata.nr_frames = kdata.num;
777790 set_xen_guest_handle(xdata.frame_list, pfns);
drivers/xen/xenbus/xenbus.h+1−0
@@ -115,6 +115,7 @@ int xenbus_probe_node(struct xen_bus_type *bus, · 114 unmodified lines
115115 const char *type,
116116 const char *nodename);
117117 int xenbus_probe_devices(struct xen_bus_type *bus);
118+void xenbus_probe(void);
118119
119120 void xenbus_dev_changed(const char *node, struct xen_bus_type *bus);
120121
drivers/xen/xenbus/xenbus_comms.c+0−8
@@ -57,16 +57,8 @@ DEFINE_MUTEX(xs_response_mutex); · 56 unmodified lines
5757 static int xenbus_irq;
5858 static struct task_struct *xenbus_task;
5959
60−static DECLARE_WORK(probe_work, xenbus_probe);
61−
62−
6360 static irqreturn_t wake_waiting(int irq, void *unused)
6461 {
65− if (unlikely(xenstored_ready == 0)) {
66− xenstored_ready = 1;
67− schedule_work(&probe_work);
68− }
69−
7062 wake_up(&xb_waitq);
7163 return IRQ_HANDLED;
7264 }
drivers/xen/xenbus/xenbus_probe.c+67−14
@@ -683,29 +683,76 @@ void unregister_xenstore_notifier(struct notifier_block *nb) · 682 unmodified lines
683683 }
684684 EXPORT_SYMBOL_GPL(unregister_xenstore_notifier);
685685
686−void xenbus_probe(struct work_struct *unused)
686+void xenbus_probe(void)
687687 {
688688 xenstored_ready = 1;
689689
690+ /*
691+ * In the HVM case, xenbus_init() deferred its call to
692+ * xs_init() in case callbacks were not operational yet.
693+ * So do it now.
694+ */
695+ if (xen_store_domain_type == XS_HVM)
696+ xs_init();
697+
690698 /* Notify others that xenstore is up */
691699 blocking_notifier_call_chain(&xenstore_chain, 0, NULL);
692700 }
693−EXPORT_SYMBOL_GPL(xenbus_probe);
694701
695−static int __init xenbus_probe_initcall(void)
702+/*
703+ * Returns true when XenStore init must be deferred in order to
704+ * allow the PCI platform device to be initialised, before we
705+ * can actually have event channel interrupts working.
706+ */
707+static bool xs_hvm_defer_init_for_callback(void)
696708 {
697− if (!xen_domain())
698− return -ENODEV;
709+#ifdef CONFIG_XEN_PVHVM
710+ return xen_store_domain_type == XS_HVM &&
711+ !xen_have_vector_callback;
712+#else
713+ return false;
714+#endif
715+}
699716
700− if (xen_initial_domain() || xen_hvm_domain())
701− return 0;
717+static int __init xenbus_probe_initcall(void)
718+{
719+ /*
720+ * Probe XenBus here in the XS_PV case, and also XS_HVM unless we
721+ * need to wait for the platform PCI device to come up.
722+ */
723+ if (xen_store_domain_type == XS_PV ||
724+ (xen_store_domain_type == XS_HVM &&
725+ !xs_hvm_defer_init_for_callback()))
726+ xenbus_probe();
702727
703− xenbus_probe(NULL);
704728 return 0;
705729 }
706−
707730 device_initcall(xenbus_probe_initcall);
708731
732+int xen_set_callback_via(uint64_t via)
733+{
734+ struct xen_hvm_param a;
735+ int ret;
736+
737+ a.domid = DOMID_SELF;
738+ a.index = HVM_PARAM_CALLBACK_IRQ;
739+ a.value = via;
740+
741+ ret = HYPERVISOR_hvm_op(HVMOP_set_param, &a);
742+ if (ret)
743+ return ret;
744+
745+ /*
746+ * If xenbus_probe_initcall() deferred the xenbus_probe()
747+ * due to the callback not functioning yet, we can do it now.
748+ */
749+ if (!xenstored_ready && xs_hvm_defer_init_for_callback())
750+ xenbus_probe();
751+
752+ return ret;
753+}
754+EXPORT_SYMBOL_GPL(xen_set_callback_via);
755+
709756 /* Set up event channel for xenstored which is run as a local process
710757 * (this is normally used only in dom0)
711758 */
@@ -818,11 +865,17 @@ static int __init xenbus_init(void) · 106 unmodified lines
818865 break;
819866 }
820867
821− /* Initialize the interface to xenstore. */
822− err = xs_init();
823− if (err) {
824− pr_warn("Error initializing xenstore comms: %i\n", err);
825− goto out_error;
868+ /*
869+ * HVM domains may not have a functional callback yet. In that
870+ * case let xs_init() be called from xenbus_probe(), which will
871+ * get invoked at an appropriate time.
872+ */
873+ if (xen_store_domain_type != XS_HVM) {
874+ err = xs_init();
875+ if (err) {
876+ pr_warn("Error initializing xenstore comms: %i\n", err);
877+ goto out_error;
878+ }
826879 }
827880
828881 if ((xen_store_domain_type != XS_LOCAL) &&
fs/cachefiles/rdwr.c+0−2
@@ -413,7 +413,6 @@ int cachefiles_read_or_alloc_page(struct fscache_retrieval *op, · 412 unmodified lines
413413
414414 inode = d_backing_inode(object->backer);
415415 ASSERT(S_ISREG(inode->i_mode));
416− ASSERT(inode->i_mapping->a_ops->readpages);
417416
418417 /* calculate the shift required to use bmap */
419418 shift = PAGE_SHIFT - inode->i_sb->s_blocksize_bits;
@@ -713,7 +712,6 @@ int cachefiles_read_or_alloc_pages(struct fscache_retrieval *op, · 293 unmodified lines
713712
714713 inode = d_backing_inode(object->backer);
715714 ASSERT(S_ISREG(inode->i_mode));
716− ASSERT(inode->i_mapping->a_ops->readpages);
717715
718716 /* calculate the shift required to use bmap */
719717 shift = PAGE_SHIFT - inode->i_sb->s_blocksize_bits;
fs/cifs/connect.c+1−1
@@ -3740,7 +3740,7 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses, · 3739 unmodified lines
37403740
37413741 if (!ses->binding) {
37423742 ses->capabilities = server->capabilities;
3743− if (linuxExtEnabled == 0)
3743+ if (!linuxExtEnabled)
37443744 ses->capabilities &= (~server->vals->cap_unix);
37453745
37463746 if (ses->auth_key.response) {
fs/cifs/dfs_cache.c+2−1
@@ -1260,7 +1260,8 @@ void dfs_cache_del_vol(const char *fullpath) · 1259 unmodified lines
12601260 vi = find_vol(fullpath);
12611261 spin_unlock(&vol_list_lock);
12621262
1263− kref_put(&vi->refcnt, vol_release);
1263+ if (!IS_ERR(vi))
1264+ kref_put(&vi->refcnt, vol_release);
12641265 }
12651266
12661267 /**
fs/cifs/fs_context.c+1−3
@@ -303,8 +303,6 @@ do { \ · 302 unmodified lines
303303 int
304304 smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx)
305305 {
306− int rc = 0;
307−
308306 memcpy(new_ctx, ctx, sizeof(*ctx));
309307 new_ctx->prepath = NULL;
310308 new_ctx->mount_options = NULL;
@@ -327,7 +325,7 @@ smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx · 16 unmodified lines
327325 DUP_CTX_STR(nodename);
328326 DUP_CTX_STR(iocharset);
329327
330− return rc;
328+ return 0;
331329 }
332330
333331 static int
fs/cifs/smb2pdu.c+1−1
@@ -3248,7 +3248,7 @@ close_exit: · 3247 unmodified lines
32483248 free_rsp_buf(resp_buftype, rsp);
32493249
32503250 /* retry close in a worker thread if this one is interrupted */
3251− if (rc == -EINTR) {
3251+ if (is_interrupt_error(rc)) {
32523252 int tmp_rc;
32533253
32543254 tmp_rc = smb2_handle_cancelled_close(tcon, persistent_fid,
fs/cifs/smb2pdu.h+1−1
@@ -424,7 +424,7 @@ struct smb2_rdma_transform_capabilities_context { · 423 unmodified lines
424424 __le16 TransformCount;
425425 __u16 Reserved1;
426426 __u32 Reserved2;
427− __le16 RDMATransformIds[1];
427+ __le16 RDMATransformIds[];
428428 } __packed;
429429
430430 /* Signing algorithms */
fs/ext4/ext4_jbd2.c+0−17
@@ -372,20 +372,3 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line, · 371 unmodified lines
372372 }
373373 return err;
374374 }
375−
376−int __ext4_handle_dirty_super(const char *where, unsigned int line,
377− handle_t *handle, struct super_block *sb)
378−{
379− struct buffer_head *bh = EXT4_SB(sb)->s_sbh;
380− int err = 0;
381−
382− ext4_superblock_csum_set(sb);
383− if (ext4_handle_valid(handle)) {
384− err = jbd2_journal_dirty_metadata(handle, bh);
385− if (err)
386− ext4_journal_abort_handle(where, line, __func__,
387− bh, handle, err);
388− } else
389− mark_buffer_dirty(bh);
390− return err;
391−}
fs/ext4/ext4_jbd2.h+0−5
@@ -244,9 +244,6 @@ int __ext4_handle_dirty_metadata(const char *where, unsigned int line, · 243 unmodified lines
244244 handle_t *handle, struct inode *inode,
245245 struct buffer_head *bh);
246246
247−int __ext4_handle_dirty_super(const char *where, unsigned int line,
248− handle_t *handle, struct super_block *sb);
249−
250247 #define ext4_journal_get_write_access(handle, bh) \
251248 __ext4_journal_get_write_access(__func__, __LINE__, (handle), (bh))
252249 #define ext4_forget(handle, is_metadata, inode, bh, block_nr) \
@@ -257,8 +254,6 @@ int __ext4_handle_dirty_super(const char *where, unsigned int line, · 4 unmodified lines
257254 #define ext4_handle_dirty_metadata(handle, inode, bh) \
258255 __ext4_handle_dirty_metadata(__func__, __LINE__, (handle), (inode), \
259256 (bh))
260−#define ext4_handle_dirty_super(handle, sb) \
261− __ext4_handle_dirty_super(__func__, __LINE__, (handle), (sb))
262257
263258 handle_t *__ext4_journal_start_sb(struct super_block *sb, unsigned int line,
264259 int type, int blocks, int rsv_blocks,
fs/ext4/fast_commit.c+18−17
@@ -604,13 +604,13 @@ void ext4_fc_track_range(handle_t *handle, struct inode *inode, ext4_lblk_t star · 603 unmodified lines
604604 trace_ext4_fc_track_range(inode, start, end, ret);
605605 }
606606
607−static void ext4_fc_submit_bh(struct super_block *sb)
607+static void ext4_fc_submit_bh(struct super_block *sb, bool is_tail)
608608 {
609609 int write_flags = REQ_SYNC;
610610 struct buffer_head *bh = EXT4_SB(sb)->s_fc_bh;
611611
612− /* TODO: REQ_FUA | REQ_PREFLUSH is unnecessarily expensive. */
613− if (test_opt(sb, BARRIER))
612+ /* Add REQ_FUA | REQ_PREFLUSH only its tail */
613+ if (test_opt(sb, BARRIER) && is_tail)
614614 write_flags |= REQ_FUA | REQ_PREFLUSH;
615615 lock_buffer(bh);
616616 set_buffer_dirty(bh);
@@ -684,7 +684,7 @@ static u8 *ext4_fc_reserve_space(struct super_block *sb, int len, u32 *crc) · 67 unmodified lines
684684 *crc = ext4_chksum(sbi, *crc, tl, sizeof(*tl));
685685 if (pad_len > 0)
686686 ext4_fc_memzero(sb, tl + 1, pad_len, crc);
687− ext4_fc_submit_bh(sb);
687+ ext4_fc_submit_bh(sb, false);
688688
689689 ret = jbd2_fc_get_buf(EXT4_SB(sb)->s_journal, &bh);
690690 if (ret)
@@ -741,7 +741,7 @@ static int ext4_fc_write_tail(struct super_block *sb, u32 crc) · 50 unmodified lines
741741 tail.fc_crc = cpu_to_le32(crc);
742742 ext4_fc_memcpy(sb, dst, &tail.fc_crc, sizeof(tail.fc_crc), NULL);
743743
744− ext4_fc_submit_bh(sb);
744+ ext4_fc_submit_bh(sb, true);
745745
746746 return 0;
747747 }
@@ -1268,7 +1268,7 @@ static void ext4_fc_cleanup(journal_t *journal, int full) · 520 unmodified lines
12681268 list_splice_init(&sbi->s_fc_dentry_q[FC_Q_STAGING],
12691269 &sbi->s_fc_dentry_q[FC_Q_MAIN]);
12701270 list_splice_init(&sbi->s_fc_q[FC_Q_STAGING],
1271− &sbi->s_fc_q[FC_Q_STAGING]);
1271+ &sbi->s_fc_q[FC_Q_MAIN]);
12721272
12731273 ext4_clear_mount_flag(sb, EXT4_MF_FC_COMMITTING);
12741274 ext4_clear_mount_flag(sb, EXT4_MF_FC_INELIGIBLE);
@@ -1318,14 +1318,14 @@ static int ext4_fc_replay_unlink(struct super_block *sb, struct ext4_fc_tl *tl) · 43 unmodified lines
13181318 entry.len = darg.dname_len;
13191319 inode = ext4_iget(sb, darg.ino, EXT4_IGET_NORMAL);
13201320
1321− if (IS_ERR_OR_NULL(inode)) {
1321+ if (IS_ERR(inode)) {
13221322 jbd_debug(1, "Inode %d not found", darg.ino);
13231323 return 0;
13241324 }
13251325
13261326 old_parent = ext4_iget(sb, darg.parent_ino,
13271327 EXT4_IGET_NORMAL);
1328− if (IS_ERR_OR_NULL(old_parent)) {
1328+ if (IS_ERR(old_parent)) {
13291329 jbd_debug(1, "Dir with inode %d not found", darg.parent_ino);
13301330 iput(inode);
13311331 return 0;
@@ -1410,7 +1410,7 @@ static int ext4_fc_replay_link(struct super_block *sb, struct ext4_fc_tl *tl) · 78 unmodified lines
14101410 darg.parent_ino, darg.dname_len);
14111411
14121412 inode = ext4_iget(sb, darg.ino, EXT4_IGET_NORMAL);
1413− if (IS_ERR_OR_NULL(inode)) {
1413+ if (IS_ERR(inode)) {
14141414 jbd_debug(1, "Inode not found.");
14151415 return 0;
14161416 }
@@ -1466,10 +1466,11 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl) · 49 unmodified lines
14661466 trace_ext4_fc_replay(sb, tag, ino, 0, 0);
14671467
14681468 inode = ext4_iget(sb, ino, EXT4_IGET_NORMAL);
1469− if (!IS_ERR_OR_NULL(inode)) {
1469+ if (!IS_ERR(inode)) {
14701470 ext4_ext_clear_bb(inode);
14711471 iput(inode);
14721472 }
1473+ inode = NULL;
14731474
14741475 ext4_fc_record_modified_inode(sb, ino);
14751476
@@ -1512,7 +1513,7 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl) · 36 unmodified lines
15121513
15131514 /* Given that we just wrote the inode on disk, this SHOULD succeed. */
15141515 inode = ext4_iget(sb, ino, EXT4_IGET_NORMAL);
1515− if (IS_ERR_OR_NULL(inode)) {
1516+ if (IS_ERR(inode)) {
15161517 jbd_debug(1, "Inode not found.");
15171518 return -EFSCORRUPTED;
15181519 }
@@ -1564,7 +1565,7 @@ static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl) · 45 unmodified lines
15641565 goto out;
15651566
15661567 inode = ext4_iget(sb, darg.ino, EXT4_IGET_NORMAL);
1567− if (IS_ERR_OR_NULL(inode)) {
1568+ if (IS_ERR(inode)) {
15681569 jbd_debug(1, "inode %d not found.", darg.ino);
15691570 inode = NULL;
15701571 ret = -EINVAL;
@@ -1577,7 +1578,7 @@ static int ext4_fc_replay_create(struct super_block *sb, struct ext4_fc_tl *tl) · 6 unmodified lines
15771578 * dot and dot dot dirents are setup properly.
15781579 */
15791580 dir = ext4_iget(sb, darg.parent_ino, EXT4_IGET_NORMAL);
1580− if (IS_ERR_OR_NULL(dir)) {
1581+ if (IS_ERR(dir)) {
15811582 jbd_debug(1, "Dir %d not found.", darg.ino);
15821583 goto out;
15831584 }
@@ -1653,7 +1654,7 @@ static int ext4_fc_replay_add_range(struct super_block *sb, · 69 unmodified lines
16531654
16541655 inode = ext4_iget(sb, le32_to_cpu(fc_add_ex->fc_ino),
16551656 EXT4_IGET_NORMAL);
1656− if (IS_ERR_OR_NULL(inode)) {
1657+ if (IS_ERR(inode)) {
16571658 jbd_debug(1, "Inode not found.");
16581659 return 0;
16591660 }
@@ -1777,7 +1778,7 @@ ext4_fc_replay_del_range(struct super_block *sb, struct ext4_fc_tl *tl) · 117 unmodified lines
17771778 le32_to_cpu(lrange->fc_ino), cur, remaining);
17781779
17791780 inode = ext4_iget(sb, le32_to_cpu(lrange->fc_ino), EXT4_IGET_NORMAL);
1780− if (IS_ERR_OR_NULL(inode)) {
1781+ if (IS_ERR(inode)) {
17811782 jbd_debug(1, "Inode %d not found", le32_to_cpu(lrange->fc_ino));
17821783 return 0;
17831784 }
@@ -1832,7 +1833,7 @@ static void ext4_fc_set_bitmaps_and_counters(struct super_block *sb) · 48 unmodified lines
18321833 for (i = 0; i < state->fc_modified_inodes_used; i++) {
18331834 inode = ext4_iget(sb, state->fc_modified_inodes[i],
18341835 EXT4_IGET_NORMAL);
1835− if (IS_ERR_OR_NULL(inode)) {
1836+ if (IS_ERR(inode)) {
18361837 jbd_debug(1, "Inode %d not found.",
18371838 state->fc_modified_inodes[i]);
18381839 continue;
@@ -1849,7 +1850,7 @@ static void ext4_fc_set_bitmaps_and_counters(struct super_block *sb) · 10 unmodified lines
18491850
18501851 if (ret > 0) {
18511852 path = ext4_find_extent(inode, map.m_lblk, NULL, 0);
1852− if (!IS_ERR_OR_NULL(path)) {
1853+ if (!IS_ERR(path)) {
18531854 for (j = 0; j < path->p_depth; j++)
18541855 ext4_mb_mark_bb(inode->i_sb,
18551856 path[j].p_block, 1, 1);
fs/ext4/file.c+5−2
@@ -809,9 +809,12 @@ static int ext4_sample_last_mounted(struct super_block *sb, · 808 unmodified lines
809809 err = ext4_journal_get_write_access(handle, sbi->s_sbh);
810810 if (err)
811811 goto out_journal;
812− strlcpy(sbi->s_es->s_last_mounted, cp,
812+ lock_buffer(sbi->s_sbh);
813+ strncpy(sbi->s_es->s_last_mounted, cp,
813814 sizeof(sbi->s_es->s_last_mounted));
814− ext4_handle_dirty_super(handle, sb);
815+ ext4_superblock_csum_set(sb);
816+ unlock_buffer(sbi->s_sbh);
817+ ext4_handle_dirty_metadata(handle, NULL, sbi->s_sbh);
815818 out_journal:
816819 ext4_journal_stop(handle);
817820 out:
fs/ext4/inode.c+5−1
@@ -5150,9 +5150,13 @@ static int ext4_do_update_inode(handle_t *handle, · 5149 unmodified lines
51505150 err = ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh);
51515151 if (err)
51525152 goto out_brelse;
5153+ lock_buffer(EXT4_SB(sb)->s_sbh);
51535154 ext4_set_feature_large_file(sb);
5155+ ext4_superblock_csum_set(sb);
5156+ unlock_buffer(EXT4_SB(sb)->s_sbh);
51545157 ext4_handle_sync(handle);
5155− err = ext4_handle_dirty_super(handle, sb);
5158+ err = ext4_handle_dirty_metadata(handle, NULL,
5159+ EXT4_SB(sb)->s_sbh);
51565160 }
51575161 ext4_update_inode_fsync_trans(handle, inode, need_datasync);
51585162 out_brelse:
fs/ext4/ioctl.c+3−0
@@ -1157,7 +1157,10 @@ resizefs_out: · 1156 unmodified lines
11571157 err = ext4_journal_get_write_access(handle, sbi->s_sbh);
11581158 if (err)
11591159 goto pwsalt_err_journal;
1160+ lock_buffer(sbi->s_sbh);
11601161 generate_random_uuid(sbi->s_es->s_encrypt_pw_salt);
1162+ ext4_superblock_csum_set(sb);
1163+ unlock_buffer(sbi->s_sbh);
11611164 err = ext4_handle_dirty_metadata(handle, NULL,
11621165 sbi->s_sbh);
11631166 pwsalt_err_journal:
fs/ext4/namei.c+17−10
@@ -2976,14 +2976,17 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode) · 2975 unmodified lines
29762976 (le32_to_cpu(sbi->s_es->s_inodes_count))) {
29772977 /* Insert this inode at the head of the on-disk orphan list */
29782978 NEXT_ORPHAN(inode) = le32_to_cpu(sbi->s_es->s_last_orphan);
2979+ lock_buffer(sbi->s_sbh);
29792980 sbi->s_es->s_last_orphan = cpu_to_le32(inode->i_ino);
2981+ ext4_superblock_csum_set(sb);
2982+ unlock_buffer(sbi->s_sbh);
29802983 dirty = true;
29812984 }
29822985 list_add(&EXT4_I(inode)->i_orphan, &sbi->s_orphan);
29832986 mutex_unlock(&sbi->s_orphan_lock);
29842987
29852988 if (dirty) {
2986− err = ext4_handle_dirty_super(handle, sb);
2989+ err = ext4_handle_dirty_metadata(handle, NULL, sbi->s_sbh);
29872990 rc = ext4_mark_iloc_dirty(handle, inode, &iloc);
29882991 if (!err)
29892992 err = rc;
@@ -3059,9 +3062,12 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode) · 69 unmodified lines
30593062 mutex_unlock(&sbi->s_orphan_lock);
30603063 goto out_brelse;
30613064 }
3065+ lock_buffer(sbi->s_sbh);
30623066 sbi->s_es->s_last_orphan = cpu_to_le32(ino_next);
3067+ ext4_superblock_csum_set(inode->i_sb);
3068+ unlock_buffer(sbi->s_sbh);
30633069 mutex_unlock(&sbi->s_orphan_lock);
3064− err = ext4_handle_dirty_super(handle, inode->i_sb);
3070+ err = ext4_handle_dirty_metadata(handle, NULL, sbi->s_sbh);
30653071 } else {
30663072 struct ext4_iloc iloc2;
30673073 struct inode *i_prev =
@@ -3593,9 +3599,6 @@ static int ext4_setent(handle_t *handle, struct ext4_renament *ent, · 525 unmodified lines
35933599 return retval2;
35943600 }
35953601 }
3596− brelse(ent->bh);
3597− ent->bh = NULL;
3598−
35993602 return retval;
36003603 }
36013604
@@ -3794,6 +3797,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, · 192 unmodified lines
37943797 }
37953798 }
37963799
3800+ old_file_type = old.de->file_type;
37973801 if (IS_DIRSYNC(old.dir) || IS_DIRSYNC(new.dir))
37983802 ext4_handle_sync(handle);
37993803
@@ -3821,7 +3825,6 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, · 21 unmodified lines
38213825 force_reread = (new.dir->i_ino == old.dir->i_ino &&
38223826 ext4_test_inode_flag(new.dir, EXT4_INODE_INLINE_DATA));
38233827
3824− old_file_type = old.de->file_type;
38253828 if (whiteout) {
38263829 /*
38273830 * Do this before adding a new entry, so the old entry is sure
@@ -3919,15 +3922,19 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, · 91 unmodified lines
39193922 retval = 0;
39203923
39213924 end_rename:
3922− brelse(old.dir_bh);
3923− brelse(old.bh);
3924− brelse(new.bh);
39253925 if (whiteout) {
3926− if (retval)
3926+ if (retval) {
3927+ ext4_setent(handle, &old,
3928+ old.inode->i_ino, old_file_type);
39273929 drop_nlink(whiteout);
3930+ }
39283931 unlock_new_inode(whiteout);
39293932 iput(whiteout);
3933+
39303934 }
3935+ brelse(old.dir_bh);
3936+ brelse(old.bh);
3937+ brelse(new.bh);
39313938 if (handle)
39323939 ext4_journal_stop(handle);
39333940 return retval;
fs/ext4/resize.c+16−4
@@ -899,8 +899,11 @@ static int add_new_gdb(handle_t *handle, struct inode *inode, · 898 unmodified lines
899899 EXT4_SB(sb)->s_gdb_count++;
900900 ext4_kvfree_array_rcu(o_group_desc);
901901
902+ lock_buffer(EXT4_SB(sb)->s_sbh);
902903 le16_add_cpu(&es->s_reserved_gdt_blocks, -1);
903− err = ext4_handle_dirty_super(handle, sb);
904+ ext4_superblock_csum_set(sb);
905+ unlock_buffer(EXT4_SB(sb)->s_sbh);
906+ err = ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh);
904907 if (err)
905908 ext4_std_error(sb, err);
906909 return err;
@@ -1384,6 +1387,7 @@ static void ext4_update_super(struct super_block *sb, · 477 unmodified lines
13841387 reserved_blocks *= blocks_count;
13851388 do_div(reserved_blocks, 100);
13861389
1390+ lock_buffer(sbi->s_sbh);
13871391 ext4_blocks_count_set(es, ext4_blocks_count(es) + blocks_count);
13881392 ext4_free_blocks_count_set(es, ext4_free_blocks_count(es) + free_blocks);
13891393 le32_add_cpu(&es->s_inodes_count, EXT4_INODES_PER_GROUP(sb) *
@@ -1421,6 +1425,8 @@ static void ext4_update_super(struct super_block *sb, · 31 unmodified lines
14211425 * active. */
14221426 ext4_r_blocks_count_set(es, ext4_r_blocks_count(es) +
14231427 reserved_blocks);
1428+ ext4_superblock_csum_set(sb);
1429+ unlock_buffer(sbi->s_sbh);
14241430
14251431 /* Update the free space counts */
14261432 percpu_counter_add(&sbi->s_freeclusters_counter,
@@ -1515,7 +1521,7 @@ static int ext4_flex_group_add(struct super_block *sb, · 88 unmodified lines
15151521
15161522 ext4_update_super(sb, flex_gd);
15171523
1518− err = ext4_handle_dirty_super(handle, sb);
1524+ err = ext4_handle_dirty_metadata(handle, NULL, sbi->s_sbh);
15191525
15201526 exit_journal:
15211527 err2 = ext4_journal_stop(handle);
@@ -1717,15 +1723,18 @@ static int ext4_group_extend_no_check(struct super_block *sb, · 195 unmodified lines
17171723 goto errout;
17181724 }
17191725
1726+ lock_buffer(EXT4_SB(sb)->s_sbh);
17201727 ext4_blocks_count_set(es, o_blocks_count + add);
17211728 ext4_free_blocks_count_set(es, ext4_free_blocks_count(es) + add);
1729+ ext4_superblock_csum_set(sb);
1730+ unlock_buffer(EXT4_SB(sb)->s_sbh);
17221731 ext4_debug("freeing blocks %llu through %llu\n", o_blocks_count,
17231732 o_blocks_count + add);
17241733 /* We add the blocks to the bitmap and set the group need init bit */
17251734 err = ext4_group_add_blocks(handle, sb, o_blocks_count, add);
17261735 if (err)
17271736 goto errout;
1728− ext4_handle_dirty_super(handle, sb);
1737+ ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh);
17291738 ext4_debug("freed blocks %llu through %llu\n", o_blocks_count,
17301739 o_blocks_count + add);
17311740 errout:
@@ -1874,12 +1883,15 @@ static int ext4_convert_meta_bg(struct super_block *sb, struct inode *inode) · 142 unmodified lines
18741883 if (err)
18751884 goto errout;
18761885
1886+ lock_buffer(sbi->s_sbh);
18771887 ext4_clear_feature_resize_inode(sb);
18781888 ext4_set_feature_meta_bg(sb);
18791889 sbi->s_es->s_first_meta_bg =
18801890 cpu_to_le32(num_desc_blocks(sb, sbi->s_groups_count));
1891+ ext4_superblock_csum_set(sb);
1892+ unlock_buffer(sbi->s_sbh);
18811893
1882− err = ext4_handle_dirty_super(handle, sb);
1894+ err = ext4_handle_dirty_metadata(handle, NULL, sbi->s_sbh);
18831895 if (err) {
18841896 ext4_std_error(sb, err);
18851897 goto errout;
fs/ext4/super.c+118−72
@@ -65,7 +65,8 @@ static struct ratelimit_state ext4_mount_msg_ratelimit; · 64 unmodified lines
6565 static int ext4_load_journal(struct super_block *, struct ext4_super_block *,
6666 unsigned long journal_devnum);
6767 static int ext4_show_options(struct seq_file *seq, struct dentry *root);
68−static int ext4_commit_super(struct super_block *sb, int sync);
68+static void ext4_update_super(struct super_block *sb);
69+static int ext4_commit_super(struct super_block *sb);
6970 static int ext4_mark_recovery_complete(struct super_block *sb,
7071 struct ext4_super_block *es);
7172 static int ext4_clear_journal_err(struct super_block *sb,
@@ -586,15 +587,12 @@ static int ext4_errno_to_code(int errno) · 514 unmodified lines
586587 return EXT4_ERR_UNKNOWN;
587588 }
588589
589−static void __save_error_info(struct super_block *sb, int error,
590− __u32 ino, __u64 block,
591− const char *func, unsigned int line)
590+static void save_error_info(struct super_block *sb, int error,
591+ __u32 ino, __u64 block,
592+ const char *func, unsigned int line)
592593 {
593594 struct ext4_sb_info *sbi = EXT4_SB(sb);
594595
595− EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
596− if (bdev_read_only(sb->s_bdev))
597− return;
598596 /* We default to EFSCORRUPTED error... */
599597 if (error == 0)
600598 error = EFSCORRUPTED;
@@ -618,15 +616,6 @@ static void __save_error_info(struct super_block *sb, int error, · 17 unmodified lines
618616 spin_unlock(&sbi->s_error_lock);
619617 }
620618
621−static void save_error_info(struct super_block *sb, int error,
622− __u32 ino, __u64 block,
623− const char *func, unsigned int line)
624−{
625− __save_error_info(sb, error, ino, block, func, line);
626− if (!bdev_read_only(sb->s_bdev))
627− ext4_commit_super(sb, 1);
628−}
629−
630619 /* Deal with the reporting of failure conditions on a filesystem such as
631620 * inconsistencies detected or read IO failures.
632621 *
@@ -647,19 +636,40 @@ static void save_error_info(struct super_block *sb, int error, · 14 unmodified lines
647636 * used to deal with unrecoverable failures such as journal IO errors or ENOMEM
648637 * at a critical moment in log management.
649638 */
650−static void ext4_handle_error(struct super_block *sb, bool force_ro)
639+static void ext4_handle_error(struct super_block *sb, bool force_ro, int error,
640+ __u32 ino, __u64 block,
641+ const char *func, unsigned int line)
651642 {
652643 journal_t *journal = EXT4_SB(sb)->s_journal;
644+ bool continue_fs = !force_ro && test_opt(sb, ERRORS_CONT);
653645
646+ EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
654647 if (test_opt(sb, WARN_ON_ERROR))
655648 WARN_ON_ONCE(1);
656649
657− if (sb_rdonly(sb) || (!force_ro && test_opt(sb, ERRORS_CONT)))
650+ if (!continue_fs && !sb_rdonly(sb)) {
651+ ext4_set_mount_flag(sb, EXT4_MF_FS_ABORTED);
652+ if (journal)
653+ jbd2_journal_abort(journal, -EIO);
654+ }
655+
656+ if (!bdev_read_only(sb->s_bdev)) {
657+ save_error_info(sb, error, ino, block, func, line);
658+ /*
659+ * In case the fs should keep running, we need to writeout
660+ * superblock through the journal. Due to lock ordering
661+ * constraints, it may not be safe to do it right here so we
662+ * defer superblock flushing to a workqueue.
663+ */
664+ if (continue_fs)
665+ schedule_work(&EXT4_SB(sb)->s_error_work);
666+ else
667+ ext4_commit_super(sb);
668+ }
669+
670+ if (sb_rdonly(sb) || continue_fs)
658671 return;
659672
660− ext4_set_mount_flag(sb, EXT4_MF_FS_ABORTED);
661− if (journal)
662− jbd2_journal_abort(journal, -EIO);
663673 /*
664674 * We force ERRORS_RO behavior when system is rebooting. Otherwise we
665675 * could panic during 'reboot -f' as the underlying device got already
@@ -682,8 +692,39 @@ static void flush_stashed_error_work(struct work_struct *work) · 16 unmodified lines
682692 {
683693 struct ext4_sb_info *sbi = container_of(work, struct ext4_sb_info,
684694 s_error_work);
695+ journal_t *journal = sbi->s_journal;
696+ handle_t *handle;
685697
686− ext4_commit_super(sbi->s_sb, 1);
698+ /*
699+ * If the journal is still running, we have to write out superblock
700+ * through the journal to avoid collisions of other journalled sb
701+ * updates.
702+ *
703+ * We use directly jbd2 functions here to avoid recursing back into
704+ * ext4 error handling code during handling of previous errors.
705+ */
706+ if (!sb_rdonly(sbi->s_sb) && journal) {
707+ handle = jbd2_journal_start(journal, 1);
708+ if (IS_ERR(handle))
709+ goto write_directly;
710+ if (jbd2_journal_get_write_access(handle, sbi->s_sbh)) {
711+ jbd2_journal_stop(handle);
712+ goto write_directly;
713+ }
714+ ext4_update_super(sbi->s_sb);
715+ if (jbd2_journal_dirty_metadata(handle, sbi->s_sbh)) {
716+ jbd2_journal_stop(handle);
717+ goto write_directly;
718+ }
719+ jbd2_journal_stop(handle);
720+ return;
721+ }
722+write_directly:
723+ /*
724+ * Write through journal failed. Write sb directly to get error info
725+ * out and hope for the best.
726+ */
727+ ext4_commit_super(sbi->s_sb);
687728 }
688729
689730 #define ext4_error_ratelimit(sb) \
@@ -710,8 +751,7 @@ void __ext4_error(struct super_block *sb, const char *function, · 20 unmodified lines
710751 sb->s_id, function, line, current->comm, &vaf);
711752 va_end(args);
712753 }
713− save_error_info(sb, error, 0, block, function, line);
714− ext4_handle_error(sb, force_ro);
754+ ext4_handle_error(sb, force_ro, error, 0, block, function, line);
715755 }
716756
717757 void __ext4_error_inode(struct inode *inode, const char *function,
@@ -741,9 +781,8 @@ void __ext4_error_inode(struct inode *inode, const char *function, · 23 unmodified lines
741781 current->comm, &vaf);
742782 va_end(args);
743783 }
744− save_error_info(inode->i_sb, error, inode->i_ino, block,
745− function, line);
746− ext4_handle_error(inode->i_sb, false);
784+ ext4_handle_error(inode->i_sb, false, error, inode->i_ino, block,
785+ function, line);
747786 }
748787
749788 void __ext4_error_file(struct file *file, const char *function,
@@ -780,9 +819,8 @@ void __ext4_error_file(struct file *file, const char *function, · 30 unmodified lines
780819 current->comm, path, &vaf);
781820 va_end(args);
782821 }
783− save_error_info(inode->i_sb, EFSCORRUPTED, inode->i_ino, block,
784− function, line);
785− ext4_handle_error(inode->i_sb, false);
822+ ext4_handle_error(inode->i_sb, false, EFSCORRUPTED, inode->i_ino, block,
823+ function, line);
786824 }
787825
788826 const char *ext4_decode_error(struct super_block *sb, int errno,
@@ -849,8 +887,7 @@ void __ext4_std_error(struct super_block *sb, const char *function, · 60 unmodified lines
849887 sb->s_id, function, line, errstr);
850888 }
851889
852− save_error_info(sb, -errno, 0, 0, function, line);
853− ext4_handle_error(sb, false);
890+ ext4_handle_error(sb, false, -errno, 0, 0, function, line);
854891 }
855892
856893 void __ext4_msg(struct super_block *sb,
@@ -944,13 +981,16 @@ __acquires(bitlock) · 87 unmodified lines
944981 if (test_opt(sb, ERRORS_CONT)) {
945982 if (test_opt(sb, WARN_ON_ERROR))
946983 WARN_ON_ONCE(1);
947− __save_error_info(sb, EFSCORRUPTED, ino, block, function, line);
948− schedule_work(&EXT4_SB(sb)->s_error_work);
984+ EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
985+ if (!bdev_read_only(sb->s_bdev)) {
986+ save_error_info(sb, EFSCORRUPTED, ino, block, function,
987+ line);
988+ schedule_work(&EXT4_SB(sb)->s_error_work);
989+ }
949990 return;
950991 }
951992 ext4_unlock_group(sb, grp);
952− save_error_info(sb, EFSCORRUPTED, ino, block, function, line);
953− ext4_handle_error(sb, false);
993+ ext4_handle_error(sb, false, EFSCORRUPTED, ino, block, function, line);
954994 /*
955995 * We only get here in the ERRORS_RO case; relocking the group
956996 * may be dangerous, but nothing bad will happen since the
@@ -1152,7 +1192,7 @@ static void ext4_put_super(struct super_block *sb) · 195 unmodified lines
11521192 es->s_state = cpu_to_le16(sbi->s_mount_state);
11531193 }
11541194 if (!sb_rdonly(sb))
1155− ext4_commit_super(sb, 1);
1195+ ext4_commit_super(sb);
11561196
11571197 rcu_read_lock();
11581198 group_desc = rcu_dereference(sbi->s_group_desc);
@@ -2642,7 +2682,7 @@ static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es, · 1483 unmodified lines
26422682 if (sbi->s_journal)
26432683 ext4_set_feature_journal_needs_recovery(sb);
26442684
2645− err = ext4_commit_super(sb, 1);
2685+ err = ext4_commit_super(sb);
26462686 done:
26472687 if (test_opt(sb, DEBUG))
26482688 printk(KERN_INFO "[EXT4 FS bs=%lu, gc=%u, "
@@ -4868,7 +4908,7 @@ no_journal: · 2219 unmodified lines
48684908 if (DUMMY_ENCRYPTION_ENABLED(sbi) && !sb_rdonly(sb) &&
48694909 !ext4_has_feature_encrypt(sb)) {
48704910 ext4_set_feature_encrypt(sb);
4871− ext4_commit_super(sb, 1);
4911+ ext4_commit_super(sb);
48724912 }
48734913
48744914 /*
@@ -5418,7 +5458,7 @@ static int ext4_load_journal(struct super_block *sb, · 543 unmodified lines
54185458 es->s_journal_dev = cpu_to_le32(journal_devnum);
54195459
54205460 /* Make sure we flush the recovery flag to disk. */
5421− ext4_commit_super(sb, 1);
5461+ ext4_commit_super(sb);
54225462 }
54235463
54245464 return 0;
@@ -5428,16 +5468,14 @@ err_out: · 3 unmodified lines
54285468 return err;
54295469 }
54305470
5431−static int ext4_commit_super(struct super_block *sb, int sync)
5471+/* Copy state of EXT4_SB(sb) into buffer for on-disk superblock */
5472+static void ext4_update_super(struct super_block *sb)
54325473 {
54335474 struct ext4_sb_info *sbi = EXT4_SB(sb);
5434− struct ext4_super_block *es = EXT4_SB(sb)->s_es;
5435− struct buffer_head *sbh = EXT4_SB(sb)->s_sbh;
5436− int error = 0;
5437−
5438− if (!sbh || block_device_ejected(sb))
5439− return error;
5475+ struct ext4_super_block *es = sbi->s_es;
5476+ struct buffer_head *sbh = sbi->s_sbh;
54405477
5478+ lock_buffer(sbh);
54415479 /*
54425480 * If the file system is mounted read-only, don't update the
54435481 * superblock write time. This avoids updating the superblock
@@ -5451,17 +5489,17 @@ static int ext4_commit_super(struct super_block *sb, int sync) · 7 unmodified lines
54515489 if (!(sb->s_flags & SB_RDONLY))
54525490 ext4_update_tstamp(es, s_wtime);
54535491 es->s_kbytes_written =
5454− cpu_to_le64(EXT4_SB(sb)->s_kbytes_written +
5492+ cpu_to_le64(sbi->s_kbytes_written +
54555493 ((part_stat_read(sb->s_bdev, sectors[STAT_WRITE]) -
5456− EXT4_SB(sb)->s_sectors_written_start) >> 1));
5457− if (percpu_counter_initialized(&EXT4_SB(sb)->s_freeclusters_counter))
5494+ sbi->s_sectors_written_start) >> 1));
5495+ if (percpu_counter_initialized(&sbi->s_freeclusters_counter))
54585496 ext4_free_blocks_count_set(es,
5459− EXT4_C2B(EXT4_SB(sb), percpu_counter_sum_positive(
5460− &EXT4_SB(sb)->s_freeclusters_counter)));
5461− if (percpu_counter_initialized(&EXT4_SB(sb)->s_freeinodes_counter))
5497+ EXT4_C2B(sbi, percpu_counter_sum_positive(
5498+ &sbi->s_freeclusters_counter)));
5499+ if (percpu_counter_initialized(&sbi->s_freeinodes_counter))
54625500 es->s_free_inodes_count =
54635501 cpu_to_le32(percpu_counter_sum_positive(
5464− &EXT4_SB(sb)->s_freeinodes_counter));
5502+ &sbi->s_freeinodes_counter));
54655503 /* Copy error information to the on-disk superblock */
54665504 spin_lock(&sbi->s_error_lock);
54675505 if (sbi->s_add_error_count > 0) {
@@ -5502,10 +5540,20 @@ static int ext4_commit_super(struct super_block *sb, int sync) · 34 unmodified lines
55025540 }
55035541 spin_unlock(&sbi->s_error_lock);
55045542
5505− BUFFER_TRACE(sbh, "marking dirty");
55065543 ext4_superblock_csum_set(sb);
5507− if (sync)
5508− lock_buffer(sbh);
5544+ unlock_buffer(sbh);
5545+}
5546+
5547+static int ext4_commit_super(struct super_block *sb)
5548+{
5549+ struct buffer_head *sbh = EXT4_SB(sb)->s_sbh;
5550+ int error = 0;
5551+
5552+ if (!sbh || block_device_ejected(sb))
5553+ return error;
5554+
5555+ ext4_update_super(sb);
5556+
55095557 if (buffer_write_io_error(sbh) || !buffer_uptodate(sbh)) {
55105558 /*
55115559 * Oh, dear. A previous attempt to write the
@@ -5520,17 +5568,15 @@ static int ext4_commit_super(struct super_block *sb, int sync) · 8 unmodified lines
55205568 clear_buffer_write_io_error(sbh);
55215569 set_buffer_uptodate(sbh);
55225570 }
5571+ BUFFER_TRACE(sbh, "marking dirty");
55235572 mark_buffer_dirty(sbh);
5524− if (sync) {
5525− unlock_buffer(sbh);
5526− error = __sync_dirty_buffer(sbh,
5527− REQ_SYNC | (test_opt(sb, BARRIER) ? REQ_FUA : 0));
5528− if (buffer_write_io_error(sbh)) {
5529− ext4_msg(sb, KERN_ERR, "I/O error while writing "
5530− "superblock");
5531− clear_buffer_write_io_error(sbh);
5532− set_buffer_uptodate(sbh);
5533− }
5573+ error = __sync_dirty_buffer(sbh,
5574+ REQ_SYNC | (test_opt(sb, BARRIER) ? REQ_FUA : 0));
5575+ if (buffer_write_io_error(sbh)) {
5576+ ext4_msg(sb, KERN_ERR, "I/O error while writing "
5577+ "superblock");
5578+ clear_buffer_write_io_error(sbh);
5579+ set_buffer_uptodate(sbh);
55345580 }
55355581 return error;
55365582 }
@@ -5561,7 +5607,7 @@ static int ext4_mark_recovery_complete(struct super_block *sb, · 24 unmodified lines
55615607
55625608 if (ext4_has_feature_journal_needs_recovery(sb) && sb_rdonly(sb)) {
55635609 ext4_clear_feature_journal_needs_recovery(sb);
5564− ext4_commit_super(sb, 1);
5610+ ext4_commit_super(sb);
55655611 }
55665612 out:
55675613 jbd2_journal_unlock_updates(journal);
@@ -5603,7 +5649,7 @@ static int ext4_clear_journal_err(struct super_block *sb, · 35 unmodified lines
56035649
56045650 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
56055651 es->s_state |= cpu_to_le16(EXT4_ERROR_FS);
5606− ext4_commit_super(sb, 1);
5652+ ext4_commit_super(sb);
56075653
56085654 jbd2_journal_clear_err(journal);
56095655 jbd2_journal_update_sb_errno(journal);
@@ -5705,7 +5751,7 @@ static int ext4_freeze(struct super_block *sb) · 95 unmodified lines
57055751 ext4_clear_feature_journal_needs_recovery(sb);
57065752 }
57075753
5708− error = ext4_commit_super(sb, 1);
5754+ error = ext4_commit_super(sb);
57095755 out:
57105756 if (journal)
57115757 /* we rely on upper layer to stop further updates */
@@ -5727,7 +5773,7 @@ static int ext4_unfreeze(struct super_block *sb) · 15 unmodified lines
57275773 ext4_set_feature_journal_needs_recovery(sb);
57285774 }
57295775
5730− ext4_commit_super(sb, 1);
5776+ ext4_commit_super(sb);
57315777 return 0;
57325778 }
57335779
@@ -5987,7 +6033,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) · 253 unmodified lines
59876033 }
59886034
59896035 if (sbi->s_journal == NULL && !(old_sb_flags & SB_RDONLY)) {
5990− err = ext4_commit_super(sb, 1);
6036+ err = ext4_commit_super(sb);
59916037 if (err)
59926038 goto restore_opts;
59936039 }
fs/ext4/xattr.c+4−1
@@ -792,8 +792,11 @@ static void ext4_xattr_update_super_block(handle_t *handle, · 791 unmodified lines
792792
793793 BUFFER_TRACE(EXT4_SB(sb)->s_sbh, "get_write_access");
794794 if (ext4_journal_get_write_access(handle, EXT4_SB(sb)->s_sbh) == 0) {
795+ lock_buffer(EXT4_SB(sb)->s_sbh);
795796 ext4_set_feature_xattr(sb);
796− ext4_handle_dirty_super(handle, sb);
797+ ext4_superblock_csum_set(sb);
798+ unlock_buffer(EXT4_SB(sb)->s_sbh);
799+ ext4_handle_dirty_metadata(handle, NULL, EXT4_SB(sb)->s_sbh);
797800 }
798801 }
799802
fs/io_uring.c+41−5
@@ -354,6 +354,7 @@ struct io_ring_ctx { · 353 unmodified lines
354354 unsigned cq_entries;
355355 unsigned cq_mask;
356356 atomic_t cq_timeouts;
357+ unsigned cq_last_tm_flush;
357358 unsigned long cq_check_overflow;
358359 struct wait_queue_head cq_wait;
359360 struct fasync_struct *cq_fasync;
@@ -1106,6 +1107,9 @@ static void io_sq_thread_drop_mm_files(void) · 746 unmodified lines
11061107
11071108 static int __io_sq_thread_acquire_files(struct io_ring_ctx *ctx)
11081109 {
1110+ if (current->flags & PF_EXITING)
1111+ return -EFAULT;
1112+
11091113 if (!current->files) {
11101114 struct files_struct *files;
11111115 struct nsproxy *nsproxy;
@@ -1133,6 +1137,8 @@ static int __io_sq_thread_acquire_mm(struct io_ring_ctx *ctx) · 21 unmodified lines
11331137 {
11341138 struct mm_struct *mm;
11351139
1140+ if (current->flags & PF_EXITING)
1141+ return -EFAULT;
11361142 if (current->mm)
11371143 return 0;
11381144
@@ -1634,19 +1640,38 @@ static void __io_queue_deferred(struct io_ring_ctx *ctx) · 495 unmodified lines
16341640
16351641 static void io_flush_timeouts(struct io_ring_ctx *ctx)
16361642 {
1637− while (!list_empty(&ctx->timeout_list)) {
1643+ u32 seq;
1644+
1645+ if (list_empty(&ctx->timeout_list))
1646+ return;
1647+
1648+ seq = ctx->cached_cq_tail - atomic_read(&ctx->cq_timeouts);
1649+
1650+ do {
1651+ u32 events_needed, events_got;
16381652 struct io_kiocb *req = list_first_entry(&ctx->timeout_list,
16391653 struct io_kiocb, timeout.list);
16401654
16411655 if (io_is_timeout_noseq(req))
16421656 break;
1643− if (req->timeout.target_seq != ctx->cached_cq_tail
1644− - atomic_read(&ctx->cq_timeouts))
1657+
1658+ /*
1659+ * Since seq can easily wrap around over time, subtract
1660+ * the last seq at which timeouts were flushed before comparing.
1661+ * Assuming not more than 2^31-1 events have happened since,
1662+ * these subtractions won't have wrapped, so we can check if
1663+ * target is in [last_seq, current_seq] by comparing the two.
1664+ */
1665+ events_needed = req->timeout.target_seq - ctx->cq_last_tm_flush;
1666+ events_got = seq - ctx->cq_last_tm_flush;
1667+ if (events_got < events_needed)
16451668 break;
16461669
16471670 list_del_init(&req->timeout.list);
16481671 io_kill_timeout(req);
1649− }
1672+ } while (!list_empty(&ctx->timeout_list));
1673+
1674+ ctx->cq_last_tm_flush = seq;
16501675 }
16511676
16521677 static void io_commit_cqring(struct io_ring_ctx *ctx)
@@ -5832,6 +5857,12 @@ static int io_timeout(struct io_kiocb *req) · 4179 unmodified lines
58325857 tail = ctx->cached_cq_tail - atomic_read(&ctx->cq_timeouts);
58335858 req->timeout.target_seq = tail + off;
58345859
5860+ /* Update the last seq here in case io_flush_timeouts() hasn't.
5861+ * This is safe because ->completion_lock is held, and submissions
5862+ * and completions are never mixed in the same ->completion_lock section.
5863+ */
5864+ ctx->cq_last_tm_flush = tail;
5865+
58355866 /*
58365867 * Insertion sort, ensuring the first entry in the list is always
58375868 * the one we need first.
@@ -7056,6 +7087,7 @@ static int io_sq_thread(void *data) · 1218 unmodified lines
70567087
70577088 if (sqt_spin || !time_after(jiffies, timeout)) {
70587089 io_run_task_work();
7090+ io_sq_thread_drop_mm_files();
70597091 cond_resched();
70607092 if (sqt_spin)
70617093 timeout = jiffies + sqd->sq_thread_idle;
@@ -7093,6 +7125,7 @@ static int io_sq_thread(void *data) · 31 unmodified lines
70937125 }
70947126
70957127 io_run_task_work();
7128+ io_sq_thread_drop_mm_files();
70967129
70977130 if (cur_css)
70987131 io_sq_thread_unassociate_blkcg();
@@ -8888,7 +8921,8 @@ static void io_disable_sqo_submit(struct io_ring_ctx *ctx) · 1789 unmodified lines
88888921 mutex_unlock(&ctx->uring_lock);
88898922
88908923 /* make sure callers enter the ring to get error */
8891− io_ring_set_wakeup_flag(ctx);
8924+ if (ctx->rings)
8925+ io_ring_set_wakeup_flag(ctx);
88928926 }
88938927
88948928 /*
@@ -9067,6 +9101,7 @@ void __io_uring_task_cancel(void) · 172 unmodified lines
90679101 finish_wait(&tctx->wait, &wait);
90689102 } while (1);
90699103
9104+ finish_wait(&tctx->wait, &wait);
90709105 atomic_dec(&tctx->in_idle);
90719106
90729107 io_uring_remove_task_files(tctx);
@@ -9700,6 +9735,7 @@ static int io_uring_create(unsigned entries, struct io_uring_params *p, · 627 unmodified lines
97009735 */
97019736 ret = io_uring_install_fd(ctx, file);
97029737 if (ret < 0) {
9738+ io_disable_sqo_submit(ctx);
97039739 /* fput will clean it up */
97049740 fput(file);
97059741 return ret;
fs/namespace.c+5−2
@@ -1713,8 +1713,6 @@ static int can_umount(const struct path *path, int flags) · 1712 unmodified lines
17131713 {
17141714 struct mount *mnt = real_mount(path->mnt);
17151715
1716− if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW))
1717− return -EINVAL;
17181716 if (!may_mount())
17191717 return -EPERM;
17201718 if (path->dentry != path->mnt->mnt_root)
@@ -1728,6 +1726,7 @@ static int can_umount(const struct path *path, int flags) · 7 unmodified lines
17281726 return 0;
17291727 }
17301728
1729+// caller is responsible for flags being sane
17311730 int path_umount(struct path *path, int flags)
17321731 {
17331732 struct mount *mnt = real_mount(path->mnt);
@@ -1749,6 +1748,10 @@ static int ksys_umount(char __user *name, int flags) · 15 unmodified lines
17491748 struct path path;
17501749 int ret;
17511750
1751+ // basic validity checks done first
1752+ if (flags & ~(MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW))
1753+ return -EINVAL;
1754+
17521755 if (!(flags & UMOUNT_NOFOLLOW))
17531756 lookup_flags |= LOOKUP_FOLLOW;
17541757 ret = user_path_at(AT_FDCWD, name, lookup_flags, &path);
fs/nfsd/nfs3xdr.c+6−1
@@ -865,9 +865,14 @@ compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp, · 864 unmodified lines
865865 if (isdotent(name, namlen)) {
866866 if (namlen == 2) {
867867 dchild = dget_parent(dparent);
868− /* filesystem root - cannot return filehandle for ".." */
868+ /*
869+ * Don't return filehandle for ".." if we're at
870+ * the filesystem or export root:
871+ */
869872 if (dchild == dparent)
870873 goto out;
874+ if (dparent == exp->ex_path.dentry)
875+ goto out;
871876 } else
872877 dchild = dget(dparent);
873878 } else
fs/proc/task_mmu.c+30−23
@@ -1035,6 +1035,25 @@ struct clear_refs_private { · 1034 unmodified lines
10351035 };
10361036
10371037 #ifdef CONFIG_MEM_SOFT_DIRTY
1038+
1039+#define is_cow_mapping(flags) (((flags) & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE)
1040+
1041+static inline bool pte_is_pinned(struct vm_area_struct *vma, unsigned long addr, pte_t pte)
1042+{
1043+ struct page *page;
1044+
1045+ if (!pte_write(pte))
1046+ return false;
1047+ if (!is_cow_mapping(vma->vm_flags))
1048+ return false;
1049+ if (likely(!atomic_read(&vma->vm_mm->has_pinned)))
1050+ return false;
1051+ page = vm_normal_page(vma, addr, pte);
1052+ if (!page)
1053+ return false;
1054+ return page_maybe_dma_pinned(page);
1055+}
1056+
10381057 static inline void clear_soft_dirty(struct vm_area_struct *vma,
10391058 unsigned long addr, pte_t *pte)
10401059 {
@@ -1049,6 +1068,8 @@ static inline void clear_soft_dirty(struct vm_area_struct *vma, · 8 unmodified lines
10491068 if (pte_present(ptent)) {
10501069 pte_t old_pte;
10511070
1071+ if (pte_is_pinned(vma, addr, ptent))
1072+ return;
10521073 old_pte = ptep_modify_prot_start(vma, addr, pte);
10531074 ptent = pte_wrprotect(old_pte);
10541075 ptent = pte_clear_soft_dirty(ptent);
@@ -1215,41 +1236,26 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf, · 160 unmodified lines
12151236 .type = type,
12161237 };
12171238
1239+ if (mmap_write_lock_killable(mm)) {
1240+ count = -EINTR;
1241+ goto out_mm;
1242+ }
12181243 if (type == CLEAR_REFS_MM_HIWATER_RSS) {
1219− if (mmap_write_lock_killable(mm)) {
1220− count = -EINTR;
1221− goto out_mm;
1222− }
1223−
12241244 /*
12251245 * Writing 5 to /proc/pid/clear_refs resets the peak
12261246 * resident set size to this mm's current rss value.
12271247 */
12281248 reset_mm_hiwater_rss(mm);
1229− mmap_write_unlock(mm);
1230− goto out_mm;
1249+ goto out_unlock;
12311250 }
12321251
1233− if (mmap_read_lock_killable(mm)) {
1234− count = -EINTR;
1235− goto out_mm;
1236− }
12371252 tlb_gather_mmu(&tlb, mm, 0, -1);
12381253 if (type == CLEAR_REFS_SOFT_DIRTY) {
12391254 for (vma = mm->mmap; vma; vma = vma->vm_next) {
12401255 if (!(vma->vm_flags & VM_SOFTDIRTY))
12411256 continue;
1242− mmap_read_unlock(mm);
1243− if (mmap_write_lock_killable(mm)) {
1244− count = -EINTR;
1245− goto out_mm;
1246− }
1247− for (vma = mm->mmap; vma; vma = vma->vm_next) {
1248− vma->vm_flags &= ~VM_SOFTDIRTY;
1249− vma_set_page_prot(vma);
1250− }
1251− mmap_write_downgrade(mm);
1252− break;
1257+ vma->vm_flags &= ~VM_SOFTDIRTY;
1258+ vma_set_page_prot(vma);
12531259 }
12541260
12551261 mmu_notifier_range_init(&range, MMU_NOTIFY_SOFT_DIRTY,
@@ -1261,7 +1267,8 @@ static ssize_t clear_refs_write(struct file *file, const char __user *buf, · 5 unmodified lines
12611267 if (type == CLEAR_REFS_SOFT_DIRTY)
12621268 mmu_notifier_invalidate_range_end(&range);
12631269 tlb_finish_mmu(&tlb, 0, -1);
1264− mmap_read_unlock(mm);
1270+out_unlock:
1271+ mmap_write_unlock(mm);
12651272 out_mm:
12661273 mmput(mm);
12671274 }
include/asm-generic/bitops/atomic.h+3−3
@@ -11,19 +11,19 @@ · 10 unmodified lines
1111 * See Documentation/atomic_bitops.txt for details.
1212 */
1313
14−static inline void set_bit(unsigned int nr, volatile unsigned long *p)
14+static __always_inline void set_bit(unsigned int nr, volatile unsigned long *p)
1515 {
1616 p += BIT_WORD(nr);
1717 atomic_long_or(BIT_MASK(nr), (atomic_long_t *)p);
1818 }
1919
20−static inline void clear_bit(unsigned int nr, volatile unsigned long *p)
20+static __always_inline void clear_bit(unsigned int nr, volatile unsigned long *p)
2121 {
2222 p += BIT_WORD(nr);
2323 atomic_long_andnot(BIT_MASK(nr), (atomic_long_t *)p);
2424 }
2525
26−static inline void change_bit(unsigned int nr, volatile unsigned long *p)
26+static __always_inline void change_bit(unsigned int nr, volatile unsigned long *p)
2727 {
2828 p += BIT_WORD(nr);
2929 atomic_long_xor(BIT_MASK(nr), (atomic_long_t *)p);
include/linux/compiler-gcc.h+6−0
@@ -13,6 +13,12 @@ · 12 unmodified lines
1313 /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58145 */
1414 #if GCC_VERSION < 40900
1515 # error Sorry, your version of GCC is too old - please use 4.9 or newer.
16+#elif defined(CONFIG_ARM64) && GCC_VERSION < 50100
17+/*
18+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
19+ * https://lore.kernel.org/r/20210107111841.GN1551@shell.armlinux.org.uk
20+ */
21+# error Sorry, your version of GCC is too old - please use 5.1 or newer.
1622 #endif
1723
1824 /*
include/linux/dm-bufio.h+1−0
@@ -150,6 +150,7 @@ void dm_bufio_set_minimum_buffers(struct dm_bufio_client *c, unsigned n); · 149 unmodified lines
150150
151151 unsigned dm_bufio_get_block_size(struct dm_bufio_client *c);
152152 sector_t dm_bufio_get_device_size(struct dm_bufio_client *c);
153+struct dm_io_client *dm_bufio_get_dm_io_client(struct dm_bufio_client *c);
153154 sector_t dm_bufio_get_block_number(struct dm_buffer *b);
154155 void *dm_bufio_get_block_data(struct dm_buffer *b);
155156 void *dm_bufio_get_aux_data(struct dm_buffer *b);
include/linux/kasan.h+5−1
@@ -35,8 +35,12 @@ struct kunit_kasan_expectation { · 34 unmodified lines
3535 #define KASAN_SHADOW_INIT 0
3636 #endif
3737
38+#ifndef PTE_HWTABLE_PTRS
39+#define PTE_HWTABLE_PTRS 0
40+#endif
41+
3842 extern unsigned char kasan_early_shadow_page[PAGE_SIZE];
39−extern pte_t kasan_early_shadow_pte[PTRS_PER_PTE];
43+extern pte_t kasan_early_shadow_pte[PTRS_PER_PTE + PTE_HWTABLE_PTRS];
4044 extern pmd_t kasan_early_shadow_pmd[PTRS_PER_PMD];
4145 extern pud_t kasan_early_shadow_pud[PTRS_PER_PUD];
4246 extern p4d_t kasan_early_shadow_p4d[MAX_PTRS_PER_P4D];
include/linux/mdio-bitbang.h+3−0
@@ -35,6 +35,9 @@ struct mdiobb_ctrl { · 34 unmodified lines
3535 const struct mdiobb_ops *ops;
3636 };
3737
38+int mdiobb_read(struct mii_bus *bus, int phy, int reg);
39+int mdiobb_write(struct mii_bus *bus, int phy, int reg, u16 val);
40+
3841 /* The returned bus is not yet registered with the phy layer. */
3942 struct mii_bus *alloc_mdio_bitbang(struct mdiobb_ctrl *ctrl);
4043
include/linux/memcontrol.h+1−1
@@ -665,7 +665,7 @@ static inline struct lruvec *mem_cgroup_page_lruvec(struct page *page, · 664 unmodified lines
665665 {
666666 struct mem_cgroup *memcg = page_memcg(page);
667667
668− VM_WARN_ON_ONCE_PAGE(!memcg, page);
668+ VM_WARN_ON_ONCE_PAGE(!memcg && !mem_cgroup_disabled(), page);
669669 return mem_cgroup_lruvec(memcg, pgdat);
670670 }
671671
include/linux/perf/arm_pmu.h+0−2
@@ -163,8 +163,6 @@ int arm_pmu_acpi_probe(armpmu_init_fn init_fn); · 162 unmodified lines
163163 static inline int arm_pmu_acpi_probe(armpmu_init_fn init_fn) { return 0; }
164164 #endif
165165
166−bool arm_pmu_irq_is_nmi(void);
167−
168166 /* Internal functions only for core arm_pmu code */
169167 struct arm_pmu *armpmu_alloc(void);
170168 struct arm_pmu *armpmu_alloc_atomic(void);
include/linux/usb/usbnet.h+2−0
@@ -81,6 +81,8 @@ struct usbnet { · 80 unmodified lines
8181 # define EVENT_LINK_CHANGE 11
8282 # define EVENT_SET_RX_MODE 12
8383 # define EVENT_NO_IP_ALIGN 13
84+ u32 rx_speed; /* in bps - NOT Mbps */
85+ u32 tx_speed; /* in bps - NOT Mbps */
8486 };
8587
8688 static inline struct usb_driver *driver_of(struct usb_interface *intf)
include/net/cfg80211.h+4−1
@@ -1756,7 +1756,7 @@ struct cfg80211_sar_specs { · 1755 unmodified lines
17561756
17571757
17581758 /**
1759− * @struct cfg80211_sar_chan_ranges - sar frequency ranges
1759+ * struct cfg80211_sar_freq_ranges - sar frequency ranges
17601760 * @start_freq: start range edge frequency
17611761 * @end_freq: end range edge frequency
17621762 */
@@ -3972,6 +3972,8 @@ struct mgmt_frame_regs { · 2209 unmodified lines
39723972 * This callback may sleep.
39733973 * @reset_tid_config: Reset TID specific configuration for the peer, for the
39743974 * given TIDs. This callback may sleep.
3975+ *
3976+ * @set_sar_specs: Update the SAR (TX power) settings.
39753977 */
39763978 struct cfg80211_ops {
39773979 int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -4929,6 +4931,7 @@ struct wiphy_iftype_akm_suites { · 951 unmodified lines
49294931 * @max_data_retry_count: maximum supported per TID retry count for
49304932 * configuration through the %NL80211_TID_CONFIG_ATTR_RETRY_SHORT and
49314933 * %NL80211_TID_CONFIG_ATTR_RETRY_LONG attributes
4934+ * @sar_capa: SAR control capabilities
49324935 */
49334936 struct wiphy {
49344937 /* assign these fields before you register the wiphy */
include/net/inet_connection_sock.h+3−0
@@ -76,6 +76,8 @@ struct inet_connection_sock_af_ops { · 75 unmodified lines
7676 * @icsk_ext_hdr_len: Network protocol overhead (IP/IPv6 options)
7777 * @icsk_ack: Delayed ACK control data
7878 * @icsk_mtup; MTU probing control data
79+ * @icsk_probes_tstamp: Probe timestamp (cleared by non-zero window ack)
80+ * @icsk_user_timeout: TCP_USER_TIMEOUT value
7981 */
8082 struct inet_connection_sock {
8183 /* inet_sock has to be the first member! */
@@ -129,6 +131,7 @@ struct inet_connection_sock { · 47 unmodified lines
129131
130132 u32 probe_timestamp;
131133 } icsk_mtup;
134+ u32 icsk_probes_tstamp;
132135 u32 icsk_user_timeout;
133136
134137 u64 icsk_ca_priv[104 / sizeof(u64)];
include/net/mac80211.h+1−0
@@ -3880,6 +3880,7 @@ enum ieee80211_reconfig_type { · 3879 unmodified lines
38803880 * This callback may sleep.
38813881 * @sta_set_4addr: Called to notify the driver when a station starts/stops using
38823882 * 4-address mode
3883+ * @set_sar_specs: Update the SAR (TX power) settings.
38833884 */
38843885 struct ieee80211_ops {
38853886 void (*tx)(struct ieee80211_hw *hw,
include/net/sock.h+12−5
@@ -1921,10 +1921,13 @@ static inline void sk_set_txhash(struct sock *sk) · 1920 unmodified lines
19211921 sk->sk_txhash = net_tx_rndhash();
19221922 }
19231923
1924−static inline void sk_rethink_txhash(struct sock *sk)
1924+static inline bool sk_rethink_txhash(struct sock *sk)
19251925 {
1926− if (sk->sk_txhash)
1926+ if (sk->sk_txhash) {
19271927 sk_set_txhash(sk);
1928+ return true;
1929+ }
1930+ return false;
19281931 }
19291932
19301933 static inline struct dst_entry *
@@ -1947,12 +1950,10 @@ sk_dst_get(struct sock *sk) · 16 unmodified lines
19471950 return dst;
19481951 }
19491952
1950−static inline void dst_negative_advice(struct sock *sk)
1953+static inline void __dst_negative_advice(struct sock *sk)
19511954 {
19521955 struct dst_entry *ndst, *dst = __sk_dst_get(sk);
19531956
1954− sk_rethink_txhash(sk);
1955−
19561957 if (dst && dst->ops->negative_advice) {
19571958 ndst = dst->ops->negative_advice(dst);
19581959
@@ -1964,6 +1965,12 @@ static inline void dst_negative_advice(struct sock *sk) · 5 unmodified lines
19641965 }
19651966 }
19661967
1968+static inline void dst_negative_advice(struct sock *sk)
1969+{
1970+ sk_rethink_txhash(sk);
1971+ __dst_negative_advice(sk);
1972+}
1973+
19671974 static inline void
19681975 __sk_dst_set(struct sock *sk, struct dst_entry *dst)
19691976 {
include/trace/events/sunrpc.h+53−6
@@ -1424,13 +1424,61 @@ TRACE_EVENT(rpcb_unregister, · 1423 unmodified lines
14241424 )
14251425 );
14261426
1427+/* Record an xdr_buf containing a fully-formed RPC message */
1428+DECLARE_EVENT_CLASS(svc_xdr_msg_class,
1429+ TP_PROTO(
1430+ const struct xdr_buf *xdr
1431+ ),
1432+
1433+ TP_ARGS(xdr),
1434+
1435+ TP_STRUCT__entry(
1436+ __field(u32, xid)
1437+ __field(const void *, head_base)
1438+ __field(size_t, head_len)
1439+ __field(const void *, tail_base)
1440+ __field(size_t, tail_len)
1441+ __field(unsigned int, page_len)
1442+ __field(unsigned int, msg_len)
1443+ ),
1444+
1445+ TP_fast_assign(
1446+ __be32 *p = (__be32 *)xdr->head[0].iov_base;
1447+
1448+ __entry->xid = be32_to_cpu(*p);
1449+ __entry->head_base = p;
1450+ __entry->head_len = xdr->head[0].iov_len;
1451+ __entry->tail_base = xdr->tail[0].iov_base;
1452+ __entry->tail_len = xdr->tail[0].iov_len;
1453+ __entry->page_len = xdr->page_len;
1454+ __entry->msg_len = xdr->len;
1455+ ),
1456+
1457+ TP_printk("xid=0x%08x head=[%p,%zu] page=%u tail=[%p,%zu] len=%u",
1458+ __entry->xid,
1459+ __entry->head_base, __entry->head_len, __entry->page_len,
1460+ __entry->tail_base, __entry->tail_len, __entry->msg_len
1461+ )
1462+);
1463+
1464+#define DEFINE_SVCXDRMSG_EVENT(name) \
1465+ DEFINE_EVENT(svc_xdr_msg_class, \
1466+ svc_xdr_##name, \
1467+ TP_PROTO( \
1468+ const struct xdr_buf *xdr \
1469+ ), \
1470+ TP_ARGS(xdr))
1471+
1472+DEFINE_SVCXDRMSG_EVENT(recvfrom);
1473+
1474+/* Record an xdr_buf containing arbitrary data, tagged with an XID */
14271475 DECLARE_EVENT_CLASS(svc_xdr_buf_class,
14281476 TP_PROTO(
1429− const struct svc_rqst *rqst,
1477+ __be32 xid,
14301478 const struct xdr_buf *xdr
14311479 ),
14321480
1433− TP_ARGS(rqst, xdr),
1481+ TP_ARGS(xid, xdr),
14341482
14351483 TP_STRUCT__entry(
14361484 __field(u32, xid)
@@ -1443,7 +1491,7 @@ DECLARE_EVENT_CLASS(svc_xdr_buf_class, · 6 unmodified lines
14431491 ),
14441492
14451493 TP_fast_assign(
1446− __entry->xid = be32_to_cpu(rqst->rq_xid);
1494+ __entry->xid = be32_to_cpu(xid);
14471495 __entry->head_base = xdr->head[0].iov_base;
14481496 __entry->head_len = xdr->head[0].iov_len;
14491497 __entry->tail_base = xdr->tail[0].iov_base;
@@ -1463,12 +1511,11 @@ DECLARE_EVENT_CLASS(svc_xdr_buf_class, · 13 unmodified lines
14631511 DEFINE_EVENT(svc_xdr_buf_class, \
14641512 svc_xdr_##name, \
14651513 TP_PROTO( \
1466− const struct svc_rqst *rqst, \
1514+ __be32 xid, \
14671515 const struct xdr_buf *xdr \
14681516 ), \
1469− TP_ARGS(rqst, xdr))
1517+ TP_ARGS(xid, xdr))
14701518
1471−DEFINE_SVCXDRBUF_EVENT(recvfrom);
14721519 DEFINE_SVCXDRBUF_EVENT(sendto);
14731520
14741521 /*
include/xen/xenbus.h+1−1
@@ -192,7 +192,7 @@ void xs_suspend_cancel(void); · 191 unmodified lines
192192
193193 struct work_struct;
194194
195−void xenbus_probe(struct work_struct *);
195+void xenbus_probe(void);
196196
197197 #define XENBUS_IS_ERR_READ(str) ({ \
198198 if (!IS_ERR(str) && strlen(str) == 0) { \
kernel/bpf/bpf_inode_storage.c+6−3
@@ -176,14 +176,14 @@ BPF_CALL_4(bpf_inode_storage_get, struct bpf_map *, map, struct inode *, inode, · 175 unmodified lines
176176 * bpf_local_storage_update expects the owner to have a
177177 * valid storage pointer.
178178 */
179− if (!inode_storage_ptr(inode))
179+ if (!inode || !inode_storage_ptr(inode))
180180 return (unsigned long)NULL;
181181
182182 sdata = inode_storage_lookup(inode, map, true);
183183 if (sdata)
184184 return (unsigned long)sdata->data;
185185
186− /* This helper must only called from where the inode is gurranteed
186+ /* This helper must only called from where the inode is guaranteed
187187 * to have a refcount and cannot be freed.
188188 */
189189 if (flags & BPF_LOCAL_STORAGE_GET_F_CREATE) {
@@ -200,7 +200,10 @@ BPF_CALL_4(bpf_inode_storage_get, struct bpf_map *, map, struct inode *, inode, · 10 unmodified lines
200200 BPF_CALL_2(bpf_inode_storage_delete,
201201 struct bpf_map *, map, struct inode *, inode)
202202 {
203− /* This helper must only called from where the inode is gurranteed
203+ if (!inode)
204+ return -EINVAL;
205+
206+ /* This helper must only called from where the inode is guaranteed
204207 * to have a refcount and cannot be freed.
205208 */
206209 return inode_storage_delete(inode, map);
kernel/bpf/bpf_task_storage.c+4−1
@@ -218,7 +218,7 @@ BPF_CALL_4(bpf_task_storage_get, struct bpf_map *, map, struct task_struct *, · 217 unmodified lines
218218 * bpf_local_storage_update expects the owner to have a
219219 * valid storage pointer.
220220 */
221− if (!task_storage_ptr(task))
221+ if (!task || !task_storage_ptr(task))
222222 return (unsigned long)NULL;
223223
224224 sdata = task_storage_lookup(task, map, true);
@@ -243,6 +243,9 @@ BPF_CALL_4(bpf_task_storage_get, struct bpf_map *, map, struct task_struct *, · 18 unmodified lines
243243 BPF_CALL_2(bpf_task_storage_delete, struct bpf_map *, map, struct task_struct *,
244244 task)
245245 {
246+ if (!task)
247+ return -EINVAL;
248+
246249 /* This helper must only be called from places where the lifetime of the task
247250 * is guaranteed. Either by being refcounted or by being protected
248251 * by an RCU read-side critical section.
kernel/bpf/btf.c+1−1
@@ -4172,7 +4172,7 @@ static int btf_parse_hdr(struct btf_verifier_env *env) · 4171 unmodified lines
41724172 return -ENOTSUPP;
41734173 }
41744174
4175− if (btf_data_size == hdr->hdr_len) {
4175+ if (!btf->base_btf && btf_data_size == hdr->hdr_len) {
41764176 btf_verifier_log(env, "No data");
41774177 return -EINVAL;
41784178 }
kernel/bpf/cgroup.c+3−2
@@ -1391,12 +1391,13 @@ int __cgroup_bpf_run_filter_setsockopt(struct sock *sk, int *level, · 1390 unmodified lines
13911391 if (ctx.optlen != 0) {
13921392 *optlen = ctx.optlen;
13931393 *kernel_optval = ctx.optval;
1394+ /* export and don't free sockopt buf */
1395+ return 0;
13941396 }
13951397 }
13961398
13971399 out:
1398− if (ret)
1399− sockopt_free_buf(&ctx);
1400+ sockopt_free_buf(&ctx);
14001401 return ret;
14011402 }
14021403
kernel/bpf/helpers.c+1−1
@@ -108,7 +108,7 @@ BPF_CALL_2(bpf_map_peek_elem, struct bpf_map *, map, void *, value) · 107 unmodified lines
108108 }
109109
110110 const struct bpf_func_proto bpf_map_peek_elem_proto = {
111− .func = bpf_map_pop_elem,
111+ .func = bpf_map_peek_elem,
112112 .gpl_only = false,
113113 .ret_type = RET_INTEGER,
114114 .arg1_type = ARG_CONST_MAP_PTR,
kernel/bpf/syscall.c+4−2
@@ -2712,7 +2712,6 @@ out_unlock: · 2711 unmodified lines
27122712 out_put_prog:
27132713 if (tgt_prog_fd && tgt_prog)
27142714 bpf_prog_put(tgt_prog);
2715− bpf_prog_put(prog);
27162715 return err;
27172716 }
27182717
@@ -2825,7 +2824,10 @@ static int bpf_raw_tracepoint_open(const union bpf_attr *attr) · 106 unmodified lines
28252824 tp_name = prog->aux->attach_func_name;
28262825 break;
28272826 }
2828− return bpf_tracing_prog_attach(prog, 0, 0);
2827+ err = bpf_tracing_prog_attach(prog, 0, 0);
2828+ if (err >= 0)
2829+ return err;
2830+ goto out_put_prog;
28292831 case BPF_PROG_TYPE_RAW_TRACEPOINT:
28302832 case BPF_PROG_TYPE_RAW_TRACEPOINT_WRITABLE:
28312833 if (strncpy_from_user(buf,
kernel/bpf/verifier.c+5−3
@@ -2217,6 +2217,8 @@ static bool is_spillable_regtype(enum bpf_reg_type type) · 2216 unmodified lines
22172217 case PTR_TO_RDWR_BUF:
22182218 case PTR_TO_RDWR_BUF_OR_NULL:
22192219 case PTR_TO_PERCPU_BTF_ID:
2220+ case PTR_TO_MEM:
2221+ case PTR_TO_MEM_OR_NULL:
22202222 return true;
22212223 default:
22222224 return false;
@@ -5352,7 +5354,7 @@ static bool signed_add_overflows(s64 a, s64 b) · 3129 unmodified lines
53525354 return res < a;
53535355 }
53545356
5355−static bool signed_add32_overflows(s64 a, s64 b)
5357+static bool signed_add32_overflows(s32 a, s32 b)
53565358 {
53575359 /* Do the add in u32, where overflow is well-defined */
53585360 s32 res = (s32)((u32)a + (u32)b);
@@ -5362,7 +5364,7 @@ static bool signed_add32_overflows(s64 a, s64 b) · 3 unmodified lines
53625364 return res < a;
53635365 }
53645366
5365−static bool signed_sub_overflows(s32 a, s32 b)
5367+static bool signed_sub_overflows(s64 a, s64 b)
53665368 {
53675369 /* Do the sub in u64, where overflow is well-defined */
53685370 s64 res = (s64)((u64)a - (u64)b);
@@ -5374,7 +5376,7 @@ static bool signed_sub_overflows(s32 a, s32 b) · 5 unmodified lines
53745376
53755377 static bool signed_sub32_overflows(s32 a, s32 b)
53765378 {
5377− /* Do the sub in u64, where overflow is well-defined */
5379+ /* Do the sub in u32, where overflow is well-defined */
53785380 s32 res = (s32)((u32)a - (u32)b);
53795381
53805382 if (b < 0)
kernel/signal.c+3−0
@@ -2550,6 +2550,9 @@ bool get_signal(struct ksignal *ksig) · 2549 unmodified lines
25502550 struct signal_struct *signal = current->signal;
25512551 int signr;
25522552
2553+ if (unlikely(current->task_works))
2554+ task_work_run();
2555+
25532556 /*
25542557 * For non-generic architectures, check for TIF_NOTIFY_SIGNAL so
25552558 * that the arch handlers don't all have to do it. If we get here
lib/iov_iter.c+1−1
@@ -1658,7 +1658,7 @@ static int copy_compat_iovec_from_user(struct iovec *iov, · 1657 unmodified lines
16581658 (const struct compat_iovec __user *)uvec;
16591659 int ret = -EFAULT, i;
16601660
1661− if (!user_access_begin(uvec, nr_segs * sizeof(*uvec)))
1661+ if (!user_access_begin(uiov, nr_segs * sizeof(*uiov)))
16621662 return -EFAULT;
16631663
16641664 for (i = 0; i < nr_segs; i++) {
mm/hugetlb.c+1−1
@@ -4371,7 +4371,7 @@ retry: · 4370 unmodified lines
43714371 * So we need to block hugepage fault by PG_hwpoison bit check.
43724372 */
43734373 if (unlikely(PageHWPoison(page))) {
4374− ret = VM_FAULT_HWPOISON |
4374+ ret = VM_FAULT_HWPOISON_LARGE |
43754375 VM_FAULT_SET_HINDEX(hstate_index(h));
43764376 goto backout_unlocked;
43774377 }
mm/kasan/init.c+2−1
@@ -64,7 +64,8 @@ static inline bool kasan_pmd_table(pud_t pud) · 63 unmodified lines
6464 return false;
6565 }
6666 #endif
67−pte_t kasan_early_shadow_pte[PTRS_PER_PTE] __page_aligned_bss;
67+pte_t kasan_early_shadow_pte[PTRS_PER_PTE + PTE_HWTABLE_PTRS]
68+ __page_aligned_bss;
6869
6970 static inline bool kasan_pte_table(pmd_t pmd)
7071 {
mm/memory-failure.c+1−1
@@ -1940,7 +1940,7 @@ retry: · 1939 unmodified lines
19401940 goto retry;
19411941 }
19421942 } else if (ret == -EIO) {
1943− pr_info("%s: %#lx: unknown page type: %lx (%pGP)\n",
1943+ pr_info("%s: %#lx: unknown page type: %lx (%pGp)\n",
19441944 __func__, pfn, page->flags, &page->flags);
19451945 }
19461946
mm/mempolicy.c+1−1
@@ -1111,7 +1111,7 @@ int do_migrate_pages(struct mm_struct *mm, const nodemask_t *from, · 1110 unmodified lines
11111111 const nodemask_t *to, int flags)
11121112 {
11131113 int busy = 0;
1114− int err;
1114+ int err = 0;
11151115 nodemask_t tmp;
11161116
11171117 migrate_prep();
mm/page_alloc.c+16−15
@@ -2862,20 +2862,20 @@ __rmqueue(struct zone *zone, unsigned int order, int migratetype, · 2861 unmodified lines
28622862 {
28632863 struct page *page;
28642864
2865−#ifdef CONFIG_CMA
2866− /*
2867− * Balance movable allocations between regular and CMA areas by
2868− * allocating from CMA when over half of the zone's free memory
2869− * is in the CMA area.
2870− */
2871− if (alloc_flags & ALLOC_CMA &&
2872− zone_page_state(zone, NR_FREE_CMA_PAGES) >
2873− zone_page_state(zone, NR_FREE_PAGES) / 2) {
2874− page = __rmqueue_cma_fallback(zone, order);
2875− if (page)
2876− return page;
2865+ if (IS_ENABLED(CONFIG_CMA)) {
2866+ /*
2867+ * Balance movable allocations between regular and CMA areas by
2868+ * allocating from CMA when over half of the zone's free memory
2869+ * is in the CMA area.
2870+ */
2871+ if (alloc_flags & ALLOC_CMA &&
2872+ zone_page_state(zone, NR_FREE_CMA_PAGES) >
2873+ zone_page_state(zone, NR_FREE_PAGES) / 2) {
2874+ page = __rmqueue_cma_fallback(zone, order);
2875+ if (page)
2876+ goto out;
2877+ }
28772878 }
2878−#endif
28792879 retry:
28802880 page = __rmqueue_smallest(zone, order, migratetype);
28812881 if (unlikely(!page)) {
@@ -2886,8 +2886,9 @@ retry: · 4 unmodified lines
28862886 alloc_flags))
28872887 goto retry;
28882888 }
2889−
2890− trace_mm_page_alloc_zone_locked(page, order, migratetype);
2889+out:
2890+ if (page)
2891+ trace_mm_page_alloc_zone_locked(page, order, migratetype);
28912892 return page;
28922893 }
28932894
mm/process_vm_access.c+1−0
@@ -9,6 +9,7 @@ · 8 unmodified lines
99 #include <linux/mm.h>
1010 #include <linux/uio.h>
1111 #include <linux/sched.h>
12+#include <linux/compat.h>
1213 #include <linux/sched/mm.h>
1314 #include <linux/highmem.h>
1415 #include <linux/ptrace.h>
mm/slub.c+1−1
@@ -1973,7 +1973,7 @@ static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n, · 1972 unmodified lines
19731973
19741974 t = acquire_slab(s, n, page, object == NULL, &objects);
19751975 if (!t)
1976− break;
1976+ continue; /* cmpxchg raced */
19771977
19781978 available += objects;
19791979 if (!object) {
mm/vmalloc.c+3−1
@@ -2420,8 +2420,10 @@ void *vmap(struct page **pages, unsigned int count, · 2419 unmodified lines
24202420 return NULL;
24212421 }
24222422
2423− if (flags & VM_MAP_PUT_PAGES)
2423+ if (flags & VM_MAP_PUT_PAGES) {
24242424 area->pages = pages;
2425+ area->nr_pages = count;
2426+ }
24252427 return area->addr;
24262428 }
24272429 EXPORT_SYMBOL(vmap);
mm/vmscan.c+2−0
@@ -1238,6 +1238,8 @@ static unsigned int shrink_page_list(struct list_head *page_list, · 1237 unmodified lines
12381238 if (!PageSwapCache(page)) {
12391239 if (!(sc->gfp_mask & __GFP_IO))
12401240 goto keep_locked;
1241+ if (page_maybe_dma_pinned(page))
1242+ goto keep_locked;
12411243 if (PageTransHuge(page)) {
12421244 /* cannot split THP, skip it */
12431245 if (!can_split_huge_page(page, NULL))
net/bpf/test_run.c+2−1
@@ -272,7 +272,8 @@ int bpf_prog_test_run_raw_tp(struct bpf_prog *prog, · 271 unmodified lines
272272 kattr->test.repeat)
273273 return -EINVAL;
274274
275− if (ctx_size_in < prog->aux->max_ctx_offset)
275+ if (ctx_size_in < prog->aux->max_ctx_offset ||
276+ ctx_size_in > MAX_BPF_FUNC_ARGS * sizeof(u64))
276277 return -EINVAL;
277278
278279 if ((kattr->test.flags & BPF_F_TEST_RUN_ON_CPU) == 0 && cpu != 0)
net/core/dev.c+5−0
@@ -9690,6 +9690,11 @@ static netdev_features_t netdev_fix_features(struct net_device *dev, · 9689 unmodified lines
96909690 }
96919691 }
96929692
9693+ if ((features & NETIF_F_HW_TLS_RX) && !(features & NETIF_F_RXCSUM)) {
9694+ netdev_dbg(dev, "Dropping TLS RX HW offload feature since no RXCSUM feature.\n");
9695+ features &= ~NETIF_F_HW_TLS_RX;
9696+ }
9697+
96939698 return features;
96949699 }
96959700
net/core/devlink.c+2−2
@@ -4146,7 +4146,7 @@ out: · 4145 unmodified lines
41464146 static int devlink_nl_cmd_port_param_get_doit(struct sk_buff *skb,
41474147 struct genl_info *info)
41484148 {
4149− struct devlink_port *devlink_port = info->user_ptr[0];
4149+ struct devlink_port *devlink_port = info->user_ptr[1];
41504150 struct devlink_param_item *param_item;
41514151 struct sk_buff *msg;
41524152 int err;
@@ -4175,7 +4175,7 @@ static int devlink_nl_cmd_port_param_get_doit(struct sk_buff *skb, · 22 unmodified lines
41754175 static int devlink_nl_cmd_port_param_set_doit(struct sk_buff *skb,
41764176 struct genl_info *info)
41774177 {
4178− struct devlink_port *devlink_port = info->user_ptr[0];
4178+ struct devlink_port *devlink_port = info->user_ptr[1];
41794179
41804180 return __devlink_nl_cmd_param_set_doit(devlink_port->devlink,
41814181 devlink_port->index,
net/core/gen_estimator.c+7−4
@@ -80,11 +80,11 @@ static void est_timer(struct timer_list *t) · 79 unmodified lines
8080 u64 rate, brate;
8181
8282 est_fetch_counters(est, &b);
83− brate = (b.bytes - est->last_bytes) << (10 - est->ewma_log - est->intvl_log);
84− brate -= (est->avbps >> est->ewma_log);
83+ brate = (b.bytes - est->last_bytes) << (10 - est->intvl_log);
84+ brate = (brate >> est->ewma_log) - (est->avbps >> est->ewma_log);
8585
86− rate = (b.packets - est->last_packets) << (10 - est->ewma_log - est->intvl_log);
87− rate -= (est->avpps >> est->ewma_log);
86+ rate = (b.packets - est->last_packets) << (10 - est->intvl_log);
87+ rate = (rate >> est->ewma_log) - (est->avpps >> est->ewma_log);
8888
8989 write_seqcount_begin(&est->seq);
9090 est->avbps += brate;
@@ -143,6 +143,9 @@ int gen_new_estimator(struct gnet_stats_basic_packed *bstats, · 52 unmodified lines
143143 if (parm->interval < -2 || parm->interval > 3)
144144 return -EINVAL;
145145
146+ if (parm->ewma_log == 0 || parm->ewma_log >= 31)
147+ return -EINVAL;
148+
146149 est = kzalloc(sizeof(*est), GFP_KERNEL);
147150 if (!est)
148151 return -ENOBUFS;
net/core/skbuff.c+5−1
@@ -437,7 +437,11 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev, unsigned int len, · 436 unmodified lines
437437
438438 len += NET_SKB_PAD;
439439
440− if ((len > SKB_WITH_OVERHEAD(PAGE_SIZE)) ||
440+ /* If requested length is either too small or too big,
441+ * we use kmalloc() for skb->head allocation.
442+ */
443+ if (len <= SKB_WITH_OVERHEAD(1024) ||
444+ len > SKB_WITH_OVERHEAD(PAGE_SIZE) ||
441445 (gfp_mask & (__GFP_DIRECT_RECLAIM | GFP_DMA))) {
442446 skb = __alloc_skb(len, gfp_mask, SKB_ALLOC_RX, NUMA_NO_NODE);
443447 if (!skb)
net/ipv4/inet_connection_sock.c+1−0
@@ -851,6 +851,7 @@ struct sock *inet_csk_clone_lock(const struct sock *sk, · 850 unmodified lines
851851 newicsk->icsk_retransmits = 0;
852852 newicsk->icsk_backoff = 0;
853853 newicsk->icsk_probes_out = 0;
854+ newicsk->icsk_probes_tstamp = 0;
854855
855856 /* Deinitialize accept_queue to trap illegal accesses. */
856857 memset(&newicsk->icsk_accept_queue, 0, sizeof(newicsk->icsk_accept_queue));
net/ipv4/netfilter/ipt_rpfilter.c+1−1
@@ -76,7 +76,7 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par) · 75 unmodified lines
7676 flow.daddr = iph->saddr;
7777 flow.saddr = rpfilter_get_saddr(iph->daddr);
7878 flow.flowi4_mark = info->flags & XT_RPFILTER_VALID_MARK ? skb->mark : 0;
79− flow.flowi4_tos = RT_TOS(iph->tos);
79+ flow.flowi4_tos = iph->tos & IPTOS_RT_MASK;
8080 flow.flowi4_scope = RT_SCOPE_UNIVERSE;
8181 flow.flowi4_oif = l3mdev_master_ifindex_rcu(xt_in(par));
8282
net/ipv4/tcp.c+1−0
@@ -2937,6 +2937,7 @@ int tcp_disconnect(struct sock *sk, int flags) · 2936 unmodified lines
29372937
29382938 icsk->icsk_backoff = 0;
29392939 icsk->icsk_probes_out = 0;
2940+ icsk->icsk_probes_tstamp = 0;
29402941 icsk->icsk_rto = TCP_TIMEOUT_INIT;
29412942 icsk->icsk_rto_min = TCP_RTO_MIN;
29422943 icsk->icsk_delack_max = TCP_DELACK_MAX;
net/ipv4/tcp_input.c+3−3
@@ -3384,6 +3384,7 @@ static void tcp_ack_probe(struct sock *sk) · 3383 unmodified lines
33843384 return;
33853385 if (!after(TCP_SKB_CB(head)->end_seq, tcp_wnd_end(tp))) {
33863386 icsk->icsk_backoff = 0;
3387+ icsk->icsk_probes_tstamp = 0;
33873388 inet_csk_clear_xmit_timer(sk, ICSK_TIME_PROBE0);
33883389 /* Socket must be waked up by subsequent tcp_data_snd_check().
33893390 * This function is not for random using!
@@ -4396,10 +4397,9 @@ static void tcp_rcv_spurious_retrans(struct sock *sk, const struct sk_buff *skb) · 1006 unmodified lines
43964397 * The receiver remembers and reflects via DSACKs. Leverage the
43974398 * DSACK state and change the txhash to re-route speculatively.
43984399 */
4399− if (TCP_SKB_CB(skb)->seq == tcp_sk(sk)->duplicate_sack[0].start_seq) {
4400− sk_rethink_txhash(sk);
4400+ if (TCP_SKB_CB(skb)->seq == tcp_sk(sk)->duplicate_sack[0].start_seq &&
4401+ sk_rethink_txhash(sk))
44014402 NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPDUPLICATEDATAREHASH);
4402− }
44034403 }
44044404
44054405 static void tcp_send_dupack(struct sock *sk, const struct sk_buff *skb)
net/ipv4/tcp_ipv4.c+15−14
@@ -1595,6 +1595,8 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb, · 1594 unmodified lines
15951595 tcp_move_syn(newtp, req);
15961596 ireq->ireq_opt = NULL;
15971597 } else {
1598+ newinet->inet_opt = NULL;
1599+
15981600 if (!req_unhash && found_dup_sk) {
15991601 /* This code path should only be executed in the
16001602 * syncookie case only
@@ -1602,8 +1604,6 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb, · 1 unmodified line
16021604 bh_unlock_sock(newsk);
16031605 sock_put(newsk);
16041606 newsk = NULL;
1605− } else {
1606− newinet->inet_opt = NULL;
16071607 }
16081608 }
16091609 return newsk;
@@ -1760,6 +1760,7 @@ int tcp_v4_early_demux(struct sk_buff *skb) · 150 unmodified lines
17601760 bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb)
17611761 {
17621762 u32 limit = READ_ONCE(sk->sk_rcvbuf) + READ_ONCE(sk->sk_sndbuf);
1763+ u32 tail_gso_size, tail_gso_segs;
17631764 struct skb_shared_info *shinfo;
17641765 const struct tcphdr *th;
17651766 struct tcphdr *thtail;
@@ -1767,6 +1768,7 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb) · 1 unmodified line
17671768 unsigned int hdrlen;
17681769 bool fragstolen;
17691770 u32 gso_segs;
1771+ u32 gso_size;
17701772 int delta;
17711773
17721774 /* In case all data was pulled from skb frags (in __pskb_pull_tail()),
@@ -1792,13 +1794,6 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb) · 19 unmodified lines
17921794 */
17931795 th = (const struct tcphdr *)skb->data;
17941796 hdrlen = th->doff * 4;
1795− shinfo = skb_shinfo(skb);
1796−
1797− if (!shinfo->gso_size)
1798− shinfo->gso_size = skb->len - hdrlen;
1799−
1800− if (!shinfo->gso_segs)
1801− shinfo->gso_segs = 1;
18021797
18031798 tail = sk->sk_backlog.tail;
18041799 if (!tail)
@@ -1821,6 +1816,15 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb) · 16 unmodified lines
18211816 goto no_coalesce;
18221817
18231818 __skb_pull(skb, hdrlen);
1819+
1820+ shinfo = skb_shinfo(skb);
1821+ gso_size = shinfo->gso_size ?: skb->len;
1822+ gso_segs = shinfo->gso_segs ?: 1;
1823+
1824+ shinfo = skb_shinfo(tail);
1825+ tail_gso_size = shinfo->gso_size ?: (tail->len - hdrlen);
1826+ tail_gso_segs = shinfo->gso_segs ?: 1;
1827+
18241828 if (skb_try_coalesce(tail, skb, &fragstolen, &delta)) {
18251829 TCP_SKB_CB(tail)->end_seq = TCP_SKB_CB(skb)->end_seq;
18261830
@@ -1847,11 +1851,8 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb) · 20 unmodified lines
18471851 }
18481852
18491853 /* Not as strict as GRO. We only need to carry mss max value */
1850− skb_shinfo(tail)->gso_size = max(shinfo->gso_size,
1851− skb_shinfo(tail)->gso_size);
1852−
1853− gso_segs = skb_shinfo(tail)->gso_segs + shinfo->gso_segs;
1854− skb_shinfo(tail)->gso_segs = min_t(u32, gso_segs, 0xFFFF);
1854+ shinfo->gso_size = max(gso_size, tail_gso_size);
1855+ shinfo->gso_segs = min_t(u32, gso_segs + tail_gso_segs, 0xFFFF);
18551856
18561857 sk->sk_backlog.len += delta;
18571858 __NET_INC_STATS(sock_net(sk),
net/ipv4/tcp_output.c+1−0
@@ -4084,6 +4084,7 @@ void tcp_send_probe0(struct sock *sk) · 4083 unmodified lines
40844084 /* Cancel probe timer, if it is not required. */
40854085 icsk->icsk_probes_out = 0;
40864086 icsk->icsk_backoff = 0;
4087+ icsk->icsk_probes_tstamp = 0;
40874088 return;
40884089 }
40894090
net/ipv4/tcp_timer.c+15−21
@@ -219,14 +219,8 @@ static int tcp_write_timeout(struct sock *sk) · 218 unmodified lines
219219 int retry_until;
220220
221221 if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) {
222− if (icsk->icsk_retransmits) {
223− dst_negative_advice(sk);
224− } else {
225− sk_rethink_txhash(sk);
226− tp->timeout_rehash++;
227− __NET_INC_STATS(sock_net(sk),
228− LINUX_MIB_TCPTIMEOUTREHASH);
229− }
222+ if (icsk->icsk_retransmits)
223+ __dst_negative_advice(sk);
230224 retry_until = icsk->icsk_syn_retries ? : net->ipv4.sysctl_tcp_syn_retries;
231225 expired = icsk->icsk_retransmits >= retry_until;
232226 } else {
@@ -234,12 +228,7 @@ static int tcp_write_timeout(struct sock *sk) · 1 unmodified line
234228 /* Black hole detection */
235229 tcp_mtu_probing(icsk, sk);
236230
237− dst_negative_advice(sk);
238− } else {
239− sk_rethink_txhash(sk);
240− tp->timeout_rehash++;
241− __NET_INC_STATS(sock_net(sk),
242− LINUX_MIB_TCPTIMEOUTREHASH);
231+ __dst_negative_advice(sk);
243232 }
244233
245234 retry_until = net->ipv4.sysctl_tcp_retries2;
@@ -270,6 +259,11 @@ static int tcp_write_timeout(struct sock *sk) · 24 unmodified lines
270259 return 1;
271260 }
272261
262+ if (sk_rethink_txhash(sk)) {
263+ tp->timeout_rehash++;
264+ __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPTIMEOUTREHASH);
265+ }
266+
273267 return 0;
274268 }
275269
@@ -349,6 +343,7 @@ static void tcp_probe_timer(struct sock *sk) · 73 unmodified lines
349343
350344 if (tp->packets_out || !skb) {
351345 icsk->icsk_probes_out = 0;
346+ icsk->icsk_probes_tstamp = 0;
352347 return;
353348 }
354349
@@ -360,13 +355,12 @@ static void tcp_probe_timer(struct sock *sk) · 5 unmodified lines
360355 * corresponding system limit. We also implement similar policy when
361356 * we use RTO to probe window in tcp_retransmit_timer().
362357 */
363− if (icsk->icsk_user_timeout) {
364− u32 elapsed = tcp_model_timeout(sk, icsk->icsk_probes_out,
365− tcp_probe0_base(sk));
366−
367− if (elapsed >= icsk->icsk_user_timeout)
368− goto abort;
369− }
358+ if (!icsk->icsk_probes_tstamp)
359+ icsk->icsk_probes_tstamp = tcp_jiffies32;
360+ else if (icsk->icsk_user_timeout &&
361+ (s32)(tcp_jiffies32 - icsk->icsk_probes_tstamp) >=
362+ msecs_to_jiffies(icsk->icsk_user_timeout))
363+ goto abort;
370364
371365 max_probes = sock_net(sk)->ipv4.sysctl_tcp_retries2;
372366 if (sock_flag(sk, SOCK_DEAD)) {
net/ipv4/udp.c+2−1
@@ -2555,7 +2555,8 @@ int udp_v4_early_demux(struct sk_buff *skb) · 2554 unmodified lines
25552555 */
25562556 if (!inet_sk(sk)->inet_daddr && in_dev)
25572557 return ip_mc_validate_source(skb, iph->daddr,
2558− iph->saddr, iph->tos,
2558+ iph->saddr,
2559+ iph->tos & IPTOS_RT_MASK,
25592560 skb->dev, in_dev, &itag);
25602561 }
25612562 return 0;
net/ipv6/addrconf.c+2−1
@@ -2467,8 +2467,9 @@ static void addrconf_add_mroute(struct net_device *dev) · 2466 unmodified lines
24672467 .fc_ifindex = dev->ifindex,
24682468 .fc_dst_len = 8,
24692469 .fc_flags = RTF_UP,
2470− .fc_type = RTN_UNICAST,
2470+ .fc_type = RTN_MULTICAST,
24712471 .fc_nlinfo.nl_net = dev_net(dev),
2472+ .fc_protocol = RTPROT_KERNEL,
24722473 };
24732474
24742475 ipv6_addr_set(&cfg.fc_dst, htonl(0xFF000000), 0, 0, 0);
net/mac80211/debugfs.c+20−24
@@ -120,18 +120,17 @@ static ssize_t aqm_write(struct file *file, · 119 unmodified lines
120120 {
121121 struct ieee80211_local *local = file->private_data;
122122 char buf[100];
123− size_t len;
124123
125− if (count > sizeof(buf))
124+ if (count >= sizeof(buf))
126125 return -EINVAL;
127126
128127 if (copy_from_user(buf, user_buf, count))
129128 return -EFAULT;
130129
131− buf[sizeof(buf) - 1] = '\0';
132− len = strlen(buf);
133− if (len > 0 && buf[len-1] == '\n')
134− buf[len-1] = 0;
130+ if (count && buf[count - 1] == '\n')
131+ buf[count - 1] = '\0';
132+ else
133+ buf[count] = '\0';
135134
136135 if (sscanf(buf, "fq_limit %u", &local->fq.limit) == 1)
137136 return count;
@@ -177,18 +176,17 @@ static ssize_t airtime_flags_write(struct file *file, · 39 unmodified lines
177176 {
178177 struct ieee80211_local *local = file->private_data;
179178 char buf[16];
180− size_t len;
181179
182− if (count > sizeof(buf))
180+ if (count >= sizeof(buf))
183181 return -EINVAL;
184182
185183 if (copy_from_user(buf, user_buf, count))
186184 return -EFAULT;
187185
188− buf[sizeof(buf) - 1] = 0;
189− len = strlen(buf);
190− if (len > 0 && buf[len - 1] == '\n')
191− buf[len - 1] = 0;
186+ if (count && buf[count - 1] == '\n')
187+ buf[count - 1] = '\0';
188+ else
189+ buf[count] = '\0';
192190
193191 if (kstrtou16(buf, 0, &local->airtime_flags))
194192 return -EINVAL;
@@ -237,20 +235,19 @@ static ssize_t aql_txq_limit_write(struct file *file, · 42 unmodified lines
237235 {
238236 struct ieee80211_local *local = file->private_data;
239237 char buf[100];
240− size_t len;
241238 u32 ac, q_limit_low, q_limit_high, q_limit_low_old, q_limit_high_old;
242239 struct sta_info *sta;
243240
244− if (count > sizeof(buf))
241+ if (count >= sizeof(buf))
245242 return -EINVAL;
246243
247244 if (copy_from_user(buf, user_buf, count))
248245 return -EFAULT;
249246
250− buf[sizeof(buf) - 1] = 0;
251− len = strlen(buf);
252− if (len > 0 && buf[len - 1] == '\n')
253− buf[len - 1] = 0;
247+ if (count && buf[count - 1] == '\n')
248+ buf[count - 1] = '\0';
249+ else
250+ buf[count] = '\0';
254251
255252 if (sscanf(buf, "%u %u %u", &ac, &q_limit_low, &q_limit_high) != 3)
256253 return -EINVAL;
@@ -306,18 +303,17 @@ static ssize_t force_tx_status_write(struct file *file, · 49 unmodified lines
306303 {
307304 struct ieee80211_local *local = file->private_data;
308305 char buf[3];
309− size_t len;
310306
311− if (count > sizeof(buf))
307+ if (count >= sizeof(buf))
312308 return -EINVAL;
313309
314310 if (copy_from_user(buf, user_buf, count))
315311 return -EFAULT;
316312
317− buf[sizeof(buf) - 1] = '\0';
318− len = strlen(buf);
319− if (len > 0 && buf[len - 1] == '\n')
320− buf[len - 1] = 0;
313+ if (count && buf[count - 1] == '\n')
314+ buf[count - 1] = '\0';
315+ else
316+ buf[count] = '\0';
321317
322318 if (buf[0] == '0' && buf[1] == '\0')
323319 local->force_tx_status = 0;
net/mac80211/rx.c+2−0
@@ -4176,6 +4176,8 @@ void ieee80211_check_fast_rx(struct sta_info *sta) · 4175 unmodified lines
41764176
41774177 rcu_read_lock();
41784178 key = rcu_dereference(sta->ptk[sta->ptk_idx]);
4179+ if (!key)
4180+ key = rcu_dereference(sdata->default_unicast_key);
41794181 if (key) {
41804182 switch (key->conf.cipher) {
41814183 case WLAN_CIPHER_SUITE_TKIP:
net/mac80211/tx.c+17−14
@@ -649,7 +649,7 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx) · 648 unmodified lines
649649 if (!skip_hw && tx->key &&
650650 tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
651651 info->control.hw_key = &tx->key->conf;
652− } else if (!ieee80211_is_mgmt(hdr->frame_control) && tx->sta &&
652+ } else if (ieee80211_is_data_present(hdr->frame_control) && tx->sta &&
653653 test_sta_flag(tx->sta, WLAN_STA_USES_ENCRYPTION)) {
654654 return TX_DROP;
655655 }
@@ -3809,7 +3809,7 @@ void __ieee80211_schedule_txq(struct ieee80211_hw *hw, · 3153 unmodified lines
38093809 * get immediately moved to the back of the list on the next
38103810 * call to ieee80211_next_txq().
38113811 */
3812− if (txqi->txq.sta &&
3812+ if (txqi->txq.sta && local->airtime_flags &&
38133813 wiphy_ext_feature_isset(local->hw.wiphy,
38143814 NL80211_EXT_FEATURE_AIRTIME_FAIRNESS))
38153815 list_add(&txqi->schedule_order,
@@ -4251,7 +4251,6 @@ netdev_tx_t ieee80211_subif_start_xmit_8023(struct sk_buff *skb, · 435 unmodified lines
42514251 struct ethhdr *ehdr = (struct ethhdr *)skb->data;
42524252 struct ieee80211_key *key;
42534253 struct sta_info *sta;
4254− bool offload = true;
42554254
42564255 if (unlikely(skb->len < ETH_HLEN)) {
42574256 kfree_skb(skb);
@@ -4267,18 +4266,22 @@ netdev_tx_t ieee80211_subif_start_xmit_8023(struct sk_buff *skb, · 9 unmodified lines
42674266
42684267 if (unlikely(IS_ERR_OR_NULL(sta) || !sta->uploaded ||
42694268 !test_sta_flag(sta, WLAN_STA_AUTHORIZED) ||
4270− sdata->control_port_protocol == ehdr->h_proto))
4271− offload = false;
4272− else if ((key = rcu_dereference(sta->ptk[sta->ptk_idx])) &&
4273− (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) ||
4274− key->conf.cipher == WLAN_CIPHER_SUITE_TKIP))
4275− offload = false;
4276−
4277− if (offload)
4278− ieee80211_8023_xmit(sdata, dev, sta, key, skb);
4279− else
4280− ieee80211_subif_start_xmit(skb, dev);
4269+ sdata->control_port_protocol == ehdr->h_proto))
4270+ goto skip_offload;
4271+
4272+ key = rcu_dereference(sta->ptk[sta->ptk_idx]);
4273+ if (!key)
4274+ key = rcu_dereference(sdata->default_unicast_key);
4275+
4276+ if (key && (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE) ||
4277+ key->conf.cipher == WLAN_CIPHER_SUITE_TKIP))
4278+ goto skip_offload;
4279+
4280+ ieee80211_8023_xmit(sdata, dev, sta, key, skb);
4281+ goto out;
42814282
4283+skip_offload:
4284+ ieee80211_subif_start_xmit(skb, dev);
42824285 out:
42834286 rcu_read_unlock();
42844287
net/nfc/nci/core.c+1−1
@@ -508,7 +508,7 @@ static int nci_open_device(struct nci_dev *ndev) · 507 unmodified lines
508508 };
509509 unsigned long opt = 0;
510510
511− if (!(ndev->nci_ver & NCI_VER_2_MASK))
511+ if (ndev->nci_ver & NCI_VER_2_MASK)
512512 opt = (unsigned long)&nci_init_v2_cmd;
513513
514514 rc = __nci_request(ndev, nci_init_req, opt,
net/sched/cls_flower.c+13−9
@@ -1272,6 +1272,10 @@ static int fl_set_enc_opt(struct nlattr **tb, struct fl_flow_key *key, · 1271 unmodified lines
12721272
12731273 nla_opt_msk = nla_data(tb[TCA_FLOWER_KEY_ENC_OPTS_MASK]);
12741274 msk_depth = nla_len(tb[TCA_FLOWER_KEY_ENC_OPTS_MASK]);
1275+ if (!nla_ok(nla_opt_msk, msk_depth)) {
1276+ NL_SET_ERR_MSG(extack, "Invalid nested attribute for masks");
1277+ return -EINVAL;
1278+ }
12751279 }
12761280
12771281 nla_for_each_attr(nla_opt_key, nla_enc_key,
@@ -1307,9 +1311,6 @@ static int fl_set_enc_opt(struct nlattr **tb, struct fl_flow_key *key, · 29 unmodified lines
13071311 NL_SET_ERR_MSG(extack, "Key and mask miss aligned");
13081312 return -EINVAL;
13091313 }
1310−
1311− if (msk_depth)
1312− nla_opt_msk = nla_next(nla_opt_msk, &msk_depth);
13131314 break;
13141315 case TCA_FLOWER_KEY_ENC_OPTS_VXLAN:
13151316 if (key->enc_opts.dst_opt_type) {
@@ -1340,9 +1341,6 @@ static int fl_set_enc_opt(struct nlattr **tb, struct fl_flow_key *key, · 24 unmodified lines
13401341 NL_SET_ERR_MSG(extack, "Key and mask miss aligned");
13411342 return -EINVAL;
13421343 }
1343−
1344− if (msk_depth)
1345− nla_opt_msk = nla_next(nla_opt_msk, &msk_depth);
13461344 break;
13471345 case TCA_FLOWER_KEY_ENC_OPTS_ERSPAN:
13481346 if (key->enc_opts.dst_opt_type) {
@@ -1373,14 +1371,20 @@ static int fl_set_enc_opt(struct nlattr **tb, struct fl_flow_key *key, · 24 unmodified lines
13731371 NL_SET_ERR_MSG(extack, "Key and mask miss aligned");
13741372 return -EINVAL;
13751373 }
1376−
1377− if (msk_depth)
1378− nla_opt_msk = nla_next(nla_opt_msk, &msk_depth);
13791374 break;
13801375 default:
13811376 NL_SET_ERR_MSG(extack, "Unknown tunnel option type");
13821377 return -EINVAL;
13831378 }
1379+
1380+ if (!msk_depth)
1381+ continue;
1382+
1383+ if (!nla_ok(nla_opt_msk, msk_depth)) {
1384+ NL_SET_ERR_MSG(extack, "A mask attribute is invalid");
1385+ return -EINVAL;
1386+ }
1387+ nla_opt_msk = nla_next(nla_opt_msk, &msk_depth);
13841388 }
13851389
13861390 return 0;
net/sched/cls_tcindex.c+6−2
@@ -366,9 +366,13 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base, · 365 unmodified lines
366366 if (tb[TCA_TCINDEX_MASK])
367367 cp->mask = nla_get_u16(tb[TCA_TCINDEX_MASK]);
368368
369− if (tb[TCA_TCINDEX_SHIFT])
369+ if (tb[TCA_TCINDEX_SHIFT]) {
370370 cp->shift = nla_get_u32(tb[TCA_TCINDEX_SHIFT]);
371−
371+ if (cp->shift > 16) {
372+ err = -EINVAL;
373+ goto errout;
374+ }
375+ }
372376 if (!cp->hash) {
373377 /* Hash not specified, use perfect hash if the upper limit
374378 * of the hashing index is below the threshold.
net/sched/sch_api.c+2−1
@@ -412,7 +412,8 @@ struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, · 411 unmodified lines
412412 {
413413 struct qdisc_rate_table *rtab;
414414
415− if (tab == NULL || r->rate == 0 || r->cell_log == 0 ||
415+ if (tab == NULL || r->rate == 0 ||
416+ r->cell_log == 0 || r->cell_log >= 32 ||
416417 nla_len(tab) != TC_RTAB_SIZE) {
417418 NL_SET_ERR_MSG(extack, "Invalid rate table parameters for searching");
418419 return NULL;
net/sunrpc/svc_xprt.c+2−2
@@ -857,6 +857,7 @@ int svc_recv(struct svc_rqst *rqstp, long timeout) · 856 unmodified lines
857857 err = -EAGAIN;
858858 if (len <= 0)
859859 goto out_release;
860+ trace_svc_xdr_recvfrom(&rqstp->rq_arg);
860861
861862 clear_bit(XPT_OLD, &xprt->xpt_flags);
862863
@@ -866,7 +867,6 @@ int svc_recv(struct svc_rqst *rqstp, long timeout) · 3 unmodified lines
866867
867868 if (serv->sv_stats)
868869 serv->sv_stats->netcnt++;
869− trace_svc_xdr_recvfrom(rqstp, &rqstp->rq_arg);
870870 return len;
871871 out_release:
872872 rqstp->rq_res.len = 0;
@@ -904,7 +904,7 @@ int svc_send(struct svc_rqst *rqstp) · 31 unmodified lines
904904 xb->len = xb->head[0].iov_len +
905905 xb->page_len +
906906 xb->tail[0].iov_len;
907− trace_svc_xdr_sendto(rqstp, xb);
907+ trace_svc_xdr_sendto(rqstp->rq_xid, xb);
908908 trace_svc_stats_latency(rqstp);
909909
910910 len = xprt->xpt_ops->xpo_sendto(rqstp);
net/wireless/reg.c+10−1
@@ -5,7 +5,7 @@ · 4 unmodified lines
55 * Copyright 2008-2011 Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
66 * Copyright 2013-2014 Intel Mobile Communications GmbH
77 * Copyright 2017 Intel Deutschland GmbH
8− * Copyright (C) 2018 - 2019 Intel Corporation
8+ * Copyright (C) 2018 - 2021 Intel Corporation
99 *
1010 * Permission to use, copy, modify, and/or distribute this software for any
1111 * purpose with or without fee is hereby granted, provided that the above
@@ -139,6 +139,11 @@ static const struct ieee80211_regdomain *get_cfg80211_regdom(void) · 127 unmodified lines
139139 return rcu_dereference_rtnl(cfg80211_regdomain);
140140 }
141141
142+/*
143+ * Returns the regulatory domain associated with the wiphy.
144+ *
145+ * Requires either RTNL or RCU protection
146+ */
142147 const struct ieee80211_regdomain *get_wiphy_regdom(struct wiphy *wiphy)
143148 {
144149 return rcu_dereference_rtnl(wiphy->regd);
@@ -2571,9 +2576,13 @@ void wiphy_apply_custom_regulatory(struct wiphy *wiphy, · 2426 unmodified lines
25712576 if (IS_ERR(new_regd))
25722577 return;
25732578
2579+ rtnl_lock();
2580+
25742581 tmp = get_wiphy_regdom(wiphy);
25752582 rcu_assign_pointer(wiphy->regd, new_regd);
25762583 rcu_free_regdom(tmp);
2584+
2585+ rtnl_unlock();
25772586 }
25782587 EXPORT_SYMBOL(wiphy_apply_custom_regulatory);
25792588
net/xdp/xsk.c+2−2
@@ -108,9 +108,9 @@ EXPORT_SYMBOL(xsk_get_pool_from_qid); · 107 unmodified lines
108108
109109 void xsk_clear_pool_at_qid(struct net_device *dev, u16 queue_id)
110110 {
111− if (queue_id < dev->real_num_rx_queues)
111+ if (queue_id < dev->num_rx_queues)
112112 dev->_rx[queue_id].pool = NULL;
113− if (queue_id < dev->real_num_tx_queues)
113+ if (queue_id < dev->num_tx_queues)
114114 dev->_tx[queue_id].pool = NULL;
115115 }
116116
security/lsm_audit.c+5−2
@@ -275,7 +275,9 @@ static void dump_common_audit_data(struct audit_buffer *ab, · 274 unmodified lines
275275 struct inode *inode;
276276
277277 audit_log_format(ab, " name=");
278+ spin_lock(&a->u.dentry->d_lock);
278279 audit_log_untrustedstring(ab, a->u.dentry->d_name.name);
280+ spin_unlock(&a->u.dentry->d_lock);
279281
280282 inode = d_backing_inode(a->u.dentry);
281283 if (inode) {
@@ -293,8 +295,9 @@ static void dump_common_audit_data(struct audit_buffer *ab, · 11 unmodified lines
293295 dentry = d_find_alias(inode);
294296 if (dentry) {
295297 audit_log_format(ab, " name=");
296− audit_log_untrustedstring(ab,
297− dentry->d_name.name);
298+ spin_lock(&dentry->d_lock);
299+ audit_log_untrustedstring(ab, dentry->d_name.name);
300+ spin_unlock(&dentry->d_lock);
298301 dput(dentry);
299302 }
300303 audit_log_format(ab, " dev=");
tools/bootconfig/scripts/bconf2ftrace.sh+1−0
@@ -152,6 +152,7 @@ setup_instance() { # [instance] · 151 unmodified lines
152152 set_array_of ${instance}.options ${instancedir}/trace_options
153153 set_value_of ${instance}.trace_clock ${instancedir}/trace_clock
154154 set_value_of ${instance}.cpumask ${instancedir}/tracing_cpumask
155+ set_value_of ${instance}.tracing_on ${instancedir}/tracing_on
155156 set_value_of ${instance}.tracer ${instancedir}/current_tracer
156157 set_array_of ${instance}.ftrace.filters \
157158 ${instancedir}/set_ftrace_filter
tools/bootconfig/scripts/ftrace2bconf.sh+4−0
@@ -221,6 +221,10 @@ instance_options() { # [instance-name] · 220 unmodified lines
221221 if [ `echo $val | sed -e s/f//g`x != x ]; then
222222 emit_kv $PREFIX.cpumask = $val
223223 fi
224+ val=`cat $INSTANCE/tracing_on`
225+ if [ `echo $val | sed -e s/f//g`x != x ]; then
226+ emit_kv $PREFIX.tracing_on = $val
227+ fi
224228
225229 val=
226230 for i in `cat $INSTANCE/set_event`; do
tools/include/linux/build_bug.h+0−5
@@ -79,9 +79,4 @@ · 78 unmodified lines
7979 #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
8080 #endif // static_assert
8181
82−#ifdef __GENKSYMS__
83−/* genksyms gets confused by _Static_assert */
84−#define _Static_assert(expr, ...)
85−#endif
86−
8782 #endif /* _LINUX_BUILD_BUG_H */
tools/include/uapi/linux/kvm.h+2−0
@@ -251,6 +251,7 @@ struct kvm_hyperv_exit { · 250 unmodified lines
251251 #define KVM_EXIT_X86_RDMSR 29
252252 #define KVM_EXIT_X86_WRMSR 30
253253 #define KVM_EXIT_DIRTY_RING_FULL 31
254+#define KVM_EXIT_AP_RESET_HOLD 32
254255
255256 /* For KVM_EXIT_INTERNAL_ERROR */
256257 /* Emulate instruction failed. */
@@ -573,6 +574,7 @@ struct kvm_vapic_addr { · 316 unmodified lines
573574 #define KVM_MP_STATE_CHECK_STOP 6
574575 #define KVM_MP_STATE_OPERATING 7
575576 #define KVM_MP_STATE_LOAD 8
577+#define KVM_MP_STATE_AP_RESET_HOLD 9
576578
577579 struct kvm_mp_state {
578580 __u32 mp_state;
tools/lib/bpf/btf.c+0−5
@@ -240,11 +240,6 @@ static int btf_parse_hdr(struct btf *btf) · 239 unmodified lines
240240 }
241241
242242 meta_left = btf->raw_size - sizeof(*hdr);
243− if (!meta_left) {
244− pr_debug("BTF has no data\n");
245− return -EINVAL;
246− }
247−
248243 if (meta_left < hdr->str_off + hdr->str_len) {
249244 pr_debug("Invalid BTF total size:%u\n", btf->raw_size);
250245 return -EINVAL;
tools/lib/perf/tests/test-cpumap.c+1−1
@@ -27,5 +27,5 @@ int main(int argc, char **argv) · 26 unmodified lines
2727 perf_cpu_map__put(cpus);
2828
2929 __T_END;
30− return 0;
30+ return tests_failed == 0 ? 0 : -1;
3131 }
tools/lib/perf/tests/test-evlist.c+4−3
@@ -208,13 +208,13 @@ static int test_mmap_thread(void) · 207 unmodified lines
208208 char path[PATH_MAX];
209209 int id, err, pid, go_pipe[2];
210210 union perf_event *event;
211− char bf;
212211 int count = 0;
213212
214213 snprintf(path, PATH_MAX, "%s/kernel/debug/tracing/events/syscalls/sys_enter_prctl/id",
215214 sysfs__mountpoint());
216215
217216 if (filename__read_int(path, &id)) {
217+ tests_failed++;
218218 fprintf(stderr, "error: failed to get tracepoint id: %s\n", path);
219219 return -1;
220220 }
@@ -229,6 +229,7 @@ static int test_mmap_thread(void) · 8 unmodified lines
229229 pid = fork();
230230 if (!pid) {
231231 int i;
232+ char bf;
232233
233234 read(go_pipe[0], &bf, 1);
234235
@@ -266,7 +267,7 @@ static int test_mmap_thread(void) · 31 unmodified lines
266267 perf_evlist__enable(evlist);
267268
268269 /* kick the child and wait for it to finish */
269− write(go_pipe[1], &bf, 1);
270+ write(go_pipe[1], "A", 1);
270271 waitpid(pid, NULL, 0);
271272
272273 /*
@@ -409,5 +410,5 @@ int main(int argc, char **argv) · 136 unmodified lines
409410 test_mmap_cpus();
410411
411412 __T_END;
412− return 0;
413+ return tests_failed == 0 ? 0 : -1;
413414 }
tools/lib/perf/tests/test-evsel.c+1−1
@@ -131,5 +131,5 @@ int main(int argc, char **argv) · 130 unmodified lines
131131 test_stat_thread_enable();
132132
133133 __T_END;
134− return 0;
134+ return tests_failed == 0 ? 0 : -1;
135135 }
tools/lib/perf/tests/test-threadmap.c+1−1
@@ -27,5 +27,5 @@ int main(int argc, char **argv) · 26 unmodified lines
2727 perf_thread_map__put(threads);
2828
2929 __T_END;
30− return 0;
30+ return tests_failed == 0 ? 0 : -1;
3131 }
tools/perf/examples/bpf/5sec.c+1−1
@@ -39,7 +39,7 @@ · 38 unmodified lines
3939 Copyright (C) 2018 Red Hat, Inc., Arnaldo Carvalho de Melo <acme@redhat.com>
4040 */
4141
42−#include <bpf/bpf.h>
42+#include <bpf.h>
4343
4444 #define NSEC_PER_SEC 1000000000L
4545
tools/perf/tests/shell/stat+shadow_stat.sh+14−16
@@ -9,31 +9,29 @@ perf stat -a true > /dev/null 2>&1 || exit 2 · 8 unmodified lines
99
1010 test_global_aggr()
1111 {
12− local cyc
13−
1412 perf stat -a --no-big-num -e cycles,instructions sleep 1 2>&1 | \
1513 grep -e cycles -e instructions | \
1614 while read num evt hash ipc rest
1715 do
1816 # skip not counted events
19− if [[ $num == "<not" ]]; then
17+ if [ "$num" = "<not" ]; then
2018 continue
2119 fi
2220
2321 # save cycles count
24− if [[ $evt == "cycles" ]]; then
22+ if [ "$evt" = "cycles" ]; then
2523 cyc=$num
2624 continue
2725 fi
2826
2927 # skip if no cycles
30− if [[ -z $cyc ]]; then
28+ if [ -z "$cyc" ]; then
3129 continue
3230 fi
3331
3432 # use printf for rounding and a leading zero
35− local res=`printf "%.2f" $(echo "scale=6; $num / $cyc" | bc -q)`
36− if [[ $ipc != $res ]]; then
33+ res=`printf "%.2f" $(echo "scale=6; $num / $cyc" | bc -q)`
34+ if [ "$ipc" != "$res" ]; then
3735 echo "IPC is different: $res != $ipc ($num / $cyc)"
3836 exit 1
3937 fi
@@ -42,32 +40,32 @@ test_global_aggr() · 2 unmodified lines
4240
4341 test_no_aggr()
4442 {
45− declare -A results
46−
4743 perf stat -a -A --no-big-num -e cycles,instructions sleep 1 2>&1 | \
4844 grep ^CPU | \
4945 while read cpu num evt hash ipc rest
5046 do
5147 # skip not counted events
52− if [[ $num == "<not" ]]; then
48+ if [ "$num" = "<not" ]; then
5349 continue
5450 fi
5551
5652 # save cycles count
57− if [[ $evt == "cycles" ]]; then
58− results[$cpu]=$num
53+ if [ "$evt" = "cycles" ]; then
54+ results="$results $cpu:$num"
5955 continue
6056 fi
6157
58+ cyc=${results##* $cpu:}
59+ cyc=${cyc%% *}
60+
6261 # skip if no cycles
63− local cyc=${results[$cpu]}
64− if [[ -z $cyc ]]; then
62+ if [ -z "$cyc" ]; then
6563 continue
6664 fi
6765
6866 # use printf for rounding and a leading zero
69− local res=`printf "%.2f" $(echo "scale=6; $num / $cyc" | bc -q)`
70− if [[ $ipc != $res ]]; then
67+ res=`printf "%.2f" $(echo "scale=6; $num / $cyc" | bc -q)`
68+ if [ "$ipc" != "$res" ]; then
7169 echo "IPC is different for $cpu: $res != $ipc ($num / $cyc)"
7270 exit 1
7371 fi
tools/perf/util/header.c+8−0
@@ -3323,6 +3323,14 @@ int perf_session__write_header(struct perf_session *session, · 3322 unmodified lines
33233323 attr_offset = lseek(ff.fd, 0, SEEK_CUR);
33243324
33253325 evlist__for_each_entry(evlist, evsel) {
3326+ if (evsel->core.attr.size < sizeof(evsel->core.attr)) {
3327+ /*
3328+ * We are likely in "perf inject" and have read
3329+ * from an older file. Update attr size so that
3330+ * reader gets the right offset to the ids.
3331+ */
3332+ evsel->core.attr.size = sizeof(evsel->core.attr);
3333+ }
33263334 f_attr = (struct perf_file_attr){
33273335 .attr = evsel->core.attr,
33283336 .ids = {
tools/perf/util/machine.c+2−2
@@ -2980,7 +2980,7 @@ int machines__for_each_thread(struct machines *machines, · 2979 unmodified lines
29802980
29812981 pid_t machine__get_current_tid(struct machine *machine, int cpu)
29822982 {
2983− int nr_cpus = min(machine->env->nr_cpus_online, MAX_NR_CPUS);
2983+ int nr_cpus = min(machine->env->nr_cpus_avail, MAX_NR_CPUS);
29842984
29852985 if (cpu < 0 || cpu >= nr_cpus || !machine->current_tid)
29862986 return -1;
@@ -2992,7 +2992,7 @@ int machine__set_current_tid(struct machine *machine, int cpu, pid_t pid, · 5 unmodified lines
29922992 pid_t tid)
29932993 {
29942994 struct thread *thread;
2995− int nr_cpus = min(machine->env->nr_cpus_online, MAX_NR_CPUS);
2995+ int nr_cpus = min(machine->env->nr_cpus_avail, MAX_NR_CPUS);
29962996
29972997 if (cpu < 0)
29982998 return -EINVAL;
tools/perf/util/session.c+1−1
@@ -2404,7 +2404,7 @@ int perf_session__cpu_bitmap(struct perf_session *session, · 2403 unmodified lines
24042404 {
24052405 int i, err = -1;
24062406 struct perf_cpu_map *map;
2407− int nr_cpus = min(session->header.env.nr_cpus_online, MAX_NR_CPUS);
2407+ int nr_cpus = min(session->header.env.nr_cpus_avail, MAX_NR_CPUS);
24082408
24092409 for (i = 0; i < PERF_TYPE_MAX; ++i) {
24102410 struct evsel *evsel;
tools/perf/util/stat-shadow.c+189−177
@@ -8,6 +8,7 @@ · 7 unmodified lines
88 #include "evlist.h"
99 #include "expr.h"
1010 #include "metricgroup.h"
11+#include "cgroup.h"
1112 #include <linux/zalloc.h>
1213
1314 /*
@@ -28,6 +29,7 @@ struct saved_value { · 14 unmodified lines
2829 enum stat_type type;
2930 int ctx;
3031 int cpu;
32+ struct cgroup *cgrp;
3133 struct runtime_stat *stat;
3234 struct stats stats;
3335 u64 metric_total;
@@ -57,6 +59,9 @@ static int saved_value_cmp(struct rb_node *rb_node, const void *entry) · 23 unmodified lines
5759 if (a->ctx != b->ctx)
5860 return a->ctx - b->ctx;
5961
62+ if (a->cgrp != b->cgrp)
63+ return (char *)a->cgrp < (char *)b->cgrp ? -1 : +1;
64+
6065 if (a->evsel == NULL && b->evsel == NULL) {
6166 if (a->stat == b->stat)
6267 return 0;
@@ -100,7 +105,8 @@ static struct saved_value *saved_value_lookup(struct evsel *evsel, · 37 unmodified lines
100105 bool create,
101106 enum stat_type type,
102107 int ctx,
103− struct runtime_stat *st)
108+ struct runtime_stat *st,
109+ struct cgroup *cgrp)
104110 {
105111 struct rblist *rblist;
106112 struct rb_node *nd;
@@ -110,10 +116,15 @@ static struct saved_value *saved_value_lookup(struct evsel *evsel, · 3 unmodified lines
110116 .type = type,
111117 .ctx = ctx,
112118 .stat = st,
119+ .cgrp = cgrp,
113120 };
114121
115122 rblist = &st->value_list;
116123
124+ /* don't use context info for clock events */
125+ if (type == STAT_NSECS)
126+ dm.ctx = 0;
127+
117128 nd = rblist__find(rblist, &dm);
118129 if (nd)
119130 return container_of(nd, struct saved_value, rb_node);
@@ -191,12 +202,18 @@ void perf_stat__reset_shadow_per_stat(struct runtime_stat *st) · 71 unmodified lines
191202 reset_stat(st);
192203 }
193204
205+struct runtime_stat_data {
206+ int ctx;
207+ struct cgroup *cgrp;
208+};
209+
194210 static void update_runtime_stat(struct runtime_stat *st,
195211 enum stat_type type,
196− int ctx, int cpu, u64 count)
212+ int cpu, u64 count,
213+ struct runtime_stat_data *rsd)
197214 {
198− struct saved_value *v = saved_value_lookup(NULL, cpu, true,
199− type, ctx, st);
215+ struct saved_value *v = saved_value_lookup(NULL, cpu, true, type,
216+ rsd->ctx, st, rsd->cgrp);
200217
201218 if (v)
202219 update_stats(&v->stats, count);
@@ -210,82 +227,86 @@ static void update_runtime_stat(struct runtime_stat *st, · 7 unmodified lines
210227 void perf_stat__update_shadow_stats(struct evsel *counter, u64 count,
211228 int cpu, struct runtime_stat *st)
212229 {
213− int ctx = evsel_context(counter);
214230 u64 count_ns = count;
215231 struct saved_value *v;
232+ struct runtime_stat_data rsd = {
233+ .ctx = evsel_context(counter),
234+ .cgrp = counter->cgrp,
235+ };
216236
217237 count *= counter->scale;
218238
219239 if (evsel__is_clock(counter))
220− update_runtime_stat(st, STAT_NSECS, 0, cpu, count_ns);
240+ update_runtime_stat(st, STAT_NSECS, cpu, count_ns, &rsd);
221241 else if (evsel__match(counter, HARDWARE, HW_CPU_CYCLES))
222− update_runtime_stat(st, STAT_CYCLES, ctx, cpu, count);
242+ update_runtime_stat(st, STAT_CYCLES, cpu, count, &rsd);
223243 else if (perf_stat_evsel__is(counter, CYCLES_IN_TX))
224− update_runtime_stat(st, STAT_CYCLES_IN_TX, ctx, cpu, count);
244+ update_runtime_stat(st, STAT_CYCLES_IN_TX, cpu, count, &rsd);
225245 else if (perf_stat_evsel__is(counter, TRANSACTION_START))
226− update_runtime_stat(st, STAT_TRANSACTION, ctx, cpu, count);
246+ update_runtime_stat(st, STAT_TRANSACTION, cpu, count, &rsd);
227247 else if (perf_stat_evsel__is(counter, ELISION_START))
228− update_runtime_stat(st, STAT_ELISION, ctx, cpu, count);
248+ update_runtime_stat(st, STAT_ELISION, cpu, count, &rsd);
229249 else if (perf_stat_evsel__is(counter, TOPDOWN_TOTAL_SLOTS))
230250 update_runtime_stat(st, STAT_TOPDOWN_TOTAL_SLOTS,
231− ctx, cpu, count);
251+ cpu, count, &rsd);
232252 else if (perf_stat_evsel__is(counter, TOPDOWN_SLOTS_ISSUED))
233253 update_runtime_stat(st, STAT_TOPDOWN_SLOTS_ISSUED,
234− ctx, cpu, count);
254+ cpu, count, &rsd);
235255 else if (perf_stat_evsel__is(counter, TOPDOWN_SLOTS_RETIRED))
236256 update_runtime_stat(st, STAT_TOPDOWN_SLOTS_RETIRED,
237− ctx, cpu, count);
257+ cpu, count, &rsd);
238258 else if (perf_stat_evsel__is(counter, TOPDOWN_FETCH_BUBBLES))
239259 update_runtime_stat(st, STAT_TOPDOWN_FETCH_BUBBLES,
240− ctx, cpu, count);
260+ cpu, count, &rsd);
241261 else if (perf_stat_evsel__is(counter, TOPDOWN_RECOVERY_BUBBLES))
242262 update_runtime_stat(st, STAT_TOPDOWN_RECOVERY_BUBBLES,
243− ctx, cpu, count);
263+ cpu, count, &rsd);
244264 else if (perf_stat_evsel__is(counter, TOPDOWN_RETIRING))
245265 update_runtime_stat(st, STAT_TOPDOWN_RETIRING,
246− ctx, cpu, count);
266+ cpu, count, &rsd);
247267 else if (perf_stat_evsel__is(counter, TOPDOWN_BAD_SPEC))
248268 update_runtime_stat(st, STAT_TOPDOWN_BAD_SPEC,
249− ctx, cpu, count);
269+ cpu, count, &rsd);
250270 else if (perf_stat_evsel__is(counter, TOPDOWN_FE_BOUND))
251271 update_runtime_stat(st, STAT_TOPDOWN_FE_BOUND,
252− ctx, cpu, count);
272+ cpu, count, &rsd);
253273 else if (perf_stat_evsel__is(counter, TOPDOWN_BE_BOUND))
254274 update_runtime_stat(st, STAT_TOPDOWN_BE_BOUND,
255− ctx, cpu, count);
275+ cpu, count, &rsd);
256276 else if (evsel__match(counter, HARDWARE, HW_STALLED_CYCLES_FRONTEND))
257277 update_runtime_stat(st, STAT_STALLED_CYCLES_FRONT,
258− ctx, cpu, count);
278+ cpu, count, &rsd);
259279 else if (evsel__match(counter, HARDWARE, HW_STALLED_CYCLES_BACKEND))
260280 update_runtime_stat(st, STAT_STALLED_CYCLES_BACK,
261− ctx, cpu, count);
281+ cpu, count, &rsd);
262282 else if (evsel__match(counter, HARDWARE, HW_BRANCH_INSTRUCTIONS))
263− update_runtime_stat(st, STAT_BRANCHES, ctx, cpu, count);
283+ update_runtime_stat(st, STAT_BRANCHES, cpu, count, &rsd);
264284 else if (evsel__match(counter, HARDWARE, HW_CACHE_REFERENCES))
265− update_runtime_stat(st, STAT_CACHEREFS, ctx, cpu, count);
285+ update_runtime_stat(st, STAT_CACHEREFS, cpu, count, &rsd);
266286 else if (evsel__match(counter, HW_CACHE, HW_CACHE_L1D))
267− update_runtime_stat(st, STAT_L1_DCACHE, ctx, cpu, count);
287+ update_runtime_stat(st, STAT_L1_DCACHE, cpu, count, &rsd);
268288 else if (evsel__match(counter, HW_CACHE, HW_CACHE_L1I))
269− update_runtime_stat(st, STAT_L1_ICACHE, ctx, cpu, count);
289+ update_runtime_stat(st, STAT_L1_ICACHE, cpu, count, &rsd);
270290 else if (evsel__match(counter, HW_CACHE, HW_CACHE_LL))
271− update_runtime_stat(st, STAT_LL_CACHE, ctx, cpu, count);
291+ update_runtime_stat(st, STAT_LL_CACHE, cpu, count, &rsd);
272292 else if (evsel__match(counter, HW_CACHE, HW_CACHE_DTLB))
273− update_runtime_stat(st, STAT_DTLB_CACHE, ctx, cpu, count);
293+ update_runtime_stat(st, STAT_DTLB_CACHE, cpu, count, &rsd);
274294 else if (evsel__match(counter, HW_CACHE, HW_CACHE_ITLB))
275− update_runtime_stat(st, STAT_ITLB_CACHE, ctx, cpu, count);
295+ update_runtime_stat(st, STAT_ITLB_CACHE, cpu, count, &rsd);
276296 else if (perf_stat_evsel__is(counter, SMI_NUM))
277− update_runtime_stat(st, STAT_SMI_NUM, ctx, cpu, count);
297+ update_runtime_stat(st, STAT_SMI_NUM, cpu, count, &rsd);
278298 else if (perf_stat_evsel__is(counter, APERF))
279− update_runtime_stat(st, STAT_APERF, ctx, cpu, count);
299+ update_runtime_stat(st, STAT_APERF, cpu, count, &rsd);
280300
281301 if (counter->collect_stat) {
282− v = saved_value_lookup(counter, cpu, true, STAT_NONE, 0, st);
302+ v = saved_value_lookup(counter, cpu, true, STAT_NONE, 0, st,
303+ rsd.cgrp);
283304 update_stats(&v->stats, count);
284305 if (counter->metric_leader)
285306 v->metric_total += count;
286307 } else if (counter->metric_leader) {
287308 v = saved_value_lookup(counter->metric_leader,
288− cpu, true, STAT_NONE, 0, st);
309+ cpu, true, STAT_NONE, 0, st, rsd.cgrp);
289310 v->metric_total += count;
290311 v->metric_other++;
291312 }
@@ -422,11 +443,12 @@ void perf_stat__collect_metric_expr(struct evlist *evsel_list) · 130 unmodified lines
422443 }
423444
424445 static double runtime_stat_avg(struct runtime_stat *st,
425− enum stat_type type, int ctx, int cpu)
446+ enum stat_type type, int cpu,
447+ struct runtime_stat_data *rsd)
426448 {
427449 struct saved_value *v;
428450
429− v = saved_value_lookup(NULL, cpu, false, type, ctx, st);
451+ v = saved_value_lookup(NULL, cpu, false, type, rsd->ctx, st, rsd->cgrp);
430452 if (!v)
431453 return 0.0;
432454
@@ -434,11 +456,12 @@ static double runtime_stat_avg(struct runtime_stat *st, · 1 unmodified line
434456 }
435457
436458 static double runtime_stat_n(struct runtime_stat *st,
437− enum stat_type type, int ctx, int cpu)
459+ enum stat_type type, int cpu,
460+ struct runtime_stat_data *rsd)
438461 {
439462 struct saved_value *v;
440463
441− v = saved_value_lookup(NULL, cpu, false, type, ctx, st);
464+ v = saved_value_lookup(NULL, cpu, false, type, rsd->ctx, st, rsd->cgrp);
442465 if (!v)
443466 return 0.0;
444467
@@ -446,16 +469,15 @@ static double runtime_stat_n(struct runtime_stat *st, · 1 unmodified line
446469 }
447470
448471 static void print_stalled_cycles_frontend(struct perf_stat_config *config,
449− int cpu,
450− struct evsel *evsel, double avg,
472+ int cpu, double avg,
451473 struct perf_stat_output_ctx *out,
452− struct runtime_stat *st)
474+ struct runtime_stat *st,
475+ struct runtime_stat_data *rsd)
453476 {
454477 double total, ratio = 0.0;
455478 const char *color;
456− int ctx = evsel_context(evsel);
457479
458− total = runtime_stat_avg(st, STAT_CYCLES, ctx, cpu);
480+ total = runtime_stat_avg(st, STAT_CYCLES, cpu, rsd);
459481
460482 if (total)
461483 ratio = avg / total * 100.0;
@@ -470,16 +492,15 @@ static void print_stalled_cycles_frontend(struct perf_stat_config *config, · 8 unmodified lines
470492 }
471493
472494 static void print_stalled_cycles_backend(struct perf_stat_config *config,
473− int cpu,
474− struct evsel *evsel, double avg,
495+ int cpu, double avg,
475496 struct perf_stat_output_ctx *out,
476− struct runtime_stat *st)
497+ struct runtime_stat *st,
498+ struct runtime_stat_data *rsd)
477499 {
478500 double total, ratio = 0.0;
479501 const char *color;
480− int ctx = evsel_context(evsel);
481502
482− total = runtime_stat_avg(st, STAT_CYCLES, ctx, cpu);
503+ total = runtime_stat_avg(st, STAT_CYCLES, cpu, rsd);
483504
484505 if (total)
485506 ratio = avg / total * 100.0;
@@ -490,17 +511,15 @@ static void print_stalled_cycles_backend(struct perf_stat_config *config, · 4 unmodified lines
490511 }
491512
492513 static void print_branch_misses(struct perf_stat_config *config,
493− int cpu,
494− struct evsel *evsel,
495− double avg,
514+ int cpu, double avg,
496515 struct perf_stat_output_ctx *out,
497− struct runtime_stat *st)
516+ struct runtime_stat *st,
517+ struct runtime_stat_data *rsd)
498518 {
499519 double total, ratio = 0.0;
500520 const char *color;
501− int ctx = evsel_context(evsel);
502521
503− total = runtime_stat_avg(st, STAT_BRANCHES, ctx, cpu);
522+ total = runtime_stat_avg(st, STAT_BRANCHES, cpu, rsd);
504523
505524 if (total)
506525 ratio = avg / total * 100.0;
@@ -511,18 +530,15 @@ static void print_branch_misses(struct perf_stat_config *config, · 4 unmodified lines
511530 }
512531
513532 static void print_l1_dcache_misses(struct perf_stat_config *config,
514− int cpu,
515− struct evsel *evsel,
516− double avg,
533+ int cpu, double avg,
517534 struct perf_stat_output_ctx *out,
518− struct runtime_stat *st)
519−
535+ struct runtime_stat *st,
536+ struct runtime_stat_data *rsd)
520537 {
521538 double total, ratio = 0.0;
522539 const char *color;
523− int ctx = evsel_context(evsel);
524540
525− total = runtime_stat_avg(st, STAT_L1_DCACHE, ctx, cpu);
541+ total = runtime_stat_avg(st, STAT_L1_DCACHE, cpu, rsd);
526542
527543 if (total)
528544 ratio = avg / total * 100.0;
@@ -533,18 +549,15 @@ static void print_l1_dcache_misses(struct perf_stat_config *config, · 4 unmodified lines
533549 }
534550
535551 static void print_l1_icache_misses(struct perf_stat_config *config,
536− int cpu,
537− struct evsel *evsel,
538− double avg,
552+ int cpu, double avg,
539553 struct perf_stat_output_ctx *out,
540− struct runtime_stat *st)
541−
554+ struct runtime_stat *st,
555+ struct runtime_stat_data *rsd)
542556 {
543557 double total, ratio = 0.0;
544558 const char *color;
545− int ctx = evsel_context(evsel);
546559
547− total = runtime_stat_avg(st, STAT_L1_ICACHE, ctx, cpu);
560+ total = runtime_stat_avg(st, STAT_L1_ICACHE, cpu, rsd);
548561
549562 if (total)
550563 ratio = avg / total * 100.0;
@@ -554,17 +567,15 @@ static void print_l1_icache_misses(struct perf_stat_config *config, · 3 unmodified lines
554567 }
555568
556569 static void print_dtlb_cache_misses(struct perf_stat_config *config,
557− int cpu,
558− struct evsel *evsel,
559− double avg,
570+ int cpu, double avg,
560571 struct perf_stat_output_ctx *out,
561− struct runtime_stat *st)
572+ struct runtime_stat *st,
573+ struct runtime_stat_data *rsd)
562574 {
563575 double total, ratio = 0.0;
564576 const char *color;
565− int ctx = evsel_context(evsel);
566577
567− total = runtime_stat_avg(st, STAT_DTLB_CACHE, ctx, cpu);
578+ total = runtime_stat_avg(st, STAT_DTLB_CACHE, cpu, rsd);
568579
569580 if (total)
570581 ratio = avg / total * 100.0;
@@ -574,17 +585,15 @@ static void print_dtlb_cache_misses(struct perf_stat_config *config, · 3 unmodified lines
574585 }
575586
576587 static void print_itlb_cache_misses(struct perf_stat_config *config,
577− int cpu,
578− struct evsel *evsel,
579− double avg,
588+ int cpu, double avg,
580589 struct perf_stat_output_ctx *out,
581− struct runtime_stat *st)
590+ struct runtime_stat *st,
591+ struct runtime_stat_data *rsd)
582592 {
583593 double total, ratio = 0.0;
584594 const char *color;
585− int ctx = evsel_context(evsel);
586595
587− total = runtime_stat_avg(st, STAT_ITLB_CACHE, ctx, cpu);
596+ total = runtime_stat_avg(st, STAT_ITLB_CACHE, cpu, rsd);
588597
589598 if (total)
590599 ratio = avg / total * 100.0;
@@ -594,17 +603,15 @@ static void print_itlb_cache_misses(struct perf_stat_config *config, · 3 unmodified lines
594603 }
595604
596605 static void print_ll_cache_misses(struct perf_stat_config *config,
597− int cpu,
598− struct evsel *evsel,
599− double avg,
606+ int cpu, double avg,
600607 struct perf_stat_output_ctx *out,
601− struct runtime_stat *st)
608+ struct runtime_stat *st,
609+ struct runtime_stat_data *rsd)
602610 {
603611 double total, ratio = 0.0;
604612 const char *color;
605− int ctx = evsel_context(evsel);
606613
607− total = runtime_stat_avg(st, STAT_LL_CACHE, ctx, cpu);
614+ total = runtime_stat_avg(st, STAT_LL_CACHE, cpu, rsd);
608615
609616 if (total)
610617 ratio = avg / total * 100.0;
@@ -662,56 +669,61 @@ static double sanitize_val(double x) · 51 unmodified lines
662669 return x;
663670 }
664671
665−static double td_total_slots(int ctx, int cpu, struct runtime_stat *st)
672+static double td_total_slots(int cpu, struct runtime_stat *st,
673+ struct runtime_stat_data *rsd)
666674 {
667− return runtime_stat_avg(st, STAT_TOPDOWN_TOTAL_SLOTS, ctx, cpu);
675+ return runtime_stat_avg(st, STAT_TOPDOWN_TOTAL_SLOTS, cpu, rsd);
668676 }
669677
670−static double td_bad_spec(int ctx, int cpu, struct runtime_stat *st)
678+static double td_bad_spec(int cpu, struct runtime_stat *st,
679+ struct runtime_stat_data *rsd)
671680 {
672681 double bad_spec = 0;
673682 double total_slots;
674683 double total;
675684
676− total = runtime_stat_avg(st, STAT_TOPDOWN_SLOTS_ISSUED, ctx, cpu) -
677− runtime_stat_avg(st, STAT_TOPDOWN_SLOTS_RETIRED, ctx, cpu) +
678− runtime_stat_avg(st, STAT_TOPDOWN_RECOVERY_BUBBLES, ctx, cpu);
685+ total = runtime_stat_avg(st, STAT_TOPDOWN_SLOTS_ISSUED, cpu, rsd) -
686+ runtime_stat_avg(st, STAT_TOPDOWN_SLOTS_RETIRED, cpu, rsd) +
687+ runtime_stat_avg(st, STAT_TOPDOWN_RECOVERY_BUBBLES, cpu, rsd);
679688
680− total_slots = td_total_slots(ctx, cpu, st);
689+ total_slots = td_total_slots(cpu, st, rsd);
681690 if (total_slots)
682691 bad_spec = total / total_slots;
683692 return sanitize_val(bad_spec);
684693 }
685694
686−static double td_retiring(int ctx, int cpu, struct runtime_stat *st)
695+static double td_retiring(int cpu, struct runtime_stat *st,
696+ struct runtime_stat_data *rsd)
687697 {
688698 double retiring = 0;
689− double total_slots = td_total_slots(ctx, cpu, st);
699+ double total_slots = td_total_slots(cpu, st, rsd);
690700 double ret_slots = runtime_stat_avg(st, STAT_TOPDOWN_SLOTS_RETIRED,
691− ctx, cpu);
701+ cpu, rsd);
692702
693703 if (total_slots)
694704 retiring = ret_slots / total_slots;
695705 return retiring;
696706 }
697707
698−static double td_fe_bound(int ctx, int cpu, struct runtime_stat *st)
708+static double td_fe_bound(int cpu, struct runtime_stat *st,
709+ struct runtime_stat_data *rsd)
699710 {
700711 double fe_bound = 0;
701− double total_slots = td_total_slots(ctx, cpu, st);
712+ double total_slots = td_total_slots(cpu, st, rsd);
702713 double fetch_bub = runtime_stat_avg(st, STAT_TOPDOWN_FETCH_BUBBLES,
703− ctx, cpu);
714+ cpu, rsd);
704715
705716 if (total_slots)
706717 fe_bound = fetch_bub / total_slots;
707718 return fe_bound;
708719 }
709720
710−static double td_be_bound(int ctx, int cpu, struct runtime_stat *st)
721+static double td_be_bound(int cpu, struct runtime_stat *st,
722+ struct runtime_stat_data *rsd)
711723 {
712− double sum = (td_fe_bound(ctx, cpu, st) +
713− td_bad_spec(ctx, cpu, st) +
714− td_retiring(ctx, cpu, st));
724+ double sum = (td_fe_bound(cpu, st, rsd) +
725+ td_bad_spec(cpu, st, rsd) +
726+ td_retiring(cpu, st, rsd));
715727 if (sum == 0)
716728 return 0;
717729 return sanitize_val(1.0 - sum);
@@ -722,15 +734,15 @@ static double td_be_bound(int ctx, int cpu, struct runtime_stat *st) · 4 unmodified lines
722734 * the ratios we need to recreate the sum.
723735 */
724736
725−static double td_metric_ratio(int ctx, int cpu,
726− enum stat_type type,
727− struct runtime_stat *stat)
737+static double td_metric_ratio(int cpu, enum stat_type type,
738+ struct runtime_stat *stat,
739+ struct runtime_stat_data *rsd)
728740 {
729− double sum = runtime_stat_avg(stat, STAT_TOPDOWN_RETIRING, ctx, cpu) +
730− runtime_stat_avg(stat, STAT_TOPDOWN_FE_BOUND, ctx, cpu) +
731− runtime_stat_avg(stat, STAT_TOPDOWN_BE_BOUND, ctx, cpu) +
732− runtime_stat_avg(stat, STAT_TOPDOWN_BAD_SPEC, ctx, cpu);
733− double d = runtime_stat_avg(stat, type, ctx, cpu);
741+ double sum = runtime_stat_avg(stat, STAT_TOPDOWN_RETIRING, cpu, rsd) +
742+ runtime_stat_avg(stat, STAT_TOPDOWN_FE_BOUND, cpu, rsd) +
743+ runtime_stat_avg(stat, STAT_TOPDOWN_BE_BOUND, cpu, rsd) +
744+ runtime_stat_avg(stat, STAT_TOPDOWN_BAD_SPEC, cpu, rsd);
745+ double d = runtime_stat_avg(stat, type, cpu, rsd);
734746
735747 if (sum)
736748 return d / sum;
@@ -742,34 +754,33 @@ static double td_metric_ratio(int ctx, int cpu, · 5 unmodified lines
742754 * We allow two missing.
743755 */
744756
745−static bool full_td(int ctx, int cpu,
746− struct runtime_stat *stat)
757+static bool full_td(int cpu, struct runtime_stat *stat,
758+ struct runtime_stat_data *rsd)
747759 {
748760 int c = 0;
749761
750− if (runtime_stat_avg(stat, STAT_TOPDOWN_RETIRING, ctx, cpu) > 0)
762+ if (runtime_stat_avg(stat, STAT_TOPDOWN_RETIRING, cpu, rsd) > 0)
751763 c++;
752− if (runtime_stat_avg(stat, STAT_TOPDOWN_BE_BOUND, ctx, cpu) > 0)
764+ if (runtime_stat_avg(stat, STAT_TOPDOWN_BE_BOUND, cpu, rsd) > 0)
753765 c++;
754− if (runtime_stat_avg(stat, STAT_TOPDOWN_FE_BOUND, ctx, cpu) > 0)
766+ if (runtime_stat_avg(stat, STAT_TOPDOWN_FE_BOUND, cpu, rsd) > 0)
755767 c++;
756− if (runtime_stat_avg(stat, STAT_TOPDOWN_BAD_SPEC, ctx, cpu) > 0)
768+ if (runtime_stat_avg(stat, STAT_TOPDOWN_BAD_SPEC, cpu, rsd) > 0)
757769 c++;
758770 return c >= 2;
759771 }
760772
761−static void print_smi_cost(struct perf_stat_config *config,
762− int cpu, struct evsel *evsel,
773+static void print_smi_cost(struct perf_stat_config *config, int cpu,
763774 struct perf_stat_output_ctx *out,
764− struct runtime_stat *st)
775+ struct runtime_stat *st,
776+ struct runtime_stat_data *rsd)
765777 {
766778 double smi_num, aperf, cycles, cost = 0.0;
767− int ctx = evsel_context(evsel);
768779 const char *color = NULL;
769780
770− smi_num = runtime_stat_avg(st, STAT_SMI_NUM, ctx, cpu);
771− aperf = runtime_stat_avg(st, STAT_APERF, ctx, cpu);
772− cycles = runtime_stat_avg(st, STAT_CYCLES, ctx, cpu);
781+ smi_num = runtime_stat_avg(st, STAT_SMI_NUM, cpu, rsd);
782+ aperf = runtime_stat_avg(st, STAT_APERF, cpu, rsd);
783+ cycles = runtime_stat_avg(st, STAT_CYCLES, cpu, rsd);
773784
774785 if ((cycles == 0) || (aperf == 0))
775786 return;
@@ -804,7 +815,8 @@ static int prepare_metric(struct evsel **metric_events, · 28 unmodified lines
804815 scale = 1e-9;
805816 } else {
806817 v = saved_value_lookup(metric_events[i], cpu, false,
807− STAT_NONE, 0, st);
818+ STAT_NONE, 0, st,
819+ metric_events[i]->cgrp);
808820 if (!v)
809821 break;
810822 stats = &v->stats;
@@ -930,12 +942,15 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, · 119 unmodified lines
930942 print_metric_t print_metric = out->print_metric;
931943 double total, ratio = 0.0, total2;
932944 const char *color = NULL;
933− int ctx = evsel_context(evsel);
945+ struct runtime_stat_data rsd = {
946+ .ctx = evsel_context(evsel),
947+ .cgrp = evsel->cgrp,
948+ };
934949 struct metric_event *me;
935950 int num = 1;
936951
937952 if (evsel__match(evsel, HARDWARE, HW_INSTRUCTIONS)) {
938− total = runtime_stat_avg(st, STAT_CYCLES, ctx, cpu);
953+ total = runtime_stat_avg(st, STAT_CYCLES, cpu, &rsd);
939954
940955 if (total) {
941956 ratio = avg / total;
@@ -945,12 +960,11 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, · 3 unmodified lines
945960 print_metric(config, ctxp, NULL, NULL, "insn per cycle", 0);
946961 }
947962
948− total = runtime_stat_avg(st, STAT_STALLED_CYCLES_FRONT,
949− ctx, cpu);
963+ total = runtime_stat_avg(st, STAT_STALLED_CYCLES_FRONT, cpu, &rsd);
950964
951965 total = max(total, runtime_stat_avg(st,
952966 STAT_STALLED_CYCLES_BACK,
953− ctx, cpu));
967+ cpu, &rsd));
954968
955969 if (total && avg) {
956970 out->new_line(config, ctxp);
@@ -960,8 +974,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, · 3 unmodified lines
960974 ratio);
961975 }
962976 } else if (evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES)) {
963− if (runtime_stat_n(st, STAT_BRANCHES, ctx, cpu) != 0)
964− print_branch_misses(config, cpu, evsel, avg, out, st);
977+ if (runtime_stat_n(st, STAT_BRANCHES, cpu, &rsd) != 0)
978+ print_branch_misses(config, cpu, avg, out, st, &rsd);
965979 else
966980 print_metric(config, ctxp, NULL, NULL, "of all branches", 0);
967981 } else if (
@@ -970,8 +984,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, · 2 unmodified lines
970984 ((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
971985 ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) {
972986
973− if (runtime_stat_n(st, STAT_L1_DCACHE, ctx, cpu) != 0)
974− print_l1_dcache_misses(config, cpu, evsel, avg, out, st);
987+ if (runtime_stat_n(st, STAT_L1_DCACHE, cpu, &rsd) != 0)
988+ print_l1_dcache_misses(config, cpu, avg, out, st, &rsd);
975989 else
976990 print_metric(config, ctxp, NULL, NULL, "of all L1-dcache accesses", 0);
977991 } else if (
@@ -980,8 +994,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, · 2 unmodified lines
980994 ((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
981995 ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) {
982996
983− if (runtime_stat_n(st, STAT_L1_ICACHE, ctx, cpu) != 0)
984− print_l1_icache_misses(config, cpu, evsel, avg, out, st);
997+ if (runtime_stat_n(st, STAT_L1_ICACHE, cpu, &rsd) != 0)
998+ print_l1_icache_misses(config, cpu, avg, out, st, &rsd);
985999 else
9861000 print_metric(config, ctxp, NULL, NULL, "of all L1-icache accesses", 0);
9871001 } else if (
@@ -990,8 +1004,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, · 2 unmodified lines
9901004 ((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
9911005 ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) {
9921006
993− if (runtime_stat_n(st, STAT_DTLB_CACHE, ctx, cpu) != 0)
994− print_dtlb_cache_misses(config, cpu, evsel, avg, out, st);
1007+ if (runtime_stat_n(st, STAT_DTLB_CACHE, cpu, &rsd) != 0)
1008+ print_dtlb_cache_misses(config, cpu, avg, out, st, &rsd);
9951009 else
9961010 print_metric(config, ctxp, NULL, NULL, "of all dTLB cache accesses", 0);
9971011 } else if (
@@ -1000,8 +1014,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, · 2 unmodified lines
10001014 ((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
10011015 ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) {
10021016
1003− if (runtime_stat_n(st, STAT_ITLB_CACHE, ctx, cpu) != 0)
1004− print_itlb_cache_misses(config, cpu, evsel, avg, out, st);
1017+ if (runtime_stat_n(st, STAT_ITLB_CACHE, cpu, &rsd) != 0)
1018+ print_itlb_cache_misses(config, cpu, avg, out, st, &rsd);
10051019 else
10061020 print_metric(config, ctxp, NULL, NULL, "of all iTLB cache accesses", 0);
10071021 } else if (
@@ -1010,27 +1024,27 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, · 2 unmodified lines
10101024 ((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
10111025 ((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16))) {
10121026
1013− if (runtime_stat_n(st, STAT_LL_CACHE, ctx, cpu) != 0)
1014− print_ll_cache_misses(config, cpu, evsel, avg, out, st);
1027+ if (runtime_stat_n(st, STAT_LL_CACHE, cpu, &rsd) != 0)
1028+ print_ll_cache_misses(config, cpu, avg, out, st, &rsd);
10151029 else
10161030 print_metric(config, ctxp, NULL, NULL, "of all LL-cache accesses", 0);
10171031 } else if (evsel__match(evsel, HARDWARE, HW_CACHE_MISSES)) {
1018− total = runtime_stat_avg(st, STAT_CACHEREFS, ctx, cpu);
1032+ total = runtime_stat_avg(st, STAT_CACHEREFS, cpu, &rsd);
10191033
10201034 if (total)
10211035 ratio = avg * 100 / total;
10221036
1023− if (runtime_stat_n(st, STAT_CACHEREFS, ctx, cpu) != 0)
1037+ if (runtime_stat_n(st, STAT_CACHEREFS, cpu, &rsd) != 0)
10241038 print_metric(config, ctxp, NULL, "%8.3f %%",
10251039 "of all cache refs", ratio);
10261040 else
10271041 print_metric(config, ctxp, NULL, NULL, "of all cache refs", 0);
10281042 } else if (evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_FRONTEND)) {
1029− print_stalled_cycles_frontend(config, cpu, evsel, avg, out, st);
1043+ print_stalled_cycles_frontend(config, cpu, avg, out, st, &rsd);
10301044 } else if (evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_BACKEND)) {
1031− print_stalled_cycles_backend(config, cpu, evsel, avg, out, st);
1045+ print_stalled_cycles_backend(config, cpu, avg, out, st, &rsd);
10321046 } else if (evsel__match(evsel, HARDWARE, HW_CPU_CYCLES)) {
1033− total = runtime_stat_avg(st, STAT_NSECS, 0, cpu);
1047+ total = runtime_stat_avg(st, STAT_NSECS, cpu, &rsd);
10341048
10351049 if (total) {
10361050 ratio = avg / total;
@@ -1039,7 +1053,7 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, · 2 unmodified lines
10391053 print_metric(config, ctxp, NULL, NULL, "Ghz", 0);
10401054 }
10411055 } else if (perf_stat_evsel__is(evsel, CYCLES_IN_TX)) {
1042− total = runtime_stat_avg(st, STAT_CYCLES, ctx, cpu);
1056+ total = runtime_stat_avg(st, STAT_CYCLES, cpu, &rsd);
10431057
10441058 if (total)
10451059 print_metric(config, ctxp, NULL,
@@ -1049,8 +1063,8 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, · 3 unmodified lines
10491063 print_metric(config, ctxp, NULL, NULL, "transactional cycles",
10501064 0);
10511065 } else if (perf_stat_evsel__is(evsel, CYCLES_IN_TX_CP)) {
1052− total = runtime_stat_avg(st, STAT_CYCLES, ctx, cpu);
1053− total2 = runtime_stat_avg(st, STAT_CYCLES_IN_TX, ctx, cpu);
1066+ total = runtime_stat_avg(st, STAT_CYCLES, cpu, &rsd);
1067+ total2 = runtime_stat_avg(st, STAT_CYCLES_IN_TX, cpu, &rsd);
10541068
10551069 if (total2 < avg)
10561070 total2 = avg;
@@ -1060,21 +1074,19 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, · 3 unmodified lines
10601074 else
10611075 print_metric(config, ctxp, NULL, NULL, "aborted cycles", 0);
10621076 } else if (perf_stat_evsel__is(evsel, TRANSACTION_START)) {
1063− total = runtime_stat_avg(st, STAT_CYCLES_IN_TX,
1064− ctx, cpu);
1077+ total = runtime_stat_avg(st, STAT_CYCLES_IN_TX, cpu, &rsd);
10651078
10661079 if (avg)
10671080 ratio = total / avg;
10681081
1069− if (runtime_stat_n(st, STAT_CYCLES_IN_TX, ctx, cpu) != 0)
1082+ if (runtime_stat_n(st, STAT_CYCLES_IN_TX, cpu, &rsd) != 0)
10701083 print_metric(config, ctxp, NULL, "%8.0f",
10711084 "cycles / transaction", ratio);
10721085 else
10731086 print_metric(config, ctxp, NULL, NULL, "cycles / transaction",
10741087 0);
10751088 } else if (perf_stat_evsel__is(evsel, ELISION_START)) {
1076− total = runtime_stat_avg(st, STAT_CYCLES_IN_TX,
1077− ctx, cpu);
1089+ total = runtime_stat_avg(st, STAT_CYCLES_IN_TX, cpu, &rsd);
10781090
10791091 if (avg)
10801092 ratio = total / avg;
@@ -1087,28 +1099,28 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, · 6 unmodified lines
10871099 else
10881100 print_metric(config, ctxp, NULL, NULL, "CPUs utilized", 0);
10891101 } else if (perf_stat_evsel__is(evsel, TOPDOWN_FETCH_BUBBLES)) {
1090− double fe_bound = td_fe_bound(ctx, cpu, st);
1102+ double fe_bound = td_fe_bound(cpu, st, &rsd);
10911103
10921104 if (fe_bound > 0.2)
10931105 color = PERF_COLOR_RED;
10941106 print_metric(config, ctxp, color, "%8.1f%%", "frontend bound",
10951107 fe_bound * 100.);
10961108 } else if (perf_stat_evsel__is(evsel, TOPDOWN_SLOTS_RETIRED)) {
1097− double retiring = td_retiring(ctx, cpu, st);
1109+ double retiring = td_retiring(cpu, st, &rsd);
10981110
10991111 if (retiring > 0.7)
11001112 color = PERF_COLOR_GREEN;
11011113 print_metric(config, ctxp, color, "%8.1f%%", "retiring",
11021114 retiring * 100.);
11031115 } else if (perf_stat_evsel__is(evsel, TOPDOWN_RECOVERY_BUBBLES)) {
1104− double bad_spec = td_bad_spec(ctx, cpu, st);
1116+ double bad_spec = td_bad_spec(cpu, st, &rsd);
11051117
11061118 if (bad_spec > 0.1)
11071119 color = PERF_COLOR_RED;
11081120 print_metric(config, ctxp, color, "%8.1f%%", "bad speculation",
11091121 bad_spec * 100.);
11101122 } else if (perf_stat_evsel__is(evsel, TOPDOWN_SLOTS_ISSUED)) {
1111− double be_bound = td_be_bound(ctx, cpu, st);
1123+ double be_bound = td_be_bound(cpu, st, &rsd);
11121124 const char *name = "backend bound";
11131125 static int have_recovery_bubbles = -1;
11141126
@@ -1121,43 +1133,43 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, · 6 unmodified lines
11211133
11221134 if (be_bound > 0.2)
11231135 color = PERF_COLOR_RED;
1124− if (td_total_slots(ctx, cpu, st) > 0)
1136+ if (td_total_slots(cpu, st, &rsd) > 0)
11251137 print_metric(config, ctxp, color, "%8.1f%%", name,
11261138 be_bound * 100.);
11271139 else
11281140 print_metric(config, ctxp, NULL, NULL, name, 0);
11291141 } else if (perf_stat_evsel__is(evsel, TOPDOWN_RETIRING) &&
1130− full_td(ctx, cpu, st)) {
1131− double retiring = td_metric_ratio(ctx, cpu,
1132− STAT_TOPDOWN_RETIRING, st);
1133−
1142+ full_td(cpu, st, &rsd)) {
1143+ double retiring = td_metric_ratio(cpu,
1144+ STAT_TOPDOWN_RETIRING, st,
1145+ &rsd);
11341146 if (retiring > 0.7)
11351147 color = PERF_COLOR_GREEN;
11361148 print_metric(config, ctxp, color, "%8.1f%%", "retiring",
11371149 retiring * 100.);
11381150 } else if (perf_stat_evsel__is(evsel, TOPDOWN_FE_BOUND) &&
1139− full_td(ctx, cpu, st)) {
1140− double fe_bound = td_metric_ratio(ctx, cpu,
1141− STAT_TOPDOWN_FE_BOUND, st);
1142−
1151+ full_td(cpu, st, &rsd)) {
1152+ double fe_bound = td_metric_ratio(cpu,
1153+ STAT_TOPDOWN_FE_BOUND, st,
1154+ &rsd);
11431155 if (fe_bound > 0.2)
11441156 color = PERF_COLOR_RED;
11451157 print_metric(config, ctxp, color, "%8.1f%%", "frontend bound",
11461158 fe_bound * 100.);
11471159 } else if (perf_stat_evsel__is(evsel, TOPDOWN_BE_BOUND) &&
1148− full_td(ctx, cpu, st)) {
1149− double be_bound = td_metric_ratio(ctx, cpu,
1150− STAT_TOPDOWN_BE_BOUND, st);
1151−
1160+ full_td(cpu, st, &rsd)) {
1161+ double be_bound = td_metric_ratio(cpu,
1162+ STAT_TOPDOWN_BE_BOUND, st,
1163+ &rsd);
11521164 if (be_bound > 0.2)
11531165 color = PERF_COLOR_RED;
11541166 print_metric(config, ctxp, color, "%8.1f%%", "backend bound",
11551167 be_bound * 100.);
11561168 } else if (perf_stat_evsel__is(evsel, TOPDOWN_BAD_SPEC) &&
1157− full_td(ctx, cpu, st)) {
1158− double bad_spec = td_metric_ratio(ctx, cpu,
1159− STAT_TOPDOWN_BAD_SPEC, st);
1160−
1169+ full_td(cpu, st, &rsd)) {
1170+ double bad_spec = td_metric_ratio(cpu,
1171+ STAT_TOPDOWN_BAD_SPEC, st,
1172+ &rsd);
11611173 if (bad_spec > 0.1)
11621174 color = PERF_COLOR_RED;
11631175 print_metric(config, ctxp, color, "%8.1f%%", "bad speculation",
@@ -1165,11 +1177,11 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, · 1 unmodified line
11651177 } else if (evsel->metric_expr) {
11661178 generic_metric(config, evsel->metric_expr, evsel->metric_events, NULL,
11671179 evsel->name, evsel->metric_name, NULL, 1, cpu, out, st);
1168− } else if (runtime_stat_n(st, STAT_NSECS, 0, cpu) != 0) {
1180+ } else if (runtime_stat_n(st, STAT_NSECS, cpu, &rsd) != 0) {
11691181 char unit = 'M';
11701182 char unit_buf[10];
11711183
1172− total = runtime_stat_avg(st, STAT_NSECS, 0, cpu);
1184+ total = runtime_stat_avg(st, STAT_NSECS, cpu, &rsd);
11731185
11741186 if (total)
11751187 ratio = 1000.0 * avg / total;
@@ -1180,7 +1192,7 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, · 4 unmodified lines
11801192 snprintf(unit_buf, sizeof(unit_buf), "%c/sec", unit);
11811193 print_metric(config, ctxp, NULL, "%8.3f", unit_buf, ratio);
11821194 } else if (perf_stat_evsel__is(evsel, SMI_NUM)) {
1183− print_smi_cost(config, cpu, evsel, out, st);
1195+ print_smi_cost(config, cpu, out, st, &rsd);
11841196 } else {
11851197 num = 0;
11861198 }
tools/testing/selftests/arm64/fp/fpsimd-test.S+1−1
@@ -457,7 +457,7 @@ function barf · 456 unmodified lines
457457 mov x11, x1 // actual data
458458 mov x12, x2 // data size
459459
460− puts "Mistatch: PID="
460+ puts "Mismatch: PID="
461461 mov x0, x20
462462 bl putdec
463463 puts ", iteration="
tools/testing/selftests/arm64/fp/sve-test.S+1−1
@@ -625,7 +625,7 @@ function barf · 624 unmodified lines
625625 mov x11, x1 // actual data
626626 mov x12, x2 // data size
627627
628− puts "Mistatch: PID="
628+ puts "Mismatch: PID="
629629 mov x0, x20
630630 bl putdec
631631 puts ", iteration="
tools/testing/selftests/bpf/prog_tests/test_local_storage.c+26−70
@@ -34,61 +34,6 @@ struct storage { · 33 unmodified lines
3434 struct bpf_spin_lock lock;
3535 };
3636
37−/* Copies an rm binary to a temp file. dest is a mkstemp template */
38−static int copy_rm(char *dest)
39−{
40− int fd_in, fd_out = -1, ret = 0;
41− struct stat stat;
42− char *buf = NULL;
43−
44− fd_in = open("/bin/rm", O_RDONLY);
45− if (fd_in < 0)
46− return -errno;
47−
48− fd_out = mkstemp(dest);
49− if (fd_out < 0) {
50− ret = -errno;
51− goto out;
52− }
53−
54− ret = fstat(fd_in, &stat);
55− if (ret == -1) {
56− ret = -errno;
57− goto out;
58− }
59−
60− buf = malloc(stat.st_blksize);
61− if (!buf) {
62− ret = -errno;
63− goto out;
64− }
65−
66− while (ret = read(fd_in, buf, stat.st_blksize), ret > 0) {
67− ret = write(fd_out, buf, ret);
68− if (ret < 0) {
69− ret = -errno;
70− goto out;
71−
72− }
73− }
74− if (ret < 0) {
75− ret = -errno;
76− goto out;
77−
78− }
79−
80− /* Set executable permission on the copied file */
81− ret = chmod(dest, 0100);
82− if (ret == -1)
83− ret = -errno;
84−
85−out:
86− free(buf);
87− close(fd_in);
88− close(fd_out);
89− return ret;
90−}
91−
9237 /* Fork and exec the provided rm binary and return the exit code of the
9338 * forked process and its pid.
9439 */
@@ -168,9 +113,11 @@ static bool check_syscall_operations(int map_fd, int obj_fd) · 73 unmodified lines
168113
169114 void test_test_local_storage(void)
170115 {
171− char tmp_exec_path[PATH_MAX] = "/tmp/copy_of_rmXXXXXX";
116+ char tmp_dir_path[64] = "/tmp/local_storageXXXXXX";
172117 int err, serv_sk = -1, task_fd = -1, rm_fd = -1;
173118 struct local_storage *skel = NULL;
119+ char tmp_exec_path[64];
120+ char cmd[256];
174121
175122 skel = local_storage__open_and_load();
176123 if (CHECK(!skel, "skel_load", "lsm skeleton failed\n"))
@@ -189,18 +136,24 @@ void test_test_local_storage(void) · 12 unmodified lines
189136 task_fd))
190137 goto close_prog;
191138
192− err = copy_rm(tmp_exec_path);
193− if (CHECK(err < 0, "copy_rm", "err %d errno %d\n", err, errno))
139+ if (CHECK(!mkdtemp(tmp_dir_path), "mkdtemp",
140+ "unable to create tmpdir: %d\n", errno))
194141 goto close_prog;
195142
143+ snprintf(tmp_exec_path, sizeof(tmp_exec_path), "%s/copy_of_rm",
144+ tmp_dir_path);
145+ snprintf(cmd, sizeof(cmd), "cp /bin/rm %s", tmp_exec_path);
146+ if (CHECK_FAIL(system(cmd)))
147+ goto close_prog_rmdir;
148+
196149 rm_fd = open(tmp_exec_path, O_RDONLY);
197150 if (CHECK(rm_fd < 0, "open", "failed to open %s err:%d, errno:%d",
198151 tmp_exec_path, rm_fd, errno))
199− goto close_prog;
152+ goto close_prog_rmdir;
200153
201154 if (!check_syscall_operations(bpf_map__fd(skel->maps.inode_storage_map),
202155 rm_fd))
203− goto close_prog;
156+ goto close_prog_rmdir;
204157
205158 /* Sets skel->bss->monitored_pid to the pid of the forked child
206159 * forks a child process that executes tmp_exec_path and tries to
@@ -209,33 +162,36 @@ void test_test_local_storage(void) · 2 unmodified lines
209162 */
210163 err = run_self_unlink(&skel->bss->monitored_pid, tmp_exec_path);
211164 if (CHECK(err != EPERM, "run_self_unlink", "err %d want EPERM\n", err))
212− goto close_prog_unlink;
165+ goto close_prog_rmdir;
213166
214167 /* Set the process being monitored to be the current process */
215168 skel->bss->monitored_pid = getpid();
216169
217− /* Remove the temporary created executable */
218− err = unlink(tmp_exec_path);
219− if (CHECK(err != 0, "unlink", "unable to unlink %s: %d", tmp_exec_path,
220− errno))
221− goto close_prog_unlink;
170+ /* Move copy_of_rm to a new location so that it triggers the
171+ * inode_rename LSM hook with a new_dentry that has a NULL inode ptr.
172+ */
173+ snprintf(cmd, sizeof(cmd), "mv %s/copy_of_rm %s/check_null_ptr",
174+ tmp_dir_path, tmp_dir_path);
175+ if (CHECK_FAIL(system(cmd)))
176+ goto close_prog_rmdir;
222177
223178 CHECK(skel->data->inode_storage_result != 0, "inode_storage_result",
224179 "inode_local_storage not set\n");
225180
226181 serv_sk = start_server(AF_INET6, SOCK_STREAM, NULL, 0, 0);
227182 if (CHECK(serv_sk < 0, "start_server", "failed to start server\n"))
228− goto close_prog;
183+ goto close_prog_rmdir;
229184
230185 CHECK(skel->data->sk_storage_result != 0, "sk_storage_result",
231186 "sk_local_storage not set\n");
232187
233188 if (!check_syscall_operations(bpf_map__fd(skel->maps.sk_storage_map),
234189 serv_sk))
235− goto close_prog;
190+ goto close_prog_rmdir;
236191
237−close_prog_unlink:
238− unlink(tmp_exec_path);
192+close_prog_rmdir:
193+ snprintf(cmd, sizeof(cmd), "rm -rf %s", tmp_dir_path);
194+ system(cmd);
239195 close_prog:
240196 close(serv_sk);
241197 close(rm_fd);
tools/testing/selftests/bpf/progs/local_storage.c+35−27
@@ -50,7 +50,6 @@ int BPF_PROG(unlink_hook, struct inode *dir, struct dentry *victim) · 49 unmodified lines
5050 __u32 pid = bpf_get_current_pid_tgid() >> 32;
5151 struct local_storage *storage;
5252 bool is_self_unlink;
53− int err;
5453
5554 if (pid != monitored_pid)
5655 return 0;
@@ -66,8 +65,27 @@ int BPF_PROG(unlink_hook, struct inode *dir, struct dentry *victim) · 9 unmodified lines
6665 return -EPERM;
6766 }
6867
69− storage = bpf_inode_storage_get(&inode_storage_map, victim->d_inode, 0,
70− BPF_LOCAL_STORAGE_GET_F_CREATE);
68+ return 0;
69+}
70+
71+SEC("lsm/inode_rename")
72+int BPF_PROG(inode_rename, struct inode *old_dir, struct dentry *old_dentry,
73+ struct inode *new_dir, struct dentry *new_dentry,
74+ unsigned int flags)
75+{
76+ __u32 pid = bpf_get_current_pid_tgid() >> 32;
77+ struct local_storage *storage;
78+ int err;
79+
80+ /* new_dentry->d_inode can be NULL when the inode is renamed to a file
81+ * that did not exist before. The helper should be able to handle this
82+ * NULL pointer.
83+ */
84+ bpf_inode_storage_get(&inode_storage_map, new_dentry->d_inode, 0,
85+ BPF_LOCAL_STORAGE_GET_F_CREATE);
86+
87+ storage = bpf_inode_storage_get(&inode_storage_map, old_dentry->d_inode,
88+ 0, 0);
7189 if (!storage)
7290 return 0;
7391
@@ -76,7 +94,7 @@ int BPF_PROG(unlink_hook, struct inode *dir, struct dentry *victim) · 2 unmodified lines
7694 inode_storage_result = -1;
7795 bpf_spin_unlock(&storage->lock);
7896
79− err = bpf_inode_storage_delete(&inode_storage_map, victim->d_inode);
97+ err = bpf_inode_storage_delete(&inode_storage_map, old_dentry->d_inode);
8098 if (!err)
8199 inode_storage_result = err;
82100
@@ -133,37 +151,18 @@ int BPF_PROG(socket_post_create, struct socket *sock, int family, int type, · 50 unmodified lines
133151 return 0;
134152 }
135153
136−SEC("lsm/file_open")
137−int BPF_PROG(file_open, struct file *file)
138−{
139− __u32 pid = bpf_get_current_pid_tgid() >> 32;
140− struct local_storage *storage;
141−
142− if (pid != monitored_pid)
143− return 0;
144−
145− if (!file->f_inode)
146− return 0;
147−
148− storage = bpf_inode_storage_get(&inode_storage_map, file->f_inode, 0,
149− BPF_LOCAL_STORAGE_GET_F_CREATE);
150− if (!storage)
151− return 0;
152−
153− bpf_spin_lock(&storage->lock);
154− storage->value = DUMMY_STORAGE_VALUE;
155− bpf_spin_unlock(&storage->lock);
156− return 0;
157−}
158−
159154 /* This uses the local storage to remember the inode of the binary that a
160155 * process was originally executing.
161156 */
162157 SEC("lsm/bprm_committed_creds")
163158 void BPF_PROG(exec, struct linux_binprm *bprm)
164159 {
160+ __u32 pid = bpf_get_current_pid_tgid() >> 32;
165161 struct local_storage *storage;
166162
163+ if (pid != monitored_pid)
164+ return;
165+
167166 storage = bpf_task_storage_get(&task_storage_map,
168167 bpf_get_current_task_btf(), 0,
169168 BPF_LOCAL_STORAGE_GET_F_CREATE);
@@ -172,4 +171,13 @@ void BPF_PROG(exec, struct linux_binprm *bprm) · 2 unmodified lines
172171 storage->exec_inode = bprm->file->f_inode;
173172 bpf_spin_unlock(&storage->lock);
174173 }
174+
175+ storage = bpf_inode_storage_get(&inode_storage_map, bprm->file->f_inode,
176+ 0, BPF_LOCAL_STORAGE_GET_F_CREATE);
177+ if (!storage)
178+ return;
179+
180+ bpf_spin_lock(&storage->lock);
181+ storage->value = DUMMY_STORAGE_VALUE;
182+ bpf_spin_unlock(&storage->lock);
175183 }
tools/testing/selftests/bpf/test_verifier.c+11−1
@@ -50,7 +50,7 @@ · 49 unmodified lines
5050 #define MAX_INSNS BPF_MAXINSNS
5151 #define MAX_TEST_INSNS 1000000
5252 #define MAX_FIXUPS 8
53−#define MAX_NR_MAPS 20
53+#define MAX_NR_MAPS 21
5454 #define MAX_TEST_RUNS 8
5555 #define POINTER_VALUE 0xcafe4all
5656 #define TEST_DATA_LEN 64
@@ -87,6 +87,7 @@ struct bpf_test { · 30 unmodified lines
8787 int fixup_sk_storage_map[MAX_FIXUPS];
8888 int fixup_map_event_output[MAX_FIXUPS];
8989 int fixup_map_reuseport_array[MAX_FIXUPS];
90+ int fixup_map_ringbuf[MAX_FIXUPS];
9091 const char *errstr;
9192 const char *errstr_unpriv;
9293 uint32_t insn_processed;
@@ -640,6 +641,7 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_prog_type prog_type, · 547 unmodified lines
640641 int *fixup_sk_storage_map = test->fixup_sk_storage_map;
641642 int *fixup_map_event_output = test->fixup_map_event_output;
642643 int *fixup_map_reuseport_array = test->fixup_map_reuseport_array;
644+ int *fixup_map_ringbuf = test->fixup_map_ringbuf;
643645
644646 if (test->fill_helper) {
645647 test->fill_insns = calloc(MAX_TEST_INSNS, sizeof(struct bpf_insn));
@@ -817,6 +819,14 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_prog_type prog_type, · 171 unmodified lines
817819 fixup_map_reuseport_array++;
818820 } while (*fixup_map_reuseport_array);
819821 }
822+ if (*fixup_map_ringbuf) {
823+ map_fds[20] = create_map(BPF_MAP_TYPE_RINGBUF, 0,
824+ 0, 4096);
825+ do {
826+ prog[*fixup_map_ringbuf].imm = map_fds[20];
827+ fixup_map_ringbuf++;
828+ } while (*fixup_map_ringbuf);
829+ }
820830 }
821831
822832 struct libcap {
tools/testing/selftests/bpf/verifier/spill_fill.c+30−0
@@ -28,6 +28,36 @@ · 27 unmodified lines
2828 .result = ACCEPT,
2929 .result_unpriv = ACCEPT,
3030 },
31+{
32+ "check valid spill/fill, ptr to mem",
33+ .insns = {
34+ /* reserve 8 byte ringbuf memory */
35+ BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0),
36+ BPF_LD_MAP_FD(BPF_REG_1, 0),
37+ BPF_MOV64_IMM(BPF_REG_2, 8),
38+ BPF_MOV64_IMM(BPF_REG_3, 0),
39+ BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_ringbuf_reserve),
40+ /* store a pointer to the reserved memory in R6 */
41+ BPF_MOV64_REG(BPF_REG_6, BPF_REG_0),
42+ /* check whether the reservation was successful */
43+ BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6),
44+ /* spill R6(mem) into the stack */
45+ BPF_STX_MEM(BPF_DW, BPF_REG_10, BPF_REG_6, -8),
46+ /* fill it back in R7 */
47+ BPF_LDX_MEM(BPF_DW, BPF_REG_7, BPF_REG_10, -8),
48+ /* should be able to access *(R7) = 0 */
49+ BPF_ST_MEM(BPF_DW, BPF_REG_7, 0, 0),
50+ /* submit the reserved ringbuf memory */
51+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_7),
52+ BPF_MOV64_IMM(BPF_REG_2, 0),
53+ BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_ringbuf_submit),
54+ BPF_MOV64_IMM(BPF_REG_0, 0),
55+ BPF_EXIT_INSN(),
56+ },
57+ .fixup_map_ringbuf = { 1 },
58+ .result = ACCEPT,
59+ .result_unpriv = ACCEPT,
60+},
3161 {
3262 "check corrupted spill/fill",
3363 .insns = {
tools/testing/selftests/net/fib_tests.sh+0−1
@@ -1055,7 +1055,6 @@ ipv6_addr_metric_test() · 1054 unmodified lines
10551055
10561056 check_route6 "2001:db8:104::1 dev dummy2 proto kernel metric 260"
10571057 log_test $? 0 "Set metric with peer route on local side"
1058− log_test $? 0 "User specified metric on local address"
10591058 check_route6 "2001:db8:104::2 dev dummy2 proto kernel metric 260"
10601059 log_test $? 0 "Set metric with peer route on peer side"
10611060