History

Merge tag 'kvm-arm-for-4.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm into kvm-next

KVM/ARM changes for Linux v4.5 - Complete rewrite of the arm64 world switch in C, hopefully paving the way for more sharing with the 32bit code, better maintainability and easier integration of new features. Also smaller and slightly faster in some cases... - Support for 16bit VM identifiers - Various cleanups

Paolo Bonzini committed 10 years ago

Commit def840e2 parents 7749266 c7da6fa836 files · +11543 −6814Browse files

Unified · Split

836 files
  1. Documentation/arm/keystone/Overview.txt +0 −18
  2. Documentation/block/null_blk.txt +3 −0
  3. Documentation/devicetree/bindings/gpio/gpio-mpc8xxx.txt +4 −0
  4. Documentation/devicetree/bindings/net/marvell-armada-370-neta.txt +6 −0
  5. Documentation/devicetree/bindings/thermal/rockchip-thermal.txt +3 −1
  6. MAINTAINERS +14 −8
  7. Makefile +1 −1
  8. arch/arc/configs/axs101_defconfig +1 −1
  9. arch/arc/configs/axs103_defconfig +1 −1
  10. arch/arc/configs/axs103_smp_defconfig +1 −1
  11. arch/arc/configs/nsim_hs_defconfig +1 −1
  12. arch/arc/configs/nsim_hs_smp_defconfig +1 −1
  13. arch/arc/configs/nsimosci_hs_defconfig +1 −1
  14. arch/arc/configs/nsimosci_hs_smp_defconfig +1 −1
  15. arch/arc/configs/vdk_hs38_defconfig +1 −1
  16. arch/arc/configs/vdk_hs38_smp_defconfig +1 −1
  17. arch/arc/include/asm/irqflags-arcv2.h +3 −0
  18. arch/arc/include/asm/irqflags-compact.h +2 −0
  19. arch/arc/kernel/ctx_sw.c +0 −2
  20. arch/arc/kernel/ctx_sw_asm.S +0 −3
  21. arch/arc/kernel/process.c +4 −5
  22. arch/arc/kernel/unwind.c +4 −33
  23. arch/arc/mm/tlb.c +2 −2
  24. arch/arm/Kconfig +2 −2
  25. arch/arm/boot/dts/am4372.dtsi +2 −2
  26. arch/arm/boot/dts/am43xx-clocks.dtsi +8 −0
  27. arch/arm/boot/dts/am57xx-beagle-x15.dts +1 −0
  28. arch/arm/boot/dts/animeo_ip.dts +3 −3
  29. arch/arm/boot/dts/armada-38x.dtsi +1 −0
  30. arch/arm/boot/dts/at91-foxg20.dts +1 −1
  31. arch/arm/boot/dts/at91-kizbox.dts +2 −11
  32. arch/arm/boot/dts/at91-kizbox2.dts +3 −3
  33. arch/arm/boot/dts/at91-kizboxmini.dts +2 −2
  34. arch/arm/boot/dts/at91-qil_a9260.dts +1 −1
  35. arch/arm/boot/dts/at91-sama5d2_xplained.dts +107 −9
  36. arch/arm/boot/dts/at91-sama5d3_xplained.dts +1 −1
  37. arch/arm/boot/dts/at91-sama5d4_xplained.dts +1 −11
  38. arch/arm/boot/dts/at91-sama5d4ek.dts +1 −11
  39. arch/arm/boot/dts/at91rm9200ek.dts +0 −9
  40. arch/arm/boot/dts/at91sam9261ek.dts +5 −14
  41. arch/arm/boot/dts/at91sam9263ek.dts +2 −11
  42. arch/arm/boot/dts/at91sam9g20ek_common.dtsi +2 −11
  43. arch/arm/boot/dts/at91sam9m10g45ek.dts +2 −11
  44. arch/arm/boot/dts/at91sam9n12ek.dts +1 −10
  45. arch/arm/boot/dts/at91sam9rlek.dts +2 −11
  46. arch/arm/boot/dts/at91sam9x5cm.dtsi +0 −11
  47. arch/arm/boot/dts/berlin2q.dtsi +5 −3
  48. arch/arm/boot/dts/dm816x.dtsi +6 −2
  49. arch/arm/boot/dts/dra7.dtsi +2 −2
  50. arch/arm/boot/dts/k2l-netcp.dtsi +1 −1
  51. arch/arm/boot/dts/kirkwood-ts219.dtsi +1 −1
  52. arch/arm/boot/dts/rk3288-veyron-minnie.dts +4 −0
  53. arch/arm/boot/dts/rk3288.dtsi +8 −2
  54. arch/arm/boot/dts/sama5d35ek.dts +1 −1
  55. arch/arm/boot/dts/sama5d4.dtsi +1 −1
  56. arch/arm/boot/dts/usb_a9260_common.dtsi +1 −1
  57. arch/arm/boot/dts/usb_a9263.dts +1 −1
  58. arch/arm/boot/dts/vf610-colibri.dtsi +0 −5
  59. arch/arm/boot/dts/vf610.dtsi +1 −1
  60. arch/arm/boot/dts/vfxxx.dtsi +8 −6
  61. arch/arm/configs/at91_dt_defconfig +0 −1
  62. arch/arm/configs/sama5_defconfig +0 −1
  63. arch/arm/include/asm/arch_gicv3.h +1 −0
  64. arch/arm/include/asm/irq.h +5 −0
  65. arch/arm/include/asm/kvm_arm.h +17 −17
  66. arch/arm/include/asm/kvm_emulate.h +12 −0
  67. arch/arm/include/asm/kvm_host.h +6 −0
  68. arch/arm/include/asm/kvm_mmu.h +5 −0
  69. arch/arm/include/uapi/asm/unistd.h +1 −0
  70. arch/arm/kernel/bios32.c +11 −8
  71. arch/arm/kernel/calls.S +1 −0
  72. arch/arm/kvm/arm.c +36 −4
  73. arch/arm/kvm/emulate.c +38 −36
  74. arch/arm/kvm/guest.c +6 −0
  75. arch/arm/kvm/handle_exit.c +3 −0
  76. arch/arm/kvm/mmio.c +6 −2
  77. arch/arm/kvm/mmu.c +5 −5
  78. arch/arm/kvm/psci.c +10 −10
  79. arch/arm/mach-at91/Kconfig +5 −1
  80. arch/arm/mach-at91/pm.c +6 −1
  81. arch/arm/mach-dove/include/mach/entry-macro.S +2 −2
  82. arch/arm/mach-exynos/pmu.c +5 −1
  83. arch/arm/mach-imx/gpc.c +1 −0
  84. arch/arm/mach-ixp4xx/include/mach/io.h +6 −6
  85. arch/arm/mach-omap2/Kconfig +1 −1
  86. arch/arm/mach-omap2/omap-smp.c +3 −3
  87. arch/arm/mach-omap2/omap_hwmod.c +36 −30
  88. arch/arm/mach-omap2/omap_hwmod.h +3 −0
  89. arch/arm/mach-omap2/omap_hwmod_7xx_data.c +56 −0
  90. arch/arm/mach-omap2/omap_hwmod_81xx_data.c +3 −0
  91. arch/arm/mach-omap2/pdata-quirks.c +0 −29
  92. arch/arm/mach-omap2/pm34xx.c +2 −2
  93. arch/arm/mach-orion5x/include/mach/entry-macro.S +1 −1
  94. arch/arm/mach-pxa/ezx.c +5 −0
  95. arch/arm/mach-pxa/palm27x.c +1 −1
  96. arch/arm/mach-pxa/palmtc.c +1 −1
  97. arch/arm/mach-s3c24xx/pll-s3c2440-12000000.c +1 −1
  98. arch/arm/mach-s3c24xx/pll-s3c2440-16934400.c +1 −1
  99. arch/arm/mach-shmobile/setup-r8a7793.c +1 −1
  100. arch/arm/mach-zx/Kconfig +1 −1
  101. arch/arm64/Kconfig +1 −1
  102. arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi +5 −0
  103. arch/arm64/include/asm/arch_gicv3.h +1 −0
  104. arch/arm64/include/asm/cpufeature.h +20 −2
  105. arch/arm64/include/asm/hw_breakpoint.h +4 −2
  106. arch/arm64/include/asm/irq.h +5 −0
  107. arch/arm64/include/asm/kvm_arm.h +2 −1
  108. arch/arm64/include/asm/kvm_asm.h +0 −76
  109. arch/arm64/include/asm/kvm_emulate.h +13 −6
  110. arch/arm64/include/asm/kvm_host.h +86 −1
  111. arch/arm64/include/asm/kvm_mmio.h +0 −1
  112. arch/arm64/include/asm/kvm_mmu.h +8 −1
  113. arch/arm64/include/asm/pgtable.h +8 −4
  114. arch/arm64/include/asm/sysreg.h +21 −0
  115. arch/arm64/kernel/asm-offsets.c +1 −39
  116. arch/arm64/kernel/cpufeature.c +23 −14
  117. arch/arm64/kernel/efi.c +20 −13
  118. arch/arm64/kernel/vmlinux.lds.S +3 −2
  119. arch/arm64/kvm/Makefile +1 −2
  120. arch/arm64/kvm/guest.c +9 −1
  121. arch/arm64/kvm/handle_exit.c +5 −1
  122. arch/arm64/kvm/hyp-init.S +9 −0
  123. arch/arm64/kvm/hyp.S +1 −1080
  124. arch/arm64/kvm/hyp/Makefile +14 −0
  125. arch/arm64/kvm/hyp/debug-sr.c +140 −0
  126. arch/arm64/kvm/hyp/entry.S +160 −0
  127. arch/arm64/kvm/hyp/fpsimd.S +33 −0
  128. arch/arm64/kvm/hyp/hyp-entry.S +212 −0
  129. arch/arm64/kvm/hyp/hyp.h +90 −0
  130. arch/arm64/kvm/hyp/switch.c +175 −0
  131. arch/arm64/kvm/hyp/sysreg-sr.c +138 −0
  132. arch/arm64/kvm/hyp/timer-sr.c +71 −0
  133. arch/arm64/kvm/hyp/tlb.c +80 −0
  134. arch/arm64/kvm/hyp/vgic-v2-sr.c +84 −0
  135. arch/arm64/kvm/hyp/vgic-v3-sr.c +228 −0
  136. arch/arm64/kvm/sys_regs.c +83 −85
  137. arch/arm64/kvm/sys_regs.h +4 −4
  138. arch/arm64/kvm/sys_regs_generic_v8.c +2 −2
  139. arch/arm64/kvm/vgic-v2-switch.S +0 −134
  140. arch/arm64/kvm/vgic-v3-switch.S +0 −269
  141. arch/arm64/mm/context.c +26 −12
  142. arch/arm64/mm/fault.c +14 −14
  143. arch/arm64/mm/mmu.c +14 −63
  144. arch/arm64/net/bpf_jit_comp.c +32 −15
  145. arch/blackfin/kernel/perf_event.c +1 −1
  146. arch/m68k/coldfire/m54xx.c +1 −1
  147. arch/m68k/include/asm/unistd.h +1 −1
  148. arch/m68k/include/uapi/asm/unistd.h +1 −0
  149. arch/m68k/kernel/setup_no.c +6 −3
  150. arch/m68k/kernel/syscalltable.S +1 −0
  151. arch/m68k/mm/motorola.c +1 −1
  152. arch/m68k/sun3/config.c +2 −2
  153. arch/mips/mm/dma-default.c +1 −1
  154. arch/mips/pci/pci-rt2880.c +2 −2
  155. arch/mips/pmcs-msp71xx/msp_setup.c +3 −1
  156. arch/mips/sni/reset.c +4 −2
  157. arch/mn10300/Kconfig +1 −3
  158. arch/nios2/mm/cacheflush.c +4 −20
  159. arch/parisc/include/asm/pgtable.h +2 −1
  160. arch/parisc/include/uapi/asm/unistd.h +2 −1
  161. arch/parisc/kernel/pci.c +0 −18
  162. arch/parisc/kernel/syscall_table.S +1 −0
  163. arch/powerpc/boot/dts/sbc8641d.dts +0 −8
  164. arch/powerpc/include/asm/reg.h +1 −0
  165. arch/powerpc/kernel/eeh_driver.c +4 −10
  166. arch/powerpc/kernel/process.c +18 −0
  167. arch/powerpc/kernel/signal_32.c +9 −5
  168. arch/powerpc/kernel/signal_64.c +4 −0
  169. arch/powerpc/platforms/powernv/opal-irqchip.c +29 −29
  170. arch/sh/include/uapi/asm/unistd_64.h +1 −1
  171. arch/sh/kernel/perf_event.c +1 −1
  172. arch/sparc/kernel/perf_event.c +1 −1
  173. arch/tile/kernel/perf_event.c +1 −1
  174. arch/um/Makefile +1 −1
  175. arch/um/drivers/net_user.c +6 −4
  176. arch/um/kernel/signal.c +1 −1
  177. arch/x86/boot/boot.h +0 −1
  178. arch/x86/boot/video-mode.c +2 −0
  179. arch/x86/boot/video.c +2 −0
  180. arch/x86/entry/entry_64.S +18 −1
  181. arch/x86/include/asm/page_types.h +9 −7
  182. arch/x86/include/asm/pgtable_types.h +4 −10
  183. arch/x86/include/asm/x86_init.h +0 −1
  184. arch/x86/kernel/cpu/microcode/core.c +1 −0
  185. arch/x86/kernel/cpu/perf_event.c +1 −1
  186. arch/x86/kernel/cpu/perf_event.h +3 −2
  187. arch/x86/kernel/cpu/perf_event_intel.c +1 −1
  188. arch/x86/kernel/cpu/perf_event_intel_cqm.c +1 −1
  189. arch/x86/kernel/cpu/perf_event_intel_lbr.c +3 −1
  190. arch/x86/kernel/irq_work.c +1 −1
  191. arch/x86/kernel/pmem.c +12 −0
  192. arch/x86/kernel/setup.c +0 −2
  193. arch/x86/kernel/signal.c +10 −7
  194. arch/x86/kernel/smpboot.c +5 −4
  195. arch/x86/mm/mpx.c +3 −3
  196. arch/x86/pci/bus_numa.c +2 −11
  197. arch/x86/um/signal.c +10 −8
  198. block/blk-cgroup.c +3 −3
  199. block/blk-core.c +19 −14
  200. block/blk-merge.c +30 −5
  201. block/blk-mq.c +9 −5
  202. block/blk-settings.c +16 −20
  203. block/blk-sysfs.c +3 −0
  204. block/blk-timeout.c +5 −3
  205. block/noop-iosched.c +5 −5
  206. block/partition-generic.c +1 −1
  207. block/partitions/mac.c +7 −3
  208. crypto/algif_aead.c +2 −2
  209. crypto/algif_skcipher.c +3 −3
  210. drivers/Makefile +1 −1
  211. drivers/acpi/Kconfig +2 −2
  212. drivers/acpi/nfit.c +47 −18
  213. drivers/acpi/nfit.h +2 −1
  214. drivers/acpi/pci_root.c +7 −0
  215. drivers/ata/ahci.c +12 −10
  216. drivers/ata/ahci_mvebu.c +5 −0
  217. drivers/ata/libahci.c +9 −0
  218. drivers/ata/libata-eh.c +8 −0
  219. drivers/ata/sata_fsl.c +2 −1
  220. drivers/ata/sata_sil.c +3 −0
  221. drivers/base/memory.c +4 −0
  222. drivers/base/power/domain.c +1 −2
  223. drivers/base/power/domain_governor.c +0 −3
  224. drivers/block/mtip32xx/mtip32xx.c +2 −4
  225. drivers/block/null_blk.c +244 −73
  226. drivers/block/rbd.c +1 −0
  227. drivers/bus/omap-ocp2scp.c +1 −1
  228. drivers/char/ipmi/ipmi_si_intf.c +4 −4
  229. drivers/clk/clk-gpio.c +17 −16
  230. drivers/clk/clk-qoriq.c +3 −1
  231. drivers/clk/clk-scpi.c +1 −0
  232. drivers/clk/imx/clk-pllv1.c +7 −7
  233. drivers/clk/imx/clk-pllv2.c +5 −4
  234. drivers/clk/imx/clk-vf610.c +4 −4
  235. drivers/clk/mmp/clk-mmp2.c +1 −0
  236. drivers/clk/mmp/clk-pxa168.c +1 −0
  237. drivers/clk/mmp/clk-pxa910.c +1 −0
  238. drivers/clk/sunxi/clk-a10-pll2.c +5 −18
  239. drivers/clk/ti/clk-816x.c +2 −0
  240. drivers/clk/ti/clkt_dpll.c +2 −2
  241. drivers/clk/ti/divider.c +3 −13
  242. drivers/clk/ti/fapll.c +2 −2
  243. drivers/clk/ti/mux.c +3 −12
  244. drivers/clocksource/mmio.c +1 −1
  245. drivers/cpufreq/Kconfig.arm +1 −1
  246. drivers/cpufreq/cppc_cpufreq.c +2 −1
  247. drivers/cpufreq/cpufreq.c +12 −9
  248. drivers/cpufreq/intel_pstate.c +5 −1
  249. drivers/cpufreq/s3c24xx-cpufreq.c +1 −1
  250. drivers/crypto/nx/nx-aes-ccm.c +1 −1
  251. drivers/crypto/nx/nx-aes-gcm.c +2 −1
  252. drivers/crypto/talitos.c +1 −1
  253. drivers/fpga/fpga-mgr.c +4 −9
  254. drivers/gpio/gpio-74xx-mmio.c +5 −2
  255. drivers/gpio/gpio-omap.c +0 −2
  256. drivers/gpio/gpio-palmas.c +2 −0
  257. drivers/gpio/gpio-syscon.c +5 −1
  258. drivers/gpio/gpio-tegra.c +56 −49
  259. drivers/gpio/gpiolib.c +1 −1
  260. drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 −2
  261. drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +4 −6
  262. drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +79 −29
  263. drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +13 −14
  264. drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +47 −1
  265. drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +5 −0
  266. drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 −0
  267. drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +11 −6
  268. drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +10 −1
  269. drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +29 −11
  270. drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +4 −1
  271. drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +4 −1
  272. drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +4 −1
  273. drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +1 −1
  274. drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +1 −1
  275. drivers/gpu/drm/amd/amdgpu/vce_v3_0.c +19 −5
  276. drivers/gpu/drm/amd/scheduler/gpu_scheduler.c +85 −42
  277. drivers/gpu/drm/amd/scheduler/gpu_scheduler.h +4 −1
  278. drivers/gpu/drm/amd/scheduler/sched_fence.c +13 −0
  279. drivers/gpu/drm/drm_drv.c +5 −0
  280. drivers/gpu/drm/drm_fops.c +56 −28
  281. drivers/gpu/drm/drm_irq.c +53 −1
  282. drivers/gpu/drm/i915/i915_debugfs.c +2 −0
  283. drivers/gpu/drm/i915/i915_drv.h +1 −0
  284. drivers/gpu/drm/i915/i915_gem.c +10 −2
  285. drivers/gpu/drm/i915/i915_gem_fence.c +27 −9
  286. drivers/gpu/drm/i915/intel_display.c +51 −2
  287. drivers/gpu/drm/i915/intel_dp.c +16 −35
  288. drivers/gpu/drm/i915/intel_drv.h +2 −2
  289. drivers/gpu/drm/i915/intel_hdmi.c +6 −6
  290. drivers/gpu/drm/i915/intel_i2c.c +4 −2
  291. drivers/gpu/drm/i915/intel_runtime_pm.c +4 −30
  292. drivers/gpu/drm/imx/imx-drm-core.c +3 −4
  293. drivers/gpu/drm/imx/imx-drm.h +2 −1
  294. drivers/gpu/drm/imx/imx-tve.c +1 −0
  295. drivers/gpu/drm/imx/ipuv3-crtc.c +17 −46
  296. drivers/gpu/drm/imx/ipuv3-plane.c +4 −5
  297. drivers/gpu/drm/imx/ipuv3-plane.h +1 −1
  298. drivers/gpu/drm/imx/parallel-display.c +4 −0
  299. drivers/gpu/drm/nouveau/include/nvkm/core/device.h +0 −1
  300. drivers/gpu/drm/nouveau/include/nvkm/subdev/instmem.h +1 −0
  301. drivers/gpu/drm/nouveau/nouveau_acpi.c +1 −0
  302. drivers/gpu/drm/nouveau/nouveau_display.c +11 −8
  303. drivers/gpu/drm/nouveau/nouveau_drm.h +3 −1
  304. drivers/gpu/drm/nouveau/nouveau_usif.c +4 −1
  305. drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c +2 −17
  306. drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgf117.c +2 −0
  307. drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpc.fuc +5 −3
  308. drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgf117.fuc3.h +172 −172
  309. drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk104.fuc3.h +172 −172
  310. drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk110.fuc3.h +172 −172
  311. drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk208.fuc5.h +154 −154
  312. drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgm107.fuc5.h +237 −237
  313. drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c +4 −2
  314. drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h +1 −0
  315. drivers/gpu/drm/nouveau/nvkm/subdev/instmem/base.c +5 −0
  316. drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk104.c +1 −3
  317. drivers/gpu/drm/nouveau/nvkm/subdev/volt/gk104.c +1 −1
  318. drivers/gpu/drm/radeon/cik.c +5 −6
  319. drivers/gpu/drm/radeon/evergreen.c +4 −1
  320. drivers/gpu/drm/radeon/r100.c +11 −1
  321. drivers/gpu/drm/radeon/r600.c +1 −1
  322. drivers/gpu/drm/radeon/radeon.h +1 −1
  323. drivers/gpu/drm/radeon/radeon_agp.c +3 −0
  324. drivers/gpu/drm/radeon/radeon_connectors.c +20 −1
  325. drivers/gpu/drm/radeon/radeon_display.c +79 −27
  326. drivers/gpu/drm/radeon/radeon_irq_kms.c +4 −4
  327. drivers/gpu/drm/radeon/radeon_kms.c +49 −1
  328. drivers/gpu/drm/radeon/radeon_mode.h +5 −0
  329. drivers/gpu/drm/radeon/radeon_pm.c +3 −1
  330. drivers/gpu/drm/radeon/radeon_vce.c +50 −50
  331. drivers/gpu/drm/radeon/rs600.c +1 −1
  332. drivers/gpu/drm/radeon/rs690.c +10 −0
  333. drivers/gpu/drm/radeon/rv730_dpm.c +1 −1
  334. drivers/gpu/drm/radeon/rv770_dpm.c +2 −2
  335. drivers/gpu/drm/radeon/si.c +4 −1
  336. drivers/gpu/drm/rockchip/rockchip_drm_gem.c +1 −0
  337. drivers/gpu/drm/rockchip/rockchip_drm_vop.c +18 −25
  338. drivers/gpu/drm/ttm/ttm_lock.c +1 −1
  339. drivers/gpu/drm/virtio/virtgpu_display.c +1 −1
  340. drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +1 −0
  341. drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +1 −0
  342. drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c +1 −1
  343. drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +51 −13
  344. drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +5 −2
  345. drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c +1 −1
  346. drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +1 −1
  347. drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +1 −1
  348. drivers/gpu/ipu-v3/ipu-common.c +38 −31
  349. drivers/gpu/vga/vgaarb.c +4 −2
  350. drivers/hid/hid-ids.h +1 −5
  351. drivers/hid/hid-lg.c +3 −2
  352. drivers/hid/usbhid/hid-quirks.c +4 −6
  353. drivers/iio/adc/qcom-spmi-vadc.c +3 −1
  354. drivers/iio/industrialio-buffer.c +1 −1
  355. drivers/iio/industrialio-core.c +1 −1
  356. drivers/iio/light/apds9960.c +1 −0
  357. drivers/iio/proximity/pulsedlight-lidar-lite-v2.c +3 −3
  358. drivers/infiniband/core/cma.c +1 −4
  359. drivers/infiniband/core/mad.c +5 −0
  360. drivers/infiniband/core/sa_query.c +17 −15
  361. drivers/infiniband/core/uverbs_cmd.c +17 −10
  362. drivers/infiniband/core/verbs.c +22 −21
  363. drivers/infiniband/hw/mlx4/main.c +1 −1
  364. drivers/infiniband/hw/mlx4/qp.c +13 −6
  365. drivers/infiniband/hw/mlx4/srq.c +8 −3
  366. drivers/infiniband/hw/mlx5/mr.c +13 −1
  367. drivers/infiniband/hw/qib/qib_qsfp.c +2 −2
  368. drivers/infiniband/hw/qib/qib_verbs.h +1 −1
  369. drivers/infiniband/ulp/iser/iser_verbs.c +1 −1
  370. drivers/infiniband/ulp/isert/ib_isert.c +3 −10
  371. drivers/infiniband/ulp/srp/ib_srp.c +26 −22
  372. drivers/infiniband/ulp/srp/ib_srp.h +1 −4
  373. drivers/irqchip/irq-versatile-fpga.c +5 −0
  374. drivers/isdn/hisax/config.c +1 −1
  375. drivers/isdn/hisax/hfc_pci.c +1 −1
  376. drivers/isdn/hisax/hfc_sx.c +1 −1
  377. drivers/isdn/hisax/q931.c +3 −3
  378. drivers/lightnvm/Kconfig +1 −0
  379. drivers/lightnvm/core.c +88 −70
  380. drivers/lightnvm/gennvm.c +72 −33
  381. drivers/lightnvm/gennvm.h +2 −0
  382. drivers/lightnvm/rrpc.c +52 −5
  383. drivers/md/dm-crypt.c +13 −9
  384. drivers/md/dm-mpath.c +16 −14
  385. drivers/md/dm-thin-metadata.c +29 −5
  386. drivers/md/dm-thin.c +3 −3
  387. drivers/md/dm.c +4 −3
  388. drivers/md/persistent-data/dm-btree.c +99 −2
  389. drivers/md/persistent-data/dm-btree.h +11 −3
  390. drivers/md/persistent-data/dm-space-map-metadata.c +22 −10
  391. drivers/misc/cxl/native.c +1 −1
  392. drivers/net/can/bfin_can.c +0 −2
  393. drivers/net/can/c_can/c_can.c +2 −5
  394. drivers/net/can/cc770/cc770.c +1 −1
  395. drivers/net/can/flexcan.c +2 −2
  396. drivers/net/can/janz-ican3.c +0 −1
  397. drivers/net/can/m_can/m_can.c +2 −5
  398. drivers/net/can/pch_can.c +1 −2
  399. drivers/net/can/rcar_can.c +5 −6
  400. drivers/net/can/sja1000/sja1000.c +3 −1
  401. drivers/net/can/sun4i_can.c +0 −1
  402. drivers/net/can/ti_hecc.c +2 −5
  403. drivers/net/can/usb/ems_usb.c +0 −1
  404. drivers/net/can/usb/esd_usb2.c +0 −1
  405. drivers/net/can/usb/kvaser_usb.c +2 −3
  406. drivers/net/can/usb/usb_8dev.c +1 −3
  407. drivers/net/can/xilinx_can.c +3 −6
  408. drivers/net/ethernet/Kconfig +1 −0
  409. drivers/net/ethernet/Makefile +1 −0
  410. drivers/net/ethernet/apm/xgene/xgene_enet_main.c +17 −14
  411. drivers/net/ethernet/atheros/alx/main.c +2 −0
  412. drivers/net/ethernet/atheros/alx/reg.h +1 −0
  413. drivers/net/ethernet/aurora/Kconfig +20 −0
  414. drivers/net/ethernet/aurora/Makefile +1 −0
  415. drivers/net/ethernet/aurora/nb8800.c +1552 −0
  416. drivers/net/ethernet/aurora/nb8800.h +316 −0
  417. drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +2 −2
  418. drivers/net/ethernet/broadcom/bnxt/bnxt.c +31 −13
  419. drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +3 −4
  420. drivers/net/ethernet/cadence/macb.c +4 −0
  421. drivers/net/ethernet/cadence/macb.h +5 −0
  422. drivers/net/ethernet/cavium/thunder/nic.h +2 −3
  423. drivers/net/ethernet/cavium/thunder/nic_main.c +20 −3
  424. drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c +15 −1
  425. drivers/net/ethernet/cavium/thunder/nicvf_main.c +1 −3
  426. drivers/net/ethernet/cavium/thunder/nicvf_queues.c +1 −1
  427. drivers/net/ethernet/cavium/thunder/nicvf_queues.h +1 −1
  428. drivers/net/ethernet/cavium/thunder/thunder_bgx.c +24 −4
  429. drivers/net/ethernet/cavium/thunder/thunder_bgx.h +2 −0
  430. drivers/net/ethernet/dec/tulip/tulip_core.c +7 −2
  431. drivers/net/ethernet/dec/tulip/winbond-840.c +1 −1
  432. drivers/net/ethernet/freescale/Kconfig +2 −1
  433. drivers/net/ethernet/freescale/gianfar.c +3 −3
  434. drivers/net/ethernet/freescale/gianfar_ptp.c +1 −1
  435. drivers/net/ethernet/intel/fm10k/fm10k_netdev.c +3 −1
  436. drivers/net/ethernet/marvell/mvneta.c +27 −6
  437. drivers/net/ethernet/mellanox/mlx4/cmd.c +1 −1
  438. drivers/net/ethernet/nxp/lpc_eth.c +1 −1
  439. drivers/net/ethernet/renesas/ravb_main.c +4 −2
  440. drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c +7 −6
  441. drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +8 −1
  442. drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +13 −15
  443. drivers/net/ethernet/ti/cpsw-common.c +3 −0
  444. drivers/net/macvtap.c +2 −2
  445. drivers/net/phy/broadcom.c +1 −1
  446. drivers/net/phy/phy.c +2 −1
  447. drivers/net/tun.c +2 −2
  448. drivers/net/usb/cdc_ncm.c +4 −4
  449. drivers/net/usb/qmi_wwan.c +1 −0
  450. drivers/net/virtio_net.c +19 −15
  451. drivers/net/vmxnet3/vmxnet3_drv.c +60 −11
  452. drivers/net/vrf.c +1 −10
  453. drivers/net/wan/hdlc_fr.c +5 −5
  454. drivers/net/wan/x25_asy.c +1 −5
  455. drivers/net/wireless/ath/ath10k/core.c +47 −2
  456. drivers/net/wireless/ath/ath10k/core.h +1 −0
  457. drivers/net/wireless/ath/ath10k/hw.h +15 −2
  458. drivers/net/wireless/ath/ath10k/mac.c +1 −1
  459. drivers/net/wireless/ath/ath10k/pci.c +43 −10
  460. drivers/net/wireless/iwlwifi/iwl-7000.c +1 −1
  461. drivers/net/wireless/iwlwifi/iwl-8000.c +1 −1
  462. drivers/net/wireless/iwlwifi/mvm/d3.c +2 −6
  463. drivers/net/wireless/iwlwifi/mvm/mac80211.c +8 −3
  464. drivers/net/wireless/iwlwifi/mvm/sta.c +47 −41
  465. drivers/net/wireless/iwlwifi/mvm/sta.h +2 −2
  466. drivers/net/wireless/iwlwifi/pcie/drv.c +18 −1
  467. drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c +1 −1
  468. drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c +1 −1
  469. drivers/nvme/host/Makefile +2 −1
  470. drivers/nvme/host/lightnvm.c +130 −57
  471. drivers/nvme/host/nvme.h +14 −0
  472. drivers/nvme/host/pci.c +37 −14
  473. drivers/of/address.c +3 −2
  474. drivers/of/fdt.c +6 −1
  475. drivers/of/irq.c +2 −1
  476. drivers/of/of_reserved_mem.c +7 −1
  477. drivers/parisc/iommu-helpers.h +8 −7
  478. drivers/pci/host/pcie-altera.c +16 −7
  479. drivers/pci/host/pcie-designware.c +0 −1
  480. drivers/pci/host/pcie-hisi.c +2 −2
  481. drivers/pci/msi.c +2 −2
  482. drivers/pci/pci-driver.c +14 −2
  483. drivers/pci/pci-sysfs.c +4 −1
  484. drivers/pci/pci.h +0 −2
  485. drivers/pinctrl/Kconfig +0 −4
  486. drivers/pinctrl/freescale/pinctrl-imx1-core.c +6 −2
  487. drivers/pinctrl/mediatek/pinctrl-mtk-common.c +4 −7
  488. drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c +1 −1
  489. drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c +1 −1
  490. drivers/pinctrl/sh-pfc/pfc-sh7734.c +3 −3
  491. drivers/remoteproc/remoteproc_core.c +2 −0
  492. drivers/remoteproc/remoteproc_debugfs.c +1 −1
  493. drivers/rtc/rtc-ds1307.c +8 −36
  494. drivers/scsi/Kconfig +2 −0
  495. drivers/scsi/advansys.c +1 −1
  496. drivers/scsi/hosts.c +11 −0
  497. drivers/scsi/hpsa.c +1 −1
  498. drivers/scsi/mpt3sas/Kconfig +9 −0
  499. drivers/scsi/mpt3sas/mpt3sas_scsih.c +1 −2
  500. drivers/scsi/mvsas/mv_init.c +2 −2
  501. drivers/scsi/qla2xxx/qla_nx.c +2 −1
  502. drivers/scsi/qla2xxx/tcm_qla2xxx.c +1 −1
  503. drivers/scsi/scsi_debug.c +5 −4
  504. drivers/scsi/scsi_scan.c +6 −3
  505. drivers/scsi/scsi_sysfs.c +11 −11
  506. drivers/scsi/sd.c +48 −21
  507. drivers/scsi/sd.h +1 −0
  508. drivers/scsi/st.c +3 −2
  509. drivers/soc/mediatek/Kconfig +1 −0
  510. drivers/soc/ti/knav_qmss_queue.c +4 −4
  511. drivers/spi/spi-bcm63xx.c +2 −2
  512. drivers/spi/spi-mt65xx.c +18 −8
  513. drivers/spi/spi-pl022.c +22 −6
  514. drivers/spi/spi.c +2 −0
  515. drivers/staging/iio/iio_simple_dummy_events.c +1 −1
  516. drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h +0 −1
  517. drivers/staging/lustre/lustre/libcfs/module.c +0 −17
  518. drivers/staging/lustre/lustre/obdecho/echo_client.c +11 −9
  519. drivers/target/iscsi/iscsi_target.c +12 −1
  520. drivers/target/iscsi/iscsi_target_nego.c +1 −0
  521. drivers/target/iscsi/iscsi_target_parameters.c +5 −5
  522. drivers/target/target_core_sbc.c +11 −6
  523. drivers/target/target_core_stat.c +1 −1
  524. drivers/target/target_core_tmr.c +6 −1
  525. drivers/target/target_core_transport.c +14 −12
  526. drivers/target/target_core_user.c +1 −3
  527. drivers/thermal/Kconfig +1 −1
  528. drivers/thermal/imx_thermal.c +41 −15
  529. drivers/thermal/of-thermal.c +1 −1
  530. drivers/thermal/power_allocator.c +7 −17
  531. drivers/thermal/rcar_thermal.c +21 −28
  532. drivers/thermal/rockchip_thermal.c +240 −88
  533. drivers/usb/class/cdc-acm.c +5 −0
  534. drivers/usb/core/config.c +2 −1
  535. drivers/usb/core/hub.c +14 −8
  536. drivers/usb/core/port.c +2 −2
  537. drivers/usb/core/quirks.c +9 −0
  538. drivers/usb/dwc2/platform.c +53 −28
  539. drivers/usb/dwc3/gadget.c +1 −0
  540. drivers/usb/gadget/function/f_fs.c +3 −3
  541. drivers/usb/gadget/function/f_midi.c +2 −1
  542. drivers/usb/gadget/function/uvc_configfs.c +1 −1
  543. drivers/usb/gadget/udc/pxa27x_udc.c +3 −0
  544. drivers/usb/host/ohci-at91.c +5 −6
  545. drivers/usb/host/whci/qset.c +4 −0
  546. drivers/usb/host/xhci-hub.c +42 −5
  547. drivers/usb/host/xhci-pci.c +6 −2
  548. drivers/usb/host/xhci-ring.c +2 −1
  549. drivers/usb/host/xhci.c +8 −0
  550. drivers/usb/musb/Kconfig +1 −1
  551. drivers/usb/musb/musb_core.c +7 −1
  552. drivers/usb/phy/phy-msm-usb.c +3 −3
  553. drivers/usb/phy/phy-mxs-usb.c +5 −0
  554. drivers/usb/renesas_usbhs/mod_gadget.c +9 −2
  555. drivers/usb/serial/cp210x.c +0 −1
  556. drivers/usb/serial/usb-serial-simple.c +1 −0
  557. drivers/usb/storage/uas.c +4 −0
  558. drivers/usb/storage/unusual_devs.h +1 −1
  559. drivers/usb/storage/unusual_uas.h +1 −1
  560. drivers/vfio/Kconfig +0 −15
  561. drivers/vfio/pci/vfio_pci.c +5 −5
  562. drivers/vfio/platform/vfio_platform.c +0 −1
  563. drivers/vfio/platform/vfio_platform_common.c +1 −4
  564. drivers/vfio/vfio.c +7 −181
  565. drivers/vhost/vhost.c +4 −4
  566. drivers/virtio/virtio.c +1 −0
  567. drivers/virtio/virtio_ring.c +35 −13
  568. drivers/watchdog/Kconfig +1 −1
  569. drivers/watchdog/mtk_wdt.c +1 −0
  570. drivers/watchdog/omap_wdt.c +1 −1
  571. drivers/watchdog/pnx4008_wdt.c +4 −4
  572. drivers/watchdog/tegra_wdt.c +3 −1
  573. drivers/watchdog/w83977f_wdt.c +1 −1
  574. drivers/xen/events/events_base.c +3 −2
  575. drivers/xen/evtchn.c +107 −16
  576. drivers/xen/gntdev.c +1 −1
  577. fs/9p/vfs_inode.c +2 −2
  578. fs/block_dev.c +6 −3
  579. fs/btrfs/backref.c +1 −1
  580. fs/btrfs/ctree.h +4 −0
  581. fs/btrfs/extent-tree.c +100 −23
  582. fs/btrfs/file.c +7 −3
  583. fs/btrfs/inode.c +1 −23
  584. fs/btrfs/qgroup.c +4 −1
  585. fs/btrfs/scrub.c +56 −6
  586. fs/btrfs/tests/free-space-tests.c +3 −1
  587. fs/btrfs/transaction.c +32 −0
  588. fs/btrfs/transaction.h +4 −0
  589. fs/btrfs/volumes.c +6 −7
  590. fs/btrfs/volumes.h +1 −1
  591. fs/cifs/inode.c +3 −3
  592. fs/direct-io.c +10 −1
  593. fs/dlm/lowcomms.c +2 −2
  594. fs/exofs/inode.c +1 −4
  595. fs/ext4/crypto.c +1 −1
  596. fs/ext4/ext4.h +44 −7
  597. fs/ext4/symlink.c +1 −1
  598. fs/ext4/sysfs.c +1 −1
  599. fs/fuse/cuse.c +2 −0
  600. fs/fuse/file.c +1 −1
  601. fs/jbd2/transaction.c +9 −3
  602. fs/namei.c +0 −1
  603. fs/nfs/inode.c +12 −5
  604. fs/nfs/internal.h +1 −1
  605. fs/nfs/nfs42proc.c +2 −1
  606. fs/nfs/nfs4client.c +1 −1
  607. fs/nfs/nfs4file.c +27 −32
  608. fs/nfs/nfs4proc.c +1 −1
  609. fs/nfs/nfs4xdr.c +1 −0
  610. fs/nfs/objlayout/objio_osd.c +1 −4
  611. fs/nfs/pagelist.c +1 −1
  612. fs/nfs/pnfs.c +33 −27
  613. fs/ocfs2/namei.c +1 −3
  614. fs/overlayfs/copy_up.c +6 −17
  615. fs/overlayfs/inode.c +8 −11
  616. fs/overlayfs/overlayfs.h +1 −2
  617. fs/splice.c +8 −0
  618. fs/sysv/inode.c +2 −9
  619. include/asm-generic/tlb.h +1 −1
  620. include/clocksource/arm_arch_timer.h +6 −0
  621. include/drm/drmP.h +10 −0
  622. include/kvm/arm_vgic.h +6 −0
  623. include/linux/acpi.h +2 −2
  624. include/linux/bitops.h +1 −1
  625. include/linux/blkdev.h +1 −2
  626. include/linux/bpf.h +4 −1
  627. include/linux/cgroup-defs.h +3 −10
  628. include/linux/cgroup.h +23 −24
  629. include/linux/cpufreq.h +1 −0
  630. include/linux/dns_resolver.h +1 −1
  631. include/linux/ipv6.h +1 −1
  632. include/linux/irqchip/arm-gic-v3.h +1 −0
  633. include/linux/jump_label.h +1 −1
  634. include/linux/kmemleak.h +1 −1
  635. include/linux/kref.h +0 −33
  636. include/linux/libata.h +1 −0
  637. include/linux/lightnvm.h +58 −139
  638. include/linux/lockdep.h +1 −1
  639. include/linux/mlx4/device.h +11 −0
  640. include/linux/net.h +9 −4
  641. include/linux/netdevice.h +2 −1
  642. include/linux/nfs_xdr.h +1 −0
  643. include/linux/of_irq.h +12 −7
  644. include/linux/pci.h +9 −0
  645. include/linux/perf_event.h +4 −2
  646. include/linux/proportions.h +1 −1
  647. include/linux/scpi_protocol.h +1 −1
  648. include/linux/stop_machine.h +3 −3
  649. include/linux/syscalls.h +1 −1
  650. include/linux/thermal.h +2 −1
  651. include/linux/types.h +1 −1
  652. include/linux/uprobes.h +1 −1
  653. include/linux/usb/quirks.h +3 −0
  654. include/linux/vfio.h +0 −3
  655. include/linux/wait.h +5 −5
  656. include/net/af_unix.h +1 −0
  657. include/net/ip6_route.h +4 −13
  658. include/net/ipv6.h +21 −1
  659. include/net/mac80211.h +4 −2
  660. include/net/ndisc.h +1 −2
  661. include/net/sch_generic.h +3 −0
  662. include/net/sctp/structs.h +8 −8
  663. include/net/sock.h +25 −7
  664. include/rdma/ib_mad.h +2 −0
  665. include/rdma/ib_verbs.h +1 −0
  666. include/scsi/scsi_host.h +3 −0
  667. include/sound/hda_register.h +3 −0
  668. include/sound/soc-dapm.h +1 −0
  669. include/target/target_core_base.h +1 −1
  670. include/uapi/linux/nfs.h +0 −11
  671. include/uapi/linux/vfio.h +0 −7
  672. include/video/imx-ipu-v3.h +0 −1
  673. init/Kconfig +0 −7
  674. kernel/bpf/arraymap.c +8 −2
  675. kernel/bpf/hashtab.c +25 −9
  676. kernel/bpf/inode.c +3 −3
  677. kernel/bpf/syscall.c +27 −13
  678. kernel/bpf/verifier.c +1 −2
  679. kernel/cgroup.c +78 −21
  680. kernel/cgroup_freezer.c +10 −13
  681. kernel/cgroup_pids.c +20 −57
  682. kernel/cpuset.c +21 −12
  683. kernel/events/callchain.c +1 −1
  684. kernel/events/core.c +64 −26
  685. kernel/events/ring_buffer.c +1 −1
  686. kernel/events/uprobes.c +1 −1
  687. kernel/fork.c +3 −6
  688. kernel/irq_work.c +1 −1
  689. kernel/jump_label.c +1 −1
  690. kernel/locking/lockdep.c +1 −1
  691. kernel/locking/lockdep_proc.c +1 −1
  692. kernel/pid.c +2 −2
  693. kernel/sched/clock.c +1 −1
  694. kernel/sched/core.c +36 −12
  695. kernel/sched/cputime.c +3 −0
  696. kernel/sched/fair.c +1 −1
  697. kernel/sched/rt.c +1 −1
  698. kernel/sched/sched.h +3 −0
  699. kernel/sched/wait.c +14 −14
  700. kernel/stop_machine.c +2 −2
  701. kernel/trace/ring_buffer.c +9 −8
  702. kernel/trace/trace_event_perf.c +1 −1
  703. kernel/trace/trace_events.c +16 −0
  704. lib/btree.c +1 −1
  705. lib/proportions.c +1 −1
  706. mm/backing-dev.c +16 −3
  707. mm/hugetlb.c +20 −7
  708. mm/memcontrol.c +25 −24
  709. mm/oom_kill.c +2 −0
  710. mm/page-writeback.c +1 −1
  711. mm/page_alloc.c +2 −1
  712. mm/shmem.c +14 −20
  713. mm/vmstat.c +5 −3
  714. net/bluetooth/af_bluetooth.c +3 −3
  715. net/bluetooth/smp.c +6 −1
  716. net/caif/caif_socket.c +2 −2
  717. net/core/datagram.c +1 −1
  718. net/core/neighbour.c +2 −2
  719. net/core/netclassid_cgroup.c +20 −8
  720. net/core/netprio_cgroup.c +5 −4
  721. net/core/scm.c +2 −0
  722. net/core/sock.c +5 −7
  723. net/core/stream.c +3 −3
  724. net/dccp/ipv6.c +23 −14
  725. net/dccp/proto.c +1 −2
  726. net/decnet/af_decnet.c +4 −4
  727. net/dns_resolver/dns_query.c +1 −1
  728. net/hsr/hsr_device.c +1 −1
  729. net/ipv4/igmp.c +3 −2
  730. net/ipv4/ipmr.c +8 −15
  731. net/ipv4/tcp.c +3 −4
  732. net/ipv4/tcp_input.c +20 −3
  733. net/ipv4/tcp_ipv4.c +2 −1
  734. net/ipv4/tcp_timer.c +13 −1
  735. net/ipv4/udp.c +0 −1
  736. net/ipv6/addrconf.c +1 −1
  737. net/ipv6/af_inet6.c +10 −5
  738. net/ipv6/datagram.c +3 −1
  739. net/ipv6/exthdrs.c +2 −1
  740. net/ipv6/icmp.c +0 −14
  741. net/ipv6/inet6_connection_sock.c +9 −12
  742. net/ipv6/ip6_tunnel.c +1 −1
  743. net/ipv6/ip6mr.c +8 −11
  744. net/ipv6/ipv6_sockglue.c +22 −11
  745. net/ipv6/ndisc.c +3 −7
  746. net/ipv6/netfilter/nf_conntrack_reasm.c +3 −2
  747. net/ipv6/raw.c +6 −2
  748. net/ipv6/reassembly.c +7 −3
  749. net/ipv6/route.c +1 −1
  750. net/ipv6/syncookies.c +1 −1
  751. net/ipv6/tcp_ipv6.c +19 −13
  752. net/ipv6/udp.c +6 −2
  753. net/iucv/af_iucv.c +1 −1
  754. net/l2tp/l2tp_ip6.c +6 −2
  755. net/mac80211/agg-tx.c +2 −1
  756. net/mac80211/cfg.c +6 −2
  757. net/mac80211/iface.c +3 −2
  758. net/mac80211/main.c +1 −2
  759. net/mac80211/mesh_pathtbl.c +4 −4
  760. net/mac80211/scan.c +5 −4
  761. net/nfc/llcp_sock.c +1 −1
  762. net/openvswitch/dp_notify.c +1 −1
  763. net/openvswitch/vport-geneve.c +0 −1
  764. net/openvswitch/vport-gre.c +0 −1
  765. net/openvswitch/vport-netdev.c +6 −2
  766. net/openvswitch/vport.c +4 −4
  767. net/openvswitch/vport.h +7 −1
  768. net/packet/af_packet.c +2 −2
  769. net/rds/connection.c +0 −6
  770. net/rds/send.c +3 −1
  771. net/rxrpc/ar-ack.c +3 −1
  772. net/rxrpc/ar-output.c +1 −1
  773. net/sched/sch_api.c +18 −9
  774. net/sched/sch_generic.c +1 −1
  775. net/sched/sch_mq.c +2 −2
  776. net/sched/sch_mqprio.c +2 −2
  777. net/sctp/ipv6.c +10 −3
  778. net/sctp/socket.c +25 −14
  779. net/socket.c +7 −14
  780. net/sunrpc/sched.c +3 −3
  781. net/sunrpc/svc.c +13 −0
  782. net/sunrpc/xprtsock.c +7 −7
  783. net/tipc/link.c +2 −0
  784. net/tipc/socket.c +7 −3
  785. net/tipc/udp_media.c +5 −2
  786. net/unix/af_unix.c +231 −37
  787. scripts/link-vmlinux.sh +1 −1
  788. security/keys/encrypted-keys/encrypted.c +2 −0
  789. security/keys/trusted.c +4 −1
  790. security/keys/user_defined.c +4 −1
  791. security/selinux/ss/conditional.c +2 −2
  792. sound/firewire/dice/dice.c +4 −0
  793. sound/pci/hda/hda_intel.c +30 −0
  794. sound/pci/hda/patch_ca0132.c +2 −1
  795. sound/pci/hda/patch_conexant.c +3 −2
  796. sound/pci/hda/patch_hdmi.c +8 −1
  797. sound/pci/hda/patch_realtek.c +54 −1
  798. sound/pci/hda/patch_sigmatel.c +29 −16
  799. sound/pci/rme96.c +26 −15
  800. sound/soc/codecs/arizona.c +5 −11
  801. sound/soc/codecs/es8328.c +8 −8
  802. sound/soc/codecs/nau8825.c +31 −0
  803. sound/soc/codecs/rl6231.c +4 −2
  804. sound/soc/codecs/rt5645.c +57 −4
  805. sound/soc/codecs/rt5670.h +6 −6
  806. sound/soc/codecs/rt5677.c +61 −39
  807. sound/soc/codecs/wm8960.c +1 −1
  808. sound/soc/codecs/wm8962.c +2 −2
  809. sound/soc/davinci/davinci-mcasp.c +10 −2
  810. sound/soc/fsl/Kconfig +2 −0
  811. sound/soc/fsl/fsl_sai.c +2 −1
  812. sound/soc/intel/Kconfig +1 −1
  813. sound/soc/intel/skylake/skl-topology.c +1 −0
  814. sound/soc/rockchip/rockchip_spdif.c +1 −1
  815. sound/soc/rockchip/rockchip_spdif.h +3 −3
  816. sound/soc/sh/rcar/gen.c +1 −1
  817. sound/soc/sh/rcar/src.c +7 −0
  818. sound/soc/soc-core.c +3 −3
  819. sound/soc/soc-dapm.c +7 −0
  820. sound/soc/soc-ops.c +1 −1
  821. sound/soc/soc-topology.c +2 −1
  822. sound/soc/sti/uniperif_player.c +6 −3
  823. sound/soc/sti/uniperif_reader.c +1 −2
  824. sound/soc/sunxi/sun4i-codec.c +14 −13
  825. sound/usb/midi.c +46 −0
  826. sound/usb/quirks-table.h +11 −0
  827. sound/usb/quirks.c +1 −0
  828. sound/usb/usbaudio.h +1 −0
  829. tools/testing/nvdimm/test/nfit.c +15 −34
  830. tools/testing/selftests/futex/README +1 −1
  831. tools/testing/selftests/seccomp/seccomp_bpf.c +7 −4
  832. tools/virtio/linux/kernel.h +6 −0
  833. tools/virtio/linux/virtio.h +0 −6
  834. tools/virtio/linux/virtio_config.h +13 −7
  835. virt/kvm/arm/vgic-v3.c +3 −8
  836. virt/kvm/arm/vgic.c +1 −1
Documentation/arm/keystone/Overview.txt+0−18
@@ -49,24 +49,6 @@ specified through DTS. Following are the DTS used:- · 48 unmodified lines
4949 The device tree documentation for the keystone machines are located at
5050 Documentation/devicetree/bindings/arm/keystone/keystone.txt
5151
52−Known issues & workaround
53−-------------------------
54−
55−Some of the device drivers used on keystone are re-used from that from
56−DaVinci and other TI SoCs. These device drivers may use clock APIs directly.
57−Some of the keystone specific drivers such as netcp uses run time power
58−management API instead to enable clock. As this API has limitations on
59−keystone, following workaround is needed to boot Linux.
60−
61− Add 'clk_ignore_unused' to the bootargs env variable in u-boot. Otherwise
62− clock frameworks will try to disable clocks that are unused and disable
63− the hardware. This is because netcp related power domain and clock
64− domains are enabled in u-boot as run time power management API currently
65− doesn't enable clocks for netcp due to a limitation. This workaround is
66− expected to be removed in the future when proper API support becomes
67− available. Until then, this work around is needed.
68−
69−
7052 Document Author
7153 ---------------
7254 Murali Karicheri <m-karicheri2@ti.com>
Documentation/block/null_blk.txt+3−0
@@ -70,3 +70,6 @@ use_per_node_hctx=[0/1]: Default: 0 · 69 unmodified lines
7070 parameter.
7171 1: The multi-queue block layer is instantiated with a hardware dispatch
7272 queue for each CPU node in the system.
73+
74+use_lightnvm=[0/1]: Default: 0
75+ Register device with LightNVM. Requires blk-mq to be used.
Documentation/devicetree/bindings/gpio/gpio-mpc8xxx.txt+4−0
@@ -11,6 +11,10 @@ Required properties: · 10 unmodified lines
1111 0 = active high
1212 1 = active low
1313
14+Optional properties:
15+- little-endian : GPIO registers are used as little endian. If not
16+ present registers are used as big endian by default.
17+
1418 Example:
1519
1620 gpio0: gpio@1100 {
Documentation/devicetree/bindings/net/marvell-armada-370-neta.txt+6−0
@@ -8,6 +8,11 @@ Required properties: · 7 unmodified lines
88 - phy-mode: See ethernet.txt file in the same directory
99 - clocks: a pointer to the reference clock for this device.
1010
11+Optional properties:
12+- tx-csum-limit: maximum mtu supported by port that allow TX checksum.
13+ Value is presented in bytes. If not used, by default 1600B is set for
14+ "marvell,armada-370-neta" and 9800B for others.
15+
1116 Example:
1217
1318 ethernet@d0070000 {
@@ -15,6 +20,7 @@ ethernet@d0070000 { · 1 unmodified line
1520 reg = <0xd0070000 0x2500>;
1621 interrupts = <8>;
1722 clocks = <&gate_clk 4>;
23+ tx-csum-limit = <9800>
1824 status = "okay";
1925 phy = <&phy0>;
2026 phy-mode = "rgmii-id";
Documentation/devicetree/bindings/thermal/rockchip-thermal.txt+3−1
@@ -1,7 +1,9 @@
11 * Temperature Sensor ADC (TSADC) on rockchip SoCs
22
33 Required properties:
4−- compatible : "rockchip,rk3288-tsadc"
4+- compatible : should be "rockchip,<name>-tsadc"
5+ "rockchip,rk3288-tsadc": found on RK3288 SoCs
6+ "rockchip,rk3368-tsadc": found on RK3368 SoCs
57 - reg : physical base address of the controller and length of memory mapped
68 region.
79 - interrupts : The interrupt number to the cpu. The interrupt specifier format
MAINTAINERS+14−8
@@ -318,7 +318,7 @@ M: Zhang Rui <rui.zhang@intel.com> · 317 unmodified lines
318318 L: linux-acpi@vger.kernel.org
319319 W: https://01.org/linux-acpi
320320 S: Supported
321−F: drivers/acpi/video.c
321+F: drivers/acpi/acpi_video.c
322322
323323 ACPI WMI DRIVER
324324 L: platform-driver-x86@vger.kernel.org
@@ -1847,7 +1847,7 @@ S: Supported · 1522 unmodified lines
18471847 F: drivers/net/wireless/ath/ath6kl/
18481848
18491849 WILOCITY WIL6210 WIRELESS DRIVER
1850−M: Vladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>
1850+M: Maya Erez <qca_merez@qca.qualcomm.com>
18511851 L: linux-wireless@vger.kernel.org
18521852 L: wil6210@qca.qualcomm.com
18531853 S: Supported
@@ -1931,7 +1931,7 @@ S: Supported · 77 unmodified lines
19311931 F: drivers/i2c/busses/i2c-at91.c
19321932
19331933 ATMEL ISI DRIVER
1934−M: Josh Wu <josh.wu@atmel.com>
1934+M: Ludovic Desroches <ludovic.desroches@atmel.com>
19351935 L: linux-media@vger.kernel.org
19361936 S: Supported
19371937 F: drivers/media/platform/soc_camera/atmel-isi.c
@@ -1950,7 +1950,8 @@ S: Supported · 12 unmodified lines
19501950 F: drivers/net/ethernet/cadence/
19511951
19521952 ATMEL NAND DRIVER
1953−M: Josh Wu <josh.wu@atmel.com>
1953+M: Wenyou Yang <wenyou.yang@atmel.com>
1954+M: Josh Wu <rainyfeeling@outlook.com>
19541955 L: linux-mtd@lists.infradead.org
19551956 S: Supported
19561957 F: drivers/mtd/nand/atmel_nand*
@@ -2974,6 +2975,7 @@ F: kernel/cpuset.c · 1017 unmodified lines
29742975 CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)
29752976 M: Johannes Weiner <hannes@cmpxchg.org>
29762977 M: Michal Hocko <mhocko@kernel.org>
2978+M: Vladimir Davydov <vdavydov@virtuozzo.com>
29772979 L: cgroups@vger.kernel.org
29782980 L: linux-mm@kvack.org
29792981 S: Maintained
@@ -6100,6 +6102,7 @@ M: Marc Zyngier <marc.zyngier@arm.com> · 3120 unmodified lines
61006102 L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
61016103 L: kvmarm@lists.cs.columbia.edu
61026104 W: http://systems.cs.columbia.edu/projects/kvm-arm
6105+T: git git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm.git
61036106 S: Supported
61046107 F: arch/arm/include/uapi/asm/kvm*
61056108 F: arch/arm/include/asm/kvm*
@@ -6366,6 +6369,7 @@ F: arch/*/include/asm/pmem.h · 260 unmodified lines
63666369 LIGHTNVM PLATFORM SUPPORT
63676370 M: Matias Bjorling <mb@lightnvm.io>
63686371 W: http://github/OpenChannelSSD
6372+L: linux-block@vger.kernel.org
63696373 S: Maintained
63706374 F: drivers/lightnvm/
63716375 F: include/linux/lightnvm.h
@@ -8284,7 +8288,7 @@ F: include/linux/delayacct.h · 1912 unmodified lines
82848288 F: kernel/delayacct.c
82858289
82868290 PERFORMANCE EVENTS SUBSYSTEM
8287−M: Peter Zijlstra <a.p.zijlstra@chello.nl>
8291+M: Peter Zijlstra <peterz@infradead.org>
82888292 M: Ingo Molnar <mingo@redhat.com>
82898293 M: Arnaldo Carvalho de Melo <acme@kernel.org>
82908294 L: linux-kernel@vger.kernel.org
@@ -9425,8 +9429,10 @@ F: include/scsi/sg.h · 1134 unmodified lines
94259429
94269430 SCSI SUBSYSTEM
94279431 M: "James E.J. Bottomley" <JBottomley@odin.com>
9428−L: linux-scsi@vger.kernel.org
94299432 T: git git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git
9433+M: "Martin K. Petersen" <martin.petersen@oracle.com>
9434+T: git git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git
9435+L: linux-scsi@vger.kernel.org
94309436 S: Maintained
94319437 F: drivers/scsi/
94329438 F: include/scsi/
@@ -10901,9 +10907,9 @@ S: Maintained · 1468 unmodified lines
1090110907 F: drivers/media/tuners/tua9001*
1090210908
1090310909 TULIP NETWORK DRIVERS
10904−M: Grant Grundler <grundler@parisc-linux.org>
1090510910 L: netdev@vger.kernel.org
10906−S: Maintained
10911+L: linux-parisc@vger.kernel.org
10912+S: Orphan
1090710913 F: drivers/net/ethernet/dec/tulip/
1090810914
1090910915 TUN/TAP driver
Makefile+1−1
@@ -1,7 +1,7 @@
11 VERSION = 4
22 PATCHLEVEL = 4
33 SUBLEVEL = 0
4−EXTRAVERSION = -rc2
4+EXTRAVERSION = -rc5
55 NAME = Blurry Fish Butt
66
77 # *DOCUMENTATION*
arch/arc/configs/axs101_defconfig+1−1
@@ -1,4 +1,4 @@
1−CONFIG_CROSS_COMPILE="arc-linux-uclibc-"
1+CONFIG_CROSS_COMPILE="arc-linux-"
22 CONFIG_DEFAULT_HOSTNAME="ARCLinux"
33 # CONFIG_SWAP is not set
44 CONFIG_SYSVIPC=y
arch/arc/configs/axs103_defconfig+1−1
@@ -1,4 +1,4 @@
1−CONFIG_CROSS_COMPILE="arc-linux-uclibc-"
1+CONFIG_CROSS_COMPILE="arc-linux-"
22 CONFIG_DEFAULT_HOSTNAME="ARCLinux"
33 # CONFIG_SWAP is not set
44 CONFIG_SYSVIPC=y
arch/arc/configs/axs103_smp_defconfig+1−1
@@ -1,4 +1,4 @@
1−CONFIG_CROSS_COMPILE="arc-linux-uclibc-"
1+CONFIG_CROSS_COMPILE="arc-linux-"
22 CONFIG_DEFAULT_HOSTNAME="ARCLinux"
33 # CONFIG_SWAP is not set
44 CONFIG_SYSVIPC=y
arch/arc/configs/nsim_hs_defconfig+1−1
@@ -1,4 +1,4 @@
1−CONFIG_CROSS_COMPILE="arc-linux-uclibc-"
1+CONFIG_CROSS_COMPILE="arc-linux-"
22 # CONFIG_LOCALVERSION_AUTO is not set
33 CONFIG_DEFAULT_HOSTNAME="ARCLinux"
44 # CONFIG_SWAP is not set
arch/arc/configs/nsim_hs_smp_defconfig+1−1
@@ -1,4 +1,4 @@
1−CONFIG_CROSS_COMPILE="arc-linux-uclibc-"
1+CONFIG_CROSS_COMPILE="arc-linux-"
22 # CONFIG_LOCALVERSION_AUTO is not set
33 CONFIG_DEFAULT_HOSTNAME="ARCLinux"
44 # CONFIG_SWAP is not set
arch/arc/configs/nsimosci_hs_defconfig+1−1
@@ -1,4 +1,4 @@
1−CONFIG_CROSS_COMPILE="arc-linux-uclibc-"
1+CONFIG_CROSS_COMPILE="arc-linux-"
22 # CONFIG_LOCALVERSION_AUTO is not set
33 CONFIG_DEFAULT_HOSTNAME="ARCLinux"
44 # CONFIG_SWAP is not set
arch/arc/configs/nsimosci_hs_smp_defconfig+1−1
@@ -1,4 +1,4 @@
1−CONFIG_CROSS_COMPILE="arc-linux-uclibc-"
1+CONFIG_CROSS_COMPILE="arc-linux-"
22 CONFIG_DEFAULT_HOSTNAME="ARCLinux"
33 # CONFIG_SWAP is not set
44 CONFIG_SYSVIPC=y
arch/arc/configs/vdk_hs38_defconfig+1−1
@@ -1,4 +1,4 @@
1−CONFIG_CROSS_COMPILE="arc-linux-uclibc-"
1+CONFIG_CROSS_COMPILE="arc-linux-"
22 # CONFIG_LOCALVERSION_AUTO is not set
33 CONFIG_DEFAULT_HOSTNAME="ARCLinux"
44 # CONFIG_CROSS_MEMORY_ATTACH is not set
arch/arc/configs/vdk_hs38_smp_defconfig+1−1
@@ -1,4 +1,4 @@
1−CONFIG_CROSS_COMPILE="arc-linux-uclibc-"
1+CONFIG_CROSS_COMPILE="arc-linux-"
22 # CONFIG_LOCALVERSION_AUTO is not set
33 CONFIG_DEFAULT_HOSTNAME="ARCLinux"
44 # CONFIG_CROSS_MEMORY_ATTACH is not set
arch/arc/include/asm/irqflags-arcv2.h+3−0
@@ -37,6 +37,9 @@ · 36 unmodified lines
3737 #define ISA_INIT_STATUS_BITS (STATUS_IE_MASK | STATUS_AD_MASK | \
3838 (ARCV2_IRQ_DEF_PRIO << 1))
3939
40+/* SLEEP needs default irq priority (<=) which can interrupt the doze */
41+#define ISA_SLEEP_ARG (0x10 | ARCV2_IRQ_DEF_PRIO)
42+
4043 #ifndef __ASSEMBLY__
4144
4245 /*
arch/arc/include/asm/irqflags-compact.h+2−0
@@ -43,6 +43,8 @@ · 42 unmodified lines
4343
4444 #define ISA_INIT_STATUS_BITS STATUS_IE_MASK
4545
46+#define ISA_SLEEP_ARG 0x3
47+
4648 #ifndef __ASSEMBLY__
4749
4850 /******************************************************************
arch/arc/kernel/ctx_sw.c+0−2
@@ -58,8 +58,6 @@ __switch_to(struct task_struct *prev_task, struct task_struct *next_task) · 57 unmodified lines
5858 "st sp, [r24] \n\t"
5959 #endif
6060
61− "sync \n\t"
62−
6361 /*
6462 * setup _current_task with incoming tsk.
6563 * optionally, set r25 to that as well
arch/arc/kernel/ctx_sw_asm.S+0−3
@@ -44,9 +44,6 @@ __switch_to: · 43 unmodified lines
4444 * don't need to do anything special to return it
4545 */
4646
47− /* hardware memory barrier */
48− sync
49−
5047 /*
5148 * switch to new task, contained in r1
5249 * Temp reg r3 is required to get the ptr to store val
arch/arc/kernel/process.c+4−5
@@ -44,11 +44,10 @@ SYSCALL_DEFINE0(arc_gettls) · 43 unmodified lines
4444 void arch_cpu_idle(void)
4545 {
4646 /* sleep, but enable all interrupts before committing */
47− if (is_isa_arcompact()) {
48− __asm__("sleep 0x3");
49− } else {
50− __asm__("sleep 0x10");
51− }
47+ __asm__ __volatile__(
48+ "sleep %0 \n"
49+ :
50+ :"I"(ISA_SLEEP_ARG)); /* can't be "r" has to be embedded const */
5251 }
5352
5453 asmlinkage void ret_from_fork(void);
arch/arc/kernel/unwind.c+4−33
@@ -986,42 +986,13 @@ int arc_unwind(struct unwind_frame_info *frame) · 985 unmodified lines
986986 (const u8 *)(fde +
987987 1) +
988988 *fde, ptrType);
989− if (pc >= endLoc)
989+ if (pc >= endLoc) {
990990 fde = NULL;
991− } else
992− fde = NULL;
993− }
994− if (fde == NULL) {
995− for (fde = table->address, tableSize = table->size;
996− cie = NULL, tableSize > sizeof(*fde)
997− && tableSize - sizeof(*fde) >= *fde;
998− tableSize -= sizeof(*fde) + *fde,
999− fde += 1 + *fde / sizeof(*fde)) {
1000− cie = cie_for_fde(fde, table);
1001− if (cie == &bad_cie) {
1002991 cie = NULL;
1003− break;
1004992 }
1005− if (cie == NULL
1006− || cie == &not_fde
1007− || (ptrType = fde_pointer_type(cie)) < 0)
1008− continue;
1009− ptr = (const u8 *)(fde + 2);
1010− startLoc = read_pointer(&ptr,
1011− (const u8 *)(fde + 1) +
1012− *fde, ptrType);
1013− if (!startLoc)
1014− continue;
1015− if (!(ptrType & DW_EH_PE_indirect))
1016− ptrType &=
1017− DW_EH_PE_FORM | DW_EH_PE_signed;
1018− endLoc =
1019− startLoc + read_pointer(&ptr,
1020− (const u8 *)(fde +
1021− 1) +
1022− *fde, ptrType);
1023− if (pc >= startLoc && pc < endLoc)
1024− break;
993+ } else {
994+ fde = NULL;
995+ cie = NULL;
1025996 }
1026997 }
1027998 }
arch/arc/mm/tlb.c+2−2
@@ -619,10 +619,10 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long vaddr_unaligned, · 618 unmodified lines
619619
620620 int dirty = !test_and_set_bit(PG_dc_clean, &page->flags);
621621 if (dirty) {
622− /* wback + inv dcache lines */
622+ /* wback + inv dcache lines (K-mapping) */
623623 __flush_dcache_page(paddr, paddr);
624624
625− /* invalidate any existing icache lines */
625+ /* invalidate any existing icache lines (U-mapping) */
626626 if (vma->vm_flags & VM_EXEC)
627627 __inv_icache_page(paddr, vaddr);
628628 }
arch/arm/Kconfig+2−2
@@ -76,6 +76,8 @@ config ARM · 75 unmodified lines
7676 select IRQ_FORCED_THREADING
7777 select MODULES_USE_ELF_REL
7878 select NO_BOOTMEM
79+ select OF_EARLY_FLATTREE if OF
80+ select OF_RESERVED_MEM if OF
7981 select OLD_SIGACTION
8082 select OLD_SIGSUSPEND3
8183 select PERF_USE_VMALLOC
@@ -1822,8 +1824,6 @@ config USE_OF · 1740 unmodified lines
18221824 bool "Flattened Device Tree support"
18231825 select IRQ_DOMAIN
18241826 select OF
1825− select OF_EARLY_FLATTREE
1826− select OF_RESERVED_MEM
18271827 help
18281828 Include support for flattened device tree machine descriptions.
18291829
arch/arm/boot/dts/am4372.dtsi+2−2
@@ -74,7 +74,7 @@ · 73 unmodified lines
7474 reg = <0x48240200 0x100>;
7575 interrupts = <GIC_PPI 11 IRQ_TYPE_LEVEL_HIGH>;
7676 interrupt-parent = <&gic>;
77− clocks = <&dpll_mpu_m2_ck>;
77+ clocks = <&mpu_periphclk>;
7878 };
7979
8080 local_timer: timer@48240600 {
@@ -82,7 +82,7 @@ · 1 unmodified line
8282 reg = <0x48240600 0x100>;
8383 interrupts = <GIC_PPI 13 IRQ_TYPE_LEVEL_HIGH>;
8484 interrupt-parent = <&gic>;
85− clocks = <&dpll_mpu_m2_ck>;
85+ clocks = <&mpu_periphclk>;
8686 };
8787
8888 l2-cache-controller@48242000 {
arch/arm/boot/dts/am43xx-clocks.dtsi+8−0
@@ -259,6 +259,14 @@ · 258 unmodified lines
259259 ti,invert-autoidle-bit;
260260 };
261261
262+ mpu_periphclk: mpu_periphclk {
263+ #clock-cells = <0>;
264+ compatible = "fixed-factor-clock";
265+ clocks = <&dpll_mpu_m2_ck>;
266+ clock-mult = <1>;
267+ clock-div = <2>;
268+ };
269+
262270 dpll_ddr_ck: dpll_ddr_ck {
263271 #clock-cells = <0>;
264272 compatible = "ti,am3-dpll-clock";
arch/arm/boot/dts/am57xx-beagle-x15.dts+1−0
@@ -604,6 +604,7 @@ · 603 unmodified lines
604604 reg = <0x6f>;
605605 interrupts-extended = <&crossbar_mpu GIC_SPI 2 IRQ_TYPE_EDGE_RISING>,
606606 <&dra7_pmx_core 0x424>;
607+ interrupt-names = "irq", "wakeup";
607608
608609 pinctrl-names = "default";
609610 pinctrl-0 = <&mcp79410_pins_default>;
arch/arm/boot/dts/animeo_ip.dts+3−3
@@ -155,21 +155,21 @@ · 154 unmodified lines
155155 label = "keyswitch_in";
156156 gpios = <&pioB 1 GPIO_ACTIVE_HIGH>;
157157 linux,code = <28>;
158− gpio-key,wakeup;
158+ wakeup-source;
159159 };
160160
161161 error_in {
162162 label = "error_in";
163163 gpios = <&pioB 2 GPIO_ACTIVE_HIGH>;
164164 linux,code = <29>;
165− gpio-key,wakeup;
165+ wakeup-source;
166166 };
167167
168168 btn {
169169 label = "btn";
170170 gpios = <&pioC 23 GPIO_ACTIVE_HIGH>;
171171 linux,code = <31>;
172− gpio-key,wakeup;
172+ wakeup-source;
173173 };
174174 };
175175 };
arch/arm/boot/dts/armada-38x.dtsi+1−0
@@ -498,6 +498,7 @@ · 497 unmodified lines
498498 reg = <0x70000 0x4000>;
499499 interrupts-extended = <&mpic 8>;
500500 clocks = <&gateclk 4>;
501+ tx-csum-limit = <9800>;
501502 status = "disabled";
502503 };
503504
arch/arm/boot/dts/at91-foxg20.dts+1−1
@@ -159,7 +159,7 @@ · 158 unmodified lines
159159 label = "Button";
160160 gpios = <&pioC 4 GPIO_ACTIVE_LOW>;
161161 linux,code = <0x103>;
162− gpio-key,wakeup;
162+ wakeup-source;
163163 };
164164 };
165165 };
arch/arm/boot/dts/at91-kizbox.dts+2−11
@@ -24,15 +24,6 @@ · 23 unmodified lines
2424 };
2525
2626 clocks {
27− #address-cells = <1>;
28− #size-cells = <1>;
29− ranges;
30−
31− main_clock: clock@0 {
32− compatible = "atmel,osc", "fixed-clock";
33− clock-frequency = <18432000>;
34− };
35−
3627 main_xtal {
3728 clock-frequency = <18432000>;
3829 };
@@ -94,14 +85,14 @@ · 55 unmodified lines
9485 label = "PB_RST";
9586 gpios = <&pioB 30 GPIO_ACTIVE_HIGH>;
9687 linux,code = <0x100>;
97− gpio-key,wakeup;
88+ wakeup-source;
9889 };
9990
10091 user {
10192 label = "PB_USER";
10293 gpios = <&pioB 31 GPIO_ACTIVE_HIGH>;
10394 linux,code = <0x101>;
104− gpio-key,wakeup;
95+ wakeup-source;
10596 };
10697 };
10798
arch/arm/boot/dts/at91-kizbox2.dts+3−3
@@ -171,21 +171,21 @@ · 170 unmodified lines
171171 label = "PB_PROG";
172172 gpios = <&pioE 27 GPIO_ACTIVE_LOW>;
173173 linux,code = <0x102>;
174− gpio-key,wakeup;
174+ wakeup-source;
175175 };
176176
177177 reset {
178178 label = "PB_RST";
179179 gpios = <&pioE 29 GPIO_ACTIVE_LOW>;
180180 linux,code = <0x100>;
181− gpio-key,wakeup;
181+ wakeup-source;
182182 };
183183
184184 user {
185185 label = "PB_USER";
186186 gpios = <&pioE 31 GPIO_ACTIVE_HIGH>;
187187 linux,code = <0x101>;
188− gpio-key,wakeup;
188+ wakeup-source;
189189 };
190190 };
191191
arch/arm/boot/dts/at91-kizboxmini.dts+2−2
@@ -98,14 +98,14 @@ · 97 unmodified lines
9898 label = "PB_PROG";
9999 gpios = <&pioC 17 GPIO_ACTIVE_LOW>;
100100 linux,code = <0x102>;
101− gpio-key,wakeup;
101+ wakeup-source;
102102 };
103103
104104 reset {
105105 label = "PB_RST";
106106 gpios = <&pioC 16 GPIO_ACTIVE_LOW>;
107107 linux,code = <0x100>;
108− gpio-key,wakeup;
108+ wakeup-source;
109109 };
110110 };
111111
arch/arm/boot/dts/at91-qil_a9260.dts+1−1
@@ -183,7 +183,7 @@ · 182 unmodified lines
183183 label = "user_pb";
184184 gpios = <&pioB 10 GPIO_ACTIVE_LOW>;
185185 linux,code = <28>;
186− gpio-key,wakeup;
186+ wakeup-source;
187187 };
188188 };
189189
arch/arm/boot/dts/at91-sama5d2_xplained.dts+107−9
@@ -45,6 +45,7 @@ · 44 unmodified lines
4545 /dts-v1/;
4646 #include "sama5d2.dtsi"
4747 #include "sama5d2-pinfunc.h"
48+#include <dt-bindings/mfd/atmel-flexcom.h>
4849
4950 / {
5051 model = "Atmel SAMA5D2 Xplained";
@@ -59,15 +60,6 @@ · 8 unmodified lines
5960 };
6061
6162 clocks {
62− #address-cells = <1>;
63− #size-cells = <1>;
64− ranges;
65−
66− main_clock: clock@0 {
67− compatible = "atmel,osc", "fixed-clock";
68− clock-frequency = <12000000>;
69− };
70−
7163 slow_xtal {
7264 clock-frequency = <32768>;
7365 };
@@ -91,6 +83,22 @@ · 17 unmodified lines
9183 status = "okay";
9284 };
9385
86+ sdmmc0: sdio-host@a0000000 {
87+ bus-width = <8>;
88+ pinctrl-names = "default";
89+ pinctrl-0 = <&pinctrl_sdmmc0_default>;
90+ non-removable;
91+ mmc-ddr-1_8v;
92+ status = "okay";
93+ };
94+
95+ sdmmc1: sdio-host@b0000000 {
96+ bus-width = <4>;
97+ pinctrl-names = "default";
98+ pinctrl-0 = <&pinctrl_sdmmc1_default>;
99+ status = "okay"; /* conflict with qspi0 */
100+ };
101+
94102 apb {
95103 spi0: spi@f8000000 {
96104 pinctrl-names = "default";
@@ -176,17 +184,55 @@ · 79 unmodified lines
176184 regulator-name = "VDD_SDHC_1V8";
177185 regulator-min-microvolt = <1800000>;
178186 regulator-max-microvolt = <1800000>;
187+ regulator-always-on;
179188 };
180189 };
181190 };
182191 };
183192
193+ flx0: flexcom@f8034000 {
194+ atmel,flexcom-mode = <ATMEL_FLEXCOM_MODE_USART>;
195+ status = "disabled"; /* conflict with ISC_D2 & ISC_D3 data pins */
196+
197+ uart5: serial@200 {
198+ compatible = "atmel,at91sam9260-usart";
199+ reg = <0x200 0x200>;
200+ interrupts = <19 IRQ_TYPE_LEVEL_HIGH 7>;
201+ clocks = <&flx0_clk>;
202+ clock-names = "usart";
203+ pinctrl-names = "default";
204+ pinctrl-0 = <&pinctrl_flx0_default>;
205+ atmel,fifo-size = <32>;
206+ status = "okay";
207+ };
208+ };
209+
184210 uart3: serial@fc008000 {
185211 pinctrl-names = "default";
186212 pinctrl-0 = <&pinctrl_uart3_default>;
187213 status = "okay";
188214 };
189215
216+ flx4: flexcom@fc018000 {
217+ atmel,flexcom-mode = <ATMEL_FLEXCOM_MODE_TWI>;
218+ status = "okay";
219+
220+ i2c2: i2c@600 {
221+ compatible = "atmel,sama5d2-i2c";
222+ reg = <0x600 0x200>;
223+ interrupts = <23 IRQ_TYPE_LEVEL_HIGH 7>;
224+ dmas = <0>, <0>;
225+ dma-names = "tx", "rx";
226+ #address-cells = <1>;
227+ #size-cells = <0>;
228+ clocks = <&flx4_clk>;
229+ pinctrl-names = "default";
230+ pinctrl-0 = <&pinctrl_flx4_default>;
231+ atmel,fifo-size = <16>;
232+ status = "okay";
233+ };
234+ };
235+
190236 i2c1: i2c@fc028000 {
191237 dmas = <0>, <0>;
192238 pinctrl-names = "default";
@@ -201,6 +247,18 @@ · 8 unmodified lines
201247 };
202248
203249 pinctrl@fc038000 {
250+ pinctrl_flx0_default: flx0_default {
251+ pinmux = <PIN_PB28__FLEXCOM0_IO0>,
252+ <PIN_PB29__FLEXCOM0_IO1>;
253+ bias-disable;
254+ };
255+
256+ pinctrl_flx4_default: flx4_default {
257+ pinmux = <PIN_PD12__FLEXCOM4_IO0>,
258+ <PIN_PD13__FLEXCOM4_IO1>;
259+ bias-disable;
260+ };
261+
204262 pinctrl_i2c0_default: i2c0_default {
205263 pinmux = <PIN_PD21__TWD0>,
206264 <PIN_PD22__TWCK0>;
@@ -227,6 +285,46 @@ · 20 unmodified lines
227285 bias-disable;
228286 };
229287
288+ pinctrl_sdmmc0_default: sdmmc0_default {
289+ cmd_data {
290+ pinmux = <PIN_PA1__SDMMC0_CMD>,
291+ <PIN_PA2__SDMMC0_DAT0>,
292+ <PIN_PA3__SDMMC0_DAT1>,
293+ <PIN_PA4__SDMMC0_DAT2>,
294+ <PIN_PA5__SDMMC0_DAT3>,
295+ <PIN_PA6__SDMMC0_DAT4>,
296+ <PIN_PA7__SDMMC0_DAT5>,
297+ <PIN_PA8__SDMMC0_DAT6>,
298+ <PIN_PA9__SDMMC0_DAT7>;
299+ bias-pull-up;
300+ };
301+
302+ ck_cd_rstn_vddsel {
303+ pinmux = <PIN_PA0__SDMMC0_CK>,
304+ <PIN_PA10__SDMMC0_RSTN>,
305+ <PIN_PA11__SDMMC0_VDDSEL>,
306+ <PIN_PA13__SDMMC0_CD>;
307+ bias-disable;
308+ };
309+ };
310+
311+ pinctrl_sdmmc1_default: sdmmc1_default {
312+ cmd_data {
313+ pinmux = <PIN_PA28__SDMMC1_CMD>,
314+ <PIN_PA18__SDMMC1_DAT0>,
315+ <PIN_PA19__SDMMC1_DAT1>,
316+ <PIN_PA20__SDMMC1_DAT2>,
317+ <PIN_PA21__SDMMC1_DAT3>;
318+ bias-pull-up;
319+ };
320+
321+ conf-ck_cd {
322+ pinmux = <PIN_PA22__SDMMC1_CK>,
323+ <PIN_PA30__SDMMC1_CD>;
324+ bias-disable;
325+ };
326+ };
327+
230328 pinctrl_spi0_default: spi0_default {
231329 pinmux = <PIN_PA14__SPI0_SPCK>,
232330 <PIN_PA15__SPI0_MOSI>,
arch/arm/boot/dts/at91-sama5d3_xplained.dts+1−1
@@ -315,7 +315,7 @@ · 314 unmodified lines
315315 label = "PB_USER";
316316 gpios = <&pioE 29 GPIO_ACTIVE_LOW>;
317317 linux,code = <0x104>;
318− gpio-key,wakeup;
318+ wakeup-source;
319319 };
320320 };
321321
arch/arm/boot/dts/at91-sama5d4_xplained.dts+1−11
@@ -50,7 +50,6 @@ · 49 unmodified lines
5050 compatible = "atmel,sama5d4-xplained", "atmel,sama5d4", "atmel,sama5";
5151
5252 chosen {
53− bootargs = "ignore_loglevel earlyprintk";
5453 stdout-path = "serial0:115200n8";
5554 };
5655
@@ -59,15 +58,6 @@ · 2 unmodified lines
5958 };
6059
6160 clocks {
62− #address-cells = <1>;
63− #size-cells = <1>;
64− ranges;
65−
66− main_clock: clock@0 {
67− compatible = "atmel,osc", "fixed-clock";
68− clock-frequency = <12000000>;
69− };
70−
7161 slow_xtal {
7262 clock-frequency = <32768>;
7363 };
@@ -235,7 +225,7 @@ · 161 unmodified lines
235225 label = "pb_user1";
236226 gpios = <&pioE 8 GPIO_ACTIVE_HIGH>;
237227 linux,code = <0x100>;
238− gpio-key,wakeup;
228+ wakeup-source;
239229 };
240230 };
241231
arch/arm/boot/dts/at91-sama5d4ek.dts+1−11
@@ -50,7 +50,6 @@ · 49 unmodified lines
5050 compatible = "atmel,sama5d4ek", "atmel,sama5d4", "atmel,sama5";
5151
5252 chosen {
53− bootargs = "ignore_loglevel earlyprintk";
5453 stdout-path = "serial0:115200n8";
5554 };
5655
@@ -59,15 +58,6 @@ · 2 unmodified lines
5958 };
6059
6160 clocks {
62− #address-cells = <1>;
63− #size-cells = <1>;
64− ranges;
65−
66− main_clock: clock@0 {
67− compatible = "atmel,osc", "fixed-clock";
68− clock-frequency = <12000000>;
69− };
70−
7161 slow_xtal {
7262 clock-frequency = <32768>;
7363 };
@@ -304,7 +294,7 @@ · 230 unmodified lines
304294 label = "pb_user1";
305295 gpios = <&pioE 13 GPIO_ACTIVE_HIGH>;
306296 linux,code = <0x100>;
307− gpio-key,wakeup;
297+ wakeup-source;
308298 };
309299 };
310300
arch/arm/boot/dts/at91rm9200ek.dts+0−9
@@ -21,15 +21,6 @@ · 20 unmodified lines
2121 };
2222
2323 clocks {
24− #address-cells = <1>;
25− #size-cells = <1>;
26− ranges;
27−
28− main_clock: clock@0 {
29− compatible = "atmel,osc", "fixed-clock";
30− clock-frequency = <18432000>;
31− };
32−
3324 slow_xtal {
3425 clock-frequency = <32768>;
3526 };
arch/arm/boot/dts/at91sam9261ek.dts+5−14
@@ -22,15 +22,6 @@ · 21 unmodified lines
2222 };
2323
2424 clocks {
25− #address-cells = <1>;
26− #size-cells = <1>;
27− ranges;
28−
29− main_clock: clock@0 {
30− compatible = "atmel,osc", "fixed-clock";
31− clock-frequency = <18432000>;
32− };
33−
3425 slow_xtal {
3526 clock-frequency = <32768>;
3627 };
@@ -149,7 +140,7 @@ · 112 unmodified lines
149140 ti,debounce-tol = /bits/ 16 <65535>;
150141 ti,debounce-max = /bits/ 16 <1>;
151142
152− linux,wakeup;
143+ wakeup-source;
153144 };
154145 };
155146
@@ -193,28 +184,28 @@ · 37 unmodified lines
193184 label = "button_0";
194185 gpios = <&pioA 27 GPIO_ACTIVE_LOW>;
195186 linux,code = <256>;
196− gpio-key,wakeup;
187+ wakeup-source;
197188 };
198189
199190 button_1 {
200191 label = "button_1";
201192 gpios = <&pioA 26 GPIO_ACTIVE_LOW>;
202193 linux,code = <257>;
203− gpio-key,wakeup;
194+ wakeup-source;
204195 };
205196
206197 button_2 {
207198 label = "button_2";
208199 gpios = <&pioA 25 GPIO_ACTIVE_LOW>;
209200 linux,code = <258>;
210− gpio-key,wakeup;
201+ wakeup-source;
211202 };
212203
213204 button_3 {
214205 label = "button_3";
215206 gpios = <&pioA 24 GPIO_ACTIVE_LOW>;
216207 linux,code = <259>;
217− gpio-key,wakeup;
208+ wakeup-source;
218209 };
219210 };
220211 };
arch/arm/boot/dts/at91sam9263ek.dts+2−11
@@ -22,15 +22,6 @@ · 21 unmodified lines
2222 };
2323
2424 clocks {
25− #address-cells = <1>;
26− #size-cells = <1>;
27− ranges;
28−
29− main_clock: clock@0 {
30− compatible = "atmel,osc", "fixed-clock";
31− clock-frequency = <16367660>;
32− };
33−
3425 slow_xtal {
3526 clock-frequency = <32768>;
3627 };
@@ -213,14 +204,14 @@ · 176 unmodified lines
213204 label = "left_click";
214205 gpios = <&pioC 5 GPIO_ACTIVE_LOW>;
215206 linux,code = <272>;
216− gpio-key,wakeup;
207+ wakeup-source;
217208 };
218209
219210 right_click {
220211 label = "right_click";
221212 gpios = <&pioC 4 GPIO_ACTIVE_LOW>;
222213 linux,code = <273>;
223− gpio-key,wakeup;
214+ wakeup-source;
224215 };
225216 };
226217
arch/arm/boot/dts/at91sam9g20ek_common.dtsi+2−11
@@ -19,15 +19,6 @@ · 18 unmodified lines
1919 };
2020
2121 clocks {
22− #address-cells = <1>;
23− #size-cells = <1>;
24− ranges;
25−
26− main_clock: clock@0 {
27− compatible = "atmel,osc", "fixed-clock";
28− clock-frequency = <18432000>;
29− };
30−
3122 slow_xtal {
3223 clock-frequency = <32768>;
3324 };
@@ -206,14 +197,14 @@ · 172 unmodified lines
206197 label = "Button 3";
207198 gpios = <&pioA 30 GPIO_ACTIVE_LOW>;
208199 linux,code = <0x103>;
209− gpio-key,wakeup;
200+ wakeup-source;
210201 };
211202
212203 btn4 {
213204 label = "Button 4";
214205 gpios = <&pioA 31 GPIO_ACTIVE_LOW>;
215206 linux,code = <0x104>;
216− gpio-key,wakeup;
207+ wakeup-source;
217208 };
218209 };
219210
arch/arm/boot/dts/at91sam9m10g45ek.dts+2−11
@@ -24,15 +24,6 @@ · 23 unmodified lines
2424 };
2525
2626 clocks {
27− #address-cells = <1>;
28− #size-cells = <1>;
29− ranges;
30−
31− main_clock: clock@0 {
32− compatible = "atmel,osc", "fixed-clock";
33− clock-frequency = <12000000>;
34− };
35−
3627 slow_xtal {
3728 clock-frequency = <32768>;
3829 };
@@ -323,14 +314,14 @@ · 284 unmodified lines
323314 label = "left_click";
324315 gpios = <&pioB 6 GPIO_ACTIVE_LOW>;
325316 linux,code = <272>;
326− gpio-key,wakeup;
317+ wakeup-source;
327318 };
328319
329320 right_click {
330321 label = "right_click";
331322 gpios = <&pioB 7 GPIO_ACTIVE_LOW>;
332323 linux,code = <273>;
333− gpio-key,wakeup;
324+ wakeup-source;
334325 };
335326
336327 left {
arch/arm/boot/dts/at91sam9n12ek.dts+1−10
@@ -23,15 +23,6 @@ · 22 unmodified lines
2323 };
2424
2525 clocks {
26− #address-cells = <1>;
27− #size-cells = <1>;
28− ranges;
29−
30− main_clock: clock@0 {
31− compatible = "atmel,osc", "fixed-clock";
32− clock-frequency = <16000000>;
33− };
34−
3526 slow_xtal {
3627 clock-frequency = <32768>;
3728 };
@@ -219,7 +210,7 @@ · 181 unmodified lines
219210 label = "Enter";
220211 gpios = <&pioB 3 GPIO_ACTIVE_LOW>;
221212 linux,code = <28>;
222− gpio-key,wakeup;
213+ wakeup-source;
223214 };
224215 };
225216
arch/arm/boot/dts/at91sam9rlek.dts+2−11
@@ -22,15 +22,6 @@ · 21 unmodified lines
2222 };
2323
2424 clocks {
25− #address-cells = <1>;
26− #size-cells = <1>;
27− ranges;
28−
29− main_clock: clock {
30− compatible = "atmel,osc", "fixed-clock";
31− clock-frequency = <12000000>;
32− };
33−
3425 slow_xtal {
3526 clock-frequency = <32768>;
3627 };
@@ -225,14 +216,14 @@ · 188 unmodified lines
225216 label = "right_click";
226217 gpios = <&pioB 0 GPIO_ACTIVE_LOW>;
227218 linux,code = <273>;
228− gpio-key,wakeup;
219+ wakeup-source;
229220 };
230221
231222 left_click {
232223 label = "left_click";
233224 gpios = <&pioB 1 GPIO_ACTIVE_LOW>;
234225 linux,code = <272>;
235− gpio-key,wakeup;
226+ wakeup-source;
236227 };
237228 };
238229
arch/arm/boot/dts/at91sam9x5cm.dtsi+0−11
@@ -12,17 +12,6 @@ · 11 unmodified lines
1212 reg = <0x20000000 0x8000000>;
1313 };
1414
15− clocks {
16− #address-cells = <1>;
17− #size-cells = <1>;
18− ranges;
19−
20− main_clock: clock@0 {
21− compatible = "atmel,osc", "fixed-clock";
22− clock-frequency = <12000000>;
23− };
24− };
25−
2615 clocks {
2716 slow_xtal {
2817 clock-frequency = <32768>;
arch/arm/boot/dts/berlin2q.dtsi+5−3
@@ -118,7 +118,8 @@ · 117 unmodified lines
118118 sdhci0: sdhci@ab0000 {
119119 compatible = "mrvl,pxav3-mmc";
120120 reg = <0xab0000 0x200>;
121− clocks = <&chip_clk CLKID_SDIO1XIN>;
121+ clocks = <&chip_clk CLKID_SDIO1XIN>, <&chip_clk CLKID_SDIO>;
122+ clock-names = "io", "core";
122123 interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
123124 status = "disabled";
124125 };
@@ -126,7 +127,8 @@ · 1 unmodified line
126127 sdhci1: sdhci@ab0800 {
127128 compatible = "mrvl,pxav3-mmc";
128129 reg = <0xab0800 0x200>;
129− clocks = <&chip_clk CLKID_SDIO1XIN>;
130+ clocks = <&chip_clk CLKID_SDIO1XIN>, <&chip_clk CLKID_SDIO>;
131+ clock-names = "io", "core";
130132 interrupts = <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>;
131133 status = "disabled";
132134 };
@@ -135,7 +137,7 @@ · 2 unmodified lines
135137 compatible = "mrvl,pxav3-mmc";
136138 reg = <0xab1000 0x200>;
137139 interrupts = <GIC_SPI 28 IRQ_TYPE_LEVEL_HIGH>;
138− clocks = <&chip_clk CLKID_NFC_ECC>, <&chip_clk CLKID_NFC>;
140+ clocks = <&chip_clk CLKID_NFC_ECC>, <&chip_clk CLKID_SDIO>;
139141 clock-names = "io", "core";
140142 status = "disabled";
141143 };
arch/arm/boot/dts/dm816x.dtsi+6−2
@@ -218,6 +218,7 @@ · 217 unmodified lines
218218 reg = <0x480c8000 0x2000>;
219219 interrupts = <77>;
220220 ti,hwmods = "mailbox";
221+ #mbox-cells = <1>;
221222 ti,mbox-num-users = <4>;
222223 ti,mbox-num-fifos = <12>;
223224 mbox_dsp: mbox_dsp {
@@ -279,8 +280,11 @@ · 55 unmodified lines
279280 ti,spi-num-cs = <4>;
280281 ti,hwmods = "mcspi1";
281282 dmas = <&edma 16 &edma 17
282− &edma 18 &edma 19>;
283− dma-names = "tx0", "rx0", "tx1", "rx1";
283+ &edma 18 &edma 19
284+ &edma 20 &edma 21
285+ &edma 22 &edma 23>;
286+ dma-names = "tx0", "rx0", "tx1", "rx1",
287+ "tx2", "rx2", "tx3", "rx3";
284288 };
285289
286290 mmc1: mmc@48060000 {
arch/arm/boot/dts/dra7.dtsi+2−2
@@ -1459,8 +1459,8 @@ · 1458 unmodified lines
14591459 interrupt-names = "tx", "rx";
14601460 dmas = <&sdma_xbar 133>, <&sdma_xbar 132>;
14611461 dma-names = "tx", "rx";
1462− clocks = <&mcasp3_ahclkx_mux>;
1463− clock-names = "fck";
1462+ clocks = <&mcasp3_aux_gfclk_mux>, <&mcasp3_ahclkx_mux>;
1463+ clock-names = "fck", "ahclkx";
14641464 status = "disabled";
14651465 };
14661466
arch/arm/boot/dts/k2l-netcp.dtsi+1−1
@@ -137,7 +137,7 @@ netcp: netcp@26000000 { · 136 unmodified lines
137137 /* NetCP address range */
138138 ranges = <0 0x26000000 0x1000000>;
139139
140− clocks = <&papllclk>, <&clkcpgmac>, <&chipclk12>;
140+ clocks = <&clkosr>, <&papllclk>, <&clkcpgmac>, <&chipclk12>;
141141 dma-coherent;
142142
143143 ti,navigator-dmas = <&dma_gbe 0>,
arch/arm/boot/dts/kirkwood-ts219.dtsi+1−1
@@ -40,7 +40,7 @@ · 39 unmodified lines
4040 };
4141 poweroff@12100 {
4242 compatible = "qnap,power-off";
43− reg = <0x12000 0x100>;
43+ reg = <0x12100 0x100>;
4444 clocks = <&gate_clk 7>;
4545 };
4646 spi@10600 {
arch/arm/boot/dts/rk3288-veyron-minnie.dts+4−0
@@ -86,6 +86,10 @@ · 85 unmodified lines
8686 };
8787 };
8888
89+&emmc {
90+ /delete-property/mmc-hs200-1_8v;
91+};
92+
8993 &gpio_keys {
9094 pinctrl-0 = <&pwr_key_l &ap_lid_int_l &volum_down_l &volum_up_l>;
9195
arch/arm/boot/dts/rk3288.dtsi+8−2
@@ -452,8 +452,10 @@ · 451 unmodified lines
452452 clock-names = "tsadc", "apb_pclk";
453453 resets = <&cru SRST_TSADC>;
454454 reset-names = "tsadc-apb";
455− pinctrl-names = "default";
456− pinctrl-0 = <&otp_out>;
455+ pinctrl-names = "init", "default", "sleep";
456+ pinctrl-0 = <&otp_gpio>;
457+ pinctrl-1 = <&otp_out>;
458+ pinctrl-2 = <&otp_gpio>;
457459 #thermal-sensor-cells = <1>;
458460 rockchip,hw-tshut-temp = <95000>;
459461 status = "disabled";
@@ -1395,6 +1397,10 @@ · 935 unmodified lines
13951397 };
13961398
13971399 tsadc {
1400+ otp_gpio: otp-gpio {
1401+ rockchip,pins = <0 10 RK_FUNC_GPIO &pcfg_pull_none>;
1402+ };
1403+
13981404 otp_out: otp-out {
13991405 rockchip,pins = <0 10 RK_FUNC_1 &pcfg_pull_none>;
14001406 };
arch/arm/boot/dts/sama5d35ek.dts+1−1
@@ -49,7 +49,7 @@ · 48 unmodified lines
4949 label = "pb_user1";
5050 gpios = <&pioE 27 GPIO_ACTIVE_HIGH>;
5151 linux,code = <0x100>;
52− gpio-key,wakeup;
52+ wakeup-source;
5353 };
5454 };
5555 };
arch/arm/boot/dts/sama5d4.dtsi+1−1
@@ -1300,7 +1300,7 @@ · 1299 unmodified lines
13001300 };
13011301
13021302 watchdog@fc068640 {
1303− compatible = "atmel,at91sam9260-wdt";
1303+ compatible = "atmel,sama5d4-wdt";
13041304 reg = <0xfc068640 0x10>;
13051305 clocks = <&clk32k>;
13061306 status = "disabled";
arch/arm/boot/dts/usb_a9260_common.dtsi+1−1
@@ -115,7 +115,7 @@ · 114 unmodified lines
115115 label = "user_pb";
116116 gpios = <&pioB 10 GPIO_ACTIVE_LOW>;
117117 linux,code = <28>;
118− gpio-key,wakeup;
118+ wakeup-source;
119119 };
120120 };
121121
arch/arm/boot/dts/usb_a9263.dts+1−1
@@ -143,7 +143,7 @@ · 142 unmodified lines
143143 label = "user_pb";
144144 gpios = <&pioB 10 GPIO_ACTIVE_LOW>;
145145 linux,code = <28>;
146− gpio-key,wakeup;
146+ wakeup-source;
147147 };
148148 };
149149
arch/arm/boot/dts/vf610-colibri.dtsi+0−5
@@ -18,8 +18,3 @@ · 17 unmodified lines
1818 reg = <0x80000000 0x10000000>;
1919 };
2020 };
21−
22−&L2 {
23− arm,data-latency = <2 1 2>;
24− arm,tag-latency = <3 2 3>;
25−};
arch/arm/boot/dts/vf610.dtsi+1−1
@@ -19,7 +19,7 @@ · 18 unmodified lines
1919 reg = <0x40006000 0x1000>;
2020 cache-unified;
2121 cache-level = <2>;
22− arm,data-latency = <1 1 1>;
22+ arm,data-latency = <3 3 3>;
2323 arm,tag-latency = <2 2 2>;
2424 };
2525 };
arch/arm/boot/dts/vfxxx.dtsi+8−6
@@ -158,7 +158,7 @@ · 157 unmodified lines
158158 interrupts = <67 IRQ_TYPE_LEVEL_HIGH>;
159159 clocks = <&clks VF610_CLK_DSPI0>;
160160 clock-names = "dspi";
161− spi-num-chipselects = <5>;
161+ spi-num-chipselects = <6>;
162162 status = "disabled";
163163 };
164164
@@ -170,7 +170,7 @@ · 5 unmodified lines
170170 interrupts = <68 IRQ_TYPE_LEVEL_HIGH>;
171171 clocks = <&clks VF610_CLK_DSPI1>;
172172 clock-names = "dspi";
173− spi-num-chipselects = <5>;
173+ spi-num-chipselects = <4>;
174174 status = "disabled";
175175 };
176176
@@ -178,8 +178,10 @@ · 1 unmodified line
178178 compatible = "fsl,vf610-sai";
179179 reg = <0x40031000 0x1000>;
180180 interrupts = <86 IRQ_TYPE_LEVEL_HIGH>;
181− clocks = <&clks VF610_CLK_SAI2>;
182− clock-names = "sai";
181+ clocks = <&clks VF610_CLK_SAI2>,
182+ <&clks VF610_CLK_SAI2_DIV>,
183+ <&clks 0>, <&clks 0>;
184+ clock-names = "bus", "mclk1", "mclk2", "mclk3";
183185 dma-names = "tx", "rx";
184186 dmas = <&edma0 0 21>,
185187 <&edma0 0 20>;
@@ -461,6 +463,8 @@ · 275 unmodified lines
461463 clock-names = "adc";
462464 #io-channel-cells = <1>;
463465 status = "disabled";
466+ fsl,adck-max-frequency = <30000000>, <40000000>,
467+ <20000000>;
464468 };
465469
466470 esdhc0: esdhc@400b1000 {
@@ -472,8 +476,6 @@ · 5 unmodified lines
472476 <&clks VF610_CLK_ESDHC0>;
473477 clock-names = "ipg", "ahb", "per";
474478 status = "disabled";
475− fsl,adck-max-frequency = <30000000>, <40000000>,
476− <20000000>;
477479 };
478480
479481 esdhc1: esdhc@400b2000 {
arch/arm/configs/at91_dt_defconfig+0−1
@@ -125,7 +125,6 @@ CONFIG_POWER_RESET=y · 124 unmodified lines
125125 # CONFIG_HWMON is not set
126126 CONFIG_WATCHDOG=y
127127 CONFIG_AT91SAM9X_WATCHDOG=y
128−CONFIG_SSB=m
129128 CONFIG_MFD_ATMEL_HLCDC=y
130129 CONFIG_REGULATOR=y
131130 CONFIG_REGULATOR_FIXED_VOLTAGE=y
arch/arm/configs/sama5_defconfig+0−1
@@ -129,7 +129,6 @@ CONFIG_GPIO_SYSFS=y · 128 unmodified lines
129129 CONFIG_POWER_SUPPLY=y
130130 CONFIG_POWER_RESET=y
131131 # CONFIG_HWMON is not set
132−CONFIG_SSB=m
133132 CONFIG_MFD_ATMEL_FLEXCOM=y
134133 CONFIG_REGULATOR=y
135134 CONFIG_REGULATOR_FIXED_VOLTAGE=y
arch/arm/include/asm/arch_gicv3.h+1−0
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 #ifndef __ASSEMBLY__
2222
2323 #include <linux/io.h>
24+#include <asm/barrier.h>
2425
2526 #define __ACCESS_CP15(CRn, Op1, CRm, Op2) p15, Op1, %0, CRn, CRm, Op2
2627 #define __ACCESS_CP15_64(Op1, CRm) p15, Op1, %Q0, %R0, CRm
arch/arm/include/asm/irq.h+5−0
@@ -40,6 +40,11 @@ extern void arch_trigger_all_cpu_backtrace(bool); · 39 unmodified lines
4040 #define arch_trigger_all_cpu_backtrace(x) arch_trigger_all_cpu_backtrace(x)
4141 #endif
4242
43+static inline int nr_legacy_irqs(void)
44+{
45+ return NR_IRQS_LEGACY;
46+}
47+
4348 #endif
4449
4550 #endif
arch/arm/include/asm/kvm_arm.h+17−17
@@ -19,6 +19,7 @@ · 18 unmodified lines
1919 #ifndef __ARM_KVM_ARM_H__
2020 #define __ARM_KVM_ARM_H__
2121
22+#include <linux/const.h>
2223 #include <linux/types.h>
2324
2425 /* Hyp Configuration Register (HCR) bits */
@@ -132,10 +133,9 @@ · 107 unmodified lines
132133 * space.
133134 */
134135 #define KVM_PHYS_SHIFT (40)
135−#define KVM_PHYS_SIZE (1ULL << KVM_PHYS_SHIFT)
136−#define KVM_PHYS_MASK (KVM_PHYS_SIZE - 1ULL)
137−#define PTRS_PER_S2_PGD (1ULL << (KVM_PHYS_SHIFT - 30))
138−#define S2_PGD_ORDER get_order(PTRS_PER_S2_PGD * sizeof(pgd_t))
136+#define KVM_PHYS_SIZE (_AC(1, ULL) << KVM_PHYS_SHIFT)
137+#define KVM_PHYS_MASK (KVM_PHYS_SIZE - _AC(1, ULL))
138+#define PTRS_PER_S2_PGD (_AC(1, ULL) << (KVM_PHYS_SHIFT - 30))
139139
140140 /* Virtualization Translation Control Register (VTCR) bits */
141141 #define VTCR_SH0 (3 << 12)
@@ -162,17 +162,17 @@ · 20 unmodified lines
162162 #define VTTBR_X (5 - KVM_T0SZ)
163163 #endif
164164 #define VTTBR_BADDR_SHIFT (VTTBR_X - 1)
165−#define VTTBR_BADDR_MASK (((1LLU << (40 - VTTBR_X)) - 1) << VTTBR_BADDR_SHIFT)
166−#define VTTBR_VMID_SHIFT (48LLU)
167−#define VTTBR_VMID_MASK (0xffLLU << VTTBR_VMID_SHIFT)
165+#define VTTBR_BADDR_MASK (((_AC(1, ULL) << (40 - VTTBR_X)) - 1) << VTTBR_BADDR_SHIFT)
166+#define VTTBR_VMID_SHIFT _AC(48, ULL)
167+#define VTTBR_VMID_MASK(size) (_AT(u64, (1 << size) - 1) << VTTBR_VMID_SHIFT)
168168
169169 /* Hyp Syndrome Register (HSR) bits */
170170 #define HSR_EC_SHIFT (26)
171−#define HSR_EC (0x3fU << HSR_EC_SHIFT)
172−#define HSR_IL (1U << 25)
171+#define HSR_EC (_AC(0x3f, UL) << HSR_EC_SHIFT)
172+#define HSR_IL (_AC(1, UL) << 25)
173173 #define HSR_ISS (HSR_IL - 1)
174174 #define HSR_ISV_SHIFT (24)
175−#define HSR_ISV (1U << HSR_ISV_SHIFT)
175+#define HSR_ISV (_AC(1, UL) << HSR_ISV_SHIFT)
176176 #define HSR_SRT_SHIFT (16)
177177 #define HSR_SRT_MASK (0xf << HSR_SRT_SHIFT)
178178 #define HSR_FSC (0x3f)
@@ -180,9 +180,9 @@ · 1 unmodified line
180180 #define HSR_SSE (1 << 21)
181181 #define HSR_WNR (1 << 6)
182182 #define HSR_CV_SHIFT (24)
183−#define HSR_CV (1U << HSR_CV_SHIFT)
183+#define HSR_CV (_AC(1, UL) << HSR_CV_SHIFT)
184184 #define HSR_COND_SHIFT (20)
185−#define HSR_COND (0xfU << HSR_COND_SHIFT)
185+#define HSR_COND (_AC(0xf, UL) << HSR_COND_SHIFT)
186186
187187 #define FSC_FAULT (0x04)
188188 #define FSC_ACCESS (0x08)
@@ -210,13 +210,13 @@ · 21 unmodified lines
210210 #define HSR_EC_DABT (0x24)
211211 #define HSR_EC_DABT_HYP (0x25)
212212
213−#define HSR_WFI_IS_WFE (1U << 0)
213+#define HSR_WFI_IS_WFE (_AC(1, UL) << 0)
214214
215−#define HSR_HVC_IMM_MASK ((1UL << 16) - 1)
215+#define HSR_HVC_IMM_MASK ((_AC(1, UL) << 16) - 1)
216216
217−#define HSR_DABT_S1PTW (1U << 7)
218−#define HSR_DABT_CM (1U << 8)
219−#define HSR_DABT_EA (1U << 9)
217+#define HSR_DABT_S1PTW (_AC(1, UL) << 7)
218+#define HSR_DABT_CM (_AC(1, UL) << 8)
219+#define HSR_DABT_EA (_AC(1, UL) << 9)
220220
221221 #define kvm_arm_exception_type \
222222 {0, "RESET" }, \
arch/arm/include/asm/kvm_emulate.h+12−0
@@ -28,6 +28,18 @@ · 27 unmodified lines
2828 unsigned long *vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num);
2929 unsigned long *vcpu_spsr(struct kvm_vcpu *vcpu);
3030
31+static inline unsigned long vcpu_get_reg(struct kvm_vcpu *vcpu,
32+ u8 reg_num)
33+{
34+ return *vcpu_reg(vcpu, reg_num);
35+}
36+
37+static inline void vcpu_set_reg(struct kvm_vcpu *vcpu, u8 reg_num,
38+ unsigned long val)
39+{
40+ *vcpu_reg(vcpu, reg_num) = val;
41+}
42+
3143 bool kvm_condition_valid(struct kvm_vcpu *vcpu);
3244 void kvm_skip_instr(struct kvm_vcpu *vcpu, bool is_wide_instr);
3345 void kvm_inject_undefined(struct kvm_vcpu *vcpu);
arch/arm/include/asm/kvm_host.h+6−0
@@ -150,6 +150,12 @@ struct kvm_vcpu_stat { · 149 unmodified lines
150150 u32 halt_successful_poll;
151151 u32 halt_attempted_poll;
152152 u32 halt_wakeup;
153+ u32 hvc_exit_stat;
154+ u64 wfe_exit_stat;
155+ u64 wfi_exit_stat;
156+ u64 mmio_exit_user;
157+ u64 mmio_exit_kernel;
158+ u64 exits;
153159 };
154160
155161 int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init);
arch/arm/include/asm/kvm_mmu.h+5−0
@@ -279,6 +279,11 @@ static inline void __kvm_extend_hypmap(pgd_t *boot_hyp_pgd, · 278 unmodified lines
279279 pgd_t *merged_hyp_pgd,
280280 unsigned long hyp_idmap_start) { }
281281
282+static inline unsigned int kvm_get_vmid_bits(void)
283+{
284+ return 8;
285+}
286+
282287 #endif /* !__ASSEMBLY__ */
283288
284289 #endif /* __ARM_KVM_MMU_H__ */
arch/arm/include/uapi/asm/unistd.h+1−0
@@ -416,6 +416,7 @@ · 415 unmodified lines
416416 #define __NR_execveat (__NR_SYSCALL_BASE+387)
417417 #define __NR_userfaultfd (__NR_SYSCALL_BASE+388)
418418 #define __NR_membarrier (__NR_SYSCALL_BASE+389)
419+#define __NR_mlock2 (__NR_SYSCALL_BASE+390)
419420
420421 /*
421422 * The following SWIs are ARM private.
arch/arm/kernel/bios32.c+11−8
@@ -17,11 +17,6 @@ · 16 unmodified lines
1717 #include <asm/mach/pci.h>
1818
1919 static int debug_pci;
20−static resource_size_t (*align_resource)(struct pci_dev *dev,
21− const struct resource *res,
22− resource_size_t start,
23− resource_size_t size,
24− resource_size_t align) = NULL;
2520
2621 /*
2722 * We can't use pci_get_device() here since we are
@@ -461,7 +456,6 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw, · 433 unmodified lines
461456 sys->busnr = busnr;
462457 sys->swizzle = hw->swizzle;
463458 sys->map_irq = hw->map_irq;
464− align_resource = hw->align_resource;
465459 INIT_LIST_HEAD(&sys->resources);
466460
467461 if (hw->private_data)
@@ -470,6 +464,8 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw, · 2 unmodified lines
470464 ret = hw->setup(nr, sys);
471465
472466 if (ret > 0) {
467+ struct pci_host_bridge *host_bridge;
468+
473469 ret = pcibios_init_resources(nr, sys);
474470 if (ret) {
475471 kfree(sys);
@@ -491,6 +487,9 @@ static void pcibios_init_hw(struct device *parent, struct hw_pci *hw, · 15 unmodified lines
491487 busnr = sys->bus->busn_res.end + 1;
492488
493489 list_add(&sys->node, head);
490+
491+ host_bridge = pci_find_host_bridge(sys->bus);
492+ host_bridge->align_resource = hw->align_resource;
494493 } else {
495494 kfree(sys);
496495 if (ret < 0)
@@ -578,14 +577,18 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res, · 81 unmodified lines
578577 {
579578 struct pci_dev *dev = data;
580579 resource_size_t start = res->start;
580+ struct pci_host_bridge *host_bridge;
581581
582582 if (res->flags & IORESOURCE_IO && start & 0x300)
583583 start = (start + 0x3ff) & ~0x3ff;
584584
585585 start = (start + align - 1) & ~(align - 1);
586586
587− if (align_resource)
588− return align_resource(dev, res, start, size, align);
587+ host_bridge = pci_find_host_bridge(dev->bus);
588+
589+ if (host_bridge->align_resource)
590+ return host_bridge->align_resource(dev, res,
591+ start, size, align);
589592
590593 return start;
591594 }
arch/arm/kernel/calls.S+1−0
@@ -399,6 +399,7 @@ · 398 unmodified lines
399399 CALL(sys_execveat)
400400 CALL(sys_userfaultfd)
401401 CALL(sys_membarrier)
402+ CALL(sys_mlock2)
402403 #ifndef syscalls_counted
403404 .equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls
404405 #define syscalls_counted
arch/arm/kvm/arm.c+36−4
@@ -44,6 +44,7 @@ · 43 unmodified lines
4444 #include <asm/kvm_emulate.h>
4545 #include <asm/kvm_coproc.h>
4646 #include <asm/kvm_psci.h>
47+#include <asm/sections.h>
4748
4849 #ifdef REQUIRES_VIRT
4950 __asm__(".arch_extension virt");
@@ -58,9 +59,12 @@ static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu); · 8 unmodified lines
5859
5960 /* The VMID used in the VTTBR */
6061 static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
61−static u8 kvm_next_vmid;
62+static u32 kvm_next_vmid;
63+static unsigned int kvm_vmid_bits __read_mostly;
6264 static DEFINE_SPINLOCK(kvm_vmid_lock);
6365
66+static bool vgic_present;
67+
6468 static void kvm_arm_set_running_vcpu(struct kvm_vcpu *vcpu)
6569 {
6670 BUG_ON(preemptible());
@@ -132,7 +136,8 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type) · 65 unmodified lines
132136 kvm->arch.vmid_gen = 0;
133137
134138 /* The maximum number of VCPUs is limited by the host's GIC model */
135− kvm->arch.max_vcpus = kvm_vgic_get_max_vcpus();
139+ kvm->arch.max_vcpus = vgic_present ?
140+ kvm_vgic_get_max_vcpus() : KVM_MAX_VCPUS;
136141
137142 return ret;
138143 out_free_stage2_pgd:
@@ -172,6 +177,8 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) · 33 unmodified lines
172177 int r;
173178 switch (ext) {
174179 case KVM_CAP_IRQCHIP:
180+ r = vgic_present;
181+ break;
175182 case KVM_CAP_IOEVENTFD:
176183 case KVM_CAP_DEVICE_CTRL:
177184 case KVM_CAP_USER_MEMORY:
@@ -433,11 +440,12 @@ static void update_vttbr(struct kvm *kvm) · 255 unmodified lines
433440 kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
434441 kvm->arch.vmid = kvm_next_vmid;
435442 kvm_next_vmid++;
443+ kvm_next_vmid &= (1 << kvm_vmid_bits) - 1;
436444
437445 /* update vttbr to be used with the new vmid */
438446 pgd_phys = virt_to_phys(kvm_get_hwpgd(kvm));
439447 BUG_ON(pgd_phys & ~VTTBR_BADDR_MASK);
440− vmid = ((u64)(kvm->arch.vmid) << VTTBR_VMID_SHIFT) & VTTBR_VMID_MASK;
448+ vmid = ((u64)(kvm->arch.vmid) << VTTBR_VMID_SHIFT) & VTTBR_VMID_MASK(kvm_vmid_bits);
441449 kvm->arch.vttbr = pgd_phys | vmid;
442450
443451 spin_unlock(&kvm_vmid_lock);
@@ -603,6 +611,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) · 159 unmodified lines
603611 ret = kvm_call_hyp(__kvm_vcpu_run, vcpu);
604612
605613 vcpu->mode = OUTSIDE_GUEST_MODE;
614+ vcpu->stat.exits++;
606615 /*
607616 * Back from guest
608617 *************************************************************/
@@ -913,6 +922,8 @@ static int kvm_vm_ioctl_set_device_addr(struct kvm *kvm, · 304 unmodified lines
913922
914923 switch (dev_id) {
915924 case KVM_ARM_DEVICE_VGIC_V2:
925+ if (!vgic_present)
926+ return -ENXIO;
916927 return kvm_vgic_addr(kvm, type, &dev_addr->addr, true);
917928 default:
918929 return -ENODEV;
@@ -927,6 +938,8 @@ long kvm_arch_vm_ioctl(struct file *filp, · 8 unmodified lines
927938
928939 switch (ioctl) {
929940 case KVM_CREATE_IRQCHIP: {
941+ if (!vgic_present)
942+ return -ENXIO;
930943 return kvm_vgic_create(kvm, KVM_DEV_TYPE_ARM_VGIC_V2);
931944 }
932945 case KVM_ARM_SET_DEVICE_ADDR: {
@@ -1067,6 +1080,12 @@ static int init_hyp_mode(void) · 134 unmodified lines
10671080 goto out_free_mappings;
10681081 }
10691082
1083+ err = create_hyp_mappings(__start_rodata, __end_rodata);
1084+ if (err) {
1085+ kvm_err("Cannot map rodata section\n");
1086+ goto out_free_mappings;
1087+ }
1088+
10701089 /*
10711090 * Map the Hyp stack pages
10721091 */
@@ -1111,8 +1130,17 @@ static int init_hyp_mode(void) · 38 unmodified lines
11111130 * Init HYP view of VGIC
11121131 */
11131132 err = kvm_vgic_hyp_init();
1114− if (err)
1133+ switch (err) {
1134+ case 0:
1135+ vgic_present = true;
1136+ break;
1137+ case -ENODEV:
1138+ case -ENXIO:
1139+ vgic_present = false;
1140+ break;
1141+ default:
11151142 goto out_free_context;
1143+ }
11161144
11171145 /*
11181146 * Init HYP architected timer support
@@ -1127,6 +1155,10 @@ static int init_hyp_mode(void) · 8 unmodified lines
11271155
11281156 kvm_perf_init();
11291157
1158+ /* set size of VMID supported by CPU */
1159+ kvm_vmid_bits = kvm_get_vmid_bits();
1160+ kvm_info("%d-bit VMID\n", kvm_vmid_bits);
1161+
11301162 kvm_info("Hyp mode initialized successfully\n");
11311163
11321164 return 0;
arch/arm/kvm/emulate.c+38−36
@@ -275,6 +275,40 @@ static u32 exc_vector_base(struct kvm_vcpu *vcpu) · 274 unmodified lines
275275 return vbar;
276276 }
277277
278+/*
279+ * Switch to an exception mode, updating both CPSR and SPSR. Follow
280+ * the logic described in AArch32.EnterMode() from the ARMv8 ARM.
281+ */
282+static void kvm_update_psr(struct kvm_vcpu *vcpu, unsigned long mode)
283+{
284+ unsigned long cpsr = *vcpu_cpsr(vcpu);
285+ u32 sctlr = vcpu->arch.cp15[c1_SCTLR];
286+
287+ *vcpu_cpsr(vcpu) = (cpsr & ~MODE_MASK) | mode;
288+
289+ switch (mode) {
290+ case FIQ_MODE:
291+ *vcpu_cpsr(vcpu) |= PSR_F_BIT;
292+ /* Fall through */
293+ case ABT_MODE:
294+ case IRQ_MODE:
295+ *vcpu_cpsr(vcpu) |= PSR_A_BIT;
296+ /* Fall through */
297+ default:
298+ *vcpu_cpsr(vcpu) |= PSR_I_BIT;
299+ }
300+
301+ *vcpu_cpsr(vcpu) &= ~(PSR_IT_MASK | PSR_J_BIT | PSR_E_BIT | PSR_T_BIT);
302+
303+ if (sctlr & SCTLR_TE)
304+ *vcpu_cpsr(vcpu) |= PSR_T_BIT;
305+ if (sctlr & SCTLR_EE)
306+ *vcpu_cpsr(vcpu) |= PSR_E_BIT;
307+
308+ /* Note: These now point to the mode banked copies */
309+ *vcpu_spsr(vcpu) = cpsr;
310+}
311+
278312 /**
279313 * kvm_inject_undefined - inject an undefined exception into the guest
280314 * @vcpu: The VCPU to receive the undefined exception
@@ -286,29 +320,13 @@ static u32 exc_vector_base(struct kvm_vcpu *vcpu) · 5 unmodified lines
286320 */
287321 void kvm_inject_undefined(struct kvm_vcpu *vcpu)
288322 {
289− unsigned long new_lr_value;
290− unsigned long new_spsr_value;
291323 unsigned long cpsr = *vcpu_cpsr(vcpu);
292− u32 sctlr = vcpu->arch.cp15[c1_SCTLR];
293324 bool is_thumb = (cpsr & PSR_T_BIT);
294325 u32 vect_offset = 4;
295326 u32 return_offset = (is_thumb) ? 2 : 4;
296327
297− new_spsr_value = cpsr;
298− new_lr_value = *vcpu_pc(vcpu) - return_offset;
299−
300− *vcpu_cpsr(vcpu) = (cpsr & ~MODE_MASK) | UND_MODE;
301− *vcpu_cpsr(vcpu) |= PSR_I_BIT;
302− *vcpu_cpsr(vcpu) &= ~(PSR_IT_MASK | PSR_J_BIT | PSR_E_BIT | PSR_T_BIT);
303−
304− if (sctlr & SCTLR_TE)
305− *vcpu_cpsr(vcpu) |= PSR_T_BIT;
306− if (sctlr & SCTLR_EE)
307− *vcpu_cpsr(vcpu) |= PSR_E_BIT;
308−
309− /* Note: These now point to UND banked copies */
310− *vcpu_spsr(vcpu) = cpsr;
311− *vcpu_reg(vcpu, 14) = new_lr_value;
328+ kvm_update_psr(vcpu, UND_MODE);
329+ *vcpu_reg(vcpu, 14) = *vcpu_pc(vcpu) - return_offset;
312330
313331 /* Branch to exception vector */
314332 *vcpu_pc(vcpu) = exc_vector_base(vcpu) + vect_offset;
@@ -320,30 +338,14 @@ void kvm_inject_undefined(struct kvm_vcpu *vcpu) · 5 unmodified lines
320338 */
321339 static void inject_abt(struct kvm_vcpu *vcpu, bool is_pabt, unsigned long addr)
322340 {
323− unsigned long new_lr_value;
324− unsigned long new_spsr_value;
325341 unsigned long cpsr = *vcpu_cpsr(vcpu);
326− u32 sctlr = vcpu->arch.cp15[c1_SCTLR];
327342 bool is_thumb = (cpsr & PSR_T_BIT);
328343 u32 vect_offset;
329344 u32 return_offset = (is_thumb) ? 4 : 0;
330345 bool is_lpae;
331346
332− new_spsr_value = cpsr;
333− new_lr_value = *vcpu_pc(vcpu) + return_offset;
334−
335− *vcpu_cpsr(vcpu) = (cpsr & ~MODE_MASK) | ABT_MODE;
336− *vcpu_cpsr(vcpu) |= PSR_I_BIT | PSR_A_BIT;
337− *vcpu_cpsr(vcpu) &= ~(PSR_IT_MASK | PSR_J_BIT | PSR_E_BIT | PSR_T_BIT);
338−
339− if (sctlr & SCTLR_TE)
340− *vcpu_cpsr(vcpu) |= PSR_T_BIT;
341− if (sctlr & SCTLR_EE)
342− *vcpu_cpsr(vcpu) |= PSR_E_BIT;
343−
344− /* Note: These now point to ABT banked copies */
345− *vcpu_spsr(vcpu) = cpsr;
346− *vcpu_reg(vcpu, 14) = new_lr_value;
347+ kvm_update_psr(vcpu, ABT_MODE);
348+ *vcpu_reg(vcpu, 14) = *vcpu_pc(vcpu) + return_offset;
347349
348350 if (is_pabt)
349351 vect_offset = 12;
arch/arm/kvm/guest.c+6−0
@@ -33,6 +33,12 @@ · 32 unmodified lines
3333 #define VCPU_STAT(x) { #x, offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU }
3434
3535 struct kvm_stats_debugfs_item debugfs_entries[] = {
36+ VCPU_STAT(hvc_exit_stat),
37+ VCPU_STAT(wfe_exit_stat),
38+ VCPU_STAT(wfi_exit_stat),
39+ VCPU_STAT(mmio_exit_user),
40+ VCPU_STAT(mmio_exit_kernel),
41+ VCPU_STAT(exits),
3642 { NULL }
3743 };
3844
arch/arm/kvm/handle_exit.c+3−0
@@ -42,6 +42,7 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run) · 41 unmodified lines
4242
4343 trace_kvm_hvc(*vcpu_pc(vcpu), *vcpu_reg(vcpu, 0),
4444 kvm_vcpu_hvc_get_imm(vcpu));
45+ vcpu->stat.hvc_exit_stat++;
4546
4647 ret = kvm_psci_call(vcpu);
4748 if (ret < 0) {
@@ -89,9 +90,11 @@ static int kvm_handle_wfx(struct kvm_vcpu *vcpu, struct kvm_run *run) · 41 unmodified lines
8990 {
9091 if (kvm_vcpu_get_hsr(vcpu) & HSR_WFI_IS_WFE) {
9192 trace_kvm_wfx(*vcpu_pc(vcpu), true);
93+ vcpu->stat.wfe_exit_stat++;
9294 kvm_vcpu_on_spin(vcpu);
9395 } else {
9496 trace_kvm_wfx(*vcpu_pc(vcpu), false);
97+ vcpu->stat.wfi_exit_stat++;
9598 kvm_vcpu_block(vcpu);
9699 }
97100
arch/arm/kvm/mmio.c+6−2
@@ -115,7 +115,7 @@ int kvm_handle_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run) · 114 unmodified lines
115115 trace_kvm_mmio(KVM_TRACE_MMIO_READ, len, run->mmio.phys_addr,
116116 data);
117117 data = vcpu_data_host_to_guest(vcpu, data, len);
118− *vcpu_reg(vcpu, vcpu->arch.mmio_decode.rt) = data;
118+ vcpu_set_reg(vcpu, vcpu->arch.mmio_decode.rt, data);
119119 }
120120
121121 return 0;
@@ -186,7 +186,8 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run, · 64 unmodified lines
186186 rt = vcpu->arch.mmio_decode.rt;
187187
188188 if (is_write) {
189− data = vcpu_data_guest_to_host(vcpu, *vcpu_reg(vcpu, rt), len);
189+ data = vcpu_data_guest_to_host(vcpu, vcpu_get_reg(vcpu, rt),
190+ len);
190191
191192 trace_kvm_mmio(KVM_TRACE_MMIO_WRITE, len, fault_ipa, data);
192193 mmio_write_buf(data_buf, len, data);
@@ -209,8 +210,11 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run, · 16 unmodified lines
209210
210211 if (!ret) {
211212 /* We handled the access successfully in the kernel. */
213+ vcpu->stat.mmio_exit_kernel++;
212214 kvm_handle_mmio_return(vcpu, run);
213215 return 1;
216+ } else {
217+ vcpu->stat.mmio_exit_user++;
214218 }
215219
216220 run->exit_reason = KVM_EXIT_MMIO;
arch/arm/kvm/mmu.c+5−5
@@ -218,7 +218,7 @@ static void unmap_ptes(struct kvm *kvm, pmd_t *pmd, · 217 unmodified lines
218218 kvm_tlb_flush_vmid_ipa(kvm, addr);
219219
220220 /* No need to invalidate the cache for device mappings */
221− if (!kvm_is_device_pfn(__phys_to_pfn(addr)))
221+ if (!kvm_is_device_pfn(pte_pfn(old_pte)))
222222 kvm_flush_dcache_pte(old_pte);
223223
224224 put_page(virt_to_page(pte));
@@ -310,7 +310,7 @@ static void stage2_flush_ptes(struct kvm *kvm, pmd_t *pmd, · 85 unmodified lines
310310
311311 pte = pte_offset_kernel(pmd, addr);
312312 do {
313− if (!pte_none(*pte) && !kvm_is_device_pfn(__phys_to_pfn(addr)))
313+ if (!pte_none(*pte) && !kvm_is_device_pfn(pte_pfn(*pte)))
314314 kvm_flush_dcache_pte(*pte);
315315 } while (pte++, addr += PAGE_SIZE, addr != end);
316316 }
@@ -656,9 +656,9 @@ static void *kvm_alloc_hwpgd(void) · 339 unmodified lines
656656 * kvm_alloc_stage2_pgd - allocate level-1 table for stage-2 translation.
657657 * @kvm: The KVM struct pointer for the VM.
658658 *
659− * Allocates the 1st level table only of size defined by S2_PGD_ORDER (can
660− * support either full 40-bit input addresses or limited to 32-bit input
661− * addresses). Clears the allocated pages.
659+ * Allocates only the stage-2 HW PGD level table(s) (can support either full
660+ * 40-bit input addresses or limited to 32-bit input addresses). Clears the
661+ * allocated pages.
662662 *
663663 * Note we don't need locking here as this is only called when the VM is
664664 * created, which can only be done once.
arch/arm/kvm/psci.c+10−10
@@ -75,7 +75,7 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu) · 74 unmodified lines
7575 unsigned long context_id;
7676 phys_addr_t target_pc;
7777
78− cpu_id = *vcpu_reg(source_vcpu, 1) & MPIDR_HWID_BITMASK;
78+ cpu_id = vcpu_get_reg(source_vcpu, 1) & MPIDR_HWID_BITMASK;
7979 if (vcpu_mode_is_32bit(source_vcpu))
8080 cpu_id &= ~((u32) 0);
8181
@@ -94,8 +94,8 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu) · 12 unmodified lines
9494 return PSCI_RET_INVALID_PARAMS;
9595 }
9696
97− target_pc = *vcpu_reg(source_vcpu, 2);
98− context_id = *vcpu_reg(source_vcpu, 3);
97+ target_pc = vcpu_get_reg(source_vcpu, 2);
98+ context_id = vcpu_get_reg(source_vcpu, 3);
9999
100100 kvm_reset_vcpu(vcpu);
101101
@@ -114,7 +114,7 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu) · 12 unmodified lines
114114 * NOTE: We always update r0 (or x0) because for PSCI v0.1
115115 * the general puspose registers are undefined upon CPU_ON.
116116 */
117− *vcpu_reg(vcpu, 0) = context_id;
117+ vcpu_set_reg(vcpu, 0, context_id);
118118 vcpu->arch.power_off = false;
119119 smp_mb(); /* Make sure the above is visible */
120120
@@ -134,8 +134,8 @@ static unsigned long kvm_psci_vcpu_affinity_info(struct kvm_vcpu *vcpu) · 13 unmodified lines
134134 struct kvm *kvm = vcpu->kvm;
135135 struct kvm_vcpu *tmp;
136136
137− target_affinity = *vcpu_reg(vcpu, 1);
138− lowest_affinity_level = *vcpu_reg(vcpu, 2);
137+ target_affinity = vcpu_get_reg(vcpu, 1);
138+ lowest_affinity_level = vcpu_get_reg(vcpu, 2);
139139
140140 /* Determine target affinity mask */
141141 target_affinity_mask = psci_affinity_mask(lowest_affinity_level);
@@ -209,7 +209,7 @@ int kvm_psci_version(struct kvm_vcpu *vcpu) · 67 unmodified lines
209209 static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu)
210210 {
211211 int ret = 1;
212− unsigned long psci_fn = *vcpu_reg(vcpu, 0) & ~((u32) 0);
212+ unsigned long psci_fn = vcpu_get_reg(vcpu, 0) & ~((u32) 0);
213213 unsigned long val;
214214
215215 switch (psci_fn) {
@@ -273,13 +273,13 @@ static int kvm_psci_0_2_call(struct kvm_vcpu *vcpu) · 57 unmodified lines
273273 break;
274274 }
275275
276− *vcpu_reg(vcpu, 0) = val;
276+ vcpu_set_reg(vcpu, 0, val);
277277 return ret;
278278 }
279279
280280 static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu)
281281 {
282− unsigned long psci_fn = *vcpu_reg(vcpu, 0) & ~((u32) 0);
282+ unsigned long psci_fn = vcpu_get_reg(vcpu, 0) & ~((u32) 0);
283283 unsigned long val;
284284
285285 switch (psci_fn) {
@@ -295,7 +295,7 @@ static int kvm_psci_0_1_call(struct kvm_vcpu *vcpu) · 9 unmodified lines
295295 break;
296296 }
297297
298− *vcpu_reg(vcpu, 0) = val;
298+ vcpu_set_reg(vcpu, 0, val);
299299 return 1;
300300 }
301301
arch/arm/mach-at91/Kconfig+5−1
@@ -4,7 +4,6 @@ menuconfig ARCH_AT91 · 3 unmodified lines
44 select ARCH_REQUIRE_GPIOLIB
55 select COMMON_CLK_AT91
66 select PINCTRL
7− select PINCTRL_AT91
87 select SOC_BUS
98
109 if ARCH_AT91
@@ -17,6 +16,7 @@ config SOC_SAMA5D2 · 6 unmodified lines
1716 select HAVE_AT91_USB_CLK
1817 select HAVE_AT91_H32MX
1918 select HAVE_AT91_GENERATED_CLK
19+ select PINCTRL_AT91PIO4
2020 help
2121 Select this if ou are using one of Atmel's SAMA5D2 family SoC.
2222
@@ -27,6 +27,7 @@ config SOC_SAMA5D3 · 4 unmodified lines
2727 select HAVE_AT91_UTMI
2828 select HAVE_AT91_SMD
2929 select HAVE_AT91_USB_CLK
30+ select PINCTRL_AT91
3031 help
3132 Select this if you are using one of Atmel's SAMA5D3 family SoC.
3233 This support covers SAMA5D31, SAMA5D33, SAMA5D34, SAMA5D35, SAMA5D36.
@@ -40,6 +41,7 @@ config SOC_SAMA5D4 · 7 unmodified lines
4041 select HAVE_AT91_SMD
4142 select HAVE_AT91_USB_CLK
4243 select HAVE_AT91_H32MX
44+ select PINCTRL_AT91
4345 help
4446 Select this if you are using one of Atmel's SAMA5D4 family SoC.
4547
@@ -50,6 +52,7 @@ config SOC_AT91RM9200 · 4 unmodified lines
5052 select CPU_ARM920T
5153 select HAVE_AT91_USB_CLK
5254 select MIGHT_HAVE_PCI
55+ select PINCTRL_AT91
5356 select SOC_SAM_V4_V5
5457 select SRAM if PM
5558 help
@@ -65,6 +68,7 @@ config SOC_AT91SAM9 · 9 unmodified lines
6568 select HAVE_AT91_UTMI
6669 select HAVE_FB_ATMEL
6770 select MEMORY
71+ select PINCTRL_AT91
6872 select SOC_SAM_V4_V5
6973 select SRAM if PM
7074 help
arch/arm/mach-at91/pm.c+6−1
@@ -41,8 +41,10 @@ · 40 unmodified lines
4141 * implementation should be moved down into the pinctrl driver and get
4242 * called as part of the generic suspend/resume path.
4343 */
44+#ifdef CONFIG_PINCTRL_AT91
4445 extern void at91_pinctrl_gpio_suspend(void);
4546 extern void at91_pinctrl_gpio_resume(void);
47+#endif
4648
4749 static struct {
4850 unsigned long uhp_udp_mask;
@@ -151,8 +153,9 @@ static void at91_pm_suspend(suspend_state_t state) · 102 unmodified lines
151153
152154 static int at91_pm_enter(suspend_state_t state)
153155 {
156+#ifdef CONFIG_PINCTRL_AT91
154157 at91_pinctrl_gpio_suspend();
155−
158+#endif
156159 switch (state) {
157160 /*
158161 * Suspend-to-RAM is like STANDBY plus slow clock mode, so
@@ -192,7 +195,9 @@ static int at91_pm_enter(suspend_state_t state) · 33 unmodified lines
192195 error:
193196 target_state = PM_SUSPEND_ON;
194197
198+#ifdef CONFIG_PINCTRL_AT91
195199 at91_pinctrl_gpio_resume();
200+#endif
196201 return 0;
197202 }
198203
arch/arm/mach-dove/include/mach/entry-macro.S+2−2
@@ -18,13 +18,13 @@ · 17 unmodified lines
1818 @ check low interrupts
1919 ldr \irqstat, [\base, #IRQ_CAUSE_LOW_OFF]
2020 ldr \tmp, [\base, #IRQ_MASK_LOW_OFF]
21− mov \irqnr, #31
21+ mov \irqnr, #32
2222 ands \irqstat, \irqstat, \tmp
2323
2424 @ if no low interrupts set, check high interrupts
2525 ldreq \irqstat, [\base, #IRQ_CAUSE_HIGH_OFF]
2626 ldreq \tmp, [\base, #IRQ_MASK_HIGH_OFF]
27− moveq \irqnr, #63
27+ moveq \irqnr, #64
2828 andeqs \irqstat, \irqstat, \tmp
2929
3030 @ find first active interrupt source
arch/arm/mach-exynos/pmu.c+5−1
@@ -748,8 +748,12 @@ static void exynos5_powerdown_conf(enum sys_powerdown mode) · 747 unmodified lines
748748 void exynos_sys_powerdown_conf(enum sys_powerdown mode)
749749 {
750750 unsigned int i;
751+ const struct exynos_pmu_data *pmu_data;
752+
753+ if (!pmu_context)
754+ return;
751755
752− const struct exynos_pmu_data *pmu_data = pmu_context->pmu_data;
756+ pmu_data = pmu_context->pmu_data;
753757
754758 if (pmu_data->powerdown_conf)
755759 pmu_data->powerdown_conf(mode);
arch/arm/mach-imx/gpc.c+1−0
@@ -177,6 +177,7 @@ static struct irq_chip imx_gpc_chip = { · 176 unmodified lines
177177 .irq_unmask = imx_gpc_irq_unmask,
178178 .irq_retrigger = irq_chip_retrigger_hierarchy,
179179 .irq_set_wake = imx_gpc_irq_set_wake,
180+ .irq_set_type = irq_chip_set_type_parent,
180181 #ifdef CONFIG_SMP
181182 .irq_set_affinity = irq_chip_set_affinity_parent,
182183 #endif
arch/arm/mach-ixp4xx/include/mach/io.h+6−6
@@ -143,7 +143,7 @@ static inline void __indirect_writesl(volatile void __iomem *bus_addr, · 142 unmodified lines
143143 writel(*vaddr++, bus_addr);
144144 }
145145
146−static inline unsigned char __indirect_readb(const volatile void __iomem *p)
146+static inline u8 __indirect_readb(const volatile void __iomem *p)
147147 {
148148 u32 addr = (u32)p;
149149 u32 n, byte_enables, data;
@@ -166,7 +166,7 @@ static inline void __indirect_readsb(const volatile void __iomem *bus_addr, · 16 unmodified lines
166166 *vaddr++ = readb(bus_addr);
167167 }
168168
169−static inline unsigned short __indirect_readw(const volatile void __iomem *p)
169+static inline u16 __indirect_readw(const volatile void __iomem *p)
170170 {
171171 u32 addr = (u32)p;
172172 u32 n, byte_enables, data;
@@ -189,7 +189,7 @@ static inline void __indirect_readsw(const volatile void __iomem *bus_addr, · 16 unmodified lines
189189 *vaddr++ = readw(bus_addr);
190190 }
191191
192−static inline unsigned long __indirect_readl(const volatile void __iomem *p)
192+static inline u32 __indirect_readl(const volatile void __iomem *p)
193193 {
194194 u32 addr = (__force u32)p;
195195 u32 data;
@@ -350,7 +350,7 @@ static inline void insl(u32 io_addr, void *p, u32 count) · 154 unmodified lines
350350 ((unsigned long)p <= (PIO_MASK + PIO_OFFSET)))
351351
352352 #define ioread8(p) ioread8(p)
353−static inline unsigned int ioread8(const void __iomem *addr)
353+static inline u8 ioread8(const void __iomem *addr)
354354 {
355355 unsigned long port = (unsigned long __force)addr;
356356 if (__is_io_address(port))
@@ -378,7 +378,7 @@ static inline void ioread8_rep(const void __iomem *addr, void *vaddr, u32 count) · 21 unmodified lines
378378 }
379379
380380 #define ioread16(p) ioread16(p)
381−static inline unsigned int ioread16(const void __iomem *addr)
381+static inline u16 ioread16(const void __iomem *addr)
382382 {
383383 unsigned long port = (unsigned long __force)addr;
384384 if (__is_io_address(port))
@@ -407,7 +407,7 @@ static inline void ioread16_rep(const void __iomem *addr, void *vaddr, · 22 unmodified lines
407407 }
408408
409409 #define ioread32(p) ioread32(p)
410−static inline unsigned int ioread32(const void __iomem *addr)
410+static inline u32 ioread32(const void __iomem *addr)
411411 {
412412 unsigned long port = (unsigned long __force)addr;
413413 if (__is_io_address(port))
arch/arm/mach-omap2/Kconfig+1−1
@@ -121,6 +121,7 @@ config ARCH_OMAP2PLUS_TYPICAL · 120 unmodified lines
121121 select NEON if CPU_V7
122122 select PM
123123 select REGULATOR
124+ select REGULATOR_FIXED_VOLTAGE
124125 select TWL4030_CORE if ARCH_OMAP3 || ARCH_OMAP4
125126 select TWL4030_POWER if ARCH_OMAP3 || ARCH_OMAP4
126127 select VFP
@@ -201,7 +202,6 @@ config MACH_OMAP3_PANDORA · 74 unmodified lines
201202 depends on ARCH_OMAP3
202203 default y
203204 select OMAP_PACKAGE_CBB
204− select REGULATOR_FIXED_VOLTAGE if REGULATOR
205205
206206 config MACH_NOKIA_N810
207207 bool
arch/arm/mach-omap2/omap-smp.c+3−3
@@ -143,9 +143,9 @@ static int omap4_boot_secondary(unsigned int cpu, struct task_struct *idle) · 142 unmodified lines
143143 * Ensure that CPU power state is set to ON to avoid CPU
144144 * powerdomain transition on wfi
145145 */
146− clkdm_wakeup(cpu1_clkdm);
147− omap_set_pwrdm_state(cpu1_pwrdm, PWRDM_POWER_ON);
148− clkdm_allow_idle(cpu1_clkdm);
146+ clkdm_wakeup_nolock(cpu1_clkdm);
147+ pwrdm_set_next_pwrst(cpu1_pwrdm, PWRDM_POWER_ON);
148+ clkdm_allow_idle_nolock(cpu1_clkdm);
149149
150150 if (IS_PM44XX_ERRATUM(PM_OMAP4_ROM_SMP_BOOT_ERRATUM_GICD)) {
151151 while (gic_dist_disabled()) {
arch/arm/mach-omap2/omap_hwmod.c+36−30
@@ -890,6 +890,36 @@ static int _init_opt_clks(struct omap_hwmod *oh) · 889 unmodified lines
890890 return ret;
891891 }
892892
893+static void _enable_optional_clocks(struct omap_hwmod *oh)
894+{
895+ struct omap_hwmod_opt_clk *oc;
896+ int i;
897+
898+ pr_debug("omap_hwmod: %s: enabling optional clocks\n", oh->name);
899+
900+ for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++)
901+ if (oc->_clk) {
902+ pr_debug("omap_hwmod: enable %s:%s\n", oc->role,
903+ __clk_get_name(oc->_clk));
904+ clk_enable(oc->_clk);
905+ }
906+}
907+
908+static void _disable_optional_clocks(struct omap_hwmod *oh)
909+{
910+ struct omap_hwmod_opt_clk *oc;
911+ int i;
912+
913+ pr_debug("omap_hwmod: %s: disabling optional clocks\n", oh->name);
914+
915+ for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++)
916+ if (oc->_clk) {
917+ pr_debug("omap_hwmod: disable %s:%s\n", oc->role,
918+ __clk_get_name(oc->_clk));
919+ clk_disable(oc->_clk);
920+ }
921+}
922+
893923 /**
894924 * _enable_clocks - enable hwmod main clock and interface clocks
895925 * @oh: struct omap_hwmod *
@@ -917,6 +947,9 @@ static int _enable_clocks(struct omap_hwmod *oh) · 21 unmodified lines
917947 clk_enable(os->_clk);
918948 }
919949
950+ if (oh->flags & HWMOD_OPT_CLKS_NEEDED)
951+ _enable_optional_clocks(oh);
952+
920953 /* The opt clocks are controlled by the device driver. */
921954
922955 return 0;
@@ -948,41 +981,14 @@ static int _disable_clocks(struct omap_hwmod *oh) · 25 unmodified lines
948981 clk_disable(os->_clk);
949982 }
950983
984+ if (oh->flags & HWMOD_OPT_CLKS_NEEDED)
985+ _disable_optional_clocks(oh);
986+
951987 /* The opt clocks are controlled by the device driver. */
952988
953989 return 0;
954990 }
955991
956−static void _enable_optional_clocks(struct omap_hwmod *oh)
957−{
958− struct omap_hwmod_opt_clk *oc;
959− int i;
960−
961− pr_debug("omap_hwmod: %s: enabling optional clocks\n", oh->name);
962−
963− for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++)
964− if (oc->_clk) {
965− pr_debug("omap_hwmod: enable %s:%s\n", oc->role,
966− __clk_get_name(oc->_clk));
967− clk_enable(oc->_clk);
968− }
969−}
970−
971−static void _disable_optional_clocks(struct omap_hwmod *oh)
972−{
973− struct omap_hwmod_opt_clk *oc;
974− int i;
975−
976− pr_debug("omap_hwmod: %s: disabling optional clocks\n", oh->name);
977−
978− for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++)
979− if (oc->_clk) {
980− pr_debug("omap_hwmod: disable %s:%s\n", oc->role,
981− __clk_get_name(oc->_clk));
982− clk_disable(oc->_clk);
983− }
984−}
985−
986992 /**
987993 * _omap4_enable_module - enable CLKCTRL modulemode on OMAP4
988994 * @oh: struct omap_hwmod *
arch/arm/mach-omap2/omap_hwmod.h+3−0
@@ -523,6 +523,8 @@ struct omap_hwmod_omap4_prcm { · 522 unmodified lines
523523 * HWMOD_RECONFIG_IO_CHAIN: omap_hwmod code needs to reconfigure wake-up
524524 * events by calling _reconfigure_io_chain() when a device is enabled
525525 * or idled.
526+ * HWMOD_OPT_CLKS_NEEDED: The optional clocks are needed for the module to
527+ * operate and they need to be handled at the same time as the main_clk.
526528 */
527529 #define HWMOD_SWSUP_SIDLE (1 << 0)
528530 #define HWMOD_SWSUP_MSTANDBY (1 << 1)
@@ -538,6 +540,7 @@ struct omap_hwmod_omap4_prcm { · 9 unmodified lines
538540 #define HWMOD_FORCE_MSTANDBY (1 << 11)
539541 #define HWMOD_SWSUP_SIDLE_ACT (1 << 12)
540542 #define HWMOD_RECONFIG_IO_CHAIN (1 << 13)
543+#define HWMOD_OPT_CLKS_NEEDED (1 << 14)
541544
542545 /*
543546 * omap_hwmod._int_flags definitions
arch/arm/mach-omap2/omap_hwmod_7xx_data.c+56−0
@@ -1297,6 +1297,44 @@ static struct omap_hwmod dra7xx_mcspi4_hwmod = { · 1296 unmodified lines
12971297 .dev_attr = &mcspi4_dev_attr,
12981298 };
12991299
1300+/*
1301+ * 'mcasp' class
1302+ *
1303+ */
1304+static struct omap_hwmod_class_sysconfig dra7xx_mcasp_sysc = {
1305+ .sysc_offs = 0x0004,
1306+ .sysc_flags = SYSC_HAS_SIDLEMODE,
1307+ .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
1308+ .sysc_fields = &omap_hwmod_sysc_type3,
1309+};
1310+
1311+static struct omap_hwmod_class dra7xx_mcasp_hwmod_class = {
1312+ .name = "mcasp",
1313+ .sysc = &dra7xx_mcasp_sysc,
1314+};
1315+
1316+/* mcasp3 */
1317+static struct omap_hwmod_opt_clk mcasp3_opt_clks[] = {
1318+ { .role = "ahclkx", .clk = "mcasp3_ahclkx_mux" },
1319+};
1320+
1321+static struct omap_hwmod dra7xx_mcasp3_hwmod = {
1322+ .name = "mcasp3",
1323+ .class = &dra7xx_mcasp_hwmod_class,
1324+ .clkdm_name = "l4per2_clkdm",
1325+ .main_clk = "mcasp3_aux_gfclk_mux",
1326+ .flags = HWMOD_OPT_CLKS_NEEDED,
1327+ .prcm = {
1328+ .omap4 = {
1329+ .clkctrl_offs = DRA7XX_CM_L4PER2_MCASP3_CLKCTRL_OFFSET,
1330+ .context_offs = DRA7XX_RM_L4PER2_MCASP3_CONTEXT_OFFSET,
1331+ .modulemode = MODULEMODE_SWCTRL,
1332+ },
1333+ },
1334+ .opt_clks = mcasp3_opt_clks,
1335+ .opt_clks_cnt = ARRAY_SIZE(mcasp3_opt_clks),
1336+};
1337+
13001338 /*
13011339 * 'mmc' class
13021340 *
@@ -2566,6 +2604,22 @@ static struct omap_hwmod_ocp_if dra7xx_l3_main_1__hdmi = { · 1263 unmodified lines
25662604 .user = OCP_USER_MPU | OCP_USER_SDMA,
25672605 };
25682606
2607+/* l4_per2 -> mcasp3 */
2608+static struct omap_hwmod_ocp_if dra7xx_l4_per2__mcasp3 = {
2609+ .master = &dra7xx_l4_per2_hwmod,
2610+ .slave = &dra7xx_mcasp3_hwmod,
2611+ .clk = "l4_root_clk_div",
2612+ .user = OCP_USER_MPU | OCP_USER_SDMA,
2613+};
2614+
2615+/* l3_main_1 -> mcasp3 */
2616+static struct omap_hwmod_ocp_if dra7xx_l3_main_1__mcasp3 = {
2617+ .master = &dra7xx_l3_main_1_hwmod,
2618+ .slave = &dra7xx_mcasp3_hwmod,
2619+ .clk = "l3_iclk_div",
2620+ .user = OCP_USER_MPU | OCP_USER_SDMA,
2621+};
2622+
25692623 /* l4_per1 -> elm */
25702624 static struct omap_hwmod_ocp_if dra7xx_l4_per1__elm = {
25712625 .master = &dra7xx_l4_per1_hwmod,
@@ -3308,6 +3362,8 @@ static struct omap_hwmod_ocp_if *dra7xx_hwmod_ocp_ifs[] __initdata = { · 736 unmodified lines
33083362 &dra7xx_l4_wkup__dcan1,
33093363 &dra7xx_l4_per2__dcan2,
33103364 &dra7xx_l4_per2__cpgmac0,
3365+ &dra7xx_l4_per2__mcasp3,
3366+ &dra7xx_l3_main_1__mcasp3,
33113367 &dra7xx_gmac__mdio,
33123368 &dra7xx_l4_cfg__dma_system,
33133369 &dra7xx_l3_main_1__dss,
arch/arm/mach-omap2/omap_hwmod_81xx_data.c+3−0
@@ -144,6 +144,7 @@ static struct omap_hwmod dm81xx_l4_ls_hwmod = { · 143 unmodified lines
144144 .name = "l4_ls",
145145 .clkdm_name = "alwon_l3s_clkdm",
146146 .class = &l4_hwmod_class,
147+ .flags = HWMOD_NO_IDLEST,
147148 };
148149
149150 /*
@@ -155,6 +156,7 @@ static struct omap_hwmod dm81xx_l4_hs_hwmod = { · 5 unmodified lines
155156 .name = "l4_hs",
156157 .clkdm_name = "alwon_l3_med_clkdm",
157158 .class = &l4_hwmod_class,
159+ .flags = HWMOD_NO_IDLEST,
158160 };
159161
160162 /* L3 slow -> L4 ls peripheral interface running at 125MHz */
@@ -850,6 +852,7 @@ static struct omap_hwmod dm816x_emac0_hwmod = { · 689 unmodified lines
850852 .name = "emac0",
851853 .clkdm_name = "alwon_ethernet_clkdm",
852854 .class = &dm816x_emac_hwmod_class,
855+ .flags = HWMOD_NO_IDLEST,
853856 };
854857
855858 static struct omap_hwmod_ocp_if dm81xx_l4_hs__emac0 = {
arch/arm/mach-omap2/pdata-quirks.c+0−29
@@ -24,9 +24,6 @@ · 23 unmodified lines
2424 #include <linux/platform_data/iommu-omap.h>
2525 #include <linux/platform_data/wkup_m3.h>
2626
27−#include <asm/siginfo.h>
28−#include <asm/signal.h>
29−
3027 #include "common.h"
3128 #include "common-board-devices.h"
3229 #include "dss-common.h"
@@ -385,29 +382,6 @@ static void __init omap3_pandora_legacy_init(void) · 352 unmodified lines
385382 }
386383 #endif /* CONFIG_ARCH_OMAP3 */
387384
388−#ifdef CONFIG_SOC_TI81XX
389−static int fault_fixed_up;
390−
391−static int t410_abort_handler(unsigned long addr, unsigned int fsr,
392− struct pt_regs *regs)
393−{
394− if ((fsr == 0x406 || fsr == 0xc06) && !fault_fixed_up) {
395− pr_warn("External imprecise Data abort at addr=%#lx, fsr=%#x ignored.\n",
396− addr, fsr);
397− fault_fixed_up = 1;
398− return 0;
399− }
400−
401− return 1;
402−}
403−
404−static void __init t410_abort_init(void)
405−{
406− hook_fault_code(16 + 6, t410_abort_handler, SIGBUS, BUS_OBJERR,
407− "imprecise external abort");
408−}
409−#endif
410−
411385 #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5)
412386 static struct iommu_platform_data omap4_iommu_pdata = {
413387 .reset_name = "mmu_cache",
@@ -536,9 +510,6 @@ static struct pdata_init pdata_quirks[] __initdata = { · 122 unmodified lines
536510 { "openpandora,omap3-pandora-600mhz", omap3_pandora_legacy_init, },
537511 { "openpandora,omap3-pandora-1ghz", omap3_pandora_legacy_init, },
538512 #endif
539−#ifdef CONFIG_SOC_TI81XX
540− { "hp,t410", t410_abort_init, },
541−#endif
542513 #ifdef CONFIG_SOC_OMAP5
543514 { "ti,omap5-uevm", omap5_uevm_legacy_init, },
544515 #endif
arch/arm/mach-omap2/pm34xx.c+2−2
@@ -301,11 +301,11 @@ static void omap3_pm_idle(void) · 300 unmodified lines
301301 if (omap_irq_pending())
302302 return;
303303
304− trace_cpu_idle(1, smp_processor_id());
304+ trace_cpu_idle_rcuidle(1, smp_processor_id());
305305
306306 omap_sram_idle();
307307
308− trace_cpu_idle(PWR_EVENT_EXIT, smp_processor_id());
308+ trace_cpu_idle_rcuidle(PWR_EVENT_EXIT, smp_processor_id());
309309 }
310310
311311 #ifdef CONFIG_SUSPEND
arch/arm/mach-orion5x/include/mach/entry-macro.S+1−1
@@ -21,5 +21,5 @@ · 20 unmodified lines
2121 @ find cause bits that are unmasked
2222 ands \irqstat, \irqstat, \tmp @ clear Z flag if any
2323 clzne \irqnr, \irqstat @ calc irqnr
24− rsbne \irqnr, \irqnr, #31
24+ rsbne \irqnr, \irqnr, #32
2525 .endm
arch/arm/mach-pxa/ezx.c+5−0
@@ -889,6 +889,7 @@ static void __init e680_init(void) · 888 unmodified lines
889889
890890 pxa_set_keypad_info(&e680_keypad_platform_data);
891891
892+ pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup));
892893 platform_add_devices(ARRAY_AND_SIZE(ezx_devices));
893894 platform_add_devices(ARRAY_AND_SIZE(e680_devices));
894895 }
@@ -956,6 +957,7 @@ static void __init a1200_init(void) · 61 unmodified lines
956957
957958 pxa_set_keypad_info(&a1200_keypad_platform_data);
958959
960+ pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup));
959961 platform_add_devices(ARRAY_AND_SIZE(ezx_devices));
960962 platform_add_devices(ARRAY_AND_SIZE(a1200_devices));
961963 }
@@ -1148,6 +1150,7 @@ static void __init a910_init(void) · 186 unmodified lines
11481150 platform_device_register(&a910_camera);
11491151 }
11501152
1153+ pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup));
11511154 platform_add_devices(ARRAY_AND_SIZE(ezx_devices));
11521155 platform_add_devices(ARRAY_AND_SIZE(a910_devices));
11531156 }
@@ -1215,6 +1218,7 @@ static void __init e6_init(void) · 61 unmodified lines
12151218
12161219 pxa_set_keypad_info(&e6_keypad_platform_data);
12171220
1221+ pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup));
12181222 platform_add_devices(ARRAY_AND_SIZE(ezx_devices));
12191223 platform_add_devices(ARRAY_AND_SIZE(e6_devices));
12201224 }
@@ -1256,6 +1260,7 @@ static void __init e2_init(void) · 35 unmodified lines
12561260
12571261 pxa_set_keypad_info(&e2_keypad_platform_data);
12581262
1263+ pwm_add_table(ezx_pwm_lookup, ARRAY_SIZE(ezx_pwm_lookup));
12591264 platform_add_devices(ARRAY_AND_SIZE(ezx_devices));
12601265 platform_add_devices(ARRAY_AND_SIZE(e2_devices));
12611266 }
arch/arm/mach-pxa/palm27x.c+1−1
@@ -344,7 +344,7 @@ void __init palm27x_pwm_init(int bl, int lcd) · 343 unmodified lines
344344 {
345345 palm_bl_power = bl;
346346 palm_lcd_power = lcd;
347− pwm_add_lookup(palm27x_pwm_lookup, ARRAY_SIZE(palm27x_pwm_lookup));
347+ pwm_add_table(palm27x_pwm_lookup, ARRAY_SIZE(palm27x_pwm_lookup));
348348 platform_device_register(&palm27x_backlight);
349349 }
350350 #endif
arch/arm/mach-pxa/palmtc.c+1−1
@@ -169,7 +169,7 @@ static inline void palmtc_keys_init(void) {} · 168 unmodified lines
169169 #if defined(CONFIG_BACKLIGHT_PWM) || defined(CONFIG_BACKLIGHT_PWM_MODULE)
170170 static struct pwm_lookup palmtc_pwm_lookup[] = {
171171 PWM_LOOKUP("pxa25x-pwm.1", 0, "pwm-backlight.0", NULL, PALMTC_PERIOD_NS,
172− PWM_PERIOD_NORMAL),
172+ PWM_POLARITY_NORMAL),
173173 };
174174
175175 static struct platform_pwm_backlight_data palmtc_backlight_data = {
arch/arm/mach-s3c24xx/pll-s3c2440-12000000.c+1−1
@@ -20,7 +20,7 @@ · 19 unmodified lines
2020 #include <plat/cpu.h>
2121 #include <plat/cpu-freq-core.h>
2222
23−static struct cpufreq_frequency_table s3c2440_plls_12[] __initdata = {
23+static struct cpufreq_frequency_table s3c2440_plls_12[] = {
2424 { .frequency = 75000000, .driver_data = PLLVAL(0x75, 3, 3), }, /* FVco 600.000000 */
2525 { .frequency = 80000000, .driver_data = PLLVAL(0x98, 4, 3), }, /* FVco 640.000000 */
2626 { .frequency = 90000000, .driver_data = PLLVAL(0x70, 2, 3), }, /* FVco 720.000000 */
arch/arm/mach-s3c24xx/pll-s3c2440-16934400.c+1−1
@@ -20,7 +20,7 @@ · 19 unmodified lines
2020 #include <plat/cpu.h>
2121 #include <plat/cpu-freq-core.h>
2222
23−static struct cpufreq_frequency_table s3c2440_plls_169344[] __initdata = {
23+static struct cpufreq_frequency_table s3c2440_plls_169344[] = {
2424 { .frequency = 78019200, .driver_data = PLLVAL(121, 5, 3), }, /* FVco 624.153600 */
2525 { .frequency = 84067200, .driver_data = PLLVAL(131, 5, 3), }, /* FVco 672.537600 */
2626 { .frequency = 90115200, .driver_data = PLLVAL(141, 5, 3), }, /* FVco 720.921600 */
arch/arm/mach-shmobile/setup-r8a7793.c+1−1
@@ -19,7 +19,7 @@ · 18 unmodified lines
1919 #include "common.h"
2020 #include "rcar-gen2.h"
2121
22−static const char *r8a7793_boards_compat_dt[] __initconst = {
22+static const char * const r8a7793_boards_compat_dt[] __initconst = {
2323 "renesas,r8a7793",
2424 NULL,
2525 };
arch/arm/mach-zx/Kconfig+1−1
@@ -13,7 +13,7 @@ config SOC_ZX296702 · 12 unmodified lines
1313 select ARM_GLOBAL_TIMER
1414 select HAVE_ARM_SCU if SMP
1515 select HAVE_ARM_TWD if SMP
16− select PM_GENERIC_DOMAINS
16+ select PM_GENERIC_DOMAINS if PM
1717 help
1818 Support for ZTE ZX296702 SoC which is a dual core CortexA9MP
1919 endif
arch/arm64/Kconfig+1−1
@@ -49,7 +49,7 @@ config ARM64 · 48 unmodified lines
4949 select HAVE_ARCH_AUDITSYSCALL
5050 select HAVE_ARCH_BITREVERSE
5151 select HAVE_ARCH_JUMP_LABEL
52− select HAVE_ARCH_KASAN if SPARSEMEM_VMEMMAP
52+ select HAVE_ARCH_KASAN if SPARSEMEM_VMEMMAP && !(ARM64_16K_PAGES && ARM64_VA_BITS_48)
5353 select HAVE_ARCH_KGDB
5454 select HAVE_ARCH_SECCOMP_FILTER
5555 select HAVE_ARCH_TRACEHOOK
arch/arm64/boot/dts/freescale/fsl-ls2080a.dtsi+5−0
@@ -269,6 +269,7 @@ · 268 unmodified lines
269269 clock-frequency = <0>; /* Updated by bootloader */
270270 voltage-ranges = <1800 1800 3300 3300>;
271271 sdhci,auto-cmd12;
272+ little-endian;
272273 bus-width = <4>;
273274 };
274275
@@ -277,6 +278,7 @@ · 2 unmodified lines
277278 reg = <0x0 0x2300000 0x0 0x10000>;
278279 interrupts = <0 36 0x4>; /* Level high type */
279280 gpio-controller;
281+ little-endian;
280282 #gpio-cells = <2>;
281283 interrupt-controller;
282284 #interrupt-cells = <2>;
@@ -287,6 +289,7 @@ · 4 unmodified lines
287289 reg = <0x0 0x2310000 0x0 0x10000>;
288290 interrupts = <0 36 0x4>; /* Level high type */
289291 gpio-controller;
292+ little-endian;
290293 #gpio-cells = <2>;
291294 interrupt-controller;
292295 #interrupt-cells = <2>;
@@ -297,6 +300,7 @@ · 4 unmodified lines
297300 reg = <0x0 0x2320000 0x0 0x10000>;
298301 interrupts = <0 37 0x4>; /* Level high type */
299302 gpio-controller;
303+ little-endian;
300304 #gpio-cells = <2>;
301305 interrupt-controller;
302306 #interrupt-cells = <2>;
@@ -307,6 +311,7 @@ · 4 unmodified lines
307311 reg = <0x0 0x2330000 0x0 0x10000>;
308312 interrupts = <0 37 0x4>; /* Level high type */
309313 gpio-controller;
314+ little-endian;
310315 #gpio-cells = <2>;
311316 interrupt-controller;
312317 #interrupt-cells = <2>;
arch/arm64/include/asm/arch_gicv3.h+1−0
@@ -77,6 +77,7 @@ · 76 unmodified lines
7777 #ifndef __ASSEMBLY__
7878
7979 #include <linux/stringify.h>
80+#include <asm/barrier.h>
8081
8182 /*
8283 * Low-level accessors
arch/arm64/include/asm/cpufeature.h+20−2
@@ -47,8 +47,12 @@ enum ftr_type { · 46 unmodified lines
4747 #define FTR_STRICT true /* SANITY check strict matching required */
4848 #define FTR_NONSTRICT false /* SANITY check ignored */
4949
50+#define FTR_SIGNED true /* Value should be treated as signed */
51+#define FTR_UNSIGNED false /* Value should be treated as unsigned */
52+
5053 struct arm64_ftr_bits {
51− bool strict; /* CPU Sanity check: strict matching required ? */
54+ bool sign; /* Value is signed ? */
55+ bool strict; /* CPU Sanity check: strict matching required ? */
5256 enum ftr_type type;
5357 u8 shift;
5458 u8 width;
@@ -124,6 +128,18 @@ cpuid_feature_extract_field(u64 features, int field) · 69 unmodified lines
124128 return cpuid_feature_extract_field_width(features, field, 4);
125129 }
126130
131+static inline unsigned int __attribute_const__
132+cpuid_feature_extract_unsigned_field_width(u64 features, int field, int width)
133+{
134+ return (u64)(features << (64 - width - field)) >> (64 - width);
135+}
136+
137+static inline unsigned int __attribute_const__
138+cpuid_feature_extract_unsigned_field(u64 features, int field)
139+{
140+ return cpuid_feature_extract_unsigned_field_width(features, field, 4);
141+}
142+
127143 static inline u64 arm64_ftr_mask(struct arm64_ftr_bits *ftrp)
128144 {
129145 return (u64)GENMASK(ftrp->shift + ftrp->width - 1, ftrp->shift);
@@ -131,7 +147,9 @@ static inline u64 arm64_ftr_mask(struct arm64_ftr_bits *ftrp) · 1 unmodified line
131147
132148 static inline s64 arm64_ftr_value(struct arm64_ftr_bits *ftrp, u64 val)
133149 {
134− return cpuid_feature_extract_field_width(val, ftrp->shift, ftrp->width);
150+ return ftrp->sign ?
151+ cpuid_feature_extract_field_width(val, ftrp->shift, ftrp->width) :
152+ cpuid_feature_extract_unsigned_field_width(val, ftrp->shift, ftrp->width);
135153 }
136154
137155 static inline bool id_aa64mmfr0_mixed_endian_el0(u64 mmfr0)
arch/arm64/include/asm/hw_breakpoint.h+4−2
@@ -138,16 +138,18 @@ extern struct pmu perf_ops_bp; · 137 unmodified lines
138138 /* Determine number of BRP registers available. */
139139 static inline int get_num_brps(void)
140140 {
141+ u64 dfr0 = read_system_reg(SYS_ID_AA64DFR0_EL1);
141142 return 1 +
142− cpuid_feature_extract_field(read_system_reg(SYS_ID_AA64DFR0_EL1),
143+ cpuid_feature_extract_unsigned_field(dfr0,
143144 ID_AA64DFR0_BRPS_SHIFT);
144145 }
145146
146147 /* Determine number of WRP registers available. */
147148 static inline int get_num_wrps(void)
148149 {
150+ u64 dfr0 = read_system_reg(SYS_ID_AA64DFR0_EL1);
149151 return 1 +
150− cpuid_feature_extract_field(read_system_reg(SYS_ID_AA64DFR0_EL1),
152+ cpuid_feature_extract_unsigned_field(dfr0,
151153 ID_AA64DFR0_WRPS_SHIFT);
152154 }
153155
arch/arm64/include/asm/irq.h+5−0
@@ -7,4 +7,9 @@ struct pt_regs; · 6 unmodified lines
77
88 extern void set_handle_irq(void (*handle_irq)(struct pt_regs *));
99
10+static inline int nr_legacy_irqs(void)
11+{
12+ return 0;
13+}
14+
1015 #endif
arch/arm64/include/asm/kvm_arm.h+2−1
@@ -125,6 +125,7 @@ · 124 unmodified lines
125125 #define VTCR_EL2_SL0_LVL1 (1 << 6)
126126 #define VTCR_EL2_T0SZ_MASK 0x3f
127127 #define VTCR_EL2_T0SZ_40B 24
128+#define VTCR_EL2_VS 19
128129
129130 /*
130131 * We configure the Stage-2 page tables to always restrict the IPA space to be
@@ -169,7 +170,7 @@ · 38 unmodified lines
169170 #define VTTBR_BADDR_SHIFT (VTTBR_X - 1)
170171 #define VTTBR_BADDR_MASK (((UL(1) << (PHYS_MASK_SHIFT - VTTBR_X)) - 1) << VTTBR_BADDR_SHIFT)
171172 #define VTTBR_VMID_SHIFT (UL(48))
172−#define VTTBR_VMID_MASK (UL(0xFF) << VTTBR_VMID_SHIFT)
173+#define VTTBR_VMID_MASK(size) (_AT(u64, (1 << size) - 1) << VTTBR_VMID_SHIFT)
173174
174175 /* Hyp System Trap Register */
175176 #define HSTR_EL2_T(x) (1 << x)
arch/arm64/include/asm/kvm_asm.h+0−76
@@ -20,82 +20,6 @@ · 19 unmodified lines
2020
2121 #include <asm/virt.h>
2222
23−/*
24− * 0 is reserved as an invalid value.
25− * Order *must* be kept in sync with the hyp switch code.
26− */
27−#define MPIDR_EL1 1 /* MultiProcessor Affinity Register */
28−#define CSSELR_EL1 2 /* Cache Size Selection Register */
29−#define SCTLR_EL1 3 /* System Control Register */
30−#define ACTLR_EL1 4 /* Auxiliary Control Register */
31−#define CPACR_EL1 5 /* Coprocessor Access Control */
32−#define TTBR0_EL1 6 /* Translation Table Base Register 0 */
33−#define TTBR1_EL1 7 /* Translation Table Base Register 1 */
34−#define TCR_EL1 8 /* Translation Control Register */
35−#define ESR_EL1 9 /* Exception Syndrome Register */
36−#define AFSR0_EL1 10 /* Auxilary Fault Status Register 0 */
37−#define AFSR1_EL1 11 /* Auxilary Fault Status Register 1 */
38−#define FAR_EL1 12 /* Fault Address Register */
39−#define MAIR_EL1 13 /* Memory Attribute Indirection Register */
40−#define VBAR_EL1 14 /* Vector Base Address Register */
41−#define CONTEXTIDR_EL1 15 /* Context ID Register */
42−#define TPIDR_EL0 16 /* Thread ID, User R/W */
43−#define TPIDRRO_EL0 17 /* Thread ID, User R/O */
44−#define TPIDR_EL1 18 /* Thread ID, Privileged */
45−#define AMAIR_EL1 19 /* Aux Memory Attribute Indirection Register */
46−#define CNTKCTL_EL1 20 /* Timer Control Register (EL1) */
47−#define PAR_EL1 21 /* Physical Address Register */
48−#define MDSCR_EL1 22 /* Monitor Debug System Control Register */
49−#define MDCCINT_EL1 23 /* Monitor Debug Comms Channel Interrupt Enable Reg */
50−
51−/* 32bit specific registers. Keep them at the end of the range */
52−#define DACR32_EL2 24 /* Domain Access Control Register */
53−#define IFSR32_EL2 25 /* Instruction Fault Status Register */
54−#define FPEXC32_EL2 26 /* Floating-Point Exception Control Register */
55−#define DBGVCR32_EL2 27 /* Debug Vector Catch Register */
56−#define NR_SYS_REGS 28
57−
58−/* 32bit mapping */
59−#define c0_MPIDR (MPIDR_EL1 * 2) /* MultiProcessor ID Register */
60−#define c0_CSSELR (CSSELR_EL1 * 2)/* Cache Size Selection Register */
61−#define c1_SCTLR (SCTLR_EL1 * 2) /* System Control Register */
62−#define c1_ACTLR (ACTLR_EL1 * 2) /* Auxiliary Control Register */
63−#define c1_CPACR (CPACR_EL1 * 2) /* Coprocessor Access Control */
64−#define c2_TTBR0 (TTBR0_EL1 * 2) /* Translation Table Base Register 0 */
65−#define c2_TTBR0_high (c2_TTBR0 + 1) /* TTBR0 top 32 bits */
66−#define c2_TTBR1 (TTBR1_EL1 * 2) /* Translation Table Base Register 1 */
67−#define c2_TTBR1_high (c2_TTBR1 + 1) /* TTBR1 top 32 bits */
68−#define c2_TTBCR (TCR_EL1 * 2) /* Translation Table Base Control R. */
69−#define c3_DACR (DACR32_EL2 * 2)/* Domain Access Control Register */
70−#define c5_DFSR (ESR_EL1 * 2) /* Data Fault Status Register */
71−#define c5_IFSR (IFSR32_EL2 * 2)/* Instruction Fault Status Register */
72−#define c5_ADFSR (AFSR0_EL1 * 2) /* Auxiliary Data Fault Status R */
73−#define c5_AIFSR (AFSR1_EL1 * 2) /* Auxiliary Instr Fault Status R */
74−#define c6_DFAR (FAR_EL1 * 2) /* Data Fault Address Register */
75−#define c6_IFAR (c6_DFAR + 1) /* Instruction Fault Address Register */
76−#define c7_PAR (PAR_EL1 * 2) /* Physical Address Register */
77−#define c7_PAR_high (c7_PAR + 1) /* PAR top 32 bits */
78−#define c10_PRRR (MAIR_EL1 * 2) /* Primary Region Remap Register */
79−#define c10_NMRR (c10_PRRR + 1) /* Normal Memory Remap Register */
80−#define c12_VBAR (VBAR_EL1 * 2) /* Vector Base Address Register */
81−#define c13_CID (CONTEXTIDR_EL1 * 2) /* Context ID Register */
82−#define c13_TID_URW (TPIDR_EL0 * 2) /* Thread ID, User R/W */
83−#define c13_TID_URO (TPIDRRO_EL0 * 2)/* Thread ID, User R/O */
84−#define c13_TID_PRIV (TPIDR_EL1 * 2) /* Thread ID, Privileged */
85−#define c10_AMAIR0 (AMAIR_EL1 * 2) /* Aux Memory Attr Indirection Reg */
86−#define c10_AMAIR1 (c10_AMAIR0 + 1)/* Aux Memory Attr Indirection Reg */
87−#define c14_CNTKCTL (CNTKCTL_EL1 * 2) /* Timer Control Register (PL1) */
88−
89−#define cp14_DBGDSCRext (MDSCR_EL1 * 2)
90−#define cp14_DBGBCR0 (DBGBCR0_EL1 * 2)
91−#define cp14_DBGBVR0 (DBGBVR0_EL1 * 2)
92−#define cp14_DBGBXVR0 (cp14_DBGBVR0 + 1)
93−#define cp14_DBGWCR0 (DBGWCR0_EL1 * 2)
94−#define cp14_DBGWVR0 (DBGWVR0_EL1 * 2)
95−#define cp14_DBGDCCINT (MDCCINT_EL1 * 2)
96−
97−#define NR_COPRO_REGS (NR_SYS_REGS * 2)
98−
9923 #define ARM_EXCEPTION_IRQ 0
10024 #define ARM_EXCEPTION_TRAP 1
10125
arch/arm64/include/asm/kvm_emulate.h+13−6
@@ -26,7 +26,6 @@ · 25 unmodified lines
2626
2727 #include <asm/esr.h>
2828 #include <asm/kvm_arm.h>
29−#include <asm/kvm_asm.h>
3029 #include <asm/kvm_mmio.h>
3130 #include <asm/ptrace.h>
3231 #include <asm/cputype.h>
@@ -100,13 +99,21 @@ static inline void vcpu_set_thumb(struct kvm_vcpu *vcpu) · 67 unmodified lines
10099 }
101100
102101 /*
103− * vcpu_reg should always be passed a register number coming from a
104− * read of ESR_EL2. Otherwise, it may give the wrong result on AArch32
105− * with banked registers.
102+ * vcpu_get_reg and vcpu_set_reg should always be passed a register number
103+ * coming from a read of ESR_EL2. Otherwise, it may give the wrong result on
104+ * AArch32 with banked registers.
106105 */
107−static inline unsigned long *vcpu_reg(const struct kvm_vcpu *vcpu, u8 reg_num)
106+static inline unsigned long vcpu_get_reg(const struct kvm_vcpu *vcpu,
107+ u8 reg_num)
108108 {
109− return (unsigned long *)&vcpu_gp_regs(vcpu)->regs.regs[reg_num];
109+ return (reg_num == 31) ? 0 : vcpu_gp_regs(vcpu)->regs.regs[reg_num];
110+}
111+
112+static inline void vcpu_set_reg(struct kvm_vcpu *vcpu, u8 reg_num,
113+ unsigned long val)
114+{
115+ if (reg_num != 31)
116+ vcpu_gp_regs(vcpu)->regs.regs[reg_num] = val;
110117 }
111118
112119 /* Get vcpu SPSR for current mode */
arch/arm64/include/asm/kvm_host.h+86−1
@@ -25,7 +25,6 @@ · 24 unmodified lines
2525 #include <linux/types.h>
2626 #include <linux/kvm_types.h>
2727 #include <asm/kvm.h>
28−#include <asm/kvm_asm.h>
2928 #include <asm/kvm_mmio.h>
3029
3130 #define __KVM_HAVE_ARCH_INTC_INITIALIZED
@@ -85,6 +84,86 @@ struct kvm_vcpu_fault_info { · 53 unmodified lines
8584 u64 hpfar_el2; /* Hyp IPA Fault Address Register */
8685 };
8786
87+/*
88+ * 0 is reserved as an invalid value.
89+ * Order should be kept in sync with the save/restore code.
90+ */
91+enum vcpu_sysreg {
92+ __INVALID_SYSREG__,
93+ MPIDR_EL1, /* MultiProcessor Affinity Register */
94+ CSSELR_EL1, /* Cache Size Selection Register */
95+ SCTLR_EL1, /* System Control Register */
96+ ACTLR_EL1, /* Auxiliary Control Register */
97+ CPACR_EL1, /* Coprocessor Access Control */
98+ TTBR0_EL1, /* Translation Table Base Register 0 */
99+ TTBR1_EL1, /* Translation Table Base Register 1 */
100+ TCR_EL1, /* Translation Control Register */
101+ ESR_EL1, /* Exception Syndrome Register */
102+ AFSR0_EL1, /* Auxilary Fault Status Register 0 */
103+ AFSR1_EL1, /* Auxilary Fault Status Register 1 */
104+ FAR_EL1, /* Fault Address Register */
105+ MAIR_EL1, /* Memory Attribute Indirection Register */
106+ VBAR_EL1, /* Vector Base Address Register */
107+ CONTEXTIDR_EL1, /* Context ID Register */
108+ TPIDR_EL0, /* Thread ID, User R/W */
109+ TPIDRRO_EL0, /* Thread ID, User R/O */
110+ TPIDR_EL1, /* Thread ID, Privileged */
111+ AMAIR_EL1, /* Aux Memory Attribute Indirection Register */
112+ CNTKCTL_EL1, /* Timer Control Register (EL1) */
113+ PAR_EL1, /* Physical Address Register */
114+ MDSCR_EL1, /* Monitor Debug System Control Register */
115+ MDCCINT_EL1, /* Monitor Debug Comms Channel Interrupt Enable Reg */
116+
117+ /* 32bit specific registers. Keep them at the end of the range */
118+ DACR32_EL2, /* Domain Access Control Register */
119+ IFSR32_EL2, /* Instruction Fault Status Register */
120+ FPEXC32_EL2, /* Floating-Point Exception Control Register */
121+ DBGVCR32_EL2, /* Debug Vector Catch Register */
122+
123+ NR_SYS_REGS /* Nothing after this line! */
124+};
125+
126+/* 32bit mapping */
127+#define c0_MPIDR (MPIDR_EL1 * 2) /* MultiProcessor ID Register */
128+#define c0_CSSELR (CSSELR_EL1 * 2)/* Cache Size Selection Register */
129+#define c1_SCTLR (SCTLR_EL1 * 2) /* System Control Register */
130+#define c1_ACTLR (ACTLR_EL1 * 2) /* Auxiliary Control Register */
131+#define c1_CPACR (CPACR_EL1 * 2) /* Coprocessor Access Control */
132+#define c2_TTBR0 (TTBR0_EL1 * 2) /* Translation Table Base Register 0 */
133+#define c2_TTBR0_high (c2_TTBR0 + 1) /* TTBR0 top 32 bits */
134+#define c2_TTBR1 (TTBR1_EL1 * 2) /* Translation Table Base Register 1 */
135+#define c2_TTBR1_high (c2_TTBR1 + 1) /* TTBR1 top 32 bits */
136+#define c2_TTBCR (TCR_EL1 * 2) /* Translation Table Base Control R. */
137+#define c3_DACR (DACR32_EL2 * 2)/* Domain Access Control Register */
138+#define c5_DFSR (ESR_EL1 * 2) /* Data Fault Status Register */
139+#define c5_IFSR (IFSR32_EL2 * 2)/* Instruction Fault Status Register */
140+#define c5_ADFSR (AFSR0_EL1 * 2) /* Auxiliary Data Fault Status R */
141+#define c5_AIFSR (AFSR1_EL1 * 2) /* Auxiliary Instr Fault Status R */
142+#define c6_DFAR (FAR_EL1 * 2) /* Data Fault Address Register */
143+#define c6_IFAR (c6_DFAR + 1) /* Instruction Fault Address Register */
144+#define c7_PAR (PAR_EL1 * 2) /* Physical Address Register */
145+#define c7_PAR_high (c7_PAR + 1) /* PAR top 32 bits */
146+#define c10_PRRR (MAIR_EL1 * 2) /* Primary Region Remap Register */
147+#define c10_NMRR (c10_PRRR + 1) /* Normal Memory Remap Register */
148+#define c12_VBAR (VBAR_EL1 * 2) /* Vector Base Address Register */
149+#define c13_CID (CONTEXTIDR_EL1 * 2) /* Context ID Register */
150+#define c13_TID_URW (TPIDR_EL0 * 2) /* Thread ID, User R/W */
151+#define c13_TID_URO (TPIDRRO_EL0 * 2)/* Thread ID, User R/O */
152+#define c13_TID_PRIV (TPIDR_EL1 * 2) /* Thread ID, Privileged */
153+#define c10_AMAIR0 (AMAIR_EL1 * 2) /* Aux Memory Attr Indirection Reg */
154+#define c10_AMAIR1 (c10_AMAIR0 + 1)/* Aux Memory Attr Indirection Reg */
155+#define c14_CNTKCTL (CNTKCTL_EL1 * 2) /* Timer Control Register (PL1) */
156+
157+#define cp14_DBGDSCRext (MDSCR_EL1 * 2)
158+#define cp14_DBGBCR0 (DBGBCR0_EL1 * 2)
159+#define cp14_DBGBVR0 (DBGBVR0_EL1 * 2)
160+#define cp14_DBGBXVR0 (cp14_DBGBVR0 + 1)
161+#define cp14_DBGWCR0 (DBGWCR0_EL1 * 2)
162+#define cp14_DBGWVR0 (DBGWVR0_EL1 * 2)
163+#define cp14_DBGDCCINT (MDCCINT_EL1 * 2)
164+
165+#define NR_COPRO_REGS (NR_SYS_REGS * 2)
166+
88167 struct kvm_cpu_context {
89168 struct kvm_regs gp_regs;
90169 union {
@@ -197,6 +276,12 @@ struct kvm_vcpu_stat { · 106 unmodified lines
197276 u32 halt_successful_poll;
198277 u32 halt_attempted_poll;
199278 u32 halt_wakeup;
279+ u32 hvc_exit_stat;
280+ u64 wfe_exit_stat;
281+ u64 wfi_exit_stat;
282+ u64 mmio_exit_user;
283+ u64 mmio_exit_kernel;
284+ u64 exits;
200285 };
201286
202287 int kvm_vcpu_preferred_target(struct kvm_vcpu_init *init);
arch/arm64/include/asm/kvm_mmio.h+0−1
@@ -19,7 +19,6 @@ · 18 unmodified lines
1919 #define __ARM64_KVM_MMIO_H__
2020
2121 #include <linux/kvm_host.h>
22−#include <asm/kvm_asm.h>
2322 #include <asm/kvm_arm.h>
2423
2524 /*
arch/arm64/include/asm/kvm_mmu.h+8−1
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020
2121 #include <asm/page.h>
2222 #include <asm/memory.h>
23+#include <asm/cpufeature.h>
2324
2425 /*
2526 * As we only have the TTBR0_EL2 register, we cannot express
@@ -158,7 +159,6 @@ static inline bool kvm_s2pmd_readonly(pmd_t *pmd) · 132 unmodified lines
158159 #define PTRS_PER_S2_PGD_SHIFT (KVM_PHYS_SHIFT - PGDIR_SHIFT)
159160 #endif
160161 #define PTRS_PER_S2_PGD (1 << PTRS_PER_S2_PGD_SHIFT)
161−#define S2_PGD_ORDER get_order(PTRS_PER_S2_PGD * sizeof(pgd_t))
162162
163163 #define kvm_pgd_index(addr) (((addr) >> PGDIR_SHIFT) & (PTRS_PER_S2_PGD - 1))
164164
@@ -302,5 +302,12 @@ static inline void __kvm_extend_hypmap(pgd_t *boot_hyp_pgd, · 137 unmodified lines
302302 merged_hyp_pgd[idmap_idx] = __pgd(__pa(boot_hyp_pgd) | PMD_TYPE_TABLE);
303303 }
304304
305+static inline unsigned int kvm_get_vmid_bits(void)
306+{
307+ int reg = read_system_reg(SYS_ID_AA64MMFR1_EL1);
308+
309+ return (cpuid_feature_extract_field(reg, ID_AA64MMFR1_VMIDBITS_SHIFT) == 2) ? 16 : 8;
310+}
311+
305312 #endif /* __ASSEMBLY__ */
306313 #endif /* __ARM64_KVM_MMU_H__ */
arch/arm64/include/asm/pgtable.h+8−4
@@ -276,10 +276,14 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, · 275 unmodified lines
276276 * hardware updates of the pte (ptep_set_access_flags safely changes
277277 * valid ptes without going through an invalid entry).
278278 */
279− if (IS_ENABLED(CONFIG_DEBUG_VM) && IS_ENABLED(CONFIG_ARM64_HW_AFDBM) &&
280− pte_valid(*ptep)) {
281− BUG_ON(!pte_young(pte));
282− BUG_ON(pte_write(*ptep) && !pte_dirty(pte));
279+ if (IS_ENABLED(CONFIG_ARM64_HW_AFDBM) &&
280+ pte_valid(*ptep) && pte_valid(pte)) {
281+ VM_WARN_ONCE(!pte_young(pte),
282+ "%s: racy access flag clearing: 0x%016llx -> 0x%016llx",
283+ __func__, pte_val(*ptep), pte_val(pte));
284+ VM_WARN_ONCE(pte_write(*ptep) && !pte_dirty(pte),
285+ "%s: racy dirty state clearing: 0x%016llx -> 0x%016llx",
286+ __func__, pte_val(*ptep), pte_val(pte));
283287 }
284288
285289 set_pte(ptep, pte);
arch/arm64/include/asm/sysreg.h+21−0
@@ -20,6 +20,8 @@ · 19 unmodified lines
2020 #ifndef __ASM_SYSREG_H
2121 #define __ASM_SYSREG_H
2222
23+#include <linux/stringify.h>
24+
2325 #include <asm/opcodes.h>
2426
2527 /*
@@ -208,6 +210,8 @@ · 182 unmodified lines
208210
209211 #else
210212
213+#include <linux/types.h>
214+
211215 asm(
212216 " .irp num,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30\n"
213217 " .equ __reg_num_x\\num, \\num\n"
@@ -232,6 +236,23 @@ static inline void config_sctlr_el1(u32 clear, u32 set) · 18 unmodified lines
232236 val |= set;
233237 asm volatile("msr sctlr_el1, %0" : : "r" (val));
234238 }
239+
240+/*
241+ * Unlike read_cpuid, calls to read_sysreg are never expected to be
242+ * optimized away or replaced with synthetic values.
243+ */
244+#define read_sysreg(r) ({ \
245+ u64 __val; \
246+ asm volatile("mrs %0, " __stringify(r) : "=r" (__val)); \
247+ __val; \
248+})
249+
250+#define write_sysreg(v, r) do { \
251+ u64 __val = (u64)v; \
252+ asm volatile("msr " __stringify(r) ", %0" \
253+ : : "r" (__val)); \
254+} while (0)
255+
235256 #endif
236257
237258 #endif /* __ASM_SYSREG_H */
arch/arm64/kernel/asm-offsets.c+1−39
@@ -108,49 +108,11 @@ int main(void) · 107 unmodified lines
108108 DEFINE(CPU_GP_REGS, offsetof(struct kvm_cpu_context, gp_regs));
109109 DEFINE(CPU_USER_PT_REGS, offsetof(struct kvm_regs, regs));
110110 DEFINE(CPU_FP_REGS, offsetof(struct kvm_regs, fp_regs));
111− DEFINE(CPU_SP_EL1, offsetof(struct kvm_regs, sp_el1));
112− DEFINE(CPU_ELR_EL1, offsetof(struct kvm_regs, elr_el1));
113− DEFINE(CPU_SPSR, offsetof(struct kvm_regs, spsr));
114− DEFINE(CPU_SYSREGS, offsetof(struct kvm_cpu_context, sys_regs));
111+ DEFINE(VCPU_FPEXC32_EL2, offsetof(struct kvm_vcpu, arch.ctxt.sys_regs[FPEXC32_EL2]));
115112 DEFINE(VCPU_ESR_EL2, offsetof(struct kvm_vcpu, arch.fault.esr_el2));
116113 DEFINE(VCPU_FAR_EL2, offsetof(struct kvm_vcpu, arch.fault.far_el2));
117114 DEFINE(VCPU_HPFAR_EL2, offsetof(struct kvm_vcpu, arch.fault.hpfar_el2));
118− DEFINE(VCPU_DEBUG_FLAGS, offsetof(struct kvm_vcpu, arch.debug_flags));
119− DEFINE(VCPU_DEBUG_PTR, offsetof(struct kvm_vcpu, arch.debug_ptr));
120− DEFINE(DEBUG_BCR, offsetof(struct kvm_guest_debug_arch, dbg_bcr));
121− DEFINE(DEBUG_BVR, offsetof(struct kvm_guest_debug_arch, dbg_bvr));
122− DEFINE(DEBUG_WCR, offsetof(struct kvm_guest_debug_arch, dbg_wcr));
123− DEFINE(DEBUG_WVR, offsetof(struct kvm_guest_debug_arch, dbg_wvr));
124− DEFINE(VCPU_HCR_EL2, offsetof(struct kvm_vcpu, arch.hcr_el2));
125− DEFINE(VCPU_MDCR_EL2, offsetof(struct kvm_vcpu, arch.mdcr_el2));
126− DEFINE(VCPU_IRQ_LINES, offsetof(struct kvm_vcpu, arch.irq_lines));
127115 DEFINE(VCPU_HOST_CONTEXT, offsetof(struct kvm_vcpu, arch.host_cpu_context));
128− DEFINE(VCPU_HOST_DEBUG_STATE, offsetof(struct kvm_vcpu, arch.host_debug_state));
129− DEFINE(VCPU_TIMER_CNTV_CTL, offsetof(struct kvm_vcpu, arch.timer_cpu.cntv_ctl));
130− DEFINE(VCPU_TIMER_CNTV_CVAL, offsetof(struct kvm_vcpu, arch.timer_cpu.cntv_cval));
131− DEFINE(KVM_TIMER_CNTVOFF, offsetof(struct kvm, arch.timer.cntvoff));
132− DEFINE(KVM_TIMER_ENABLED, offsetof(struct kvm, arch.timer.enabled));
133− DEFINE(VCPU_KVM, offsetof(struct kvm_vcpu, kvm));
134− DEFINE(VCPU_VGIC_CPU, offsetof(struct kvm_vcpu, arch.vgic_cpu));
135− DEFINE(VGIC_V2_CPU_HCR, offsetof(struct vgic_cpu, vgic_v2.vgic_hcr));
136− DEFINE(VGIC_V2_CPU_VMCR, offsetof(struct vgic_cpu, vgic_v2.vgic_vmcr));
137− DEFINE(VGIC_V2_CPU_MISR, offsetof(struct vgic_cpu, vgic_v2.vgic_misr));
138− DEFINE(VGIC_V2_CPU_EISR, offsetof(struct vgic_cpu, vgic_v2.vgic_eisr));
139− DEFINE(VGIC_V2_CPU_ELRSR, offsetof(struct vgic_cpu, vgic_v2.vgic_elrsr));
140− DEFINE(VGIC_V2_CPU_APR, offsetof(struct vgic_cpu, vgic_v2.vgic_apr));
141− DEFINE(VGIC_V2_CPU_LR, offsetof(struct vgic_cpu, vgic_v2.vgic_lr));
142− DEFINE(VGIC_V3_CPU_SRE, offsetof(struct vgic_cpu, vgic_v3.vgic_sre));
143− DEFINE(VGIC_V3_CPU_HCR, offsetof(struct vgic_cpu, vgic_v3.vgic_hcr));
144− DEFINE(VGIC_V3_CPU_VMCR, offsetof(struct vgic_cpu, vgic_v3.vgic_vmcr));
145− DEFINE(VGIC_V3_CPU_MISR, offsetof(struct vgic_cpu, vgic_v3.vgic_misr));
146− DEFINE(VGIC_V3_CPU_EISR, offsetof(struct vgic_cpu, vgic_v3.vgic_eisr));
147− DEFINE(VGIC_V3_CPU_ELRSR, offsetof(struct vgic_cpu, vgic_v3.vgic_elrsr));
148− DEFINE(VGIC_V3_CPU_AP0R, offsetof(struct vgic_cpu, vgic_v3.vgic_ap0r));
149− DEFINE(VGIC_V3_CPU_AP1R, offsetof(struct vgic_cpu, vgic_v3.vgic_ap1r));
150− DEFINE(VGIC_V3_CPU_LR, offsetof(struct vgic_cpu, vgic_v3.vgic_lr));
151− DEFINE(VGIC_CPU_NR_LR, offsetof(struct vgic_cpu, nr_lr));
152− DEFINE(KVM_VTTBR, offsetof(struct kvm, arch.vttbr));
153− DEFINE(KVM_VGIC_VCTRL, offsetof(struct kvm, arch.vgic.vctrl_base));
154116 #endif
155117 #ifdef CONFIG_CPU_PM
156118 DEFINE(CPU_SUSPEND_SZ, sizeof(struct cpu_suspend_ctx));
arch/arm64/kernel/cpufeature.c+23−14
@@ -44,8 +44,9 @@ unsigned int compat_elf_hwcap2 __read_mostly; · 43 unmodified lines
4444
4545 DECLARE_BITMAP(cpu_hwcaps, ARM64_NCAPS);
4646
47−#define ARM64_FTR_BITS(STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) \
47+#define __ARM64_FTR_BITS(SIGNED, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) \
4848 { \
49+ .sign = SIGNED, \
4950 .strict = STRICT, \
5051 .type = TYPE, \
5152 .shift = SHIFT, \
@@ -53,6 +54,14 @@ DECLARE_BITMAP(cpu_hwcaps, ARM64_NCAPS); · 1 unmodified line
5354 .safe_val = SAFE_VAL, \
5455 }
5556
57+/* Define a feature with signed values */
58+#define ARM64_FTR_BITS(STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) \
59+ __ARM64_FTR_BITS(FTR_SIGNED, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL)
60+
61+/* Define a feature with unsigned value */
62+#define U_ARM64_FTR_BITS(STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL) \
63+ __ARM64_FTR_BITS(FTR_UNSIGNED, STRICT, TYPE, SHIFT, WIDTH, SAFE_VAL)
64+
5665 #define ARM64_FTR_END \
5766 { \
5867 .width = 0, \
@@ -99,7 +108,7 @@ static struct arm64_ftr_bits ftr_id_aa64mmfr0[] = { · 40 unmodified lines
99108 * Differing PARange is fine as long as all peripherals and memory are mapped
100109 * within the minimum PARange of all CPUs
101110 */
102− ARM64_FTR_BITS(FTR_NONSTRICT, FTR_LOWER_SAFE, ID_AA64MMFR0_PARANGE_SHIFT, 4, 0),
111+ U_ARM64_FTR_BITS(FTR_NONSTRICT, FTR_LOWER_SAFE, ID_AA64MMFR0_PARANGE_SHIFT, 4, 0),
103112 ARM64_FTR_END,
104113 };
105114
@@ -115,18 +124,18 @@ static struct arm64_ftr_bits ftr_id_aa64mmfr1[] = { · 9 unmodified lines
115124 };
116125
117126 static struct arm64_ftr_bits ftr_ctr[] = {
118− ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 31, 1, 1), /* RAO */
127+ U_ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 31, 1, 1), /* RAO */
119128 ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 28, 3, 0),
120− ARM64_FTR_BITS(FTR_STRICT, FTR_HIGHER_SAFE, 24, 4, 0), /* CWG */
121− ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 20, 4, 0), /* ERG */
122− ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 16, 4, 1), /* DminLine */
129+ U_ARM64_FTR_BITS(FTR_STRICT, FTR_HIGHER_SAFE, 24, 4, 0), /* CWG */
130+ U_ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 20, 4, 0), /* ERG */
131+ U_ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 16, 4, 1), /* DminLine */
123132 /*
124133 * Linux can handle differing I-cache policies. Userspace JITs will
125134 * make use of *minLine
126135 */
127− ARM64_FTR_BITS(FTR_NONSTRICT, FTR_EXACT, 14, 2, 0), /* L1Ip */
136+ U_ARM64_FTR_BITS(FTR_NONSTRICT, FTR_EXACT, 14, 2, 0), /* L1Ip */
128137 ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 4, 10, 0), /* RAZ */
129− ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 0, 4, 0), /* IminLine */
138+ U_ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, 0, 4, 0), /* IminLine */
130139 ARM64_FTR_END,
131140 };
132141
@@ -144,12 +153,12 @@ static struct arm64_ftr_bits ftr_id_mmfr0[] = { · 11 unmodified lines
144153
145154 static struct arm64_ftr_bits ftr_id_aa64dfr0[] = {
146155 ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, 32, 32, 0),
147− ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, ID_AA64DFR0_CTX_CMPS_SHIFT, 4, 0),
148− ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, ID_AA64DFR0_WRPS_SHIFT, 4, 0),
149− ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, ID_AA64DFR0_BRPS_SHIFT, 4, 0),
150− ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64DFR0_PMUVER_SHIFT, 4, 0),
151− ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64DFR0_TRACEVER_SHIFT, 4, 0),
152− ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64DFR0_DEBUGVER_SHIFT, 4, 0x6),
156+ U_ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, ID_AA64DFR0_CTX_CMPS_SHIFT, 4, 0),
157+ U_ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, ID_AA64DFR0_WRPS_SHIFT, 4, 0),
158+ U_ARM64_FTR_BITS(FTR_STRICT, FTR_LOWER_SAFE, ID_AA64DFR0_BRPS_SHIFT, 4, 0),
159+ U_ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64DFR0_PMUVER_SHIFT, 4, 0),
160+ U_ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64DFR0_TRACEVER_SHIFT, 4, 0),
161+ U_ARM64_FTR_BITS(FTR_STRICT, FTR_EXACT, ID_AA64DFR0_DEBUGVER_SHIFT, 4, 0x6),
153162 ARM64_FTR_END,
154163 };
155164
arch/arm64/kernel/efi.c+20−13
@@ -127,7 +127,11 @@ static int __init uefi_init(void) · 126 unmodified lines
127127 table_size = sizeof(efi_config_table_64_t) * efi.systab->nr_tables;
128128 config_tables = early_memremap(efi_to_phys(efi.systab->tables),
129129 table_size);
130−
130+ if (config_tables == NULL) {
131+ pr_warn("Unable to map EFI config table array.\n");
132+ retval = -ENOMEM;
133+ goto out;
134+ }
131135 retval = efi_config_parse_tables(config_tables, efi.systab->nr_tables,
132136 sizeof(efi_config_table_64_t), NULL);
133137
@@ -209,6 +213,14 @@ void __init efi_init(void) · 75 unmodified lines
209213 PAGE_ALIGN(params.mmap_size + (params.mmap & ~PAGE_MASK)));
210214 memmap.phys_map = params.mmap;
211215 memmap.map = early_memremap(params.mmap, params.mmap_size);
216+ if (memmap.map == NULL) {
217+ /*
218+ * If we are booting via UEFI, the UEFI memory map is the only
219+ * description of memory we have, so there is little point in
220+ * proceeding if we cannot access it.
221+ */
222+ panic("Unable to map EFI memory map.\n");
223+ }
212224 memmap.map_end = memmap.map + params.mmap_size;
213225 memmap.desc_size = params.desc_size;
214226 memmap.desc_version = params.desc_ver;
@@ -227,7 +239,6 @@ static bool __init efi_virtmap_init(void) · 12 unmodified lines
227239 init_new_context(NULL, &efi_mm);
228240
229241 for_each_efi_memory_desc(&memmap, md) {
230− u64 paddr, npages, size;
231242 pgprot_t prot;
232243
233244 if (!(md->attribute & EFI_MEMORY_RUNTIME))
@@ -235,11 +246,6 @@ static bool __init efi_virtmap_init(void) · 1 unmodified line
235246 if (md->virt_addr == 0)
236247 return false;
237248
238− paddr = md->phys_addr;
239− npages = md->num_pages;
240− memrange_efi_to_native(&paddr, &npages);
241− size = npages << PAGE_SHIFT;
242−
243249 pr_info(" EFI remap 0x%016llx => %p\n",
244250 md->phys_addr, (void *)md->virt_addr);
245251
@@ -256,7 +262,8 @@ static bool __init efi_virtmap_init(void) · 10 unmodified lines
256262 else
257263 prot = PAGE_KERNEL;
258264
259− create_pgd_mapping(&efi_mm, paddr, md->virt_addr, size,
265+ create_pgd_mapping(&efi_mm, md->phys_addr, md->virt_addr,
266+ md->num_pages << EFI_PAGE_SHIFT,
260267 __pgprot(pgprot_val(prot) | PTE_NG));
261268 }
262269 return true;
@@ -273,12 +280,12 @@ static int __init arm64_enable_runtime_services(void) · 10 unmodified lines
273280
274281 if (!efi_enabled(EFI_BOOT)) {
275282 pr_info("EFI services will not be available.\n");
276− return -1;
283+ return 0;
277284 }
278285
279286 if (efi_runtime_disabled()) {
280287 pr_info("EFI runtime services will be disabled.\n");
281− return -1;
288+ return 0;
282289 }
283290
284291 pr_info("Remapping and enabling EFI services.\n");
@@ -288,7 +295,7 @@ static int __init arm64_enable_runtime_services(void) · 3 unmodified lines
288295 mapsize);
289296 if (!memmap.map) {
290297 pr_err("Failed to remap EFI memory map\n");
291− return -1;
298+ return -ENOMEM;
292299 }
293300 memmap.map_end = memmap.map + mapsize;
294301 efi.memmap = &memmap;
@@ -297,13 +304,13 @@ static int __init arm64_enable_runtime_services(void) · 2 unmodified lines
297304 sizeof(efi_system_table_t));
298305 if (!efi.systab) {
299306 pr_err("Failed to remap EFI System Table\n");
300− return -1;
307+ return -ENOMEM;
301308 }
302309 set_bit(EFI_SYSTEM_TABLES, &efi.flags);
303310
304311 if (!efi_virtmap_init()) {
305312 pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n");
306− return -1;
313+ return -ENOMEM;
307314 }
308315
309316 /* Set up runtime services function pointers */
arch/arm64/kernel/vmlinux.lds.S+3−2
@@ -5,6 +5,7 @@ · 4 unmodified lines
55 */
66
77 #include <asm-generic/vmlinux.lds.h>
8+#include <asm/cache.h>
89 #include <asm/kernel-pgtable.h>
910 #include <asm/thread_info.h>
1011 #include <asm/memory.h>
@@ -140,7 +141,7 @@ SECTIONS · 129 unmodified lines
140141 ARM_EXIT_KEEP(EXIT_DATA)
141142 }
142143
143− PERCPU_SECTION(64)
144+ PERCPU_SECTION(L1_CACHE_BYTES)
144145
145146 . = ALIGN(PAGE_SIZE);
146147 __init_end = .;
@@ -158,7 +159,7 @@ SECTIONS · 11 unmodified lines
158159 . = ALIGN(PAGE_SIZE);
159160 _data = .;
160161 _sdata = .;
161− RW_DATA_SECTION(64, PAGE_SIZE, THREAD_SIZE)
162+ RW_DATA_SECTION(L1_CACHE_BYTES, PAGE_SIZE, THREAD_SIZE)
162163 PECOFF_EDATA_PADDING
163164 _edata = .;
164165
arch/arm64/kvm/Makefile+1−2
@@ -10,6 +10,7 @@ KVM=../../../virt/kvm · 9 unmodified lines
1010 ARM=../../../arch/arm/kvm
1111
1212 obj-$(CONFIG_KVM_ARM_HOST) += kvm.o
13+obj-$(CONFIG_KVM_ARM_HOST) += hyp/
1314
1415 kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/kvm_main.o $(KVM)/coalesced_mmio.o $(KVM)/eventfd.o $(KVM)/vfio.o
1516 kvm-$(CONFIG_KVM_ARM_HOST) += $(ARM)/arm.o $(ARM)/mmu.o $(ARM)/mmio.o
@@ -22,8 +23,6 @@ kvm-$(CONFIG_KVM_ARM_HOST) += guest.o debug.o reset.o sys_regs.o sys_regs_generi · 6 unmodified lines
2223 kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/vgic.o
2324 kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/vgic-v2.o
2425 kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/vgic-v2-emul.o
25−kvm-$(CONFIG_KVM_ARM_HOST) += vgic-v2-switch.o
2626 kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/vgic-v3.o
2727 kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/vgic-v3-emul.o
28−kvm-$(CONFIG_KVM_ARM_HOST) += vgic-v3-switch.o
2928 kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/arch_timer.o
arch/arm64/kvm/guest.c+9−1
@@ -28,13 +28,21 @@ · 27 unmodified lines
2828 #include <asm/cputype.h>
2929 #include <asm/uaccess.h>
3030 #include <asm/kvm.h>
31−#include <asm/kvm_asm.h>
3231 #include <asm/kvm_emulate.h>
3332 #include <asm/kvm_coproc.h>
3433
3534 #include "trace.h"
3635
36+#define VM_STAT(x) { #x, offsetof(struct kvm, stat.x), KVM_STAT_VM }
37+#define VCPU_STAT(x) { #x, offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU }
38+
3739 struct kvm_stats_debugfs_item debugfs_entries[] = {
40+ VCPU_STAT(hvc_exit_stat),
41+ VCPU_STAT(wfe_exit_stat),
42+ VCPU_STAT(wfi_exit_stat),
43+ VCPU_STAT(mmio_exit_user),
44+ VCPU_STAT(mmio_exit_kernel),
45+ VCPU_STAT(exits),
3846 { NULL }
3947 };
4048
arch/arm64/kvm/handle_exit.c+5−1
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 #include <linux/kvm_host.h>
2424
2525 #include <asm/esr.h>
26+#include <asm/kvm_asm.h>
2627 #include <asm/kvm_coproc.h>
2728 #include <asm/kvm_emulate.h>
2829 #include <asm/kvm_mmu.h>
@@ -37,8 +38,9 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run) · 8 unmodified lines
3738 {
3839 int ret;
3940
40− trace_kvm_hvc_arm64(*vcpu_pc(vcpu), *vcpu_reg(vcpu, 0),
41+ trace_kvm_hvc_arm64(*vcpu_pc(vcpu), vcpu_get_reg(vcpu, 0),
4142 kvm_vcpu_hvc_get_imm(vcpu));
43+ vcpu->stat.hvc_exit_stat++;
4244
4345 ret = kvm_psci_call(vcpu);
4446 if (ret < 0) {
@@ -71,9 +73,11 @@ static int kvm_handle_wfx(struct kvm_vcpu *vcpu, struct kvm_run *run) · 26 unmodified lines
7173 {
7274 if (kvm_vcpu_get_hsr(vcpu) & ESR_ELx_WFx_ISS_WFE) {
7375 trace_kvm_wfx_arm64(*vcpu_pc(vcpu), true);
76+ vcpu->stat.wfe_exit_stat++;
7477 kvm_vcpu_on_spin(vcpu);
7578 } else {
7679 trace_kvm_wfx_arm64(*vcpu_pc(vcpu), false);
80+ vcpu->stat.wfi_exit_stat++;
7781 kvm_vcpu_block(vcpu);
7882 }
7983
arch/arm64/kvm/hyp-init.S+9−0
@@ -94,6 +94,15 @@ __do_hyp_init: · 93 unmodified lines
9494 */
9595 mrs x5, ID_AA64MMFR0_EL1
9696 bfi x4, x5, #16, #3
97+ /*
98+ * Read the VMIDBits bits from ID_AA64MMFR1_EL1 and set the VS bit in
99+ * VTCR_EL2.
100+ */
101+ mrs x5, ID_AA64MMFR1_EL1
102+ ubfx x5, x5, #5, #1
103+ lsl x5, x5, #VTCR_EL2_VS
104+ orr x4, x4, x5
105+
97106 msr vtcr_el2, x4
98107
99108 mrs x4, mair_el1
arch/arm64/kvm/hyp.S+1−1080
@@ -17,910 +17,7 @@ · 16 unmodified lines
1717
1818 #include <linux/linkage.h>
1919
20−#include <asm/alternative.h>
21−#include <asm/asm-offsets.h>
2220 #include <asm/assembler.h>
23−#include <asm/cpufeature.h>
24−#include <asm/debug-monitors.h>
25−#include <asm/esr.h>
26−#include <asm/fpsimdmacros.h>
27−#include <asm/kvm.h>
28−#include <asm/kvm_arm.h>
29−#include <asm/kvm_asm.h>
30−#include <asm/kvm_mmu.h>
31−#include <asm/memory.h>
32−
33−#define CPU_GP_REG_OFFSET(x) (CPU_GP_REGS + x)
34−#define CPU_XREG_OFFSET(x) CPU_GP_REG_OFFSET(CPU_USER_PT_REGS + 8*x)
35−#define CPU_SPSR_OFFSET(x) CPU_GP_REG_OFFSET(CPU_SPSR + 8*x)
36−#define CPU_SYSREG_OFFSET(x) (CPU_SYSREGS + 8*x)
37−
38− .text
39− .pushsection .hyp.text, "ax"
40− .align PAGE_SHIFT
41−
42−.macro save_common_regs
43− // x2: base address for cpu context
44− // x3: tmp register
45−
46− add x3, x2, #CPU_XREG_OFFSET(19)
47− stp x19, x20, [x3]
48− stp x21, x22, [x3, #16]
49− stp x23, x24, [x3, #32]
50− stp x25, x26, [x3, #48]
51− stp x27, x28, [x3, #64]
52− stp x29, lr, [x3, #80]
53−
54− mrs x19, sp_el0
55− mrs x20, elr_el2 // pc before entering el2
56− mrs x21, spsr_el2 // pstate before entering el2
57−
58− stp x19, x20, [x3, #96]
59− str x21, [x3, #112]
60−
61− mrs x22, sp_el1
62− mrs x23, elr_el1
63− mrs x24, spsr_el1
64−
65− str x22, [x2, #CPU_GP_REG_OFFSET(CPU_SP_EL1)]
66− str x23, [x2, #CPU_GP_REG_OFFSET(CPU_ELR_EL1)]
67− str x24, [x2, #CPU_SPSR_OFFSET(KVM_SPSR_EL1)]
68−.endm
69−
70−.macro restore_common_regs
71− // x2: base address for cpu context
72− // x3: tmp register
73−
74− ldr x22, [x2, #CPU_GP_REG_OFFSET(CPU_SP_EL1)]
75− ldr x23, [x2, #CPU_GP_REG_OFFSET(CPU_ELR_EL1)]
76− ldr x24, [x2, #CPU_SPSR_OFFSET(KVM_SPSR_EL1)]
77−
78− msr sp_el1, x22
79− msr elr_el1, x23
80− msr spsr_el1, x24
81−
82− add x3, x2, #CPU_XREG_OFFSET(31) // SP_EL0
83− ldp x19, x20, [x3]
84− ldr x21, [x3, #16]
85−
86− msr sp_el0, x19
87− msr elr_el2, x20 // pc on return from el2
88− msr spsr_el2, x21 // pstate on return from el2
89−
90− add x3, x2, #CPU_XREG_OFFSET(19)
91− ldp x19, x20, [x3]
92− ldp x21, x22, [x3, #16]
93− ldp x23, x24, [x3, #32]
94− ldp x25, x26, [x3, #48]
95− ldp x27, x28, [x3, #64]
96− ldp x29, lr, [x3, #80]
97−.endm
98−
99−.macro save_host_regs
100− save_common_regs
101−.endm
102−
103−.macro restore_host_regs
104− restore_common_regs
105−.endm
106−
107−.macro save_fpsimd
108− // x2: cpu context address
109− // x3, x4: tmp regs
110− add x3, x2, #CPU_GP_REG_OFFSET(CPU_FP_REGS)
111− fpsimd_save x3, 4
112−.endm
113−
114−.macro restore_fpsimd
115− // x2: cpu context address
116− // x3, x4: tmp regs
117− add x3, x2, #CPU_GP_REG_OFFSET(CPU_FP_REGS)
118− fpsimd_restore x3, 4
119−.endm
120−
121−.macro save_guest_regs
122− // x0 is the vcpu address
123− // x1 is the return code, do not corrupt!
124− // x2 is the cpu context
125− // x3 is a tmp register
126− // Guest's x0-x3 are on the stack
127−
128− // Compute base to save registers
129− add x3, x2, #CPU_XREG_OFFSET(4)
130− stp x4, x5, [x3]
131− stp x6, x7, [x3, #16]
132− stp x8, x9, [x3, #32]
133− stp x10, x11, [x3, #48]
134− stp x12, x13, [x3, #64]
135− stp x14, x15, [x3, #80]
136− stp x16, x17, [x3, #96]
137− str x18, [x3, #112]
138−
139− pop x6, x7 // x2, x3
140− pop x4, x5 // x0, x1
141−
142− add x3, x2, #CPU_XREG_OFFSET(0)
143− stp x4, x5, [x3]
144− stp x6, x7, [x3, #16]
145−
146− save_common_regs
147−.endm
148−
149−.macro restore_guest_regs
150− // x0 is the vcpu address.
151− // x2 is the cpu context
152− // x3 is a tmp register
153−
154− // Prepare x0-x3 for later restore
155− add x3, x2, #CPU_XREG_OFFSET(0)
156− ldp x4, x5, [x3]
157− ldp x6, x7, [x3, #16]
158− push x4, x5 // Push x0-x3 on the stack
159− push x6, x7
160−
161− // x4-x18
162− ldp x4, x5, [x3, #32]
163− ldp x6, x7, [x3, #48]
164− ldp x8, x9, [x3, #64]
165− ldp x10, x11, [x3, #80]
166− ldp x12, x13, [x3, #96]
167− ldp x14, x15, [x3, #112]
168− ldp x16, x17, [x3, #128]
169− ldr x18, [x3, #144]
170−
171− // x19-x29, lr, sp*, elr*, spsr*
172− restore_common_regs
173−
174− // Last bits of the 64bit state
175− pop x2, x3
176− pop x0, x1
177−
178− // Do not touch any register after this!
179−.endm
180−
181−/*
182− * Macros to perform system register save/restore.
183− *
184− * Ordering here is absolutely critical, and must be kept consistent
185− * in {save,restore}_sysregs, {save,restore}_guest_32bit_state,
186− * and in kvm_asm.h.
187− *
188− * In other words, don't touch any of these unless you know what
189− * you are doing.
190− */
191−.macro save_sysregs
192− // x2: base address for cpu context
193− // x3: tmp register
194−
195− add x3, x2, #CPU_SYSREG_OFFSET(MPIDR_EL1)
196−
197− mrs x4, vmpidr_el2
198− mrs x5, csselr_el1
199− mrs x6, sctlr_el1
200− mrs x7, actlr_el1
201− mrs x8, cpacr_el1
202− mrs x9, ttbr0_el1
203− mrs x10, ttbr1_el1
204− mrs x11, tcr_el1
205− mrs x12, esr_el1
206− mrs x13, afsr0_el1
207− mrs x14, afsr1_el1
208− mrs x15, far_el1
209− mrs x16, mair_el1
210− mrs x17, vbar_el1
211− mrs x18, contextidr_el1
212− mrs x19, tpidr_el0
213− mrs x20, tpidrro_el0
214− mrs x21, tpidr_el1
215− mrs x22, amair_el1
216− mrs x23, cntkctl_el1
217− mrs x24, par_el1
218− mrs x25, mdscr_el1
219−
220− stp x4, x5, [x3]
221− stp x6, x7, [x3, #16]
222− stp x8, x9, [x3, #32]
223− stp x10, x11, [x3, #48]
224− stp x12, x13, [x3, #64]
225− stp x14, x15, [x3, #80]
226− stp x16, x17, [x3, #96]
227− stp x18, x19, [x3, #112]
228− stp x20, x21, [x3, #128]
229− stp x22, x23, [x3, #144]
230− stp x24, x25, [x3, #160]
231−.endm
232−
233−.macro save_debug type
234− // x4: pointer to register set
235− // x5: number of registers to skip
236− // x6..x22 trashed
237−
238− adr x22, 1f
239− add x22, x22, x5, lsl #2
240− br x22
241−1:
242− mrs x21, \type\()15_el1
243− mrs x20, \type\()14_el1
244− mrs x19, \type\()13_el1
245− mrs x18, \type\()12_el1
246− mrs x17, \type\()11_el1
247− mrs x16, \type\()10_el1
248− mrs x15, \type\()9_el1
249− mrs x14, \type\()8_el1
250− mrs x13, \type\()7_el1
251− mrs x12, \type\()6_el1
252− mrs x11, \type\()5_el1
253− mrs x10, \type\()4_el1
254− mrs x9, \type\()3_el1
255− mrs x8, \type\()2_el1
256− mrs x7, \type\()1_el1
257− mrs x6, \type\()0_el1
258−
259− adr x22, 1f
260− add x22, x22, x5, lsl #2
261− br x22
262−1:
263− str x21, [x4, #(15 * 8)]
264− str x20, [x4, #(14 * 8)]
265− str x19, [x4, #(13 * 8)]
266− str x18, [x4, #(12 * 8)]
267− str x17, [x4, #(11 * 8)]
268− str x16, [x4, #(10 * 8)]
269− str x15, [x4, #(9 * 8)]
270− str x14, [x4, #(8 * 8)]
271− str x13, [x4, #(7 * 8)]
272− str x12, [x4, #(6 * 8)]
273− str x11, [x4, #(5 * 8)]
274− str x10, [x4, #(4 * 8)]
275− str x9, [x4, #(3 * 8)]
276− str x8, [x4, #(2 * 8)]
277− str x7, [x4, #(1 * 8)]
278− str x6, [x4, #(0 * 8)]
279−.endm
280−
281−.macro restore_sysregs
282− // x2: base address for cpu context
283− // x3: tmp register
284−
285− add x3, x2, #CPU_SYSREG_OFFSET(MPIDR_EL1)
286−
287− ldp x4, x5, [x3]
288− ldp x6, x7, [x3, #16]
289− ldp x8, x9, [x3, #32]
290− ldp x10, x11, [x3, #48]
291− ldp x12, x13, [x3, #64]
292− ldp x14, x15, [x3, #80]
293− ldp x16, x17, [x3, #96]
294− ldp x18, x19, [x3, #112]
295− ldp x20, x21, [x3, #128]
296− ldp x22, x23, [x3, #144]
297− ldp x24, x25, [x3, #160]
298−
299− msr vmpidr_el2, x4
300− msr csselr_el1, x5
301− msr sctlr_el1, x6
302− msr actlr_el1, x7
303− msr cpacr_el1, x8
304− msr ttbr0_el1, x9
305− msr ttbr1_el1, x10
306− msr tcr_el1, x11
307− msr esr_el1, x12
308− msr afsr0_el1, x13
309− msr afsr1_el1, x14
310− msr far_el1, x15
311− msr mair_el1, x16
312− msr vbar_el1, x17
313− msr contextidr_el1, x18
314− msr tpidr_el0, x19
315− msr tpidrro_el0, x20
316− msr tpidr_el1, x21
317− msr amair_el1, x22
318− msr cntkctl_el1, x23
319− msr par_el1, x24
320− msr mdscr_el1, x25
321−.endm
322−
323−.macro restore_debug type
324− // x4: pointer to register set
325− // x5: number of registers to skip
326− // x6..x22 trashed
327−
328− adr x22, 1f
329− add x22, x22, x5, lsl #2
330− br x22
331−1:
332− ldr x21, [x4, #(15 * 8)]
333− ldr x20, [x4, #(14 * 8)]
334− ldr x19, [x4, #(13 * 8)]
335− ldr x18, [x4, #(12 * 8)]
336− ldr x17, [x4, #(11 * 8)]
337− ldr x16, [x4, #(10 * 8)]
338− ldr x15, [x4, #(9 * 8)]
339− ldr x14, [x4, #(8 * 8)]
340− ldr x13, [x4, #(7 * 8)]
341− ldr x12, [x4, #(6 * 8)]
342− ldr x11, [x4, #(5 * 8)]
343− ldr x10, [x4, #(4 * 8)]
344− ldr x9, [x4, #(3 * 8)]
345− ldr x8, [x4, #(2 * 8)]
346− ldr x7, [x4, #(1 * 8)]
347− ldr x6, [x4, #(0 * 8)]
348−
349− adr x22, 1f
350− add x22, x22, x5, lsl #2
351− br x22
352−1:
353− msr \type\()15_el1, x21
354− msr \type\()14_el1, x20
355− msr \type\()13_el1, x19
356− msr \type\()12_el1, x18
357− msr \type\()11_el1, x17
358− msr \type\()10_el1, x16
359− msr \type\()9_el1, x15
360− msr \type\()8_el1, x14
361− msr \type\()7_el1, x13
362− msr \type\()6_el1, x12
363− msr \type\()5_el1, x11
364− msr \type\()4_el1, x10
365− msr \type\()3_el1, x9
366− msr \type\()2_el1, x8
367− msr \type\()1_el1, x7
368− msr \type\()0_el1, x6
369−.endm
370−
371−.macro skip_32bit_state tmp, target
372− // Skip 32bit state if not needed
373− mrs \tmp, hcr_el2
374− tbnz \tmp, #HCR_RW_SHIFT, \target
375−.endm
376−
377−.macro skip_tee_state tmp, target
378− // Skip ThumbEE state if not needed
379− mrs \tmp, id_pfr0_el1
380− tbz \tmp, #12, \target
381−.endm
382−
383−.macro skip_debug_state tmp, target
384− ldr \tmp, [x0, #VCPU_DEBUG_FLAGS]
385− tbz \tmp, #KVM_ARM64_DEBUG_DIRTY_SHIFT, \target
386−.endm
387−
388−/*
389− * Branch to target if CPTR_EL2.TFP bit is set (VFP/SIMD trapping enabled)
390− */
391−.macro skip_fpsimd_state tmp, target
392− mrs \tmp, cptr_el2
393− tbnz \tmp, #CPTR_EL2_TFP_SHIFT, \target
394−.endm
395−
396−.macro compute_debug_state target
397− // Compute debug state: If any of KDE, MDE or KVM_ARM64_DEBUG_DIRTY
398− // is set, we do a full save/restore cycle and disable trapping.
399− add x25, x0, #VCPU_CONTEXT
400−
401− // Check the state of MDSCR_EL1
402− ldr x25, [x25, #CPU_SYSREG_OFFSET(MDSCR_EL1)]
403− and x26, x25, #DBG_MDSCR_KDE
404− and x25, x25, #DBG_MDSCR_MDE
405− adds xzr, x25, x26
406− b.eq 9998f // Nothing to see there
407−
408− // If any interesting bits was set, we must set the flag
409− mov x26, #KVM_ARM64_DEBUG_DIRTY
410− str x26, [x0, #VCPU_DEBUG_FLAGS]
411− b 9999f // Don't skip restore
412−
413−9998:
414− // Otherwise load the flags from memory in case we recently
415− // trapped
416− skip_debug_state x25, \target
417−9999:
418−.endm
419−
420−.macro save_guest_32bit_state
421− skip_32bit_state x3, 1f
422−
423− add x3, x2, #CPU_SPSR_OFFSET(KVM_SPSR_ABT)
424− mrs x4, spsr_abt
425− mrs x5, spsr_und
426− mrs x6, spsr_irq
427− mrs x7, spsr_fiq
428− stp x4, x5, [x3]
429− stp x6, x7, [x3, #16]
430−
431− add x3, x2, #CPU_SYSREG_OFFSET(DACR32_EL2)
432− mrs x4, dacr32_el2
433− mrs x5, ifsr32_el2
434− stp x4, x5, [x3]
435−
436− skip_fpsimd_state x8, 2f
437− mrs x6, fpexc32_el2
438− str x6, [x3, #16]
439−2:
440− skip_debug_state x8, 1f
441− mrs x7, dbgvcr32_el2
442− str x7, [x3, #24]
443−1:
444−.endm
445−
446−.macro restore_guest_32bit_state
447− skip_32bit_state x3, 1f
448−
449− add x3, x2, #CPU_SPSR_OFFSET(KVM_SPSR_ABT)
450− ldp x4, x5, [x3]
451− ldp x6, x7, [x3, #16]
452− msr spsr_abt, x4
453− msr spsr_und, x5
454− msr spsr_irq, x6
455− msr spsr_fiq, x7
456−
457− add x3, x2, #CPU_SYSREG_OFFSET(DACR32_EL2)
458− ldp x4, x5, [x3]
459− msr dacr32_el2, x4
460− msr ifsr32_el2, x5
461−
462− skip_debug_state x8, 1f
463− ldr x7, [x3, #24]
464− msr dbgvcr32_el2, x7
465−1:
466−.endm
467−
468−.macro activate_traps
469− ldr x2, [x0, #VCPU_HCR_EL2]
470−
471− /*
472− * We are about to set CPTR_EL2.TFP to trap all floating point
473− * register accesses to EL2, however, the ARM ARM clearly states that
474− * traps are only taken to EL2 if the operation would not otherwise
475− * trap to EL1. Therefore, always make sure that for 32-bit guests,
476− * we set FPEXC.EN to prevent traps to EL1, when setting the TFP bit.
477− */
478− tbnz x2, #HCR_RW_SHIFT, 99f // open code skip_32bit_state
479− mov x3, #(1 << 30)
480− msr fpexc32_el2, x3
481− isb
482−99:
483− msr hcr_el2, x2
484− mov x2, #CPTR_EL2_TTA
485− orr x2, x2, #CPTR_EL2_TFP
486− msr cptr_el2, x2
487−
488− mov x2, #(1 << 15) // Trap CP15 Cr=15
489− msr hstr_el2, x2
490−
491− // Monitor Debug Config - see kvm_arm_setup_debug()
492− ldr x2, [x0, #VCPU_MDCR_EL2]
493− msr mdcr_el2, x2
494−.endm
495−
496−.macro deactivate_traps
497− mov x2, #HCR_RW
498− msr hcr_el2, x2
499− msr hstr_el2, xzr
500−
501− mrs x2, mdcr_el2
502− and x2, x2, #MDCR_EL2_HPMN_MASK
503− msr mdcr_el2, x2
504−.endm
505−
506−.macro activate_vm
507− ldr x1, [x0, #VCPU_KVM]
508− kern_hyp_va x1
509− ldr x2, [x1, #KVM_VTTBR]
510− msr vttbr_el2, x2
511−.endm
512−
513−.macro deactivate_vm
514− msr vttbr_el2, xzr
515−.endm
516−
517−/*
518− * Call into the vgic backend for state saving
519− */
520−.macro save_vgic_state
521−alternative_if_not ARM64_HAS_SYSREG_GIC_CPUIF
522− bl __save_vgic_v2_state
523−alternative_else
524− bl __save_vgic_v3_state
525−alternative_endif
526− mrs x24, hcr_el2
527− mov x25, #HCR_INT_OVERRIDE
528− neg x25, x25
529− and x24, x24, x25
530− msr hcr_el2, x24
531−.endm
532−
533−/*
534− * Call into the vgic backend for state restoring
535− */
536−.macro restore_vgic_state
537− mrs x24, hcr_el2
538− ldr x25, [x0, #VCPU_IRQ_LINES]
539− orr x24, x24, #HCR_INT_OVERRIDE
540− orr x24, x24, x25
541− msr hcr_el2, x24
542−alternative_if_not ARM64_HAS_SYSREG_GIC_CPUIF
543− bl __restore_vgic_v2_state
544−alternative_else
545− bl __restore_vgic_v3_state
546−alternative_endif
547−.endm
548−
549−.macro save_timer_state
550− // x0: vcpu pointer
551− ldr x2, [x0, #VCPU_KVM]
552− kern_hyp_va x2
553− ldr w3, [x2, #KVM_TIMER_ENABLED]
554− cbz w3, 1f
555−
556− mrs x3, cntv_ctl_el0
557− and x3, x3, #3
558− str w3, [x0, #VCPU_TIMER_CNTV_CTL]
559−
560− isb
561−
562− mrs x3, cntv_cval_el0
563− str x3, [x0, #VCPU_TIMER_CNTV_CVAL]
564−
565−1:
566− // Disable the virtual timer
567− msr cntv_ctl_el0, xzr
568−
569− // Allow physical timer/counter access for the host
570− mrs x2, cnthctl_el2
571− orr x2, x2, #3
572− msr cnthctl_el2, x2
573−
574− // Clear cntvoff for the host
575− msr cntvoff_el2, xzr
576−.endm
577−
578−.macro restore_timer_state
579− // x0: vcpu pointer
580− // Disallow physical timer access for the guest
581− // Physical counter access is allowed
582− mrs x2, cnthctl_el2
583− orr x2, x2, #1
584− bic x2, x2, #2
585− msr cnthctl_el2, x2
586−
587− ldr x2, [x0, #VCPU_KVM]
588− kern_hyp_va x2
589− ldr w3, [x2, #KVM_TIMER_ENABLED]
590− cbz w3, 1f
591−
592− ldr x3, [x2, #KVM_TIMER_CNTVOFF]
593− msr cntvoff_el2, x3
594− ldr x2, [x0, #VCPU_TIMER_CNTV_CVAL]
595− msr cntv_cval_el0, x2
596− isb
597−
598− ldr w2, [x0, #VCPU_TIMER_CNTV_CTL]
599− and x2, x2, #3
600− msr cntv_ctl_el0, x2
601−1:
602−.endm
603−
604−__save_sysregs:
605− save_sysregs
606− ret
607−
608−__restore_sysregs:
609− restore_sysregs
610− ret
611−
612−/* Save debug state */
613−__save_debug:
614− // x2: ptr to CPU context
615− // x3: ptr to debug reg struct
616− // x4/x5/x6-22/x24-26: trashed
617−
618− mrs x26, id_aa64dfr0_el1
619− ubfx x24, x26, #12, #4 // Extract BRPs
620− ubfx x25, x26, #20, #4 // Extract WRPs
621− mov w26, #15
622− sub w24, w26, w24 // How many BPs to skip
623− sub w25, w26, w25 // How many WPs to skip
624−
625− mov x5, x24
626− add x4, x3, #DEBUG_BCR
627− save_debug dbgbcr
628− add x4, x3, #DEBUG_BVR
629− save_debug dbgbvr
630−
631− mov x5, x25
632− add x4, x3, #DEBUG_WCR
633− save_debug dbgwcr
634− add x4, x3, #DEBUG_WVR
635− save_debug dbgwvr
636−
637− mrs x21, mdccint_el1
638− str x21, [x2, #CPU_SYSREG_OFFSET(MDCCINT_EL1)]
639− ret
640−
641−/* Restore debug state */
642−__restore_debug:
643− // x2: ptr to CPU context
644− // x3: ptr to debug reg struct
645− // x4/x5/x6-22/x24-26: trashed
646−
647− mrs x26, id_aa64dfr0_el1
648− ubfx x24, x26, #12, #4 // Extract BRPs
649− ubfx x25, x26, #20, #4 // Extract WRPs
650− mov w26, #15
651− sub w24, w26, w24 // How many BPs to skip
652− sub w25, w26, w25 // How many WPs to skip
653−
654− mov x5, x24
655− add x4, x3, #DEBUG_BCR
656− restore_debug dbgbcr
657− add x4, x3, #DEBUG_BVR
658− restore_debug dbgbvr
659−
660− mov x5, x25
661− add x4, x3, #DEBUG_WCR
662− restore_debug dbgwcr
663− add x4, x3, #DEBUG_WVR
664− restore_debug dbgwvr
665−
666− ldr x21, [x2, #CPU_SYSREG_OFFSET(MDCCINT_EL1)]
667− msr mdccint_el1, x21
668−
669− ret
670−
671−__save_fpsimd:
672− skip_fpsimd_state x3, 1f
673− save_fpsimd
674−1: ret
675−
676−__restore_fpsimd:
677− skip_fpsimd_state x3, 1f
678− restore_fpsimd
679−1: ret
680−
681−switch_to_guest_fpsimd:
682− push x4, lr
683−
684− mrs x2, cptr_el2
685− bic x2, x2, #CPTR_EL2_TFP
686− msr cptr_el2, x2
687− isb
688−
689− mrs x0, tpidr_el2
690−
691− ldr x2, [x0, #VCPU_HOST_CONTEXT]
692− kern_hyp_va x2
693− bl __save_fpsimd
694−
695− add x2, x0, #VCPU_CONTEXT
696− bl __restore_fpsimd
697−
698− skip_32bit_state x3, 1f
699− ldr x4, [x2, #CPU_SYSREG_OFFSET(FPEXC32_EL2)]
700− msr fpexc32_el2, x4
701−1:
702− pop x4, lr
703− pop x2, x3
704− pop x0, x1
705−
706− eret
707−
708−/*
709− * u64 __kvm_vcpu_run(struct kvm_vcpu *vcpu);
710− *
711− * This is the world switch. The first half of the function
712− * deals with entering the guest, and anything from __kvm_vcpu_return
713− * to the end of the function deals with reentering the host.
714− * On the enter path, only x0 (vcpu pointer) must be preserved until
715− * the last moment. On the exit path, x0 (vcpu pointer) and x1 (exception
716− * code) must both be preserved until the epilogue.
717− * In both cases, x2 points to the CPU context we're saving/restoring from/to.
718− */
719−ENTRY(__kvm_vcpu_run)
720− kern_hyp_va x0
721− msr tpidr_el2, x0 // Save the vcpu register
722−
723− // Host context
724− ldr x2, [x0, #VCPU_HOST_CONTEXT]
725− kern_hyp_va x2
726−
727− save_host_regs
728− bl __save_sysregs
729−
730− compute_debug_state 1f
731− add x3, x0, #VCPU_HOST_DEBUG_STATE
732− bl __save_debug
733−1:
734− activate_traps
735− activate_vm
736−
737− restore_vgic_state
738− restore_timer_state
739−
740− // Guest context
741− add x2, x0, #VCPU_CONTEXT
742−
743− // We must restore the 32-bit state before the sysregs, thanks
744− // to Cortex-A57 erratum #852523.
745− restore_guest_32bit_state
746− bl __restore_sysregs
747−
748− skip_debug_state x3, 1f
749− ldr x3, [x0, #VCPU_DEBUG_PTR]
750− kern_hyp_va x3
751− bl __restore_debug
752−1:
753− restore_guest_regs
754−
755− // That's it, no more messing around.
756− eret
757−
758−__kvm_vcpu_return:
759− // Assume x0 is the vcpu pointer, x1 the return code
760− // Guest's x0-x3 are on the stack
761−
762− // Guest context
763− add x2, x0, #VCPU_CONTEXT
764−
765− save_guest_regs
766− bl __save_fpsimd
767− bl __save_sysregs
768−
769− skip_debug_state x3, 1f
770− ldr x3, [x0, #VCPU_DEBUG_PTR]
771− kern_hyp_va x3
772− bl __save_debug
773−1:
774− save_guest_32bit_state
775−
776− save_timer_state
777− save_vgic_state
778−
779− deactivate_traps
780− deactivate_vm
781−
782− // Host context
783− ldr x2, [x0, #VCPU_HOST_CONTEXT]
784− kern_hyp_va x2
785−
786− bl __restore_sysregs
787− bl __restore_fpsimd
788− /* Clear FPSIMD and Trace trapping */
789− msr cptr_el2, xzr
790−
791− skip_debug_state x3, 1f
792− // Clear the dirty flag for the next run, as all the state has
793− // already been saved. Note that we nuke the whole 64bit word.
794− // If we ever add more flags, we'll have to be more careful...
795− str xzr, [x0, #VCPU_DEBUG_FLAGS]
796− add x3, x0, #VCPU_HOST_DEBUG_STATE
797− bl __restore_debug
798−1:
799− restore_host_regs
800−
801− mov x0, x1
802− ret
803−END(__kvm_vcpu_run)
804−
805−// void __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa);
806−ENTRY(__kvm_tlb_flush_vmid_ipa)
807− dsb ishst
808−
809− kern_hyp_va x0
810− ldr x2, [x0, #KVM_VTTBR]
811− msr vttbr_el2, x2
812− isb
813−
814− /*
815− * We could do so much better if we had the VA as well.
816− * Instead, we invalidate Stage-2 for this IPA, and the
817− * whole of Stage-1. Weep...
818− */
819− lsr x1, x1, #12
820− tlbi ipas2e1is, x1
821− /*
822− * We have to ensure completion of the invalidation at Stage-2,
823− * since a table walk on another CPU could refill a TLB with a
824− * complete (S1 + S2) walk based on the old Stage-2 mapping if
825− * the Stage-1 invalidation happened first.
826− */
827− dsb ish
828− tlbi vmalle1is
829− dsb ish
830− isb
831−
832− msr vttbr_el2, xzr
833− ret
834−ENDPROC(__kvm_tlb_flush_vmid_ipa)
835−
836−/**
837− * void __kvm_tlb_flush_vmid(struct kvm *kvm) - Flush per-VMID TLBs
838− * @struct kvm *kvm - pointer to kvm structure
839− *
840− * Invalidates all Stage 1 and 2 TLB entries for current VMID.
841− */
842−ENTRY(__kvm_tlb_flush_vmid)
843− dsb ishst
844−
845− kern_hyp_va x0
846− ldr x2, [x0, #KVM_VTTBR]
847− msr vttbr_el2, x2
848− isb
849−
850− tlbi vmalls12e1is
851− dsb ish
852− isb
853−
854− msr vttbr_el2, xzr
855− ret
856−ENDPROC(__kvm_tlb_flush_vmid)
857−
858−ENTRY(__kvm_flush_vm_context)
859− dsb ishst
860− tlbi alle1is
861− ic ialluis
862− dsb ish
863− ret
864−ENDPROC(__kvm_flush_vm_context)
865−
866−__kvm_hyp_panic:
867− // Stash PAR_EL1 before corrupting it in __restore_sysregs
868− mrs x0, par_el1
869− push x0, xzr
870−
871− // Guess the context by looking at VTTBR:
872− // If zero, then we're already a host.
873− // Otherwise restore a minimal host context before panicing.
874− mrs x0, vttbr_el2
875− cbz x0, 1f
876−
877− mrs x0, tpidr_el2
878−
879− deactivate_traps
880− deactivate_vm
881−
882− ldr x2, [x0, #VCPU_HOST_CONTEXT]
883− kern_hyp_va x2
884−
885− bl __restore_sysregs
886−
887− /*
888− * Make sure we have a valid host stack, and don't leave junk in the
889− * frame pointer that will give us a misleading host stack unwinding.
890− */
891− ldr x22, [x2, #CPU_GP_REG_OFFSET(CPU_SP_EL1)]
892− msr sp_el1, x22
893− mov x29, xzr
894−
895−1: adr x0, __hyp_panic_str
896− adr x1, 2f
897− ldp x2, x3, [x1]
898− sub x0, x0, x2
899− add x0, x0, x3
900− mrs x1, spsr_el2
901− mrs x2, elr_el2
902− mrs x3, esr_el2
903− mrs x4, far_el2
904− mrs x5, hpfar_el2
905− pop x6, xzr // active context PAR_EL1
906− mrs x7, tpidr_el2
907−
908− mov lr, #(PSR_F_BIT | PSR_I_BIT | PSR_A_BIT | PSR_D_BIT |\
909− PSR_MODE_EL1h)
910− msr spsr_el2, lr
911− ldr lr, =panic
912− msr elr_el2, lr
913− eret
914−
915− .align 3
916−2: .quad HYP_PAGE_OFFSET
917− .quad PAGE_OFFSET
918−ENDPROC(__kvm_hyp_panic)
919−
920−__hyp_panic_str:
921− .ascii "HYP panic:\nPS:%08x PC:%016x ESR:%08x\nFAR:%016x HPFAR:%016x PAR:%016x\nVCPU:%p\n\0"
922−
923− .align 2
92421
92522 /*
92623 * u64 kvm_call_hyp(void *hypfn, ...);
@@ -934,7 +31,7 @@ __hyp_panic_str: · 7 unmodified lines
93431 * passed as x0, x1, and x2 (a maximum of 3 arguments in addition to the
93532 * function pointer can be passed). The function being called must be mapped
93633 * in Hyp mode (see init_hyp_mode in arch/arm/kvm/arm.c). Return values are
937− * passed in r0 and r1.
34+ * passed in x0.
93835 *
93936 * A function pointer with a value of 0 has a special meaning, and is
94037 * used to implement __hyp_get_vectors in the same way as in
@@ -944,179 +41,3 @@ ENTRY(kvm_call_hyp) · 3 unmodified lines
94441 hvc #0
94542 ret
94643 ENDPROC(kvm_call_hyp)
947−
948−.macro invalid_vector label, target
949− .align 2
950−\label:
951− b \target
952−ENDPROC(\label)
953−.endm
954−
955− /* None of these should ever happen */
956− invalid_vector el2t_sync_invalid, __kvm_hyp_panic
957− invalid_vector el2t_irq_invalid, __kvm_hyp_panic
958− invalid_vector el2t_fiq_invalid, __kvm_hyp_panic
959− invalid_vector el2t_error_invalid, __kvm_hyp_panic
960− invalid_vector el2h_sync_invalid, __kvm_hyp_panic
961− invalid_vector el2h_irq_invalid, __kvm_hyp_panic
962− invalid_vector el2h_fiq_invalid, __kvm_hyp_panic
963− invalid_vector el2h_error_invalid, __kvm_hyp_panic
964− invalid_vector el1_sync_invalid, __kvm_hyp_panic
965− invalid_vector el1_irq_invalid, __kvm_hyp_panic
966− invalid_vector el1_fiq_invalid, __kvm_hyp_panic
967− invalid_vector el1_error_invalid, __kvm_hyp_panic
968−
969−el1_sync: // Guest trapped into EL2
970− push x0, x1
971− push x2, x3
972−
973− mrs x1, esr_el2
974− lsr x2, x1, #ESR_ELx_EC_SHIFT
975−
976− cmp x2, #ESR_ELx_EC_HVC64
977− b.ne el1_trap
978−
979− mrs x3, vttbr_el2 // If vttbr is valid, the 64bit guest
980− cbnz x3, el1_trap // called HVC
981−
982− /* Here, we're pretty sure the host called HVC. */
983− pop x2, x3
984− pop x0, x1
985−
986− /* Check for __hyp_get_vectors */
987− cbnz x0, 1f
988− mrs x0, vbar_el2
989− b 2f
990−
991−1: push lr, xzr
992−
993− /*
994− * Compute the function address in EL2, and shuffle the parameters.
995− */
996− kern_hyp_va x0
997− mov lr, x0
998− mov x0, x1
999− mov x1, x2
1000− mov x2, x3
1001− blr lr
1002−
1003− pop lr, xzr
1004−2: eret
1005−
1006−el1_trap:
1007− /*
1008− * x1: ESR
1009− * x2: ESR_EC
1010− */
1011−
1012− /* Guest accessed VFP/SIMD registers, save host, restore Guest */
1013− cmp x2, #ESR_ELx_EC_FP_ASIMD
1014− b.eq switch_to_guest_fpsimd
1015−
1016− cmp x2, #ESR_ELx_EC_DABT_LOW
1017− mov x0, #ESR_ELx_EC_IABT_LOW
1018− ccmp x2, x0, #4, ne
1019− b.ne 1f // Not an abort we care about
1020−
1021− /* This is an abort. Check for permission fault */
1022−alternative_if_not ARM64_WORKAROUND_834220
1023− and x2, x1, #ESR_ELx_FSC_TYPE
1024− cmp x2, #FSC_PERM
1025− b.ne 1f // Not a permission fault
1026−alternative_else
1027− nop // Use the permission fault path to
1028− nop // check for a valid S1 translation,
1029− nop // regardless of the ESR value.
1030−alternative_endif
1031−
1032− /*
1033− * Check for Stage-1 page table walk, which is guaranteed
1034− * to give a valid HPFAR_EL2.
1035− */
1036− tbnz x1, #7, 1f // S1PTW is set
1037−
1038− /* Preserve PAR_EL1 */
1039− mrs x3, par_el1
1040− push x3, xzr
1041−
1042− /*
1043− * Permission fault, HPFAR_EL2 is invalid.
1044− * Resolve the IPA the hard way using the guest VA.
1045− * Stage-1 translation already validated the memory access rights.
1046− * As such, we can use the EL1 translation regime, and don't have
1047− * to distinguish between EL0 and EL1 access.
1048− */
1049− mrs x2, far_el2
1050− at s1e1r, x2
1051− isb
1052−
1053− /* Read result */
1054− mrs x3, par_el1
1055− pop x0, xzr // Restore PAR_EL1 from the stack
1056− msr par_el1, x0
1057− tbnz x3, #0, 3f // Bail out if we failed the translation
1058− ubfx x3, x3, #12, #36 // Extract IPA
1059− lsl x3, x3, #4 // and present it like HPFAR
1060− b 2f
1061−
1062−1: mrs x3, hpfar_el2
1063− mrs x2, far_el2
1064−
1065−2: mrs x0, tpidr_el2
1066− str w1, [x0, #VCPU_ESR_EL2]
1067− str x2, [x0, #VCPU_FAR_EL2]
1068− str x3, [x0, #VCPU_HPFAR_EL2]
1069−
1070− mov x1, #ARM_EXCEPTION_TRAP
1071− b __kvm_vcpu_return
1072−
1073− /*
1074− * Translation failed. Just return to the guest and
1075− * let it fault again. Another CPU is probably playing
1076− * behind our back.
1077− */
1078−3: pop x2, x3
1079− pop x0, x1
1080−
1081− eret
1082−
1083−el1_irq:
1084− push x0, x1
1085− push x2, x3
1086− mrs x0, tpidr_el2
1087− mov x1, #ARM_EXCEPTION_IRQ
1088− b __kvm_vcpu_return
1089−
1090− .ltorg
1091−
1092− .align 11
1093−
1094−ENTRY(__kvm_hyp_vector)
1095− ventry el2t_sync_invalid // Synchronous EL2t
1096− ventry el2t_irq_invalid // IRQ EL2t
1097− ventry el2t_fiq_invalid // FIQ EL2t
1098− ventry el2t_error_invalid // Error EL2t
1099−
1100− ventry el2h_sync_invalid // Synchronous EL2h
1101− ventry el2h_irq_invalid // IRQ EL2h
1102− ventry el2h_fiq_invalid // FIQ EL2h
1103− ventry el2h_error_invalid // Error EL2h
1104−
1105− ventry el1_sync // Synchronous 64-bit EL1
1106− ventry el1_irq // IRQ 64-bit EL1
1107− ventry el1_fiq_invalid // FIQ 64-bit EL1
1108− ventry el1_error_invalid // Error 64-bit EL1
1109−
1110− ventry el1_sync // Synchronous 32-bit EL1
1111− ventry el1_irq // IRQ 32-bit EL1
1112− ventry el1_fiq_invalid // FIQ 32-bit EL1
1113− ventry el1_error_invalid // Error 32-bit EL1
1114−ENDPROC(__kvm_hyp_vector)
1115−
1116−
1117−ENTRY(__kvm_get_mdcr_el2)
1118− mrs x0, mdcr_el2
1119− ret
1120−ENDPROC(__kvm_get_mdcr_el2)
1121−
1122− .popsection
arch/arm64/kvm/hyp/Makefile+14−0
@@ -0,0 +1,14 @@
1+#
2+# Makefile for Kernel-based Virtual Machine module, HYP part
3+#
4+
5+obj-$(CONFIG_KVM_ARM_HOST) += vgic-v2-sr.o
6+obj-$(CONFIG_KVM_ARM_HOST) += vgic-v3-sr.o
7+obj-$(CONFIG_KVM_ARM_HOST) += timer-sr.o
8+obj-$(CONFIG_KVM_ARM_HOST) += sysreg-sr.o
9+obj-$(CONFIG_KVM_ARM_HOST) += debug-sr.o
10+obj-$(CONFIG_KVM_ARM_HOST) += entry.o
11+obj-$(CONFIG_KVM_ARM_HOST) += switch.o
12+obj-$(CONFIG_KVM_ARM_HOST) += fpsimd.o
13+obj-$(CONFIG_KVM_ARM_HOST) += tlb.o
14+obj-$(CONFIG_KVM_ARM_HOST) += hyp-entry.o
arch/arm64/kvm/hyp/debug-sr.c+140−0
@@ -0,0 +1,140 @@
1+/*
2+ * Copyright (C) 2015 - ARM Ltd
3+ * Author: Marc Zyngier <marc.zyngier@arm.com>
4+ *
5+ * This program is free software; you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License version 2 as
7+ * published by the Free Software Foundation.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+#include <linux/compiler.h>
19+#include <linux/kvm_host.h>
20+
21+#include <asm/kvm_asm.h>
22+#include <asm/kvm_mmu.h>
23+
24+#include "hyp.h"
25+
26+#define read_debug(r,n) read_sysreg(r##n##_el1)
27+#define write_debug(v,r,n) write_sysreg(v, r##n##_el1)
28+
29+#define save_debug(ptr,reg,nr) \
30+ switch (nr) { \
31+ case 15: ptr[15] = read_debug(reg, 15); \
32+ case 14: ptr[14] = read_debug(reg, 14); \
33+ case 13: ptr[13] = read_debug(reg, 13); \
34+ case 12: ptr[12] = read_debug(reg, 12); \
35+ case 11: ptr[11] = read_debug(reg, 11); \
36+ case 10: ptr[10] = read_debug(reg, 10); \
37+ case 9: ptr[9] = read_debug(reg, 9); \
38+ case 8: ptr[8] = read_debug(reg, 8); \
39+ case 7: ptr[7] = read_debug(reg, 7); \
40+ case 6: ptr[6] = read_debug(reg, 6); \
41+ case 5: ptr[5] = read_debug(reg, 5); \
42+ case 4: ptr[4] = read_debug(reg, 4); \
43+ case 3: ptr[3] = read_debug(reg, 3); \
44+ case 2: ptr[2] = read_debug(reg, 2); \
45+ case 1: ptr[1] = read_debug(reg, 1); \
46+ default: ptr[0] = read_debug(reg, 0); \
47+ }
48+
49+#define restore_debug(ptr,reg,nr) \
50+ switch (nr) { \
51+ case 15: write_debug(ptr[15], reg, 15); \
52+ case 14: write_debug(ptr[14], reg, 14); \
53+ case 13: write_debug(ptr[13], reg, 13); \
54+ case 12: write_debug(ptr[12], reg, 12); \
55+ case 11: write_debug(ptr[11], reg, 11); \
56+ case 10: write_debug(ptr[10], reg, 10); \
57+ case 9: write_debug(ptr[9], reg, 9); \
58+ case 8: write_debug(ptr[8], reg, 8); \
59+ case 7: write_debug(ptr[7], reg, 7); \
60+ case 6: write_debug(ptr[6], reg, 6); \
61+ case 5: write_debug(ptr[5], reg, 5); \
62+ case 4: write_debug(ptr[4], reg, 4); \
63+ case 3: write_debug(ptr[3], reg, 3); \
64+ case 2: write_debug(ptr[2], reg, 2); \
65+ case 1: write_debug(ptr[1], reg, 1); \
66+ default: write_debug(ptr[0], reg, 0); \
67+ }
68+
69+void __hyp_text __debug_save_state(struct kvm_vcpu *vcpu,
70+ struct kvm_guest_debug_arch *dbg,
71+ struct kvm_cpu_context *ctxt)
72+{
73+ u64 aa64dfr0;
74+ int brps, wrps;
75+
76+ if (!(vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY))
77+ return;
78+
79+ aa64dfr0 = read_sysreg(id_aa64dfr0_el1);
80+ brps = (aa64dfr0 >> 12) & 0xf;
81+ wrps = (aa64dfr0 >> 20) & 0xf;
82+
83+ save_debug(dbg->dbg_bcr, dbgbcr, brps);
84+ save_debug(dbg->dbg_bvr, dbgbvr, brps);
85+ save_debug(dbg->dbg_wcr, dbgwcr, wrps);
86+ save_debug(dbg->dbg_wvr, dbgwvr, wrps);
87+
88+ ctxt->sys_regs[MDCCINT_EL1] = read_sysreg(mdccint_el1);
89+}
90+
91+void __hyp_text __debug_restore_state(struct kvm_vcpu *vcpu,
92+ struct kvm_guest_debug_arch *dbg,
93+ struct kvm_cpu_context *ctxt)
94+{
95+ u64 aa64dfr0;
96+ int brps, wrps;
97+
98+ if (!(vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY))
99+ return;
100+
101+ aa64dfr0 = read_sysreg(id_aa64dfr0_el1);
102+
103+ brps = (aa64dfr0 >> 12) & 0xf;
104+ wrps = (aa64dfr0 >> 20) & 0xf;
105+
106+ restore_debug(dbg->dbg_bcr, dbgbcr, brps);
107+ restore_debug(dbg->dbg_bvr, dbgbvr, brps);
108+ restore_debug(dbg->dbg_wcr, dbgwcr, wrps);
109+ restore_debug(dbg->dbg_wvr, dbgwvr, wrps);
110+
111+ write_sysreg(ctxt->sys_regs[MDCCINT_EL1], mdccint_el1);
112+}
113+
114+void __hyp_text __debug_cond_save_host_state(struct kvm_vcpu *vcpu)
115+{
116+ /* If any of KDE, MDE or KVM_ARM64_DEBUG_DIRTY is set, perform
117+ * a full save/restore cycle. */
118+ if ((vcpu->arch.ctxt.sys_regs[MDSCR_EL1] & DBG_MDSCR_KDE) ||
119+ (vcpu->arch.ctxt.sys_regs[MDSCR_EL1] & DBG_MDSCR_MDE))
120+ vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY;
121+
122+ __debug_save_state(vcpu, &vcpu->arch.host_debug_state,
123+ kern_hyp_va(vcpu->arch.host_cpu_context));
124+}
125+
126+void __hyp_text __debug_cond_restore_host_state(struct kvm_vcpu *vcpu)
127+{
128+ __debug_restore_state(vcpu, &vcpu->arch.host_debug_state,
129+ kern_hyp_va(vcpu->arch.host_cpu_context));
130+
131+ if (vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY)
132+ vcpu->arch.debug_flags &= ~KVM_ARM64_DEBUG_DIRTY;
133+}
134+
135+static u32 __hyp_text __debug_read_mdcr_el2(void)
136+{
137+ return read_sysreg(mdcr_el2);
138+}
139+
140+__alias(__debug_read_mdcr_el2) u32 __kvm_get_mdcr_el2(void);
arch/arm64/kvm/hyp/entry.S+160−0
@@ -0,0 +1,160 @@
1+/*
2+ * Copyright (C) 2015 - ARM Ltd
3+ * Author: Marc Zyngier <marc.zyngier@arm.com>
4+ *
5+ * This program is free software; you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License version 2 as
7+ * published by the Free Software Foundation.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+#include <linux/linkage.h>
19+
20+#include <asm/asm-offsets.h>
21+#include <asm/assembler.h>
22+#include <asm/fpsimdmacros.h>
23+#include <asm/kvm.h>
24+#include <asm/kvm_arm.h>
25+#include <asm/kvm_asm.h>
26+#include <asm/kvm_mmu.h>
27+
28+#define CPU_GP_REG_OFFSET(x) (CPU_GP_REGS + x)
29+#define CPU_XREG_OFFSET(x) CPU_GP_REG_OFFSET(CPU_USER_PT_REGS + 8*x)
30+
31+ .text
32+ .pushsection .hyp.text, "ax"
33+
34+.macro save_callee_saved_regs ctxt
35+ stp x19, x20, [\ctxt, #CPU_XREG_OFFSET(19)]
36+ stp x21, x22, [\ctxt, #CPU_XREG_OFFSET(21)]
37+ stp x23, x24, [\ctxt, #CPU_XREG_OFFSET(23)]
38+ stp x25, x26, [\ctxt, #CPU_XREG_OFFSET(25)]
39+ stp x27, x28, [\ctxt, #CPU_XREG_OFFSET(27)]
40+ stp x29, lr, [\ctxt, #CPU_XREG_OFFSET(29)]
41+.endm
42+
43+.macro restore_callee_saved_regs ctxt
44+ ldp x19, x20, [\ctxt, #CPU_XREG_OFFSET(19)]
45+ ldp x21, x22, [\ctxt, #CPU_XREG_OFFSET(21)]
46+ ldp x23, x24, [\ctxt, #CPU_XREG_OFFSET(23)]
47+ ldp x25, x26, [\ctxt, #CPU_XREG_OFFSET(25)]
48+ ldp x27, x28, [\ctxt, #CPU_XREG_OFFSET(27)]
49+ ldp x29, lr, [\ctxt, #CPU_XREG_OFFSET(29)]
50+.endm
51+
52+/*
53+ * u64 __guest_enter(struct kvm_vcpu *vcpu,
54+ * struct kvm_cpu_context *host_ctxt);
55+ */
56+ENTRY(__guest_enter)
57+ // x0: vcpu
58+ // x1: host/guest context
59+ // x2-x18: clobbered by macros
60+
61+ // Store the host regs
62+ save_callee_saved_regs x1
63+
64+ // Preserve vcpu & host_ctxt for use at exit time
65+ stp x0, x1, [sp, #-16]!
66+
67+ add x1, x0, #VCPU_CONTEXT
68+
69+ // Prepare x0-x1 for later restore by pushing them onto the stack
70+ ldp x2, x3, [x1, #CPU_XREG_OFFSET(0)]
71+ stp x2, x3, [sp, #-16]!
72+
73+ // x2-x18
74+ ldp x2, x3, [x1, #CPU_XREG_OFFSET(2)]
75+ ldp x4, x5, [x1, #CPU_XREG_OFFSET(4)]
76+ ldp x6, x7, [x1, #CPU_XREG_OFFSET(6)]
77+ ldp x8, x9, [x1, #CPU_XREG_OFFSET(8)]
78+ ldp x10, x11, [x1, #CPU_XREG_OFFSET(10)]
79+ ldp x12, x13, [x1, #CPU_XREG_OFFSET(12)]
80+ ldp x14, x15, [x1, #CPU_XREG_OFFSET(14)]
81+ ldp x16, x17, [x1, #CPU_XREG_OFFSET(16)]
82+ ldr x18, [x1, #CPU_XREG_OFFSET(18)]
83+
84+ // x19-x29, lr
85+ restore_callee_saved_regs x1
86+
87+ // Last bits of the 64bit state
88+ ldp x0, x1, [sp], #16
89+
90+ // Do not touch any register after this!
91+ eret
92+ENDPROC(__guest_enter)
93+
94+ENTRY(__guest_exit)
95+ // x0: vcpu
96+ // x1: return code
97+ // x2-x3: free
98+ // x4-x29,lr: vcpu regs
99+ // vcpu x0-x3 on the stack
100+
101+ add x2, x0, #VCPU_CONTEXT
102+
103+ stp x4, x5, [x2, #CPU_XREG_OFFSET(4)]
104+ stp x6, x7, [x2, #CPU_XREG_OFFSET(6)]
105+ stp x8, x9, [x2, #CPU_XREG_OFFSET(8)]
106+ stp x10, x11, [x2, #CPU_XREG_OFFSET(10)]
107+ stp x12, x13, [x2, #CPU_XREG_OFFSET(12)]
108+ stp x14, x15, [x2, #CPU_XREG_OFFSET(14)]
109+ stp x16, x17, [x2, #CPU_XREG_OFFSET(16)]
110+ str x18, [x2, #CPU_XREG_OFFSET(18)]
111+
112+ ldp x6, x7, [sp], #16 // x2, x3
113+ ldp x4, x5, [sp], #16 // x0, x1
114+
115+ stp x4, x5, [x2, #CPU_XREG_OFFSET(0)]
116+ stp x6, x7, [x2, #CPU_XREG_OFFSET(2)]
117+
118+ save_callee_saved_regs x2
119+
120+ // Restore vcpu & host_ctxt from the stack
121+ // (preserving return code in x1)
122+ ldp x0, x2, [sp], #16
123+ // Now restore the host regs
124+ restore_callee_saved_regs x2
125+
126+ mov x0, x1
127+ ret
128+ENDPROC(__guest_exit)
129+
130+ENTRY(__fpsimd_guest_restore)
131+ stp x4, lr, [sp, #-16]!
132+
133+ mrs x2, cptr_el2
134+ bic x2, x2, #CPTR_EL2_TFP
135+ msr cptr_el2, x2
136+ isb
137+
138+ mrs x3, tpidr_el2
139+
140+ ldr x0, [x3, #VCPU_HOST_CONTEXT]
141+ kern_hyp_va x0
142+ add x0, x0, #CPU_GP_REG_OFFSET(CPU_FP_REGS)
143+ bl __fpsimd_save_state
144+
145+ add x2, x3, #VCPU_CONTEXT
146+ add x0, x2, #CPU_GP_REG_OFFSET(CPU_FP_REGS)
147+ bl __fpsimd_restore_state
148+
149+ // Skip restoring fpexc32 for AArch64 guests
150+ mrs x1, hcr_el2
151+ tbnz x1, #HCR_RW_SHIFT, 1f
152+ ldr x4, [x3, #VCPU_FPEXC32_EL2]
153+ msr fpexc32_el2, x4
154+1:
155+ ldp x4, lr, [sp], #16
156+ ldp x2, x3, [sp], #16
157+ ldp x0, x1, [sp], #16
158+
159+ eret
160+ENDPROC(__fpsimd_guest_restore)
arch/arm64/kvm/hyp/fpsimd.S+33−0
@@ -0,0 +1,33 @@
1+/*
2+ * Copyright (C) 2015 - ARM Ltd
3+ * Author: Marc Zyngier <marc.zyngier@arm.com>
4+ *
5+ * This program is free software; you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License version 2 as
7+ * published by the Free Software Foundation.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+#include <linux/linkage.h>
19+
20+#include <asm/fpsimdmacros.h>
21+
22+ .text
23+ .pushsection .hyp.text, "ax"
24+
25+ENTRY(__fpsimd_save_state)
26+ fpsimd_save x0, 1
27+ ret
28+ENDPROC(__fpsimd_save_state)
29+
30+ENTRY(__fpsimd_restore_state)
31+ fpsimd_restore x0, 1
32+ ret
33+ENDPROC(__fpsimd_restore_state)
arch/arm64/kvm/hyp/hyp-entry.S+212−0
@@ -0,0 +1,212 @@
1+/*
2+ * Copyright (C) 2015 - ARM Ltd
3+ * Author: Marc Zyngier <marc.zyngier@arm.com>
4+ *
5+ * This program is free software; you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License version 2 as
7+ * published by the Free Software Foundation.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+#include <linux/linkage.h>
19+
20+#include <asm/alternative.h>
21+#include <asm/assembler.h>
22+#include <asm/asm-offsets.h>
23+#include <asm/cpufeature.h>
24+#include <asm/kvm_arm.h>
25+#include <asm/kvm_asm.h>
26+#include <asm/kvm_mmu.h>
27+
28+ .text
29+ .pushsection .hyp.text, "ax"
30+
31+.macro save_x0_to_x3
32+ stp x0, x1, [sp, #-16]!
33+ stp x2, x3, [sp, #-16]!
34+.endm
35+
36+.macro restore_x0_to_x3
37+ ldp x2, x3, [sp], #16
38+ ldp x0, x1, [sp], #16
39+.endm
40+
41+el1_sync: // Guest trapped into EL2
42+ save_x0_to_x3
43+
44+ mrs x1, esr_el2
45+ lsr x2, x1, #ESR_ELx_EC_SHIFT
46+
47+ cmp x2, #ESR_ELx_EC_HVC64
48+ b.ne el1_trap
49+
50+ mrs x3, vttbr_el2 // If vttbr is valid, the 64bit guest
51+ cbnz x3, el1_trap // called HVC
52+
53+ /* Here, we're pretty sure the host called HVC. */
54+ restore_x0_to_x3
55+
56+ /* Check for __hyp_get_vectors */
57+ cbnz x0, 1f
58+ mrs x0, vbar_el2
59+ b 2f
60+
61+1: stp lr, xzr, [sp, #-16]!
62+
63+ /*
64+ * Compute the function address in EL2, and shuffle the parameters.
65+ */
66+ kern_hyp_va x0
67+ mov lr, x0
68+ mov x0, x1
69+ mov x1, x2
70+ mov x2, x3
71+ blr lr
72+
73+ ldp lr, xzr, [sp], #16
74+2: eret
75+
76+el1_trap:
77+ /*
78+ * x1: ESR
79+ * x2: ESR_EC
80+ */
81+
82+ /* Guest accessed VFP/SIMD registers, save host, restore Guest */
83+ cmp x2, #ESR_ELx_EC_FP_ASIMD
84+ b.eq __fpsimd_guest_restore
85+
86+ cmp x2, #ESR_ELx_EC_DABT_LOW
87+ mov x0, #ESR_ELx_EC_IABT_LOW
88+ ccmp x2, x0, #4, ne
89+ b.ne 1f // Not an abort we care about
90+
91+ /* This is an abort. Check for permission fault */
92+alternative_if_not ARM64_WORKAROUND_834220
93+ and x2, x1, #ESR_ELx_FSC_TYPE
94+ cmp x2, #FSC_PERM
95+ b.ne 1f // Not a permission fault
96+alternative_else
97+ nop // Use the permission fault path to
98+ nop // check for a valid S1 translation,
99+ nop // regardless of the ESR value.
100+alternative_endif
101+
102+ /*
103+ * Check for Stage-1 page table walk, which is guaranteed
104+ * to give a valid HPFAR_EL2.
105+ */
106+ tbnz x1, #7, 1f // S1PTW is set
107+
108+ /* Preserve PAR_EL1 */
109+ mrs x3, par_el1
110+ stp x3, xzr, [sp, #-16]!
111+
112+ /*
113+ * Permission fault, HPFAR_EL2 is invalid.
114+ * Resolve the IPA the hard way using the guest VA.
115+ * Stage-1 translation already validated the memory access rights.
116+ * As such, we can use the EL1 translation regime, and don't have
117+ * to distinguish between EL0 and EL1 access.
118+ */
119+ mrs x2, far_el2
120+ at s1e1r, x2
121+ isb
122+
123+ /* Read result */
124+ mrs x3, par_el1
125+ ldp x0, xzr, [sp], #16 // Restore PAR_EL1 from the stack
126+ msr par_el1, x0
127+ tbnz x3, #0, 3f // Bail out if we failed the translation
128+ ubfx x3, x3, #12, #36 // Extract IPA
129+ lsl x3, x3, #4 // and present it like HPFAR
130+ b 2f
131+
132+1: mrs x3, hpfar_el2
133+ mrs x2, far_el2
134+
135+2: mrs x0, tpidr_el2
136+ str w1, [x0, #VCPU_ESR_EL2]
137+ str x2, [x0, #VCPU_FAR_EL2]
138+ str x3, [x0, #VCPU_HPFAR_EL2]
139+
140+ mov x1, #ARM_EXCEPTION_TRAP
141+ b __guest_exit
142+
143+ /*
144+ * Translation failed. Just return to the guest and
145+ * let it fault again. Another CPU is probably playing
146+ * behind our back.
147+ */
148+3: restore_x0_to_x3
149+
150+ eret
151+
152+el1_irq:
153+ save_x0_to_x3
154+ mrs x0, tpidr_el2
155+ mov x1, #ARM_EXCEPTION_IRQ
156+ b __guest_exit
157+
158+ENTRY(__hyp_do_panic)
159+ mov lr, #(PSR_F_BIT | PSR_I_BIT | PSR_A_BIT | PSR_D_BIT |\
160+ PSR_MODE_EL1h)
161+ msr spsr_el2, lr
162+ ldr lr, =panic
163+ msr elr_el2, lr
164+ eret
165+ENDPROC(__hyp_do_panic)
166+
167+.macro invalid_vector label, target = __hyp_panic
168+ .align 2
169+\label:
170+ b \target
171+ENDPROC(\label)
172+.endm
173+
174+ /* None of these should ever happen */
175+ invalid_vector el2t_sync_invalid
176+ invalid_vector el2t_irq_invalid
177+ invalid_vector el2t_fiq_invalid
178+ invalid_vector el2t_error_invalid
179+ invalid_vector el2h_sync_invalid
180+ invalid_vector el2h_irq_invalid
181+ invalid_vector el2h_fiq_invalid
182+ invalid_vector el2h_error_invalid
183+ invalid_vector el1_sync_invalid
184+ invalid_vector el1_irq_invalid
185+ invalid_vector el1_fiq_invalid
186+ invalid_vector el1_error_invalid
187+
188+ .ltorg
189+
190+ .align 11
191+
192+ENTRY(__kvm_hyp_vector)
193+ ventry el2t_sync_invalid // Synchronous EL2t
194+ ventry el2t_irq_invalid // IRQ EL2t
195+ ventry el2t_fiq_invalid // FIQ EL2t
196+ ventry el2t_error_invalid // Error EL2t
197+
198+ ventry el2h_sync_invalid // Synchronous EL2h
199+ ventry el2h_irq_invalid // IRQ EL2h
200+ ventry el2h_fiq_invalid // FIQ EL2h
201+ ventry el2h_error_invalid // Error EL2h
202+
203+ ventry el1_sync // Synchronous 64-bit EL1
204+ ventry el1_irq // IRQ 64-bit EL1
205+ ventry el1_fiq_invalid // FIQ 64-bit EL1
206+ ventry el1_error_invalid // Error 64-bit EL1
207+
208+ ventry el1_sync // Synchronous 32-bit EL1
209+ ventry el1_irq // IRQ 32-bit EL1
210+ ventry el1_fiq_invalid // FIQ 32-bit EL1
211+ ventry el1_error_invalid // Error 32-bit EL1
212+ENDPROC(__kvm_hyp_vector)
arch/arm64/kvm/hyp/hyp.h+90−0
@@ -0,0 +1,90 @@
1+/*
2+ * Copyright (C) 2015 - ARM Ltd
3+ * Author: Marc Zyngier <marc.zyngier@arm.com>
4+ *
5+ * This program is free software; you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License version 2 as
7+ * published by the Free Software Foundation.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+#ifndef __ARM64_KVM_HYP_H__
19+#define __ARM64_KVM_HYP_H__
20+
21+#include <linux/compiler.h>
22+#include <linux/kvm_host.h>
23+#include <asm/kvm_mmu.h>
24+#include <asm/sysreg.h>
25+
26+#define __hyp_text __section(.hyp.text) notrace
27+
28+#define kern_hyp_va(v) (typeof(v))((unsigned long)(v) & HYP_PAGE_OFFSET_MASK)
29+#define hyp_kern_va(v) (typeof(v))((unsigned long)(v) - HYP_PAGE_OFFSET \
30+ + PAGE_OFFSET)
31+
32+/**
33+ * hyp_alternate_select - Generates patchable code sequences that are
34+ * used to switch between two implementations of a function, depending
35+ * on the availability of a feature.
36+ *
37+ * @fname: a symbol name that will be defined as a function returning a
38+ * function pointer whose type will match @orig and @alt
39+ * @orig: A pointer to the default function, as returned by @fname when
40+ * @cond doesn't hold
41+ * @alt: A pointer to the alternate function, as returned by @fname
42+ * when @cond holds
43+ * @cond: a CPU feature (as described in asm/cpufeature.h)
44+ */
45+#define hyp_alternate_select(fname, orig, alt, cond) \
46+typeof(orig) * __hyp_text fname(void) \
47+{ \
48+ typeof(alt) *val = orig; \
49+ asm volatile(ALTERNATIVE("nop \n", \
50+ "mov %0, %1 \n", \
51+ cond) \
52+ : "+r" (val) : "r" (alt)); \
53+ return val; \
54+}
55+
56+void __vgic_v2_save_state(struct kvm_vcpu *vcpu);
57+void __vgic_v2_restore_state(struct kvm_vcpu *vcpu);
58+
59+void __vgic_v3_save_state(struct kvm_vcpu *vcpu);
60+void __vgic_v3_restore_state(struct kvm_vcpu *vcpu);
61+
62+void __timer_save_state(struct kvm_vcpu *vcpu);
63+void __timer_restore_state(struct kvm_vcpu *vcpu);
64+
65+void __sysreg_save_state(struct kvm_cpu_context *ctxt);
66+void __sysreg_restore_state(struct kvm_cpu_context *ctxt);
67+void __sysreg32_save_state(struct kvm_vcpu *vcpu);
68+void __sysreg32_restore_state(struct kvm_vcpu *vcpu);
69+
70+void __debug_save_state(struct kvm_vcpu *vcpu,
71+ struct kvm_guest_debug_arch *dbg,
72+ struct kvm_cpu_context *ctxt);
73+void __debug_restore_state(struct kvm_vcpu *vcpu,
74+ struct kvm_guest_debug_arch *dbg,
75+ struct kvm_cpu_context *ctxt);
76+void __debug_cond_save_host_state(struct kvm_vcpu *vcpu);
77+void __debug_cond_restore_host_state(struct kvm_vcpu *vcpu);
78+
79+void __fpsimd_save_state(struct user_fpsimd_state *fp_regs);
80+void __fpsimd_restore_state(struct user_fpsimd_state *fp_regs);
81+static inline bool __fpsimd_enabled(void)
82+{
83+ return !(read_sysreg(cptr_el2) & CPTR_EL2_TFP);
84+}
85+
86+u64 __guest_enter(struct kvm_vcpu *vcpu, struct kvm_cpu_context *host_ctxt);
87+void __noreturn __hyp_do_panic(unsigned long, ...);
88+
89+#endif /* __ARM64_KVM_HYP_H__ */
90+
arch/arm64/kvm/hyp/switch.c+175−0
@@ -0,0 +1,175 @@
1+/*
2+ * Copyright (C) 2015 - ARM Ltd
3+ * Author: Marc Zyngier <marc.zyngier@arm.com>
4+ *
5+ * This program is free software; you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License version 2 as
7+ * published by the Free Software Foundation.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+#include "hyp.h"
19+
20+static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu)
21+{
22+ u64 val;
23+
24+ /*
25+ * We are about to set CPTR_EL2.TFP to trap all floating point
26+ * register accesses to EL2, however, the ARM ARM clearly states that
27+ * traps are only taken to EL2 if the operation would not otherwise
28+ * trap to EL1. Therefore, always make sure that for 32-bit guests,
29+ * we set FPEXC.EN to prevent traps to EL1, when setting the TFP bit.
30+ */
31+ val = vcpu->arch.hcr_el2;
32+ if (!(val & HCR_RW)) {
33+ write_sysreg(1 << 30, fpexc32_el2);
34+ isb();
35+ }
36+ write_sysreg(val, hcr_el2);
37+ /* Trap on AArch32 cp15 c15 accesses (EL1 or EL0) */
38+ write_sysreg(1 << 15, hstr_el2);
39+ write_sysreg(CPTR_EL2_TTA | CPTR_EL2_TFP, cptr_el2);
40+ write_sysreg(vcpu->arch.mdcr_el2, mdcr_el2);
41+}
42+
43+static void __hyp_text __deactivate_traps(struct kvm_vcpu *vcpu)
44+{
45+ write_sysreg(HCR_RW, hcr_el2);
46+ write_sysreg(0, hstr_el2);
47+ write_sysreg(read_sysreg(mdcr_el2) & MDCR_EL2_HPMN_MASK, mdcr_el2);
48+ write_sysreg(0, cptr_el2);
49+}
50+
51+static void __hyp_text __activate_vm(struct kvm_vcpu *vcpu)
52+{
53+ struct kvm *kvm = kern_hyp_va(vcpu->kvm);
54+ write_sysreg(kvm->arch.vttbr, vttbr_el2);
55+}
56+
57+static void __hyp_text __deactivate_vm(struct kvm_vcpu *vcpu)
58+{
59+ write_sysreg(0, vttbr_el2);
60+}
61+
62+static hyp_alternate_select(__vgic_call_save_state,
63+ __vgic_v2_save_state, __vgic_v3_save_state,
64+ ARM64_HAS_SYSREG_GIC_CPUIF);
65+
66+static hyp_alternate_select(__vgic_call_restore_state,
67+ __vgic_v2_restore_state, __vgic_v3_restore_state,
68+ ARM64_HAS_SYSREG_GIC_CPUIF);
69+
70+static void __hyp_text __vgic_save_state(struct kvm_vcpu *vcpu)
71+{
72+ __vgic_call_save_state()(vcpu);
73+ write_sysreg(read_sysreg(hcr_el2) & ~HCR_INT_OVERRIDE, hcr_el2);
74+}
75+
76+static void __hyp_text __vgic_restore_state(struct kvm_vcpu *vcpu)
77+{
78+ u64 val;
79+
80+ val = read_sysreg(hcr_el2);
81+ val |= HCR_INT_OVERRIDE;
82+ val |= vcpu->arch.irq_lines;
83+ write_sysreg(val, hcr_el2);
84+
85+ __vgic_call_restore_state()(vcpu);
86+}
87+
88+static int __hyp_text __guest_run(struct kvm_vcpu *vcpu)
89+{
90+ struct kvm_cpu_context *host_ctxt;
91+ struct kvm_cpu_context *guest_ctxt;
92+ bool fp_enabled;
93+ u64 exit_code;
94+
95+ vcpu = kern_hyp_va(vcpu);
96+ write_sysreg(vcpu, tpidr_el2);
97+
98+ host_ctxt = kern_hyp_va(vcpu->arch.host_cpu_context);
99+ guest_ctxt = &vcpu->arch.ctxt;
100+
101+ __sysreg_save_state(host_ctxt);
102+ __debug_cond_save_host_state(vcpu);
103+
104+ __activate_traps(vcpu);
105+ __activate_vm(vcpu);
106+
107+ __vgic_restore_state(vcpu);
108+ __timer_restore_state(vcpu);
109+
110+ /*
111+ * We must restore the 32-bit state before the sysregs, thanks
112+ * to Cortex-A57 erratum #852523.
113+ */
114+ __sysreg32_restore_state(vcpu);
115+ __sysreg_restore_state(guest_ctxt);
116+ __debug_restore_state(vcpu, kern_hyp_va(vcpu->arch.debug_ptr), guest_ctxt);
117+
118+ /* Jump in the fire! */
119+ exit_code = __guest_enter(vcpu, host_ctxt);
120+ /* And we're baaack! */
121+
122+ fp_enabled = __fpsimd_enabled();
123+
124+ __sysreg_save_state(guest_ctxt);
125+ __sysreg32_save_state(vcpu);
126+ __timer_save_state(vcpu);
127+ __vgic_save_state(vcpu);
128+
129+ __deactivate_traps(vcpu);
130+ __deactivate_vm(vcpu);
131+
132+ __sysreg_restore_state(host_ctxt);
133+
134+ if (fp_enabled) {
135+ __fpsimd_save_state(&guest_ctxt->gp_regs.fp_regs);
136+ __fpsimd_restore_state(&host_ctxt->gp_regs.fp_regs);
137+ }
138+
139+ __debug_save_state(vcpu, kern_hyp_va(vcpu->arch.debug_ptr), guest_ctxt);
140+ __debug_cond_restore_host_state(vcpu);
141+
142+ return exit_code;
143+}
144+
145+__alias(__guest_run) int __kvm_vcpu_run(struct kvm_vcpu *vcpu);
146+
147+static const char __hyp_panic_string[] = "HYP panic:\nPS:%08llx PC:%016llx ESR:%08llx\nFAR:%016llx HPFAR:%016llx PAR:%016llx\nVCPU:%p\n";
148+
149+void __hyp_text __noreturn __hyp_panic(void)
150+{
151+ unsigned long str_va = (unsigned long)__hyp_panic_string;
152+ u64 spsr = read_sysreg(spsr_el2);
153+ u64 elr = read_sysreg(elr_el2);
154+ u64 par = read_sysreg(par_el1);
155+
156+ if (read_sysreg(vttbr_el2)) {
157+ struct kvm_vcpu *vcpu;
158+ struct kvm_cpu_context *host_ctxt;
159+
160+ vcpu = (struct kvm_vcpu *)read_sysreg(tpidr_el2);
161+ host_ctxt = kern_hyp_va(vcpu->arch.host_cpu_context);
162+ __deactivate_traps(vcpu);
163+ __deactivate_vm(vcpu);
164+ __sysreg_restore_state(host_ctxt);
165+ }
166+
167+ /* Call panic for real */
168+ __hyp_do_panic(hyp_kern_va(str_va),
169+ spsr, elr,
170+ read_sysreg(esr_el2), read_sysreg(far_el2),
171+ read_sysreg(hpfar_el2), par,
172+ (void *)read_sysreg(tpidr_el2));
173+
174+ unreachable();
175+}
arch/arm64/kvm/hyp/sysreg-sr.c+138−0
@@ -0,0 +1,138 @@
1+/*
2+ * Copyright (C) 2012-2015 - ARM Ltd
3+ * Author: Marc Zyngier <marc.zyngier@arm.com>
4+ *
5+ * This program is free software; you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License version 2 as
7+ * published by the Free Software Foundation.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+#include <linux/compiler.h>
19+#include <linux/kvm_host.h>
20+
21+#include <asm/kvm_asm.h>
22+#include <asm/kvm_mmu.h>
23+
24+#include "hyp.h"
25+
26+/* ctxt is already in the HYP VA space */
27+void __hyp_text __sysreg_save_state(struct kvm_cpu_context *ctxt)
28+{
29+ ctxt->sys_regs[MPIDR_EL1] = read_sysreg(vmpidr_el2);
30+ ctxt->sys_regs[CSSELR_EL1] = read_sysreg(csselr_el1);
31+ ctxt->sys_regs[SCTLR_EL1] = read_sysreg(sctlr_el1);
32+ ctxt->sys_regs[ACTLR_EL1] = read_sysreg(actlr_el1);
33+ ctxt->sys_regs[CPACR_EL1] = read_sysreg(cpacr_el1);
34+ ctxt->sys_regs[TTBR0_EL1] = read_sysreg(ttbr0_el1);
35+ ctxt->sys_regs[TTBR1_EL1] = read_sysreg(ttbr1_el1);
36+ ctxt->sys_regs[TCR_EL1] = read_sysreg(tcr_el1);
37+ ctxt->sys_regs[ESR_EL1] = read_sysreg(esr_el1);
38+ ctxt->sys_regs[AFSR0_EL1] = read_sysreg(afsr0_el1);
39+ ctxt->sys_regs[AFSR1_EL1] = read_sysreg(afsr1_el1);
40+ ctxt->sys_regs[FAR_EL1] = read_sysreg(far_el1);
41+ ctxt->sys_regs[MAIR_EL1] = read_sysreg(mair_el1);
42+ ctxt->sys_regs[VBAR_EL1] = read_sysreg(vbar_el1);
43+ ctxt->sys_regs[CONTEXTIDR_EL1] = read_sysreg(contextidr_el1);
44+ ctxt->sys_regs[TPIDR_EL0] = read_sysreg(tpidr_el0);
45+ ctxt->sys_regs[TPIDRRO_EL0] = read_sysreg(tpidrro_el0);
46+ ctxt->sys_regs[TPIDR_EL1] = read_sysreg(tpidr_el1);
47+ ctxt->sys_regs[AMAIR_EL1] = read_sysreg(amair_el1);
48+ ctxt->sys_regs[CNTKCTL_EL1] = read_sysreg(cntkctl_el1);
49+ ctxt->sys_regs[PAR_EL1] = read_sysreg(par_el1);
50+ ctxt->sys_regs[MDSCR_EL1] = read_sysreg(mdscr_el1);
51+
52+ ctxt->gp_regs.regs.sp = read_sysreg(sp_el0);
53+ ctxt->gp_regs.regs.pc = read_sysreg(elr_el2);
54+ ctxt->gp_regs.regs.pstate = read_sysreg(spsr_el2);
55+ ctxt->gp_regs.sp_el1 = read_sysreg(sp_el1);
56+ ctxt->gp_regs.elr_el1 = read_sysreg(elr_el1);
57+ ctxt->gp_regs.spsr[KVM_SPSR_EL1]= read_sysreg(spsr_el1);
58+}
59+
60+void __hyp_text __sysreg_restore_state(struct kvm_cpu_context *ctxt)
61+{
62+ write_sysreg(ctxt->sys_regs[MPIDR_EL1], vmpidr_el2);
63+ write_sysreg(ctxt->sys_regs[CSSELR_EL1], csselr_el1);
64+ write_sysreg(ctxt->sys_regs[SCTLR_EL1], sctlr_el1);
65+ write_sysreg(ctxt->sys_regs[ACTLR_EL1], actlr_el1);
66+ write_sysreg(ctxt->sys_regs[CPACR_EL1], cpacr_el1);
67+ write_sysreg(ctxt->sys_regs[TTBR0_EL1], ttbr0_el1);
68+ write_sysreg(ctxt->sys_regs[TTBR1_EL1], ttbr1_el1);
69+ write_sysreg(ctxt->sys_regs[TCR_EL1], tcr_el1);
70+ write_sysreg(ctxt->sys_regs[ESR_EL1], esr_el1);
71+ write_sysreg(ctxt->sys_regs[AFSR0_EL1], afsr0_el1);
72+ write_sysreg(ctxt->sys_regs[AFSR1_EL1], afsr1_el1);
73+ write_sysreg(ctxt->sys_regs[FAR_EL1], far_el1);
74+ write_sysreg(ctxt->sys_regs[MAIR_EL1], mair_el1);
75+ write_sysreg(ctxt->sys_regs[VBAR_EL1], vbar_el1);
76+ write_sysreg(ctxt->sys_regs[CONTEXTIDR_EL1], contextidr_el1);
77+ write_sysreg(ctxt->sys_regs[TPIDR_EL0], tpidr_el0);
78+ write_sysreg(ctxt->sys_regs[TPIDRRO_EL0], tpidrro_el0);
79+ write_sysreg(ctxt->sys_regs[TPIDR_EL1], tpidr_el1);
80+ write_sysreg(ctxt->sys_regs[AMAIR_EL1], amair_el1);
81+ write_sysreg(ctxt->sys_regs[CNTKCTL_EL1], cntkctl_el1);
82+ write_sysreg(ctxt->sys_regs[PAR_EL1], par_el1);
83+ write_sysreg(ctxt->sys_regs[MDSCR_EL1], mdscr_el1);
84+
85+ write_sysreg(ctxt->gp_regs.regs.sp, sp_el0);
86+ write_sysreg(ctxt->gp_regs.regs.pc, elr_el2);
87+ write_sysreg(ctxt->gp_regs.regs.pstate, spsr_el2);
88+ write_sysreg(ctxt->gp_regs.sp_el1, sp_el1);
89+ write_sysreg(ctxt->gp_regs.elr_el1, elr_el1);
90+ write_sysreg(ctxt->gp_regs.spsr[KVM_SPSR_EL1], spsr_el1);
91+}
92+
93+void __hyp_text __sysreg32_save_state(struct kvm_vcpu *vcpu)
94+{
95+ u64 *spsr, *sysreg;
96+
97+ if (read_sysreg(hcr_el2) & HCR_RW)
98+ return;
99+
100+ spsr = vcpu->arch.ctxt.gp_regs.spsr;
101+ sysreg = vcpu->arch.ctxt.sys_regs;
102+
103+ spsr[KVM_SPSR_ABT] = read_sysreg(spsr_abt);
104+ spsr[KVM_SPSR_UND] = read_sysreg(spsr_und);
105+ spsr[KVM_SPSR_IRQ] = read_sysreg(spsr_irq);
106+ spsr[KVM_SPSR_FIQ] = read_sysreg(spsr_fiq);
107+
108+ sysreg[DACR32_EL2] = read_sysreg(dacr32_el2);
109+ sysreg[IFSR32_EL2] = read_sysreg(ifsr32_el2);
110+
111+ if (__fpsimd_enabled())
112+ sysreg[FPEXC32_EL2] = read_sysreg(fpexc32_el2);
113+
114+ if (vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY)
115+ sysreg[DBGVCR32_EL2] = read_sysreg(dbgvcr32_el2);
116+}
117+
118+void __hyp_text __sysreg32_restore_state(struct kvm_vcpu *vcpu)
119+{
120+ u64 *spsr, *sysreg;
121+
122+ if (read_sysreg(hcr_el2) & HCR_RW)
123+ return;
124+
125+ spsr = vcpu->arch.ctxt.gp_regs.spsr;
126+ sysreg = vcpu->arch.ctxt.sys_regs;
127+
128+ write_sysreg(spsr[KVM_SPSR_ABT], spsr_abt);
129+ write_sysreg(spsr[KVM_SPSR_UND], spsr_und);
130+ write_sysreg(spsr[KVM_SPSR_IRQ], spsr_irq);
131+ write_sysreg(spsr[KVM_SPSR_FIQ], spsr_fiq);
132+
133+ write_sysreg(sysreg[DACR32_EL2], dacr32_el2);
134+ write_sysreg(sysreg[IFSR32_EL2], ifsr32_el2);
135+
136+ if (vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY)
137+ write_sysreg(sysreg[DBGVCR32_EL2], dbgvcr32_el2);
138+}
arch/arm64/kvm/hyp/timer-sr.c+71−0
@@ -0,0 +1,71 @@
1+/*
2+ * Copyright (C) 2012-2015 - ARM Ltd
3+ * Author: Marc Zyngier <marc.zyngier@arm.com>
4+ *
5+ * This program is free software; you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License version 2 as
7+ * published by the Free Software Foundation.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+#include <clocksource/arm_arch_timer.h>
19+#include <linux/compiler.h>
20+#include <linux/kvm_host.h>
21+
22+#include <asm/kvm_mmu.h>
23+
24+#include "hyp.h"
25+
26+/* vcpu is already in the HYP VA space */
27+void __hyp_text __timer_save_state(struct kvm_vcpu *vcpu)
28+{
29+ struct kvm *kvm = kern_hyp_va(vcpu->kvm);
30+ struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
31+ u64 val;
32+
33+ if (kvm->arch.timer.enabled) {
34+ timer->cntv_ctl = read_sysreg(cntv_ctl_el0);
35+ timer->cntv_cval = read_sysreg(cntv_cval_el0);
36+ }
37+
38+ /* Disable the virtual timer */
39+ write_sysreg(0, cntv_ctl_el0);
40+
41+ /* Allow physical timer/counter access for the host */
42+ val = read_sysreg(cnthctl_el2);
43+ val |= CNTHCTL_EL1PCTEN | CNTHCTL_EL1PCEN;
44+ write_sysreg(val, cnthctl_el2);
45+
46+ /* Clear cntvoff for the host */
47+ write_sysreg(0, cntvoff_el2);
48+}
49+
50+void __hyp_text __timer_restore_state(struct kvm_vcpu *vcpu)
51+{
52+ struct kvm *kvm = kern_hyp_va(vcpu->kvm);
53+ struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu;
54+ u64 val;
55+
56+ /*
57+ * Disallow physical timer access for the guest
58+ * Physical counter access is allowed
59+ */
60+ val = read_sysreg(cnthctl_el2);
61+ val &= ~CNTHCTL_EL1PCEN;
62+ val |= CNTHCTL_EL1PCTEN;
63+ write_sysreg(val, cnthctl_el2);
64+
65+ if (kvm->arch.timer.enabled) {
66+ write_sysreg(kvm->arch.timer.cntvoff, cntvoff_el2);
67+ write_sysreg(timer->cntv_cval, cntv_cval_el0);
68+ isb();
69+ write_sysreg(timer->cntv_ctl, cntv_ctl_el0);
70+ }
71+}
arch/arm64/kvm/hyp/tlb.c+80−0
@@ -0,0 +1,80 @@
1+/*
2+ * Copyright (C) 2015 - ARM Ltd
3+ * Author: Marc Zyngier <marc.zyngier@arm.com>
4+ *
5+ * This program is free software; you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License version 2 as
7+ * published by the Free Software Foundation.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+#include "hyp.h"
19+
20+static void __hyp_text __tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)
21+{
22+ dsb(ishst);
23+
24+ /* Switch to requested VMID */
25+ kvm = kern_hyp_va(kvm);
26+ write_sysreg(kvm->arch.vttbr, vttbr_el2);
27+ isb();
28+
29+ /*
30+ * We could do so much better if we had the VA as well.
31+ * Instead, we invalidate Stage-2 for this IPA, and the
32+ * whole of Stage-1. Weep...
33+ */
34+ ipa >>= 12;
35+ asm volatile("tlbi ipas2e1is, %0" : : "r" (ipa));
36+
37+ /*
38+ * We have to ensure completion of the invalidation at Stage-2,
39+ * since a table walk on another CPU could refill a TLB with a
40+ * complete (S1 + S2) walk based on the old Stage-2 mapping if
41+ * the Stage-1 invalidation happened first.
42+ */
43+ dsb(ish);
44+ asm volatile("tlbi vmalle1is" : : );
45+ dsb(ish);
46+ isb();
47+
48+ write_sysreg(0, vttbr_el2);
49+}
50+
51+__alias(__tlb_flush_vmid_ipa) void __kvm_tlb_flush_vmid_ipa(struct kvm *kvm,
52+ phys_addr_t ipa);
53+
54+static void __hyp_text __tlb_flush_vmid(struct kvm *kvm)
55+{
56+ dsb(ishst);
57+
58+ /* Switch to requested VMID */
59+ kvm = kern_hyp_va(kvm);
60+ write_sysreg(kvm->arch.vttbr, vttbr_el2);
61+ isb();
62+
63+ asm volatile("tlbi vmalls12e1is" : : );
64+ dsb(ish);
65+ isb();
66+
67+ write_sysreg(0, vttbr_el2);
68+}
69+
70+__alias(__tlb_flush_vmid) void __kvm_tlb_flush_vmid(struct kvm *kvm);
71+
72+static void __hyp_text __tlb_flush_vm_context(void)
73+{
74+ dsb(ishst);
75+ asm volatile("tlbi alle1is \n"
76+ "ic ialluis ": : );
77+ dsb(ish);
78+}
79+
80+__alias(__tlb_flush_vm_context) void __kvm_flush_vm_context(void);
arch/arm64/kvm/hyp/vgic-v2-sr.c+84−0
@@ -0,0 +1,84 @@
1+/*
2+ * Copyright (C) 2012-2015 - ARM Ltd
3+ * Author: Marc Zyngier <marc.zyngier@arm.com>
4+ *
5+ * This program is free software; you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License version 2 as
7+ * published by the Free Software Foundation.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+#include <linux/compiler.h>
19+#include <linux/irqchip/arm-gic.h>
20+#include <linux/kvm_host.h>
21+
22+#include <asm/kvm_mmu.h>
23+
24+#include "hyp.h"
25+
26+/* vcpu is already in the HYP VA space */
27+void __hyp_text __vgic_v2_save_state(struct kvm_vcpu *vcpu)
28+{
29+ struct kvm *kvm = kern_hyp_va(vcpu->kvm);
30+ struct vgic_v2_cpu_if *cpu_if = &vcpu->arch.vgic_cpu.vgic_v2;
31+ struct vgic_dist *vgic = &kvm->arch.vgic;
32+ void __iomem *base = kern_hyp_va(vgic->vctrl_base);
33+ u32 eisr0, eisr1, elrsr0, elrsr1;
34+ int i, nr_lr;
35+
36+ if (!base)
37+ return;
38+
39+ nr_lr = vcpu->arch.vgic_cpu.nr_lr;
40+ cpu_if->vgic_vmcr = readl_relaxed(base + GICH_VMCR);
41+ cpu_if->vgic_misr = readl_relaxed(base + GICH_MISR);
42+ eisr0 = readl_relaxed(base + GICH_EISR0);
43+ elrsr0 = readl_relaxed(base + GICH_ELRSR0);
44+ if (unlikely(nr_lr > 32)) {
45+ eisr1 = readl_relaxed(base + GICH_EISR1);
46+ elrsr1 = readl_relaxed(base + GICH_ELRSR1);
47+ } else {
48+ eisr1 = elrsr1 = 0;
49+ }
50+#ifdef CONFIG_CPU_BIG_ENDIAN
51+ cpu_if->vgic_eisr = ((u64)eisr0 << 32) | eisr1;
52+ cpu_if->vgic_elrsr = ((u64)elrsr0 << 32) | elrsr1;
53+#else
54+ cpu_if->vgic_eisr = ((u64)eisr1 << 32) | eisr0;
55+ cpu_if->vgic_elrsr = ((u64)elrsr1 << 32) | elrsr0;
56+#endif
57+ cpu_if->vgic_apr = readl_relaxed(base + GICH_APR);
58+
59+ writel_relaxed(0, base + GICH_HCR);
60+
61+ for (i = 0; i < nr_lr; i++)
62+ cpu_if->vgic_lr[i] = readl_relaxed(base + GICH_LR0 + (i * 4));
63+}
64+
65+/* vcpu is already in the HYP VA space */
66+void __hyp_text __vgic_v2_restore_state(struct kvm_vcpu *vcpu)
67+{
68+ struct kvm *kvm = kern_hyp_va(vcpu->kvm);
69+ struct vgic_v2_cpu_if *cpu_if = &vcpu->arch.vgic_cpu.vgic_v2;
70+ struct vgic_dist *vgic = &kvm->arch.vgic;
71+ void __iomem *base = kern_hyp_va(vgic->vctrl_base);
72+ int i, nr_lr;
73+
74+ if (!base)
75+ return;
76+
77+ writel_relaxed(cpu_if->vgic_hcr, base + GICH_HCR);
78+ writel_relaxed(cpu_if->vgic_vmcr, base + GICH_VMCR);
79+ writel_relaxed(cpu_if->vgic_apr, base + GICH_APR);
80+
81+ nr_lr = vcpu->arch.vgic_cpu.nr_lr;
82+ for (i = 0; i < nr_lr; i++)
83+ writel_relaxed(cpu_if->vgic_lr[i], base + GICH_LR0 + (i * 4));
84+}
arch/arm64/kvm/hyp/vgic-v3-sr.c+228−0
@@ -0,0 +1,228 @@
1+/*
2+ * Copyright (C) 2012-2015 - ARM Ltd
3+ * Author: Marc Zyngier <marc.zyngier@arm.com>
4+ *
5+ * This program is free software; you can redistribute it and/or modify
6+ * it under the terms of the GNU General Public License version 2 as
7+ * published by the Free Software Foundation.
8+ *
9+ * This program is distributed in the hope that it will be useful,
10+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+ * GNU General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+#include <linux/compiler.h>
19+#include <linux/irqchip/arm-gic-v3.h>
20+#include <linux/kvm_host.h>
21+
22+#include <asm/kvm_mmu.h>
23+
24+#include "hyp.h"
25+
26+#define vtr_to_max_lr_idx(v) ((v) & 0xf)
27+#define vtr_to_nr_pri_bits(v) (((u32)(v) >> 29) + 1)
28+
29+#define read_gicreg(r) \
30+ ({ \
31+ u64 reg; \
32+ asm volatile("mrs_s %0, " __stringify(r) : "=r" (reg)); \
33+ reg; \
34+ })
35+
36+#define write_gicreg(v,r) \
37+ do { \
38+ u64 __val = (v); \
39+ asm volatile("msr_s " __stringify(r) ", %0" : : "r" (__val));\
40+ } while (0)
41+
42+/* vcpu is already in the HYP VA space */
43+void __hyp_text __vgic_v3_save_state(struct kvm_vcpu *vcpu)
44+{
45+ struct vgic_v3_cpu_if *cpu_if = &vcpu->arch.vgic_cpu.vgic_v3;
46+ u64 val;
47+ u32 max_lr_idx, nr_pri_bits;
48+
49+ /*
50+ * Make sure stores to the GIC via the memory mapped interface
51+ * are now visible to the system register interface.
52+ */
53+ dsb(st);
54+
55+ cpu_if->vgic_vmcr = read_gicreg(ICH_VMCR_EL2);
56+ cpu_if->vgic_misr = read_gicreg(ICH_MISR_EL2);
57+ cpu_if->vgic_eisr = read_gicreg(ICH_EISR_EL2);
58+ cpu_if->vgic_elrsr = read_gicreg(ICH_ELSR_EL2);
59+
60+ write_gicreg(0, ICH_HCR_EL2);
61+ val = read_gicreg(ICH_VTR_EL2);
62+ max_lr_idx = vtr_to_max_lr_idx(val);
63+ nr_pri_bits = vtr_to_nr_pri_bits(val);
64+
65+ switch (max_lr_idx) {
66+ case 15:
67+ cpu_if->vgic_lr[VGIC_V3_LR_INDEX(15)] = read_gicreg(ICH_LR15_EL2);
68+ case 14:
69+ cpu_if->vgic_lr[VGIC_V3_LR_INDEX(14)] = read_gicreg(ICH_LR14_EL2);
70+ case 13:
71+ cpu_if->vgic_lr[VGIC_V3_LR_INDEX(13)] = read_gicreg(ICH_LR13_EL2);
72+ case 12:
73+ cpu_if->vgic_lr[VGIC_V3_LR_INDEX(12)] = read_gicreg(ICH_LR12_EL2);
74+ case 11:
75+ cpu_if->vgic_lr[VGIC_V3_LR_INDEX(11)] = read_gicreg(ICH_LR11_EL2);
76+ case 10:
77+ cpu_if->vgic_lr[VGIC_V3_LR_INDEX(10)] = read_gicreg(ICH_LR10_EL2);
78+ case 9:
79+ cpu_if->vgic_lr[VGIC_V3_LR_INDEX(9)] = read_gicreg(ICH_LR9_EL2);
80+ case 8:
81+ cpu_if->vgic_lr[VGIC_V3_LR_INDEX(8)] = read_gicreg(ICH_LR8_EL2);
82+ case 7:
83+ cpu_if->vgic_lr[VGIC_V3_LR_INDEX(7)] = read_gicreg(ICH_LR7_EL2);
84+ case 6:
85+ cpu_if->vgic_lr[VGIC_V3_LR_INDEX(6)] = read_gicreg(ICH_LR6_EL2);
86+ case 5:
87+ cpu_if->vgic_lr[VGIC_V3_LR_INDEX(5)] = read_gicreg(ICH_LR5_EL2);
88+ case 4:
89+ cpu_if->vgic_lr[VGIC_V3_LR_INDEX(4)] = read_gicreg(ICH_LR4_EL2);
90+ case 3:
91+ cpu_if->vgic_lr[VGIC_V3_LR_INDEX(3)] = read_gicreg(ICH_LR3_EL2);
92+ case 2:
93+ cpu_if->vgic_lr[VGIC_V3_LR_INDEX(2)] = read_gicreg(ICH_LR2_EL2);
94+ case 1:
95+ cpu_if->vgic_lr[VGIC_V3_LR_INDEX(1)] = read_gicreg(ICH_LR1_EL2);
96+ case 0:
97+ cpu_if->vgic_lr[VGIC_V3_LR_INDEX(0)] = read_gicreg(ICH_LR0_EL2);
98+ }
99+
100+ switch (nr_pri_bits) {
101+ case 7:
102+ cpu_if->vgic_ap0r[3] = read_gicreg(ICH_AP0R3_EL2);
103+ cpu_if->vgic_ap0r[2] = read_gicreg(ICH_AP0R2_EL2);
104+ case 6:
105+ cpu_if->vgic_ap0r[1] = read_gicreg(ICH_AP0R1_EL2);
106+ default:
107+ cpu_if->vgic_ap0r[0] = read_gicreg(ICH_AP0R0_EL2);
108+ }
109+
110+ switch (nr_pri_bits) {
111+ case 7:
112+ cpu_if->vgic_ap1r[3] = read_gicreg(ICH_AP1R3_EL2);
113+ cpu_if->vgic_ap1r[2] = read_gicreg(ICH_AP1R2_EL2);
114+ case 6:
115+ cpu_if->vgic_ap1r[1] = read_gicreg(ICH_AP1R1_EL2);
116+ default:
117+ cpu_if->vgic_ap1r[0] = read_gicreg(ICH_AP1R0_EL2);
118+ }
119+
120+ val = read_gicreg(ICC_SRE_EL2);
121+ write_gicreg(val | ICC_SRE_EL2_ENABLE, ICC_SRE_EL2);
122+ isb(); /* Make sure ENABLE is set at EL2 before setting SRE at EL1 */
123+ write_gicreg(1, ICC_SRE_EL1);
124+}
125+
126+void __hyp_text __vgic_v3_restore_state(struct kvm_vcpu *vcpu)
127+{
128+ struct vgic_v3_cpu_if *cpu_if = &vcpu->arch.vgic_cpu.vgic_v3;
129+ u64 val;
130+ u32 max_lr_idx, nr_pri_bits;
131+
132+ /*
133+ * VFIQEn is RES1 if ICC_SRE_EL1.SRE is 1. This causes a
134+ * Group0 interrupt (as generated in GICv2 mode) to be
135+ * delivered as a FIQ to the guest, with potentially fatal
136+ * consequences. So we must make sure that ICC_SRE_EL1 has
137+ * been actually programmed with the value we want before
138+ * starting to mess with the rest of the GIC.
139+ */
140+ write_gicreg(cpu_if->vgic_sre, ICC_SRE_EL1);
141+ isb();
142+
143+ write_gicreg(cpu_if->vgic_hcr, ICH_HCR_EL2);
144+ write_gicreg(cpu_if->vgic_vmcr, ICH_VMCR_EL2);
145+
146+ val = read_gicreg(ICH_VTR_EL2);
147+ max_lr_idx = vtr_to_max_lr_idx(val);
148+ nr_pri_bits = vtr_to_nr_pri_bits(val);
149+
150+ switch (nr_pri_bits) {
151+ case 7:
152+ write_gicreg(cpu_if->vgic_ap1r[3], ICH_AP1R3_EL2);
153+ write_gicreg(cpu_if->vgic_ap1r[2], ICH_AP1R2_EL2);
154+ case 6:
155+ write_gicreg(cpu_if->vgic_ap1r[1], ICH_AP1R1_EL2);
156+ default:
157+ write_gicreg(cpu_if->vgic_ap1r[0], ICH_AP1R0_EL2);
158+ }
159+
160+ switch (nr_pri_bits) {
161+ case 7:
162+ write_gicreg(cpu_if->vgic_ap0r[3], ICH_AP0R3_EL2);
163+ write_gicreg(cpu_if->vgic_ap0r[2], ICH_AP0R2_EL2);
164+ case 6:
165+ write_gicreg(cpu_if->vgic_ap0r[1], ICH_AP0R1_EL2);
166+ default:
167+ write_gicreg(cpu_if->vgic_ap0r[0], ICH_AP0R0_EL2);
168+ }
169+
170+ switch (max_lr_idx) {
171+ case 15:
172+ write_gicreg(cpu_if->vgic_lr[VGIC_V3_LR_INDEX(15)], ICH_LR15_EL2);
173+ case 14:
174+ write_gicreg(cpu_if->vgic_lr[VGIC_V3_LR_INDEX(14)], ICH_LR14_EL2);
175+ case 13:
176+ write_gicreg(cpu_if->vgic_lr[VGIC_V3_LR_INDEX(13)], ICH_LR13_EL2);
177+ case 12:
178+ write_gicreg(cpu_if->vgic_lr[VGIC_V3_LR_INDEX(12)], ICH_LR12_EL2);
179+ case 11:
180+ write_gicreg(cpu_if->vgic_lr[VGIC_V3_LR_INDEX(11)], ICH_LR11_EL2);
181+ case 10:
182+ write_gicreg(cpu_if->vgic_lr[VGIC_V3_LR_INDEX(10)], ICH_LR10_EL2);
183+ case 9:
184+ write_gicreg(cpu_if->vgic_lr[VGIC_V3_LR_INDEX(9)], ICH_LR9_EL2);
185+ case 8:
186+ write_gicreg(cpu_if->vgic_lr[VGIC_V3_LR_INDEX(8)], ICH_LR8_EL2);
187+ case 7:
188+ write_gicreg(cpu_if->vgic_lr[VGIC_V3_LR_INDEX(7)], ICH_LR7_EL2);
189+ case 6:
190+ write_gicreg(cpu_if->vgic_lr[VGIC_V3_LR_INDEX(6)], ICH_LR6_EL2);
191+ case 5:
192+ write_gicreg(cpu_if->vgic_lr[VGIC_V3_LR_INDEX(5)], ICH_LR5_EL2);
193+ case 4:
194+ write_gicreg(cpu_if->vgic_lr[VGIC_V3_LR_INDEX(4)], ICH_LR4_EL2);
195+ case 3:
196+ write_gicreg(cpu_if->vgic_lr[VGIC_V3_LR_INDEX(3)], ICH_LR3_EL2);
197+ case 2:
198+ write_gicreg(cpu_if->vgic_lr[VGIC_V3_LR_INDEX(2)], ICH_LR2_EL2);
199+ case 1:
200+ write_gicreg(cpu_if->vgic_lr[VGIC_V3_LR_INDEX(1)], ICH_LR1_EL2);
201+ case 0:
202+ write_gicreg(cpu_if->vgic_lr[VGIC_V3_LR_INDEX(0)], ICH_LR0_EL2);
203+ }
204+
205+ /*
206+ * Ensures that the above will have reached the
207+ * (re)distributors. This ensure the guest will read the
208+ * correct values from the memory-mapped interface.
209+ */
210+ isb();
211+ dsb(sy);
212+
213+ /*
214+ * Prevent the guest from touching the GIC system registers if
215+ * SRE isn't enabled for GICv3 emulation.
216+ */
217+ if (!cpu_if->vgic_sre) {
218+ write_gicreg(read_gicreg(ICC_SRE_EL2) & ~ICC_SRE_EL2_ENABLE,
219+ ICC_SRE_EL2);
220+ }
221+}
222+
223+static u64 __hyp_text __vgic_v3_read_ich_vtr_el2(void)
224+{
225+ return read_gicreg(ICH_VTR_EL2);
226+}
227+
228+__alias(__vgic_v3_read_ich_vtr_el2) u64 __vgic_v3_get_ich_vtr_el2(void);
arch/arm64/kvm/sys_regs.c+83−85
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929 #include <asm/debug-monitors.h>
3030 #include <asm/esr.h>
3131 #include <asm/kvm_arm.h>
32+#include <asm/kvm_asm.h>
3233 #include <asm/kvm_coproc.h>
3334 #include <asm/kvm_emulate.h>
3435 #include <asm/kvm_host.h>
@@ -78,7 +79,7 @@ static u32 get_ccsidr(u32 csselr) · 43 unmodified lines
7879 * See note at ARMv7 ARM B1.14.4 (TL;DR: S/W ops are not easily virtualized).
7980 */
8081 static bool access_dcsw(struct kvm_vcpu *vcpu,
81− const struct sys_reg_params *p,
82+ struct sys_reg_params *p,
8283 const struct sys_reg_desc *r)
8384 {
8485 if (!p->is_write)
@@ -94,21 +95,19 @@ static bool access_dcsw(struct kvm_vcpu *vcpu, · 9 unmodified lines
9495 * sys_regs and leave it in complete control of the caches.
9596 */
9697 static bool access_vm_reg(struct kvm_vcpu *vcpu,
97− const struct sys_reg_params *p,
98+ struct sys_reg_params *p,
9899 const struct sys_reg_desc *r)
99100 {
100− unsigned long val;
101101 bool was_enabled = vcpu_has_cache_enabled(vcpu);
102102
103103 BUG_ON(!p->is_write);
104104
105− val = *vcpu_reg(vcpu, p->Rt);
106105 if (!p->is_aarch32) {
107− vcpu_sys_reg(vcpu, r->reg) = val;
106+ vcpu_sys_reg(vcpu, r->reg) = p->regval;
108107 } else {
109108 if (!p->is_32bit)
110− vcpu_cp15_64_high(vcpu, r->reg) = val >> 32;
111− vcpu_cp15_64_low(vcpu, r->reg) = val & 0xffffffffUL;
109+ vcpu_cp15_64_high(vcpu, r->reg) = upper_32_bits(p->regval);
110+ vcpu_cp15_64_low(vcpu, r->reg) = lower_32_bits(p->regval);
112111 }
113112
114113 kvm_toggle_cache(vcpu, was_enabled);
@@ -122,22 +121,19 @@ static bool access_vm_reg(struct kvm_vcpu *vcpu, · 7 unmodified lines
122121 * for both AArch64 and AArch32 accesses.
123122 */
124123 static bool access_gic_sgi(struct kvm_vcpu *vcpu,
125− const struct sys_reg_params *p,
124+ struct sys_reg_params *p,
126125 const struct sys_reg_desc *r)
127126 {
128− u64 val;
129−
130127 if (!p->is_write)
131128 return read_from_write_only(vcpu, p);
132129
133− val = *vcpu_reg(vcpu, p->Rt);
134− vgic_v3_dispatch_sgi(vcpu, val);
130+ vgic_v3_dispatch_sgi(vcpu, p->regval);
135131
136132 return true;
137133 }
138134
139135 static bool trap_raz_wi(struct kvm_vcpu *vcpu,
140− const struct sys_reg_params *p,
136+ struct sys_reg_params *p,
141137 const struct sys_reg_desc *r)
142138 {
143139 if (p->is_write)
@@ -147,19 +143,19 @@ static bool trap_raz_wi(struct kvm_vcpu *vcpu, · 3 unmodified lines
147143 }
148144
149145 static bool trap_oslsr_el1(struct kvm_vcpu *vcpu,
150− const struct sys_reg_params *p,
146+ struct sys_reg_params *p,
151147 const struct sys_reg_desc *r)
152148 {
153149 if (p->is_write) {
154150 return ignore_write(vcpu, p);
155151 } else {
156− *vcpu_reg(vcpu, p->Rt) = (1 << 3);
152+ p->regval = (1 << 3);
157153 return true;
158154 }
159155 }
160156
161157 static bool trap_dbgauthstatus_el1(struct kvm_vcpu *vcpu,
162− const struct sys_reg_params *p,
158+ struct sys_reg_params *p,
163159 const struct sys_reg_desc *r)
164160 {
165161 if (p->is_write) {
@@ -167,7 +163,7 @@ static bool trap_dbgauthstatus_el1(struct kvm_vcpu *vcpu, · 1 unmodified line
167163 } else {
168164 u32 val;
169165 asm volatile("mrs %0, dbgauthstatus_el1" : "=r" (val));
170− *vcpu_reg(vcpu, p->Rt) = val;
166+ p->regval = val;
171167 return true;
172168 }
173169 }
@@ -200,17 +196,17 @@ static bool trap_dbgauthstatus_el1(struct kvm_vcpu *vcpu, · 26 unmodified lines
200196 * now use the debug registers.
201197 */
202198 static bool trap_debug_regs(struct kvm_vcpu *vcpu,
203− const struct sys_reg_params *p,
199+ struct sys_reg_params *p,
204200 const struct sys_reg_desc *r)
205201 {
206202 if (p->is_write) {
207− vcpu_sys_reg(vcpu, r->reg) = *vcpu_reg(vcpu, p->Rt);
203+ vcpu_sys_reg(vcpu, r->reg) = p->regval;
208204 vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY;
209205 } else {
210− *vcpu_reg(vcpu, p->Rt) = vcpu_sys_reg(vcpu, r->reg);
206+ p->regval = vcpu_sys_reg(vcpu, r->reg);
211207 }
212208
213− trace_trap_reg(__func__, r->reg, p->is_write, *vcpu_reg(vcpu, p->Rt));
209+ trace_trap_reg(__func__, r->reg, p->is_write, p->regval);
214210
215211 return true;
216212 }
@@ -224,11 +220,11 @@ static bool trap_debug_regs(struct kvm_vcpu *vcpu, · 7 unmodified lines
224220 * All writes will set the KVM_ARM64_DEBUG_DIRTY flag to ensure the
225221 * hyp.S code switches between host and guest values in future.
226222 */
227−static inline void reg_to_dbg(struct kvm_vcpu *vcpu,
228− const struct sys_reg_params *p,
229− u64 *dbg_reg)
223+static void reg_to_dbg(struct kvm_vcpu *vcpu,
224+ struct sys_reg_params *p,
225+ u64 *dbg_reg)
230226 {
231− u64 val = *vcpu_reg(vcpu, p->Rt);
227+ u64 val = p->regval;
232228
233229 if (p->is_32bit) {
234230 val &= 0xffffffffUL;
@@ -239,21 +235,18 @@ static inline void reg_to_dbg(struct kvm_vcpu *vcpu, · 4 unmodified lines
239235 vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY;
240236 }
241237
242−static inline void dbg_to_reg(struct kvm_vcpu *vcpu,
243− const struct sys_reg_params *p,
244− u64 *dbg_reg)
238+static void dbg_to_reg(struct kvm_vcpu *vcpu,
239+ struct sys_reg_params *p,
240+ u64 *dbg_reg)
245241 {
246− u64 val = *dbg_reg;
247−
242+ p->regval = *dbg_reg;
248243 if (p->is_32bit)
249− val &= 0xffffffffUL;
250−
251− *vcpu_reg(vcpu, p->Rt) = val;
244+ p->regval &= 0xffffffffUL;
252245 }
253246
254−static inline bool trap_bvr(struct kvm_vcpu *vcpu,
255− const struct sys_reg_params *p,
256− const struct sys_reg_desc *rd)
247+static bool trap_bvr(struct kvm_vcpu *vcpu,
248+ struct sys_reg_params *p,
249+ const struct sys_reg_desc *rd)
257250 {
258251 u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg];
259252
@@ -287,15 +280,15 @@ static int get_bvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, · 27 unmodified lines
287280 return 0;
288281 }
289282
290−static inline void reset_bvr(struct kvm_vcpu *vcpu,
291− const struct sys_reg_desc *rd)
283+static void reset_bvr(struct kvm_vcpu *vcpu,
284+ const struct sys_reg_desc *rd)
292285 {
293286 vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg] = rd->val;
294287 }
295288
296−static inline bool trap_bcr(struct kvm_vcpu *vcpu,
297− const struct sys_reg_params *p,
298− const struct sys_reg_desc *rd)
289+static bool trap_bcr(struct kvm_vcpu *vcpu,
290+ struct sys_reg_params *p,
291+ const struct sys_reg_desc *rd)
299292 {
300293 u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_bcr[rd->reg];
301294
@@ -330,15 +323,15 @@ static int get_bcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, · 28 unmodified lines
330323 return 0;
331324 }
332325
333−static inline void reset_bcr(struct kvm_vcpu *vcpu,
334− const struct sys_reg_desc *rd)
326+static void reset_bcr(struct kvm_vcpu *vcpu,
327+ const struct sys_reg_desc *rd)
335328 {
336329 vcpu->arch.vcpu_debug_state.dbg_bcr[rd->reg] = rd->val;
337330 }
338331
339−static inline bool trap_wvr(struct kvm_vcpu *vcpu,
340− const struct sys_reg_params *p,
341− const struct sys_reg_desc *rd)
332+static bool trap_wvr(struct kvm_vcpu *vcpu,
333+ struct sys_reg_params *p,
334+ const struct sys_reg_desc *rd)
342335 {
343336 u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg];
344337
@@ -373,15 +366,15 @@ static int get_wvr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, · 28 unmodified lines
373366 return 0;
374367 }
375368
376−static inline void reset_wvr(struct kvm_vcpu *vcpu,
377− const struct sys_reg_desc *rd)
369+static void reset_wvr(struct kvm_vcpu *vcpu,
370+ const struct sys_reg_desc *rd)
378371 {
379372 vcpu->arch.vcpu_debug_state.dbg_wvr[rd->reg] = rd->val;
380373 }
381374
382−static inline bool trap_wcr(struct kvm_vcpu *vcpu,
383− const struct sys_reg_params *p,
384− const struct sys_reg_desc *rd)
375+static bool trap_wcr(struct kvm_vcpu *vcpu,
376+ struct sys_reg_params *p,
377+ const struct sys_reg_desc *rd)
385378 {
386379 u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_wcr[rd->reg];
387380
@@ -415,8 +408,8 @@ static int get_wcr(struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd, · 27 unmodified lines
415408 return 0;
416409 }
417410
418−static inline void reset_wcr(struct kvm_vcpu *vcpu,
419− const struct sys_reg_desc *rd)
411+static void reset_wcr(struct kvm_vcpu *vcpu,
412+ const struct sys_reg_desc *rd)
420413 {
421414 vcpu->arch.vcpu_debug_state.dbg_wcr[rd->reg] = rd->val;
422415 }
@@ -687,7 +680,7 @@ static const struct sys_reg_desc sys_reg_descs[] = { · 264 unmodified lines
687680 };
688681
689682 static bool trap_dbgidr(struct kvm_vcpu *vcpu,
690− const struct sys_reg_params *p,
683+ struct sys_reg_params *p,
691684 const struct sys_reg_desc *r)
692685 {
693686 if (p->is_write) {
@@ -697,23 +690,23 @@ static bool trap_dbgidr(struct kvm_vcpu *vcpu, · 3 unmodified lines
697690 u64 pfr = read_system_reg(SYS_ID_AA64PFR0_EL1);
698691 u32 el3 = !!cpuid_feature_extract_field(pfr, ID_AA64PFR0_EL3_SHIFT);
699692
700− *vcpu_reg(vcpu, p->Rt) = ((((dfr >> ID_AA64DFR0_WRPS_SHIFT) & 0xf) << 28) |
701− (((dfr >> ID_AA64DFR0_BRPS_SHIFT) & 0xf) << 24) |
702− (((dfr >> ID_AA64DFR0_CTX_CMPS_SHIFT) & 0xf) << 20) |
703− (6 << 16) | (el3 << 14) | (el3 << 12));
693+ p->regval = ((((dfr >> ID_AA64DFR0_WRPS_SHIFT) & 0xf) << 28) |
694+ (((dfr >> ID_AA64DFR0_BRPS_SHIFT) & 0xf) << 24) |
695+ (((dfr >> ID_AA64DFR0_CTX_CMPS_SHIFT) & 0xf) << 20)
696+ | (6 << 16) | (el3 << 14) | (el3 << 12));
704697 return true;
705698 }
706699 }
707700
708701 static bool trap_debug32(struct kvm_vcpu *vcpu,
709− const struct sys_reg_params *p,
702+ struct sys_reg_params *p,
710703 const struct sys_reg_desc *r)
711704 {
712705 if (p->is_write) {
713− vcpu_cp14(vcpu, r->reg) = *vcpu_reg(vcpu, p->Rt);
706+ vcpu_cp14(vcpu, r->reg) = p->regval;
714707 vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY;
715708 } else {
716− *vcpu_reg(vcpu, p->Rt) = vcpu_cp14(vcpu, r->reg);
709+ p->regval = vcpu_cp14(vcpu, r->reg);
717710 }
718711
719712 return true;
@@ -730,9 +723,9 @@ static bool trap_debug32(struct kvm_vcpu *vcpu, · 10 unmodified lines
730723 * system is in.
731724 */
732725
733−static inline bool trap_xvr(struct kvm_vcpu *vcpu,
734− const struct sys_reg_params *p,
735− const struct sys_reg_desc *rd)
726+static bool trap_xvr(struct kvm_vcpu *vcpu,
727+ struct sys_reg_params *p,
728+ const struct sys_reg_desc *rd)
736729 {
737730 u64 *dbg_reg = &vcpu->arch.vcpu_debug_state.dbg_bvr[rd->reg];
738731
@@ -740,12 +733,12 @@ static inline bool trap_xvr(struct kvm_vcpu *vcpu, · 1 unmodified line
740733 u64 val = *dbg_reg;
741734
742735 val &= 0xffffffffUL;
743− val |= *vcpu_reg(vcpu, p->Rt) << 32;
736+ val |= p->regval << 32;
744737 *dbg_reg = val;
745738
746739 vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY;
747740 } else {
748− *vcpu_reg(vcpu, p->Rt) = *dbg_reg >> 32;
741+ p->regval = *dbg_reg >> 32;
749742 }
750743
751744 trace_trap_reg(__func__, rd->reg, p->is_write, *dbg_reg);
@@ -991,7 +984,7 @@ int kvm_handle_cp14_load_store(struct kvm_vcpu *vcpu, struct kvm_run *run) · 239 unmodified lines
991984 * Return 0 if the access has been handled, and -1 if not.
992985 */
993986 static int emulate_cp(struct kvm_vcpu *vcpu,
994− const struct sys_reg_params *params,
987+ struct sys_reg_params *params,
995988 const struct sys_reg_desc *table,
996989 size_t num)
997990 {
@@ -1062,12 +1055,12 @@ static int kvm_handle_cp_64(struct kvm_vcpu *vcpu, · 64 unmodified lines
10621055 {
10631056 struct sys_reg_params params;
10641057 u32 hsr = kvm_vcpu_get_hsr(vcpu);
1058+ int Rt = (hsr >> 5) & 0xf;
10651059 int Rt2 = (hsr >> 10) & 0xf;
10661060
10671061 params.is_aarch32 = true;
10681062 params.is_32bit = false;
10691063 params.CRm = (hsr >> 1) & 0xf;
1070− params.Rt = (hsr >> 5) & 0xf;
10711064 params.is_write = ((hsr & 1) == 0);
10721065
10731066 params.Op0 = 0;
@@ -1076,15 +1069,12 @@ static int kvm_handle_cp_64(struct kvm_vcpu *vcpu, · 2 unmodified lines
10761069 params.CRn = 0;
10771070
10781071 /*
1079− * Massive hack here. Store Rt2 in the top 32bits so we only
1080− * have one register to deal with. As we use the same trap
1072+ * Make a 64-bit value out of Rt and Rt2. As we use the same trap
10811073 * backends between AArch32 and AArch64, we get away with it.
10821074 */
10831075 if (params.is_write) {
1084− u64 val = *vcpu_reg(vcpu, params.Rt);
1085− val &= 0xffffffff;
1086− val |= *vcpu_reg(vcpu, Rt2) << 32;
1087− *vcpu_reg(vcpu, params.Rt) = val;
1076+ params.regval = vcpu_get_reg(vcpu, Rt) & 0xffffffff;
1077+ params.regval |= vcpu_get_reg(vcpu, Rt2) << 32;
10881078 }
10891079
10901080 if (!emulate_cp(vcpu, &params, target_specific, nr_specific))
@@ -1095,11 +1085,10 @@ static int kvm_handle_cp_64(struct kvm_vcpu *vcpu, · 4 unmodified lines
10951085 unhandled_cp_access(vcpu, &params);
10961086
10971087 out:
1098− /* Do the opposite hack for the read side */
1088+ /* Split up the value between registers for the read side */
10991089 if (!params.is_write) {
1100− u64 val = *vcpu_reg(vcpu, params.Rt);
1101− val >>= 32;
1102− *vcpu_reg(vcpu, Rt2) = val;
1090+ vcpu_set_reg(vcpu, Rt, lower_32_bits(params.regval));
1091+ vcpu_set_reg(vcpu, Rt2, upper_32_bits(params.regval));
11031092 }
11041093
11051094 return 1;
@@ -1118,21 +1107,24 @@ static int kvm_handle_cp_32(struct kvm_vcpu *vcpu, · 12 unmodified lines
11181107 {
11191108 struct sys_reg_params params;
11201109 u32 hsr = kvm_vcpu_get_hsr(vcpu);
1110+ int Rt = (hsr >> 5) & 0xf;
11211111
11221112 params.is_aarch32 = true;
11231113 params.is_32bit = true;
11241114 params.CRm = (hsr >> 1) & 0xf;
1125− params.Rt = (hsr >> 5) & 0xf;
1115+ params.regval = vcpu_get_reg(vcpu, Rt);
11261116 params.is_write = ((hsr & 1) == 0);
11271117 params.CRn = (hsr >> 10) & 0xf;
11281118 params.Op0 = 0;
11291119 params.Op1 = (hsr >> 14) & 0x7;
11301120 params.Op2 = (hsr >> 17) & 0x7;
11311121
1132− if (!emulate_cp(vcpu, &params, target_specific, nr_specific))
1133− return 1;
1134− if (!emulate_cp(vcpu, &params, global, nr_global))
1122+ if (!emulate_cp(vcpu, &params, target_specific, nr_specific) ||
1123+ !emulate_cp(vcpu, &params, global, nr_global)) {
1124+ if (!params.is_write)
1125+ vcpu_set_reg(vcpu, Rt, params.regval);
11351126 return 1;
1127+ }
11361128
11371129 unhandled_cp_access(vcpu, &params);
11381130 return 1;
@@ -1175,7 +1167,7 @@ int kvm_handle_cp14_32(struct kvm_vcpu *vcpu, struct kvm_run *run) · 36 unmodified lines
11751167 }
11761168
11771169 static int emulate_sys_reg(struct kvm_vcpu *vcpu,
1178− const struct sys_reg_params *params)
1170+ struct sys_reg_params *params)
11791171 {
11801172 size_t num;
11811173 const struct sys_reg_desc *table, *r;
@@ -1230,6 +1222,8 @@ int kvm_handle_sys_reg(struct kvm_vcpu *vcpu, struct kvm_run *run) · 48 unmodified lines
12301222 {
12311223 struct sys_reg_params params;
12321224 unsigned long esr = kvm_vcpu_get_hsr(vcpu);
1225+ int Rt = (esr >> 5) & 0x1f;
1226+ int ret;
12331227
12341228 trace_kvm_handle_sys_reg(esr);
12351229
@@ -1240,10 +1234,14 @@ int kvm_handle_sys_reg(struct kvm_vcpu *vcpu, struct kvm_run *run) · 4 unmodified lines
12401234 params.CRn = (esr >> 10) & 0xf;
12411235 params.CRm = (esr >> 1) & 0xf;
12421236 params.Op2 = (esr >> 17) & 0x7;
1243− params.Rt = (esr >> 5) & 0x1f;
1237+ params.regval = vcpu_get_reg(vcpu, Rt);
12441238 params.is_write = !(esr & 1);
12451239
1246− return emulate_sys_reg(vcpu, &params);
1240+ ret = emulate_sys_reg(vcpu, &params);
1241+
1242+ if (!params.is_write)
1243+ vcpu_set_reg(vcpu, Rt, params.regval);
1244+ return ret;
12471245 }
12481246
12491247 /******************************************************************************
arch/arm64/kvm/sys_regs.h+4−4
@@ -28,7 +28,7 @@ struct sys_reg_params { · 27 unmodified lines
2828 u8 CRn;
2929 u8 CRm;
3030 u8 Op2;
31− u8 Rt;
31+ u64 regval;
3232 bool is_write;
3333 bool is_aarch32;
3434 bool is_32bit; /* Only valid if is_aarch32 is true */
@@ -44,7 +44,7 @@ struct sys_reg_desc { · 9 unmodified lines
4444
4545 /* Trapped access from guest, if non-NULL. */
4646 bool (*access)(struct kvm_vcpu *,
47− const struct sys_reg_params *,
47+ struct sys_reg_params *,
4848 const struct sys_reg_desc *);
4949
5050 /* Initialization for vcpu. */
@@ -77,9 +77,9 @@ static inline bool ignore_write(struct kvm_vcpu *vcpu, · 26 unmodified lines
7777 }
7878
7979 static inline bool read_zero(struct kvm_vcpu *vcpu,
80− const struct sys_reg_params *p)
80+ struct sys_reg_params *p)
8181 {
82− *vcpu_reg(vcpu, p->Rt) = 0;
82+ p->regval = 0;
8383 return true;
8484 }
8585
arch/arm64/kvm/sys_regs_generic_v8.c+2−2
@@ -31,13 +31,13 @@ · 30 unmodified lines
3131 #include "sys_regs.h"
3232
3333 static bool access_actlr(struct kvm_vcpu *vcpu,
34− const struct sys_reg_params *p,
34+ struct sys_reg_params *p,
3535 const struct sys_reg_desc *r)
3636 {
3737 if (p->is_write)
3838 return ignore_write(vcpu, p);
3939
40− *vcpu_reg(vcpu, p->Rt) = vcpu_sys_reg(vcpu, ACTLR_EL1);
40+ p->regval = vcpu_sys_reg(vcpu, ACTLR_EL1);
4141 return true;
4242 }
4343
arch/arm64/kvm/vgic-v2-switch.S+0−134
@@ -1,134 +0,0 @@
1−/*
2− * Copyright (C) 2012,2013 - ARM Ltd
3− * Author: Marc Zyngier <marc.zyngier@arm.com>
4− *
5− * This program is free software; you can redistribute it and/or modify
6− * it under the terms of the GNU General Public License version 2 as
7− * published by the Free Software Foundation.
8− *
9− * This program is distributed in the hope that it will be useful,
10− * but WITHOUT ANY WARRANTY; without even the implied warranty of
11− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12− * GNU General Public License for more details.
13− *
14− * You should have received a copy of the GNU General Public License
15− * along with this program. If not, see <http://www.gnu.org/licenses/>.
16− */
17−
18−#include <linux/linkage.h>
19−#include <linux/irqchip/arm-gic.h>
20−
21−#include <asm/assembler.h>
22−#include <asm/memory.h>
23−#include <asm/asm-offsets.h>
24−#include <asm/kvm.h>
25−#include <asm/kvm_asm.h>
26−#include <asm/kvm_arm.h>
27−#include <asm/kvm_mmu.h>
28−
29− .text
30− .pushsection .hyp.text, "ax"
31−
32−/*
33− * Save the VGIC CPU state into memory
34− * x0: Register pointing to VCPU struct
35− * Do not corrupt x1!!!
36− */
37−ENTRY(__save_vgic_v2_state)
38−__save_vgic_v2_state:
39− /* Get VGIC VCTRL base into x2 */
40− ldr x2, [x0, #VCPU_KVM]
41− kern_hyp_va x2
42− ldr x2, [x2, #KVM_VGIC_VCTRL]
43− kern_hyp_va x2
44− cbz x2, 2f // disabled
45−
46− /* Compute the address of struct vgic_cpu */
47− add x3, x0, #VCPU_VGIC_CPU
48−
49− /* Save all interesting registers */
50− ldr w5, [x2, #GICH_VMCR]
51− ldr w6, [x2, #GICH_MISR]
52− ldr w7, [x2, #GICH_EISR0]
53− ldr w8, [x2, #GICH_EISR1]
54− ldr w9, [x2, #GICH_ELRSR0]
55− ldr w10, [x2, #GICH_ELRSR1]
56− ldr w11, [x2, #GICH_APR]
57−CPU_BE( rev w5, w5 )
58−CPU_BE( rev w6, w6 )
59−CPU_BE( rev w7, w7 )
60−CPU_BE( rev w8, w8 )
61−CPU_BE( rev w9, w9 )
62−CPU_BE( rev w10, w10 )
63−CPU_BE( rev w11, w11 )
64−
65− str w5, [x3, #VGIC_V2_CPU_VMCR]
66− str w6, [x3, #VGIC_V2_CPU_MISR]
67−CPU_LE( str w7, [x3, #VGIC_V2_CPU_EISR] )
68−CPU_LE( str w8, [x3, #(VGIC_V2_CPU_EISR + 4)] )
69−CPU_LE( str w9, [x3, #VGIC_V2_CPU_ELRSR] )
70−CPU_LE( str w10, [x3, #(VGIC_V2_CPU_ELRSR + 4)] )
71−CPU_BE( str w7, [x3, #(VGIC_V2_CPU_EISR + 4)] )
72−CPU_BE( str w8, [x3, #VGIC_V2_CPU_EISR] )
73−CPU_BE( str w9, [x3, #(VGIC_V2_CPU_ELRSR + 4)] )
74−CPU_BE( str w10, [x3, #VGIC_V2_CPU_ELRSR] )
75− str w11, [x3, #VGIC_V2_CPU_APR]
76−
77− /* Clear GICH_HCR */
78− str wzr, [x2, #GICH_HCR]
79−
80− /* Save list registers */
81− add x2, x2, #GICH_LR0
82− ldr w4, [x3, #VGIC_CPU_NR_LR]
83− add x3, x3, #VGIC_V2_CPU_LR
84−1: ldr w5, [x2], #4
85−CPU_BE( rev w5, w5 )
86− str w5, [x3], #4
87− sub w4, w4, #1
88− cbnz w4, 1b
89−2:
90− ret
91−ENDPROC(__save_vgic_v2_state)
92−
93−/*
94− * Restore the VGIC CPU state from memory
95− * x0: Register pointing to VCPU struct
96− */
97−ENTRY(__restore_vgic_v2_state)
98−__restore_vgic_v2_state:
99− /* Get VGIC VCTRL base into x2 */
100− ldr x2, [x0, #VCPU_KVM]
101− kern_hyp_va x2
102− ldr x2, [x2, #KVM_VGIC_VCTRL]
103− kern_hyp_va x2
104− cbz x2, 2f // disabled
105−
106− /* Compute the address of struct vgic_cpu */
107− add x3, x0, #VCPU_VGIC_CPU
108−
109− /* We only restore a minimal set of registers */
110− ldr w4, [x3, #VGIC_V2_CPU_HCR]
111− ldr w5, [x3, #VGIC_V2_CPU_VMCR]
112− ldr w6, [x3, #VGIC_V2_CPU_APR]
113−CPU_BE( rev w4, w4 )
114−CPU_BE( rev w5, w5 )
115−CPU_BE( rev w6, w6 )
116−
117− str w4, [x2, #GICH_HCR]
118− str w5, [x2, #GICH_VMCR]
119− str w6, [x2, #GICH_APR]
120−
121− /* Restore list registers */
122− add x2, x2, #GICH_LR0
123− ldr w4, [x3, #VGIC_CPU_NR_LR]
124− add x3, x3, #VGIC_V2_CPU_LR
125−1: ldr w5, [x3], #4
126−CPU_BE( rev w5, w5 )
127− str w5, [x2], #4
128− sub w4, w4, #1
129− cbnz w4, 1b
130−2:
131− ret
132−ENDPROC(__restore_vgic_v2_state)
133−
134− .popsection
arch/arm64/kvm/vgic-v3-switch.S+0−269
@@ -1,269 +0,0 @@
1−/*
2− * Copyright (C) 2012,2013 - ARM Ltd
3− * Author: Marc Zyngier <marc.zyngier@arm.com>
4− *
5− * This program is free software; you can redistribute it and/or modify
6− * it under the terms of the GNU General Public License version 2 as
7− * published by the Free Software Foundation.
8− *
9− * This program is distributed in the hope that it will be useful,
10− * but WITHOUT ANY WARRANTY; without even the implied warranty of
11− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12− * GNU General Public License for more details.
13− *
14− * You should have received a copy of the GNU General Public License
15− * along with this program. If not, see <http://www.gnu.org/licenses/>.
16− */
17−
18−#include <linux/linkage.h>
19−#include <linux/irqchip/arm-gic-v3.h>
20−
21−#include <asm/assembler.h>
22−#include <asm/memory.h>
23−#include <asm/asm-offsets.h>
24−#include <asm/kvm.h>
25−#include <asm/kvm_asm.h>
26−#include <asm/kvm_arm.h>
27−
28− .text
29− .pushsection .hyp.text, "ax"
30−
31−/*
32− * We store LRs in reverse order to let the CPU deal with streaming
33− * access. Use this macro to make it look saner...
34− */
35−#define LR_OFFSET(n) (VGIC_V3_CPU_LR + (15 - n) * 8)
36−
37−/*
38− * Save the VGIC CPU state into memory
39− * x0: Register pointing to VCPU struct
40− * Do not corrupt x1!!!
41− */
42−.macro save_vgic_v3_state
43− // Compute the address of struct vgic_cpu
44− add x3, x0, #VCPU_VGIC_CPU
45−
46− // Make sure stores to the GIC via the memory mapped interface
47− // are now visible to the system register interface
48− dsb st
49−
50− // Save all interesting registers
51− mrs_s x5, ICH_VMCR_EL2
52− mrs_s x6, ICH_MISR_EL2
53− mrs_s x7, ICH_EISR_EL2
54− mrs_s x8, ICH_ELSR_EL2
55−
56− str w5, [x3, #VGIC_V3_CPU_VMCR]
57− str w6, [x3, #VGIC_V3_CPU_MISR]
58− str w7, [x3, #VGIC_V3_CPU_EISR]
59− str w8, [x3, #VGIC_V3_CPU_ELRSR]
60−
61− msr_s ICH_HCR_EL2, xzr
62−
63− mrs_s x21, ICH_VTR_EL2
64− mvn w22, w21
65− ubfiz w23, w22, 2, 4 // w23 = (15 - ListRegs) * 4
66−
67− adr x24, 1f
68− add x24, x24, x23
69− br x24
70−
71−1:
72− mrs_s x20, ICH_LR15_EL2
73− mrs_s x19, ICH_LR14_EL2
74− mrs_s x18, ICH_LR13_EL2
75− mrs_s x17, ICH_LR12_EL2
76− mrs_s x16, ICH_LR11_EL2
77− mrs_s x15, ICH_LR10_EL2
78− mrs_s x14, ICH_LR9_EL2
79− mrs_s x13, ICH_LR8_EL2
80− mrs_s x12, ICH_LR7_EL2
81− mrs_s x11, ICH_LR6_EL2
82− mrs_s x10, ICH_LR5_EL2
83− mrs_s x9, ICH_LR4_EL2
84− mrs_s x8, ICH_LR3_EL2
85− mrs_s x7, ICH_LR2_EL2
86− mrs_s x6, ICH_LR1_EL2
87− mrs_s x5, ICH_LR0_EL2
88−
89− adr x24, 1f
90− add x24, x24, x23
91− br x24
92−
93−1:
94− str x20, [x3, #LR_OFFSET(15)]
95− str x19, [x3, #LR_OFFSET(14)]
96− str x18, [x3, #LR_OFFSET(13)]
97− str x17, [x3, #LR_OFFSET(12)]
98− str x16, [x3, #LR_OFFSET(11)]
99− str x15, [x3, #LR_OFFSET(10)]
100− str x14, [x3, #LR_OFFSET(9)]
101− str x13, [x3, #LR_OFFSET(8)]
102− str x12, [x3, #LR_OFFSET(7)]
103− str x11, [x3, #LR_OFFSET(6)]
104− str x10, [x3, #LR_OFFSET(5)]
105− str x9, [x3, #LR_OFFSET(4)]
106− str x8, [x3, #LR_OFFSET(3)]
107− str x7, [x3, #LR_OFFSET(2)]
108− str x6, [x3, #LR_OFFSET(1)]
109− str x5, [x3, #LR_OFFSET(0)]
110−
111− tbnz w21, #29, 6f // 6 bits
112− tbz w21, #30, 5f // 5 bits
113− // 7 bits
114− mrs_s x20, ICH_AP0R3_EL2
115− str w20, [x3, #(VGIC_V3_CPU_AP0R + 3*4)]
116− mrs_s x19, ICH_AP0R2_EL2
117− str w19, [x3, #(VGIC_V3_CPU_AP0R + 2*4)]
118−6: mrs_s x18, ICH_AP0R1_EL2
119− str w18, [x3, #(VGIC_V3_CPU_AP0R + 1*4)]
120−5: mrs_s x17, ICH_AP0R0_EL2
121− str w17, [x3, #VGIC_V3_CPU_AP0R]
122−
123− tbnz w21, #29, 6f // 6 bits
124− tbz w21, #30, 5f // 5 bits
125− // 7 bits
126− mrs_s x20, ICH_AP1R3_EL2
127− str w20, [x3, #(VGIC_V3_CPU_AP1R + 3*4)]
128− mrs_s x19, ICH_AP1R2_EL2
129− str w19, [x3, #(VGIC_V3_CPU_AP1R + 2*4)]
130−6: mrs_s x18, ICH_AP1R1_EL2
131− str w18, [x3, #(VGIC_V3_CPU_AP1R + 1*4)]
132−5: mrs_s x17, ICH_AP1R0_EL2
133− str w17, [x3, #VGIC_V3_CPU_AP1R]
134−
135− // Restore SRE_EL1 access and re-enable SRE at EL1.
136− mrs_s x5, ICC_SRE_EL2
137− orr x5, x5, #ICC_SRE_EL2_ENABLE
138− msr_s ICC_SRE_EL2, x5
139− isb
140− mov x5, #1
141− msr_s ICC_SRE_EL1, x5
142−.endm
143−
144−/*
145− * Restore the VGIC CPU state from memory
146− * x0: Register pointing to VCPU struct
147− */
148−.macro restore_vgic_v3_state
149− // Compute the address of struct vgic_cpu
150− add x3, x0, #VCPU_VGIC_CPU
151−
152− // Restore all interesting registers
153− ldr w4, [x3, #VGIC_V3_CPU_HCR]
154− ldr w5, [x3, #VGIC_V3_CPU_VMCR]
155− ldr w25, [x3, #VGIC_V3_CPU_SRE]
156−
157− msr_s ICC_SRE_EL1, x25
158−
159− // make sure SRE is valid before writing the other registers
160− isb
161−
162− msr_s ICH_HCR_EL2, x4
163− msr_s ICH_VMCR_EL2, x5
164−
165− mrs_s x21, ICH_VTR_EL2
166−
167− tbnz w21, #29, 6f // 6 bits
168− tbz w21, #30, 5f // 5 bits
169− // 7 bits
170− ldr w20, [x3, #(VGIC_V3_CPU_AP1R + 3*4)]
171− msr_s ICH_AP1R3_EL2, x20
172− ldr w19, [x3, #(VGIC_V3_CPU_AP1R + 2*4)]
173− msr_s ICH_AP1R2_EL2, x19
174−6: ldr w18, [x3, #(VGIC_V3_CPU_AP1R + 1*4)]
175− msr_s ICH_AP1R1_EL2, x18
176−5: ldr w17, [x3, #VGIC_V3_CPU_AP1R]
177− msr_s ICH_AP1R0_EL2, x17
178−
179− tbnz w21, #29, 6f // 6 bits
180− tbz w21, #30, 5f // 5 bits
181− // 7 bits
182− ldr w20, [x3, #(VGIC_V3_CPU_AP0R + 3*4)]
183− msr_s ICH_AP0R3_EL2, x20
184− ldr w19, [x3, #(VGIC_V3_CPU_AP0R + 2*4)]
185− msr_s ICH_AP0R2_EL2, x19
186−6: ldr w18, [x3, #(VGIC_V3_CPU_AP0R + 1*4)]
187− msr_s ICH_AP0R1_EL2, x18
188−5: ldr w17, [x3, #VGIC_V3_CPU_AP0R]
189− msr_s ICH_AP0R0_EL2, x17
190−
191− and w22, w21, #0xf
192− mvn w22, w21
193− ubfiz w23, w22, 2, 4 // w23 = (15 - ListRegs) * 4
194−
195− adr x24, 1f
196− add x24, x24, x23
197− br x24
198−
199−1:
200− ldr x20, [x3, #LR_OFFSET(15)]
201− ldr x19, [x3, #LR_OFFSET(14)]
202− ldr x18, [x3, #LR_OFFSET(13)]
203− ldr x17, [x3, #LR_OFFSET(12)]
204− ldr x16, [x3, #LR_OFFSET(11)]
205− ldr x15, [x3, #LR_OFFSET(10)]
206− ldr x14, [x3, #LR_OFFSET(9)]
207− ldr x13, [x3, #LR_OFFSET(8)]
208− ldr x12, [x3, #LR_OFFSET(7)]
209− ldr x11, [x3, #LR_OFFSET(6)]
210− ldr x10, [x3, #LR_OFFSET(5)]
211− ldr x9, [x3, #LR_OFFSET(4)]
212− ldr x8, [x3, #LR_OFFSET(3)]
213− ldr x7, [x3, #LR_OFFSET(2)]
214− ldr x6, [x3, #LR_OFFSET(1)]
215− ldr x5, [x3, #LR_OFFSET(0)]
216−
217− adr x24, 1f
218− add x24, x24, x23
219− br x24
220−
221−1:
222− msr_s ICH_LR15_EL2, x20
223− msr_s ICH_LR14_EL2, x19
224− msr_s ICH_LR13_EL2, x18
225− msr_s ICH_LR12_EL2, x17
226− msr_s ICH_LR11_EL2, x16
227− msr_s ICH_LR10_EL2, x15
228− msr_s ICH_LR9_EL2, x14
229− msr_s ICH_LR8_EL2, x13
230− msr_s ICH_LR7_EL2, x12
231− msr_s ICH_LR6_EL2, x11
232− msr_s ICH_LR5_EL2, x10
233− msr_s ICH_LR4_EL2, x9
234− msr_s ICH_LR3_EL2, x8
235− msr_s ICH_LR2_EL2, x7
236− msr_s ICH_LR1_EL2, x6
237− msr_s ICH_LR0_EL2, x5
238−
239− // Ensure that the above will have reached the
240− // (re)distributors. This ensure the guest will read
241− // the correct values from the memory-mapped interface.
242− isb
243− dsb sy
244−
245− // Prevent the guest from touching the GIC system registers
246− // if SRE isn't enabled for GICv3 emulation
247− cbnz x25, 1f
248− mrs_s x5, ICC_SRE_EL2
249− and x5, x5, #~ICC_SRE_EL2_ENABLE
250− msr_s ICC_SRE_EL2, x5
251−1:
252−.endm
253−
254−ENTRY(__save_vgic_v3_state)
255− save_vgic_v3_state
256− ret
257−ENDPROC(__save_vgic_v3_state)
258−
259−ENTRY(__restore_vgic_v3_state)
260− restore_vgic_v3_state
261− ret
262−ENDPROC(__restore_vgic_v3_state)
263−
264−ENTRY(__vgic_v3_get_ich_vtr_el2)
265− mrs_s x0, ICH_VTR_EL2
266− ret
267−ENDPROC(__vgic_v3_get_ich_vtr_el2)
268−
269− .popsection
arch/arm64/mm/context.c+26−12
@@ -76,13 +76,28 @@ static void flush_context(unsigned int cpu) · 75 unmodified lines
7676 __flush_icache_all();
7777 }
7878
79−static int is_reserved_asid(u64 asid)
79+static bool check_update_reserved_asid(u64 asid, u64 newasid)
8080 {
8181 int cpu;
82− for_each_possible_cpu(cpu)
83− if (per_cpu(reserved_asids, cpu) == asid)
84− return 1;
85− return 0;
82+ bool hit = false;
83+
84+ /*
85+ * Iterate over the set of reserved ASIDs looking for a match.
86+ * If we find one, then we can update our mm to use newasid
87+ * (i.e. the same ASID in the current generation) but we can't
88+ * exit the loop early, since we need to ensure that all copies
89+ * of the old ASID are updated to reflect the mm. Failure to do
90+ * so could result in us missing the reserved ASID in a future
91+ * generation.
92+ */
93+ for_each_possible_cpu(cpu) {
94+ if (per_cpu(reserved_asids, cpu) == asid) {
95+ hit = true;
96+ per_cpu(reserved_asids, cpu) = newasid;
97+ }
98+ }
99+
100+ return hit;
86101 }
87102
88103 static u64 new_context(struct mm_struct *mm, unsigned int cpu)
@@ -92,12 +107,14 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu) · 3 unmodified lines
92107 u64 generation = atomic64_read(&asid_generation);
93108
94109 if (asid != 0) {
110+ u64 newasid = generation | (asid & ~ASID_MASK);
111+
95112 /*
96113 * If our current ASID was active during a rollover, we
97114 * can continue to use it and this was just a false alarm.
98115 */
99− if (is_reserved_asid(asid))
100− return generation | (asid & ~ASID_MASK);
116+ if (check_update_reserved_asid(asid, newasid))
117+ return newasid;
101118
102119 /*
103120 * We had a valid ASID in a previous life, so try to re-use
@@ -105,7 +122,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu) · 1 unmodified line
105122 */
106123 asid &= ~ASID_MASK;
107124 if (!__test_and_set_bit(asid, asid_map))
108− goto bump_gen;
125+ return newasid;
109126 }
110127
111128 /*
@@ -129,10 +146,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu) · 17 unmodified lines
129146 set_asid:
130147 __set_bit(asid, asid_map);
131148 cur_idx = asid;
132−
133−bump_gen:
134− asid |= generation;
135− return asid;
149+ return asid | generation;
136150 }
137151
138152 void check_and_switch_context(struct mm_struct *mm, unsigned int cpu)
arch/arm64/mm/fault.c+14−14
@@ -393,16 +393,16 @@ static struct fault_info { · 392 unmodified lines
393393 { do_translation_fault, SIGSEGV, SEGV_MAPERR, "level 1 translation fault" },
394394 { do_translation_fault, SIGSEGV, SEGV_MAPERR, "level 2 translation fault" },
395395 { do_page_fault, SIGSEGV, SEGV_MAPERR, "level 3 translation fault" },
396− { do_bad, SIGBUS, 0, "reserved access flag fault" },
396+ { do_bad, SIGBUS, 0, "unknown 8" },
397397 { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 1 access flag fault" },
398398 { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 2 access flag fault" },
399399 { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 3 access flag fault" },
400− { do_bad, SIGBUS, 0, "reserved permission fault" },
400+ { do_bad, SIGBUS, 0, "unknown 12" },
401401 { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 1 permission fault" },
402402 { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 2 permission fault" },
403403 { do_page_fault, SIGSEGV, SEGV_ACCERR, "level 3 permission fault" },
404404 { do_bad, SIGBUS, 0, "synchronous external abort" },
405− { do_bad, SIGBUS, 0, "asynchronous external abort" },
405+ { do_bad, SIGBUS, 0, "unknown 17" },
406406 { do_bad, SIGBUS, 0, "unknown 18" },
407407 { do_bad, SIGBUS, 0, "unknown 19" },
408408 { do_bad, SIGBUS, 0, "synchronous abort (translation table walk)" },
@@ -410,16 +410,16 @@ static struct fault_info { · 1 unmodified line
410410 { do_bad, SIGBUS, 0, "synchronous abort (translation table walk)" },
411411 { do_bad, SIGBUS, 0, "synchronous abort (translation table walk)" },
412412 { do_bad, SIGBUS, 0, "synchronous parity error" },
413− { do_bad, SIGBUS, 0, "asynchronous parity error" },
413+ { do_bad, SIGBUS, 0, "unknown 25" },
414414 { do_bad, SIGBUS, 0, "unknown 26" },
415415 { do_bad, SIGBUS, 0, "unknown 27" },
416− { do_bad, SIGBUS, 0, "synchronous parity error (translation table walk" },
417− { do_bad, SIGBUS, 0, "synchronous parity error (translation table walk" },
418− { do_bad, SIGBUS, 0, "synchronous parity error (translation table walk" },
419− { do_bad, SIGBUS, 0, "synchronous parity error (translation table walk" },
416+ { do_bad, SIGBUS, 0, "synchronous parity error (translation table walk)" },
417+ { do_bad, SIGBUS, 0, "synchronous parity error (translation table walk)" },
418+ { do_bad, SIGBUS, 0, "synchronous parity error (translation table walk)" },
419+ { do_bad, SIGBUS, 0, "synchronous parity error (translation table walk)" },
420420 { do_bad, SIGBUS, 0, "unknown 32" },
421421 { do_bad, SIGBUS, BUS_ADRALN, "alignment fault" },
422− { do_bad, SIGBUS, 0, "debug event" },
422+ { do_bad, SIGBUS, 0, "unknown 34" },
423423 { do_bad, SIGBUS, 0, "unknown 35" },
424424 { do_bad, SIGBUS, 0, "unknown 36" },
425425 { do_bad, SIGBUS, 0, "unknown 37" },
@@ -433,21 +433,21 @@ static struct fault_info { · 7 unmodified lines
433433 { do_bad, SIGBUS, 0, "unknown 45" },
434434 { do_bad, SIGBUS, 0, "unknown 46" },
435435 { do_bad, SIGBUS, 0, "unknown 47" },
436− { do_bad, SIGBUS, 0, "unknown 48" },
436+ { do_bad, SIGBUS, 0, "TLB conflict abort" },
437437 { do_bad, SIGBUS, 0, "unknown 49" },
438438 { do_bad, SIGBUS, 0, "unknown 50" },
439439 { do_bad, SIGBUS, 0, "unknown 51" },
440440 { do_bad, SIGBUS, 0, "implementation fault (lockdown abort)" },
441− { do_bad, SIGBUS, 0, "unknown 53" },
441+ { do_bad, SIGBUS, 0, "implementation fault (unsupported exclusive)" },
442442 { do_bad, SIGBUS, 0, "unknown 54" },
443443 { do_bad, SIGBUS, 0, "unknown 55" },
444444 { do_bad, SIGBUS, 0, "unknown 56" },
445445 { do_bad, SIGBUS, 0, "unknown 57" },
446− { do_bad, SIGBUS, 0, "implementation fault (coprocessor abort)" },
446+ { do_bad, SIGBUS, 0, "unknown 58" },
447447 { do_bad, SIGBUS, 0, "unknown 59" },
448448 { do_bad, SIGBUS, 0, "unknown 60" },
449− { do_bad, SIGBUS, 0, "unknown 61" },
450− { do_bad, SIGBUS, 0, "unknown 62" },
449+ { do_bad, SIGBUS, 0, "section domain fault" },
450+ { do_bad, SIGBUS, 0, "page domain fault" },
451451 { do_bad, SIGBUS, 0, "unknown 63" },
452452 };
453453
arch/arm64/mm/mmu.c+14−63
@@ -64,8 +64,12 @@ EXPORT_SYMBOL(phys_mem_access_prot); · 63 unmodified lines
6464
6565 static void __init *early_alloc(unsigned long sz)
6666 {
67− void *ptr = __va(memblock_alloc(sz, sz));
68− BUG_ON(!ptr);
67+ phys_addr_t phys;
68+ void *ptr;
69+
70+ phys = memblock_alloc(sz, sz);
71+ BUG_ON(!phys);
72+ ptr = __va(phys);
6973 memset(ptr, 0, sz);
7074 return ptr;
7175 }
@@ -81,55 +85,19 @@ static void split_pmd(pmd_t *pmd, pte_t *pte) · 9 unmodified lines
8185 do {
8286 /*
8387 * Need to have the least restrictive permissions available
84− * permissions will be fixed up later. Default the new page
85− * range as contiguous ptes.
88+ * permissions will be fixed up later
8689 */
87− set_pte(pte, pfn_pte(pfn, PAGE_KERNEL_EXEC_CONT));
90+ set_pte(pte, pfn_pte(pfn, PAGE_KERNEL_EXEC));
8891 pfn++;
8992 } while (pte++, i++, i < PTRS_PER_PTE);
9093 }
9194
92−/*
93− * Given a PTE with the CONT bit set, determine where the CONT range
94− * starts, and clear the entire range of PTE CONT bits.
95− */
96−static void clear_cont_pte_range(pte_t *pte, unsigned long addr)
97−{
98− int i;
99−
100− pte -= CONT_RANGE_OFFSET(addr);
101− for (i = 0; i < CONT_PTES; i++) {
102− set_pte(pte, pte_mknoncont(*pte));
103− pte++;
104− }
105− flush_tlb_all();
106−}
107−
108−/*
109− * Given a range of PTEs set the pfn and provided page protection flags
110− */
111−static void __populate_init_pte(pte_t *pte, unsigned long addr,
112− unsigned long end, phys_addr_t phys,
113− pgprot_t prot)
114−{
115− unsigned long pfn = __phys_to_pfn(phys);
116−
117− do {
118− /* clear all the bits except the pfn, then apply the prot */
119− set_pte(pte, pfn_pte(pfn, prot));
120− pte++;
121− pfn++;
122− addr += PAGE_SIZE;
123− } while (addr != end);
124−}
125−
12695 static void alloc_init_pte(pmd_t *pmd, unsigned long addr,
127− unsigned long end, phys_addr_t phys,
96+ unsigned long end, unsigned long pfn,
12897 pgprot_t prot,
12998 void *(*alloc)(unsigned long size))
13099 {
131100 pte_t *pte;
132− unsigned long next;
133101
134102 if (pmd_none(*pmd) || pmd_sect(*pmd)) {
135103 pte = alloc(PTRS_PER_PTE * sizeof(pte_t));
@@ -142,27 +110,9 @@ static void alloc_init_pte(pmd_t *pmd, unsigned long addr, · 6 unmodified lines
142110
143111 pte = pte_offset_kernel(pmd, addr);
144112 do {
145− next = min(end, (addr + CONT_SIZE) & CONT_MASK);
146− if (((addr | next | phys) & ~CONT_MASK) == 0) {
147− /* a block of CONT_PTES */
148− __populate_init_pte(pte, addr, next, phys,
149− __pgprot(pgprot_val(prot) | PTE_CONT));
150− } else {
151− /*
152− * If the range being split is already inside of a
153− * contiguous range but this PTE isn't going to be
154− * contiguous, then we want to unmark the adjacent
155− * ranges, then update the portion of the range we
156− * are interrested in.
157− */
158− clear_cont_pte_range(pte, addr);
159− __populate_init_pte(pte, addr, next, phys, prot);
160− }
161−
162− pte += (next - addr) >> PAGE_SHIFT;
163− phys += next - addr;
164− addr = next;
165− } while (addr != end);
113+ set_pte(pte, pfn_pte(pfn, prot));
114+ pfn++;
115+ } while (pte++, addr += PAGE_SIZE, addr != end);
166116 }
167117
168118 static void split_pud(pud_t *old_pud, pmd_t *pmd)
@@ -223,7 +173,8 @@ static void alloc_init_pmd(struct mm_struct *mm, pud_t *pud, · 54 unmodified lines
223173 }
224174 }
225175 } else {
226− alloc_init_pte(pmd, addr, next, phys, prot, alloc);
176+ alloc_init_pte(pmd, addr, next, __phys_to_pfn(phys),
177+ prot, alloc);
227178 }
228179 phys += next - addr;
229180 } while (pmd++, addr = next, addr != end);
arch/arm64/net/bpf_jit_comp.c+32−15
@@ -139,6 +139,12 @@ static inline int epilogue_offset(const struct jit_ctx *ctx) · 138 unmodified lines
139139 /* Stack must be multiples of 16B */
140140 #define STACK_ALIGN(sz) (((sz) + 15) & ~15)
141141
142+#define _STACK_SIZE \
143+ (MAX_BPF_STACK \
144+ + 4 /* extra for skb_copy_bits buffer */)
145+
146+#define STACK_SIZE STACK_ALIGN(_STACK_SIZE)
147+
142148 static void build_prologue(struct jit_ctx *ctx)
143149 {
144150 const u8 r6 = bpf2a64[BPF_REG_6];
@@ -150,10 +156,6 @@ static void build_prologue(struct jit_ctx *ctx) · 5 unmodified lines
150156 const u8 rx = bpf2a64[BPF_REG_X];
151157 const u8 tmp1 = bpf2a64[TMP_REG_1];
152158 const u8 tmp2 = bpf2a64[TMP_REG_2];
153− int stack_size = MAX_BPF_STACK;
154−
155− stack_size += 4; /* extra for skb_copy_bits buffer */
156− stack_size = STACK_ALIGN(stack_size);
157159
158160 /*
159161 * BPF prog stack layout
@@ -165,12 +167,13 @@ static void build_prologue(struct jit_ctx *ctx) · 5 unmodified lines
165167 * | ... | callee saved registers
166168 * +-----+
167169 * | | x25/x26
168− * BPF fp register => -80:+-----+
170+ * BPF fp register => -80:+-----+ <= (BPF_FP)
169171 * | |
170172 * | ... | BPF prog stack
171173 * | |
172− * | |
173− * current A64_SP => +-----+
174+ * +-----+ <= (BPF_FP - MAX_BPF_STACK)
175+ * |RSVD | JIT scratchpad
176+ * current A64_SP => +-----+ <= (BPF_FP - STACK_SIZE)
174177 * | |
175178 * | ... | Function call stack
176179 * | |
@@ -196,7 +199,7 @@ static void build_prologue(struct jit_ctx *ctx) · 19 unmodified lines
196199 emit(A64_MOV(1, fp, A64_SP), ctx);
197200
198201 /* Set up function call stack */
199− emit(A64_SUB_I(1, A64_SP, A64_SP, stack_size), ctx);
202+ emit(A64_SUB_I(1, A64_SP, A64_SP, STACK_SIZE), ctx);
200203
201204 /* Clear registers A and X */
202205 emit_a64_mov_i64(ra, 0, ctx);
@@ -213,13 +216,9 @@ static void build_epilogue(struct jit_ctx *ctx) · 10 unmodified lines
213216 const u8 fp = bpf2a64[BPF_REG_FP];
214217 const u8 tmp1 = bpf2a64[TMP_REG_1];
215218 const u8 tmp2 = bpf2a64[TMP_REG_2];
216− int stack_size = MAX_BPF_STACK;
217−
218− stack_size += 4; /* extra for skb_copy_bits buffer */
219− stack_size = STACK_ALIGN(stack_size);
220219
221220 /* We're done with BPF stack */
222− emit(A64_ADD_I(1, A64_SP, A64_SP, stack_size), ctx);
221+ emit(A64_ADD_I(1, A64_SP, A64_SP, STACK_SIZE), ctx);
223222
224223 /* Restore fs (x25) and x26 */
225224 emit(A64_POP(fp, A64_R(26), A64_SP), ctx);
@@ -591,7 +590,25 @@ emit_cond_jmp: · 365 unmodified lines
591590 case BPF_ST | BPF_MEM | BPF_H:
592591 case BPF_ST | BPF_MEM | BPF_B:
593592 case BPF_ST | BPF_MEM | BPF_DW:
594− goto notyet;
593+ /* Load imm to a register then store it */
594+ ctx->tmp_used = 1;
595+ emit_a64_mov_i(1, tmp2, off, ctx);
596+ emit_a64_mov_i(1, tmp, imm, ctx);
597+ switch (BPF_SIZE(code)) {
598+ case BPF_W:
599+ emit(A64_STR32(tmp, dst, tmp2), ctx);
600+ break;
601+ case BPF_H:
602+ emit(A64_STRH(tmp, dst, tmp2), ctx);
603+ break;
604+ case BPF_B:
605+ emit(A64_STRB(tmp, dst, tmp2), ctx);
606+ break;
607+ case BPF_DW:
608+ emit(A64_STR64(tmp, dst, tmp2), ctx);
609+ break;
610+ }
611+ break;
595612
596613 /* STX: *(size *)(dst + off) = src */
597614 case BPF_STX | BPF_MEM | BPF_W:
@@ -658,7 +675,7 @@ emit_cond_jmp: · 60 unmodified lines
658675 return -EINVAL;
659676 }
660677 emit_a64_mov_i64(r3, size, ctx);
661− emit(A64_ADD_I(1, r4, fp, MAX_BPF_STACK), ctx);
678+ emit(A64_SUB_I(1, r4, fp, STACK_SIZE), ctx);
662679 emit_a64_mov_i64(r5, (unsigned long)bpf_load_pointer, ctx);
663680 emit(A64_PUSH(A64_FP, A64_LR, A64_SP), ctx);
664681 emit(A64_MOV(1, A64_FP, A64_SP), ctx);
arch/blackfin/kernel/perf_event.c+1−1
@@ -14,7 +14,7 @@ · 13 unmodified lines
1414 * Copyright (C) 2008-2009 Red Hat, Inc., Ingo Molnar
1515 * Copyright (C) 2009 Jaswinder Singh Rajput
1616 * Copyright (C) 2009 Advanced Micro Devices, Inc., Robert Richter
17− * Copyright (C) 2008-2009 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
17+ * Copyright (C) 2008-2009 Red Hat, Inc., Peter Zijlstra
1818 * Copyright (C) 2009 Intel Corporation, <markus.t.metzger@intel.com>
1919 *
2020 * ppc:
arch/m68k/coldfire/m54xx.c+1−1
@@ -98,7 +98,7 @@ static void __init mcf54xx_bootmem_alloc(void) · 97 unmodified lines
9898 memstart = PAGE_ALIGN(_ramstart);
9999 min_low_pfn = PFN_DOWN(_rambase);
100100 start_pfn = PFN_DOWN(memstart);
101− max_low_pfn = PFN_DOWN(_ramend);
101+ max_pfn = max_low_pfn = PFN_DOWN(_ramend);
102102 high_memory = (void *)_ramend;
103103
104104 m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6;
arch/m68k/include/asm/unistd.h+1−1
@@ -4,7 +4,7 @@ · 3 unmodified lines
44 #include <uapi/asm/unistd.h>
55
66
7−#define NR_syscalls 375
7+#define NR_syscalls 376
88
99 #define __ARCH_WANT_OLD_READDIR
1010 #define __ARCH_WANT_OLD_STAT
arch/m68k/include/uapi/asm/unistd.h+1−0
@@ -380,5 +380,6 @@ · 379 unmodified lines
380380 #define __NR_sendmmsg 372
381381 #define __NR_userfaultfd 373
382382 #define __NR_membarrier 374
383+#define __NR_mlock2 375
383384
384385 #endif /* _UAPI_ASM_M68K_UNISTD_H_ */
arch/m68k/kernel/setup_no.c+6−3
@@ -238,11 +238,14 @@ void __init setup_arch(char **cmdline_p) · 237 unmodified lines
238238 * Give all the memory to the bootmap allocator, tell it to put the
239239 * boot mem_map at the start of memory.
240240 */
241+ min_low_pfn = PFN_DOWN(memory_start);
242+ max_pfn = max_low_pfn = PFN_DOWN(memory_end);
243+
241244 bootmap_size = init_bootmem_node(
242245 NODE_DATA(0),
243− memory_start >> PAGE_SHIFT, /* map goes here */
244− PAGE_OFFSET >> PAGE_SHIFT, /* 0 on coldfire */
245− memory_end >> PAGE_SHIFT);
246+ min_low_pfn, /* map goes here */
247+ PFN_DOWN(PAGE_OFFSET),
248+ max_pfn);
246249 /*
247250 * Free the usable memory, we have to make sure we do not free
248251 * the bootmem bitmap so we then reserve it after freeing it :-)
arch/m68k/kernel/syscalltable.S+1−0
@@ -395,3 +395,4 @@ ENTRY(sys_call_table) · 394 unmodified lines
395395 .long sys_sendmmsg
396396 .long sys_userfaultfd
397397 .long sys_membarrier
398+ .long sys_mlock2 /* 375 */
arch/m68k/mm/motorola.c+1−1
@@ -250,7 +250,7 @@ void __init paging_init(void) · 249 unmodified lines
250250 high_memory = phys_to_virt(max_addr);
251251
252252 min_low_pfn = availmem >> PAGE_SHIFT;
253− max_low_pfn = max_addr >> PAGE_SHIFT;
253+ max_pfn = max_low_pfn = max_addr >> PAGE_SHIFT;
254254
255255 for (i = 0; i < m68k_num_memory; i++) {
256256 addr = m68k_memory[i].addr;
arch/m68k/sun3/config.c+2−2
@@ -118,13 +118,13 @@ static void __init sun3_bootmem_alloc(unsigned long memory_start, · 117 unmodified lines
118118 memory_end = memory_end & PAGE_MASK;
119119
120120 start_page = __pa(memory_start) >> PAGE_SHIFT;
121− num_pages = __pa(memory_end) >> PAGE_SHIFT;
121+ max_pfn = num_pages = __pa(memory_end) >> PAGE_SHIFT;
122122
123123 high_memory = (void *)memory_end;
124124 availmem = memory_start;
125125
126126 m68k_setup_node(0);
127− availmem += init_bootmem_node(NODE_DATA(0), start_page, 0, num_pages);
127+ availmem += init_bootmem(start_page, num_pages);
128128 availmem = (availmem + (PAGE_SIZE-1)) & PAGE_MASK;
129129
130130 free_bootmem(__pa(availmem), memory_end - (availmem));
arch/mips/mm/dma-default.c+1−1
@@ -145,7 +145,7 @@ static void *mips_dma_alloc_coherent(struct device *dev, size_t size, · 144 unmodified lines
145145
146146 gfp = massage_gfp_flags(dev, gfp);
147147
148− if (IS_ENABLED(CONFIG_DMA_CMA) && !(gfp & GFP_ATOMIC))
148+ if (IS_ENABLED(CONFIG_DMA_CMA) && gfpflags_allow_blocking(gfp))
149149 page = dma_alloc_from_contiguous(dev,
150150 count, get_order(size));
151151 if (!page)
arch/mips/pci/pci-rt2880.c+2−2
@@ -11,6 +11,7 @@ · 10 unmodified lines
1111 * by the Free Software Foundation.
1212 */
1313
14+#include <linux/delay.h>
1415 #include <linux/types.h>
1516 #include <linux/pci.h>
1617 #include <linux/io.h>
@@ -232,8 +233,7 @@ static int rt288x_pci_probe(struct platform_device *pdev) · 215 unmodified lines
232233 ioport_resource.end = RT2880_PCI_IO_BASE + RT2880_PCI_IO_SIZE - 1;
233234
234235 rt2880_pci_reg_write(0, RT2880_PCI_REG_PCICFG_ADDR);
235− for (i = 0; i < 0xfffff; i++)
236− ;
236+ udelay(1);
237237
238238 rt2880_pci_reg_write(0x79, RT2880_PCI_REG_ARBCTL);
239239 rt2880_pci_reg_write(0x07FF0001, RT2880_PCI_REG_BAR0SETUP_ADDR);
arch/mips/pmcs-msp71xx/msp_setup.c+3−1
@@ -10,6 +10,8 @@ · 9 unmodified lines
1010 * option) any later version.
1111 */
1212
13+#include <linux/delay.h>
14+
1315 #include <asm/bootinfo.h>
1416 #include <asm/cacheflush.h>
1517 #include <asm/idle.h>
@@ -77,7 +79,7 @@ void msp7120_reset(void) · 61 unmodified lines
7779 */
7880
7981 /* Wait a bit for the DDRC to settle */
80− for (i = 0; i < 100000000; i++);
82+ mdelay(125);
8183
8284 #if defined(CONFIG_PMC_MSP7120_GW)
8385 /*
arch/mips/sni/reset.c+4−2
@@ -3,6 +3,8 @@ · 2 unmodified lines
33 *
44 * Reset a SNI machine.
55 */
6+#include <linux/delay.h>
7+
68 #include <asm/io.h>
79 #include <asm/reboot.h>
810 #include <asm/sni.h>
@@ -32,9 +34,9 @@ void sni_machine_restart(char *command) · 23 unmodified lines
3234 for (;;) {
3335 for (i = 0; i < 100; i++) {
3436 kb_wait();
35− for (j = 0; j < 100000 ; j++)
36− /* nothing */;
37+ udelay(50);
3738 outb_p(0xfe, 0x64); /* pulse reset low */
39+ udelay(50);
3840 }
3941 }
4042 }
arch/mn10300/Kconfig+1−3
@@ -1,6 +1,7 @@
11 config MN10300
22 def_bool y
33 select HAVE_OPROFILE
4+ select HAVE_UID16
45 select GENERIC_IRQ_SHOW
56 select ARCH_WANT_IPC_PARSE_VERSION
67 select HAVE_ARCH_TRACEHOOK
@@ -37,9 +38,6 @@ config HIGHMEM · 30 unmodified lines
3738 config NUMA
3839 def_bool n
3940
40−config UID16
41− def_bool y
42−
4341 config RWSEM_GENERIC_SPINLOCK
4442 def_bool y
4543
arch/nios2/mm/cacheflush.c+4−20
@@ -23,22 +23,6 @@ static void __flush_dcache(unsigned long start, unsigned long end) · 22 unmodified lines
2323 end += (cpuinfo.dcache_line_size - 1);
2424 end &= ~(cpuinfo.dcache_line_size - 1);
2525
26− for (addr = start; addr < end; addr += cpuinfo.dcache_line_size) {
27− __asm__ __volatile__ (" flushda 0(%0)\n"
28− : /* Outputs */
29− : /* Inputs */ "r"(addr)
30− /* : No clobber */);
31− }
32−}
33−
34−static void __flush_dcache_all(unsigned long start, unsigned long end)
35−{
36− unsigned long addr;
37−
38− start &= ~(cpuinfo.dcache_line_size - 1);
39− end += (cpuinfo.dcache_line_size - 1);
40− end &= ~(cpuinfo.dcache_line_size - 1);
41−
4226 if (end > start + cpuinfo.dcache_size)
4327 end = start + cpuinfo.dcache_size;
4428
@@ -112,7 +96,7 @@ static void flush_aliases(struct address_space *mapping, struct page *page) · 67 unmodified lines
11296
11397 void flush_cache_all(void)
11498 {
115− __flush_dcache_all(0, cpuinfo.dcache_size);
99+ __flush_dcache(0, cpuinfo.dcache_size);
116100 __flush_icache(0, cpuinfo.icache_size);
117101 }
118102
@@ -182,7 +166,7 @@ void __flush_dcache_page(struct address_space *mapping, struct page *page) · 63 unmodified lines
182166 */
183167 unsigned long start = (unsigned long)page_address(page);
184168
185− __flush_dcache_all(start, start + PAGE_SIZE);
169+ __flush_dcache(start, start + PAGE_SIZE);
186170 }
187171
188172 void flush_dcache_page(struct page *page)
@@ -268,7 +252,7 @@ void copy_from_user_page(struct vm_area_struct *vma, struct page *page, · 79 unmodified lines
268252 {
269253 flush_cache_page(vma, user_vaddr, page_to_pfn(page));
270254 memcpy(dst, src, len);
271− __flush_dcache_all((unsigned long)src, (unsigned long)src + len);
255+ __flush_dcache((unsigned long)src, (unsigned long)src + len);
272256 if (vma->vm_flags & VM_EXEC)
273257 __flush_icache((unsigned long)src, (unsigned long)src + len);
274258 }
@@ -279,7 +263,7 @@ void copy_to_user_page(struct vm_area_struct *vma, struct page *page, · 4 unmodified lines
279263 {
280264 flush_cache_page(vma, user_vaddr, page_to_pfn(page));
281265 memcpy(dst, src, len);
282− __flush_dcache_all((unsigned long)dst, (unsigned long)dst + len);
266+ __flush_dcache((unsigned long)dst, (unsigned long)dst + len);
283267 if (vma->vm_flags & VM_EXEC)
284268 __flush_icache((unsigned long)dst, (unsigned long)dst + len);
285269 }
arch/parisc/include/asm/pgtable.h+2−1
@@ -372,7 +372,8 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; } · 371 unmodified lines
372372 */
373373 #ifdef CONFIG_HUGETLB_PAGE
374374 #define pte_huge(pte) (pte_val(pte) & _PAGE_HUGE)
375−#define pte_mkhuge(pte) (__pte(pte_val(pte) | _PAGE_HUGE))
375+#define pte_mkhuge(pte) (__pte(pte_val(pte) | \
376+ (parisc_requires_coherency() ? 0 : _PAGE_HUGE)))
376377 #else
377378 #define pte_huge(pte) (0)
378379 #define pte_mkhuge(pte) (pte)
arch/parisc/include/uapi/asm/unistd.h+2−1
@@ -360,8 +360,9 @@ · 359 unmodified lines
360360 #define __NR_execveat (__NR_Linux + 342)
361361 #define __NR_membarrier (__NR_Linux + 343)
362362 #define __NR_userfaultfd (__NR_Linux + 344)
363+#define __NR_mlock2 (__NR_Linux + 345)
363364
364−#define __NR_Linux_syscalls (__NR_userfaultfd + 1)
365+#define __NR_Linux_syscalls (__NR_mlock2 + 1)
365366
366367
367368 #define __IGNORE_select /* newselect */
arch/parisc/kernel/pci.c+0−18
@@ -171,24 +171,6 @@ void pcibios_set_master(struct pci_dev *dev) · 170 unmodified lines
171171 }
172172
173173
174−void __init pcibios_init_bus(struct pci_bus *bus)
175−{
176− struct pci_dev *dev = bus->self;
177− unsigned short bridge_ctl;
178−
179− /* We deal only with pci controllers and pci-pci bridges. */
180− if (!dev || (dev->class >> 8) != PCI_CLASS_BRIDGE_PCI)
181− return;
182−
183− /* PCI-PCI bridge - set the cache line and default latency
184− (32) for primary and secondary buses. */
185− pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, 32);
186−
187− pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &bridge_ctl);
188− bridge_ctl |= PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR;
189− pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bridge_ctl);
190−}
191−
192174 /*
193175 * pcibios align resources() is called every time generic PCI code
194176 * wants to generate a new address. The process of looking for
arch/parisc/kernel/syscall_table.S+1−0
@@ -440,6 +440,7 @@ · 439 unmodified lines
440440 ENTRY_COMP(execveat)
441441 ENTRY_SAME(membarrier)
442442 ENTRY_SAME(userfaultfd)
443+ ENTRY_SAME(mlock2) /* 345 */
443444
444445
445446 .ifne (. - 90b) - (__NR_Linux_syscalls * (91b - 90b))
arch/powerpc/boot/dts/sbc8641d.dts+0−8
@@ -227,23 +227,15 @@ · 226 unmodified lines
227227 reg = <0x520 0x20>;
228228
229229 phy0: ethernet-phy@1f {
230− interrupt-parent = <&mpic>;
231− interrupts = <10 1>;
232230 reg = <0x1f>;
233231 };
234232 phy1: ethernet-phy@0 {
235− interrupt-parent = <&mpic>;
236− interrupts = <10 1>;
237233 reg = <0>;
238234 };
239235 phy2: ethernet-phy@1 {
240− interrupt-parent = <&mpic>;
241− interrupts = <10 1>;
242236 reg = <1>;
243237 };
244238 phy3: ethernet-phy@2 {
245− interrupt-parent = <&mpic>;
246− interrupts = <10 1>;
247239 reg = <2>;
248240 };
249241 tbi0: tbi-phy@11 {
arch/powerpc/include/asm/reg.h+1−0
@@ -108,6 +108,7 @@ · 107 unmodified lines
108108 #define MSR_TS_T __MASK(MSR_TS_T_LG) /* Transaction Transactional */
109109 #define MSR_TS_MASK (MSR_TS_T | MSR_TS_S) /* Transaction State bits */
110110 #define MSR_TM_ACTIVE(x) (((x) & MSR_TS_MASK) != 0) /* Transaction active? */
111+#define MSR_TM_RESV(x) (((x) & MSR_TS_MASK) == MSR_TS_MASK) /* Reserved */
111112 #define MSR_TM_TRANSACTIONAL(x) (((x) & MSR_TS_MASK) == MSR_TS_T)
112113 #define MSR_TM_SUSPENDED(x) (((x) & MSR_TS_MASK) == MSR_TS_S)
113114
arch/powerpc/kernel/eeh_driver.c+4−10
@@ -590,16 +590,10 @@ static int eeh_reset_device(struct eeh_pe *pe, struct pci_bus *bus) · 589 unmodified lines
590590 eeh_ops->configure_bridge(pe);
591591 eeh_pe_restore_bars(pe);
592592
593− /*
594− * If it's PHB PE, the frozen state on all available PEs should have
595− * been cleared by the PHB reset. Otherwise, we unfreeze the PE and its
596− * child PEs because they might be in frozen state.
597− */
598− if (!(pe->type & EEH_PE_PHB)) {
599− rc = eeh_clear_pe_frozen_state(pe, false);
600− if (rc)
601− return rc;
602− }
593+ /* Clear frozen state */
594+ rc = eeh_clear_pe_frozen_state(pe, false);
595+ if (rc)
596+ return rc;
603597
604598 /* Give the system 5 seconds to finish running the user-space
605599 * hotplug shutdown scripts, e.g. ifdown for ethernet. Yes,
arch/powerpc/kernel/process.c+18−0
@@ -551,6 +551,24 @@ static void tm_reclaim_thread(struct thread_struct *thr, · 550 unmodified lines
551551 msr_diff &= MSR_FP | MSR_VEC | MSR_VSX | MSR_FE0 | MSR_FE1;
552552 }
553553
554+ /*
555+ * Use the current MSR TM suspended bit to track if we have
556+ * checkpointed state outstanding.
557+ * On signal delivery, we'd normally reclaim the checkpointed
558+ * state to obtain stack pointer (see:get_tm_stackpointer()).
559+ * This will then directly return to userspace without going
560+ * through __switch_to(). However, if the stack frame is bad,
561+ * we need to exit this thread which calls __switch_to() which
562+ * will again attempt to reclaim the already saved tm state.
563+ * Hence we need to check that we've not already reclaimed
564+ * this state.
565+ * We do this using the current MSR, rather tracking it in
566+ * some specific thread_struct bit, as it has the additional
567+ * benifit of checking for a potential TM bad thing exception.
568+ */
569+ if (!MSR_TM_SUSPENDED(mfmsr()))
570+ return;
571+
554572 tm_reclaim(thr, thr->regs->msr, cause);
555573
556574 /* Having done the reclaim, we now have the checkpointed
arch/powerpc/kernel/signal_32.c+9−5
@@ -875,6 +875,15 @@ static long restore_tm_user_regs(struct pt_regs *regs, · 874 unmodified lines
875875 return 1;
876876 #endif /* CONFIG_SPE */
877877
878+ /* Get the top half of the MSR from the user context */
879+ if (__get_user(msr_hi, &tm_sr->mc_gregs[PT_MSR]))
880+ return 1;
881+ msr_hi <<= 32;
882+ /* If TM bits are set to the reserved value, it's an invalid context */
883+ if (MSR_TM_RESV(msr_hi))
884+ return 1;
885+ /* Pull in the MSR TM bits from the user context */
886+ regs->msr = (regs->msr & ~MSR_TS_MASK) | (msr_hi & MSR_TS_MASK);
878887 /* Now, recheckpoint. This loads up all of the checkpointed (older)
879888 * registers, including FP and V[S]Rs. After recheckpointing, the
880889 * transactional versions should be loaded.
@@ -884,11 +893,6 @@ static long restore_tm_user_regs(struct pt_regs *regs, · 3 unmodified lines
884893 current->thread.tm_texasr |= TEXASR_FS;
885894 /* This loads the checkpointed FP/VEC state, if used */
886895 tm_recheckpoint(&current->thread, msr);
887− /* Get the top half of the MSR */
888− if (__get_user(msr_hi, &tm_sr->mc_gregs[PT_MSR]))
889− return 1;
890− /* Pull in MSR TM from user context */
891− regs->msr = (regs->msr & ~MSR_TS_MASK) | ((msr_hi<<32) & MSR_TS_MASK);
892896
893897 /* This loads the speculative FP/VEC state, if used */
894898 if (msr & MSR_FP) {
arch/powerpc/kernel/signal_64.c+4−0
@@ -438,6 +438,10 @@ static long restore_tm_sigcontexts(struct pt_regs *regs, · 437 unmodified lines
438438
439439 /* get MSR separately, transfer the LE bit if doing signal return */
440440 err |= __get_user(msr, &sc->gp_regs[PT_MSR]);
441+ /* Don't allow reserved mode. */
442+ if (MSR_TM_RESV(msr))
443+ return -EINVAL;
444+
441445 /* pull in MSR TM from user context */
442446 regs->msr = (regs->msr & ~MSR_TS_MASK) | (msr & MSR_TS_MASK);
443447
arch/powerpc/platforms/powernv/opal-irqchip.c+29−29
@@ -43,11 +43,34 @@ static unsigned int opal_irq_count; · 42 unmodified lines
4343 static unsigned int *opal_irqs;
4444
4545 static void opal_handle_irq_work(struct irq_work *work);
46−static __be64 last_outstanding_events;
46+static u64 last_outstanding_events;
4747 static struct irq_work opal_event_irq_work = {
4848 .func = opal_handle_irq_work,
4949 };
5050
51+void opal_handle_events(uint64_t events)
52+{
53+ int virq, hwirq = 0;
54+ u64 mask = opal_event_irqchip.mask;
55+
56+ if (!in_irq() && (events & mask)) {
57+ last_outstanding_events = events;
58+ irq_work_queue(&opal_event_irq_work);
59+ return;
60+ }
61+
62+ while (events & mask) {
63+ hwirq = fls64(events) - 1;
64+ if (BIT_ULL(hwirq) & mask) {
65+ virq = irq_find_mapping(opal_event_irqchip.domain,
66+ hwirq);
67+ if (virq)
68+ generic_handle_irq(virq);
69+ }
70+ events &= ~BIT_ULL(hwirq);
71+ }
72+}
73+
5174 static void opal_event_mask(struct irq_data *d)
5275 {
5376 clear_bit(d->hwirq, &opal_event_irqchip.mask);
@@ -55,12 +78,12 @@ static void opal_event_mask(struct irq_data *d) · 1 unmodified line
5578
5679 static void opal_event_unmask(struct irq_data *d)
5780 {
81+ __be64 events;
82+
5883 set_bit(d->hwirq, &opal_event_irqchip.mask);
5984
60− opal_poll_events(&last_outstanding_events);
61− if (last_outstanding_events & opal_event_irqchip.mask)
62− /* Need to retrigger the interrupt */
63− irq_work_queue(&opal_event_irq_work);
85+ opal_poll_events(&events);
86+ opal_handle_events(be64_to_cpu(events));
6487 }
6588
6689 static int opal_event_set_type(struct irq_data *d, unsigned int flow_type)
@@ -96,29 +119,6 @@ static int opal_event_map(struct irq_domain *d, unsigned int irq, · 29 unmodified lines
96119 return 0;
97120 }
98121
99−void opal_handle_events(uint64_t events)
100−{
101− int virq, hwirq = 0;
102− u64 mask = opal_event_irqchip.mask;
103−
104− if (!in_irq() && (events & mask)) {
105− last_outstanding_events = events;
106− irq_work_queue(&opal_event_irq_work);
107− return;
108− }
109−
110− while (events & mask) {
111− hwirq = fls64(events) - 1;
112− if (BIT_ULL(hwirq) & mask) {
113− virq = irq_find_mapping(opal_event_irqchip.domain,
114− hwirq);
115− if (virq)
116− generic_handle_irq(virq);
117− }
118− events &= ~BIT_ULL(hwirq);
119− }
120−}
121−
122122 static irqreturn_t opal_interrupt(int irq, void *data)
123123 {
124124 __be64 events;
@@ -131,7 +131,7 @@ static irqreturn_t opal_interrupt(int irq, void *data) · 6 unmodified lines
131131
132132 static void opal_handle_irq_work(struct irq_work *work)
133133 {
134− opal_handle_events(be64_to_cpu(last_outstanding_events));
134+ opal_handle_events(last_outstanding_events);
135135 }
136136
137137 static int opal_event_match(struct irq_domain *h, struct device_node *node,
arch/sh/include/uapi/asm/unistd_64.h+1−1
@@ -278,7 +278,7 @@ · 277 unmodified lines
278278 #define __NR_fsetxattr 256
279279 #define __NR_getxattr 257
280280 #define __NR_lgetxattr 258
281−#define __NR_fgetxattr 269
281+#define __NR_fgetxattr 259
282282 #define __NR_listxattr 260
283283 #define __NR_llistxattr 261
284284 #define __NR_flistxattr 262
arch/sh/kernel/perf_event.c+1−1
@@ -10,7 +10,7 @@ · 9 unmodified lines
1010 * Copyright (C) 2008-2009 Red Hat, Inc., Ingo Molnar
1111 * Copyright (C) 2009 Jaswinder Singh Rajput
1212 * Copyright (C) 2009 Advanced Micro Devices, Inc., Robert Richter
13− * Copyright (C) 2008-2009 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
13+ * Copyright (C) 2008-2009 Red Hat, Inc., Peter Zijlstra
1414 * Copyright (C) 2009 Intel Corporation, <markus.t.metzger@intel.com>
1515 *
1616 * ppc:
arch/sparc/kernel/perf_event.c+1−1
@@ -9,7 +9,7 @@ · 8 unmodified lines
99 * Copyright (C) 2008-2009 Red Hat, Inc., Ingo Molnar
1010 * Copyright (C) 2009 Jaswinder Singh Rajput
1111 * Copyright (C) 2009 Advanced Micro Devices, Inc., Robert Richter
12− * Copyright (C) 2008-2009 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
12+ * Copyright (C) 2008-2009 Red Hat, Inc., Peter Zijlstra
1313 */
1414
1515 #include <linux/perf_event.h>
arch/tile/kernel/perf_event.c+1−1
@@ -21,7 +21,7 @@ · 20 unmodified lines
2121 * Copyright (C) 2008-2009 Red Hat, Inc., Ingo Molnar
2222 * Copyright (C) 2009 Jaswinder Singh Rajput
2323 * Copyright (C) 2009 Advanced Micro Devices, Inc., Robert Richter
24− * Copyright (C) 2008-2009 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
24+ * Copyright (C) 2008-2009 Red Hat, Inc., Peter Zijlstra
2525 * Copyright (C) 2009 Intel Corporation, <markus.t.metzger@intel.com>
2626 * Copyright (C) 2009 Google, Inc., Stephane Eranian
2727 */
arch/um/Makefile+1−1
@@ -131,7 +131,7 @@ export LDS_ELF_FORMAT := $(ELF_FORMAT) · 130 unmodified lines
131131 # The wrappers will select whether using "malloc" or the kernel allocator.
132132 LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
133133
134−LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt)) -lrt
134+LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt))
135135
136136 # Used by link-vmlinux.sh which has special support for um link
137137 export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
arch/um/drivers/net_user.c+6−4
@@ -249,21 +249,23 @@ void close_addr(unsigned char *addr, unsigned char *netmask, void *arg) · 248 unmodified lines
249249
250250 char *split_if_spec(char *str, ...)
251251 {
252− char **arg, *end;
252+ char **arg, *end, *ret = NULL;
253253 va_list ap;
254254
255255 va_start(ap, str);
256256 while ((arg = va_arg(ap, char **)) != NULL) {
257257 if (*str == '\0')
258− return NULL;
258+ goto out;
259259 end = strchr(str, ',');
260260 if (end != str)
261261 *arg = str;
262262 if (end == NULL)
263− return NULL;
263+ goto out;
264264 *end++ = '\0';
265265 str = end;
266266 }
267+ ret = str;
268+out:
267269 va_end(ap);
268− return str;
270+ return ret;
269271 }
arch/um/kernel/signal.c+1−1
@@ -69,7 +69,7 @@ void do_signal(struct pt_regs *regs) · 68 unmodified lines
6969 struct ksignal ksig;
7070 int handled_sig = 0;
7171
72− while (get_signal(&ksig)) {
72+ if (get_signal(&ksig)) {
7373 handled_sig = 1;
7474 /* Whee! Actually deliver the signal. */
7575 handle_signal(&ksig, regs);
arch/x86/boot/boot.h+0−1
@@ -23,7 +23,6 @@ · 22 unmodified lines
2323 #include <stdarg.h>
2424 #include <linux/types.h>
2525 #include <linux/edd.h>
26−#include <asm/boot.h>
2726 #include <asm/setup.h>
2827 #include "bitops.h"
2928 #include "ctype.h"
arch/x86/boot/video-mode.c+2−0
@@ -19,6 +19,8 @@ · 18 unmodified lines
1919 #include "video.h"
2020 #include "vesa.h"
2121
22+#include <uapi/asm/boot.h>
23+
2224 /*
2325 * Common variables
2426 */
arch/x86/boot/video.c+2−0
@@ -13,6 +13,8 @@ · 12 unmodified lines
1313 * Select video mode
1414 */
1515
16+#include <uapi/asm/boot.h>
17+
1618 #include "boot.h"
1719 #include "video.h"
1820 #include "vesa.h"
arch/x86/entry/entry_64.S+18−1
@@ -509,6 +509,17 @@ END(irq_entries_start) · 508 unmodified lines
509509 * tracking that we're in kernel mode.
510510 */
511511 SWAPGS
512+
513+ /*
514+ * We need to tell lockdep that IRQs are off. We can't do this until
515+ * we fix gsbase, and we should do it before enter_from_user_mode
516+ * (which can take locks). Since TRACE_IRQS_OFF idempotent,
517+ * the simplest way to handle it is to just call it twice if
518+ * we enter from user mode. There's no reason to optimize this since
519+ * TRACE_IRQS_OFF is a no-op if lockdep is off.
520+ */
521+ TRACE_IRQS_OFF
522+
512523 #ifdef CONFIG_CONTEXT_TRACKING
513524 call enter_from_user_mode
514525 #endif
@@ -1049,12 +1060,18 @@ ENTRY(error_entry) · 534 unmodified lines
10491060 SWAPGS
10501061
10511062 .Lerror_entry_from_usermode_after_swapgs:
1063+ /*
1064+ * We need to tell lockdep that IRQs are off. We can't do this until
1065+ * we fix gsbase, and we should do it before enter_from_user_mode
1066+ * (which can take locks).
1067+ */
1068+ TRACE_IRQS_OFF
10521069 #ifdef CONFIG_CONTEXT_TRACKING
10531070 call enter_from_user_mode
10541071 #endif
1072+ ret
10551073
10561074 .Lerror_entry_done:
1057−
10581075 TRACE_IRQS_OFF
10591076 ret
10601077
arch/x86/include/asm/page_types.h+9−7
@@ -9,19 +9,21 @@ · 8 unmodified lines
99 #define PAGE_SIZE (_AC(1,UL) << PAGE_SHIFT)
1010 #define PAGE_MASK (~(PAGE_SIZE-1))
1111
12+#define PMD_PAGE_SIZE (_AC(1, UL) << PMD_SHIFT)
13+#define PMD_PAGE_MASK (~(PMD_PAGE_SIZE-1))
14+
15+#define PUD_PAGE_SIZE (_AC(1, UL) << PUD_SHIFT)
16+#define PUD_PAGE_MASK (~(PUD_PAGE_SIZE-1))
17+
1218 #define __PHYSICAL_MASK ((phys_addr_t)((1ULL << __PHYSICAL_MASK_SHIFT) - 1))
1319 #define __VIRTUAL_MASK ((1UL << __VIRTUAL_MASK_SHIFT) - 1)
1420
15−/* Cast PAGE_MASK to a signed type so that it is sign-extended if
21+/* Cast *PAGE_MASK to a signed type so that it is sign-extended if
1622 virtual addresses are 32-bits but physical addresses are larger
1723 (ie, 32-bit PAE). */
1824 #define PHYSICAL_PAGE_MASK (((signed long)PAGE_MASK) & __PHYSICAL_MASK)
19−
20−#define PMD_PAGE_SIZE (_AC(1, UL) << PMD_SHIFT)
21−#define PMD_PAGE_MASK (~(PMD_PAGE_SIZE-1))
22−
23−#define PUD_PAGE_SIZE (_AC(1, UL) << PUD_SHIFT)
24−#define PUD_PAGE_MASK (~(PUD_PAGE_SIZE-1))
25+#define PHYSICAL_PMD_PAGE_MASK (((signed long)PMD_PAGE_MASK) & __PHYSICAL_MASK)
26+#define PHYSICAL_PUD_PAGE_MASK (((signed long)PUD_PAGE_MASK) & __PHYSICAL_MASK)
2527
2628 #define HPAGE_SHIFT PMD_SHIFT
2729 #define HPAGE_SIZE (_AC(1,UL) << HPAGE_SHIFT)
arch/x86/include/asm/pgtable_types.h+4−10
@@ -279,17 +279,14 @@ static inline pmdval_t native_pmd_val(pmd_t pmd) · 278 unmodified lines
279279 static inline pudval_t pud_pfn_mask(pud_t pud)
280280 {
281281 if (native_pud_val(pud) & _PAGE_PSE)
282− return PUD_PAGE_MASK & PHYSICAL_PAGE_MASK;
282+ return PHYSICAL_PUD_PAGE_MASK;
283283 else
284284 return PTE_PFN_MASK;
285285 }
286286
287287 static inline pudval_t pud_flags_mask(pud_t pud)
288288 {
289− if (native_pud_val(pud) & _PAGE_PSE)
290− return ~(PUD_PAGE_MASK & (pudval_t)PHYSICAL_PAGE_MASK);
291− else
292− return ~PTE_PFN_MASK;
289+ return ~pud_pfn_mask(pud);
293290 }
294291
295292 static inline pudval_t pud_flags(pud_t pud)
@@ -300,17 +297,14 @@ static inline pudval_t pud_flags(pud_t pud) · 4 unmodified lines
300297 static inline pmdval_t pmd_pfn_mask(pmd_t pmd)
301298 {
302299 if (native_pmd_val(pmd) & _PAGE_PSE)
303− return PMD_PAGE_MASK & PHYSICAL_PAGE_MASK;
300+ return PHYSICAL_PMD_PAGE_MASK;
304301 else
305302 return PTE_PFN_MASK;
306303 }
307304
308305 static inline pmdval_t pmd_flags_mask(pmd_t pmd)
309306 {
310− if (native_pmd_val(pmd) & _PAGE_PSE)
311− return ~(PMD_PAGE_MASK & (pmdval_t)PHYSICAL_PAGE_MASK);
312− else
313− return ~PTE_PFN_MASK;
307+ return ~pmd_pfn_mask(pmd);
314308 }
315309
316310 static inline pmdval_t pmd_flags(pmd_t pmd)
arch/x86/include/asm/x86_init.h+0−1
@@ -1,7 +1,6 @@
11 #ifndef _ASM_X86_PLATFORM_H
22 #define _ASM_X86_PLATFORM_H
33
4−#include <asm/pgtable_types.h>
54 #include <asm/bootparam.h>
65
76 struct mpc_bus;
arch/x86/kernel/cpu/microcode/core.c+1−0
@@ -698,3 +698,4 @@ int __init microcode_init(void) · 697 unmodified lines
698698 return error;
699699
700700 }
701+late_initcall(microcode_init);
arch/x86/kernel/cpu/perf_event.c+1−1
@@ -5,7 +5,7 @@ · 4 unmodified lines
55 * Copyright (C) 2008-2009 Red Hat, Inc., Ingo Molnar
66 * Copyright (C) 2009 Jaswinder Singh Rajput
77 * Copyright (C) 2009 Advanced Micro Devices, Inc., Robert Richter
8− * Copyright (C) 2008-2009 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
8+ * Copyright (C) 2008-2009 Red Hat, Inc., Peter Zijlstra
99 * Copyright (C) 2009 Intel Corporation, <markus.t.metzger@intel.com>
1010 * Copyright (C) 2009 Google, Inc., Stephane Eranian
1111 *
arch/x86/kernel/cpu/perf_event.h+3−2
@@ -5,7 +5,7 @@ · 4 unmodified lines
55 * Copyright (C) 2008-2009 Red Hat, Inc., Ingo Molnar
66 * Copyright (C) 2009 Jaswinder Singh Rajput
77 * Copyright (C) 2009 Advanced Micro Devices, Inc., Robert Richter
8− * Copyright (C) 2008-2009 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
8+ * Copyright (C) 2008-2009 Red Hat, Inc., Peter Zijlstra
99 * Copyright (C) 2009 Intel Corporation, <markus.t.metzger@intel.com>
1010 * Copyright (C) 2009 Google, Inc., Stephane Eranian
1111 *
@@ -387,7 +387,7 @@ struct cpu_hw_events { · 375 unmodified lines
387387 /* Check flags and event code/umask, and set the HSW N/A flag */
388388 #define INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_NA(code, n) \
389389 __EVENT_CONSTRAINT(code, n, \
390− INTEL_ARCH_EVENT_MASK|INTEL_ARCH_EVENT_MASK, \
390+ INTEL_ARCH_EVENT_MASK|X86_ALL_EVENT_FLAGS, \
391391 HWEIGHT(n), 0, PERF_X86_EVENT_PEBS_NA_HSW)
392392
393393
@@ -627,6 +627,7 @@ struct x86_perf_task_context { · 233 unmodified lines
627627 u64 lbr_from[MAX_LBR_ENTRIES];
628628 u64 lbr_to[MAX_LBR_ENTRIES];
629629 u64 lbr_info[MAX_LBR_ENTRIES];
630+ int tos;
630631 int lbr_callstack_users;
631632 int lbr_stack_state;
632633 };
arch/x86/kernel/cpu/perf_event_intel.c+1−1
@@ -232,7 +232,7 @@ static struct event_constraint intel_hsw_event_constraints[] = { · 231 unmodified lines
232232 FIXED_EVENT_CONSTRAINT(0x00c0, 0), /* INST_RETIRED.ANY */
233233 FIXED_EVENT_CONSTRAINT(0x003c, 1), /* CPU_CLK_UNHALTED.CORE */
234234 FIXED_EVENT_CONSTRAINT(0x0300, 2), /* CPU_CLK_UNHALTED.REF */
235− INTEL_EVENT_CONSTRAINT(0x48, 0x4), /* L1D_PEND_MISS.* */
235+ INTEL_UEVENT_CONSTRAINT(0x148, 0x4), /* L1D_PEND_MISS.PENDING */
236236 INTEL_UEVENT_CONSTRAINT(0x01c0, 0x2), /* INST_RETIRED.PREC_DIST */
237237 INTEL_EVENT_CONSTRAINT(0xcd, 0x8), /* MEM_TRANS_RETIRED.LOAD_LATENCY */
238238 /* CYCLE_ACTIVITY.CYCLES_L1D_PENDING */
arch/x86/kernel/cpu/perf_event_intel_cqm.c+1−1
@@ -298,7 +298,7 @@ static bool __match_event(struct perf_event *a, struct perf_event *b) · 297 unmodified lines
298298 static inline struct perf_cgroup *event_to_cgroup(struct perf_event *event)
299299 {
300300 if (event->attach_state & PERF_ATTACH_TASK)
301− return perf_cgroup_from_task(event->hw.target);
301+ return perf_cgroup_from_task(event->hw.target, event->ctx);
302302
303303 return event->cgrp;
304304 }
arch/x86/kernel/cpu/perf_event_intel_lbr.c+3−1
@@ -239,7 +239,7 @@ static void __intel_pmu_lbr_restore(struct x86_perf_task_context *task_ctx) · 238 unmodified lines
239239 }
240240
241241 mask = x86_pmu.lbr_nr - 1;
242− tos = intel_pmu_lbr_tos();
242+ tos = task_ctx->tos;
243243 for (i = 0; i < tos; i++) {
244244 lbr_idx = (tos - i) & mask;
245245 wrmsrl(x86_pmu.lbr_from + lbr_idx, task_ctx->lbr_from[i]);
@@ -247,6 +247,7 @@ static void __intel_pmu_lbr_restore(struct x86_perf_task_context *task_ctx) · 1 unmodified line
247247 if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO)
248248 wrmsrl(MSR_LBR_INFO_0 + lbr_idx, task_ctx->lbr_info[i]);
249249 }
250+ wrmsrl(x86_pmu.lbr_tos, tos);
250251 task_ctx->lbr_stack_state = LBR_NONE;
251252 }
252253
@@ -270,6 +271,7 @@ static void __intel_pmu_lbr_save(struct x86_perf_task_context *task_ctx) · 17 unmodified lines
270271 if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO)
271272 rdmsrl(MSR_LBR_INFO_0 + lbr_idx, task_ctx->lbr_info[i]);
272273 }
274+ task_ctx->tos = tos;
273275 task_ctx->lbr_stack_state = LBR_VALID;
274276 }
275277
arch/x86/kernel/irq_work.c+1−1
@@ -1,7 +1,7 @@
11 /*
22 * x86 specific code for irq_work
33 *
4− * Copyright (C) 2010 Red Hat, Inc., Peter Zijlstra <pzijlstr@redhat.com>
4+ * Copyright (C) 2010 Red Hat, Inc., Peter Zijlstra
55 */
66
77 #include <linux/kernel.h>
arch/x86/kernel/pmem.c+12−0
@@ -4,10 +4,22 @@ · 3 unmodified lines
44 */
55 #include <linux/platform_device.h>
66 #include <linux/module.h>
7+#include <linux/ioport.h>
8+
9+static int found(u64 start, u64 end, void *data)
10+{
11+ return 1;
12+}
713
814 static __init int register_e820_pmem(void)
915 {
16+ char *pmem = "Persistent Memory (legacy)";
1017 struct platform_device *pdev;
18+ int rc;
19+
20+ rc = walk_iomem_res(pmem, IORESOURCE_MEM, 0, -1, NULL, found);
21+ if (rc <= 0)
22+ return 0;
1123
1224 /*
1325 * See drivers/nvdimm/e820.c for the implementation, this is
arch/x86/kernel/setup.c+0−2
@@ -1250,8 +1250,6 @@ void __init setup_arch(char **cmdline_p) · 1249 unmodified lines
12501250 if (efi_enabled(EFI_BOOT))
12511251 efi_apply_memmap_quirks();
12521252 #endif
1253−
1254− microcode_init();
12551253 }
12561254
12571255 #ifdef CONFIG_X86_32
arch/x86/kernel/signal.c+10−7
@@ -690,12 +690,15 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs) · 689 unmodified lines
690690 signal_setup_done(failed, ksig, stepping);
691691 }
692692
693−#ifdef CONFIG_X86_32
694−#define NR_restart_syscall __NR_restart_syscall
695−#else /* !CONFIG_X86_32 */
696−#define NR_restart_syscall \
697− test_thread_flag(TIF_IA32) ? __NR_ia32_restart_syscall : __NR_restart_syscall
698−#endif /* CONFIG_X86_32 */
693+static inline unsigned long get_nr_restart_syscall(const struct pt_regs *regs)
694+{
695+#if defined(CONFIG_X86_32) || !defined(CONFIG_X86_64)
696+ return __NR_restart_syscall;
697+#else /* !CONFIG_X86_32 && CONFIG_X86_64 */
698+ return test_thread_flag(TIF_IA32) ? __NR_ia32_restart_syscall :
699+ __NR_restart_syscall | (regs->orig_ax & __X32_SYSCALL_BIT);
700+#endif /* CONFIG_X86_32 || !CONFIG_X86_64 */
701+}
699702
700703 /*
701704 * Note that 'init' is a special process: it doesn't get signals it doesn't
@@ -724,7 +727,7 @@ void do_signal(struct pt_regs *regs) · 22 unmodified lines
724727 break;
725728
726729 case -ERESTART_RESTARTBLOCK:
727− regs->ax = NR_restart_syscall;
730+ regs->ax = get_nr_restart_syscall(regs);
728731 regs->ip -= 2;
729732 break;
730733 }
arch/x86/kernel/smpboot.c+5−4
@@ -509,7 +509,7 @@ void __inquire_remote_apic(int apicid) · 508 unmodified lines
509509 */
510510 #define UDELAY_10MS_DEFAULT 10000
511511
512−static unsigned int init_udelay = INT_MAX;
512+static unsigned int init_udelay = UINT_MAX;
513513
514514 static int __init cpu_init_udelay(char *str)
515515 {
@@ -522,14 +522,15 @@ early_param("cpu_init_udelay", cpu_init_udelay); · 6 unmodified lines
522522 static void __init smp_quirk_init_udelay(void)
523523 {
524524 /* if cmdline changed it from default, leave it alone */
525− if (init_udelay != INT_MAX)
525+ if (init_udelay != UINT_MAX)
526526 return;
527527
528528 /* if modern processor, use no delay */
529529 if (((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && (boot_cpu_data.x86 == 6)) ||
530− ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) && (boot_cpu_data.x86 >= 0xF)))
530+ ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) && (boot_cpu_data.x86 >= 0xF))) {
531531 init_udelay = 0;
532−
532+ return;
533+ }
533534 /* else, use legacy delay */
534535 init_udelay = UDELAY_10MS_DEFAULT;
535536 }
arch/x86/mm/mpx.c+3−3
@@ -101,19 +101,19 @@ static int get_reg_offset(struct insn *insn, struct pt_regs *regs, · 100 unmodified lines
101101 switch (type) {
102102 case REG_TYPE_RM:
103103 regno = X86_MODRM_RM(insn->modrm.value);
104− if (X86_REX_B(insn->rex_prefix.value) == 1)
104+ if (X86_REX_B(insn->rex_prefix.value))
105105 regno += 8;
106106 break;
107107
108108 case REG_TYPE_INDEX:
109109 regno = X86_SIB_INDEX(insn->sib.value);
110− if (X86_REX_X(insn->rex_prefix.value) == 1)
110+ if (X86_REX_X(insn->rex_prefix.value))
111111 regno += 8;
112112 break;
113113
114114 case REG_TYPE_BASE:
115115 regno = X86_SIB_BASE(insn->sib.value);
116− if (X86_REX_B(insn->rex_prefix.value) == 1)
116+ if (X86_REX_B(insn->rex_prefix.value))
117117 regno += 8;
118118 break;
119119
arch/x86/pci/bus_numa.c+2−11
@@ -50,18 +50,9 @@ void x86_pci_root_bus_resources(int bus, struct list_head *resources) · 49 unmodified lines
5050 if (!found)
5151 pci_add_resource(resources, &info->busn);
5252
53− list_for_each_entry(root_res, &info->resources, list) {
54− struct resource *res;
55− struct resource *root;
53+ list_for_each_entry(root_res, &info->resources, list)
54+ pci_add_resource(resources, &root_res->res);
5655
57− res = &root_res->res;
58− pci_add_resource(resources, res);
59− if (res->flags & IORESOURCE_IO)
60− root = &ioport_resource;
61− else
62− root = &iomem_resource;
63− insert_resource(root, res);
64− }
6556 return;
6657
6758 default_resources:
arch/x86/um/signal.c+10−8
@@ -211,7 +211,7 @@ static int copy_sc_from_user(struct pt_regs *regs, · 210 unmodified lines
211211 if (err)
212212 return 1;
213213
214− err = convert_fxsr_from_user(&fpx, sc.fpstate);
214+ err = convert_fxsr_from_user(&fpx, (void *)sc.fpstate);
215215 if (err)
216216 return 1;
217217
@@ -227,7 +227,7 @@ static int copy_sc_from_user(struct pt_regs *regs, · 9 unmodified lines
227227 {
228228 struct user_i387_struct fp;
229229
230− err = copy_from_user(&fp, sc.fpstate,
230+ err = copy_from_user(&fp, (void *)sc.fpstate,
231231 sizeof(struct user_i387_struct));
232232 if (err)
233233 return 1;
@@ -291,7 +291,7 @@ static int copy_sc_to_user(struct sigcontext __user *to, · 57 unmodified lines
291291 #endif
292292 #undef PUTREG
293293 sc.oldmask = mask;
294− sc.fpstate = to_fp;
294+ sc.fpstate = (unsigned long)to_fp;
295295
296296 err = copy_to_user(to, &sc, sizeof(struct sigcontext));
297297 if (err)
@@ -468,12 +468,10 @@ long sys_sigreturn(void) · 170 unmodified lines
468468 struct sigframe __user *frame = (struct sigframe __user *)(sp - 8);
469469 sigset_t set;
470470 struct sigcontext __user *sc = &frame->sc;
471− unsigned long __user *oldmask = &sc->oldmask;
472− unsigned long __user *extramask = frame->extramask;
473471 int sig_size = (_NSIG_WORDS - 1) * sizeof(unsigned long);
474472
475− if (copy_from_user(&set.sig[0], oldmask, sizeof(set.sig[0])) ||
476− copy_from_user(&set.sig[1], extramask, sig_size))
473+ if (copy_from_user(&set.sig[0], (void *)sc->oldmask, sizeof(set.sig[0])) ||
474+ copy_from_user(&set.sig[1], frame->extramask, sig_size))
477475 goto segfault;
478476
479477 set_current_blocked(&set);
@@ -505,6 +503,7 @@ int setup_signal_stack_si(unsigned long stack_top, struct ksignal *ksig, · 25 unmodified lines
505503 {
506504 struct rt_sigframe __user *frame;
507505 int err = 0, sig = ksig->sig;
506+ unsigned long fp_to;
508507
509508 frame = (struct rt_sigframe __user *)
510509 round_down(stack_top - sizeof(struct rt_sigframe), 16);
@@ -526,7 +525,10 @@ int setup_signal_stack_si(unsigned long stack_top, struct ksignal *ksig, · 15 unmodified lines
526525 err |= __save_altstack(&frame->uc.uc_stack, PT_REGS_SP(regs));
527526 err |= copy_sc_to_user(&frame->uc.uc_mcontext, &frame->fpstate, regs,
528527 set->sig[0]);
529− err |= __put_user(&frame->fpstate, &frame->uc.uc_mcontext.fpstate);
528+
529+ fp_to = (unsigned long)&frame->fpstate;
530+
531+ err |= __put_user(fp_to, &frame->uc.uc_mcontext.fpstate);
530532 if (sizeof(*set) == 16) {
531533 err |= __put_user(set->sig[0], &frame->uc.uc_sigmask.sig[0]);
532534 err |= __put_user(set->sig[1], &frame->uc.uc_sigmask.sig[1]);
block/blk-cgroup.c+3−3
@@ -1127,15 +1127,15 @@ void blkcg_exit_queue(struct request_queue *q) · 1126 unmodified lines
11271127 * of the main cic data structures. For now we allow a task to change
11281128 * its cgroup only if it's the only owner of its ioc.
11291129 */
1130−static int blkcg_can_attach(struct cgroup_subsys_state *css,
1131− struct cgroup_taskset *tset)
1130+static int blkcg_can_attach(struct cgroup_taskset *tset)
11321131 {
11331132 struct task_struct *task;
1133+ struct cgroup_subsys_state *dst_css;
11341134 struct io_context *ioc;
11351135 int ret = 0;
11361136
11371137 /* task_lock() is needed to avoid races with exit_io_context() */
1138− cgroup_taskset_for_each(task, tset) {
1138+ cgroup_taskset_for_each(task, dst_css, tset) {
11391139 task_lock(task);
11401140 ioc = task->io_context;
11411141 if (ioc && atomic_read(&ioc->nr_tasks) > 1)
block/blk-core.c+19−14
@@ -2114,7 +2114,8 @@ blk_qc_t submit_bio(int rw, struct bio *bio) · 2113 unmodified lines
21142114 EXPORT_SYMBOL(submit_bio);
21152115
21162116 /**
2117− * blk_rq_check_limits - Helper function to check a request for the queue limit
2117+ * blk_cloned_rq_check_limits - Helper function to check a cloned request
2118+ * for new the queue limits
21182119 * @q: the queue
21192120 * @rq: the request being checked
21202121 *
@@ -2125,20 +2126,13 @@ EXPORT_SYMBOL(submit_bio); · 4 unmodified lines
21252126 * after it is inserted to @q, it should be checked against @q before
21262127 * the insertion using this generic function.
21272128 *
2128− * This function should also be useful for request stacking drivers
2129− * in some cases below, so export this function.
21302129 * Request stacking drivers like request-based dm may change the queue
2131− * limits while requests are in the queue (e.g. dm's table swapping).
2132− * Such request stacking drivers should check those requests against
2133− * the new queue limits again when they dispatch those requests,
2134− * although such checkings are also done against the old queue limits
2135− * when submitting requests.
2130+ * limits when retrying requests on other queues. Those requests need
2131+ * to be checked against the new queue limits again during dispatch.
21362132 */
2137−int blk_rq_check_limits(struct request_queue *q, struct request *rq)
2133+static int blk_cloned_rq_check_limits(struct request_queue *q,
2134+ struct request *rq)
21382135 {
2139− if (!rq_mergeable(rq))
2140− return 0;
2141−
21422136 if (blk_rq_sectors(rq) > blk_queue_get_max_sectors(q, rq->cmd_flags)) {
21432137 printk(KERN_ERR "%s: over max size limit.\n", __func__);
21442138 return -EIO;
@@ -2158,7 +2152,6 @@ int blk_rq_check_limits(struct request_queue *q, struct request *rq) · 13 unmodified lines
21582152
21592153 return 0;
21602154 }
2161−EXPORT_SYMBOL_GPL(blk_rq_check_limits);
21622155
21632156 /**
21642157 * blk_insert_cloned_request - Helper for stacking drivers to submit a request
@@ -2170,7 +2163,7 @@ int blk_insert_cloned_request(struct request_queue *q, struct request *rq) · 5 unmodified lines
21702163 unsigned long flags;
21712164 int where = ELEVATOR_INSERT_BACK;
21722165
2173− if (blk_rq_check_limits(q, rq))
2166+ if (blk_cloned_rq_check_limits(q, rq))
21742167 return -EIO;
21752168
21762169 if (rq->rq_disk &&
@@ -3412,6 +3405,9 @@ int blk_pre_runtime_suspend(struct request_queue *q) · 1235 unmodified lines
34123405 {
34133406 int ret = 0;
34143407
3408+ if (!q->dev)
3409+ return ret;
3410+
34153411 spin_lock_irq(q->queue_lock);
34163412 if (q->nr_pending) {
34173413 ret = -EBUSY;
@@ -3439,6 +3435,9 @@ EXPORT_SYMBOL(blk_pre_runtime_suspend); · 21 unmodified lines
34393435 */
34403436 void blk_post_runtime_suspend(struct request_queue *q, int err)
34413437 {
3438+ if (!q->dev)
3439+ return;
3440+
34423441 spin_lock_irq(q->queue_lock);
34433442 if (!err) {
34443443 q->rpm_status = RPM_SUSPENDED;
@@ -3463,6 +3462,9 @@ EXPORT_SYMBOL(blk_post_runtime_suspend); · 18 unmodified lines
34633462 */
34643463 void blk_pre_runtime_resume(struct request_queue *q)
34653464 {
3465+ if (!q->dev)
3466+ return;
3467+
34663468 spin_lock_irq(q->queue_lock);
34673469 q->rpm_status = RPM_RESUMING;
34683470 spin_unlock_irq(q->queue_lock);
@@ -3485,6 +3487,9 @@ EXPORT_SYMBOL(blk_pre_runtime_resume); · 16 unmodified lines
34853487 */
34863488 void blk_post_runtime_resume(struct request_queue *q, int err)
34873489 {
3490+ if (!q->dev)
3491+ return;
3492+
34883493 spin_lock_irq(q->queue_lock);
34893494 if (!err) {
34903495 q->rpm_status = RPM_ACTIVE;
block/blk-merge.c+30−5
@@ -76,6 +76,9 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, · 75 unmodified lines
7676 struct bio_vec bv, bvprv, *bvprvp = NULL;
7777 struct bvec_iter iter;
7878 unsigned seg_size = 0, nsegs = 0, sectors = 0;
79+ unsigned front_seg_size = bio->bi_seg_front_size;
80+ bool do_split = true;
81+ struct bio *new = NULL;
7982
8083 bio_for_each_segment(bv, bio, iter) {
8184 if (sectors + (bv.bv_len >> 9) > queue_max_sectors(q))
@@ -98,8 +101,11 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, · 16 unmodified lines
98101
99102 seg_size += bv.bv_len;
100103 bvprv = bv;
101− bvprvp = &bv;
104+ bvprvp = &bvprv;
102105 sectors += bv.bv_len >> 9;
106+
107+ if (nsegs == 1 && seg_size > front_seg_size)
108+ front_seg_size = seg_size;
103109 continue;
104110 }
105111 new_segment:
@@ -108,16 +114,29 @@ new_segment: · 2 unmodified lines
108114
109115 nsegs++;
110116 bvprv = bv;
111− bvprvp = &bv;
117+ bvprvp = &bvprv;
112118 seg_size = bv.bv_len;
113119 sectors += bv.bv_len >> 9;
120+
121+ if (nsegs == 1 && seg_size > front_seg_size)
122+ front_seg_size = seg_size;
114123 }
115124
116− *segs = nsegs;
117− return NULL;
125+ do_split = false;
118126 split:
119127 *segs = nsegs;
120− return bio_split(bio, sectors, GFP_NOIO, bs);
128+
129+ if (do_split) {
130+ new = bio_split(bio, sectors, GFP_NOIO, bs);
131+ if (new)
132+ bio = new;
133+ }
134+
135+ bio->bi_seg_front_size = front_seg_size;
136+ if (seg_size > bio->bi_seg_back_size)
137+ bio->bi_seg_back_size = seg_size;
138+
139+ return do_split ? new : NULL;
121140 }
122141
123142 void blk_queue_split(struct request_queue *q, struct bio **bio,
@@ -412,6 +431,12 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq, · 288 unmodified lines
412431 if (sg)
413432 sg_mark_end(sg);
414433
434+ /*
435+ * Something must have been wrong if the figured number of
436+ * segment is bigger than number of req's physical segments
437+ */
438+ WARN_ON(nsegs > rq->nr_phys_segments);
439+
415440 return nsegs;
416441 }
417442 EXPORT_SYMBOL(blk_rq_map_sg);
block/blk-mq.c+9−5
@@ -1291,15 +1291,16 @@ static blk_qc_t blk_mq_make_request(struct request_queue *q, struct bio *bio) · 1290 unmodified lines
12911291 blk_mq_bio_to_request(rq, bio);
12921292
12931293 /*
1294− * we do limited pluging. If bio can be merged, do merge.
1294+ * We do limited pluging. If the bio can be merged, do that.
12951295 * Otherwise the existing request in the plug list will be
12961296 * issued. So the plug list will have one request at most
12971297 */
12981298 if (plug) {
12991299 /*
13001300 * The plug list might get flushed before this. If that
1301− * happens, same_queue_rq is invalid and plug list is empty
1302− **/
1301+ * happens, same_queue_rq is invalid and plug list is
1302+ * empty
1303+ */
13031304 if (same_queue_rq && !list_empty(&plug->mq_list)) {
13041305 old_rq = same_queue_rq;
13051306 list_del_init(&old_rq->queuelist);
@@ -1380,12 +1381,15 @@ static blk_qc_t blk_sq_make_request(struct request_queue *q, struct bio *bio) · 74 unmodified lines
13801381 blk_mq_bio_to_request(rq, bio);
13811382 if (!request_count)
13821383 trace_block_plug(q);
1383− else if (request_count >= BLK_MAX_REQUEST_COUNT) {
1384+
1385+ blk_mq_put_ctx(data.ctx);
1386+
1387+ if (request_count >= BLK_MAX_REQUEST_COUNT) {
13841388 blk_flush_plug_list(plug, false);
13851389 trace_block_plug(q);
13861390 }
1391+
13871392 list_add_tail(&rq->queuelist, &plug->mq_list);
1388− blk_mq_put_ctx(data.ctx);
13891393 return cookie;
13901394 }
13911395
block/blk-settings.c+16−20
@@ -91,7 +91,8 @@ void blk_set_default_limits(struct queue_limits *lim) · 90 unmodified lines
9191 lim->seg_boundary_mask = BLK_SEG_BOUNDARY_MASK;
9292 lim->virt_boundary_mask = 0;
9393 lim->max_segment_size = BLK_MAX_SEGMENT_SIZE;
94− lim->max_sectors = lim->max_hw_sectors = BLK_SAFE_MAX_SECTORS;
94+ lim->max_sectors = lim->max_dev_sectors = lim->max_hw_sectors =
95+ BLK_SAFE_MAX_SECTORS;
9596 lim->chunk_sectors = 0;
9697 lim->max_write_same_sectors = 0;
9798 lim->max_discard_sectors = 0;
@@ -127,6 +128,7 @@ void blk_set_stacking_limits(struct queue_limits *lim) · 29 unmodified lines
127128 lim->max_hw_sectors = UINT_MAX;
128129 lim->max_segment_size = UINT_MAX;
129130 lim->max_sectors = UINT_MAX;
131+ lim->max_dev_sectors = UINT_MAX;
130132 lim->max_write_same_sectors = UINT_MAX;
131133 }
132134 EXPORT_SYMBOL(blk_set_stacking_limits);
@@ -214,8 +216,8 @@ void blk_queue_bounce_limit(struct request_queue *q, u64 max_addr) · 81 unmodified lines
214216 EXPORT_SYMBOL(blk_queue_bounce_limit);
215217
216218 /**
217− * blk_limits_max_hw_sectors - set hard and soft limit of max sectors for request
218− * @limits: the queue limits
219+ * blk_queue_max_hw_sectors - set max sectors for a request for this queue
220+ * @q: the request queue for the device
219221 * @max_hw_sectors: max hardware sectors in the usual 512b unit
220222 *
221223 * Description:
@@ -224,13 +226,19 @@ EXPORT_SYMBOL(blk_queue_bounce_limit); · 2 unmodified lines
224226 * the device driver based upon the capabilities of the I/O
225227 * controller.
226228 *
229+ * max_dev_sectors is a hard limit imposed by the storage device for
230+ * READ/WRITE requests. It is set by the disk driver.
231+ *
227232 * max_sectors is a soft limit imposed by the block layer for
228233 * filesystem type requests. This value can be overridden on a
229234 * per-device basis in /sys/block/<device>/queue/max_sectors_kb.
230235 * The soft limit can not exceed max_hw_sectors.
231236 **/
232−void blk_limits_max_hw_sectors(struct queue_limits *limits, unsigned int max_hw_sectors)
237+void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_sectors)
233238 {
239+ struct queue_limits *limits = &q->limits;
240+ unsigned int max_sectors;
241+
234242 if ((max_hw_sectors << 9) < PAGE_CACHE_SIZE) {
235243 max_hw_sectors = 1 << (PAGE_CACHE_SHIFT - 9);
236244 printk(KERN_INFO "%s: set to minimum %d\n",
@@ -238,22 +246,9 @@ void blk_limits_max_hw_sectors(struct queue_limits *limits, unsigned int max_hw_ · 1 unmodified line
238246 }
239247
240248 limits->max_hw_sectors = max_hw_sectors;
241− limits->max_sectors = min_t(unsigned int, max_hw_sectors,
242− BLK_DEF_MAX_SECTORS);
243−}
244−EXPORT_SYMBOL(blk_limits_max_hw_sectors);
245−
246−/**
247− * blk_queue_max_hw_sectors - set max sectors for a request for this queue
248− * @q: the request queue for the device
249− * @max_hw_sectors: max hardware sectors in the usual 512b unit
250− *
251− * Description:
252− * See description for blk_limits_max_hw_sectors().
253− **/
254−void blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_sectors)
255−{
256− blk_limits_max_hw_sectors(&q->limits, max_hw_sectors);
249+ max_sectors = min_not_zero(max_hw_sectors, limits->max_dev_sectors);
250+ max_sectors = min_t(unsigned int, max_sectors, BLK_DEF_MAX_SECTORS);
251+ limits->max_sectors = max_sectors;
257252 }
258253 EXPORT_SYMBOL(blk_queue_max_hw_sectors);
259254
@@ -527,6 +522,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, · 267 unmodified lines
527522
528523 t->max_sectors = min_not_zero(t->max_sectors, b->max_sectors);
529524 t->max_hw_sectors = min_not_zero(t->max_hw_sectors, b->max_hw_sectors);
525+ t->max_dev_sectors = min_not_zero(t->max_dev_sectors, b->max_dev_sectors);
530526 t->max_write_same_sectors = min(t->max_write_same_sectors,
531527 b->max_write_same_sectors);
532528 t->bounce_pfn = min_not_zero(t->bounce_pfn, b->bounce_pfn);
block/blk-sysfs.c+3−0
@@ -205,6 +205,9 @@ queue_max_sectors_store(struct request_queue *q, const char *page, size_t count) · 204 unmodified lines
205205 if (ret < 0)
206206 return ret;
207207
208+ max_hw_sectors_kb = min_not_zero(max_hw_sectors_kb, (unsigned long)
209+ q->limits.max_dev_sectors >> 1);
210+
208211 if (max_sectors_kb > max_hw_sectors_kb || max_sectors_kb < page_kb)
209212 return -EINVAL;
210213
block/blk-timeout.c+5−3
@@ -158,11 +158,13 @@ void blk_abort_request(struct request *req) · 157 unmodified lines
158158 {
159159 if (blk_mark_rq_complete(req))
160160 return;
161− blk_delete_timer(req);
162− if (req->q->mq_ops)
161+
162+ if (req->q->mq_ops) {
163163 blk_mq_rq_timed_out(req, false);
164− else
164+ } else {
165+ blk_delete_timer(req);
165166 blk_rq_timed_out(req);
167+ }
166168 }
167169 EXPORT_SYMBOL_GPL(blk_abort_request);
168170
block/noop-iosched.c+5−5
@@ -21,10 +21,10 @@ static void noop_merged_requests(struct request_queue *q, struct request *rq, · 20 unmodified lines
2121 static int noop_dispatch(struct request_queue *q, int force)
2222 {
2323 struct noop_data *nd = q->elevator->elevator_data;
24+ struct request *rq;
2425
25− if (!list_empty(&nd->queue)) {
26− struct request *rq;
27− rq = list_entry(nd->queue.next, struct request, queuelist);
26+ rq = list_first_entry_or_null(&nd->queue, struct request, queuelist);
27+ if (rq) {
2828 list_del_init(&rq->queuelist);
2929 elv_dispatch_sort(q, rq);
3030 return 1;
@@ -46,7 +46,7 @@ noop_former_request(struct request_queue *q, struct request *rq) · 15 unmodified lines
4646
4747 if (rq->queuelist.prev == &nd->queue)
4848 return NULL;
49− return list_entry(rq->queuelist.prev, struct request, queuelist);
49+ return list_prev_entry(rq, queuelist);
5050 }
5151
5252 static struct request *
@@ -56,7 +56,7 @@ noop_latter_request(struct request_queue *q, struct request *rq) · 3 unmodified lines
5656
5757 if (rq->queuelist.next == &nd->queue)
5858 return NULL;
59− return list_entry(rq->queuelist.next, struct request, queuelist);
59+ return list_next_entry(rq, queuelist);
6060 }
6161
6262 static int noop_init_queue(struct request_queue *q, struct elevator_type *e)
block/partition-generic.c+1−1
@@ -397,7 +397,7 @@ static int drop_partitions(struct gendisk *disk, struct block_device *bdev) · 396 unmodified lines
397397 struct hd_struct *part;
398398 int res;
399399
400− if (bdev->bd_part_count)
400+ if (bdev->bd_part_count || bdev->bd_super)
401401 return -EBUSY;
402402 res = invalidate_partition(disk, 0);
403403 if (res)
block/partitions/mac.c+7−3
@@ -32,7 +32,7 @@ int mac_partition(struct parsed_partitions *state) · 31 unmodified lines
3232 Sector sect;
3333 unsigned char *data;
3434 int slot, blocks_in_map;
35− unsigned secsize;
35+ unsigned secsize, datasize, partoffset;
3636 #ifdef CONFIG_PPC_PMAC
3737 int found_root = 0;
3838 int found_root_goodness = 0;
@@ -50,10 +50,14 @@ int mac_partition(struct parsed_partitions *state) · 11 unmodified lines
5050 }
5151 secsize = be16_to_cpu(md->block_size);
5252 put_dev_sector(sect);
53− data = read_part_sector(state, secsize/512, &sect);
53+ datasize = round_down(secsize, 512);
54+ data = read_part_sector(state, datasize / 512, &sect);
5455 if (!data)
5556 return -1;
56− part = (struct mac_partition *) (data + secsize%512);
57+ partoffset = secsize % 512;
58+ if (partoffset + sizeof(*part) > datasize)
59+ return -1;
60+ part = (struct mac_partition *) (data + partoffset);
5761 if (be16_to_cpu(part->signature) != MAC_PARTITION_MAGIC) {
5862 put_dev_sector(sect);
5963 return 0; /* not a MacOS disk */
crypto/algif_aead.c+2−2
@@ -125,7 +125,7 @@ static int aead_wait_for_data(struct sock *sk, unsigned flags) · 124 unmodified lines
125125 if (flags & MSG_DONTWAIT)
126126 return -EAGAIN;
127127
128− set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);
128+ sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
129129
130130 for (;;) {
131131 if (signal_pending(current))
@@ -139,7 +139,7 @@ static int aead_wait_for_data(struct sock *sk, unsigned flags) · 7 unmodified lines
139139 }
140140 finish_wait(sk_sleep(sk), &wait);
141141
142− clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);
142+ sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
143143
144144 return err;
145145 }
crypto/algif_skcipher.c+3−3
@@ -212,7 +212,7 @@ static int skcipher_wait_for_wmem(struct sock *sk, unsigned flags) · 211 unmodified lines
212212 if (flags & MSG_DONTWAIT)
213213 return -EAGAIN;
214214
215− set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
215+ sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
216216
217217 for (;;) {
218218 if (signal_pending(current))
@@ -258,7 +258,7 @@ static int skcipher_wait_for_data(struct sock *sk, unsigned flags) · 39 unmodified lines
258258 return -EAGAIN;
259259 }
260260
261− set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);
261+ sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
262262
263263 for (;;) {
264264 if (signal_pending(current))
@@ -272,7 +272,7 @@ static int skcipher_wait_for_data(struct sock *sk, unsigned flags) · 7 unmodified lines
272272 }
273273 finish_wait(sk_sleep(sk), &wait);
274274
275− clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags);
275+ sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
276276
277277 return err;
278278 }
drivers/Makefile+1−1
@@ -63,6 +63,7 @@ obj-$(CONFIG_FB_I810) += video/fbdev/i810/ · 62 unmodified lines
6363 obj-$(CONFIG_FB_INTEL) += video/fbdev/intelfb/
6464
6565 obj-$(CONFIG_PARPORT) += parport/
66+obj-$(CONFIG_NVM) += lightnvm/
6667 obj-y += base/ block/ misc/ mfd/ nfc/
6768 obj-$(CONFIG_LIBNVDIMM) += nvdimm/
6869 obj-$(CONFIG_DMA_SHARED_BUFFER) += dma-buf/
@@ -70,7 +71,6 @@ obj-$(CONFIG_NUBUS) += nubus/ · 1 unmodified line
7071 obj-y += macintosh/
7172 obj-$(CONFIG_IDE) += ide/
7273 obj-$(CONFIG_SCSI) += scsi/
73−obj-$(CONFIG_NVM) += lightnvm/
7474 obj-y += nvme/
7575 obj-$(CONFIG_ATA) += ata/
7676 obj-$(CONFIG_TARGET_CORE) += target/
drivers/acpi/Kconfig+2−2
@@ -58,10 +58,10 @@ config ACPI_CCA_REQUIRED · 57 unmodified lines
5858 bool
5959
6060 config ACPI_DEBUGGER
61− bool "In-kernel debugger (EXPERIMENTAL)"
61+ bool "AML debugger interface (EXPERIMENTAL)"
6262 select ACPI_DEBUG
6363 help
64− Enable in-kernel debugging facilities: statistics, internal
64+ Enable in-kernel debugging of AML facilities: statistics, internal
6565 object dump, single step control method execution.
6666 This is still under development, currently enabling this only
6767 results in the compilation of the ACPICA debugger files.
drivers/acpi/nfit.c+47−18
@@ -233,11 +233,12 @@ static bool add_spa(struct acpi_nfit_desc *acpi_desc, · 232 unmodified lines
233233 struct nfit_table_prev *prev,
234234 struct acpi_nfit_system_address *spa)
235235 {
236+ size_t length = min_t(size_t, sizeof(*spa), spa->header.length);
236237 struct device *dev = acpi_desc->dev;
237238 struct nfit_spa *nfit_spa;
238239
239240 list_for_each_entry(nfit_spa, &prev->spas, list) {
240− if (memcmp(nfit_spa->spa, spa, sizeof(*spa)) == 0) {
241+ if (memcmp(nfit_spa->spa, spa, length) == 0) {
241242 list_move_tail(&nfit_spa->list, &acpi_desc->spas);
242243 return true;
243244 }
@@ -259,11 +260,12 @@ static bool add_memdev(struct acpi_nfit_desc *acpi_desc, · 15 unmodified lines
259260 struct nfit_table_prev *prev,
260261 struct acpi_nfit_memory_map *memdev)
261262 {
263+ size_t length = min_t(size_t, sizeof(*memdev), memdev->header.length);
262264 struct device *dev = acpi_desc->dev;
263265 struct nfit_memdev *nfit_memdev;
264266
265267 list_for_each_entry(nfit_memdev, &prev->memdevs, list)
266− if (memcmp(nfit_memdev->memdev, memdev, sizeof(*memdev)) == 0) {
268+ if (memcmp(nfit_memdev->memdev, memdev, length) == 0) {
267269 list_move_tail(&nfit_memdev->list, &acpi_desc->memdevs);
268270 return true;
269271 }
@@ -284,11 +286,12 @@ static bool add_dcr(struct acpi_nfit_desc *acpi_desc, · 14 unmodified lines
284286 struct nfit_table_prev *prev,
285287 struct acpi_nfit_control_region *dcr)
286288 {
289+ size_t length = min_t(size_t, sizeof(*dcr), dcr->header.length);
287290 struct device *dev = acpi_desc->dev;
288291 struct nfit_dcr *nfit_dcr;
289292
290293 list_for_each_entry(nfit_dcr, &prev->dcrs, list)
291− if (memcmp(nfit_dcr->dcr, dcr, sizeof(*dcr)) == 0) {
294+ if (memcmp(nfit_dcr->dcr, dcr, length) == 0) {
292295 list_move_tail(&nfit_dcr->list, &acpi_desc->dcrs);
293296 return true;
294297 }
@@ -308,11 +311,12 @@ static bool add_bdw(struct acpi_nfit_desc *acpi_desc, · 13 unmodified lines
308311 struct nfit_table_prev *prev,
309312 struct acpi_nfit_data_region *bdw)
310313 {
314+ size_t length = min_t(size_t, sizeof(*bdw), bdw->header.length);
311315 struct device *dev = acpi_desc->dev;
312316 struct nfit_bdw *nfit_bdw;
313317
314318 list_for_each_entry(nfit_bdw, &prev->bdws, list)
315− if (memcmp(nfit_bdw->bdw, bdw, sizeof(*bdw)) == 0) {
319+ if (memcmp(nfit_bdw->bdw, bdw, length) == 0) {
316320 list_move_tail(&nfit_bdw->list, &acpi_desc->bdws);
317321 return true;
318322 }
@@ -332,11 +336,12 @@ static bool add_idt(struct acpi_nfit_desc *acpi_desc, · 13 unmodified lines
332336 struct nfit_table_prev *prev,
333337 struct acpi_nfit_interleave *idt)
334338 {
339+ size_t length = min_t(size_t, sizeof(*idt), idt->header.length);
335340 struct device *dev = acpi_desc->dev;
336341 struct nfit_idt *nfit_idt;
337342
338343 list_for_each_entry(nfit_idt, &prev->idts, list)
339− if (memcmp(nfit_idt->idt, idt, sizeof(*idt)) == 0) {
344+ if (memcmp(nfit_idt->idt, idt, length) == 0) {
340345 list_move_tail(&nfit_idt->list, &acpi_desc->idts);
341346 return true;
342347 }
@@ -356,11 +361,12 @@ static bool add_flush(struct acpi_nfit_desc *acpi_desc, · 13 unmodified lines
356361 struct nfit_table_prev *prev,
357362 struct acpi_nfit_flush_address *flush)
358363 {
364+ size_t length = min_t(size_t, sizeof(*flush), flush->header.length);
359365 struct device *dev = acpi_desc->dev;
360366 struct nfit_flush *nfit_flush;
361367
362368 list_for_each_entry(nfit_flush, &prev->flushes, list)
363− if (memcmp(nfit_flush->flush, flush, sizeof(*flush)) == 0) {
369+ if (memcmp(nfit_flush->flush, flush, length) == 0) {
364370 list_move_tail(&nfit_flush->list, &acpi_desc->flushes);
365371 return true;
366372 }
@@ -655,7 +661,7 @@ static ssize_t revision_show(struct device *dev, · 288 unmodified lines
655661 struct nvdimm_bus_descriptor *nd_desc = to_nd_desc(nvdimm_bus);
656662 struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc);
657663
658− return sprintf(buf, "%d\n", acpi_desc->nfit->header.revision);
664+ return sprintf(buf, "%d\n", acpi_desc->acpi_header.revision);
659665 }
660666 static DEVICE_ATTR_RO(revision);
661667
@@ -1652,7 +1658,6 @@ int acpi_nfit_init(struct acpi_nfit_desc *acpi_desc, acpi_size sz) · 990 unmodified lines
16521658
16531659 data = (u8 *) acpi_desc->nfit;
16541660 end = data + sz;
1655− data += sizeof(struct acpi_table_nfit);
16561661 while (!IS_ERR_OR_NULL(data))
16571662 data = add_table(acpi_desc, &prev, data, end);
16581663
@@ -1748,13 +1753,29 @@ static int acpi_nfit_add(struct acpi_device *adev) · 89 unmodified lines
17481753 return PTR_ERR(acpi_desc);
17491754 }
17501755
1751− acpi_desc->nfit = (struct acpi_table_nfit *) tbl;
1756+ /*
1757+ * Save the acpi header for later and then skip it,
1758+ * making nfit point to the first nfit table header.
1759+ */
1760+ acpi_desc->acpi_header = *tbl;
1761+ acpi_desc->nfit = (void *) tbl + sizeof(struct acpi_table_nfit);
1762+ sz -= sizeof(struct acpi_table_nfit);
17521763
17531764 /* Evaluate _FIT and override with that if present */
17541765 status = acpi_evaluate_object(adev->handle, "_FIT", NULL, &buf);
17551766 if (ACPI_SUCCESS(status) && buf.length > 0) {
1756− acpi_desc->nfit = (struct acpi_table_nfit *)buf.pointer;
1757− sz = buf.length;
1767+ union acpi_object *obj;
1768+ /*
1769+ * Adjust for the acpi_object header of the _FIT
1770+ */
1771+ obj = buf.pointer;
1772+ if (obj->type == ACPI_TYPE_BUFFER) {
1773+ acpi_desc->nfit =
1774+ (struct acpi_nfit_header *)obj->buffer.pointer;
1775+ sz = obj->buffer.length;
1776+ } else
1777+ dev_dbg(dev, "%s invalid type %d, ignoring _FIT\n",
1778+ __func__, (int) obj->type);
17581779 }
17591780
17601781 rc = acpi_nfit_init(acpi_desc, sz);
@@ -1777,7 +1798,8 @@ static void acpi_nfit_notify(struct acpi_device *adev, u32 event) · 16 unmodified lines
17771798 {
17781799 struct acpi_nfit_desc *acpi_desc = dev_get_drvdata(&adev->dev);
17791800 struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL };
1780− struct acpi_table_nfit *nfit_saved;
1801+ struct acpi_nfit_header *nfit_saved;
1802+ union acpi_object *obj;
17811803 struct device *dev = &adev->dev;
17821804 acpi_status status;
17831805 int ret;
@@ -1808,12 +1830,19 @@ static void acpi_nfit_notify(struct acpi_device *adev, u32 event) · 24 unmodified lines
18081830 }
18091831
18101832 nfit_saved = acpi_desc->nfit;
1811− acpi_desc->nfit = (struct acpi_table_nfit *)buf.pointer;
1812− ret = acpi_nfit_init(acpi_desc, buf.length);
1813− if (!ret) {
1814− /* Merge failed, restore old nfit, and exit */
1815− acpi_desc->nfit = nfit_saved;
1816− dev_err(dev, "failed to merge updated NFIT\n");
1833+ obj = buf.pointer;
1834+ if (obj->type == ACPI_TYPE_BUFFER) {
1835+ acpi_desc->nfit =
1836+ (struct acpi_nfit_header *)obj->buffer.pointer;
1837+ ret = acpi_nfit_init(acpi_desc, obj->buffer.length);
1838+ if (ret) {
1839+ /* Merge failed, restore old nfit, and exit */
1840+ acpi_desc->nfit = nfit_saved;
1841+ dev_err(dev, "failed to merge updated NFIT\n");
1842+ }
1843+ } else {
1844+ /* Bad _FIT, restore old nfit */
1845+ dev_err(dev, "Invalid _FIT\n");
18171846 }
18181847 kfree(buf.pointer);
18191848
drivers/acpi/nfit.h+2−1
@@ -96,7 +96,8 @@ struct nfit_mem { · 95 unmodified lines
9696
9797 struct acpi_nfit_desc {
9898 struct nvdimm_bus_descriptor nd_desc;
99− struct acpi_table_nfit *nfit;
99+ struct acpi_table_header acpi_header;
100+ struct acpi_nfit_header *nfit;
100101 struct mutex spa_map_mutex;
101102 struct mutex init_mutex;
102103 struct list_head spa_maps;
drivers/acpi/pci_root.c+7−0
@@ -768,6 +768,13 @@ static void pci_acpi_root_add_resources(struct acpi_pci_root_info *info) · 767 unmodified lines
768768 else
769769 continue;
770770
771+ /*
772+ * Some legacy x86 host bridge drivers use iomem_resource and
773+ * ioport_resource as default resource pool, skip it.
774+ */
775+ if (res == root)
776+ continue;
777+
771778 conflict = insert_resource_conflict(root, res);
772779 if (conflict) {
773780 dev_info(&info->bridge->dev,
drivers/ata/ahci.c+12−10
@@ -314,16 +314,6 @@ static const struct pci_device_id ahci_pci_tbl[] = { · 313 unmodified lines
314314 { PCI_VDEVICE(INTEL, 0x1f37), board_ahci_avn }, /* Avoton RAID */
315315 { PCI_VDEVICE(INTEL, 0x1f3e), board_ahci_avn }, /* Avoton RAID */
316316 { PCI_VDEVICE(INTEL, 0x1f3f), board_ahci_avn }, /* Avoton RAID */
317− { PCI_VDEVICE(INTEL, 0xa182), board_ahci }, /* Lewisburg AHCI*/
318− { PCI_VDEVICE(INTEL, 0xa202), board_ahci }, /* Lewisburg AHCI*/
319− { PCI_VDEVICE(INTEL, 0xa184), board_ahci }, /* Lewisburg RAID*/
320− { PCI_VDEVICE(INTEL, 0xa204), board_ahci }, /* Lewisburg RAID*/
321− { PCI_VDEVICE(INTEL, 0xa186), board_ahci }, /* Lewisburg RAID*/
322− { PCI_VDEVICE(INTEL, 0xa206), board_ahci }, /* Lewisburg RAID*/
323− { PCI_VDEVICE(INTEL, 0x2822), board_ahci }, /* Lewisburg RAID*/
324− { PCI_VDEVICE(INTEL, 0x2826), board_ahci }, /* Lewisburg RAID*/
325− { PCI_VDEVICE(INTEL, 0xa18e), board_ahci }, /* Lewisburg RAID*/
326− { PCI_VDEVICE(INTEL, 0xa20e), board_ahci }, /* Lewisburg RAID*/
327317 { PCI_VDEVICE(INTEL, 0x2823), board_ahci }, /* Wellsburg RAID */
328318 { PCI_VDEVICE(INTEL, 0x2827), board_ahci }, /* Wellsburg RAID */
329319 { PCI_VDEVICE(INTEL, 0x8d02), board_ahci }, /* Wellsburg AHCI */
@@ -350,10 +340,22 @@ static const struct pci_device_id ahci_pci_tbl[] = { · 20 unmodified lines
350340 { PCI_VDEVICE(INTEL, 0x9d03), board_ahci }, /* Sunrise Point-LP AHCI */
351341 { PCI_VDEVICE(INTEL, 0x9d05), board_ahci }, /* Sunrise Point-LP RAID */
352342 { PCI_VDEVICE(INTEL, 0x9d07), board_ahci }, /* Sunrise Point-LP RAID */
343+ { PCI_VDEVICE(INTEL, 0xa102), board_ahci }, /* Sunrise Point-H AHCI */
353344 { PCI_VDEVICE(INTEL, 0xa103), board_ahci }, /* Sunrise Point-H AHCI */
354345 { PCI_VDEVICE(INTEL, 0xa105), board_ahci }, /* Sunrise Point-H RAID */
346+ { PCI_VDEVICE(INTEL, 0xa106), board_ahci }, /* Sunrise Point-H RAID */
355347 { PCI_VDEVICE(INTEL, 0xa107), board_ahci }, /* Sunrise Point-H RAID */
356348 { PCI_VDEVICE(INTEL, 0xa10f), board_ahci }, /* Sunrise Point-H RAID */
349+ { PCI_VDEVICE(INTEL, 0x2822), board_ahci }, /* Lewisburg RAID*/
350+ { PCI_VDEVICE(INTEL, 0x2826), board_ahci }, /* Lewisburg RAID*/
351+ { PCI_VDEVICE(INTEL, 0xa182), board_ahci }, /* Lewisburg AHCI*/
352+ { PCI_VDEVICE(INTEL, 0xa184), board_ahci }, /* Lewisburg RAID*/
353+ { PCI_VDEVICE(INTEL, 0xa186), board_ahci }, /* Lewisburg RAID*/
354+ { PCI_VDEVICE(INTEL, 0xa18e), board_ahci }, /* Lewisburg RAID*/
355+ { PCI_VDEVICE(INTEL, 0xa202), board_ahci }, /* Lewisburg AHCI*/
356+ { PCI_VDEVICE(INTEL, 0xa204), board_ahci }, /* Lewisburg RAID*/
357+ { PCI_VDEVICE(INTEL, 0xa206), board_ahci }, /* Lewisburg RAID*/
358+ { PCI_VDEVICE(INTEL, 0xa20e), board_ahci }, /* Lewisburg RAID*/
357359
358360 /* JMicron 360/1/3/5/6, match class to avoid IDE function */
359361 { PCI_VENDOR_ID_JMICRON, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
drivers/ata/ahci_mvebu.c+5−0
@@ -62,6 +62,7 @@ static void ahci_mvebu_regret_option(struct ahci_host_priv *hpriv) · 61 unmodified lines
6262 writel(0x80, hpriv->mmio + AHCI_VENDOR_SPECIFIC_0_DATA);
6363 }
6464
65+#ifdef CONFIG_PM_SLEEP
6566 static int ahci_mvebu_suspend(struct platform_device *pdev, pm_message_t state)
6667 {
6768 return ahci_platform_suspend_host(&pdev->dev);
@@ -81,6 +82,10 @@ static int ahci_mvebu_resume(struct platform_device *pdev) · 13 unmodified lines
8182
8283 return ahci_platform_resume_host(&pdev->dev);
8384 }
85+#else
86+#define ahci_mvebu_suspend NULL
87+#define ahci_mvebu_resume NULL
88+#endif
8489
8590 static const struct ata_port_info ahci_mvebu_port_info = {
8691 .flags = AHCI_FLAG_COMMON,
drivers/ata/libahci.c+9−0
@@ -1273,6 +1273,15 @@ static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp, · 1272 unmodified lines
12731273 ata_tf_to_fis(tf, pmp, is_cmd, fis);
12741274 ahci_fill_cmd_slot(pp, 0, cmd_fis_len | flags | (pmp << 12));
12751275
1276+ /* set port value for softreset of Port Multiplier */
1277+ if (pp->fbs_enabled && pp->fbs_last_dev != pmp) {
1278+ tmp = readl(port_mmio + PORT_FBS);
1279+ tmp &= ~(PORT_FBS_DEV_MASK | PORT_FBS_DEC);
1280+ tmp |= pmp << PORT_FBS_DEV_OFFSET;
1281+ writel(tmp, port_mmio + PORT_FBS);
1282+ pp->fbs_last_dev = pmp;
1283+ }
1284+
12761285 /* issue & wait */
12771286 writel(1, port_mmio + PORT_CMD_ISSUE);
12781287
drivers/ata/libata-eh.c+8−0
@@ -1505,12 +1505,20 @@ static const char *ata_err_string(unsigned int err_mask) · 1504 unmodified lines
15051505 unsigned int ata_read_log_page(struct ata_device *dev, u8 log,
15061506 u8 page, void *buf, unsigned int sectors)
15071507 {
1508+ unsigned long ap_flags = dev->link->ap->flags;
15081509 struct ata_taskfile tf;
15091510 unsigned int err_mask;
15101511 bool dma = false;
15111512
15121513 DPRINTK("read log page - log 0x%x, page 0x%x\n", log, page);
15131514
1515+ /*
1516+ * Return error without actually issuing the command on controllers
1517+ * which e.g. lockup on a read log page.
1518+ */
1519+ if (ap_flags & ATA_FLAG_NO_LOG_PAGE)
1520+ return AC_ERR_DEV;
1521+
15141522 retry:
15151523 ata_tf_init(dev, &tf);
15161524 if (dev->dma_mode && ata_id_has_read_log_dma_ext(dev->id) &&
drivers/ata/sata_fsl.c+2−1
@@ -45,7 +45,8 @@ enum { · 44 unmodified lines
4545 SATA_FSL_MAX_PRD_DIRECT = 16, /* Direct PRDT entries */
4646
4747 SATA_FSL_HOST_FLAGS = (ATA_FLAG_SATA | ATA_FLAG_PIO_DMA |
48− ATA_FLAG_PMP | ATA_FLAG_NCQ | ATA_FLAG_AN),
48+ ATA_FLAG_PMP | ATA_FLAG_NCQ |
49+ ATA_FLAG_AN | ATA_FLAG_NO_LOG_PAGE),
4950
5051 SATA_FSL_MAX_CMDS = SATA_FSL_QUEUE_DEPTH,
5152 SATA_FSL_CMD_HDR_SIZE = 16, /* 4 DWORDS */
drivers/ata/sata_sil.c+3−0
@@ -630,6 +630,9 @@ static void sil_dev_config(struct ata_device *dev) · 629 unmodified lines
630630 unsigned int n, quirks = 0;
631631 unsigned char model_num[ATA_ID_PROD_LEN + 1];
632632
633+ /* This controller doesn't support trim */
634+ dev->horkage |= ATA_HORKAGE_NOTRIM;
635+
633636 ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num));
634637
635638 for (n = 0; sil_blacklist[n].product; n++)
drivers/base/memory.c+4−0
@@ -303,6 +303,10 @@ static int memory_subsys_offline(struct device *dev) · 302 unmodified lines
303303 if (mem->state == MEM_OFFLINE)
304304 return 0;
305305
306+ /* Can't offline block with non-present sections */
307+ if (mem->section_count != sections_per_block)
308+ return -EINVAL;
309+
306310 return memory_block_change_state(mem, MEM_OFFLINE, MEM_ONLINE);
307311 }
308312
drivers/base/power/domain.c+1−2
@@ -1775,10 +1775,10 @@ int genpd_dev_pm_attach(struct device *dev) · 1774 unmodified lines
17751775 }
17761776
17771777 pd = of_genpd_get_from_provider(&pd_args);
1778+ of_node_put(pd_args.np);
17781779 if (IS_ERR(pd)) {
17791780 dev_dbg(dev, "%s() failed to find PM domain: %ld\n",
17801781 __func__, PTR_ERR(pd));
1781− of_node_put(dev->of_node);
17821782 return -EPROBE_DEFER;
17831783 }
17841784
@@ -1796,7 +1796,6 @@ int genpd_dev_pm_attach(struct device *dev) · 11 unmodified lines
17961796 if (ret < 0) {
17971797 dev_err(dev, "failed to add to PM domain %s: %d",
17981798 pd->name, ret);
1799− of_node_put(dev->of_node);
18001799 goto out;
18011800 }
18021801
drivers/base/power/domain_governor.c+0−3
@@ -160,9 +160,6 @@ static bool default_power_down_ok(struct dev_pm_domain *pd) · 159 unmodified lines
160160 struct gpd_timing_data *td;
161161 s64 constraint_ns;
162162
163− if (!pdd->dev->driver)
164− continue;
165−
166163 /*
167164 * Check if the device is allowed to be off long enough for the
168165 * domain to turn off and on (that's how much time it will
drivers/block/mtip32xx/mtip32xx.c+2−4
@@ -3810,7 +3810,6 @@ static int mtip_block_initialize(struct driver_data *dd) · 3809 unmodified lines
38103810 sector_t capacity;
38113811 unsigned int index = 0;
38123812 struct kobject *kobj;
3813− unsigned char thd_name[16];
38143813
38153814 if (dd->disk)
38163815 goto skip_create_disk; /* hw init done, before rebuild */
@@ -3958,10 +3957,9 @@ skip_create_disk: · 141 unmodified lines
39583957 }
39593958
39603959 start_service_thread:
3961− sprintf(thd_name, "mtip_svc_thd_%02d", index);
39623960 dd->mtip_svc_handler = kthread_create_on_node(mtip_service_thread,
3963− dd, dd->numa_node, "%s",
3964− thd_name);
3961+ dd, dd->numa_node,
3962+ "mtip_svc_thd_%02d", index);
39653963
39663964 if (IS_ERR(dd->mtip_svc_handler)) {
39673965 dev_err(&dd->pdev->dev, "service thread failed to start\n");
drivers/block/null_blk.c+244−73
@@ -8,6 +8,7 @@ · 7 unmodified lines
88 #include <linux/slab.h>
99 #include <linux/blk-mq.h>
1010 #include <linux/hrtimer.h>
11+#include <linux/lightnvm.h>
1112
1213 struct nullb_cmd {
1314 struct list_head list;
@@ -17,6 +18,7 @@ struct nullb_cmd { · 3 unmodified lines
1718 struct bio *bio;
1819 unsigned int tag;
1920 struct nullb_queue *nq;
21+ struct hrtimer timer;
2022 };
2123
2224 struct nullb_queue {
@@ -39,23 +41,14 @@ struct nullb { · 16 unmodified lines
3941
4042 struct nullb_queue *queues;
4143 unsigned int nr_queues;
44+ char disk_name[DISK_NAME_LEN];
4245 };
4346
4447 static LIST_HEAD(nullb_list);
4548 static struct mutex lock;
4649 static int null_major;
4750 static int nullb_indexes;
48−
49−struct completion_queue {
50− struct llist_head list;
51− struct hrtimer timer;
52−};
53−
54−/*
55− * These are per-cpu for now, they will need to be configured by the
56− * complete_queues parameter and appropriately mapped.
57− */
58−static DEFINE_PER_CPU(struct completion_queue, completion_queues);
51+static struct kmem_cache *ppa_cache;
5952
6053 enum {
6154 NULL_IRQ_NONE = 0,
@@ -119,6 +112,10 @@ static int nr_devices = 2; · 57 unmodified lines
119112 module_param(nr_devices, int, S_IRUGO);
120113 MODULE_PARM_DESC(nr_devices, "Number of devices to register");
121114
115+static bool use_lightnvm;
116+module_param(use_lightnvm, bool, S_IRUGO);
117+MODULE_PARM_DESC(use_lightnvm, "Register as a LightNVM device");
118+
122119 static int irqmode = NULL_IRQ_SOFTIRQ;
123120
124121 static int null_set_irqmode(const char *str, const struct kernel_param *kp)
@@ -135,8 +132,8 @@ static const struct kernel_param_ops null_irqmode_param_ops = { · 10 unmodified lines
135132 device_param_cb(irqmode, &null_irqmode_param_ops, &irqmode, S_IRUGO);
136133 MODULE_PARM_DESC(irqmode, "IRQ completion handler. 0-none, 1-softirq, 2-timer");
137134
138−static int completion_nsec = 10000;
139−module_param(completion_nsec, int, S_IRUGO);
135+static unsigned long completion_nsec = 10000;
136+module_param(completion_nsec, ulong, S_IRUGO);
140137 MODULE_PARM_DESC(completion_nsec, "Time in ns to complete a request in hardware. Default: 10,000ns");
141138
142139 static int hw_queue_depth = 64;
@@ -173,6 +170,8 @@ static void free_cmd(struct nullb_cmd *cmd) · 30 unmodified lines
173170 put_tag(cmd->nq, cmd->tag);
174171 }
175172
173+static enum hrtimer_restart null_cmd_timer_expired(struct hrtimer *timer);
174+
176175 static struct nullb_cmd *__alloc_cmd(struct nullb_queue *nq)
177176 {
178177 struct nullb_cmd *cmd;
@@ -183,6 +182,11 @@ static struct nullb_cmd *__alloc_cmd(struct nullb_queue *nq) · 4 unmodified lines
183182 cmd = &nq->cmds[tag];
184183 cmd->tag = tag;
185184 cmd->nq = nq;
185+ if (irqmode == NULL_IRQ_TIMER) {
186+ hrtimer_init(&cmd->timer, CLOCK_MONOTONIC,
187+ HRTIMER_MODE_REL);
188+ cmd->timer.function = null_cmd_timer_expired;
189+ }
186190 return cmd;
187191 }
188192
@@ -213,6 +217,8 @@ static struct nullb_cmd *alloc_cmd(struct nullb_queue *nq, int can_wait) · 24 unmodified lines
213217
214218 static void end_cmd(struct nullb_cmd *cmd)
215219 {
220+ struct request_queue *q = NULL;
221+
216222 switch (queue_mode) {
217223 case NULL_Q_MQ:
218224 blk_mq_end_request(cmd->rq, 0);
@@ -223,55 +229,37 @@ static void end_cmd(struct nullb_cmd *cmd) · 4 unmodified lines
223229 break;
224230 case NULL_Q_BIO:
225231 bio_endio(cmd->bio);
226− break;
232+ goto free_cmd;
227233 }
228234
235+ if (cmd->rq)
236+ q = cmd->rq->q;
237+
238+ /* Restart queue if needed, as we are freeing a tag */
239+ if (q && !q->mq_ops && blk_queue_stopped(q)) {
240+ unsigned long flags;
241+
242+ spin_lock_irqsave(q->queue_lock, flags);
243+ if (blk_queue_stopped(q))
244+ blk_start_queue(q);
245+ spin_unlock_irqrestore(q->queue_lock, flags);
246+ }
247+free_cmd:
229248 free_cmd(cmd);
230249 }
231250
232251 static enum hrtimer_restart null_cmd_timer_expired(struct hrtimer *timer)
233252 {
234− struct completion_queue *cq;
235− struct llist_node *entry;
236− struct nullb_cmd *cmd;
237−
238− cq = &per_cpu(completion_queues, smp_processor_id());
239−
240− while ((entry = llist_del_all(&cq->list)) != NULL) {
241− entry = llist_reverse_order(entry);
242− do {
243− struct request_queue *q = NULL;
244−
245− cmd = container_of(entry, struct nullb_cmd, ll_list);
246− entry = entry->next;
247− if (cmd->rq)
248− q = cmd->rq->q;
249− end_cmd(cmd);
250−
251− if (q && !q->mq_ops && blk_queue_stopped(q)) {
252− spin_lock(q->queue_lock);
253− if (blk_queue_stopped(q))
254− blk_start_queue(q);
255− spin_unlock(q->queue_lock);
256− }
257− } while (entry);
258− }
253+ end_cmd(container_of(timer, struct nullb_cmd, timer));
259254
260255 return HRTIMER_NORESTART;
261256 }
262257
263258 static void null_cmd_end_timer(struct nullb_cmd *cmd)
264259 {
265− struct completion_queue *cq = &per_cpu(completion_queues, get_cpu());
260+ ktime_t kt = ktime_set(0, completion_nsec);
266261
267− cmd->ll_list.next = NULL;
268− if (llist_add(&cmd->ll_list, &cq->list)) {
269− ktime_t kt = ktime_set(0, completion_nsec);
270−
271− hrtimer_start(&cq->timer, kt, HRTIMER_MODE_REL_PINNED);
272− }
273−
274− put_cpu();
262+ hrtimer_start(&cmd->timer, kt, HRTIMER_MODE_REL);
275263 }
276264
277265 static void null_softirq_done_fn(struct request *rq)
@@ -369,6 +357,10 @@ static int null_queue_rq(struct blk_mq_hw_ctx *hctx, · 91 unmodified lines
369357 {
370358 struct nullb_cmd *cmd = blk_mq_rq_to_pdu(bd->rq);
371359
360+ if (irqmode == NULL_IRQ_TIMER) {
361+ hrtimer_init(&cmd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
362+ cmd->timer.function = null_cmd_timer_expired;
363+ }
372364 cmd->rq = bd->rq;
373365 cmd->nq = hctx->driver_data;
374366
@@ -427,15 +419,157 @@ static void null_del_dev(struct nullb *nullb) · 52 unmodified lines
427419 {
428420 list_del_init(&nullb->list);
429421
430− del_gendisk(nullb->disk);
422+ if (use_lightnvm)
423+ nvm_unregister(nullb->disk_name);
424+ else
425+ del_gendisk(nullb->disk);
431426 blk_cleanup_queue(nullb->q);
432427 if (queue_mode == NULL_Q_MQ)
433428 blk_mq_free_tag_set(&nullb->tag_set);
434− put_disk(nullb->disk);
429+ if (!use_lightnvm)
430+ put_disk(nullb->disk);
435431 cleanup_queues(nullb);
436432 kfree(nullb);
437433 }
438434
435+#ifdef CONFIG_NVM
436+
437+static void null_lnvm_end_io(struct request *rq, int error)
438+{
439+ struct nvm_rq *rqd = rq->end_io_data;
440+ struct nvm_dev *dev = rqd->dev;
441+
442+ dev->mt->end_io(rqd, error);
443+
444+ blk_put_request(rq);
445+}
446+
447+static int null_lnvm_submit_io(struct nvm_dev *dev, struct nvm_rq *rqd)
448+{
449+ struct request_queue *q = dev->q;
450+ struct request *rq;
451+ struct bio *bio = rqd->bio;
452+
453+ rq = blk_mq_alloc_request(q, bio_rw(bio), GFP_KERNEL, 0);
454+ if (IS_ERR(rq))
455+ return -ENOMEM;
456+
457+ rq->cmd_type = REQ_TYPE_DRV_PRIV;
458+ rq->__sector = bio->bi_iter.bi_sector;
459+ rq->ioprio = bio_prio(bio);
460+
461+ if (bio_has_data(bio))
462+ rq->nr_phys_segments = bio_phys_segments(q, bio);
463+
464+ rq->__data_len = bio->bi_iter.bi_size;
465+ rq->bio = rq->biotail = bio;
466+
467+ rq->end_io_data = rqd;
468+
469+ blk_execute_rq_nowait(q, NULL, rq, 0, null_lnvm_end_io);
470+
471+ return 0;
472+}
473+
474+static int null_lnvm_id(struct nvm_dev *dev, struct nvm_id *id)
475+{
476+ sector_t size = gb * 1024 * 1024 * 1024ULL;
477+ sector_t blksize;
478+ struct nvm_id_group *grp;
479+
480+ id->ver_id = 0x1;
481+ id->vmnt = 0;
482+ id->cgrps = 1;
483+ id->cap = 0x3;
484+ id->dom = 0x1;
485+
486+ id->ppaf.blk_offset = 0;
487+ id->ppaf.blk_len = 16;
488+ id->ppaf.pg_offset = 16;
489+ id->ppaf.pg_len = 16;
490+ id->ppaf.sect_offset = 32;
491+ id->ppaf.sect_len = 8;
492+ id->ppaf.pln_offset = 40;
493+ id->ppaf.pln_len = 8;
494+ id->ppaf.lun_offset = 48;
495+ id->ppaf.lun_len = 8;
496+ id->ppaf.ch_offset = 56;
497+ id->ppaf.ch_len = 8;
498+
499+ do_div(size, bs); /* convert size to pages */
500+ do_div(size, 256); /* concert size to pgs pr blk */
501+ grp = &id->groups[0];
502+ grp->mtype = 0;
503+ grp->fmtype = 0;
504+ grp->num_ch = 1;
505+ grp->num_pg = 256;
506+ blksize = size;
507+ do_div(size, (1 << 16));
508+ grp->num_lun = size + 1;
509+ do_div(blksize, grp->num_lun);
510+ grp->num_blk = blksize;
511+ grp->num_pln = 1;
512+
513+ grp->fpg_sz = bs;
514+ grp->csecs = bs;
515+ grp->trdt = 25000;
516+ grp->trdm = 25000;
517+ grp->tprt = 500000;
518+ grp->tprm = 500000;
519+ grp->tbet = 1500000;
520+ grp->tbem = 1500000;
521+ grp->mpos = 0x010101; /* single plane rwe */
522+ grp->cpar = hw_queue_depth;
523+
524+ return 0;
525+}
526+
527+static void *null_lnvm_create_dma_pool(struct nvm_dev *dev, char *name)
528+{
529+ mempool_t *virtmem_pool;
530+
531+ virtmem_pool = mempool_create_slab_pool(64, ppa_cache);
532+ if (!virtmem_pool) {
533+ pr_err("null_blk: Unable to create virtual memory pool\n");
534+ return NULL;
535+ }
536+
537+ return virtmem_pool;
538+}
539+
540+static void null_lnvm_destroy_dma_pool(void *pool)
541+{
542+ mempool_destroy(pool);
543+}
544+
545+static void *null_lnvm_dev_dma_alloc(struct nvm_dev *dev, void *pool,
546+ gfp_t mem_flags, dma_addr_t *dma_handler)
547+{
548+ return mempool_alloc(pool, mem_flags);
549+}
550+
551+static void null_lnvm_dev_dma_free(void *pool, void *entry,
552+ dma_addr_t dma_handler)
553+{
554+ mempool_free(entry, pool);
555+}
556+
557+static struct nvm_dev_ops null_lnvm_dev_ops = {
558+ .identity = null_lnvm_id,
559+ .submit_io = null_lnvm_submit_io,
560+
561+ .create_dma_pool = null_lnvm_create_dma_pool,
562+ .destroy_dma_pool = null_lnvm_destroy_dma_pool,
563+ .dev_dma_alloc = null_lnvm_dev_dma_alloc,
564+ .dev_dma_free = null_lnvm_dev_dma_free,
565+
566+ /* Simulate nvme protocol restriction */
567+ .max_phys_sect = 64,
568+};
569+#else
570+static struct nvm_dev_ops null_lnvm_dev_ops;
571+#endif /* CONFIG_NVM */
572+
439573 static int null_open(struct block_device *bdev, fmode_t mode)
440574 {
441575 return 0;
@@ -575,11 +709,6 @@ static int null_add_dev(void) · 133 unmodified lines
575709 queue_flag_set_unlocked(QUEUE_FLAG_NONROT, nullb->q);
576710 queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, nullb->q);
577711
578− disk = nullb->disk = alloc_disk_node(1, home_node);
579− if (!disk) {
580− rv = -ENOMEM;
581− goto out_cleanup_blk_queue;
582− }
583712
584713 mutex_lock(&lock);
585714 list_add_tail(&nullb->list, &nullb_list);
@@ -589,6 +718,21 @@ static int null_add_dev(void) · 3 unmodified lines
589718 blk_queue_logical_block_size(nullb->q, bs);
590719 blk_queue_physical_block_size(nullb->q, bs);
591720
721+ sprintf(nullb->disk_name, "nullb%d", nullb->index);
722+
723+ if (use_lightnvm) {
724+ rv = nvm_register(nullb->q, nullb->disk_name,
725+ &null_lnvm_dev_ops);
726+ if (rv)
727+ goto out_cleanup_blk_queue;
728+ goto done;
729+ }
730+
731+ disk = nullb->disk = alloc_disk_node(1, home_node);
732+ if (!disk) {
733+ rv = -ENOMEM;
734+ goto out_cleanup_lightnvm;
735+ }
592736 size = gb * 1024 * 1024 * 1024ULL;
593737 set_capacity(disk, size >> 9);
594738
@@ -598,10 +742,15 @@ static int null_add_dev(void) · 3 unmodified lines
598742 disk->fops = &null_fops;
599743 disk->private_data = nullb;
600744 disk->queue = nullb->q;
601− sprintf(disk->disk_name, "nullb%d", nullb->index);
745+ strncpy(disk->disk_name, nullb->disk_name, DISK_NAME_LEN);
746+
602747 add_disk(disk);
748+done:
603749 return 0;
604750
751+out_cleanup_lightnvm:
752+ if (use_lightnvm)
753+ nvm_unregister(nullb->disk_name);
605754 out_cleanup_blk_queue:
606755 blk_cleanup_queue(nullb->q);
607756 out_cleanup_tags:
@@ -617,7 +766,9 @@ out: · 9 unmodified lines
617766
618767 static int __init null_init(void)
619768 {
769+ int ret = 0;
620770 unsigned int i;
771+ struct nullb *nullb;
621772
622773 if (bs > PAGE_SIZE) {
623774 pr_warn("null_blk: invalid block size\n");
@@ -625,6 +776,18 @@ static int __init null_init(void) · 1 unmodified line
625776 bs = PAGE_SIZE;
626777 }
627778
779+ if (use_lightnvm && bs != 4096) {
780+ pr_warn("null_blk: LightNVM only supports 4k block size\n");
781+ pr_warn("null_blk: defaults block size to 4k\n");
782+ bs = 4096;
783+ }
784+
785+ if (use_lightnvm && queue_mode != NULL_Q_MQ) {
786+ pr_warn("null_blk: LightNVM only supported for blk-mq\n");
787+ pr_warn("null_blk: defaults queue mode to blk-mq\n");
788+ queue_mode = NULL_Q_MQ;
789+ }
790+
628791 if (queue_mode == NULL_Q_MQ && use_per_node_hctx) {
629792 if (submit_queues < nr_online_nodes) {
630793 pr_warn("null_blk: submit_queues param is set to %u.",
@@ -638,32 +801,38 @@ static int __init null_init(void) · 7 unmodified lines
638801
639802 mutex_init(&lock);
640803
641− /* Initialize a separate list for each CPU for issuing softirqs */
642− for_each_possible_cpu(i) {
643− struct completion_queue *cq = &per_cpu(completion_queues, i);
644−
645− init_llist_head(&cq->list);
646−
647− if (irqmode != NULL_IRQ_TIMER)
648− continue;
649−
650− hrtimer_init(&cq->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
651− cq->timer.function = null_cmd_timer_expired;
652− }
653−
654804 null_major = register_blkdev(0, "nullb");
655805 if (null_major < 0)
656806 return null_major;
657807
658− for (i = 0; i < nr_devices; i++) {
659− if (null_add_dev()) {
660− unregister_blkdev(null_major, "nullb");
661− return -EINVAL;
808+ if (use_lightnvm) {
809+ ppa_cache = kmem_cache_create("ppa_cache", 64 * sizeof(u64),
810+ 0, 0, NULL);
811+ if (!ppa_cache) {
812+ pr_err("null_blk: unable to create ppa cache\n");
813+ ret = -ENOMEM;
814+ goto err_ppa;
662815 }
663816 }
664817
818+ for (i = 0; i < nr_devices; i++) {
819+ ret = null_add_dev();
820+ if (ret)
821+ goto err_dev;
822+ }
823+
665824 pr_info("null: module loaded\n");
666825 return 0;
826+
827+err_dev:
828+ while (!list_empty(&nullb_list)) {
829+ nullb = list_entry(nullb_list.next, struct nullb, list);
830+ null_del_dev(nullb);
831+ }
832+ kmem_cache_destroy(ppa_cache);
833+err_ppa:
834+ unregister_blkdev(null_major, "nullb");
835+ return ret;
667836 }
668837
669838 static void __exit null_exit(void)
@@ -678,6 +847,8 @@ static void __exit null_exit(void) · 8 unmodified lines
678847 null_del_dev(nullb);
679848 }
680849 mutex_unlock(&lock);
850+
851+ kmem_cache_destroy(ppa_cache);
681852 }
682853
683854 module_init(null_init);
drivers/block/rbd.c+1−0
@@ -3442,6 +3442,7 @@ static void rbd_queue_workfn(struct work_struct *work) · 3441 unmodified lines
34423442 goto err_rq;
34433443 }
34443444 img_request->rq = rq;
3445+ snapc = NULL; /* img_request consumes a ref */
34453446
34463447 if (op_type == OBJ_OP_DISCARD)
34473448 result = rbd_img_request_fill(img_request, OBJ_REQUEST_NODATA,
drivers/bus/omap-ocp2scp.c+1−1
@@ -117,7 +117,7 @@ static struct platform_driver omap_ocp2scp_driver = { · 116 unmodified lines
117117
118118 module_platform_driver(omap_ocp2scp_driver);
119119
120−MODULE_ALIAS("platform: omap-ocp2scp");
120+MODULE_ALIAS("platform:omap-ocp2scp");
121121 MODULE_AUTHOR("Texas Instruments Inc.");
122122 MODULE_DESCRIPTION("OMAP OCP2SCP driver");
123123 MODULE_LICENSE("GPL v2");
drivers/char/ipmi/ipmi_si_intf.c+4−4
@@ -1230,14 +1230,14 @@ static int smi_start_processing(void *send_info, · 1229 unmodified lines
12301230
12311231 new_smi->intf = intf;
12321232
1233− /* Try to claim any interrupts. */
1234− if (new_smi->irq_setup)
1235− new_smi->irq_setup(new_smi);
1236−
12371233 /* Set up the timer that drives the interface. */
12381234 setup_timer(&new_smi->si_timer, smi_timeout, (long)new_smi);
12391235 smi_mod_timer(new_smi, jiffies + SI_TIMEOUT_JIFFIES);
12401236
1237+ /* Try to claim any interrupts. */
1238+ if (new_smi->irq_setup)
1239+ new_smi->irq_setup(new_smi);
1240+
12411241 /*
12421242 * Check if the user forcefully enabled the daemon.
12431243 */
drivers/clk/clk-gpio.c+17−16
@@ -209,6 +209,8 @@ EXPORT_SYMBOL_GPL(clk_register_gpio_mux); · 208 unmodified lines
209209
210210 struct clk_gpio_delayed_register_data {
211211 const char *gpio_name;
212+ int num_parents;
213+ const char **parent_names;
212214 struct device_node *node;
213215 struct mutex lock;
214216 struct clk *clk;
@@ -222,8 +224,6 @@ static struct clk *of_clk_gpio_delayed_register_get( · 7 unmodified lines
222224 {
223225 struct clk_gpio_delayed_register_data *data = _data;
224226 struct clk *clk;
225− const char **parent_names;
226− int i, num_parents;
227227 int gpio;
228228 enum of_gpio_flags of_flags;
229229
@@ -248,26 +248,14 @@ static struct clk *of_clk_gpio_delayed_register_get( · 18 unmodified lines
248248 return ERR_PTR(gpio);
249249 }
250250
251− num_parents = of_clk_get_parent_count(data->node);
252−
253− parent_names = kcalloc(num_parents, sizeof(char *), GFP_KERNEL);
254− if (!parent_names) {
255− clk = ERR_PTR(-ENOMEM);
256− goto out;
257− }
258−
259− for (i = 0; i < num_parents; i++)
260− parent_names[i] = of_clk_get_parent_name(data->node, i);
261−
262− clk = data->clk_register_get(data->node->name, parent_names,
263− num_parents, gpio, of_flags & OF_GPIO_ACTIVE_LOW);
251+ clk = data->clk_register_get(data->node->name, data->parent_names,
252+ data->num_parents, gpio, of_flags & OF_GPIO_ACTIVE_LOW);
264253 if (IS_ERR(clk))
265254 goto out;
266255
267256 data->clk = clk;
268257 out:
269258 mutex_unlock(&data->lock);
270− kfree(parent_names);
271259
272260 return clk;
273261 }
@@ -296,11 +284,24 @@ static void __init of_gpio_clk_setup(struct device_node *node, · 22 unmodified lines
296284 unsigned gpio, bool active_low))
297285 {
298286 struct clk_gpio_delayed_register_data *data;
287+ const char **parent_names;
288+ int i, num_parents;
299289
300290 data = kzalloc(sizeof(*data), GFP_KERNEL);
301291 if (!data)
302292 return;
303293
294+ num_parents = of_clk_get_parent_count(node);
295+
296+ parent_names = kcalloc(num_parents, sizeof(char *), GFP_KERNEL);
297+ if (!parent_names)
298+ return;
299+
300+ for (i = 0; i < num_parents; i++)
301+ parent_names[i] = of_clk_get_parent_name(node, i);
302+
303+ data->num_parents = num_parents;
304+ data->parent_names = parent_names;
304305 data->node = node;
305306 data->gpio_name = gpio_name;
306307 data->clk_register_get = clk_register_get;
drivers/clk/clk-qoriq.c+3−1
@@ -778,8 +778,10 @@ static struct clk * __init create_one_cmux(struct clockgen *cg, int idx) · 777 unmodified lines
778778 */
779779 clksel = (cg_in(cg, hwc->reg) & CLKSEL_MASK) >> CLKSEL_SHIFT;
780780 div = get_pll_div(cg, hwc, clksel);
781− if (!div)
781+ if (!div) {
782+ kfree(hwc);
782783 return NULL;
784+ }
783785
784786 pct80_rate = clk_get_rate(div->clk);
785787 pct80_rate *= 8;
drivers/clk/clk-scpi.c+1−0
@@ -292,6 +292,7 @@ static int scpi_clocks_probe(struct platform_device *pdev) · 291 unmodified lines
292292 ret = scpi_clk_add(dev, child, match);
293293 if (ret) {
294294 scpi_clocks_remove(pdev);
295+ of_node_put(child);
295296 return ret;
296297 }
297298 }
drivers/clk/imx/clk-pllv1.c+7−7
@@ -52,7 +52,7 @@ static unsigned long clk_pllv1_recalc_rate(struct clk_hw *hw, · 51 unmodified lines
5252 unsigned long parent_rate)
5353 {
5454 struct clk_pllv1 *pll = to_clk_pllv1(hw);
55− long long ll;
55+ unsigned long long ull;
5656 int mfn_abs;
5757 unsigned int mfi, mfn, mfd, pd;
5858 u32 reg;
@@ -94,16 +94,16 @@ static unsigned long clk_pllv1_recalc_rate(struct clk_hw *hw, · 35 unmodified lines
9494 rate = parent_rate * 2;
9595 rate /= pd + 1;
9696
97− ll = (unsigned long long)rate * mfn_abs;
97+ ull = (unsigned long long)rate * mfn_abs;
9898
99− do_div(ll, mfd + 1);
99+ do_div(ull, mfd + 1);
100100
101101 if (mfn_is_negative(pll, mfn))
102− ll = -ll;
102+ ull = (rate * mfi) - ull;
103+ else
104+ ull = (rate * mfi) + ull;
103105
104− ll = (rate * mfi) + ll;
105−
106− return ll;
106+ return ull;
107107 }
108108
109109 static struct clk_ops clk_pllv1_ops = {
drivers/clk/imx/clk-pllv2.c+5−4
@@ -79,7 +79,7 @@ static unsigned long __clk_pllv2_recalc_rate(unsigned long parent_rate, · 78 unmodified lines
7979 {
8080 long mfi, mfn, mfd, pdf, ref_clk;
8181 unsigned long dbl;
82− s64 temp;
82+ u64 temp;
8383
8484 dbl = dp_ctl & MXC_PLL_DP_CTL_DPDCK0_2_EN;
8585
@@ -98,8 +98,9 @@ static unsigned long __clk_pllv2_recalc_rate(unsigned long parent_rate, · 12 unmodified lines
9898 temp = (u64) ref_clk * abs(mfn);
9999 do_div(temp, mfd + 1);
100100 if (mfn < 0)
101− temp = -temp;
102− temp = (ref_clk * mfi) + temp;
101+ temp = (ref_clk * mfi) - temp;
102+ else
103+ temp = (ref_clk * mfi) + temp;
103104
104105 return temp;
105106 }
@@ -126,7 +127,7 @@ static int __clk_pllv2_set_rate(unsigned long rate, unsigned long parent_rate, · 20 unmodified lines
126127 {
127128 u32 reg;
128129 long mfi, pdf, mfn, mfd = 999999;
129− s64 temp64;
130+ u64 temp64;
130131 unsigned long quad_parent_rate;
131132
132133 quad_parent_rate = 4 * parent_rate;
drivers/clk/imx/clk-vf610.c+4−4
@@ -335,22 +335,22 @@ static void __init vf610_clocks_init(struct device_node *ccm_node) · 334 unmodified lines
335335 clk[VF610_CLK_SAI0_SEL] = imx_clk_mux("sai0_sel", CCM_CSCMR1, 0, 2, sai_sels, 4);
336336 clk[VF610_CLK_SAI0_EN] = imx_clk_gate("sai0_en", "sai0_sel", CCM_CSCDR1, 16);
337337 clk[VF610_CLK_SAI0_DIV] = imx_clk_divider("sai0_div", "sai0_en", CCM_CSCDR1, 0, 4);
338− clk[VF610_CLK_SAI0] = imx_clk_gate2("sai0", "sai0_div", CCM_CCGR0, CCM_CCGRx_CGn(15));
338+ clk[VF610_CLK_SAI0] = imx_clk_gate2("sai0", "ipg_bus", CCM_CCGR0, CCM_CCGRx_CGn(15));
339339
340340 clk[VF610_CLK_SAI1_SEL] = imx_clk_mux("sai1_sel", CCM_CSCMR1, 2, 2, sai_sels, 4);
341341 clk[VF610_CLK_SAI1_EN] = imx_clk_gate("sai1_en", "sai1_sel", CCM_CSCDR1, 17);
342342 clk[VF610_CLK_SAI1_DIV] = imx_clk_divider("sai1_div", "sai1_en", CCM_CSCDR1, 4, 4);
343− clk[VF610_CLK_SAI1] = imx_clk_gate2("sai1", "sai1_div", CCM_CCGR1, CCM_CCGRx_CGn(0));
343+ clk[VF610_CLK_SAI1] = imx_clk_gate2("sai1", "ipg_bus", CCM_CCGR1, CCM_CCGRx_CGn(0));
344344
345345 clk[VF610_CLK_SAI2_SEL] = imx_clk_mux("sai2_sel", CCM_CSCMR1, 4, 2, sai_sels, 4);
346346 clk[VF610_CLK_SAI2_EN] = imx_clk_gate("sai2_en", "sai2_sel", CCM_CSCDR1, 18);
347347 clk[VF610_CLK_SAI2_DIV] = imx_clk_divider("sai2_div", "sai2_en", CCM_CSCDR1, 8, 4);
348− clk[VF610_CLK_SAI2] = imx_clk_gate2("sai2", "sai2_div", CCM_CCGR1, CCM_CCGRx_CGn(1));
348+ clk[VF610_CLK_SAI2] = imx_clk_gate2("sai2", "ipg_bus", CCM_CCGR1, CCM_CCGRx_CGn(1));
349349
350350 clk[VF610_CLK_SAI3_SEL] = imx_clk_mux("sai3_sel", CCM_CSCMR1, 6, 2, sai_sels, 4);
351351 clk[VF610_CLK_SAI3_EN] = imx_clk_gate("sai3_en", "sai3_sel", CCM_CSCDR1, 19);
352352 clk[VF610_CLK_SAI3_DIV] = imx_clk_divider("sai3_div", "sai3_en", CCM_CSCDR1, 12, 4);
353− clk[VF610_CLK_SAI3] = imx_clk_gate2("sai3", "sai3_div", CCM_CCGR1, CCM_CCGRx_CGn(2));
353+ clk[VF610_CLK_SAI3] = imx_clk_gate2("sai3", "ipg_bus", CCM_CCGR1, CCM_CCGRx_CGn(2));
354354
355355 clk[VF610_CLK_NFC_SEL] = imx_clk_mux("nfc_sel", CCM_CSCMR1, 12, 2, nfc_sels, 4);
356356 clk[VF610_CLK_NFC_EN] = imx_clk_gate("nfc_en", "nfc_sel", CCM_CSCDR2, 9);
drivers/clk/mmp/clk-mmp2.c+1−0
@@ -9,6 +9,7 @@ · 8 unmodified lines
99 * warranty of any kind, whether express or implied.
1010 */
1111
12+#include <linux/clk.h>
1213 #include <linux/module.h>
1314 #include <linux/kernel.h>
1415 #include <linux/spinlock.h>
drivers/clk/mmp/clk-pxa168.c+1−0
@@ -9,6 +9,7 @@ · 8 unmodified lines
99 * warranty of any kind, whether express or implied.
1010 */
1111
12+#include <linux/clk.h>
1213 #include <linux/module.h>
1314 #include <linux/kernel.h>
1415 #include <linux/spinlock.h>
drivers/clk/mmp/clk-pxa910.c+1−0
@@ -9,6 +9,7 @@ · 8 unmodified lines
99 * warranty of any kind, whether express or implied.
1010 */
1111
12+#include <linux/clk.h>
1213 #include <linux/module.h>
1314 #include <linux/kernel.h>
1415 #include <linux/spinlock.h>
drivers/clk/sunxi/clk-a10-pll2.c+5−18
@@ -41,15 +41,10 @@ · 40 unmodified lines
4141
4242 #define SUN4I_PLL2_OUTPUTS 4
4343
44−struct sun4i_pll2_data {
45− u32 post_div_offset;
46− u32 pre_div_flags;
47−};
48−
4944 static DEFINE_SPINLOCK(sun4i_a10_pll2_lock);
5045
5146 static void __init sun4i_pll2_setup(struct device_node *node,
52− struct sun4i_pll2_data *data)
47+ int post_div_offset)
5348 {
5449 const char *clk_name = node->name, *parent;
5550 struct clk **clks, *base_clk, *prediv_clk;
@@ -76,7 +71,7 @@ static void __init sun4i_pll2_setup(struct device_node *node, · 20 unmodified lines
7671 parent, 0, reg,
7772 SUN4I_PLL2_PRE_DIV_SHIFT,
7873 SUN4I_PLL2_PRE_DIV_WIDTH,
79− data->pre_div_flags,
74+ CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
8075 &sun4i_a10_pll2_lock);
8176 if (!prediv_clk) {
8277 pr_err("Couldn't register the prediv clock\n");
@@ -127,7 +122,7 @@ static void __init sun4i_pll2_setup(struct device_node *node, · 44 unmodified lines
127122 */
128123 val = readl(reg);
129124 val &= ~(SUN4I_PLL2_POST_DIV_MASK << SUN4I_PLL2_POST_DIV_SHIFT);
130− val |= (SUN4I_PLL2_POST_DIV_VALUE - data->post_div_offset) << SUN4I_PLL2_POST_DIV_SHIFT;
125+ val |= (SUN4I_PLL2_POST_DIV_VALUE - post_div_offset) << SUN4I_PLL2_POST_DIV_SHIFT;
131126 writel(val, reg);
132127
133128 of_property_read_string_index(node, "clock-output-names",
@@ -191,25 +186,17 @@ err_unmap: · 57 unmodified lines
191186 iounmap(reg);
192187 }
193188
194−static struct sun4i_pll2_data sun4i_a10_pll2_data = {
195− .pre_div_flags = CLK_DIVIDER_ONE_BASED | CLK_DIVIDER_ALLOW_ZERO,
196−};
197−
198189 static void __init sun4i_a10_pll2_setup(struct device_node *node)
199190 {
200− sun4i_pll2_setup(node, &sun4i_a10_pll2_data);
191+ sun4i_pll2_setup(node, 0);
201192 }
202193
203194 CLK_OF_DECLARE(sun4i_a10_pll2, "allwinner,sun4i-a10-pll2-clk",
204195 sun4i_a10_pll2_setup);
205196
206−static struct sun4i_pll2_data sun5i_a13_pll2_data = {
207− .post_div_offset = 1,
208−};
209−
210197 static void __init sun5i_a13_pll2_setup(struct device_node *node)
211198 {
212− sun4i_pll2_setup(node, &sun5i_a13_pll2_data);
199+ sun4i_pll2_setup(node, 1);
213200 }
214201
215202 CLK_OF_DECLARE(sun5i_a13_pll2, "allwinner,sun5i-a13-pll2-clk",
drivers/clk/ti/clk-816x.c+2−0
@@ -20,6 +20,8 @@ static struct ti_dt_clk dm816x_clks[] = { · 19 unmodified lines
2020 DT_CLK(NULL, "sys_clkin", "sys_clkin_ck"),
2121 DT_CLK(NULL, "timer_sys_ck", "sys_clkin_ck"),
2222 DT_CLK(NULL, "sys_32k_ck", "sys_32k_ck"),
23+ DT_CLK(NULL, "timer_32k_ck", "sysclk18_ck"),
24+ DT_CLK(NULL, "timer_ext_ck", "tclkin_ck"),
2325 DT_CLK(NULL, "mpu_ck", "mpu_ck"),
2426 DT_CLK(NULL, "timer1_fck", "timer1_fck"),
2527 DT_CLK(NULL, "timer2_fck", "timer2_fck"),
drivers/clk/ti/clkt_dpll.c+2−2
@@ -240,7 +240,7 @@ u8 omap2_init_dpll_parent(struct clk_hw *hw) · 239 unmodified lines
240240 */
241241 unsigned long omap2_get_dpll_rate(struct clk_hw_omap *clk)
242242 {
243− long long dpll_clk;
243+ u64 dpll_clk;
244244 u32 dpll_mult, dpll_div, v;
245245 struct dpll_data *dd;
246246
@@ -262,7 +262,7 @@ unsigned long omap2_get_dpll_rate(struct clk_hw_omap *clk) · 15 unmodified lines
262262 dpll_div = v & dd->div1_mask;
263263 dpll_div >>= __ffs(dd->div1_mask);
264264
265− dpll_clk = (long long)clk_get_rate(dd->clk_ref) * dpll_mult;
265+ dpll_clk = (u64)clk_get_rate(dd->clk_ref) * dpll_mult;
266266 do_div(dpll_clk, dpll_div + 1);
267267
268268 return dpll_clk;
drivers/clk/ti/divider.c+3−13
@@ -214,7 +214,6 @@ static int ti_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate, · 213 unmodified lines
214214 {
215215 struct clk_divider *divider;
216216 unsigned int div, value;
217− unsigned long flags = 0;
218217 u32 val;
219218
220219 if (!hw || !rate)
@@ -228,9 +227,6 @@ static int ti_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate, · 7 unmodified lines
228227 if (value > div_mask(divider))
229228 value = div_mask(divider);
230229
231− if (divider->lock)
232− spin_lock_irqsave(divider->lock, flags);
233−
234230 if (divider->flags & CLK_DIVIDER_HIWORD_MASK) {
235231 val = div_mask(divider) << (divider->shift + 16);
236232 } else {
@@ -240,9 +236,6 @@ static int ti_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate, · 3 unmodified lines
240236 val |= value << divider->shift;
241237 ti_clk_ll_ops->clk_writel(val, divider->reg);
242238
243− if (divider->lock)
244− spin_unlock_irqrestore(divider->lock, flags);
245−
246239 return 0;
247240 }
248241
@@ -256,8 +249,7 @@ static struct clk *_register_divider(struct device *dev, const char *name, · 7 unmodified lines
256249 const char *parent_name,
257250 unsigned long flags, void __iomem *reg,
258251 u8 shift, u8 width, u8 clk_divider_flags,
259− const struct clk_div_table *table,
260− spinlock_t *lock)
252+ const struct clk_div_table *table)
261253 {
262254 struct clk_divider *div;
263255 struct clk *clk;
@@ -288,7 +280,6 @@ static struct clk *_register_divider(struct device *dev, const char *name, · 24 unmodified lines
288280 div->shift = shift;
289281 div->width = width;
290282 div->flags = clk_divider_flags;
291− div->lock = lock;
292283 div->hw.init = &init;
293284 div->table = table;
294285
@@ -421,7 +412,7 @@ struct clk *ti_clk_register_divider(struct ti_clk *setup) · 126 unmodified lines
421412
422413 clk = _register_divider(NULL, setup->name, div->parent,
423414 flags, (void __iomem *)reg, div->bit_shift,
424− width, div_flags, table, NULL);
415+ width, div_flags, table);
425416
426417 if (IS_ERR(clk))
427418 kfree(table);
@@ -584,8 +575,7 @@ static void __init of_ti_divider_clk_setup(struct device_node *node) · 156 unmodified lines
584575 goto cleanup;
585576
586577 clk = _register_divider(NULL, node->name, parent_name, flags, reg,
587− shift, width, clk_divider_flags, table,
588− NULL);
578+ shift, width, clk_divider_flags, table);
589579
590580 if (!IS_ERR(clk)) {
591581 of_clk_add_provider(node, of_clk_src_simple_get, clk);
drivers/clk/ti/fapll.c+2−2
@@ -168,7 +168,7 @@ static unsigned long ti_fapll_recalc_rate(struct clk_hw *hw, · 167 unmodified lines
168168 {
169169 struct fapll_data *fd = to_fapll(hw);
170170 u32 fapll_n, fapll_p, v;
171− long long rate;
171+ u64 rate;
172172
173173 if (ti_fapll_clock_is_bypass(fd))
174174 return parent_rate;
@@ -314,7 +314,7 @@ static unsigned long ti_fapll_synth_recalc_rate(struct clk_hw *hw, · 139 unmodified lines
314314 {
315315 struct fapll_synth *synth = to_synth(hw);
316316 u32 synth_div_m;
317− long long rate;
317+ u64 rate;
318318
319319 /* The audio_pll_clk1 is hardwired to produce 32.768KiHz clock */
320320 if (!synth->div)
drivers/clk/ti/mux.c+3−12
@@ -69,7 +69,6 @@ static int ti_clk_mux_set_parent(struct clk_hw *hw, u8 index) · 68 unmodified lines
6969 {
7070 struct clk_mux *mux = to_clk_mux(hw);
7171 u32 val;
72− unsigned long flags = 0;
7372
7473 if (mux->table) {
7574 index = mux->table[index];
@@ -81,9 +80,6 @@ static int ti_clk_mux_set_parent(struct clk_hw *hw, u8 index) · 5 unmodified lines
8180 index++;
8281 }
8382
84− if (mux->lock)
85− spin_lock_irqsave(mux->lock, flags);
86−
8783 if (mux->flags & CLK_MUX_HIWORD_MASK) {
8884 val = mux->mask << (mux->shift + 16);
8985 } else {
@@ -93,9 +89,6 @@ static int ti_clk_mux_set_parent(struct clk_hw *hw, u8 index) · 3 unmodified lines
9389 val |= index << mux->shift;
9490 ti_clk_ll_ops->clk_writel(val, mux->reg);
9591
96− if (mux->lock)
97− spin_unlock_irqrestore(mux->lock, flags);
98−
9992 return 0;
10093 }
10194
@@ -109,7 +102,7 @@ static struct clk *_register_mux(struct device *dev, const char *name, · 7 unmodified lines
109102 const char **parent_names, u8 num_parents,
110103 unsigned long flags, void __iomem *reg,
111104 u8 shift, u32 mask, u8 clk_mux_flags,
112− u32 *table, spinlock_t *lock)
105+ u32 *table)
113106 {
114107 struct clk_mux *mux;
115108 struct clk *clk;
@@ -133,7 +126,6 @@ static struct clk *_register_mux(struct device *dev, const char *name, · 17 unmodified lines
133126 mux->shift = shift;
134127 mux->mask = mask;
135128 mux->flags = clk_mux_flags;
136− mux->lock = lock;
137129 mux->table = table;
138130 mux->hw.init = &init;
139131
@@ -175,7 +167,7 @@ struct clk *ti_clk_register_mux(struct ti_clk *setup) · 35 unmodified lines
175167
176168 return _register_mux(NULL, setup->name, mux->parents, mux->num_parents,
177169 flags, (void __iomem *)reg, mux->bit_shift, mask,
178− mux_flags, NULL, NULL);
170+ mux_flags, NULL);
179171 }
180172
181173 /**
@@ -227,8 +219,7 @@ static void of_mux_clk_setup(struct device_node *node) · 45 unmodified lines
227219 mask = (1 << fls(mask)) - 1;
228220
229221 clk = _register_mux(NULL, node->name, parent_names, num_parents,
230− flags, reg, shift, mask, clk_mux_flags, NULL,
231− NULL);
222+ flags, reg, shift, mask, clk_mux_flags, NULL);
232223
233224 if (!IS_ERR(clk))
234225 of_clk_add_provider(node, of_clk_src_simple_get, clk);
drivers/clocksource/mmio.c+1−1
@@ -55,7 +55,7 @@ int __init clocksource_mmio_init(void __iomem *base, const char *name, · 54 unmodified lines
5555 {
5656 struct clocksource_mmio *cs;
5757
58− if (bits > 32 || bits < 16)
58+ if (bits > 64 || bits < 16)
5959 return -EINVAL;
6060
6161 cs = kzalloc(sizeof(struct clocksource_mmio), GFP_KERNEL);
drivers/cpufreq/Kconfig.arm+1−1
@@ -202,7 +202,7 @@ config ARM_SA1110_CPUFREQ · 201 unmodified lines
202202
203203 config ARM_SCPI_CPUFREQ
204204 tristate "SCPI based CPUfreq driver"
205− depends on ARM_BIG_LITTLE_CPUFREQ && ARM_SCPI_PROTOCOL
205+ depends on ARM_BIG_LITTLE_CPUFREQ && ARM_SCPI_PROTOCOL && COMMON_CLK_SCPI
206206 help
207207 This adds the CPUfreq driver support for ARM big.LITTLE platforms
208208 using SCPI protocol for CPU power management.
drivers/cpufreq/cppc_cpufreq.c+2−1
@@ -98,10 +98,11 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy) · 97 unmodified lines
9898 policy->max = cpu->perf_caps.highest_perf;
9999 policy->cpuinfo.min_freq = policy->min;
100100 policy->cpuinfo.max_freq = policy->max;
101+ policy->shared_type = cpu->shared_type;
101102
102103 if (policy->shared_type == CPUFREQ_SHARED_TYPE_ANY)
103104 cpumask_copy(policy->cpus, cpu->shared_cpu_map);
104− else {
105+ else if (policy->shared_type == CPUFREQ_SHARED_TYPE_ALL) {
105106 /* Support only SW_ANY for now. */
106107 pr_debug("Unsupported CPU co-ord type\n");
107108 return -EFAULT;
drivers/cpufreq/cpufreq.c+12−9
@@ -976,10 +976,14 @@ static int cpufreq_init_policy(struct cpufreq_policy *policy) · 975 unmodified lines
976976
977977 new_policy.governor = gov;
978978
979− /* Use the default policy if its valid. */
980− if (cpufreq_driver->setpolicy)
981− cpufreq_parse_governor(gov->name, &new_policy.policy, NULL);
982−
979+ /* Use the default policy if there is no last_policy. */
980+ if (cpufreq_driver->setpolicy) {
981+ if (policy->last_policy)
982+ new_policy.policy = policy->last_policy;
983+ else
984+ cpufreq_parse_governor(gov->name, &new_policy.policy,
985+ NULL);
986+ }
983987 /* set default policy */
984988 return cpufreq_set_policy(policy, &new_policy);
985989 }
@@ -1330,6 +1334,8 @@ static void cpufreq_offline_prepare(unsigned int cpu) · 344 unmodified lines
13301334 if (has_target())
13311335 strncpy(policy->last_governor, policy->governor->name,
13321336 CPUFREQ_NAME_LEN);
1337+ else
1338+ policy->last_policy = policy->policy;
13331339 } else if (cpu == policy->cpu) {
13341340 /* Nominate new CPU */
13351341 policy->cpu = cpumask_any(policy->cpus);
@@ -1401,13 +1407,10 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) · 65 unmodified lines
14011407 }
14021408
14031409 cpumask_clear_cpu(cpu, policy->real_cpus);
1410+ remove_cpu_dev_symlink(policy, cpu);
14041411
1405− if (cpumask_empty(policy->real_cpus)) {
1412+ if (cpumask_empty(policy->real_cpus))
14061413 cpufreq_policy_free(policy, true);
1407− return;
1408− }
1409−
1410− remove_cpu_dev_symlink(policy, cpu);
14111414 }
14121415
14131416 static void handle_update(struct work_struct *work)
drivers/cpufreq/intel_pstate.c+5−1
@@ -1101,6 +1101,8 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) · 1100 unmodified lines
11011101 policy->max >= policy->cpuinfo.max_freq) {
11021102 pr_debug("intel_pstate: set performance\n");
11031103 limits = &performance_limits;
1104+ if (hwp_active)
1105+ intel_pstate_hwp_set();
11041106 return 0;
11051107 }
11061108
@@ -1108,7 +1110,8 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) · 1 unmodified line
11081110 limits = &powersave_limits;
11091111 limits->min_policy_pct = (policy->min * 100) / policy->cpuinfo.max_freq;
11101112 limits->min_policy_pct = clamp_t(int, limits->min_policy_pct, 0 , 100);
1111− limits->max_policy_pct = (policy->max * 100) / policy->cpuinfo.max_freq;
1113+ limits->max_policy_pct = DIV_ROUND_UP(policy->max * 100,
1114+ policy->cpuinfo.max_freq);
11121115 limits->max_policy_pct = clamp_t(int, limits->max_policy_pct, 0 , 100);
11131116
11141117 /* Normalize user input to [min_policy_pct, max_policy_pct] */
@@ -1120,6 +1123,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) · 5 unmodified lines
11201123 limits->max_sysfs_pct);
11211124 limits->max_perf_pct = max(limits->min_policy_pct,
11221125 limits->max_perf_pct);
1126+ limits->max_perf = round_up(limits->max_perf, 8);
11231127
11241128 /* Make sure min_perf_pct <= max_perf_pct */
11251129 limits->min_perf_pct = min(limits->max_perf_pct, limits->min_perf_pct);
drivers/cpufreq/s3c24xx-cpufreq.c+1−1
@@ -648,7 +648,7 @@ late_initcall(s3c_cpufreq_initcall); · 647 unmodified lines
648648 *
649649 * Register the given set of PLLs with the system.
650650 */
651−int __init s3c_plltab_register(struct cpufreq_frequency_table *plls,
651+int s3c_plltab_register(struct cpufreq_frequency_table *plls,
652652 unsigned int plls_no)
653653 {
654654 struct cpufreq_frequency_table *vals;
drivers/crypto/nx/nx-aes-ccm.c+1−1
@@ -409,7 +409,7 @@ static int ccm_nx_decrypt(struct aead_request *req, · 408 unmodified lines
409409 processed += to_process;
410410 } while (processed < nbytes);
411411
412− rc = memcmp(csbcpb->cpb.aes_ccm.out_pat_or_mac, priv->oauth_tag,
412+ rc = crypto_memneq(csbcpb->cpb.aes_ccm.out_pat_or_mac, priv->oauth_tag,
413413 authsize) ? -EBADMSG : 0;
414414 out:
415415 spin_unlock_irqrestore(&nx_ctx->lock, irq_flags);
drivers/crypto/nx/nx-aes-gcm.c+2−1
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121
2222 #include <crypto/internal/aead.h>
2323 #include <crypto/aes.h>
24+#include <crypto/algapi.h>
2425 #include <crypto/scatterwalk.h>
2526 #include <linux/module.h>
2627 #include <linux/types.h>
@@ -418,7 +419,7 @@ mac: · 391 unmodified lines
418419 itag, req->src, req->assoclen + nbytes,
419420 crypto_aead_authsize(crypto_aead_reqtfm(req)),
420421 SCATTERWALK_FROM_SG);
421− rc = memcmp(itag, otag,
422+ rc = crypto_memneq(itag, otag,
422423 crypto_aead_authsize(crypto_aead_reqtfm(req))) ?
423424 -EBADMSG : 0;
424425 }
drivers/crypto/talitos.c+1−1
@@ -977,7 +977,7 @@ static void ipsec_esp_decrypt_swauth_done(struct device *dev, · 976 unmodified lines
977977 } else
978978 oicv = (char *)&edesc->link_tbl[0];
979979
980− err = memcmp(oicv, icv, authsize) ? -EBADMSG : 0;
980+ err = crypto_memneq(oicv, icv, authsize) ? -EBADMSG : 0;
981981 }
982982
983983 kfree(edesc);
drivers/fpga/fpga-mgr.c+4−9
@@ -122,12 +122,10 @@ int fpga_mgr_firmware_load(struct fpga_manager *mgr, u32 flags, · 121 unmodified lines
122122 }
123123
124124 ret = fpga_mgr_buf_load(mgr, flags, fw->data, fw->size);
125− if (ret)
126− return ret;
127125
128126 release_firmware(fw);
129127
130− return 0;
128+ return ret;
131129 }
132130 EXPORT_SYMBOL_GPL(fpga_mgr_firmware_load);
133131
@@ -256,7 +254,6 @@ int fpga_mgr_register(struct device *dev, const char *name, · 122 unmodified lines
256254 void *priv)
257255 {
258256 struct fpga_manager *mgr;
259− const char *dt_label;
260257 int id, ret;
261258
262259 if (!mops || !mops->write_init || !mops->write ||
@@ -300,11 +297,9 @@ int fpga_mgr_register(struct device *dev, const char *name, · 37 unmodified lines
300297 mgr->dev.id = id;
301298 dev_set_drvdata(dev, mgr);
302299
303− dt_label = of_get_property(mgr->dev.of_node, "label", NULL);
304− if (dt_label)
305− ret = dev_set_name(&mgr->dev, "%s", dt_label);
306− else
307− ret = dev_set_name(&mgr->dev, "fpga%d", id);
300+ ret = dev_set_name(&mgr->dev, "fpga%d", id);
301+ if (ret)
302+ goto error_device;
308303
309304 ret = device_add(&mgr->dev);
310305 if (ret)
drivers/gpio/gpio-74xx-mmio.c+5−2
@@ -113,13 +113,16 @@ static int mmio_74xx_dir_out(struct gpio_chip *gc, unsigned int gpio, int val) · 112 unmodified lines
113113
114114 static int mmio_74xx_gpio_probe(struct platform_device *pdev)
115115 {
116− const struct of_device_id *of_id =
117− of_match_device(mmio_74xx_gpio_ids, &pdev->dev);
116+ const struct of_device_id *of_id;
118117 struct mmio_74xx_gpio_priv *priv;
119118 struct resource *res;
120119 void __iomem *dat;
121120 int err;
122121
122+ of_id = of_match_device(mmio_74xx_gpio_ids, &pdev->dev);
123+ if (!of_id)
124+ return -ENODEV;
125+
123126 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
124127 if (!priv)
125128 return -ENOMEM;
drivers/gpio/gpio-omap.c+0−2
@@ -1122,8 +1122,6 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc) · 1121 unmodified lines
11221122 /* MPUIO is a bit different, reading IRQ status clears it */
11231123 if (bank->is_mpuio) {
11241124 irqc->irq_ack = dummy_irq_chip.irq_ack;
1125− irqc->irq_mask = irq_gc_mask_set_bit;
1126− irqc->irq_unmask = irq_gc_mask_clr_bit;
11271125 if (!bank->regs->wkup_en)
11281126 irqc->irq_set_wake = NULL;
11291127 }
drivers/gpio/gpio-palmas.c+2−0
@@ -167,6 +167,8 @@ static int palmas_gpio_probe(struct platform_device *pdev) · 166 unmodified lines
167167 const struct palmas_device_data *dev_data;
168168
169169 match = of_match_device(of_palmas_gpio_match, &pdev->dev);
170+ if (!match)
171+ return -ENODEV;
170172 dev_data = match->data;
171173 if (!dev_data)
172174 dev_data = &palmas_dev_data;
drivers/gpio/gpio-syscon.c+5−1
@@ -187,11 +187,15 @@ MODULE_DEVICE_TABLE(of, syscon_gpio_ids); · 186 unmodified lines
187187 static int syscon_gpio_probe(struct platform_device *pdev)
188188 {
189189 struct device *dev = &pdev->dev;
190− const struct of_device_id *of_id = of_match_device(syscon_gpio_ids, dev);
190+ const struct of_device_id *of_id;
191191 struct syscon_gpio_priv *priv;
192192 struct device_node *np = dev->of_node;
193193 int ret;
194194
195+ of_id = of_match_device(syscon_gpio_ids, dev);
196+ if (!of_id)
197+ return -ENODEV;
198+
195199 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
196200 if (!priv)
197201 return -ENOMEM;
drivers/gpio/gpio-tegra.c+56−49
@@ -375,6 +375,60 @@ static int tegra_gpio_irq_set_wake(struct irq_data *d, unsigned int enable) · 374 unmodified lines
375375 }
376376 #endif
377377
378+#ifdef CONFIG_DEBUG_FS
379+
380+#include <linux/debugfs.h>
381+#include <linux/seq_file.h>
382+
383+static int dbg_gpio_show(struct seq_file *s, void *unused)
384+{
385+ int i;
386+ int j;
387+
388+ for (i = 0; i < tegra_gpio_bank_count; i++) {
389+ for (j = 0; j < 4; j++) {
390+ int gpio = tegra_gpio_compose(i, j, 0);
391+ seq_printf(s,
392+ "%d:%d %02x %02x %02x %02x %02x %02x %06x\n",
393+ i, j,
394+ tegra_gpio_readl(GPIO_CNF(gpio)),
395+ tegra_gpio_readl(GPIO_OE(gpio)),
396+ tegra_gpio_readl(GPIO_OUT(gpio)),
397+ tegra_gpio_readl(GPIO_IN(gpio)),
398+ tegra_gpio_readl(GPIO_INT_STA(gpio)),
399+ tegra_gpio_readl(GPIO_INT_ENB(gpio)),
400+ tegra_gpio_readl(GPIO_INT_LVL(gpio)));
401+ }
402+ }
403+ return 0;
404+}
405+
406+static int dbg_gpio_open(struct inode *inode, struct file *file)
407+{
408+ return single_open(file, dbg_gpio_show, &inode->i_private);
409+}
410+
411+static const struct file_operations debug_fops = {
412+ .open = dbg_gpio_open,
413+ .read = seq_read,
414+ .llseek = seq_lseek,
415+ .release = single_release,
416+};
417+
418+static void tegra_gpio_debuginit(void)
419+{
420+ (void) debugfs_create_file("tegra_gpio", S_IRUGO,
421+ NULL, NULL, &debug_fops);
422+}
423+
424+#else
425+
426+static inline void tegra_gpio_debuginit(void)
427+{
428+}
429+
430+#endif
431+
378432 static struct irq_chip tegra_gpio_irq_chip = {
379433 .name = "GPIO",
380434 .irq_ack = tegra_gpio_irq_ack,
@@ -519,6 +573,8 @@ static int tegra_gpio_probe(struct platform_device *pdev) · 138 unmodified lines
519573 spin_lock_init(&bank->lvl_lock[j]);
520574 }
521575
576+ tegra_gpio_debuginit();
577+
522578 return 0;
523579 }
524580
@@ -536,52 +592,3 @@ static int __init tegra_gpio_init(void) · 11 unmodified lines
536592 return platform_driver_register(&tegra_gpio_driver);
537593 }
538594 postcore_initcall(tegra_gpio_init);
539−
540−#ifdef CONFIG_DEBUG_FS
541−
542−#include <linux/debugfs.h>
543−#include <linux/seq_file.h>
544−
545−static int dbg_gpio_show(struct seq_file *s, void *unused)
546−{
547− int i;
548− int j;
549−
550− for (i = 0; i < tegra_gpio_bank_count; i++) {
551− for (j = 0; j < 4; j++) {
552− int gpio = tegra_gpio_compose(i, j, 0);
553− seq_printf(s,
554− "%d:%d %02x %02x %02x %02x %02x %02x %06x\n",
555− i, j,
556− tegra_gpio_readl(GPIO_CNF(gpio)),
557− tegra_gpio_readl(GPIO_OE(gpio)),
558− tegra_gpio_readl(GPIO_OUT(gpio)),
559− tegra_gpio_readl(GPIO_IN(gpio)),
560− tegra_gpio_readl(GPIO_INT_STA(gpio)),
561− tegra_gpio_readl(GPIO_INT_ENB(gpio)),
562− tegra_gpio_readl(GPIO_INT_LVL(gpio)));
563− }
564− }
565− return 0;
566−}
567−
568−static int dbg_gpio_open(struct inode *inode, struct file *file)
569−{
570− return single_open(file, dbg_gpio_show, &inode->i_private);
571−}
572−
573−static const struct file_operations debug_fops = {
574− .open = dbg_gpio_open,
575− .read = seq_read,
576− .llseek = seq_lseek,
577− .release = single_release,
578−};
579−
580−static int __init tegra_gpio_debuginit(void)
581−{
582− (void) debugfs_create_file("tegra_gpio", S_IRUGO,
583− NULL, NULL, &debug_fops);
584− return 0;
585−}
586−late_initcall(tegra_gpio_debuginit);
587−#endif
drivers/gpio/gpiolib.c+1−1
@@ -233,7 +233,7 @@ static struct gpio_desc *gpio_name_to_desc(const char * const name) · 232 unmodified lines
233233 for (i = 0; i != chip->ngpio; ++i) {
234234 struct gpio_desc *gpio = &chip->desc[i];
235235
236− if (!gpio->name)
236+ if (!gpio->name || !name)
237237 continue;
238238
239239 if (!strcmp(gpio->name, name)) {
drivers/gpu/drm/amd/amdgpu/amdgpu.h+4−2
@@ -496,6 +496,7 @@ struct amdgpu_bo_va_mapping { · 495 unmodified lines
496496
497497 /* bo virtual addresses in a specific vm */
498498 struct amdgpu_bo_va {
499+ struct mutex mutex;
499500 /* protected by bo being reserved */
500501 struct list_head bo_list;
501502 struct fence *last_pt_update;
@@ -538,6 +539,7 @@ struct amdgpu_bo { · 36 unmodified lines
538539 /* Constant after initialization */
539540 struct amdgpu_device *adev;
540541 struct drm_gem_object gem_base;
542+ struct amdgpu_bo *parent;
541543
542544 struct ttm_bo_kmap_obj dma_buf_vmap;
543545 pid_t pid;
@@ -928,8 +930,6 @@ struct amdgpu_vm_id { · 384 unmodified lines
928930 };
929931
930932 struct amdgpu_vm {
931− struct mutex mutex;
932−
933933 struct rb_root va;
934934
935935 /* protecting invalidated */
@@ -956,6 +956,8 @@ struct amdgpu_vm { · 20 unmodified lines
956956 struct amdgpu_vm_id ids[AMDGPU_MAX_RINGS];
957957 /* for interval tree */
958958 spinlock_t it_lock;
959+ /* protecting freed */
960+ spinlock_t freed_lock;
959961 };
960962
961963 struct amdgpu_vm_manager {
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c+4−6
@@ -222,6 +222,8 @@ int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data) · 221 unmodified lines
222222 }
223223
224224 p->uf.bo = gem_to_amdgpu_bo(gobj);
225+ amdgpu_bo_ref(p->uf.bo);
226+ drm_gem_object_unreference_unlocked(gobj);
225227 p->uf.offset = fence_data->offset;
226228 } else {
227229 ret = -EINVAL;
@@ -487,7 +489,7 @@ static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, bo · 259 unmodified lines
487489 amdgpu_ib_free(parser->adev, &parser->ibs[i]);
488490 kfree(parser->ibs);
489491 if (parser->uf.bo)
490− drm_gem_object_unreference_unlocked(&parser->uf.bo->gem_base);
492+ amdgpu_bo_unref(&parser->uf.bo);
491493 }
492494
493495 static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p,
@@ -776,7 +778,7 @@ static int amdgpu_cs_free_job(struct amdgpu_job *job) · 282 unmodified lines
776778 amdgpu_ib_free(job->adev, &job->ibs[i]);
777779 kfree(job->ibs);
778780 if (job->uf.bo)
779− drm_gem_object_unreference_unlocked(&job->uf.bo->gem_base);
781+ amdgpu_bo_unref(&job->uf.bo);
780782 return 0;
781783 }
782784
@@ -784,8 +786,6 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) · 1 unmodified line
784786 {
785787 struct amdgpu_device *adev = dev->dev_private;
786788 union drm_amdgpu_cs *cs = data;
787− struct amdgpu_fpriv *fpriv = filp->driver_priv;
788− struct amdgpu_vm *vm = &fpriv->vm;
789789 struct amdgpu_cs_parser parser = {};
790790 bool reserved_buffers = false;
791791 int i, r;
@@ -803,7 +803,6 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) · 11 unmodified lines
803803 r = amdgpu_cs_handle_lockup(adev, r);
804804 return r;
805805 }
806− mutex_lock(&vm->mutex);
807806 r = amdgpu_cs_parser_relocs(&parser);
808807 if (r == -ENOMEM)
809808 DRM_ERROR("Not enough memory for command submission!\n");
@@ -888,7 +887,6 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) · 78 unmodified lines
888887
889888 out:
890889 amdgpu_cs_parser_fini(&parser, r, reserved_buffers);
891− mutex_unlock(&vm->mutex);
892890 r = amdgpu_cs_handle_lockup(adev, r);
893891 return r;
894892 }
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c+79−29
@@ -73,6 +73,8 @@ static void amdgpu_flip_work_func(struct work_struct *__work) · 72 unmodified lines
7373 struct drm_crtc *crtc = &amdgpuCrtc->base;
7474 unsigned long flags;
7575 unsigned i;
76+ int vpos, hpos, stat, min_udelay;
77+ struct drm_vblank_crtc *vblank = &crtc->dev->vblank[work->crtc_id];
7678
7779 amdgpu_flip_wait_fence(adev, &work->excl);
7880 for (i = 0; i < work->shared_count; ++i)
@@ -81,6 +83,41 @@ static void amdgpu_flip_work_func(struct work_struct *__work) · 2 unmodified lines
8183 /* We borrow the event spin lock for protecting flip_status */
8284 spin_lock_irqsave(&crtc->dev->event_lock, flags);
8385
86+ /* If this happens to execute within the "virtually extended" vblank
87+ * interval before the start of the real vblank interval then it needs
88+ * to delay programming the mmio flip until the real vblank is entered.
89+ * This prevents completing a flip too early due to the way we fudge
90+ * our vblank counter and vblank timestamps in order to work around the
91+ * problem that the hw fires vblank interrupts before actual start of
92+ * vblank (when line buffer refilling is done for a frame). It
93+ * complements the fudging logic in amdgpu_get_crtc_scanoutpos() for
94+ * timestamping and amdgpu_get_vblank_counter_kms() for vblank counts.
95+ *
96+ * In practice this won't execute very often unless on very fast
97+ * machines because the time window for this to happen is very small.
98+ */
99+ for (;;) {
100+ /* GET_DISTANCE_TO_VBLANKSTART returns distance to real vblank
101+ * start in hpos, and to the "fudged earlier" vblank start in
102+ * vpos.
103+ */
104+ stat = amdgpu_get_crtc_scanoutpos(adev->ddev, work->crtc_id,
105+ GET_DISTANCE_TO_VBLANKSTART,
106+ &vpos, &hpos, NULL, NULL,
107+ &crtc->hwmode);
108+
109+ if ((stat & (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE)) !=
110+ (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE) ||
111+ !(vpos >= 0 && hpos <= 0))
112+ break;
113+
114+ /* Sleep at least until estimated real start of hw vblank */
115+ spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
116+ min_udelay = (-hpos + 1) * max(vblank->linedur_ns / 1000, 5);
117+ usleep_range(min_udelay, 2 * min_udelay);
118+ spin_lock_irqsave(&crtc->dev->event_lock, flags);
119+ };
120+
84121 /* do the flip (mmio) */
85122 adev->mode_info.funcs->page_flip(adev, work->crtc_id, work->base);
86123 /* set the flip status */
@@ -109,7 +146,7 @@ static void amdgpu_unpin_work_func(struct work_struct *__work) · 22 unmodified lines
109146 } else
110147 DRM_ERROR("failed to reserve buffer after flip\n");
111148
112− drm_gem_object_unreference_unlocked(&work->old_rbo->gem_base);
149+ amdgpu_bo_unref(&work->old_rbo);
113150 kfree(work->shared);
114151 kfree(work);
115152 }
@@ -148,8 +185,8 @@ int amdgpu_crtc_page_flip(struct drm_crtc *crtc, · 32 unmodified lines
148185 obj = old_amdgpu_fb->obj;
149186
150187 /* take a reference to the old object */
151− drm_gem_object_reference(obj);
152188 work->old_rbo = gem_to_amdgpu_bo(obj);
189+ amdgpu_bo_ref(work->old_rbo);
153190
154191 new_amdgpu_fb = to_amdgpu_framebuffer(fb);
155192 obj = new_amdgpu_fb->obj;
@@ -222,7 +259,7 @@ pflip_cleanup: · 66 unmodified lines
222259 amdgpu_bo_unreserve(new_rbo);
223260
224261 cleanup:
225− drm_gem_object_unreference_unlocked(&work->old_rbo->gem_base);
262+ amdgpu_bo_unref(&work->old_rbo);
226263 fence_put(work->excl);
227264 for (i = 0; i < work->shared_count; ++i)
228265 fence_put(work->shared[i]);
@@ -712,6 +749,15 @@ bool amdgpu_crtc_scaling_mode_fixup(struct drm_crtc *crtc, · 483 unmodified lines
712749 * \param dev Device to query.
713750 * \param pipe Crtc to query.
714751 * \param flags Flags from caller (DRM_CALLED_FROM_VBLIRQ or 0).
752+ * For driver internal use only also supports these flags:
753+ *
754+ * USE_REAL_VBLANKSTART to use the real start of vblank instead
755+ * of a fudged earlier start of vblank.
756+ *
757+ * GET_DISTANCE_TO_VBLANKSTART to return distance to the
758+ * fudged earlier start of vblank in *vpos and the distance
759+ * to true start of vblank in *hpos.
760+ *
715761 * \param *vpos Location where vertical scanout position should be stored.
716762 * \param *hpos Location where horizontal scanout position should go.
717763 * \param *stime Target location for timestamp taken immediately before
@@ -776,10 +822,40 @@ int amdgpu_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe, · 58 unmodified lines
776822 vbl_end = 0;
777823 }
778824
825+ /* Called from driver internal vblank counter query code? */
826+ if (flags & GET_DISTANCE_TO_VBLANKSTART) {
827+ /* Caller wants distance from real vbl_start in *hpos */
828+ *hpos = *vpos - vbl_start;
829+ }
830+
831+ /* Fudge vblank to start a few scanlines earlier to handle the
832+ * problem that vblank irqs fire a few scanlines before start
833+ * of vblank. Some driver internal callers need the true vblank
834+ * start to be used and signal this via the USE_REAL_VBLANKSTART flag.
835+ *
836+ * The cause of the "early" vblank irq is that the irq is triggered
837+ * by the line buffer logic when the line buffer read position enters
838+ * the vblank, whereas our crtc scanout position naturally lags the
839+ * line buffer read position.
840+ */
841+ if (!(flags & USE_REAL_VBLANKSTART))
842+ vbl_start -= adev->mode_info.crtcs[pipe]->lb_vblank_lead_lines;
843+
779844 /* Test scanout position against vblank region. */
780845 if ((*vpos < vbl_start) && (*vpos >= vbl_end))
781846 in_vbl = false;
782847
848+ /* In vblank? */
849+ if (in_vbl)
850+ ret |= DRM_SCANOUTPOS_IN_VBLANK;
851+
852+ /* Called from driver internal vblank counter query code? */
853+ if (flags & GET_DISTANCE_TO_VBLANKSTART) {
854+ /* Caller wants distance from fudged earlier vbl_start */
855+ *vpos -= vbl_start;
856+ return ret;
857+ }
858+
783859 /* Check if inside vblank area and apply corrective offsets:
784860 * vpos will then be >=0 in video scanout area, but negative
785861 * within vblank area, counting down the number of lines until
@@ -795,32 +871,6 @@ int amdgpu_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe, · 9 unmodified lines
795871 /* Correct for shifted end of vbl at vbl_end. */
796872 *vpos = *vpos - vbl_end;
797873
798− /* In vblank? */
799− if (in_vbl)
800− ret |= DRM_SCANOUTPOS_IN_VBLANK;
801−
802− /* Is vpos outside nominal vblank area, but less than
803− * 1/100 of a frame height away from start of vblank?
804− * If so, assume this isn't a massively delayed vblank
805− * interrupt, but a vblank interrupt that fired a few
806− * microseconds before true start of vblank. Compensate
807− * by adding a full frame duration to the final timestamp.
808− * Happens, e.g., on ATI R500, R600.
809− *
810− * We only do this if DRM_CALLED_FROM_VBLIRQ.
811− */
812− if ((flags & DRM_CALLED_FROM_VBLIRQ) && !in_vbl) {
813− vbl_start = mode->crtc_vdisplay;
814− vtotal = mode->crtc_vtotal;
815−
816− if (vbl_start - *vpos < vtotal / 100) {
817− *vpos -= vtotal;
818−
819− /* Signal this correction as "applied". */
820− ret |= 0x8;
821− }
822− }
823−
824874 return ret;
825875 }
826876
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c+13−14
@@ -115,12 +115,9 @@ int amdgpu_gem_object_open(struct drm_gem_object *obj, struct drm_file *file_pri · 114 unmodified lines
115115 struct amdgpu_vm *vm = &fpriv->vm;
116116 struct amdgpu_bo_va *bo_va;
117117 int r;
118− mutex_lock(&vm->mutex);
119118 r = amdgpu_bo_reserve(rbo, false);
120− if (r) {
121− mutex_unlock(&vm->mutex);
119+ if (r)
122120 return r;
123− }
124121
125122 bo_va = amdgpu_vm_bo_find(vm, rbo);
126123 if (!bo_va) {
@@ -129,7 +126,6 @@ int amdgpu_gem_object_open(struct drm_gem_object *obj, struct drm_file *file_pri · 2 unmodified lines
129126 ++bo_va->ref_count;
130127 }
131128 amdgpu_bo_unreserve(rbo);
132− mutex_unlock(&vm->mutex);
133129 return 0;
134130 }
135131
@@ -142,10 +138,8 @@ void amdgpu_gem_object_close(struct drm_gem_object *obj, · 6 unmodified lines
142138 struct amdgpu_vm *vm = &fpriv->vm;
143139 struct amdgpu_bo_va *bo_va;
144140 int r;
145− mutex_lock(&vm->mutex);
146141 r = amdgpu_bo_reserve(rbo, true);
147142 if (r) {
148− mutex_unlock(&vm->mutex);
149143 dev_err(adev->dev, "leaking bo va because "
150144 "we fail to reserve bo (%d)\n", r);
151145 return;
@@ -157,7 +151,6 @@ void amdgpu_gem_object_close(struct drm_gem_object *obj, · 5 unmodified lines
157151 }
158152 }
159153 amdgpu_bo_unreserve(rbo);
160− mutex_unlock(&vm->mutex);
161154 }
162155
163156 static int amdgpu_gem_handle_lockup(struct amdgpu_device *adev, int r)
@@ -242,8 +235,9 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data, · 78 unmodified lines
242235 AMDGPU_GEM_USERPTR_REGISTER))
243236 return -EINVAL;
244237
245− if (!(args->flags & AMDGPU_GEM_USERPTR_ANONONLY) ||
246− !(args->flags & AMDGPU_GEM_USERPTR_REGISTER)) {
238+ if (!(args->flags & AMDGPU_GEM_USERPTR_READONLY) && (
239+ !(args->flags & AMDGPU_GEM_USERPTR_ANONONLY) ||
240+ !(args->flags & AMDGPU_GEM_USERPTR_REGISTER))) {
247241
248242 /* if we want to write to it we must require anonymous
249243 memory and install a MMU notifier */
@@ -483,6 +477,14 @@ static void amdgpu_gem_va_update_vm(struct amdgpu_device *adev, · 233 unmodified lines
483477 if (domain == AMDGPU_GEM_DOMAIN_CPU)
484478 goto error_unreserve;
485479 }
480+ list_for_each_entry(entry, &duplicates, head) {
481+ domain = amdgpu_mem_type_to_domain(entry->bo->mem.mem_type);
482+ /* if anything is swapped out don't swap it in here,
483+ just abort and wait for the next CS */
484+ if (domain == AMDGPU_GEM_DOMAIN_CPU)
485+ goto error_unreserve;
486+ }
487+
486488 r = amdgpu_vm_update_page_directory(adev, bo_va->vm);
487489 if (r)
488490 goto error_unreserve;
@@ -553,7 +555,6 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, · 64 unmodified lines
553555 gobj = drm_gem_object_lookup(dev, filp, args->handle);
554556 if (gobj == NULL)
555557 return -ENOENT;
556− mutex_lock(&fpriv->vm.mutex);
557558 rbo = gem_to_amdgpu_bo(gobj);
558559 INIT_LIST_HEAD(&list);
559560 INIT_LIST_HEAD(&duplicates);
@@ -568,7 +569,6 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, · 8 unmodified lines
568569 }
569570 r = ttm_eu_reserve_buffers(&ticket, &list, true, &duplicates);
570571 if (r) {
571− mutex_unlock(&fpriv->vm.mutex);
572572 drm_gem_object_unreference_unlocked(gobj);
573573 return r;
574574 }
@@ -577,7 +577,6 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, · 2 unmodified lines
577577 if (!bo_va) {
578578 ttm_eu_backoff_reservation(&ticket, &list);
579579 drm_gem_object_unreference_unlocked(gobj);
580− mutex_unlock(&fpriv->vm.mutex);
581580 return -ENOENT;
582581 }
583582
@@ -602,7 +601,7 @@ int amdgpu_gem_va_ioctl(struct drm_device *dev, void *data, · 18 unmodified lines
602601 ttm_eu_backoff_reservation(&ticket, &list);
603602 if (!r && !(args->flags & AMDGPU_VM_DELAY_UPDATE))
604603 amdgpu_gem_va_update_vm(adev, bo_va, args->operation);
605− mutex_unlock(&fpriv->vm.mutex);
604+
606605 drm_gem_object_unreference_unlocked(gobj);
607606 return r;
608607 }
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c+47−1
@@ -611,13 +611,59 @@ void amdgpu_driver_preclose_kms(struct drm_device *dev, · 610 unmodified lines
611611 u32 amdgpu_get_vblank_counter_kms(struct drm_device *dev, unsigned int pipe)
612612 {
613613 struct amdgpu_device *adev = dev->dev_private;
614+ int vpos, hpos, stat;
615+ u32 count;
614616
615617 if (pipe >= adev->mode_info.num_crtc) {
616618 DRM_ERROR("Invalid crtc %u\n", pipe);
617619 return -EINVAL;
618620 }
619621
620− return amdgpu_display_vblank_get_counter(adev, pipe);
622+ /* The hw increments its frame counter at start of vsync, not at start
623+ * of vblank, as is required by DRM core vblank counter handling.
624+ * Cook the hw count here to make it appear to the caller as if it
625+ * incremented at start of vblank. We measure distance to start of
626+ * vblank in vpos. vpos therefore will be >= 0 between start of vblank
627+ * and start of vsync, so vpos >= 0 means to bump the hw frame counter
628+ * result by 1 to give the proper appearance to caller.
629+ */
630+ if (adev->mode_info.crtcs[pipe]) {
631+ /* Repeat readout if needed to provide stable result if
632+ * we cross start of vsync during the queries.
633+ */
634+ do {
635+ count = amdgpu_display_vblank_get_counter(adev, pipe);
636+ /* Ask amdgpu_get_crtc_scanoutpos to return vpos as
637+ * distance to start of vblank, instead of regular
638+ * vertical scanout pos.
639+ */
640+ stat = amdgpu_get_crtc_scanoutpos(
641+ dev, pipe, GET_DISTANCE_TO_VBLANKSTART,
642+ &vpos, &hpos, NULL, NULL,
643+ &adev->mode_info.crtcs[pipe]->base.hwmode);
644+ } while (count != amdgpu_display_vblank_get_counter(adev, pipe));
645+
646+ if (((stat & (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE)) !=
647+ (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE))) {
648+ DRM_DEBUG_VBL("Query failed! stat %d\n", stat);
649+ } else {
650+ DRM_DEBUG_VBL("crtc %d: dist from vblank start %d\n",
651+ pipe, vpos);
652+
653+ /* Bump counter if we are at >= leading edge of vblank,
654+ * but before vsync where vpos would turn negative and
655+ * the hw counter really increments.
656+ */
657+ if (vpos >= 0)
658+ count++;
659+ }
660+ } else {
661+ /* Fallback to use value as is. */
662+ count = amdgpu_display_vblank_get_counter(adev, pipe);
663+ DRM_DEBUG_VBL("NULL mode info! Returned count may be wrong.\n");
664+ }
665+
666+ return count;
621667 }
622668
623669 /**
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h+5−0
@@ -407,6 +407,7 @@ struct amdgpu_crtc { · 406 unmodified lines
407407 u32 line_time;
408408 u32 wm_low;
409409 u32 wm_high;
410+ u32 lb_vblank_lead_lines;
410411 struct drm_display_mode hw_mode;
411412 };
412413
@@ -528,6 +529,10 @@ struct amdgpu_framebuffer { · 115 unmodified lines
528529 #define ENCODER_MODE_IS_DP(em) (((em) == ATOM_ENCODER_MODE_DP) || \
529530 ((em) == ATOM_ENCODER_MODE_DP_MST))
530531
532+/* Driver internal use only flags of amdgpu_get_crtc_scanoutpos() */
533+#define USE_REAL_VBLANKSTART (1 << 30)
534+#define GET_DISTANCE_TO_VBLANKSTART (1 << 31)
535+
531536 void amdgpu_link_encoder_connector(struct drm_device *dev);
532537
533538 struct drm_connector *
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c+1−0
@@ -100,6 +100,7 @@ static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo) · 99 unmodified lines
100100 list_del_init(&bo->list);
101101 mutex_unlock(&bo->adev->gem.mutex);
102102 drm_gem_object_release(&bo->gem_base);
103+ amdgpu_bo_unref(&bo->parent);
103104 kfree(bo->metadata);
104105 kfree(bo);
105106 }
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c+11−6
@@ -587,9 +587,13 @@ static int amdgpu_ttm_backend_bind(struct ttm_tt *ttm, · 586 unmodified lines
587587 uint32_t flags = amdgpu_ttm_tt_pte_flags(gtt->adev, ttm, bo_mem);
588588 int r;
589589
590− if (gtt->userptr)
591− amdgpu_ttm_tt_pin_userptr(ttm);
592−
590+ if (gtt->userptr) {
591+ r = amdgpu_ttm_tt_pin_userptr(ttm);
592+ if (r) {
593+ DRM_ERROR("failed to pin userptr\n");
594+ return r;
595+ }
596+ }
593597 gtt->offset = (unsigned long)(bo_mem->start << PAGE_SHIFT);
594598 if (!ttm->num_pages) {
595599 WARN(1, "nothing to bind %lu pages for mreg %p back %p!\n",
@@ -797,11 +801,12 @@ uint32_t amdgpu_ttm_tt_pte_flags(struct amdgpu_device *adev, struct ttm_tt *ttm, · 201 unmodified lines
797801 if (mem && mem->mem_type != TTM_PL_SYSTEM)
798802 flags |= AMDGPU_PTE_VALID;
799803
800− if (mem && mem->mem_type == TTM_PL_TT)
804+ if (mem && mem->mem_type == TTM_PL_TT) {
801805 flags |= AMDGPU_PTE_SYSTEM;
802806
803− if (!ttm || ttm->caching_state == tt_cached)
804− flags |= AMDGPU_PTE_SNOOPED;
807+ if (ttm->caching_state == tt_cached)
808+ flags |= AMDGPU_PTE_SNOOPED;
809+ }
805810
806811 if (adev->asic_type >= CHIP_TOPAZ)
807812 flags |= AMDGPU_PTE_EXECUTABLE;
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c+10−1
@@ -392,7 +392,10 @@ int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle, · 391 unmodified lines
392392 ib->ptr[ib->length_dw++] = 0x00000001; /* session cmd */
393393 ib->ptr[ib->length_dw++] = handle;
394394
395− ib->ptr[ib->length_dw++] = 0x00000030; /* len */
395+ if ((ring->adev->vce.fw_version >> 24) >= 52)
396+ ib->ptr[ib->length_dw++] = 0x00000040; /* len */
397+ else
398+ ib->ptr[ib->length_dw++] = 0x00000030; /* len */
396399 ib->ptr[ib->length_dw++] = 0x01000001; /* create cmd */
397400 ib->ptr[ib->length_dw++] = 0x00000000;
398401 ib->ptr[ib->length_dw++] = 0x00000042;
@@ -404,6 +407,12 @@ int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle, · 5 unmodified lines
404407 ib->ptr[ib->length_dw++] = 0x00000100;
405408 ib->ptr[ib->length_dw++] = 0x0000000c;
406409 ib->ptr[ib->length_dw++] = 0x00000000;
410+ if ((ring->adev->vce.fw_version >> 24) >= 52) {
411+ ib->ptr[ib->length_dw++] = 0x00000000;
412+ ib->ptr[ib->length_dw++] = 0x00000000;
413+ ib->ptr[ib->length_dw++] = 0x00000000;
414+ ib->ptr[ib->length_dw++] = 0x00000000;
415+ }
407416
408417 ib->ptr[ib->length_dw++] = 0x00000014; /* len */
409418 ib->ptr[ib->length_dw++] = 0x05000005; /* feedback buffer */
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c+29−11
@@ -885,17 +885,21 @@ int amdgpu_vm_clear_freed(struct amdgpu_device *adev, · 884 unmodified lines
885885 struct amdgpu_bo_va_mapping *mapping;
886886 int r;
887887
888+ spin_lock(&vm->freed_lock);
888889 while (!list_empty(&vm->freed)) {
889890 mapping = list_first_entry(&vm->freed,
890891 struct amdgpu_bo_va_mapping, list);
891892 list_del(&mapping->list);
892−
893+ spin_unlock(&vm->freed_lock);
893894 r = amdgpu_vm_bo_update_mapping(adev, vm, mapping, 0, 0, NULL);
894895 kfree(mapping);
895896 if (r)
896897 return r;
897898
899+ spin_lock(&vm->freed_lock);
898900 }
901+ spin_unlock(&vm->freed_lock);
902+
899903 return 0;
900904
901905 }
@@ -922,8 +926,9 @@ int amdgpu_vm_clear_invalids(struct amdgpu_device *adev, · 20 unmodified lines
922926 bo_va = list_first_entry(&vm->invalidated,
923927 struct amdgpu_bo_va, vm_status);
924928 spin_unlock(&vm->status_lock);
925−
929+ mutex_lock(&bo_va->mutex);
926930 r = amdgpu_vm_bo_update(adev, bo_va, NULL);
931+ mutex_unlock(&bo_va->mutex);
927932 if (r)
928933 return r;
929934
@@ -967,7 +972,7 @@ struct amdgpu_bo_va *amdgpu_vm_bo_add(struct amdgpu_device *adev, · 37 unmodified lines
967972 INIT_LIST_HEAD(&bo_va->valids);
968973 INIT_LIST_HEAD(&bo_va->invalids);
969974 INIT_LIST_HEAD(&bo_va->vm_status);
970−
975+ mutex_init(&bo_va->mutex);
971976 list_add_tail(&bo_va->bo_list, &bo->va);
972977
973978 return bo_va;
@@ -1045,7 +1050,9 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev, · 71 unmodified lines
10451050 mapping->offset = offset;
10461051 mapping->flags = flags;
10471052
1053+ mutex_lock(&bo_va->mutex);
10481054 list_add(&mapping->list, &bo_va->invalids);
1055+ mutex_unlock(&bo_va->mutex);
10491056 spin_lock(&vm->it_lock);
10501057 interval_tree_insert(&mapping->it, &vm->va);
10511058 spin_unlock(&vm->it_lock);
@@ -1076,6 +1083,11 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev, · 24 unmodified lines
10761083 if (r)
10771084 goto error_free;
10781085
1086+ /* Keep a reference to the page table to avoid freeing
1087+ * them up in the wrong order.
1088+ */
1089+ pt->parent = amdgpu_bo_ref(vm->page_directory);
1090+
10791091 r = amdgpu_vm_clear_bo(adev, pt);
10801092 if (r) {
10811093 amdgpu_bo_unref(&pt);
@@ -1121,7 +1133,7 @@ int amdgpu_vm_bo_unmap(struct amdgpu_device *adev, · 39 unmodified lines
11211133 bool valid = true;
11221134
11231135 saddr /= AMDGPU_GPU_PAGE_SIZE;
1124−
1136+ mutex_lock(&bo_va->mutex);
11251137 list_for_each_entry(mapping, &bo_va->valids, list) {
11261138 if (mapping->it.start == saddr)
11271139 break;
@@ -1135,20 +1147,25 @@ int amdgpu_vm_bo_unmap(struct amdgpu_device *adev, · 7 unmodified lines
11351147 break;
11361148 }
11371149
1138− if (&mapping->list == &bo_va->invalids)
1150+ if (&mapping->list == &bo_va->invalids) {
1151+ mutex_unlock(&bo_va->mutex);
11391152 return -ENOENT;
1153+ }
11401154 }
1141−
1155+ mutex_unlock(&bo_va->mutex);
11421156 list_del(&mapping->list);
11431157 spin_lock(&vm->it_lock);
11441158 interval_tree_remove(&mapping->it, &vm->va);
11451159 spin_unlock(&vm->it_lock);
11461160 trace_amdgpu_vm_bo_unmap(bo_va, mapping);
11471161
1148− if (valid)
1162+ if (valid) {
1163+ spin_lock(&vm->freed_lock);
11491164 list_add(&mapping->list, &vm->freed);
1150− else
1165+ spin_unlock(&vm->freed_lock);
1166+ } else {
11511167 kfree(mapping);
1168+ }
11521169
11531170 return 0;
11541171 }
@@ -1181,7 +1198,9 @@ void amdgpu_vm_bo_rmv(struct amdgpu_device *adev, · 26 unmodified lines
11811198 interval_tree_remove(&mapping->it, &vm->va);
11821199 spin_unlock(&vm->it_lock);
11831200 trace_amdgpu_vm_bo_unmap(bo_va, mapping);
1201+ spin_lock(&vm->freed_lock);
11841202 list_add(&mapping->list, &vm->freed);
1203+ spin_unlock(&vm->freed_lock);
11851204 }
11861205 list_for_each_entry_safe(mapping, next, &bo_va->invalids, list) {
11871206 list_del(&mapping->list);
@@ -1190,8 +1209,8 @@ void amdgpu_vm_bo_rmv(struct amdgpu_device *adev, · 2 unmodified lines
11901209 spin_unlock(&vm->it_lock);
11911210 kfree(mapping);
11921211 }
1193−
11941212 fence_put(bo_va->last_pt_update);
1213+ mutex_destroy(&bo_va->mutex);
11951214 kfree(bo_va);
11961215 }
11971216
@@ -1236,13 +1255,13 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm) · 38 unmodified lines
12361255 vm->ids[i].id = 0;
12371256 vm->ids[i].flushed_updates = NULL;
12381257 }
1239− mutex_init(&vm->mutex);
12401258 vm->va = RB_ROOT;
12411259 spin_lock_init(&vm->status_lock);
12421260 INIT_LIST_HEAD(&vm->invalidated);
12431261 INIT_LIST_HEAD(&vm->cleared);
12441262 INIT_LIST_HEAD(&vm->freed);
12451263 spin_lock_init(&vm->it_lock);
1264+ spin_lock_init(&vm->freed_lock);
12461265 pd_size = amdgpu_vm_directory_size(adev);
12471266 pd_entries = amdgpu_vm_num_pdes(adev);
12481267
@@ -1320,7 +1339,6 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm) · 71 unmodified lines
13201339 fence_put(vm->ids[i].flushed_updates);
13211340 }
13221341
1323− mutex_destroy(&vm->mutex);
13241342 }
13251343
13261344 /**
drivers/gpu/drm/amd/amdgpu/dce_v10_0.c+4−1
@@ -1250,7 +1250,7 @@ static void dce_v10_0_program_watermarks(struct amdgpu_device *adev, · 1249 unmodified lines
12501250 u32 pixel_period;
12511251 u32 line_time = 0;
12521252 u32 latency_watermark_a = 0, latency_watermark_b = 0;
1253− u32 tmp, wm_mask;
1253+ u32 tmp, wm_mask, lb_vblank_lead_lines = 0;
12541254
12551255 if (amdgpu_crtc->base.enabled && num_heads && mode) {
12561256 pixel_period = 1000000 / (u32)mode->clock;
@@ -1333,6 +1333,7 @@ static void dce_v10_0_program_watermarks(struct amdgpu_device *adev, · 76 unmodified lines
13331333 (adev->mode_info.disp_priority == 2)) {
13341334 DRM_DEBUG_KMS("force priority to high\n");
13351335 }
1336+ lb_vblank_lead_lines = DIV_ROUND_UP(lb_size, mode->crtc_hdisplay);
13361337 }
13371338
13381339 /* select wm A */
@@ -1357,6 +1358,8 @@ static void dce_v10_0_program_watermarks(struct amdgpu_device *adev, · 18 unmodified lines
13571358 amdgpu_crtc->line_time = line_time;
13581359 amdgpu_crtc->wm_high = latency_watermark_a;
13591360 amdgpu_crtc->wm_low = latency_watermark_b;
1361+ /* Save number of lines the linebuffer leads before the scanout */
1362+ amdgpu_crtc->lb_vblank_lead_lines = lb_vblank_lead_lines;
13601363 }
13611364
13621365 /**
drivers/gpu/drm/amd/amdgpu/dce_v11_0.c+4−1
@@ -1238,7 +1238,7 @@ static void dce_v11_0_program_watermarks(struct amdgpu_device *adev, · 1237 unmodified lines
12381238 u32 pixel_period;
12391239 u32 line_time = 0;
12401240 u32 latency_watermark_a = 0, latency_watermark_b = 0;
1241− u32 tmp, wm_mask;
1241+ u32 tmp, wm_mask, lb_vblank_lead_lines = 0;
12421242
12431243 if (amdgpu_crtc->base.enabled && num_heads && mode) {
12441244 pixel_period = 1000000 / (u32)mode->clock;
@@ -1321,6 +1321,7 @@ static void dce_v11_0_program_watermarks(struct amdgpu_device *adev, · 76 unmodified lines
13211321 (adev->mode_info.disp_priority == 2)) {
13221322 DRM_DEBUG_KMS("force priority to high\n");
13231323 }
1324+ lb_vblank_lead_lines = DIV_ROUND_UP(lb_size, mode->crtc_hdisplay);
13241325 }
13251326
13261327 /* select wm A */
@@ -1345,6 +1346,8 @@ static void dce_v11_0_program_watermarks(struct amdgpu_device *adev, · 18 unmodified lines
13451346 amdgpu_crtc->line_time = line_time;
13461347 amdgpu_crtc->wm_high = latency_watermark_a;
13471348 amdgpu_crtc->wm_low = latency_watermark_b;
1349+ /* Save number of lines the linebuffer leads before the scanout */
1350+ amdgpu_crtc->lb_vblank_lead_lines = lb_vblank_lead_lines;
13481351 }
13491352
13501353 /**
drivers/gpu/drm/amd/amdgpu/dce_v8_0.c+4−1
@@ -1193,7 +1193,7 @@ static void dce_v8_0_program_watermarks(struct amdgpu_device *adev, · 1192 unmodified lines
11931193 u32 pixel_period;
11941194 u32 line_time = 0;
11951195 u32 latency_watermark_a = 0, latency_watermark_b = 0;
1196− u32 tmp, wm_mask;
1196+ u32 tmp, wm_mask, lb_vblank_lead_lines = 0;
11971197
11981198 if (amdgpu_crtc->base.enabled && num_heads && mode) {
11991199 pixel_period = 1000000 / (u32)mode->clock;
@@ -1276,6 +1276,7 @@ static void dce_v8_0_program_watermarks(struct amdgpu_device *adev, · 76 unmodified lines
12761276 (adev->mode_info.disp_priority == 2)) {
12771277 DRM_DEBUG_KMS("force priority to high\n");
12781278 }
1279+ lb_vblank_lead_lines = DIV_ROUND_UP(lb_size, mode->crtc_hdisplay);
12791280 }
12801281
12811282 /* select wm A */
@@ -1302,6 +1303,8 @@ static void dce_v8_0_program_watermarks(struct amdgpu_device *adev, · 20 unmodified lines
13021303 amdgpu_crtc->line_time = line_time;
13031304 amdgpu_crtc->wm_high = latency_watermark_a;
13041305 amdgpu_crtc->wm_low = latency_watermark_b;
1306+ /* Save number of lines the linebuffer leads before the scanout */
1307+ amdgpu_crtc->lb_vblank_lead_lines = lb_vblank_lead_lines;
13051308 }
13061309
13071310 /**
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c+1−1
@@ -513,7 +513,7 @@ static int gmc_v7_0_gart_enable(struct amdgpu_device *adev) · 512 unmodified lines
513513 WREG32(mmVM_L2_CNTL3, tmp);
514514 /* setup context0 */
515515 WREG32(mmVM_CONTEXT0_PAGE_TABLE_START_ADDR, adev->mc.gtt_start >> 12);
516− WREG32(mmVM_CONTEXT0_PAGE_TABLE_END_ADDR, (adev->mc.gtt_end >> 12) - 1);
516+ WREG32(mmVM_CONTEXT0_PAGE_TABLE_END_ADDR, adev->mc.gtt_end >> 12);
517517 WREG32(mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR, adev->gart.table_addr >> 12);
518518 WREG32(mmVM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR,
519519 (u32)(adev->dummy_page.addr >> 12));
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c+1−1
@@ -657,7 +657,7 @@ static int gmc_v8_0_gart_enable(struct amdgpu_device *adev) · 656 unmodified lines
657657 WREG32(mmVM_L2_CNTL4, tmp);
658658 /* setup context0 */
659659 WREG32(mmVM_CONTEXT0_PAGE_TABLE_START_ADDR, adev->mc.gtt_start >> 12);
660− WREG32(mmVM_CONTEXT0_PAGE_TABLE_END_ADDR, (adev->mc.gtt_end >> 12) - 1);
660+ WREG32(mmVM_CONTEXT0_PAGE_TABLE_END_ADDR, adev->mc.gtt_end >> 12);
661661 WREG32(mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR, adev->gart.table_addr >> 12);
662662 WREG32(mmVM_CONTEXT0_PROTECTION_FAULT_DEFAULT_ADDR,
663663 (u32)(adev->dummy_page.addr >> 12));
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c+19−5
@@ -40,6 +40,9 @@ · 39 unmodified lines
4040
4141 #define GRBM_GFX_INDEX__VCE_INSTANCE__SHIFT 0x04
4242 #define GRBM_GFX_INDEX__VCE_INSTANCE_MASK 0x10
43+#define mmVCE_LMI_VCPU_CACHE_40BIT_BAR0 0x8616
44+#define mmVCE_LMI_VCPU_CACHE_40BIT_BAR1 0x8617
45+#define mmVCE_LMI_VCPU_CACHE_40BIT_BAR2 0x8618
4346
4447 #define VCE_V3_0_FW_SIZE (384 * 1024)
4548 #define VCE_V3_0_STACK_SIZE (64 * 1024)
@@ -130,9 +133,11 @@ static int vce_v3_0_start(struct amdgpu_device *adev) · 84 unmodified lines
130133
131134 /* set BUSY flag */
132135 WREG32_P(mmVCE_STATUS, 1, ~1);
133−
134− WREG32_P(mmVCE_VCPU_CNTL, VCE_VCPU_CNTL__CLK_EN_MASK,
135− ~VCE_VCPU_CNTL__CLK_EN_MASK);
136+ if (adev->asic_type >= CHIP_STONEY)
137+ WREG32_P(mmVCE_VCPU_CNTL, 1, ~0x200001);
138+ else
139+ WREG32_P(mmVCE_VCPU_CNTL, VCE_VCPU_CNTL__CLK_EN_MASK,
140+ ~VCE_VCPU_CNTL__CLK_EN_MASK);
136141
137142 WREG32_P(mmVCE_SOFT_RESET,
138143 VCE_SOFT_RESET__ECPU_SOFT_RESET_MASK,
@@ -391,8 +396,12 @@ static void vce_v3_0_mc_resume(struct amdgpu_device *adev, int idx) · 252 unmodified lines
391396 WREG32(mmVCE_LMI_SWAP_CNTL, 0);
392397 WREG32(mmVCE_LMI_SWAP_CNTL1, 0);
393398 WREG32(mmVCE_LMI_VM_CTRL, 0);
394−
395− WREG32(mmVCE_LMI_VCPU_CACHE_40BIT_BAR, (adev->vce.gpu_addr >> 8));
399+ if (adev->asic_type >= CHIP_STONEY) {
400+ WREG32(mmVCE_LMI_VCPU_CACHE_40BIT_BAR0, (adev->vce.gpu_addr >> 8));
401+ WREG32(mmVCE_LMI_VCPU_CACHE_40BIT_BAR1, (adev->vce.gpu_addr >> 8));
402+ WREG32(mmVCE_LMI_VCPU_CACHE_40BIT_BAR2, (adev->vce.gpu_addr >> 8));
403+ } else
404+ WREG32(mmVCE_LMI_VCPU_CACHE_40BIT_BAR, (adev->vce.gpu_addr >> 8));
396405 offset = AMDGPU_VCE_FIRMWARE_OFFSET;
397406 size = VCE_V3_0_FW_SIZE;
398407 WREG32(mmVCE_VCPU_CACHE_OFFSET0, offset & 0x7fffffff);
@@ -576,6 +585,11 @@ static int vce_v3_0_process_interrupt(struct amdgpu_device *adev, · 177 unmodified lines
576585 struct amdgpu_iv_entry *entry)
577586 {
578587 DRM_DEBUG("IH: VCE\n");
588+
589+ WREG32_P(mmVCE_SYS_INT_STATUS,
590+ VCE_SYS_INT_STATUS__VCE_SYS_INT_TRAP_INTERRUPT_INT_MASK,
591+ ~VCE_SYS_INT_STATUS__VCE_SYS_INT_TRAP_INTERRUPT_INT_MASK);
592+
579593 switch (entry->src_data) {
580594 case 0:
581595 amdgpu_fence_process(&adev->vce.ring[0]);
drivers/gpu/drm/amd/scheduler/gpu_scheduler.c+85−42
@@ -30,8 +30,7 @@ · 29 unmodified lines
3030 #define CREATE_TRACE_POINTS
3131 #include "gpu_sched_trace.h"
3232
33−static struct amd_sched_job *
34−amd_sched_entity_pop_job(struct amd_sched_entity *entity);
33+static bool amd_sched_entity_is_ready(struct amd_sched_entity *entity);
3534 static void amd_sched_wakeup(struct amd_gpu_scheduler *sched);
3635
3736 struct kmem_cache *sched_fence_slab;
@@ -64,36 +63,36 @@ static void amd_sched_rq_remove_entity(struct amd_sched_rq *rq, · 26 unmodified lines
6463 }
6564
6665 /**
67− * Select next job from a specified run queue with round robin policy.
68− * Return NULL if nothing available.
66+ * Select an entity which could provide a job to run
67+ *
68+ * @rq The run queue to check.
69+ *
70+ * Try to find a ready entity, returns NULL if none found.
6971 */
70−static struct amd_sched_job *
71−amd_sched_rq_select_job(struct amd_sched_rq *rq)
72+static struct amd_sched_entity *
73+amd_sched_rq_select_entity(struct amd_sched_rq *rq)
7274 {
7375 struct amd_sched_entity *entity;
74− struct amd_sched_job *sched_job;
7576
7677 spin_lock(&rq->lock);
7778
7879 entity = rq->current_entity;
7980 if (entity) {
8081 list_for_each_entry_continue(entity, &rq->entities, list) {
81− sched_job = amd_sched_entity_pop_job(entity);
82− if (sched_job) {
82+ if (amd_sched_entity_is_ready(entity)) {
8383 rq->current_entity = entity;
8484 spin_unlock(&rq->lock);
85− return sched_job;
85+ return entity;
8686 }
8787 }
8888 }
8989
9090 list_for_each_entry(entity, &rq->entities, list) {
9191
92− sched_job = amd_sched_entity_pop_job(entity);
93− if (sched_job) {
92+ if (amd_sched_entity_is_ready(entity)) {
9493 rq->current_entity = entity;
9594 spin_unlock(&rq->lock);
96− return sched_job;
95+ return entity;
9796 }
9897
9998 if (entity == rq->current_entity)
@@ -176,6 +175,24 @@ static bool amd_sched_entity_is_idle(struct amd_sched_entity *entity) · 76 unmodified lines
176175 return false;
177176 }
178177
178+/**
179+ * Check if entity is ready
180+ *
181+ * @entity The pointer to a valid scheduler entity
182+ *
183+ * Return true if entity could provide a job.
184+ */
185+static bool amd_sched_entity_is_ready(struct amd_sched_entity *entity)
186+{
187+ if (kfifo_is_empty(&entity->job_queue))
188+ return false;
189+
190+ if (ACCESS_ONCE(entity->dependency))
191+ return false;
192+
193+ return true;
194+}
195+
179196 /**
180197 * Destroy a context entity
181198 *
@@ -211,32 +228,53 @@ static void amd_sched_entity_wakeup(struct fence *f, struct fence_cb *cb) · 29 unmodified lines
211228 amd_sched_wakeup(entity->sched);
212229 }
213230
231+static bool amd_sched_entity_add_dependency_cb(struct amd_sched_entity *entity)
232+{
233+ struct amd_gpu_scheduler *sched = entity->sched;
234+ struct fence * fence = entity->dependency;
235+ struct amd_sched_fence *s_fence;
236+
237+ if (fence->context == entity->fence_context) {
238+ /* We can ignore fences from ourself */
239+ fence_put(entity->dependency);
240+ return false;
241+ }
242+
243+ s_fence = to_amd_sched_fence(fence);
244+ if (s_fence && s_fence->sched == sched) {
245+ /* Fence is from the same scheduler */
246+ if (test_bit(AMD_SCHED_FENCE_SCHEDULED_BIT, &fence->flags)) {
247+ /* Ignore it when it is already scheduled */
248+ fence_put(entity->dependency);
249+ return false;
250+ }
251+
252+ /* Wait for fence to be scheduled */
253+ entity->cb.func = amd_sched_entity_wakeup;
254+ list_add_tail(&entity->cb.node, &s_fence->scheduled_cb);
255+ return true;
256+ }
257+
258+ if (!fence_add_callback(entity->dependency, &entity->cb,
259+ amd_sched_entity_wakeup))
260+ return true;
261+
262+ fence_put(entity->dependency);
263+ return false;
264+}
265+
214266 static struct amd_sched_job *
215267 amd_sched_entity_pop_job(struct amd_sched_entity *entity)
216268 {
217269 struct amd_gpu_scheduler *sched = entity->sched;
218270 struct amd_sched_job *sched_job;
219271
220− if (ACCESS_ONCE(entity->dependency))
221− return NULL;
222−
223272 if (!kfifo_out_peek(&entity->job_queue, &sched_job, sizeof(sched_job)))
224273 return NULL;
225274
226− while ((entity->dependency = sched->ops->dependency(sched_job))) {
227−
228− if (entity->dependency->context == entity->fence_context) {
229− /* We can ignore fences from ourself */
230− fence_put(entity->dependency);
231− continue;
232− }
233−
234− if (fence_add_callback(entity->dependency, &entity->cb,
235− amd_sched_entity_wakeup))
236− fence_put(entity->dependency);
237− else
275+ while ((entity->dependency = sched->ops->dependency(sched_job)))
276+ if (amd_sched_entity_add_dependency_cb(entity))
238277 return NULL;
239− }
240278
241279 return sched_job;
242280 }
@@ -250,6 +288,7 @@ amd_sched_entity_pop_job(struct amd_sched_entity *entity) · 7 unmodified lines
250288 */
251289 static bool amd_sched_entity_in(struct amd_sched_job *sched_job)
252290 {
291+ struct amd_gpu_scheduler *sched = sched_job->sched;
253292 struct amd_sched_entity *entity = sched_job->s_entity;
254293 bool added, first = false;
255294
@@ -264,7 +303,7 @@ static bool amd_sched_entity_in(struct amd_sched_job *sched_job) · 8 unmodified lines
264303
265304 /* first job wakes up scheduler */
266305 if (first)
267− amd_sched_wakeup(sched_job->sched);
306+ amd_sched_wakeup(sched);
268307
269308 return added;
270309 }
@@ -280,9 +319,9 @@ void amd_sched_entity_push_job(struct amd_sched_job *sched_job) · 9 unmodified lines
280319 {
281320 struct amd_sched_entity *entity = sched_job->s_entity;
282321
322+ trace_amd_sched_job(sched_job);
283323 wait_event(entity->sched->job_scheduled,
284324 amd_sched_entity_in(sched_job));
285− trace_amd_sched_job(sched_job);
286325 }
287326
288327 /**
@@ -304,22 +343,22 @@ static void amd_sched_wakeup(struct amd_gpu_scheduler *sched) · 15 unmodified lines
304343 }
305344
306345 /**
307− * Select next to run
346+ * Select next entity to process
308347 */
309−static struct amd_sched_job *
310−amd_sched_select_job(struct amd_gpu_scheduler *sched)
348+static struct amd_sched_entity *
349+amd_sched_select_entity(struct amd_gpu_scheduler *sched)
311350 {
312− struct amd_sched_job *sched_job;
351+ struct amd_sched_entity *entity;
313352
314353 if (!amd_sched_ready(sched))
315354 return NULL;
316355
317356 /* Kernel run queue has higher priority than normal run queue*/
318− sched_job = amd_sched_rq_select_job(&sched->kernel_rq);
319− if (sched_job == NULL)
320− sched_job = amd_sched_rq_select_job(&sched->sched_rq);
357+ entity = amd_sched_rq_select_entity(&sched->kernel_rq);
358+ if (entity == NULL)
359+ entity = amd_sched_rq_select_entity(&sched->sched_rq);
321360
322− return sched_job;
361+ return entity;
323362 }
324363
325364 static void amd_sched_process_job(struct fence *f, struct fence_cb *cb)
@@ -381,13 +420,16 @@ static int amd_sched_main(void *param) · 55 unmodified lines
381420 unsigned long flags;
382421
383422 wait_event_interruptible(sched->wake_up_worker,
384− kthread_should_stop() ||
385− (sched_job = amd_sched_select_job(sched)));
423+ (entity = amd_sched_select_entity(sched)) ||
424+ kthread_should_stop());
386425
426+ if (!entity)
427+ continue;
428+
429+ sched_job = amd_sched_entity_pop_job(entity);
387430 if (!sched_job)
388431 continue;
389432
390− entity = sched_job->s_entity;
391433 s_fence = sched_job->s_fence;
392434
393435 if (sched->timeout != MAX_SCHEDULE_TIMEOUT) {
@@ -400,6 +442,7 @@ static int amd_sched_main(void *param) · 6 unmodified lines
400442
401443 atomic_inc(&sched->hw_rq_count);
402444 fence = sched->ops->run_job(sched_job);
445+ amd_sched_fence_scheduled(s_fence);
403446 if (fence) {
404447 r = fence_add_callback(fence, &s_fence->cb,
405448 amd_sched_process_job);
drivers/gpu/drm/amd/scheduler/gpu_scheduler.h+4−1
@@ -27,6 +27,8 @@ · 26 unmodified lines
2727 #include <linux/kfifo.h>
2828 #include <linux/fence.h>
2929
30+#define AMD_SCHED_FENCE_SCHEDULED_BIT FENCE_FLAG_USER_BITS
31+
3032 struct amd_gpu_scheduler;
3133 struct amd_sched_rq;
3234
@@ -68,6 +70,7 @@ struct amd_sched_rq { · 35 unmodified lines
6870 struct amd_sched_fence {
6971 struct fence base;
7072 struct fence_cb cb;
73+ struct list_head scheduled_cb;
7174 struct amd_gpu_scheduler *sched;
7275 spinlock_t lock;
7376 void *owner;
@@ -134,7 +137,7 @@ void amd_sched_entity_push_job(struct amd_sched_job *sched_job); · 60 unmodified lines
134137
135138 struct amd_sched_fence *amd_sched_fence_create(
136139 struct amd_sched_entity *s_entity, void *owner);
140+void amd_sched_fence_scheduled(struct amd_sched_fence *fence);
137141 void amd_sched_fence_signal(struct amd_sched_fence *fence);
138142
139−
140143 #endif
drivers/gpu/drm/amd/scheduler/sched_fence.c+13−0
@@ -35,6 +35,8 @@ struct amd_sched_fence *amd_sched_fence_create(struct amd_sched_entity *s_entity · 34 unmodified lines
3535 fence = kmem_cache_zalloc(sched_fence_slab, GFP_KERNEL);
3636 if (fence == NULL)
3737 return NULL;
38+
39+ INIT_LIST_HEAD(&fence->scheduled_cb);
3840 fence->owner = owner;
3941 fence->sched = s_entity->sched;
4042 spin_lock_init(&fence->lock);
@@ -55,6 +57,17 @@ void amd_sched_fence_signal(struct amd_sched_fence *fence) · 14 unmodified lines
5557 FENCE_TRACE(&fence->base, "was already signaled\n");
5658 }
5759
60+void amd_sched_fence_scheduled(struct amd_sched_fence *s_fence)
61+{
62+ struct fence_cb *cur, *tmp;
63+
64+ set_bit(AMD_SCHED_FENCE_SCHEDULED_BIT, &s_fence->base.flags);
65+ list_for_each_entry_safe(cur, tmp, &s_fence->scheduled_cb, node) {
66+ list_del_init(&cur->node);
67+ cur->func(&s_fence->base, cur);
68+ }
69+}
70+
5871 static const char *amd_sched_fence_get_driver_name(struct fence *fence)
5972 {
6073 return "amd_sched";
drivers/gpu/drm/drm_drv.c+5−0
@@ -160,6 +160,11 @@ int drm_setmaster_ioctl(struct drm_device *dev, void *data, · 159 unmodified lines
160160 goto out_unlock;
161161 }
162162
163+ if (!file_priv->allowed_master) {
164+ ret = drm_new_set_master(dev, file_priv);
165+ goto out_unlock;
166+ }
167+
163168 file_priv->minor->master = drm_master_get(file_priv->master);
164169 file_priv->is_master = 1;
165170 if (dev->driver->master_set) {
drivers/gpu/drm/drm_fops.c+56−28
@@ -125,6 +125,60 @@ static int drm_cpu_valid(void) · 124 unmodified lines
125125 return 1;
126126 }
127127
128+/**
129+ * drm_new_set_master - Allocate a new master object and become master for the
130+ * associated master realm.
131+ *
132+ * @dev: The associated device.
133+ * @fpriv: File private identifying the client.
134+ *
135+ * This function must be called with dev::struct_mutex held.
136+ * Returns negative error code on failure. Zero on success.
137+ */
138+int drm_new_set_master(struct drm_device *dev, struct drm_file *fpriv)
139+{
140+ struct drm_master *old_master;
141+ int ret;
142+
143+ lockdep_assert_held_once(&dev->master_mutex);
144+
145+ /* create a new master */
146+ fpriv->minor->master = drm_master_create(fpriv->minor);
147+ if (!fpriv->minor->master)
148+ return -ENOMEM;
149+
150+ /* take another reference for the copy in the local file priv */
151+ old_master = fpriv->master;
152+ fpriv->master = drm_master_get(fpriv->minor->master);
153+
154+ if (dev->driver->master_create) {
155+ ret = dev->driver->master_create(dev, fpriv->master);
156+ if (ret)
157+ goto out_err;
158+ }
159+ if (dev->driver->master_set) {
160+ ret = dev->driver->master_set(dev, fpriv, true);
161+ if (ret)
162+ goto out_err;
163+ }
164+
165+ fpriv->is_master = 1;
166+ fpriv->allowed_master = 1;
167+ fpriv->authenticated = 1;
168+ if (old_master)
169+ drm_master_put(&old_master);
170+
171+ return 0;
172+
173+out_err:
174+ /* drop both references and restore old master on failure */
175+ drm_master_put(&fpriv->minor->master);
176+ drm_master_put(&fpriv->master);
177+ fpriv->master = old_master;
178+
179+ return ret;
180+}
181+
128182 /**
129183 * Called whenever a process opens /dev/drm.
130184 *
@@ -189,35 +243,9 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor) · 58 unmodified lines
189243 mutex_lock(&dev->master_mutex);
190244 if (drm_is_primary_client(priv) && !priv->minor->master) {
191245 /* create a new master */
192− priv->minor->master = drm_master_create(priv->minor);
193− if (!priv->minor->master) {
194− ret = -ENOMEM;
246+ ret = drm_new_set_master(dev, priv);
247+ if (ret)
195248 goto out_close;
196− }
197−
198− priv->is_master = 1;
199− /* take another reference for the copy in the local file priv */
200− priv->master = drm_master_get(priv->minor->master);
201− priv->authenticated = 1;
202−
203− if (dev->driver->master_create) {
204− ret = dev->driver->master_create(dev, priv->master);
205− if (ret) {
206− /* drop both references if this fails */
207− drm_master_put(&priv->minor->master);
208− drm_master_put(&priv->master);
209− goto out_close;
210− }
211− }
212− if (dev->driver->master_set) {
213− ret = dev->driver->master_set(dev, priv, true);
214− if (ret) {
215− /* drop both references if this fails */
216− drm_master_put(&priv->minor->master);
217− drm_master_put(&priv->master);
218− goto out_close;
219− }
220− }
221249 } else if (drm_is_primary_client(priv)) {
222250 /* get a reference to the master */
223251 priv->master = drm_master_get(priv->minor->master);
drivers/gpu/drm/drm_irq.c+53−1
@@ -980,7 +980,8 @@ static void send_vblank_event(struct drm_device *dev, · 979 unmodified lines
980980 struct drm_pending_vblank_event *e,
981981 unsigned long seq, struct timeval *now)
982982 {
983− WARN_ON_SMP(!spin_is_locked(&dev->event_lock));
983+ assert_spin_locked(&dev->event_lock);
984+
984985 e->event.sequence = seq;
985986 e->event.tv_sec = now->tv_sec;
986987 e->event.tv_usec = now->tv_usec;
@@ -992,6 +993,57 @@ static void send_vblank_event(struct drm_device *dev, · 5 unmodified lines
992993 e->event.sequence);
993994 }
994995
996+/**
997+ * drm_arm_vblank_event - arm vblank event after pageflip
998+ * @dev: DRM device
999+ * @pipe: CRTC index
1000+ * @e: the event to prepare to send
1001+ *
1002+ * A lot of drivers need to generate vblank events for the very next vblank
1003+ * interrupt. For example when the page flip interrupt happens when the page
1004+ * flip gets armed, but not when it actually executes within the next vblank
1005+ * period. This helper function implements exactly the required vblank arming
1006+ * behaviour.
1007+ *
1008+ * Caller must hold event lock. Caller must also hold a vblank reference for
1009+ * the event @e, which will be dropped when the next vblank arrives.
1010+ *
1011+ * This is the legacy version of drm_crtc_arm_vblank_event().
1012+ */
1013+void drm_arm_vblank_event(struct drm_device *dev, unsigned int pipe,
1014+ struct drm_pending_vblank_event *e)
1015+{
1016+ assert_spin_locked(&dev->event_lock);
1017+
1018+ e->pipe = pipe;
1019+ e->event.sequence = drm_vblank_count(dev, pipe);
1020+ list_add_tail(&e->base.link, &dev->vblank_event_list);
1021+}
1022+EXPORT_SYMBOL(drm_arm_vblank_event);
1023+
1024+/**
1025+ * drm_crtc_arm_vblank_event - arm vblank event after pageflip
1026+ * @crtc: the source CRTC of the vblank event
1027+ * @e: the event to send
1028+ *
1029+ * A lot of drivers need to generate vblank events for the very next vblank
1030+ * interrupt. For example when the page flip interrupt happens when the page
1031+ * flip gets armed, but not when it actually executes within the next vblank
1032+ * period. This helper function implements exactly the required vblank arming
1033+ * behaviour.
1034+ *
1035+ * Caller must hold event lock. Caller must also hold a vblank reference for
1036+ * the event @e, which will be dropped when the next vblank arrives.
1037+ *
1038+ * This is the native KMS version of drm_arm_vblank_event().
1039+ */
1040+void drm_crtc_arm_vblank_event(struct drm_crtc *crtc,
1041+ struct drm_pending_vblank_event *e)
1042+{
1043+ drm_arm_vblank_event(crtc->dev, drm_crtc_index(crtc), e);
1044+}
1045+EXPORT_SYMBOL(drm_crtc_arm_vblank_event);
1046+
9951047 /**
9961048 * drm_send_vblank_event - helper to send vblank event after pageflip
9971049 * @dev: DRM device
drivers/gpu/drm/i915/i915_debugfs.c+2−0
@@ -2734,6 +2734,8 @@ static const char *power_domain_str(enum intel_display_power_domain domain) · 2733 unmodified lines
27342734 return "AUX_C";
27352735 case POWER_DOMAIN_AUX_D:
27362736 return "AUX_D";
2737+ case POWER_DOMAIN_GMBUS:
2738+ return "GMBUS";
27372739 case POWER_DOMAIN_INIT:
27382740 return "INIT";
27392741 default:
drivers/gpu/drm/i915/i915_drv.h+1−0
@@ -199,6 +199,7 @@ enum intel_display_power_domain { · 198 unmodified lines
199199 POWER_DOMAIN_AUX_B,
200200 POWER_DOMAIN_AUX_C,
201201 POWER_DOMAIN_AUX_D,
202+ POWER_DOMAIN_GMBUS,
202203 POWER_DOMAIN_INIT,
203204
204205 POWER_DOMAIN_NUM,
drivers/gpu/drm/i915/i915_gem.c+10−2
@@ -1210,8 +1210,16 @@ int __i915_wait_request(struct drm_i915_gem_request *req, · 1209 unmodified lines
12101210 if (i915_gem_request_completed(req, true))
12111211 return 0;
12121212
1213− timeout_expire = timeout ?
1214− jiffies + nsecs_to_jiffies_timeout((u64)*timeout) : 0;
1213+ timeout_expire = 0;
1214+ if (timeout) {
1215+ if (WARN_ON(*timeout < 0))
1216+ return -EINVAL;
1217+
1218+ if (*timeout == 0)
1219+ return -ETIME;
1220+
1221+ timeout_expire = jiffies + nsecs_to_jiffies_timeout(*timeout);
1222+ }
12151223
12161224 if (INTEL_INFO(dev_priv)->gen >= 6)
12171225 gen6_rps_boost(dev_priv, rps, req->emitted_jiffies);
drivers/gpu/drm/i915/i915_gem_fence.c+27−9
@@ -642,11 +642,10 @@ i915_gem_detect_bit_6_swizzle(struct drm_device *dev) · 641 unmodified lines
642642 }
643643
644644 /* check for L-shaped memory aka modified enhanced addressing */
645− if (IS_GEN4(dev)) {
646− uint32_t ddc2 = I915_READ(DCC2);
647−
648− if (!(ddc2 & DCC2_MODIFIED_ENHANCED_DISABLE))
649− dev_priv->quirks |= QUIRK_PIN_SWIZZLED_PAGES;
645+ if (IS_GEN4(dev) &&
646+ !(I915_READ(DCC2) & DCC2_MODIFIED_ENHANCED_DISABLE)) {
647+ swizzle_x = I915_BIT_6_SWIZZLE_UNKNOWN;
648+ swizzle_y = I915_BIT_6_SWIZZLE_UNKNOWN;
650649 }
651650
652651 if (dcc == 0xffffffff) {
@@ -675,16 +674,35 @@ i915_gem_detect_bit_6_swizzle(struct drm_device *dev) · 22 unmodified lines
675674 * matching, which was the case for the swizzling required in
676675 * the table above, or from the 1-ch value being less than
677676 * the minimum size of a rank.
677+ *
678+ * Reports indicate that the swizzling actually
679+ * varies depending upon page placement inside the
680+ * channels, i.e. we see swizzled pages where the
681+ * banks of memory are paired and unswizzled on the
682+ * uneven portion, so leave that as unknown.
678683 */
679− if (I915_READ16(C0DRB3) != I915_READ16(C1DRB3)) {
680− swizzle_x = I915_BIT_6_SWIZZLE_NONE;
681− swizzle_y = I915_BIT_6_SWIZZLE_NONE;
682− } else {
684+ if (I915_READ16(C0DRB3) == I915_READ16(C1DRB3)) {
683685 swizzle_x = I915_BIT_6_SWIZZLE_9_10;
684686 swizzle_y = I915_BIT_6_SWIZZLE_9;
685687 }
686688 }
687689
690+ if (swizzle_x == I915_BIT_6_SWIZZLE_UNKNOWN ||
691+ swizzle_y == I915_BIT_6_SWIZZLE_UNKNOWN) {
692+ /* Userspace likes to explode if it sees unknown swizzling,
693+ * so lie. We will finish the lie when reporting through
694+ * the get-tiling-ioctl by reporting the physical swizzle
695+ * mode as unknown instead.
696+ *
697+ * As we don't strictly know what the swizzling is, it may be
698+ * bit17 dependent, and so we need to also prevent the pages
699+ * from being moved.
700+ */
701+ dev_priv->quirks |= QUIRK_PIN_SWIZZLED_PAGES;
702+ swizzle_x = I915_BIT_6_SWIZZLE_NONE;
703+ swizzle_y = I915_BIT_6_SWIZZLE_NONE;
704+ }
705+
688706 dev_priv->mm.bit_6_swizzle_x = swizzle_x;
689707 dev_priv->mm.bit_6_swizzle_y = swizzle_y;
690708 }
drivers/gpu/drm/i915/intel_display.c+51−2
@@ -5194,11 +5194,31 @@ static enum intel_display_power_domain port_to_power_domain(enum port port) · 5193 unmodified lines
51945194 case PORT_E:
51955195 return POWER_DOMAIN_PORT_DDI_E_2_LANES;
51965196 default:
5197− WARN_ON_ONCE(1);
5197+ MISSING_CASE(port);
51985198 return POWER_DOMAIN_PORT_OTHER;
51995199 }
52005200 }
52015201
5202+static enum intel_display_power_domain port_to_aux_power_domain(enum port port)
5203+{
5204+ switch (port) {
5205+ case PORT_A:
5206+ return POWER_DOMAIN_AUX_A;
5207+ case PORT_B:
5208+ return POWER_DOMAIN_AUX_B;
5209+ case PORT_C:
5210+ return POWER_DOMAIN_AUX_C;
5211+ case PORT_D:
5212+ return POWER_DOMAIN_AUX_D;
5213+ case PORT_E:
5214+ /* FIXME: Check VBT for actual wiring of PORT E */
5215+ return POWER_DOMAIN_AUX_D;
5216+ default:
5217+ MISSING_CASE(port);
5218+ return POWER_DOMAIN_AUX_A;
5219+ }
5220+}
5221+
52025222 #define for_each_power_domain(domain, mask) \
52035223 for ((domain) = 0; (domain) < POWER_DOMAIN_NUM; (domain)++) \
52045224 if ((1 << (domain)) & (mask))
@@ -5230,6 +5250,36 @@ intel_display_port_power_domain(struct intel_encoder *intel_encoder) · 25 unmodified lines
52305250 }
52315251 }
52325252
5253+enum intel_display_power_domain
5254+intel_display_port_aux_power_domain(struct intel_encoder *intel_encoder)
5255+{
5256+ struct drm_device *dev = intel_encoder->base.dev;
5257+ struct intel_digital_port *intel_dig_port;
5258+
5259+ switch (intel_encoder->type) {
5260+ case INTEL_OUTPUT_UNKNOWN:
5261+ case INTEL_OUTPUT_HDMI:
5262+ /*
5263+ * Only DDI platforms should ever use these output types.
5264+ * We can get here after the HDMI detect code has already set
5265+ * the type of the shared encoder. Since we can't be sure
5266+ * what's the status of the given connectors, play safe and
5267+ * run the DP detection too.
5268+ */
5269+ WARN_ON_ONCE(!HAS_DDI(dev));
5270+ case INTEL_OUTPUT_DISPLAYPORT:
5271+ case INTEL_OUTPUT_EDP:
5272+ intel_dig_port = enc_to_dig_port(&intel_encoder->base);
5273+ return port_to_aux_power_domain(intel_dig_port->port);
5274+ case INTEL_OUTPUT_DP_MST:
5275+ intel_dig_port = enc_to_mst(&intel_encoder->base)->primary;
5276+ return port_to_aux_power_domain(intel_dig_port->port);
5277+ default:
5278+ MISSING_CASE(intel_encoder->type);
5279+ return POWER_DOMAIN_AUX_A;
5280+ }
5281+}
5282+
52335283 static unsigned long get_crtc_power_domains(struct drm_crtc *crtc)
52345284 {
52355285 struct drm_device *dev = crtc->dev;
@@ -12460,7 +12510,6 @@ intel_pipe_config_compare(struct drm_device *dev, · 7224 unmodified lines
1246012510 if (INTEL_INFO(dev)->gen < 8) {
1246112511 PIPE_CONF_CHECK_M_N(dp_m_n);
1246212512
12463− PIPE_CONF_CHECK_I(has_drrs);
1246412513 if (current_config->has_drrs)
1246512514 PIPE_CONF_CHECK_M_N(dp_m2_n2);
1246612515 } else
drivers/gpu/drm/i915/intel_dp.c+16−35
@@ -277,7 +277,7 @@ static void pps_lock(struct intel_dp *intel_dp) · 276 unmodified lines
277277 * See vlv_power_sequencer_reset() why we need
278278 * a power domain reference here.
279279 */
280− power_domain = intel_display_port_power_domain(encoder);
280+ power_domain = intel_display_port_aux_power_domain(encoder);
281281 intel_display_power_get(dev_priv, power_domain);
282282
283283 mutex_lock(&dev_priv->pps_mutex);
@@ -293,7 +293,7 @@ static void pps_unlock(struct intel_dp *intel_dp) · 9 unmodified lines
293293
294294 mutex_unlock(&dev_priv->pps_mutex);
295295
296− power_domain = intel_display_port_power_domain(encoder);
296+ power_domain = intel_display_port_aux_power_domain(encoder);
297297 intel_display_power_put(dev_priv, power_domain);
298298 }
299299
@@ -816,8 +816,6 @@ intel_dp_aux_ch(struct intel_dp *intel_dp, · 516 unmodified lines
816816
817817 intel_dp_check_edp(intel_dp);
818818
819− intel_aux_display_runtime_get(dev_priv);
820−
821819 /* Try to wait for any previous AUX channel activity */
822820 for (try = 0; try < 3; try++) {
823821 status = I915_READ_NOTRACE(ch_ctl);
@@ -926,7 +924,6 @@ done: · 102 unmodified lines
926924 ret = recv_bytes;
927925 out:
928926 pm_qos_update_request(&dev_priv->pm_qos, PM_QOS_DEFAULT_VALUE);
929− intel_aux_display_runtime_put(dev_priv);
930927
931928 if (vdd)
932929 edp_panel_vdd_off(intel_dp, false);
@@ -1784,7 +1781,7 @@ static bool edp_panel_vdd_on(struct intel_dp *intel_dp) · 851 unmodified lines
17841781 if (edp_have_panel_vdd(intel_dp))
17851782 return need_to_disable;
17861783
1787− power_domain = intel_display_port_power_domain(intel_encoder);
1784+ power_domain = intel_display_port_aux_power_domain(intel_encoder);
17881785 intel_display_power_get(dev_priv, power_domain);
17891786
17901787 DRM_DEBUG_KMS("Turning eDP port %c VDD on\n",
@@ -1874,7 +1871,7 @@ static void edp_panel_vdd_off_sync(struct intel_dp *intel_dp) · 83 unmodified lines
18741871 if ((pp & POWER_TARGET_ON) == 0)
18751872 intel_dp->last_power_cycle = jiffies;
18761873
1877− power_domain = intel_display_port_power_domain(intel_encoder);
1874+ power_domain = intel_display_port_aux_power_domain(intel_encoder);
18781875 intel_display_power_put(dev_priv, power_domain);
18791876 }
18801877
@@ -2025,7 +2022,7 @@ static void edp_panel_off(struct intel_dp *intel_dp) · 144 unmodified lines
20252022 wait_panel_off(intel_dp);
20262023
20272024 /* We got a reference when we enabled the VDD. */
2028− power_domain = intel_display_port_power_domain(intel_encoder);
2025+ power_domain = intel_display_port_aux_power_domain(intel_encoder);
20292026 intel_display_power_put(dev_priv, power_domain);
20302027 }
20312028
@@ -4765,26 +4762,6 @@ intel_dp_unset_edid(struct intel_dp *intel_dp) · 2733 unmodified lines
47654762 intel_dp->has_audio = false;
47664763 }
47674764
4768−static enum intel_display_power_domain
4769−intel_dp_power_get(struct intel_dp *dp)
4770−{
4771− struct intel_encoder *encoder = &dp_to_dig_port(dp)->base;
4772− enum intel_display_power_domain power_domain;
4773−
4774− power_domain = intel_display_port_power_domain(encoder);
4775− intel_display_power_get(to_i915(encoder->base.dev), power_domain);
4776−
4777− return power_domain;
4778−}
4779−
4780−static void
4781−intel_dp_power_put(struct intel_dp *dp,
4782− enum intel_display_power_domain power_domain)
4783−{
4784− struct intel_encoder *encoder = &dp_to_dig_port(dp)->base;
4785− intel_display_power_put(to_i915(encoder->base.dev), power_domain);
4786−}
4787−
47884765 static enum drm_connector_status
47894766 intel_dp_detect(struct drm_connector *connector, bool force)
47904767 {
@@ -4808,7 +4785,8 @@ intel_dp_detect(struct drm_connector *connector, bool force) · 17 unmodified lines
48084785 return connector_status_disconnected;
48094786 }
48104787
4811− power_domain = intel_dp_power_get(intel_dp);
4788+ power_domain = intel_display_port_aux_power_domain(intel_encoder);
4789+ intel_display_power_get(to_i915(dev), power_domain);
48124790
48134791 /* Can't disconnect eDP, but you can close the lid... */
48144792 if (is_edp(intel_dp))
@@ -4853,7 +4831,7 @@ intel_dp_detect(struct drm_connector *connector, bool force) · 38 unmodified lines
48534831 }
48544832
48554833 out:
4856− intel_dp_power_put(intel_dp, power_domain);
4834+ intel_display_power_put(to_i915(dev), power_domain);
48574835 return status;
48584836 }
48594837
@@ -4862,6 +4840,7 @@ intel_dp_force(struct drm_connector *connector) · 2 unmodified lines
48624840 {
48634841 struct intel_dp *intel_dp = intel_attached_dp(connector);
48644842 struct intel_encoder *intel_encoder = &dp_to_dig_port(intel_dp)->base;
4843+ struct drm_i915_private *dev_priv = to_i915(intel_encoder->base.dev);
48654844 enum intel_display_power_domain power_domain;
48664845
48674846 DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
@@ -4871,11 +4850,12 @@ intel_dp_force(struct drm_connector *connector) · 3 unmodified lines
48714850 if (connector->status != connector_status_connected)
48724851 return;
48734852
4874− power_domain = intel_dp_power_get(intel_dp);
4853+ power_domain = intel_display_port_aux_power_domain(intel_encoder);
4854+ intel_display_power_get(dev_priv, power_domain);
48754855
48764856 intel_dp_set_edid(intel_dp);
48774857
4878− intel_dp_power_put(intel_dp, power_domain);
4858+ intel_display_power_put(dev_priv, power_domain);
48794859
48804860 if (intel_encoder->type != INTEL_OUTPUT_EDP)
48814861 intel_encoder->type = INTEL_OUTPUT_DISPLAYPORT;
@@ -5091,7 +5071,7 @@ static void intel_edp_panel_vdd_sanitize(struct intel_dp *intel_dp) · 209 unmodified lines
50915071 * indefinitely.
50925072 */
50935073 DRM_DEBUG_KMS("VDD left on by BIOS, adjusting state tracking\n");
5094− power_domain = intel_display_port_power_domain(&intel_dig_port->base);
5074+ power_domain = intel_display_port_aux_power_domain(&intel_dig_port->base);
50955075 intel_display_power_get(dev_priv, power_domain);
50965076
50975077 edp_panel_vdd_schedule_off(intel_dp);
@@ -5153,7 +5133,8 @@ intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port, bool long_hpd) · 55 unmodified lines
51535133 enum intel_display_power_domain power_domain;
51545134 enum irqreturn ret = IRQ_NONE;
51555135
5156− if (intel_dig_port->base.type != INTEL_OUTPUT_EDP)
5136+ if (intel_dig_port->base.type != INTEL_OUTPUT_EDP &&
5137+ intel_dig_port->base.type != INTEL_OUTPUT_HDMI)
51575138 intel_dig_port->base.type = INTEL_OUTPUT_DISPLAYPORT;
51585139
51595140 if (long_hpd && intel_dig_port->base.type == INTEL_OUTPUT_EDP) {
@@ -5172,7 +5153,7 @@ intel_dp_hpd_pulse(struct intel_digital_port *intel_dig_port, bool long_hpd) · 12 unmodified lines
51725153 port_name(intel_dig_port->port),
51735154 long_hpd ? "long" : "short");
51745155
5175− power_domain = intel_display_port_power_domain(intel_encoder);
5156+ power_domain = intel_display_port_aux_power_domain(intel_encoder);
51765157 intel_display_power_get(dev_priv, power_domain);
51775158
51785159 if (long_hpd) {
drivers/gpu/drm/i915/intel_drv.h+2−2
@@ -1169,6 +1169,8 @@ void hsw_enable_ips(struct intel_crtc *crtc); · 1168 unmodified lines
11691169 void hsw_disable_ips(struct intel_crtc *crtc);
11701170 enum intel_display_power_domain
11711171 intel_display_port_power_domain(struct intel_encoder *intel_encoder);
1172+enum intel_display_power_domain
1173+intel_display_port_aux_power_domain(struct intel_encoder *intel_encoder);
11721174 void intel_mode_from_pipe_config(struct drm_display_mode *mode,
11731175 struct intel_crtc_state *pipe_config);
11741176 void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc);
@@ -1377,8 +1379,6 @@ void intel_display_power_get(struct drm_i915_private *dev_priv, · 202 unmodified lines
13771379 enum intel_display_power_domain domain);
13781380 void intel_display_power_put(struct drm_i915_private *dev_priv,
13791381 enum intel_display_power_domain domain);
1380−void intel_aux_display_runtime_get(struct drm_i915_private *dev_priv);
1381−void intel_aux_display_runtime_put(struct drm_i915_private *dev_priv);
13821382 void intel_runtime_pm_get(struct drm_i915_private *dev_priv);
13831383 void intel_runtime_pm_get_noresume(struct drm_i915_private *dev_priv);
13841384 void intel_runtime_pm_put(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/intel_hdmi.c+6−6
@@ -1335,21 +1335,17 @@ intel_hdmi_set_edid(struct drm_connector *connector, bool force) · 1334 unmodified lines
13351335 {
13361336 struct drm_i915_private *dev_priv = to_i915(connector->dev);
13371337 struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
1338− struct intel_encoder *intel_encoder =
1339− &hdmi_to_dig_port(intel_hdmi)->base;
1340− enum intel_display_power_domain power_domain;
13411338 struct edid *edid = NULL;
13421339 bool connected = false;
13431340
1344− power_domain = intel_display_port_power_domain(intel_encoder);
1345− intel_display_power_get(dev_priv, power_domain);
1341+ intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS);
13461342
13471343 if (force)
13481344 edid = drm_get_edid(connector,
13491345 intel_gmbus_get_adapter(dev_priv,
13501346 intel_hdmi->ddc_bus));
13511347
1352− intel_display_power_put(dev_priv, power_domain);
1348+ intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS);
13531349
13541350 to_intel_connector(connector)->detect_edid = edid;
13551351 if (edid && edid->input & DRM_EDID_INPUT_DIGITAL) {
@@ -1383,6 +1379,8 @@ intel_hdmi_detect(struct drm_connector *connector, bool force) · 27 unmodified lines
13831379 DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n",
13841380 connector->base.id, connector->name);
13851381
1382+ intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS);
1383+
13861384 while (!live_status && --retry) {
13871385 live_status = intel_digital_port_connected(dev_priv,
13881386 hdmi_to_dig_port(intel_hdmi));
@@ -1402,6 +1400,8 @@ intel_hdmi_detect(struct drm_connector *connector, bool force) · 13 unmodified lines
14021400 } else
14031401 status = connector_status_disconnected;
14041402
1403+ intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS);
1404+
14051405 return status;
14061406 }
14071407
drivers/gpu/drm/i915/intel_i2c.c+4−2
@@ -483,7 +483,7 @@ gmbus_xfer(struct i2c_adapter *adapter, · 482 unmodified lines
483483 int i = 0, inc, try = 0;
484484 int ret = 0;
485485
486− intel_aux_display_runtime_get(dev_priv);
486+ intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS);
487487 mutex_lock(&dev_priv->gmbus_mutex);
488488
489489 if (bus->force_bit) {
@@ -595,7 +595,9 @@ timeout: · 105 unmodified lines
595595
596596 out:
597597 mutex_unlock(&dev_priv->gmbus_mutex);
598− intel_aux_display_runtime_put(dev_priv);
598+
599+ intel_display_power_put(dev_priv, POWER_DOMAIN_GMBUS);
600+
599601 return ret;
600602 }
601603
drivers/gpu/drm/i915/intel_runtime_pm.c+4−30
@@ -362,6 +362,7 @@ static void hsw_set_power_well(struct drm_i915_private *dev_priv, · 361 unmodified lines
362362 BIT(POWER_DOMAIN_AUX_C) | \
363363 BIT(POWER_DOMAIN_AUDIO) | \
364364 BIT(POWER_DOMAIN_VGA) | \
365+ BIT(POWER_DOMAIN_GMBUS) | \
365366 BIT(POWER_DOMAIN_INIT))
366367 #define BXT_DISPLAY_POWERWELL_1_POWER_DOMAINS ( \
367368 BXT_DISPLAY_POWERWELL_2_POWER_DOMAINS | \
@@ -1483,6 +1484,7 @@ void intel_display_power_put(struct drm_i915_private *dev_priv, · 1115 unmodified lines
14831484 BIT(POWER_DOMAIN_AUX_B) | \
14841485 BIT(POWER_DOMAIN_AUX_C) | \
14851486 BIT(POWER_DOMAIN_AUX_D) | \
1487+ BIT(POWER_DOMAIN_GMBUS) | \
14861488 BIT(POWER_DOMAIN_INIT))
14871489 #define HSW_DISPLAY_POWER_DOMAINS ( \
14881490 (POWER_DOMAIN_MASK & ~HSW_ALWAYS_ON_POWER_DOMAINS) | \
@@ -1845,6 +1847,8 @@ int intel_power_domains_init(struct drm_i915_private *dev_priv) · 356 unmodified lines
18451847 i915.disable_power_well = sanitize_disable_power_well_option(dev_priv,
18461848 i915.disable_power_well);
18471849
1850+ BUILD_BUG_ON(POWER_DOMAIN_NUM > 31);
1851+
18481852 mutex_init(&power_domains->lock);
18491853
18501854 /*
@@ -2063,36 +2067,6 @@ void intel_power_domains_init_hw(struct drm_i915_private *dev_priv) · 212 unmodified lines
20632067 power_domains->initializing = false;
20642068 }
20652069
2066−/**
2067− * intel_aux_display_runtime_get - grab an auxiliary power domain reference
2068− * @dev_priv: i915 device instance
2069− *
2070− * This function grabs a power domain reference for the auxiliary power domain
2071− * (for access to the GMBUS and DP AUX blocks) and ensures that it and all its
2072− * parents are powered up. Therefore users should only grab a reference to the
2073− * innermost power domain they need.
2074− *
2075− * Any power domain reference obtained by this function must have a symmetric
2076− * call to intel_aux_display_runtime_put() to release the reference again.
2077− */
2078−void intel_aux_display_runtime_get(struct drm_i915_private *dev_priv)
2079−{
2080− intel_runtime_pm_get(dev_priv);
2081−}
2082−
2083−/**
2084− * intel_aux_display_runtime_put - release an auxiliary power domain reference
2085− * @dev_priv: i915 device instance
2086− *
2087− * This function drops the auxiliary power domain reference obtained by
2088− * intel_aux_display_runtime_get() and might power down the corresponding
2089− * hardware block right away if this is the last reference.
2090− */
2091−void intel_aux_display_runtime_put(struct drm_i915_private *dev_priv)
2092−{
2093− intel_runtime_pm_put(dev_priv);
2094−}
2095−
20962070 /**
20972071 * intel_runtime_pm_get - grab a runtime pm reference
20982072 * @dev_priv: i915 device instance
drivers/gpu/drm/imx/imx-drm-core.c+3−4
@@ -63,8 +63,7 @@ static void imx_drm_driver_lastclose(struct drm_device *drm) · 62 unmodified lines
6363 #if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER)
6464 struct imx_drm_device *imxdrm = drm->dev_private;
6565
66− if (imxdrm->fbhelper)
67− drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
66+ drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
6867 #endif
6968 }
7069
@@ -340,7 +339,7 @@ err_kms: · 269 unmodified lines
340339 * imx_drm_add_crtc - add a new crtc
341340 */
342341 int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
343− struct imx_drm_crtc **new_crtc,
342+ struct imx_drm_crtc **new_crtc, struct drm_plane *primary_plane,
344343 const struct imx_drm_crtc_helper_funcs *imx_drm_helper_funcs,
345344 struct device_node *port)
346345 {
@@ -379,7 +378,7 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc, · 32 unmodified lines
379378 drm_crtc_helper_add(crtc,
380379 imx_drm_crtc->imx_drm_helper_funcs.crtc_helper_funcs);
381380
382− drm_crtc_init(drm, crtc,
381+ drm_crtc_init_with_planes(drm, crtc, primary_plane, NULL,
383382 imx_drm_crtc->imx_drm_helper_funcs.crtc_funcs);
384383
385384 return 0;
drivers/gpu/drm/imx/imx-drm.h+2−1
@@ -9,6 +9,7 @@ struct drm_display_mode; · 8 unmodified lines
99 struct drm_encoder;
1010 struct drm_fbdev_cma;
1111 struct drm_framebuffer;
12+struct drm_plane;
1213 struct imx_drm_crtc;
1314 struct platform_device;
1415
@@ -24,7 +25,7 @@ struct imx_drm_crtc_helper_funcs { · 9 unmodified lines
2425 };
2526
2627 int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
27− struct imx_drm_crtc **new_crtc,
28+ struct imx_drm_crtc **new_crtc, struct drm_plane *primary_plane,
2829 const struct imx_drm_crtc_helper_funcs *imx_helper_funcs,
2930 struct device_node *port);
3031 int imx_drm_remove_crtc(struct imx_drm_crtc *);
drivers/gpu/drm/imx/imx-tve.c+1−0
@@ -721,6 +721,7 @@ static const struct of_device_id imx_tve_dt_ids[] = { · 720 unmodified lines
721721 { .compatible = "fsl,imx53-tve", },
722722 { /* sentinel */ }
723723 };
724+MODULE_DEVICE_TABLE(of, imx_tve_dt_ids);
724725
725726 static struct platform_driver imx_tve_driver = {
726727 .probe = imx_tve_probe,
drivers/gpu/drm/imx/ipuv3-crtc.c+17−46
@@ -212,7 +212,8 @@ static void ipu_crtc_handle_pageflip(struct ipu_crtc *ipu_crtc) · 211 unmodified lines
212212
213213 spin_lock_irqsave(&drm->event_lock, flags);
214214 if (ipu_crtc->page_flip_event)
215− drm_send_vblank_event(drm, -1, ipu_crtc->page_flip_event);
215+ drm_crtc_send_vblank_event(&ipu_crtc->base,
216+ ipu_crtc->page_flip_event);
216217 ipu_crtc->page_flip_event = NULL;
217218 imx_drm_crtc_vblank_put(ipu_crtc->imx_crtc);
218219 spin_unlock_irqrestore(&drm->event_lock, flags);
@@ -349,7 +350,6 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc, · 130 unmodified lines
349350 struct ipu_soc *ipu = dev_get_drvdata(ipu_crtc->dev->parent);
350351 int dp = -EINVAL;
351352 int ret;
352− int id;
353353
354354 ret = ipu_get_resources(ipu_crtc, pdata);
355355 if (ret) {
@@ -358,18 +358,23 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc, · 2 unmodified lines
358358 return ret;
359359 }
360360
361+ if (pdata->dp >= 0)
362+ dp = IPU_DP_FLOW_SYNC_BG;
363+ ipu_crtc->plane[0] = ipu_plane_init(drm, ipu, pdata->dma[0], dp, 0,
364+ DRM_PLANE_TYPE_PRIMARY);
365+ if (IS_ERR(ipu_crtc->plane[0])) {
366+ ret = PTR_ERR(ipu_crtc->plane[0]);
367+ goto err_put_resources;
368+ }
369+
361370 ret = imx_drm_add_crtc(drm, &ipu_crtc->base, &ipu_crtc->imx_crtc,
362− &ipu_crtc_helper_funcs, ipu_crtc->dev->of_node);
371+ &ipu_crtc->plane[0]->base, &ipu_crtc_helper_funcs,
372+ ipu_crtc->dev->of_node);
363373 if (ret) {
364374 dev_err(ipu_crtc->dev, "adding crtc failed with %d.\n", ret);
365375 goto err_put_resources;
366376 }
367377
368− if (pdata->dp >= 0)
369− dp = IPU_DP_FLOW_SYNC_BG;
370− id = imx_drm_crtc_id(ipu_crtc->imx_crtc);
371− ipu_crtc->plane[0] = ipu_plane_init(ipu_crtc->base.dev, ipu,
372− pdata->dma[0], dp, BIT(id), true);
373378 ret = ipu_plane_get_resources(ipu_crtc->plane[0]);
374379 if (ret) {
375380 dev_err(ipu_crtc->dev, "getting plane 0 resources failed with %d.\n",
@@ -379,10 +384,10 @@ static int ipu_crtc_init(struct ipu_crtc *ipu_crtc, · 3 unmodified lines
379384
380385 /* If this crtc is using the DP, add an overlay plane */
381386 if (pdata->dp >= 0 && pdata->dma[1] > 0) {
382− ipu_crtc->plane[1] = ipu_plane_init(ipu_crtc->base.dev, ipu,
383− pdata->dma[1],
384− IPU_DP_FLOW_SYNC_FG,
385− BIT(id), false);
387+ ipu_crtc->plane[1] = ipu_plane_init(drm, ipu, pdata->dma[1],
388+ IPU_DP_FLOW_SYNC_FG,
389+ drm_crtc_mask(&ipu_crtc->base),
390+ DRM_PLANE_TYPE_OVERLAY);
386391 if (IS_ERR(ipu_crtc->plane[1]))
387392 ipu_crtc->plane[1] = NULL;
388393 }
@@ -407,28 +412,6 @@ err_put_resources: · 18 unmodified lines
407412 return ret;
408413 }
409414
410−static struct device_node *ipu_drm_get_port_by_id(struct device_node *parent,
411− int port_id)
412−{
413− struct device_node *port;
414− int id, ret;
415−
416− port = of_get_child_by_name(parent, "port");
417− while (port) {
418− ret = of_property_read_u32(port, "reg", &id);
419− if (!ret && id == port_id)
420− return port;
421−
422− do {
423− port = of_get_next_child(parent, port);
424− if (!port)
425− return NULL;
426− } while (of_node_cmp(port->name, "port"));
427− }
428−
429− return NULL;
430−}
431−
432415 static int ipu_drm_bind(struct device *dev, struct device *master, void *data)
433416 {
434417 struct ipu_client_platformdata *pdata = dev->platform_data;
@@ -470,23 +453,11 @@ static const struct component_ops ipu_crtc_ops = { · 35 unmodified lines
470453 static int ipu_drm_probe(struct platform_device *pdev)
471454 {
472455 struct device *dev = &pdev->dev;
473− struct ipu_client_platformdata *pdata = dev->platform_data;
474456 int ret;
475457
476458 if (!dev->platform_data)
477459 return -EINVAL;
478460
479− if (!dev->of_node) {
480− /* Associate crtc device with the corresponding DI port node */
481− dev->of_node = ipu_drm_get_port_by_id(dev->parent->of_node,
482− pdata->di + 2);
483− if (!dev->of_node) {
484− dev_err(dev, "missing port@%d node in %s\n",
485− pdata->di + 2, dev->parent->of_node->full_name);
486− return -ENODEV;
487− }
488− }
489−
490461 ret = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
491462 if (ret)
492463 return ret;
drivers/gpu/drm/imx/ipuv3-plane.c+4−5
@@ -381,7 +381,7 @@ static struct drm_plane_funcs ipu_plane_funcs = { · 380 unmodified lines
381381
382382 struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu,
383383 int dma, int dp, unsigned int possible_crtcs,
384− bool priv)
384+ enum drm_plane_type type)
385385 {
386386 struct ipu_plane *ipu_plane;
387387 int ret;
@@ -399,10 +399,9 @@ struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu, · 11 unmodified lines
399399 ipu_plane->dma = dma;
400400 ipu_plane->dp_flow = dp;
401401
402− ret = drm_plane_init(dev, &ipu_plane->base, possible_crtcs,
403− &ipu_plane_funcs, ipu_plane_formats,
404− ARRAY_SIZE(ipu_plane_formats),
405− priv);
402+ ret = drm_universal_plane_init(dev, &ipu_plane->base, possible_crtcs,
403+ &ipu_plane_funcs, ipu_plane_formats,
404+ ARRAY_SIZE(ipu_plane_formats), type);
406405 if (ret) {
407406 DRM_ERROR("failed to initialize plane\n");
408407 kfree(ipu_plane);
drivers/gpu/drm/imx/ipuv3-plane.h+1−1
@@ -34,7 +34,7 @@ struct ipu_plane { · 33 unmodified lines
3434
3535 struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu,
3636 int dma, int dp, unsigned int possible_crtcs,
37− bool priv);
37+ enum drm_plane_type type);
3838
3939 /* Init IDMAC, DMFC, DP */
4040 int ipu_plane_mode_set(struct ipu_plane *plane, struct drm_crtc *crtc,
drivers/gpu/drm/imx/parallel-display.c+4−0
@@ -54,7 +54,11 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector) · 53 unmodified lines
5454
5555 if (imxpd->panel && imxpd->panel->funcs &&
5656 imxpd->panel->funcs->get_modes) {
57+ struct drm_display_info *di = &connector->display_info;
58+
5759 num_modes = imxpd->panel->funcs->get_modes(imxpd->panel);
60+ if (!imxpd->bus_format && di->num_bus_formats)
61+ imxpd->bus_format = di->bus_formats[0];
5862 if (num_modes > 0)
5963 return num_modes;
6064 }
drivers/gpu/drm/nouveau/include/nvkm/core/device.h+0−1
@@ -159,7 +159,6 @@ struct nvkm_device_func { · 158 unmodified lines
159159 struct nvkm_device_quirk {
160160 u8 tv_pin_mask;
161161 u8 tv_gpio;
162− bool War00C800_0;
163162 };
164163
165164 struct nvkm_device_chip {
drivers/gpu/drm/nouveau/include/nvkm/subdev/instmem.h+1−0
@@ -7,6 +7,7 @@ struct nvkm_instmem { · 6 unmodified lines
77 const struct nvkm_instmem_func *func;
88 struct nvkm_subdev subdev;
99
10+ spinlock_t lock;
1011 struct list_head list;
1112 u32 reserved;
1213
drivers/gpu/drm/nouveau/nouveau_acpi.c+1−0
@@ -367,6 +367,7 @@ static int nouveau_rom_call(acpi_handle rom_handle, uint8_t *bios, · 366 unmodified lines
367367 return -ENODEV;
368368 }
369369 obj = (union acpi_object *)buffer.pointer;
370+ len = min(len, (int)obj->buffer.length);
370371 memcpy(bios+offset, obj->buffer.pointer, len);
371372 kfree(buffer.pointer);
372373 return len;
drivers/gpu/drm/nouveau/nouveau_display.c+11−8
@@ -829,7 +829,6 @@ nouveau_finish_page_flip(struct nouveau_channel *chan, · 828 unmodified lines
829829 struct drm_device *dev = drm->dev;
830830 struct nouveau_page_flip_state *s;
831831 unsigned long flags;
832− int crtcid = -1;
833832
834833 spin_lock_irqsave(&dev->event_lock, flags);
835834
@@ -841,15 +840,19 @@ nouveau_finish_page_flip(struct nouveau_channel *chan, · 5 unmodified lines
841840
842841 s = list_first_entry(&fctx->flip, struct nouveau_page_flip_state, head);
843842 if (s->event) {
844− /* Vblank timestamps/counts are only correct on >= NV-50 */
845− if (drm->device.info.family >= NV_DEVICE_INFO_V0_TESLA)
846− crtcid = s->crtc;
843+ if (drm->device.info.family < NV_DEVICE_INFO_V0_TESLA) {
844+ drm_arm_vblank_event(dev, s->crtc, s->event);
845+ } else {
846+ drm_send_vblank_event(dev, s->crtc, s->event);
847847
848− drm_send_vblank_event(dev, crtcid, s->event);
848+ /* Give up ownership of vblank for page-flipped crtc */
849+ drm_vblank_put(dev, s->crtc);
850+ }
851+ }
852+ else {
853+ /* Give up ownership of vblank for page-flipped crtc */
854+ drm_vblank_put(dev, s->crtc);
849855 }
850−
851− /* Give up ownership of vblank for page-flipped crtc */
852− drm_vblank_put(dev, s->crtc);
853856
854857 list_del(&s->head);
855858 if (ps)
drivers/gpu/drm/nouveau/nouveau_drm.h+3−1
@@ -39,6 +39,7 @@ · 38 unmodified lines
3939
4040 #include <nvif/client.h>
4141 #include <nvif/device.h>
42+#include <nvif/ioctl.h>
4243
4344 #include <drmP.h>
4445
@@ -65,9 +66,10 @@ struct nouveau_drm_tile { · 20 unmodified lines
6566 };
6667
6768 enum nouveau_drm_object_route {
68− NVDRM_OBJECT_NVIF = 0,
69+ NVDRM_OBJECT_NVIF = NVIF_IOCTL_V0_OWNER_NVIF,
6970 NVDRM_OBJECT_USIF,
7071 NVDRM_OBJECT_ABI16,
72+ NVDRM_OBJECT_ANY = NVIF_IOCTL_V0_OWNER_ANY,
7173 };
7274
7375 enum nouveau_drm_notify_route {
drivers/gpu/drm/nouveau/nouveau_usif.c+4−1
@@ -313,7 +313,10 @@ usif_ioctl(struct drm_file *filp, void __user *user, u32 argc) · 312 unmodified lines
313313 if (nvif_unpack(argv->v0, 0, 0, true)) {
314314 /* block access to objects not created via this interface */
315315 owner = argv->v0.owner;
316− argv->v0.owner = NVDRM_OBJECT_USIF;
316+ if (argv->v0.object == 0ULL)
317+ argv->v0.owner = NVDRM_OBJECT_ANY; /* except client */
318+ else
319+ argv->v0.owner = NVDRM_OBJECT_USIF;
317320 } else
318321 goto done;
319322
drivers/gpu/drm/nouveau/nvkm/engine/device/pci.c+2−17
@@ -258,12 +258,6 @@ nvkm_device_pci_10de_0df4[] = { · 257 unmodified lines
258258 {}
259259 };
260260
261−static const struct nvkm_device_pci_vendor
262−nvkm_device_pci_10de_0fcd[] = {
263− { 0x17aa, 0x3801, NULL, { .War00C800_0 = true } }, /* Lenovo Y510P */
264− {}
265−};
266−
267261 static const struct nvkm_device_pci_vendor
268262 nvkm_device_pci_10de_0fd2[] = {
269263 { 0x1028, 0x0595, "GeForce GT 640M LE" },
@@ -684,7 +678,6 @@ nvkm_device_pci_10de_1189[] = { · 414 unmodified lines
684678 static const struct nvkm_device_pci_vendor
685679 nvkm_device_pci_10de_1199[] = {
686680 { 0x1458, 0xd001, "GeForce GTX 760" },
687− { 0x1462, 0x1106, "GeForce GTX 780M", { .War00C800_0 = true } }, /* Medion Erazer X7827 */
688681 {}
689682 };
690683
@@ -694,14 +687,6 @@ nvkm_device_pci_10de_11e3[] = { · 3 unmodified lines
694687 {}
695688 };
696689
697−static const struct nvkm_device_pci_vendor
698−nvkm_device_pci_10de_11fc[] = {
699− { 0x1179, 0x0001, NULL, { .War00C800_0 = true } }, /* Toshiba Tecra W50 */
700− { 0x17aa, 0x2211, NULL, { .War00C800_0 = true } }, /* Lenovo W541 */
701− { 0x17aa, 0x221e, NULL, { .War00C800_0 = true } }, /* Lenovo W541 */
702− {}
703−};
704−
705690 static const struct nvkm_device_pci_vendor
706691 nvkm_device_pci_10de_1247[] = {
707692 { 0x1043, 0x212a, "GeForce GT 635M" },
@@ -1356,7 +1341,7 @@ nvkm_device_pci_10de[] = { · 648 unmodified lines
13561341 { 0x0fc6, "GeForce GTX 650" },
13571342 { 0x0fc8, "GeForce GT 740" },
13581343 { 0x0fc9, "GeForce GT 730" },
1359− { 0x0fcd, "GeForce GT 755M", nvkm_device_pci_10de_0fcd },
1344+ { 0x0fcd, "GeForce GT 755M" },
13601345 { 0x0fce, "GeForce GT 640M LE" },
13611346 { 0x0fd1, "GeForce GT 650M" },
13621347 { 0x0fd2, "GeForce GT 640M", nvkm_device_pci_10de_0fd2 },
@@ -1490,7 +1475,7 @@ nvkm_device_pci_10de[] = { · 127 unmodified lines
14901475 { 0x11e2, "GeForce GTX 765M" },
14911476 { 0x11e3, "GeForce GTX 760M", nvkm_device_pci_10de_11e3 },
14921477 { 0x11fa, "Quadro K4000" },
1493− { 0x11fc, "Quadro K2100M", nvkm_device_pci_10de_11fc },
1478+ { 0x11fc, "Quadro K2100M" },
14941479 { 0x1200, "GeForce GTX 560 Ti" },
14951480 { 0x1201, "GeForce GTX 560" },
14961481 { 0x1203, "GeForce GTX 460 SE v2" },
drivers/gpu/drm/nouveau/nvkm/engine/gr/ctxgf117.c+2−0
@@ -207,6 +207,8 @@ gf117_grctx_generate_attrib(struct gf100_grctx *info) · 206 unmodified lines
207207 const u32 b = beta * gr->ppc_tpc_nr[gpc][ppc];
208208 const u32 t = timeslice_mode;
209209 const u32 o = PPC_UNIT(gpc, ppc, 0);
210+ if (!(gr->ppc_mask[gpc] & (1 << ppc)))
211+ continue;
210212 mmio_skip(info, o + 0xc0, (t << 28) | (b << 16) | ++bo);
211213 mmio_wr32(info, o + 0xc0, (t << 28) | (b << 16) | --bo);
212214 bo += grctx->attrib_nr_max * gr->ppc_tpc_nr[gpc][ppc];
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpc.fuc+5−3
@@ -52,10 +52,12 @@ mmio_list_base: · 51 unmodified lines
5252 #endif
5353
5454 #ifdef INCLUDE_CODE
55+#define gpc_addr(reg,addr) /*
56+*/ imm32(reg,addr) /*
57+*/ or reg NV_PGRAPH_GPCX_GPCCS_MMIO_CTRL_BASE_ENABLE
5558 #define gpc_wr32(addr,reg) /*
59+*/ gpc_addr($r14,addr) /*
5660 */ mov b32 $r15 reg /*
57−*/ imm32($r14, addr) /*
58−*/ or $r14 NV_PGRAPH_GPCX_GPCCS_MMIO_CTRL_BASE_ENABLE /*
5961 */ call(nv_wr32)
6062
6163 // reports an exception to the host
@@ -161,7 +163,7 @@ init: · 99 unmodified lines
161163
162164 #if NV_PGRAPH_GPCX_UNK__SIZE > 0
163165 // figure out which, and how many, UNKs are actually present
164− imm32($r14, 0x500c30)
166+ gpc_addr($r14, 0x500c30)
165167 clear b32 $r2
166168 clear b32 $r3
167169 clear b32 $r4
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgf117.fuc3.h+172−172
@@ -314,7 +314,7 @@ uint32_t gf117_grgpc_code[] = { · 313 unmodified lines
314314 0x03f01200,
315315 0x0002d000,
316316 0x17f104bd,
317− 0x10fe0542,
317+ 0x10fe0545,
318318 0x0007f100,
319319 0x0003f007,
320320 0xbd0000d0,
@@ -338,184 +338,184 @@ uint32_t gf117_grgpc_code[] = { · 17 unmodified lines
338338 0x02d00103,
339339 0xf104bd00,
340340 0xf00c30e7,
341− 0x24bd50e3,
342− 0x44bd34bd,
343−/* 0x0430: init_unk_loop */
344− 0xb06821f4,
345− 0x0bf400f6,
346− 0x01f7f00f,
347− 0xfd04f2bb,
348− 0x30b6054f,
349−/* 0x0445: init_unk_next */
350− 0x0120b601,
351− 0xb004e0b6,
352− 0x1bf40126,
353−/* 0x0451: init_unk_done */
354− 0x070380e2,
355− 0xf1080480,
356− 0xf0010027,
357− 0x22cf0223,
358− 0x9534bd00,
359− 0x07f10825,
360− 0x03f0c000,
361− 0x0005d001,
362− 0x07f104bd,
363− 0x03f0c100,
364− 0x0005d001,
365− 0x0e9804bd,
366− 0x010f9800,
367− 0x015021f5,
368− 0xbb002fbb,
369− 0x0e98003f,
370− 0x020f9801,
371− 0x015021f5,
372− 0xfd050e98,
373− 0x2ebb00ef,
374− 0x003ebb00,
375− 0x98020e98,
376− 0x21f5030f,
377− 0x0e980150,
378− 0x00effd07,
379− 0xbb002ebb,
380− 0x35b6003e,
381− 0x0007f102,
382− 0x0103f0d3,
383− 0xbd0003d0,
384− 0x0825b604,
385− 0xb60635b6,
386− 0x30b60120,
387− 0x0824b601,
388− 0xb90834b6,
389− 0x21f5022f,
390− 0x2fbb02d3,
391− 0x003fbb00,
392− 0x010007f1,
393− 0xd00203f0,
341+ 0xe5f050e3,
342+ 0xbd24bd01,
343+/* 0x0433: init_unk_loop */
344+ 0xf444bd34,
345+ 0xf6b06821,
346+ 0x0f0bf400,
347+ 0xbb01f7f0,
348+ 0x4ffd04f2,
349+ 0x0130b605,
350+/* 0x0448: init_unk_next */
351+ 0xb60120b6,
352+ 0x26b004e0,
353+ 0xe21bf401,
354+/* 0x0454: init_unk_done */
355+ 0x80070380,
356+ 0x27f10804,
357+ 0x23f00100,
358+ 0x0022cf02,
359+ 0x259534bd,
360+ 0x0007f108,
361+ 0x0103f0c0,
362+ 0xbd0005d0,
363+ 0x0007f104,
364+ 0x0103f0c1,
365+ 0xbd0005d0,
366+ 0x000e9804,
367+ 0xf5010f98,
368+ 0xbb015021,
369+ 0x3fbb002f,
370+ 0x010e9800,
371+ 0xf5020f98,
372+ 0x98015021,
373+ 0xeffd050e,
374+ 0x002ebb00,
375+ 0x98003ebb,
376+ 0x0f98020e,
377+ 0x5021f503,
378+ 0x070e9801,
379+ 0xbb00effd,
380+ 0x3ebb002e,
381+ 0x0235b600,
382+ 0xd30007f1,
383+ 0xd00103f0,
394384 0x04bd0003,
395− 0x29f024bd,
396− 0x0007f11f,
397− 0x0203f008,
398− 0xbd0002d0,
399−/* 0x0505: main */
400− 0x0031f404,
401− 0xf00028f4,
402− 0x21f424d7,
403− 0xf401f439,
404− 0xf404e4b0,
405− 0x81fe1e18,
406− 0x0627f001,
407− 0x12fd20bd,
408− 0x01e4b604,
409− 0xfe051efd,
410− 0x21f50018,
411− 0x0ef405fa,
412−/* 0x0535: main_not_ctx_xfer */
413− 0x10ef94d3,
414− 0xf501f5f0,
415− 0xf4037e21,
416−/* 0x0542: ih */
417− 0x80f9c60e,
418− 0xf90188fe,
419− 0xf990f980,
420− 0xf9b0f9a0,
421− 0xf9e0f9d0,
422− 0xf104bdf0,
423− 0xf00200a7,
424− 0xaacf00a3,
425− 0x04abc400,
426− 0xf02c0bf4,
427− 0xe7f124d7,
428− 0xe3f01a00,
429− 0x00eecf00,
430− 0x1900f7f1,
431− 0xcf00f3f0,
432− 0x21f400ff,
433− 0x01e7f004,
434− 0x1d0007f1,
435− 0xd00003f0,
436− 0x04bd000e,
437−/* 0x0590: ih_no_fifo */
438− 0x010007f1,
439− 0xd00003f0,
440− 0x04bd000a,
441− 0xe0fcf0fc,
442− 0xb0fcd0fc,
443− 0x90fca0fc,
444− 0x88fe80fc,
445− 0xf480fc00,
446− 0x01f80032,
447−/* 0x05b4: hub_barrier_done */
448− 0x9801f7f0,
449− 0xfebb040e,
450− 0x02ffb904,
451− 0x9418e7f1,
452− 0xf440e3f0,
453− 0x00f89d21,
454−/* 0x05cc: ctx_redswitch */
455− 0xf120f7f0,
385+ 0xb60825b6,
386+ 0x20b60635,
387+ 0x0130b601,
388+ 0xb60824b6,
389+ 0x2fb90834,
390+ 0xd321f502,
391+ 0x002fbb02,
392+ 0xf1003fbb,
393+ 0xf0010007,
394+ 0x03d00203,
395+ 0xbd04bd00,
396+ 0x1f29f024,
397+ 0x080007f1,
398+ 0xd00203f0,
399+ 0x04bd0002,
400+/* 0x0508: main */
401+ 0xf40031f4,
402+ 0xd7f00028,
403+ 0x3921f424,
404+ 0xb0f401f4,
405+ 0x18f404e4,
406+ 0x0181fe1e,
407+ 0xbd0627f0,
408+ 0x0412fd20,
409+ 0xfd01e4b6,
410+ 0x18fe051e,
411+ 0xfd21f500,
412+ 0xd30ef405,
413+/* 0x0538: main_not_ctx_xfer */
414+ 0xf010ef94,
415+ 0x21f501f5,
416+ 0x0ef4037e,
417+/* 0x0545: ih */
418+ 0xfe80f9c6,
419+ 0x80f90188,
420+ 0xa0f990f9,
421+ 0xd0f9b0f9,
422+ 0xf0f9e0f9,
423+ 0xa7f104bd,
424+ 0xa3f00200,
425+ 0x00aacf00,
426+ 0xf404abc4,
427+ 0xd7f02c0b,
428+ 0x00e7f124,
429+ 0x00e3f01a,
430+ 0xf100eecf,
431+ 0xf01900f7,
432+ 0xffcf00f3,
433+ 0x0421f400,
434+ 0xf101e7f0,
435+ 0xf01d0007,
436+ 0x0ed00003,
437+/* 0x0593: ih_no_fifo */
438+ 0xf104bd00,
439+ 0xf0010007,
440+ 0x0ad00003,
441+ 0xfc04bd00,
442+ 0xfce0fcf0,
443+ 0xfcb0fcd0,
444+ 0xfc90fca0,
445+ 0x0088fe80,
446+ 0x32f480fc,
447+/* 0x05b7: hub_barrier_done */
448+ 0xf001f800,
449+ 0x0e9801f7,
450+ 0x04febb04,
451+ 0xf102ffb9,
452+ 0xf09418e7,
453+ 0x21f440e3,
454+/* 0x05cf: ctx_redswitch */
455+ 0xf000f89d,
456+ 0x07f120f7,
457+ 0x03f08500,
458+ 0x000fd001,
459+ 0xe7f004bd,
460+/* 0x05e1: ctx_redswitch_delay */
461+ 0x01e2b608,
462+ 0xf1fd1bf4,
463+ 0xf10800f5,
464+ 0xf10200f5,
456465 0xf0850007,
457466 0x0fd00103,
458− 0xf004bd00,
459−/* 0x05de: ctx_redswitch_delay */
460− 0xe2b608e7,
461− 0xfd1bf401,
462− 0x0800f5f1,
463− 0x0200f5f1,
464− 0x850007f1,
465− 0xd00103f0,
466− 0x04bd000f,
467−/* 0x05fa: ctx_xfer */
468− 0x07f100f8,
469− 0x03f08100,
470− 0x000fd002,
471− 0x11f404bd,
472− 0xcc21f507,
473−/* 0x060d: ctx_xfer_not_load */
474− 0x6a21f505,
475− 0xf124bd02,
476− 0xf047fc07,
477− 0x02d00203,
478− 0xf004bd00,
479− 0x20b6012c,
480− 0xfc07f103,
481− 0x0203f04a,
482− 0xbd0002d0,
483− 0x01acf004,
484− 0xf102a5f0,
485− 0xf00000b7,
486− 0x0c9850b3,
487− 0x0fc4b604,
488− 0x9800bcbb,
489− 0x0d98000c,
490− 0x00e7f001,
491− 0x016f21f5,
492− 0xf101acf0,
493− 0xf04000b7,
494− 0x0c9850b3,
495− 0x0fc4b604,
496− 0x9800bcbb,
497− 0x0d98010c,
498− 0x060f9802,
499− 0x0800e7f1,
500− 0x016f21f5,
467+ 0xf804bd00,
468+/* 0x05fd: ctx_xfer */
469+ 0x0007f100,
470+ 0x0203f081,
471+ 0xbd000fd0,
472+ 0x0711f404,
473+ 0x05cf21f5,
474+/* 0x0610: ctx_xfer_not_load */
475+ 0x026a21f5,
476+ 0x07f124bd,
477+ 0x03f047fc,
478+ 0x0002d002,
479+ 0x2cf004bd,
480+ 0x0320b601,
481+ 0x4afc07f1,
482+ 0xd00203f0,
483+ 0x04bd0002,
501484 0xf001acf0,
502− 0xb7f104a5,
503− 0xb3f03000,
485+ 0xb7f102a5,
486+ 0xb3f00000,
504487 0x040c9850,
505488 0xbb0fc4b6,
506489 0x0c9800bc,
507− 0x030d9802,
508− 0xf1080f98,
509− 0xf50200e7,
510− 0xf5016f21,
511− 0xf4025e21,
512− 0x12f40601,
513−/* 0x06a9: ctx_xfer_post */
514− 0x7f21f507,
515−/* 0x06ad: ctx_xfer_done */
516− 0xb421f502,
517− 0x0000f805,
518− 0x00000000,
490+ 0x010d9800,
491+ 0xf500e7f0,
492+ 0xf0016f21,
493+ 0xb7f101ac,
494+ 0xb3f04000,
495+ 0x040c9850,
496+ 0xbb0fc4b6,
497+ 0x0c9800bc,
498+ 0x020d9801,
499+ 0xf1060f98,
500+ 0xf50800e7,
501+ 0xf0016f21,
502+ 0xa5f001ac,
503+ 0x00b7f104,
504+ 0x50b3f030,
505+ 0xb6040c98,
506+ 0xbcbb0fc4,
507+ 0x020c9800,
508+ 0x98030d98,
509+ 0xe7f1080f,
510+ 0x21f50200,
511+ 0x21f5016f,
512+ 0x01f4025e,
513+ 0x0712f406,
514+/* 0x06ac: ctx_xfer_post */
515+ 0x027f21f5,
516+/* 0x06b0: ctx_xfer_done */
517+ 0x05b721f5,
518+ 0x000000f8,
519519 0x00000000,
520520 0x00000000,
521521 0x00000000,
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk104.fuc3.h+172−172
@@ -314,7 +314,7 @@ uint32_t gk104_grgpc_code[] = { · 313 unmodified lines
314314 0x03f01200,
315315 0x0002d000,
316316 0x17f104bd,
317− 0x10fe0542,
317+ 0x10fe0545,
318318 0x0007f100,
319319 0x0003f007,
320320 0xbd0000d0,
@@ -338,184 +338,184 @@ uint32_t gk104_grgpc_code[] = { · 17 unmodified lines
338338 0x02d00103,
339339 0xf104bd00,
340340 0xf00c30e7,
341− 0x24bd50e3,
342− 0x44bd34bd,
343−/* 0x0430: init_unk_loop */
344− 0xb06821f4,
345− 0x0bf400f6,
346− 0x01f7f00f,
347− 0xfd04f2bb,
348− 0x30b6054f,
349−/* 0x0445: init_unk_next */
350− 0x0120b601,
351− 0xb004e0b6,
352− 0x1bf40126,
353−/* 0x0451: init_unk_done */
354− 0x070380e2,
355− 0xf1080480,
356− 0xf0010027,
357− 0x22cf0223,
358− 0x9534bd00,
359− 0x07f10825,
360− 0x03f0c000,
361− 0x0005d001,
362− 0x07f104bd,
363− 0x03f0c100,
364− 0x0005d001,
365− 0x0e9804bd,
366− 0x010f9800,
367− 0x015021f5,
368− 0xbb002fbb,
369− 0x0e98003f,
370− 0x020f9801,
371− 0x015021f5,
372− 0xfd050e98,
373− 0x2ebb00ef,
374− 0x003ebb00,
375− 0x98020e98,
376− 0x21f5030f,
377− 0x0e980150,
378− 0x00effd07,
379− 0xbb002ebb,
380− 0x35b6003e,
381− 0x0007f102,
382− 0x0103f0d3,
383− 0xbd0003d0,
384− 0x0825b604,
385− 0xb60635b6,
386− 0x30b60120,
387− 0x0824b601,
388− 0xb90834b6,
389− 0x21f5022f,
390− 0x2fbb02d3,
391− 0x003fbb00,
392− 0x010007f1,
393− 0xd00203f0,
341+ 0xe5f050e3,
342+ 0xbd24bd01,
343+/* 0x0433: init_unk_loop */
344+ 0xf444bd34,
345+ 0xf6b06821,
346+ 0x0f0bf400,
347+ 0xbb01f7f0,
348+ 0x4ffd04f2,
349+ 0x0130b605,
350+/* 0x0448: init_unk_next */
351+ 0xb60120b6,
352+ 0x26b004e0,
353+ 0xe21bf401,
354+/* 0x0454: init_unk_done */
355+ 0x80070380,
356+ 0x27f10804,
357+ 0x23f00100,
358+ 0x0022cf02,
359+ 0x259534bd,
360+ 0x0007f108,
361+ 0x0103f0c0,
362+ 0xbd0005d0,
363+ 0x0007f104,
364+ 0x0103f0c1,
365+ 0xbd0005d0,
366+ 0x000e9804,
367+ 0xf5010f98,
368+ 0xbb015021,
369+ 0x3fbb002f,
370+ 0x010e9800,
371+ 0xf5020f98,
372+ 0x98015021,
373+ 0xeffd050e,
374+ 0x002ebb00,
375+ 0x98003ebb,
376+ 0x0f98020e,
377+ 0x5021f503,
378+ 0x070e9801,
379+ 0xbb00effd,
380+ 0x3ebb002e,
381+ 0x0235b600,
382+ 0xd30007f1,
383+ 0xd00103f0,
394384 0x04bd0003,
395− 0x29f024bd,
396− 0x0007f11f,
397− 0x0203f008,
398− 0xbd0002d0,
399−/* 0x0505: main */
400− 0x0031f404,
401− 0xf00028f4,
402− 0x21f424d7,
403− 0xf401f439,
404− 0xf404e4b0,
405− 0x81fe1e18,
406− 0x0627f001,
407− 0x12fd20bd,
408− 0x01e4b604,
409− 0xfe051efd,
410− 0x21f50018,
411− 0x0ef405fa,
412−/* 0x0535: main_not_ctx_xfer */
413− 0x10ef94d3,
414− 0xf501f5f0,
415− 0xf4037e21,
416−/* 0x0542: ih */
417− 0x80f9c60e,
418− 0xf90188fe,
419− 0xf990f980,
420− 0xf9b0f9a0,
421− 0xf9e0f9d0,
422− 0xf104bdf0,
423− 0xf00200a7,
424− 0xaacf00a3,
425− 0x04abc400,
426− 0xf02c0bf4,
427− 0xe7f124d7,
428− 0xe3f01a00,
429− 0x00eecf00,
430− 0x1900f7f1,
431− 0xcf00f3f0,
432− 0x21f400ff,
433− 0x01e7f004,
434− 0x1d0007f1,
435− 0xd00003f0,
436− 0x04bd000e,
437−/* 0x0590: ih_no_fifo */
438− 0x010007f1,
439− 0xd00003f0,
440− 0x04bd000a,
441− 0xe0fcf0fc,
442− 0xb0fcd0fc,
443− 0x90fca0fc,
444− 0x88fe80fc,
445− 0xf480fc00,
446− 0x01f80032,
447−/* 0x05b4: hub_barrier_done */
448− 0x9801f7f0,
449− 0xfebb040e,
450− 0x02ffb904,
451− 0x9418e7f1,
452− 0xf440e3f0,
453− 0x00f89d21,
454−/* 0x05cc: ctx_redswitch */
455− 0xf120f7f0,
385+ 0xb60825b6,
386+ 0x20b60635,
387+ 0x0130b601,
388+ 0xb60824b6,
389+ 0x2fb90834,
390+ 0xd321f502,
391+ 0x002fbb02,
392+ 0xf1003fbb,
393+ 0xf0010007,
394+ 0x03d00203,
395+ 0xbd04bd00,
396+ 0x1f29f024,
397+ 0x080007f1,
398+ 0xd00203f0,
399+ 0x04bd0002,
400+/* 0x0508: main */
401+ 0xf40031f4,
402+ 0xd7f00028,
403+ 0x3921f424,
404+ 0xb0f401f4,
405+ 0x18f404e4,
406+ 0x0181fe1e,
407+ 0xbd0627f0,
408+ 0x0412fd20,
409+ 0xfd01e4b6,
410+ 0x18fe051e,
411+ 0xfd21f500,
412+ 0xd30ef405,
413+/* 0x0538: main_not_ctx_xfer */
414+ 0xf010ef94,
415+ 0x21f501f5,
416+ 0x0ef4037e,
417+/* 0x0545: ih */
418+ 0xfe80f9c6,
419+ 0x80f90188,
420+ 0xa0f990f9,
421+ 0xd0f9b0f9,
422+ 0xf0f9e0f9,
423+ 0xa7f104bd,
424+ 0xa3f00200,
425+ 0x00aacf00,
426+ 0xf404abc4,
427+ 0xd7f02c0b,
428+ 0x00e7f124,
429+ 0x00e3f01a,
430+ 0xf100eecf,
431+ 0xf01900f7,
432+ 0xffcf00f3,
433+ 0x0421f400,
434+ 0xf101e7f0,
435+ 0xf01d0007,
436+ 0x0ed00003,
437+/* 0x0593: ih_no_fifo */
438+ 0xf104bd00,
439+ 0xf0010007,
440+ 0x0ad00003,
441+ 0xfc04bd00,
442+ 0xfce0fcf0,
443+ 0xfcb0fcd0,
444+ 0xfc90fca0,
445+ 0x0088fe80,
446+ 0x32f480fc,
447+/* 0x05b7: hub_barrier_done */
448+ 0xf001f800,
449+ 0x0e9801f7,
450+ 0x04febb04,
451+ 0xf102ffb9,
452+ 0xf09418e7,
453+ 0x21f440e3,
454+/* 0x05cf: ctx_redswitch */
455+ 0xf000f89d,
456+ 0x07f120f7,
457+ 0x03f08500,
458+ 0x000fd001,
459+ 0xe7f004bd,
460+/* 0x05e1: ctx_redswitch_delay */
461+ 0x01e2b608,
462+ 0xf1fd1bf4,
463+ 0xf10800f5,
464+ 0xf10200f5,
456465 0xf0850007,
457466 0x0fd00103,
458− 0xf004bd00,
459−/* 0x05de: ctx_redswitch_delay */
460− 0xe2b608e7,
461− 0xfd1bf401,
462− 0x0800f5f1,
463− 0x0200f5f1,
464− 0x850007f1,
465− 0xd00103f0,
466− 0x04bd000f,
467−/* 0x05fa: ctx_xfer */
468− 0x07f100f8,
469− 0x03f08100,
470− 0x000fd002,
471− 0x11f404bd,
472− 0xcc21f507,
473−/* 0x060d: ctx_xfer_not_load */
474− 0x6a21f505,
475− 0xf124bd02,
476− 0xf047fc07,
477− 0x02d00203,
478− 0xf004bd00,
479− 0x20b6012c,
480− 0xfc07f103,
481− 0x0203f04a,
482− 0xbd0002d0,
483− 0x01acf004,
484− 0xf102a5f0,
485− 0xf00000b7,
486− 0x0c9850b3,
487− 0x0fc4b604,
488− 0x9800bcbb,
489− 0x0d98000c,
490− 0x00e7f001,
491− 0x016f21f5,
492− 0xf101acf0,
493− 0xf04000b7,
494− 0x0c9850b3,
495− 0x0fc4b604,
496− 0x9800bcbb,
497− 0x0d98010c,
498− 0x060f9802,
499− 0x0800e7f1,
500− 0x016f21f5,
467+ 0xf804bd00,
468+/* 0x05fd: ctx_xfer */
469+ 0x0007f100,
470+ 0x0203f081,
471+ 0xbd000fd0,
472+ 0x0711f404,
473+ 0x05cf21f5,
474+/* 0x0610: ctx_xfer_not_load */
475+ 0x026a21f5,
476+ 0x07f124bd,
477+ 0x03f047fc,
478+ 0x0002d002,
479+ 0x2cf004bd,
480+ 0x0320b601,
481+ 0x4afc07f1,
482+ 0xd00203f0,
483+ 0x04bd0002,
501484 0xf001acf0,
502− 0xb7f104a5,
503− 0xb3f03000,
485+ 0xb7f102a5,
486+ 0xb3f00000,
504487 0x040c9850,
505488 0xbb0fc4b6,
506489 0x0c9800bc,
507− 0x030d9802,
508− 0xf1080f98,
509− 0xf50200e7,
510− 0xf5016f21,
511− 0xf4025e21,
512− 0x12f40601,
513−/* 0x06a9: ctx_xfer_post */
514− 0x7f21f507,
515−/* 0x06ad: ctx_xfer_done */
516− 0xb421f502,
517− 0x0000f805,
518− 0x00000000,
490+ 0x010d9800,
491+ 0xf500e7f0,
492+ 0xf0016f21,
493+ 0xb7f101ac,
494+ 0xb3f04000,
495+ 0x040c9850,
496+ 0xbb0fc4b6,
497+ 0x0c9800bc,
498+ 0x020d9801,
499+ 0xf1060f98,
500+ 0xf50800e7,
501+ 0xf0016f21,
502+ 0xa5f001ac,
503+ 0x00b7f104,
504+ 0x50b3f030,
505+ 0xb6040c98,
506+ 0xbcbb0fc4,
507+ 0x020c9800,
508+ 0x98030d98,
509+ 0xe7f1080f,
510+ 0x21f50200,
511+ 0x21f5016f,
512+ 0x01f4025e,
513+ 0x0712f406,
514+/* 0x06ac: ctx_xfer_post */
515+ 0x027f21f5,
516+/* 0x06b0: ctx_xfer_done */
517+ 0x05b721f5,
518+ 0x000000f8,
519519 0x00000000,
520520 0x00000000,
521521 0x00000000,
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk110.fuc3.h+172−172
@@ -314,7 +314,7 @@ uint32_t gk110_grgpc_code[] = { · 313 unmodified lines
314314 0x03f01200,
315315 0x0002d000,
316316 0x17f104bd,
317− 0x10fe0542,
317+ 0x10fe0545,
318318 0x0007f100,
319319 0x0003f007,
320320 0xbd0000d0,
@@ -338,184 +338,184 @@ uint32_t gk110_grgpc_code[] = { · 17 unmodified lines
338338 0x02d00103,
339339 0xf104bd00,
340340 0xf00c30e7,
341− 0x24bd50e3,
342− 0x44bd34bd,
343−/* 0x0430: init_unk_loop */
344− 0xb06821f4,
345− 0x0bf400f6,
346− 0x01f7f00f,
347− 0xfd04f2bb,
348− 0x30b6054f,
349−/* 0x0445: init_unk_next */
350− 0x0120b601,
351− 0xb004e0b6,
352− 0x1bf40226,
353−/* 0x0451: init_unk_done */
354− 0x070380e2,
355− 0xf1080480,
356− 0xf0010027,
357− 0x22cf0223,
358− 0x9534bd00,
359− 0x07f10825,
360− 0x03f0c000,
361− 0x0005d001,
362− 0x07f104bd,
363− 0x03f0c100,
364− 0x0005d001,
365− 0x0e9804bd,
366− 0x010f9800,
367− 0x015021f5,
368− 0xbb002fbb,
369− 0x0e98003f,
370− 0x020f9801,
371− 0x015021f5,
372− 0xfd050e98,
373− 0x2ebb00ef,
374− 0x003ebb00,
375− 0x98020e98,
376− 0x21f5030f,
377− 0x0e980150,
378− 0x00effd07,
379− 0xbb002ebb,
380− 0x35b6003e,
381− 0x0007f102,
382− 0x0103f0d3,
383− 0xbd0003d0,
384− 0x0825b604,
385− 0xb60635b6,
386− 0x30b60120,
387− 0x0824b601,
388− 0xb90834b6,
389− 0x21f5022f,
390− 0x2fbb02d3,
391− 0x003fbb00,
392− 0x010007f1,
393− 0xd00203f0,
341+ 0xe5f050e3,
342+ 0xbd24bd01,
343+/* 0x0433: init_unk_loop */
344+ 0xf444bd34,
345+ 0xf6b06821,
346+ 0x0f0bf400,
347+ 0xbb01f7f0,
348+ 0x4ffd04f2,
349+ 0x0130b605,
350+/* 0x0448: init_unk_next */
351+ 0xb60120b6,
352+ 0x26b004e0,
353+ 0xe21bf402,
354+/* 0x0454: init_unk_done */
355+ 0x80070380,
356+ 0x27f10804,
357+ 0x23f00100,
358+ 0x0022cf02,
359+ 0x259534bd,
360+ 0x0007f108,
361+ 0x0103f0c0,
362+ 0xbd0005d0,
363+ 0x0007f104,
364+ 0x0103f0c1,
365+ 0xbd0005d0,
366+ 0x000e9804,
367+ 0xf5010f98,
368+ 0xbb015021,
369+ 0x3fbb002f,
370+ 0x010e9800,
371+ 0xf5020f98,
372+ 0x98015021,
373+ 0xeffd050e,
374+ 0x002ebb00,
375+ 0x98003ebb,
376+ 0x0f98020e,
377+ 0x5021f503,
378+ 0x070e9801,
379+ 0xbb00effd,
380+ 0x3ebb002e,
381+ 0x0235b600,
382+ 0xd30007f1,
383+ 0xd00103f0,
394384 0x04bd0003,
395− 0x29f024bd,
396− 0x0007f11f,
397− 0x0203f030,
398− 0xbd0002d0,
399−/* 0x0505: main */
400− 0x0031f404,
401− 0xf00028f4,
402− 0x21f424d7,
403− 0xf401f439,
404− 0xf404e4b0,
405− 0x81fe1e18,
406− 0x0627f001,
407− 0x12fd20bd,
408− 0x01e4b604,
409− 0xfe051efd,
410− 0x21f50018,
411− 0x0ef405fa,
412−/* 0x0535: main_not_ctx_xfer */
413− 0x10ef94d3,
414− 0xf501f5f0,
415− 0xf4037e21,
416−/* 0x0542: ih */
417− 0x80f9c60e,
418− 0xf90188fe,
419− 0xf990f980,
420− 0xf9b0f9a0,
421− 0xf9e0f9d0,
422− 0xf104bdf0,
423− 0xf00200a7,
424− 0xaacf00a3,
425− 0x04abc400,
426− 0xf02c0bf4,
427− 0xe7f124d7,
428− 0xe3f01a00,
429− 0x00eecf00,
430− 0x1900f7f1,
431− 0xcf00f3f0,
432− 0x21f400ff,
433− 0x01e7f004,
434− 0x1d0007f1,
435− 0xd00003f0,
436− 0x04bd000e,
437−/* 0x0590: ih_no_fifo */
438− 0x010007f1,
439− 0xd00003f0,
440− 0x04bd000a,
441− 0xe0fcf0fc,
442− 0xb0fcd0fc,
443− 0x90fca0fc,
444− 0x88fe80fc,
445− 0xf480fc00,
446− 0x01f80032,
447−/* 0x05b4: hub_barrier_done */
448− 0x9801f7f0,
449− 0xfebb040e,
450− 0x02ffb904,
451− 0x9418e7f1,
452− 0xf440e3f0,
453− 0x00f89d21,
454−/* 0x05cc: ctx_redswitch */
455− 0xf120f7f0,
385+ 0xb60825b6,
386+ 0x20b60635,
387+ 0x0130b601,
388+ 0xb60824b6,
389+ 0x2fb90834,
390+ 0xd321f502,
391+ 0x002fbb02,
392+ 0xf1003fbb,
393+ 0xf0010007,
394+ 0x03d00203,
395+ 0xbd04bd00,
396+ 0x1f29f024,
397+ 0x300007f1,
398+ 0xd00203f0,
399+ 0x04bd0002,
400+/* 0x0508: main */
401+ 0xf40031f4,
402+ 0xd7f00028,
403+ 0x3921f424,
404+ 0xb0f401f4,
405+ 0x18f404e4,
406+ 0x0181fe1e,
407+ 0xbd0627f0,
408+ 0x0412fd20,
409+ 0xfd01e4b6,
410+ 0x18fe051e,
411+ 0xfd21f500,
412+ 0xd30ef405,
413+/* 0x0538: main_not_ctx_xfer */
414+ 0xf010ef94,
415+ 0x21f501f5,
416+ 0x0ef4037e,
417+/* 0x0545: ih */
418+ 0xfe80f9c6,
419+ 0x80f90188,
420+ 0xa0f990f9,
421+ 0xd0f9b0f9,
422+ 0xf0f9e0f9,
423+ 0xa7f104bd,
424+ 0xa3f00200,
425+ 0x00aacf00,
426+ 0xf404abc4,
427+ 0xd7f02c0b,
428+ 0x00e7f124,
429+ 0x00e3f01a,
430+ 0xf100eecf,
431+ 0xf01900f7,
432+ 0xffcf00f3,
433+ 0x0421f400,
434+ 0xf101e7f0,
435+ 0xf01d0007,
436+ 0x0ed00003,
437+/* 0x0593: ih_no_fifo */
438+ 0xf104bd00,
439+ 0xf0010007,
440+ 0x0ad00003,
441+ 0xfc04bd00,
442+ 0xfce0fcf0,
443+ 0xfcb0fcd0,
444+ 0xfc90fca0,
445+ 0x0088fe80,
446+ 0x32f480fc,
447+/* 0x05b7: hub_barrier_done */
448+ 0xf001f800,
449+ 0x0e9801f7,
450+ 0x04febb04,
451+ 0xf102ffb9,
452+ 0xf09418e7,
453+ 0x21f440e3,
454+/* 0x05cf: ctx_redswitch */
455+ 0xf000f89d,
456+ 0x07f120f7,
457+ 0x03f08500,
458+ 0x000fd001,
459+ 0xe7f004bd,
460+/* 0x05e1: ctx_redswitch_delay */
461+ 0x01e2b608,
462+ 0xf1fd1bf4,
463+ 0xf10800f5,
464+ 0xf10200f5,
456465 0xf0850007,
457466 0x0fd00103,
458− 0xf004bd00,
459−/* 0x05de: ctx_redswitch_delay */
460− 0xe2b608e7,
461− 0xfd1bf401,
462− 0x0800f5f1,
463− 0x0200f5f1,
464− 0x850007f1,
465− 0xd00103f0,
466− 0x04bd000f,
467−/* 0x05fa: ctx_xfer */
468− 0x07f100f8,
469− 0x03f08100,
470− 0x000fd002,
471− 0x11f404bd,
472− 0xcc21f507,
473−/* 0x060d: ctx_xfer_not_load */
474− 0x6a21f505,
475− 0xf124bd02,
476− 0xf047fc07,
477− 0x02d00203,
478− 0xf004bd00,
479− 0x20b6012c,
480− 0xfc07f103,
481− 0x0203f04a,
482− 0xbd0002d0,
483− 0x01acf004,
484− 0xf102a5f0,
485− 0xf00000b7,
486− 0x0c9850b3,
487− 0x0fc4b604,
488− 0x9800bcbb,
489− 0x0d98000c,
490− 0x00e7f001,
491− 0x016f21f5,
492− 0xf101acf0,
493− 0xf04000b7,
494− 0x0c9850b3,
495− 0x0fc4b604,
496− 0x9800bcbb,
497− 0x0d98010c,
498− 0x060f9802,
499− 0x0800e7f1,
500− 0x016f21f5,
467+ 0xf804bd00,
468+/* 0x05fd: ctx_xfer */
469+ 0x0007f100,
470+ 0x0203f081,
471+ 0xbd000fd0,
472+ 0x0711f404,
473+ 0x05cf21f5,
474+/* 0x0610: ctx_xfer_not_load */
475+ 0x026a21f5,
476+ 0x07f124bd,
477+ 0x03f047fc,
478+ 0x0002d002,
479+ 0x2cf004bd,
480+ 0x0320b601,
481+ 0x4afc07f1,
482+ 0xd00203f0,
483+ 0x04bd0002,
501484 0xf001acf0,
502− 0xb7f104a5,
503− 0xb3f03000,
485+ 0xb7f102a5,
486+ 0xb3f00000,
504487 0x040c9850,
505488 0xbb0fc4b6,
506489 0x0c9800bc,
507− 0x030d9802,
508− 0xf1080f98,
509− 0xf50200e7,
510− 0xf5016f21,
511− 0xf4025e21,
512− 0x12f40601,
513−/* 0x06a9: ctx_xfer_post */
514− 0x7f21f507,
515−/* 0x06ad: ctx_xfer_done */
516− 0xb421f502,
517− 0x0000f805,
518− 0x00000000,
490+ 0x010d9800,
491+ 0xf500e7f0,
492+ 0xf0016f21,
493+ 0xb7f101ac,
494+ 0xb3f04000,
495+ 0x040c9850,
496+ 0xbb0fc4b6,
497+ 0x0c9800bc,
498+ 0x020d9801,
499+ 0xf1060f98,
500+ 0xf50800e7,
501+ 0xf0016f21,
502+ 0xa5f001ac,
503+ 0x00b7f104,
504+ 0x50b3f030,
505+ 0xb6040c98,
506+ 0xbcbb0fc4,
507+ 0x020c9800,
508+ 0x98030d98,
509+ 0xe7f1080f,
510+ 0x21f50200,
511+ 0x21f5016f,
512+ 0x01f4025e,
513+ 0x0712f406,
514+/* 0x06ac: ctx_xfer_post */
515+ 0x027f21f5,
516+/* 0x06b0: ctx_xfer_done */
517+ 0x05b721f5,
518+ 0x000000f8,
519519 0x00000000,
520520 0x00000000,
521521 0x00000000,
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgk208.fuc5.h+154−154
@@ -276,7 +276,7 @@ uint32_t gk208_grgpc_code[] = { · 275 unmodified lines
276276 0x02020014,
277277 0xf6120040,
278278 0x04bd0002,
279− 0xfe048141,
279+ 0xfe048441,
280280 0x00400010,
281281 0x0000f607,
282282 0x040204bd,
@@ -295,165 +295,165 @@ uint32_t gk208_grgpc_code[] = { · 12 unmodified lines
295295 0x01c90080,
296296 0xbd0002f6,
297297 0x0c308e04,
298− 0xbd24bd50,
299−/* 0x0383: init_unk_loop */
300− 0x7e44bd34,
301− 0xb0000065,
302− 0x0bf400f6,
303− 0xbb010f0e,
304− 0x4ffd04f2,
305− 0x0130b605,
306−/* 0x0398: init_unk_next */
307− 0xb60120b6,
308− 0x26b004e0,
309− 0xe21bf401,
310−/* 0x03a4: init_unk_done */
311− 0xb50703b5,
312− 0x00820804,
313− 0x22cf0201,
314− 0x9534bd00,
315− 0x00800825,
316− 0x05f601c0,
317− 0x8004bd00,
318− 0xf601c100,
319− 0x04bd0005,
320− 0x98000e98,
321− 0x207e010f,
322− 0x2fbb0001,
323− 0x003fbb00,
324− 0x98010e98,
325− 0x207e020f,
326− 0x0e980001,
327− 0x00effd05,
328− 0xbb002ebb,
329− 0x0e98003e,
330− 0x030f9802,
331− 0x0001207e,
332− 0xfd070e98,
333− 0x2ebb00ef,
334− 0x003ebb00,
335− 0x800235b6,
336− 0xf601d300,
337− 0x04bd0003,
338− 0xb60825b6,
339− 0x20b60635,
340− 0x0130b601,
341− 0xb60824b6,
342− 0x2fb20834,
343− 0x0002687e,
344− 0xbb002fbb,
345− 0x0080003f,
346− 0x03f60201,
347− 0xbd04bd00,
348− 0x1f29f024,
349− 0x02300080,
350− 0xbd0002f6,
351−/* 0x0445: main */
352− 0x0031f404,
353− 0x0d0028f4,
354− 0x00377e24,
355− 0xf401f400,
356− 0xf404e4b0,
357− 0x81fe1d18,
358− 0xbd060201,
359− 0x0412fd20,
360− 0xfd01e4b6,
361− 0x18fe051e,
362− 0x05187e00,
363− 0xd40ef400,
364−/* 0x0474: main_not_ctx_xfer */
365− 0xf010ef94,
366− 0xf87e01f5,
367− 0x0ef40002,
368−/* 0x0481: ih */
369− 0xfe80f9c7,
370− 0x80f90188,
371− 0xa0f990f9,
372− 0xd0f9b0f9,
373− 0xf0f9e0f9,
374− 0x004a04bd,
375− 0x00aacf02,
376− 0xf404abc4,
377− 0x240d1f0b,
378− 0xcf1a004e,
379− 0x004f00ee,
380− 0x00ffcf19,
381− 0x0000047e,
382− 0x0040010e,
383− 0x000ef61d,
384−/* 0x04be: ih_no_fifo */
385− 0x004004bd,
386− 0x000af601,
387− 0xf0fc04bd,
388− 0xd0fce0fc,
389− 0xa0fcb0fc,
390− 0x80fc90fc,
391− 0xfc0088fe,
392− 0x0032f480,
393−/* 0x04de: hub_barrier_done */
394− 0x010f01f8,
395− 0xbb040e98,
396− 0xffb204fe,
397− 0x4094188e,
398− 0x00008f7e,
399−/* 0x04f2: ctx_redswitch */
400− 0x200f00f8,
298+ 0x01e5f050,
299+ 0x34bd24bd,
300+/* 0x0386: init_unk_loop */
301+ 0x657e44bd,
302+ 0xf6b00000,
303+ 0x0e0bf400,
304+ 0xf2bb010f,
305+ 0x054ffd04,
306+/* 0x039b: init_unk_next */
307+ 0xb60130b6,
308+ 0xe0b60120,
309+ 0x0126b004,
310+/* 0x03a7: init_unk_done */
311+ 0xb5e21bf4,
312+ 0x04b50703,
313+ 0x01008208,
314+ 0x0022cf02,
315+ 0x259534bd,
316+ 0xc0008008,
317+ 0x0005f601,
318+ 0x008004bd,
319+ 0x05f601c1,
320+ 0x9804bd00,
321+ 0x0f98000e,
322+ 0x01207e01,
323+ 0x002fbb00,
324+ 0x98003fbb,
325+ 0x0f98010e,
326+ 0x01207e02,
327+ 0x050e9800,
328+ 0xbb00effd,
329+ 0x3ebb002e,
330+ 0x020e9800,
331+ 0x7e030f98,
332+ 0x98000120,
333+ 0xeffd070e,
334+ 0x002ebb00,
335+ 0xb6003ebb,
336+ 0x00800235,
337+ 0x03f601d3,
338+ 0xb604bd00,
339+ 0x35b60825,
340+ 0x0120b606,
341+ 0xb60130b6,
342+ 0x34b60824,
343+ 0x7e2fb208,
344+ 0xbb000268,
345+ 0x3fbb002f,
346+ 0x01008000,
347+ 0x0003f602,
348+ 0x24bd04bd,
349+ 0x801f29f0,
350+ 0xf6023000,
351+ 0x04bd0002,
352+/* 0x0448: main */
353+ 0xf40031f4,
354+ 0x240d0028,
355+ 0x0000377e,
356+ 0xb0f401f4,
357+ 0x18f404e4,
358+ 0x0181fe1d,
359+ 0x20bd0602,
360+ 0xb60412fd,
361+ 0x1efd01e4,
362+ 0x0018fe05,
363+ 0x00051b7e,
364+/* 0x0477: main_not_ctx_xfer */
365+ 0x94d40ef4,
366+ 0xf5f010ef,
367+ 0x02f87e01,
368+ 0xc70ef400,
369+/* 0x0484: ih */
370+ 0x88fe80f9,
371+ 0xf980f901,
372+ 0xf9a0f990,
373+ 0xf9d0f9b0,
374+ 0xbdf0f9e0,
375+ 0x02004a04,
376+ 0xc400aacf,
377+ 0x0bf404ab,
378+ 0x4e240d1f,
379+ 0xeecf1a00,
380+ 0x19004f00,
381+ 0x7e00ffcf,
382+ 0x0e000004,
383+ 0x1d004001,
384+ 0xbd000ef6,
385+/* 0x04c1: ih_no_fifo */
386+ 0x01004004,
387+ 0xbd000af6,
388+ 0xfcf0fc04,
389+ 0xfcd0fce0,
390+ 0xfca0fcb0,
391+ 0xfe80fc90,
392+ 0x80fc0088,
393+ 0xf80032f4,
394+/* 0x04e1: hub_barrier_done */
395+ 0x98010f01,
396+ 0xfebb040e,
397+ 0x8effb204,
398+ 0x7e409418,
399+ 0xf800008f,
400+/* 0x04f5: ctx_redswitch */
401+ 0x80200f00,
402+ 0xf6018500,
403+ 0x04bd000f,
404+/* 0x0502: ctx_redswitch_delay */
405+ 0xe2b6080e,
406+ 0xfd1bf401,
407+ 0x0800f5f1,
408+ 0x0200f5f1,
401409 0x01850080,
402410 0xbd000ff6,
403−/* 0x04ff: ctx_redswitch_delay */
404− 0xb6080e04,
405− 0x1bf401e2,
406− 0x00f5f1fd,
407− 0x00f5f108,
408− 0x85008002,
409− 0x000ff601,
410− 0x00f804bd,
411−/* 0x0518: ctx_xfer */
412− 0x02810080,
413− 0xbd000ff6,
414− 0x0711f404,
415− 0x0004f27e,
416−/* 0x0528: ctx_xfer_not_load */
417− 0x0002167e,
418− 0xfc8024bd,
419− 0x02f60247,
420− 0xf004bd00,
421− 0x20b6012c,
422− 0x4afc8003,
411+/* 0x051b: ctx_xfer */
412+ 0x8000f804,
413+ 0xf6028100,
414+ 0x04bd000f,
415+ 0x7e0711f4,
416+/* 0x052b: ctx_xfer_not_load */
417+ 0x7e0004f5,
418+ 0xbd000216,
419+ 0x47fc8024,
423420 0x0002f602,
424− 0xacf004bd,
425− 0x02a5f001,
426− 0x5000008b,
427− 0xb6040c98,
428− 0xbcbb0fc4,
429− 0x000c9800,
430− 0x0e010d98,
431− 0x013d7e00,
432− 0x01acf000,
433− 0x5040008b,
434− 0xb6040c98,
435− 0xbcbb0fc4,
436− 0x010c9800,
437− 0x98020d98,
438− 0x004e060f,
439− 0x013d7e08,
440− 0x01acf000,
441− 0x8b04a5f0,
442− 0x98503000,
421+ 0x2cf004bd,
422+ 0x0320b601,
423+ 0x024afc80,
424+ 0xbd0002f6,
425+ 0x01acf004,
426+ 0x8b02a5f0,
427+ 0x98500000,
443428 0xc4b6040c,
444429 0x00bcbb0f,
445− 0x98020c98,
446− 0x0f98030d,
447− 0x02004e08,
430+ 0x98000c98,
431+ 0x000e010d,
448432 0x00013d7e,
449− 0x00020a7e,
450− 0xf40601f4,
451−/* 0x05b2: ctx_xfer_post */
452− 0x277e0712,
453−/* 0x05b6: ctx_xfer_done */
454− 0xde7e0002,
455− 0x00f80004,
456− 0x00000000,
433+ 0x8b01acf0,
434+ 0x98504000,
435+ 0xc4b6040c,
436+ 0x00bcbb0f,
437+ 0x98010c98,
438+ 0x0f98020d,
439+ 0x08004e06,
440+ 0x00013d7e,
441+ 0xf001acf0,
442+ 0x008b04a5,
443+ 0x0c985030,
444+ 0x0fc4b604,
445+ 0x9800bcbb,
446+ 0x0d98020c,
447+ 0x080f9803,
448+ 0x7e02004e,
449+ 0x7e00013d,
450+ 0xf400020a,
451+ 0x12f40601,
452+/* 0x05b5: ctx_xfer_post */
453+ 0x02277e07,
454+/* 0x05b9: ctx_xfer_done */
455+ 0x04e17e00,
456+ 0x0000f800,
457457 0x00000000,
458458 0x00000000,
459459 0x00000000,
drivers/gpu/drm/nouveau/nvkm/engine/gr/fuc/gpcgm107.fuc5.h+237−237
@@ -289,7 +289,7 @@ uint32_t gm107_grgpc_code[] = { · 288 unmodified lines
289289 0x020014fe,
290290 0x12004002,
291291 0xbd0002f6,
292− 0x05b04104,
292+ 0x05b34104,
293293 0x400010fe,
294294 0x00f60700,
295295 0x0204bd00,
@@ -308,259 +308,259 @@ uint32_t gm107_grgpc_code[] = { · 12 unmodified lines
308308 0xc900800f,
309309 0x0002f601,
310310 0x308e04bd,
311− 0x24bd500c,
312− 0x44bd34bd,
313−/* 0x03b0: init_unk_loop */
314− 0x0000657e,
315− 0xf400f6b0,
316− 0x010f0e0b,
317− 0xfd04f2bb,
318− 0x30b6054f,
319−/* 0x03c5: init_unk_next */
320− 0x0120b601,
321− 0xb004e0b6,
322− 0x1bf40226,
323−/* 0x03d1: init_unk_done */
324− 0x0703b5e2,
325− 0x820804b5,
326− 0xcf020100,
327− 0x34bd0022,
328− 0x80082595,
329− 0xf601c000,
311+ 0xe5f0500c,
312+ 0xbd24bd01,
313+/* 0x03b3: init_unk_loop */
314+ 0x7e44bd34,
315+ 0xb0000065,
316+ 0x0bf400f6,
317+ 0xbb010f0e,
318+ 0x4ffd04f2,
319+ 0x0130b605,
320+/* 0x03c8: init_unk_next */
321+ 0xb60120b6,
322+ 0x26b004e0,
323+ 0xe21bf402,
324+/* 0x03d4: init_unk_done */
325+ 0xb50703b5,
326+ 0x00820804,
327+ 0x22cf0201,
328+ 0x9534bd00,
329+ 0x00800825,
330+ 0x05f601c0,
331+ 0x8004bd00,
332+ 0xf601c100,
330333 0x04bd0005,
331− 0x01c10080,
332− 0xbd0005f6,
333− 0x000e9804,
334− 0x7e010f98,
335− 0xbb000120,
336− 0x3fbb002f,
337− 0x010e9800,
338− 0x7e020f98,
339− 0x98000120,
340− 0xeffd050e,
341− 0x002ebb00,
342− 0x98003ebb,
343− 0x0f98020e,
344− 0x01207e03,
345− 0x070e9800,
346− 0xbb00effd,
347− 0x3ebb002e,
348− 0x0235b600,
349− 0x01d30080,
350− 0xbd0003f6,
351− 0x0825b604,
352− 0xb60635b6,
353− 0x30b60120,
354− 0x0824b601,
355− 0xb20834b6,
356− 0x02687e2f,
357− 0x002fbb00,
358− 0x0f003fbb,
359− 0x8effb23f,
360− 0xf0501d60,
361− 0x8f7e01e5,
362− 0x0c0f0000,
363− 0xa88effb2,
364− 0xe5f0501d,
365− 0x008f7e01,
366− 0x03147e00,
367− 0xb23f0f00,
368− 0x1d608eff,
369− 0x01e5f050,
370− 0x00008f7e,
371− 0xffb2000f,
372− 0x501d9c8e,
373− 0x7e01e5f0,
374− 0x0f00008f,
375− 0x03147e01,
376− 0x8effb200,
334+ 0x98000e98,
335+ 0x207e010f,
336+ 0x2fbb0001,
337+ 0x003fbb00,
338+ 0x98010e98,
339+ 0x207e020f,
340+ 0x0e980001,
341+ 0x00effd05,
342+ 0xbb002ebb,
343+ 0x0e98003e,
344+ 0x030f9802,
345+ 0x0001207e,
346+ 0xfd070e98,
347+ 0x2ebb00ef,
348+ 0x003ebb00,
349+ 0x800235b6,
350+ 0xf601d300,
351+ 0x04bd0003,
352+ 0xb60825b6,
353+ 0x20b60635,
354+ 0x0130b601,
355+ 0xb60824b6,
356+ 0x2fb20834,
357+ 0x0002687e,
358+ 0xbb002fbb,
359+ 0x3f0f003f,
360+ 0x501d608e,
361+ 0xb201e5f0,
362+ 0x008f7eff,
363+ 0x8e0c0f00,
377364 0xf0501da8,
378− 0x8f7e01e5,
379− 0xff0f0000,
380− 0x988effb2,
365+ 0xffb201e5,
366+ 0x00008f7e,
367+ 0x0003147e,
368+ 0x608e3f0f,
381369 0xe5f0501d,
382− 0x008f7e01,
383− 0xb2020f00,
384− 0x1da88eff,
370+ 0x7effb201,
371+ 0x0f00008f,
372+ 0x1d9c8e00,
385373 0x01e5f050,
386− 0x00008f7e,
374+ 0x8f7effb2,
375+ 0x010f0000,
387376 0x0003147e,
388− 0x85050498,
389− 0x98504000,
390− 0x64b60406,
391− 0x0056bb0f,
392−/* 0x04e0: tpc_strand_init_tpc_loop */
393− 0x05705eb8,
394− 0x00657e00,
395− 0xbdf6b200,
396−/* 0x04ed: tpc_strand_init_idx_loop */
397− 0x605eb874,
398− 0x7fb20005,
399− 0x00008f7e,
400− 0x05885eb8,
401− 0x082f9500,
402− 0x00008f7e,
403− 0x058c5eb8,
404− 0x082f9500,
377+ 0x501da88e,
378+ 0xb201e5f0,
379+ 0x008f7eff,
380+ 0x8eff0f00,
381+ 0xf0501d98,
382+ 0xffb201e5,
405383 0x00008f7e,
406− 0x05905eb8,
407− 0x00657e00,
408− 0x06f5b600,
409− 0xb601f0b6,
410− 0x2fbb08f4,
411− 0x003fbb00,
412− 0xb60170b6,
413− 0x1bf40162,
414− 0x0050b7bf,
415− 0x0142b608,
416− 0x0fa81bf4,
417− 0x8effb23f,
418− 0xf0501d60,
419− 0x8f7e01e5,
420− 0x0d0f0000,
421− 0xa88effb2,
384+ 0xa88e020f,
422385 0xe5f0501d,
423− 0x008f7e01,
424− 0x03147e00,
425− 0x01008000,
426− 0x0003f602,
427− 0x24bd04bd,
428− 0x801f29f0,
429− 0xf6023000,
430− 0x04bd0002,
431−/* 0x0574: main */
432− 0xf40031f4,
433− 0x240d0028,
434− 0x0000377e,
435− 0xb0f401f4,
436− 0x18f404e4,
437− 0x0181fe1d,
438− 0x20bd0602,
439− 0xb60412fd,
440− 0x1efd01e4,
441− 0x0018fe05,
442− 0x0006477e,
443−/* 0x05a3: main_not_ctx_xfer */
444− 0x94d40ef4,
445− 0xf5f010ef,
446− 0x02f87e01,
447− 0xc70ef400,
448−/* 0x05b0: ih */
449− 0x88fe80f9,
450− 0xf980f901,
451− 0xf9a0f990,
452− 0xf9d0f9b0,
453− 0xbdf0f9e0,
454− 0x02004a04,
455− 0xc400aacf,
456− 0x0bf404ab,
457− 0x4e240d1f,
458− 0xeecf1a00,
459− 0x19004f00,
460− 0x7e00ffcf,
461− 0x0e000004,
462− 0x1d004001,
463− 0xbd000ef6,
464−/* 0x05ed: ih_no_fifo */
465− 0x01004004,
466− 0xbd000af6,
467− 0xfcf0fc04,
468− 0xfcd0fce0,
469− 0xfca0fcb0,
470− 0xfe80fc90,
471− 0x80fc0088,
472− 0xf80032f4,
473−/* 0x060d: hub_barrier_done */
474− 0x98010f01,
475− 0xfebb040e,
476− 0x8effb204,
477− 0x7e409418,
478− 0xf800008f,
479−/* 0x0621: ctx_redswitch */
480− 0x80200f00,
386+ 0x7effb201,
387+ 0x7e00008f,
388+ 0x98000314,
389+ 0x00850504,
390+ 0x06985040,
391+ 0x0f64b604,
392+/* 0x04e3: tpc_strand_init_tpc_loop */
393+ 0xb80056bb,
394+ 0x0005705e,
395+ 0x0000657e,
396+ 0x74bdf6b2,
397+/* 0x04f0: tpc_strand_init_idx_loop */
398+ 0x05605eb8,
399+ 0x7e7fb200,
400+ 0xb800008f,
401+ 0x0005885e,
402+ 0x7e082f95,
403+ 0xb800008f,
404+ 0x00058c5e,
405+ 0x7e082f95,
406+ 0xb800008f,
407+ 0x0005905e,
408+ 0x0000657e,
409+ 0xb606f5b6,
410+ 0xf4b601f0,
411+ 0x002fbb08,
412+ 0xb6003fbb,
413+ 0x62b60170,
414+ 0xbf1bf401,
415+ 0x080050b7,
416+ 0xf40142b6,
417+ 0x3f0fa81b,
418+ 0x501d608e,
419+ 0xb201e5f0,
420+ 0x008f7eff,
421+ 0x8e0d0f00,
422+ 0xf0501da8,
423+ 0xffb201e5,
424+ 0x00008f7e,
425+ 0x0003147e,
426+ 0x02010080,
427+ 0xbd0003f6,
428+ 0xf024bd04,
429+ 0x00801f29,
430+ 0x02f60230,
431+/* 0x0577: main */
432+ 0xf404bd00,
433+ 0x28f40031,
434+ 0x7e240d00,
435+ 0xf4000037,
436+ 0xe4b0f401,
437+ 0x1d18f404,
438+ 0x020181fe,
439+ 0xfd20bd06,
440+ 0xe4b60412,
441+ 0x051efd01,
442+ 0x7e0018fe,
443+ 0xf400064a,
444+/* 0x05a6: main_not_ctx_xfer */
445+ 0xef94d40e,
446+ 0x01f5f010,
447+ 0x0002f87e,
448+/* 0x05b3: ih */
449+ 0xf9c70ef4,
450+ 0x0188fe80,
451+ 0x90f980f9,
452+ 0xb0f9a0f9,
453+ 0xe0f9d0f9,
454+ 0x04bdf0f9,
455+ 0xcf02004a,
456+ 0xabc400aa,
457+ 0x1f0bf404,
458+ 0x004e240d,
459+ 0x00eecf1a,
460+ 0xcf19004f,
461+ 0x047e00ff,
462+ 0x010e0000,
463+ 0xf61d0040,
464+ 0x04bd000e,
465+/* 0x05f0: ih_no_fifo */
466+ 0xf6010040,
467+ 0x04bd000a,
468+ 0xe0fcf0fc,
469+ 0xb0fcd0fc,
470+ 0x90fca0fc,
471+ 0x88fe80fc,
472+ 0xf480fc00,
473+ 0x01f80032,
474+/* 0x0610: hub_barrier_done */
475+ 0x0e98010f,
476+ 0x04febb04,
477+ 0x188effb2,
478+ 0x8f7e4094,
479+ 0x00f80000,
480+/* 0x0624: ctx_redswitch */
481+ 0x0080200f,
482+ 0x0ff60185,
483+ 0x0e04bd00,
484+/* 0x0631: ctx_redswitch_delay */
485+ 0x01e2b608,
486+ 0xf1fd1bf4,
487+ 0xf10800f5,
488+ 0x800200f5,
481489 0xf6018500,
482490 0x04bd000f,
483−/* 0x062e: ctx_redswitch_delay */
484− 0xe2b6080e,
485− 0xfd1bf401,
486− 0x0800f5f1,
487− 0x0200f5f1,
488− 0x01850080,
489− 0xbd000ff6,
490−/* 0x0647: ctx_xfer */
491− 0x8000f804,
492− 0xf6028100,
493− 0x04bd000f,
494− 0xc48effb2,
495− 0xe5f0501d,
496− 0x008f7e01,
497− 0x0711f400,
498− 0x0006217e,
499−/* 0x0664: ctx_xfer_not_load */
500− 0x0002167e,
501− 0xfc8024bd,
502− 0x02f60247,
503− 0xf004bd00,
504− 0x20b6012c,
505− 0x4afc8003,
491+/* 0x064a: ctx_xfer */
492+ 0x008000f8,
493+ 0x0ff60281,
494+ 0x8e04bd00,
495+ 0xf0501dc4,
496+ 0xffb201e5,
497+ 0x00008f7e,
498+ 0x7e0711f4,
499+/* 0x0667: ctx_xfer_not_load */
500+ 0x7e000624,
501+ 0xbd000216,
502+ 0x47fc8024,
506503 0x0002f602,
507− 0x0c0f04bd,
508− 0xa88effb2,
509− 0xe5f0501d,
510− 0x008f7e01,
511− 0x03147e00,
512− 0xb23f0f00,
513− 0x1d608eff,
514− 0x01e5f050,
504+ 0x2cf004bd,
505+ 0x0320b601,
506+ 0x024afc80,
507+ 0xbd0002f6,
508+ 0x8e0c0f04,
509+ 0xf0501da8,
510+ 0xffb201e5,
515511 0x00008f7e,
516− 0xffb2000f,
517− 0x501d9c8e,
518− 0x7e01e5f0,
512+ 0x0003147e,
513+ 0x608e3f0f,
514+ 0xe5f0501d,
515+ 0x7effb201,
519516 0x0f00008f,
520− 0x03147e01,
521− 0x01fcf000,
522− 0xb203f0b6,
523− 0x1da88eff,
517+ 0x1d9c8e00,
524518 0x01e5f050,
525− 0x00008f7e,
526− 0xf001acf0,
527− 0x008b02a5,
528− 0x0c985000,
529− 0x0fc4b604,
530− 0x9800bcbb,
531− 0x0d98000c,
532− 0x7e000e01,
533− 0xf000013d,
534− 0x008b01ac,
535− 0x0c985040,
536− 0x0fc4b604,
537− 0x9800bcbb,
538− 0x0d98010c,
539− 0x060f9802,
540− 0x7e08004e,
541− 0xf000013d,
519+ 0x8f7effb2,
520+ 0x010f0000,
521+ 0x0003147e,
522+ 0xb601fcf0,
523+ 0xa88e03f0,
524+ 0xe5f0501d,
525+ 0x7effb201,
526+ 0xf000008f,
542527 0xa5f001ac,
543− 0x30008b04,
528+ 0x00008b02,
544529 0x040c9850,
545530 0xbb0fc4b6,
546531 0x0c9800bc,
547− 0x030d9802,
548− 0x4e080f98,
549− 0x3d7e0200,
550− 0x0a7e0001,
551− 0x147e0002,
552− 0x01f40003,
553− 0x1a12f406,
554−/* 0x073c: ctx_xfer_post */
555− 0x0002277e,
556− 0xffb20d0f,
557− 0x501da88e,
558− 0x7e01e5f0,
559− 0x7e00008f,
560−/* 0x0753: ctx_xfer_done */
561− 0x7e000314,
562− 0xf800060d,
563− 0x00000000,
532+ 0x010d9800,
533+ 0x3d7e000e,
534+ 0xacf00001,
535+ 0x40008b01,
536+ 0x040c9850,
537+ 0xbb0fc4b6,
538+ 0x0c9800bc,
539+ 0x020d9801,
540+ 0x4e060f98,
541+ 0x3d7e0800,
542+ 0xacf00001,
543+ 0x04a5f001,
544+ 0x5030008b,
545+ 0xb6040c98,
546+ 0xbcbb0fc4,
547+ 0x020c9800,
548+ 0x98030d98,
549+ 0x004e080f,
550+ 0x013d7e02,
551+ 0x020a7e00,
552+ 0x03147e00,
553+ 0x0601f400,
554+/* 0x073f: ctx_xfer_post */
555+ 0x7e1a12f4,
556+ 0x0f000227,
557+ 0x1da88e0d,
558+ 0x01e5f050,
559+ 0x8f7effb2,
560+ 0x147e0000,
561+/* 0x0756: ctx_xfer_done */
562+ 0x107e0003,
563+ 0x00f80006,
564564 0x00000000,
565565 0x00000000,
566566 0x00000000,
drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c+4−2
@@ -143,7 +143,7 @@ gf100_gr_zbc_depth_get(struct gf100_gr *gr, int format, · 142 unmodified lines
143143 static int
144144 gf100_fermi_mthd_zbc_color(struct nvkm_object *object, void *data, u32 size)
145145 {
146− struct gf100_gr *gr = (void *)object->engine;
146+ struct gf100_gr *gr = gf100_gr(nvkm_gr(object->engine));
147147 union {
148148 struct fermi_a_zbc_color_v0 v0;
149149 } *args = data;
@@ -189,7 +189,7 @@ gf100_fermi_mthd_zbc_color(struct nvkm_object *object, void *data, u32 size) · 39 unmodified lines
189189 static int
190190 gf100_fermi_mthd_zbc_depth(struct nvkm_object *object, void *data, u32 size)
191191 {
192− struct gf100_gr *gr = (void *)object->engine;
192+ struct gf100_gr *gr = gf100_gr(nvkm_gr(object->engine));
193193 union {
194194 struct fermi_a_zbc_depth_v0 v0;
195195 } *args = data;
@@ -1530,6 +1530,8 @@ gf100_gr_oneinit(struct nvkm_gr *base) · 1334 unmodified lines
15301530 gr->ppc_nr[i] = gr->func->ppc_nr;
15311531 for (j = 0; j < gr->ppc_nr[i]; j++) {
15321532 u8 mask = nvkm_rd32(device, GPC_UNIT(i, 0x0c30 + (j * 4)));
1533+ if (mask)
1534+ gr->ppc_mask[i] |= (1 << j);
15331535 gr->ppc_tpc_nr[i][j] = hweight8(mask);
15341536 }
15351537 }
drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.h+1−0
@@ -97,6 +97,7 @@ struct gf100_gr { · 96 unmodified lines
9797 u8 tpc_nr[GPC_MAX];
9898 u8 tpc_total;
9999 u8 ppc_nr[GPC_MAX];
100+ u8 ppc_mask[GPC_MAX];
100101 u8 ppc_tpc_nr[GPC_MAX][4];
101102
102103 struct nvkm_memory *unk4188b4;
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/base.c+5−0
@@ -97,7 +97,9 @@ static void * · 96 unmodified lines
9797 nvkm_instobj_dtor(struct nvkm_memory *memory)
9898 {
9999 struct nvkm_instobj *iobj = nvkm_instobj(memory);
100+ spin_lock(&iobj->imem->lock);
100101 list_del(&iobj->head);
102+ spin_unlock(&iobj->imem->lock);
101103 nvkm_memory_del(&iobj->parent);
102104 return iobj;
103105 }
@@ -190,7 +192,9 @@ nvkm_instobj_new(struct nvkm_instmem *imem, u32 size, u32 align, bool zero, · 86 unmodified lines
190192 nvkm_memory_ctor(&nvkm_instobj_func_slow, &iobj->memory);
191193 iobj->parent = memory;
192194 iobj->imem = imem;
195+ spin_lock(&iobj->imem->lock);
193196 list_add_tail(&iobj->head, &imem->list);
197+ spin_unlock(&iobj->imem->lock);
194198 memory = &iobj->memory;
195199 }
196200
@@ -309,5 +313,6 @@ nvkm_instmem_ctor(const struct nvkm_instmem_func *func, · 112 unmodified lines
309313 {
310314 nvkm_subdev_ctor(&nvkm_instmem, device, index, 0, &imem->subdev);
311315 imem->func = func;
316+ spin_lock_init(&imem->lock);
312317 INIT_LIST_HEAD(&imem->list);
313318 }
drivers/gpu/drm/nouveau/nvkm/subdev/pmu/gk104.c+1−3
@@ -81,9 +81,7 @@ gk104_pmu_pgob(struct nvkm_pmu *pmu, bool enable) · 80 unmodified lines
8181 nvkm_mask(device, 0x000200, 0x00001000, 0x00001000);
8282 nvkm_rd32(device, 0x000200);
8383
84− if ( nvkm_boolopt(device->cfgopt, "War00C800_0",
85− device->quirk ? device->quirk->War00C800_0 : false)) {
86− nvkm_info(&pmu->subdev, "hw bug workaround enabled\n");
84+ if (nvkm_boolopt(device->cfgopt, "War00C800_0", true)) {
8785 switch (device->chipset) {
8886 case 0xe4:
8987 magic(device, 0x04000000);
drivers/gpu/drm/nouveau/nvkm/subdev/volt/gk104.c+1−1
@@ -59,7 +59,7 @@ gk104_volt_set(struct nvkm_volt *base, u32 uv) · 58 unmodified lines
5959 duty = (uv - bios->base) * div / bios->pwm_range;
6060
6161 nvkm_wr32(device, 0x20340, div);
62− nvkm_wr32(device, 0x20344, 0x8000000 | duty);
62+ nvkm_wr32(device, 0x20344, 0x80000000 | duty);
6363
6464 return 0;
6565 }
drivers/gpu/drm/radeon/cik.c+5−6
@@ -4173,11 +4173,7 @@ void cik_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) · 4172 unmodified lines
41734173 control |= ib->length_dw | (vm_id << 24);
41744174
41754175 radeon_ring_write(ring, header);
4176− radeon_ring_write(ring,
4177−#ifdef __BIG_ENDIAN
4178− (2 << 0) |
4179−#endif
4180− (ib->gpu_addr & 0xFFFFFFFC));
4176+ radeon_ring_write(ring, (ib->gpu_addr & 0xFFFFFFFC));
41814177 radeon_ring_write(ring, upper_32_bits(ib->gpu_addr) & 0xFFFF);
41824178 radeon_ring_write(ring, control);
41834179 }
@@ -8472,7 +8468,7 @@ restart_ih: · 4288 unmodified lines
84728468 if (queue_dp)
84738469 schedule_work(&rdev->dp_work);
84748470 if (queue_hotplug)
8475− schedule_work(&rdev->hotplug_work);
8471+ schedule_delayed_work(&rdev->hotplug_work, 0);
84768472 if (queue_reset) {
84778473 rdev->needs_reset = true;
84788474 wake_up_all(&rdev->fence_queue);
@@ -9630,6 +9626,9 @@ static void dce8_program_watermarks(struct radeon_device *rdev, · 1151 unmodified lines
96309626 (rdev->disp_priority == 2)) {
96319627 DRM_DEBUG_KMS("force priority to high\n");
96329628 }
9629+
9630+ /* Save number of lines the linebuffer leads before the scanout */
9631+ radeon_crtc->lb_vblank_lead_lines = DIV_ROUND_UP(lb_size, mode->crtc_hdisplay);
96339632 }
96349633
96359634 /* select wm A */
drivers/gpu/drm/radeon/evergreen.c+4−1
@@ -2372,6 +2372,9 @@ static void evergreen_program_watermarks(struct radeon_device *rdev, · 2371 unmodified lines
23722372 c.full = dfixed_div(c, a);
23732373 priority_b_mark = dfixed_trunc(c);
23742374 priority_b_cnt |= priority_b_mark & PRIORITY_MARK_MASK;
2375+
2376+ /* Save number of lines the linebuffer leads before the scanout */
2377+ radeon_crtc->lb_vblank_lead_lines = DIV_ROUND_UP(lb_size, mode->crtc_hdisplay);
23752378 }
23762379
23772380 /* select wm A */
@@ -5344,7 +5347,7 @@ restart_ih: · 2966 unmodified lines
53445347 if (queue_dp)
53455348 schedule_work(&rdev->dp_work);
53465349 if (queue_hotplug)
5347− schedule_work(&rdev->hotplug_work);
5350+ schedule_delayed_work(&rdev->hotplug_work, 0);
53485351 if (queue_hdmi)
53495352 schedule_work(&rdev->audio_work);
53505353 if (queue_thermal && rdev->pm.dpm_enabled)
drivers/gpu/drm/radeon/r100.c+11−1
@@ -806,7 +806,7 @@ int r100_irq_process(struct radeon_device *rdev) · 805 unmodified lines
806806 status = r100_irq_ack(rdev);
807807 }
808808 if (queue_hotplug)
809− schedule_work(&rdev->hotplug_work);
809+ schedule_delayed_work(&rdev->hotplug_work, 0);
810810 if (rdev->msi_enabled) {
811811 switch (rdev->family) {
812812 case CHIP_RS400:
@@ -3217,6 +3217,9 @@ void r100_bandwidth_update(struct radeon_device *rdev) · 2404 unmodified lines
32173217 uint32_t pixel_bytes1 = 0;
32183218 uint32_t pixel_bytes2 = 0;
32193219
3220+ /* Guess line buffer size to be 8192 pixels */
3221+ u32 lb_size = 8192;
3222+
32203223 if (!rdev->mode_info.mode_config_initialized)
32213224 return;
32223225
@@ -3631,6 +3634,13 @@ void r100_bandwidth_update(struct radeon_device *rdev) · 408 unmodified lines
36313634 DRM_DEBUG_KMS("GRPH2_BUFFER_CNTL from to %x\n",
36323635 (unsigned int)RREG32(RADEON_GRPH2_BUFFER_CNTL));
36333636 }
3637+
3638+ /* Save number of lines the linebuffer leads before the scanout */
3639+ if (mode1)
3640+ rdev->mode_info.crtcs[0]->lb_vblank_lead_lines = DIV_ROUND_UP(lb_size, mode1->crtc_hdisplay);
3641+
3642+ if (mode2)
3643+ rdev->mode_info.crtcs[1]->lb_vblank_lead_lines = DIV_ROUND_UP(lb_size, mode2->crtc_hdisplay);
36343644 }
36353645
36363646 int r100_ring_test(struct radeon_device *rdev, struct radeon_ring *ring)
drivers/gpu/drm/radeon/r600.c+1−1
@@ -4276,7 +4276,7 @@ restart_ih: · 4275 unmodified lines
42764276 WREG32(IH_RB_RPTR, rptr);
42774277 }
42784278 if (queue_hotplug)
4279− schedule_work(&rdev->hotplug_work);
4279+ schedule_delayed_work(&rdev->hotplug_work, 0);
42804280 if (queue_hdmi)
42814281 schedule_work(&rdev->audio_work);
42824282 if (queue_thermal && rdev->pm.dpm_enabled)
drivers/gpu/drm/radeon/radeon.h+1−1
@@ -2414,7 +2414,7 @@ struct radeon_device { · 2413 unmodified lines
24142414 struct r600_ih ih; /* r6/700 interrupt ring */
24152415 struct radeon_rlc rlc;
24162416 struct radeon_mec mec;
2417− struct work_struct hotplug_work;
2417+ struct delayed_work hotplug_work;
24182418 struct work_struct dp_work;
24192419 struct work_struct audio_work;
24202420 int num_crtc; /* number of crtcs */
drivers/gpu/drm/radeon/radeon_agp.c+3−0
@@ -54,6 +54,9 @@ static struct radeon_agpmode_quirk radeon_agpmode_quirk_list[] = { · 53 unmodified lines
5454 /* Intel 82855PM host bridge / Mobility 9600 M10 RV350 Needs AGPMode 1 (lp #195051) */
5555 { PCI_VENDOR_ID_INTEL, 0x3340, PCI_VENDOR_ID_ATI, 0x4e50,
5656 PCI_VENDOR_ID_IBM, 0x0550, 1},
57+ /* Intel 82855PM host bridge / RV250/M9 GL [Mobility FireGL 9000/Radeon 9000] needs AGPMode 1 (Thinkpad T40p) */
58+ { PCI_VENDOR_ID_INTEL, 0x3340, PCI_VENDOR_ID_ATI, 0x4c66,
59+ PCI_VENDOR_ID_IBM, 0x054d, 1},
5760 /* Intel 82855PM host bridge / Mobility M7 needs AGPMode 1 */
5861 { PCI_VENDOR_ID_INTEL, 0x3340, PCI_VENDOR_ID_ATI, 0x4c57,
5962 PCI_VENDOR_ID_IBM, 0x0530, 1},
drivers/gpu/drm/radeon/radeon_connectors.c+20−1
@@ -1234,13 +1234,32 @@ radeon_dvi_detect(struct drm_connector *connector, bool force) · 1233 unmodified lines
12341234 if (r < 0)
12351235 return connector_status_disconnected;
12361236
1237+ if (radeon_connector->detected_hpd_without_ddc) {
1238+ force = true;
1239+ radeon_connector->detected_hpd_without_ddc = false;
1240+ }
1241+
12371242 if (!force && radeon_check_hpd_status_unchanged(connector)) {
12381243 ret = connector->status;
12391244 goto exit;
12401245 }
12411246
1242− if (radeon_connector->ddc_bus)
1247+ if (radeon_connector->ddc_bus) {
12431248 dret = radeon_ddc_probe(radeon_connector, false);
1249+
1250+ /* Sometimes the pins required for the DDC probe on DVI
1251+ * connectors don't make contact at the same time that the ones
1252+ * for HPD do. If the DDC probe fails even though we had an HPD
1253+ * signal, try again later */
1254+ if (!dret && !force &&
1255+ connector->status != connector_status_connected) {
1256+ DRM_DEBUG_KMS("hpd detected without ddc, retrying in 1 second\n");
1257+ radeon_connector->detected_hpd_without_ddc = true;
1258+ schedule_delayed_work(&rdev->hotplug_work,
1259+ msecs_to_jiffies(1000));
1260+ goto exit;
1261+ }
1262+ }
12441263 if (dret) {
12451264 radeon_connector->detected_by_load = false;
12461265 radeon_connector_free_edid(connector);
drivers/gpu/drm/radeon/radeon_display.c+79−27
@@ -322,7 +322,9 @@ void radeon_crtc_handle_vblank(struct radeon_device *rdev, int crtc_id) · 321 unmodified lines
322322 * to complete in this vblank?
323323 */
324324 if (update_pending &&
325− (DRM_SCANOUTPOS_VALID & radeon_get_crtc_scanoutpos(rdev->ddev, crtc_id, 0,
325+ (DRM_SCANOUTPOS_VALID & radeon_get_crtc_scanoutpos(rdev->ddev,
326+ crtc_id,
327+ USE_REAL_VBLANKSTART,
326328 &vpos, &hpos, NULL, NULL,
327329 &rdev->mode_info.crtcs[crtc_id]->base.hwmode)) &&
328330 ((vpos >= (99 * rdev->mode_info.crtcs[crtc_id]->base.hwmode.crtc_vdisplay)/100) ||
@@ -401,6 +403,8 @@ static void radeon_flip_work_func(struct work_struct *__work) · 72 unmodified lines
401403 struct drm_crtc *crtc = &radeon_crtc->base;
402404 unsigned long flags;
403405 int r;
406+ int vpos, hpos, stat, min_udelay;
407+ struct drm_vblank_crtc *vblank = &crtc->dev->vblank[work->crtc_id];
404408
405409 down_read(&rdev->exclusive_lock);
406410 if (work->fence) {
@@ -437,6 +441,41 @@ static void radeon_flip_work_func(struct work_struct *__work) · 30 unmodified lines
437441 /* set the proper interrupt */
438442 radeon_irq_kms_pflip_irq_get(rdev, radeon_crtc->crtc_id);
439443
444+ /* If this happens to execute within the "virtually extended" vblank
445+ * interval before the start of the real vblank interval then it needs
446+ * to delay programming the mmio flip until the real vblank is entered.
447+ * This prevents completing a flip too early due to the way we fudge
448+ * our vblank counter and vblank timestamps in order to work around the
449+ * problem that the hw fires vblank interrupts before actual start of
450+ * vblank (when line buffer refilling is done for a frame). It
451+ * complements the fudging logic in radeon_get_crtc_scanoutpos() for
452+ * timestamping and radeon_get_vblank_counter_kms() for vblank counts.
453+ *
454+ * In practice this won't execute very often unless on very fast
455+ * machines because the time window for this to happen is very small.
456+ */
457+ for (;;) {
458+ /* GET_DISTANCE_TO_VBLANKSTART returns distance to real vblank
459+ * start in hpos, and to the "fudged earlier" vblank start in
460+ * vpos.
461+ */
462+ stat = radeon_get_crtc_scanoutpos(rdev->ddev, work->crtc_id,
463+ GET_DISTANCE_TO_VBLANKSTART,
464+ &vpos, &hpos, NULL, NULL,
465+ &crtc->hwmode);
466+
467+ if ((stat & (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE)) !=
468+ (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE) ||
469+ !(vpos >= 0 && hpos <= 0))
470+ break;
471+
472+ /* Sleep at least until estimated real start of hw vblank */
473+ spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
474+ min_udelay = (-hpos + 1) * max(vblank->linedur_ns / 1000, 5);
475+ usleep_range(min_udelay, 2 * min_udelay);
476+ spin_lock_irqsave(&crtc->dev->event_lock, flags);
477+ };
478+
440479 /* do the flip (mmio) */
441480 radeon_page_flip(rdev, radeon_crtc->crtc_id, work->base);
442481
@@ -1768,6 +1807,15 @@ bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc, · 1325 unmodified lines
17681807 * \param dev Device to query.
17691808 * \param crtc Crtc to query.
17701809 * \param flags Flags from caller (DRM_CALLED_FROM_VBLIRQ or 0).
1810+ * For driver internal use only also supports these flags:
1811+ *
1812+ * USE_REAL_VBLANKSTART to use the real start of vblank instead
1813+ * of a fudged earlier start of vblank.
1814+ *
1815+ * GET_DISTANCE_TO_VBLANKSTART to return distance to the
1816+ * fudged earlier start of vblank in *vpos and the distance
1817+ * to true start of vblank in *hpos.
1818+ *
17711819 * \param *vpos Location where vertical scanout position should be stored.
17721820 * \param *hpos Location where horizontal scanout position should go.
17731821 * \param *stime Target location for timestamp taken immediately before
@@ -1911,10 +1959,40 @@ int radeon_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe, · 137 unmodified lines
19111959 vbl_end = 0;
19121960 }
19131961
1962+ /* Called from driver internal vblank counter query code? */
1963+ if (flags & GET_DISTANCE_TO_VBLANKSTART) {
1964+ /* Caller wants distance from real vbl_start in *hpos */
1965+ *hpos = *vpos - vbl_start;
1966+ }
1967+
1968+ /* Fudge vblank to start a few scanlines earlier to handle the
1969+ * problem that vblank irqs fire a few scanlines before start
1970+ * of vblank. Some driver internal callers need the true vblank
1971+ * start to be used and signal this via the USE_REAL_VBLANKSTART flag.
1972+ *
1973+ * The cause of the "early" vblank irq is that the irq is triggered
1974+ * by the line buffer logic when the line buffer read position enters
1975+ * the vblank, whereas our crtc scanout position naturally lags the
1976+ * line buffer read position.
1977+ */
1978+ if (!(flags & USE_REAL_VBLANKSTART))
1979+ vbl_start -= rdev->mode_info.crtcs[pipe]->lb_vblank_lead_lines;
1980+
19141981 /* Test scanout position against vblank region. */
19151982 if ((*vpos < vbl_start) && (*vpos >= vbl_end))
19161983 in_vbl = false;
19171984
1985+ /* In vblank? */
1986+ if (in_vbl)
1987+ ret |= DRM_SCANOUTPOS_IN_VBLANK;
1988+
1989+ /* Called from driver internal vblank counter query code? */
1990+ if (flags & GET_DISTANCE_TO_VBLANKSTART) {
1991+ /* Caller wants distance from fudged earlier vbl_start */
1992+ *vpos -= vbl_start;
1993+ return ret;
1994+ }
1995+
19181996 /* Check if inside vblank area and apply corrective offsets:
19191997 * vpos will then be >=0 in video scanout area, but negative
19201998 * within vblank area, counting down the number of lines until
@@ -1930,31 +2008,5 @@ int radeon_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe, · 9 unmodified lines
19302008 /* Correct for shifted end of vbl at vbl_end. */
19312009 *vpos = *vpos - vbl_end;
19322010
1933− /* In vblank? */
1934− if (in_vbl)
1935− ret |= DRM_SCANOUTPOS_IN_VBLANK;
1936−
1937− /* Is vpos outside nominal vblank area, but less than
1938− * 1/100 of a frame height away from start of vblank?
1939− * If so, assume this isn't a massively delayed vblank
1940− * interrupt, but a vblank interrupt that fired a few
1941− * microseconds before true start of vblank. Compensate
1942− * by adding a full frame duration to the final timestamp.
1943− * Happens, e.g., on ATI R500, R600.
1944− *
1945− * We only do this if DRM_CALLED_FROM_VBLIRQ.
1946− */
1947− if ((flags & DRM_CALLED_FROM_VBLIRQ) && !in_vbl) {
1948− vbl_start = mode->crtc_vdisplay;
1949− vtotal = mode->crtc_vtotal;
1950−
1951− if (vbl_start - *vpos < vtotal / 100) {
1952− *vpos -= vtotal;
1953−
1954− /* Signal this correction as "applied". */
1955− ret |= 0x8;
1956− }
1957− }
1958−
19592011 return ret;
19602012 }
drivers/gpu/drm/radeon/radeon_irq_kms.c+4−4
@@ -74,7 +74,7 @@ irqreturn_t radeon_driver_irq_handler_kms(int irq, void *arg) · 73 unmodified lines
7474 static void radeon_hotplug_work_func(struct work_struct *work)
7575 {
7676 struct radeon_device *rdev = container_of(work, struct radeon_device,
77− hotplug_work);
77+ hotplug_work.work);
7878 struct drm_device *dev = rdev->ddev;
7979 struct drm_mode_config *mode_config = &dev->mode_config;
8080 struct drm_connector *connector;
@@ -302,7 +302,7 @@ int radeon_irq_kms_init(struct radeon_device *rdev) · 221 unmodified lines
302302 }
303303 }
304304
305− INIT_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
305+ INIT_DELAYED_WORK(&rdev->hotplug_work, radeon_hotplug_work_func);
306306 INIT_WORK(&rdev->dp_work, radeon_dp_work_func);
307307 INIT_WORK(&rdev->audio_work, r600_audio_update_hdmi);
308308
@@ -310,7 +310,7 @@ int radeon_irq_kms_init(struct radeon_device *rdev) · 1 unmodified line
310310 r = drm_irq_install(rdev->ddev, rdev->ddev->pdev->irq);
311311 if (r) {
312312 rdev->irq.installed = false;
313− flush_work(&rdev->hotplug_work);
313+ flush_delayed_work(&rdev->hotplug_work);
314314 return r;
315315 }
316316
@@ -333,7 +333,7 @@ void radeon_irq_kms_fini(struct radeon_device *rdev) · 16 unmodified lines
333333 rdev->irq.installed = false;
334334 if (rdev->msi_enabled)
335335 pci_disable_msi(rdev->pdev);
336− flush_work(&rdev->hotplug_work);
336+ flush_delayed_work(&rdev->hotplug_work);
337337 }
338338 }
339339
drivers/gpu/drm/radeon/radeon_kms.c+49−1
@@ -755,6 +755,8 @@ void radeon_driver_preclose_kms(struct drm_device *dev, · 754 unmodified lines
755755 */
756756 u32 radeon_get_vblank_counter_kms(struct drm_device *dev, int crtc)
757757 {
758+ int vpos, hpos, stat;
759+ u32 count;
758760 struct radeon_device *rdev = dev->dev_private;
759761
760762 if (crtc < 0 || crtc >= rdev->num_crtc) {
@@ -762,7 +764,53 @@ u32 radeon_get_vblank_counter_kms(struct drm_device *dev, int crtc) · 1 unmodified line
762764 return -EINVAL;
763765 }
764766
765− return radeon_get_vblank_counter(rdev, crtc);
767+ /* The hw increments its frame counter at start of vsync, not at start
768+ * of vblank, as is required by DRM core vblank counter handling.
769+ * Cook the hw count here to make it appear to the caller as if it
770+ * incremented at start of vblank. We measure distance to start of
771+ * vblank in vpos. vpos therefore will be >= 0 between start of vblank
772+ * and start of vsync, so vpos >= 0 means to bump the hw frame counter
773+ * result by 1 to give the proper appearance to caller.
774+ */
775+ if (rdev->mode_info.crtcs[crtc]) {
776+ /* Repeat readout if needed to provide stable result if
777+ * we cross start of vsync during the queries.
778+ */
779+ do {
780+ count = radeon_get_vblank_counter(rdev, crtc);
781+ /* Ask radeon_get_crtc_scanoutpos to return vpos as
782+ * distance to start of vblank, instead of regular
783+ * vertical scanout pos.
784+ */
785+ stat = radeon_get_crtc_scanoutpos(
786+ dev, crtc, GET_DISTANCE_TO_VBLANKSTART,
787+ &vpos, &hpos, NULL, NULL,
788+ &rdev->mode_info.crtcs[crtc]->base.hwmode);
789+ } while (count != radeon_get_vblank_counter(rdev, crtc));
790+
791+ if (((stat & (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE)) !=
792+ (DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE))) {
793+ DRM_DEBUG_VBL("Query failed! stat %d\n", stat);
794+ }
795+ else {
796+ DRM_DEBUG_VBL("crtc %d: dist from vblank start %d\n",
797+ crtc, vpos);
798+
799+ /* Bump counter if we are at >= leading edge of vblank,
800+ * but before vsync where vpos would turn negative and
801+ * the hw counter really increments.
802+ */
803+ if (vpos >= 0)
804+ count++;
805+ }
806+ }
807+ else {
808+ /* Fallback to use value as is. */
809+ count = radeon_get_vblank_counter(rdev, crtc);
810+ DRM_DEBUG_VBL("NULL mode info! Returned count may be wrong.\n");
811+ }
812+
813+ return count;
766814 }
767815
768816 /**
drivers/gpu/drm/radeon/radeon_mode.h+5−0
@@ -367,6 +367,7 @@ struct radeon_crtc { · 366 unmodified lines
367367 u32 line_time;
368368 u32 wm_low;
369369 u32 wm_high;
370+ u32 lb_vblank_lead_lines;
370371 struct drm_display_mode hw_mode;
371372 enum radeon_output_csc output_csc;
372373 };
@@ -553,6 +554,7 @@ struct radeon_connector { · 180 unmodified lines
553554 void *con_priv;
554555 bool dac_load_detect;
555556 bool detected_by_load; /* if the connection status was determined by load */
557+ bool detected_hpd_without_ddc; /* if an HPD signal was detected on DVI, but ddc probing failed */
556558 uint16_t connector_object_id;
557559 struct radeon_hpd hpd;
558560 struct radeon_router router;
@@ -686,6 +688,9 @@ struct atom_voltage_table · 127 unmodified lines
686688 struct atom_voltage_table_entry entries[MAX_VOLTAGE_ENTRIES];
687689 };
688690
691+/* Driver internal use only flags of radeon_get_crtc_scanoutpos() */
692+#define USE_REAL_VBLANKSTART (1 << 30)
693+#define GET_DISTANCE_TO_VBLANKSTART (1 << 31)
689694
690695 extern void
691696 radeon_add_atom_connector(struct drm_device *dev,
drivers/gpu/drm/radeon/radeon_pm.c+3−1
@@ -1756,7 +1756,9 @@ static bool radeon_pm_in_vbl(struct radeon_device *rdev) · 1755 unmodified lines
17561756 */
17571757 for (crtc = 0; (crtc < rdev->num_crtc) && in_vbl; crtc++) {
17581758 if (rdev->pm.active_crtcs & (1 << crtc)) {
1759− vbl_status = radeon_get_crtc_scanoutpos(rdev->ddev, crtc, 0,
1759+ vbl_status = radeon_get_crtc_scanoutpos(rdev->ddev,
1760+ crtc,
1761+ USE_REAL_VBLANKSTART,
17601762 &vpos, &hpos, NULL, NULL,
17611763 &rdev->mode_info.crtcs[crtc]->base.hwmode);
17621764 if ((vbl_status & DRM_SCANOUTPOS_VALID) &&
drivers/gpu/drm/radeon/radeon_vce.c+50−50
@@ -361,31 +361,31 @@ int radeon_vce_get_create_msg(struct radeon_device *rdev, int ring, · 360 unmodified lines
361361
362362 /* stitch together an VCE create msg */
363363 ib.length_dw = 0;
364− ib.ptr[ib.length_dw++] = 0x0000000c; /* len */
365− ib.ptr[ib.length_dw++] = 0x00000001; /* session cmd */
366− ib.ptr[ib.length_dw++] = handle;
367−
368− ib.ptr[ib.length_dw++] = 0x00000030; /* len */
369− ib.ptr[ib.length_dw++] = 0x01000001; /* create cmd */
370− ib.ptr[ib.length_dw++] = 0x00000000;
371− ib.ptr[ib.length_dw++] = 0x00000042;
372− ib.ptr[ib.length_dw++] = 0x0000000a;
373− ib.ptr[ib.length_dw++] = 0x00000001;
374− ib.ptr[ib.length_dw++] = 0x00000080;
375− ib.ptr[ib.length_dw++] = 0x00000060;
376− ib.ptr[ib.length_dw++] = 0x00000100;
377− ib.ptr[ib.length_dw++] = 0x00000100;
378− ib.ptr[ib.length_dw++] = 0x0000000c;
379− ib.ptr[ib.length_dw++] = 0x00000000;
380−
381− ib.ptr[ib.length_dw++] = 0x00000014; /* len */
382− ib.ptr[ib.length_dw++] = 0x05000005; /* feedback buffer */
383− ib.ptr[ib.length_dw++] = upper_32_bits(dummy);
384− ib.ptr[ib.length_dw++] = dummy;
385− ib.ptr[ib.length_dw++] = 0x00000001;
364+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x0000000c); /* len */
365+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x00000001); /* session cmd */
366+ ib.ptr[ib.length_dw++] = cpu_to_le32(handle);
367+
368+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x00000030); /* len */
369+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x01000001); /* create cmd */
370+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x00000000);
371+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x00000042);
372+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x0000000a);
373+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x00000001);
374+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x00000080);
375+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x00000060);
376+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x00000100);
377+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x00000100);
378+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x0000000c);
379+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x00000000);
380+
381+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x00000014); /* len */
382+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x05000005); /* feedback buffer */
383+ ib.ptr[ib.length_dw++] = cpu_to_le32(upper_32_bits(dummy));
384+ ib.ptr[ib.length_dw++] = cpu_to_le32(dummy);
385+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x00000001);
386386
387387 for (i = ib.length_dw; i < ib_size_dw; ++i)
388− ib.ptr[i] = 0x0;
388+ ib.ptr[i] = cpu_to_le32(0x0);
389389
390390 r = radeon_ib_schedule(rdev, &ib, NULL, false);
391391 if (r) {
@@ -428,21 +428,21 @@ int radeon_vce_get_destroy_msg(struct radeon_device *rdev, int ring, · 36 unmodified lines
428428
429429 /* stitch together an VCE destroy msg */
430430 ib.length_dw = 0;
431− ib.ptr[ib.length_dw++] = 0x0000000c; /* len */
432− ib.ptr[ib.length_dw++] = 0x00000001; /* session cmd */
433− ib.ptr[ib.length_dw++] = handle;
431+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x0000000c); /* len */
432+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x00000001); /* session cmd */
433+ ib.ptr[ib.length_dw++] = cpu_to_le32(handle);
434434
435− ib.ptr[ib.length_dw++] = 0x00000014; /* len */
436− ib.ptr[ib.length_dw++] = 0x05000005; /* feedback buffer */
437− ib.ptr[ib.length_dw++] = upper_32_bits(dummy);
438− ib.ptr[ib.length_dw++] = dummy;
439− ib.ptr[ib.length_dw++] = 0x00000001;
435+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x00000014); /* len */
436+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x05000005); /* feedback buffer */
437+ ib.ptr[ib.length_dw++] = cpu_to_le32(upper_32_bits(dummy));
438+ ib.ptr[ib.length_dw++] = cpu_to_le32(dummy);
439+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x00000001);
440440
441− ib.ptr[ib.length_dw++] = 0x00000008; /* len */
442− ib.ptr[ib.length_dw++] = 0x02000001; /* destroy cmd */
441+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x00000008); /* len */
442+ ib.ptr[ib.length_dw++] = cpu_to_le32(0x02000001); /* destroy cmd */
443443
444444 for (i = ib.length_dw; i < ib_size_dw; ++i)
445− ib.ptr[i] = 0x0;
445+ ib.ptr[i] = cpu_to_le32(0x0);
446446
447447 r = radeon_ib_schedule(rdev, &ib, NULL, false);
448448 if (r) {
@@ -699,12 +699,12 @@ bool radeon_vce_semaphore_emit(struct radeon_device *rdev, · 250 unmodified lines
699699 {
700700 uint64_t addr = semaphore->gpu_addr;
701701
702− radeon_ring_write(ring, VCE_CMD_SEMAPHORE);
703− radeon_ring_write(ring, (addr >> 3) & 0x000FFFFF);
704− radeon_ring_write(ring, (addr >> 23) & 0x000FFFFF);
705− radeon_ring_write(ring, 0x01003000 | (emit_wait ? 1 : 0));
702+ radeon_ring_write(ring, cpu_to_le32(VCE_CMD_SEMAPHORE));
703+ radeon_ring_write(ring, cpu_to_le32((addr >> 3) & 0x000FFFFF));
704+ radeon_ring_write(ring, cpu_to_le32((addr >> 23) & 0x000FFFFF));
705+ radeon_ring_write(ring, cpu_to_le32(0x01003000 | (emit_wait ? 1 : 0)));
706706 if (!emit_wait)
707− radeon_ring_write(ring, VCE_CMD_END);
707+ radeon_ring_write(ring, cpu_to_le32(VCE_CMD_END));
708708
709709 return true;
710710 }
@@ -719,10 +719,10 @@ bool radeon_vce_semaphore_emit(struct radeon_device *rdev, · 8 unmodified lines
719719 void radeon_vce_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib)
720720 {
721721 struct radeon_ring *ring = &rdev->ring[ib->ring];
722− radeon_ring_write(ring, VCE_CMD_IB);
723− radeon_ring_write(ring, ib->gpu_addr);
724− radeon_ring_write(ring, upper_32_bits(ib->gpu_addr));
725− radeon_ring_write(ring, ib->length_dw);
722+ radeon_ring_write(ring, cpu_to_le32(VCE_CMD_IB));
723+ radeon_ring_write(ring, cpu_to_le32(ib->gpu_addr));
724+ radeon_ring_write(ring, cpu_to_le32(upper_32_bits(ib->gpu_addr)));
725+ radeon_ring_write(ring, cpu_to_le32(ib->length_dw));
726726 }
727727
728728 /**
@@ -738,12 +738,12 @@ void radeon_vce_fence_emit(struct radeon_device *rdev, · 9 unmodified lines
738738 struct radeon_ring *ring = &rdev->ring[fence->ring];
739739 uint64_t addr = rdev->fence_drv[fence->ring].gpu_addr;
740740
741− radeon_ring_write(ring, VCE_CMD_FENCE);
742− radeon_ring_write(ring, addr);
743− radeon_ring_write(ring, upper_32_bits(addr));
744− radeon_ring_write(ring, fence->seq);
745− radeon_ring_write(ring, VCE_CMD_TRAP);
746− radeon_ring_write(ring, VCE_CMD_END);
741+ radeon_ring_write(ring, cpu_to_le32(VCE_CMD_FENCE));
742+ radeon_ring_write(ring, cpu_to_le32(addr));
743+ radeon_ring_write(ring, cpu_to_le32(upper_32_bits(addr)));
744+ radeon_ring_write(ring, cpu_to_le32(fence->seq));
745+ radeon_ring_write(ring, cpu_to_le32(VCE_CMD_TRAP));
746+ radeon_ring_write(ring, cpu_to_le32(VCE_CMD_END));
747747 }
748748
749749 /**
@@ -765,7 +765,7 @@ int radeon_vce_ring_test(struct radeon_device *rdev, struct radeon_ring *ring) · 15 unmodified lines
765765 ring->idx, r);
766766 return r;
767767 }
768− radeon_ring_write(ring, VCE_CMD_END);
768+ radeon_ring_write(ring, cpu_to_le32(VCE_CMD_END));
769769 radeon_ring_unlock_commit(rdev, ring, false);
770770
771771 for (i = 0; i < rdev->usec_timeout; i++) {
drivers/gpu/drm/radeon/rs600.c+1−1
@@ -813,7 +813,7 @@ int rs600_irq_process(struct radeon_device *rdev) · 812 unmodified lines
813813 status = rs600_irq_ack(rdev);
814814 }
815815 if (queue_hotplug)
816− schedule_work(&rdev->hotplug_work);
816+ schedule_delayed_work(&rdev->hotplug_work, 0);
817817 if (queue_hdmi)
818818 schedule_work(&rdev->audio_work);
819819 if (rdev->msi_enabled) {
drivers/gpu/drm/radeon/rs690.c+10−0
@@ -207,6 +207,9 @@ void rs690_line_buffer_adjust(struct radeon_device *rdev, · 206 unmodified lines
207207 {
208208 u32 tmp;
209209
210+ /* Guess line buffer size to be 8192 pixels */
211+ u32 lb_size = 8192;
212+
210213 /*
211214 * Line Buffer Setup
212215 * There is a single line buffer shared by both display controllers.
@@ -243,6 +246,13 @@ void rs690_line_buffer_adjust(struct radeon_device *rdev, · 30 unmodified lines
243246 tmp |= V_006520_DC_LB_MEMORY_SPLIT_D1_1Q_D2_3Q;
244247 }
245248 WREG32(R_006520_DC_LB_MEMORY_SPLIT, tmp);
249+
250+ /* Save number of lines the linebuffer leads before the scanout */
251+ if (mode1)
252+ rdev->mode_info.crtcs[0]->lb_vblank_lead_lines = DIV_ROUND_UP(lb_size, mode1->crtc_hdisplay);
253+
254+ if (mode2)
255+ rdev->mode_info.crtcs[1]->lb_vblank_lead_lines = DIV_ROUND_UP(lb_size, mode2->crtc_hdisplay);
246256 }
247257
248258 struct rs690_watermark {
drivers/gpu/drm/radeon/rv730_dpm.c+1−1
@@ -464,7 +464,7 @@ void rv730_stop_dpm(struct radeon_device *rdev) · 463 unmodified lines
464464 result = rv770_send_msg_to_smc(rdev, PPSMC_MSG_TwoLevelsDisabled);
465465
466466 if (result != PPSMC_Result_OK)
467− DRM_ERROR("Could not force DPM to low\n");
467+ DRM_DEBUG("Could not force DPM to low\n");
468468
469469 WREG32_P(GENERAL_PWRMGT, 0, ~GLOBAL_PWRMGT_EN);
470470
drivers/gpu/drm/radeon/rv770_dpm.c+2−2
@@ -193,7 +193,7 @@ void rv770_stop_dpm(struct radeon_device *rdev) · 192 unmodified lines
193193 result = rv770_send_msg_to_smc(rdev, PPSMC_MSG_TwoLevelsDisabled);
194194
195195 if (result != PPSMC_Result_OK)
196− DRM_ERROR("Could not force DPM to low.\n");
196+ DRM_DEBUG("Could not force DPM to low.\n");
197197
198198 WREG32_P(GENERAL_PWRMGT, 0, ~GLOBAL_PWRMGT_EN);
199199
@@ -1418,7 +1418,7 @@ int rv770_resume_smc(struct radeon_device *rdev) · 1218 unmodified lines
14181418 int rv770_set_sw_state(struct radeon_device *rdev)
14191419 {
14201420 if (rv770_send_msg_to_smc(rdev, PPSMC_MSG_SwitchToSwState) != PPSMC_Result_OK)
1421− return -EINVAL;
1421+ DRM_DEBUG("rv770_set_sw_state failed\n");
14221422 return 0;
14231423 }
14241424
drivers/gpu/drm/radeon/si.c+4−1
@@ -2376,6 +2376,9 @@ static void dce6_program_watermarks(struct radeon_device *rdev, · 2375 unmodified lines
23762376 c.full = dfixed_div(c, a);
23772377 priority_b_mark = dfixed_trunc(c);
23782378 priority_b_cnt |= priority_b_mark & PRIORITY_MARK_MASK;
2379+
2380+ /* Save number of lines the linebuffer leads before the scanout */
2381+ radeon_crtc->lb_vblank_lead_lines = DIV_ROUND_UP(lb_size, mode->crtc_hdisplay);
23792382 }
23802383
23812384 /* select wm A */
@@ -6848,7 +6851,7 @@ restart_ih: · 4466 unmodified lines
68486851 if (queue_dp)
68496852 schedule_work(&rdev->dp_work);
68506853 if (queue_hotplug)
6851− schedule_work(&rdev->hotplug_work);
6854+ schedule_delayed_work(&rdev->hotplug_work, 0);
68526855 if (queue_thermal && rdev->pm.dpm_enabled)
68536856 schedule_work(&rdev->pm.dpm.thermal.work);
68546857 rdev->ih.rptr = rptr;
drivers/gpu/drm/rockchip/rockchip_drm_gem.c+1−0
@@ -67,6 +67,7 @@ static int rockchip_drm_gem_object_mmap(struct drm_gem_object *obj, · 66 unmodified lines
6767 * VM_PFNMAP flag that was set by drm_gem_mmap_obj()/drm_gem_mmap().
6868 */
6969 vma->vm_flags &= ~VM_PFNMAP;
70+ vma->vm_pgoff = 0;
7071
7172 ret = dma_mmap_attrs(drm->dev, vma, rk_obj->kvaddr, rk_obj->dma_addr,
7273 obj->size, &rk_obj->dma_attrs);
drivers/gpu/drm/rockchip/rockchip_drm_vop.c+18−25
@@ -374,6 +374,7 @@ static const struct of_device_id vop_driver_dt_match[] = { · 373 unmodified lines
374374 .data = &rk3288_vop },
375375 {},
376376 };
377+MODULE_DEVICE_TABLE(of, vop_driver_dt_match);
377378
378379 static inline void vop_writel(struct vop *vop, uint32_t offset, uint32_t v)
379380 {
@@ -959,8 +960,8 @@ static int vop_update_plane_event(struct drm_plane *plane, · 579 unmodified lines
959960 val = (dest.y2 - dest.y1 - 1) << 16;
960961 val |= (dest.x2 - dest.x1 - 1) & 0xffff;
961962 VOP_WIN_SET(vop, win, dsp_info, val);
962− val = (dsp_sty - 1) << 16;
963− val |= (dsp_stx - 1) & 0xffff;
963+ val = dsp_sty << 16;
964+ val |= dsp_stx & 0xffff;
964965 VOP_WIN_SET(vop, win, dsp_st, val);
965966 VOP_WIN_SET(vop, win, rb_swap, rb_swap);
966967
@@ -1289,7 +1290,7 @@ static void vop_win_state_complete(struct vop_win *vop_win, · 322 unmodified lines
12891290
12901291 if (state->event) {
12911292 spin_lock_irqsave(&drm->event_lock, flags);
1292− drm_send_vblank_event(drm, -1, state->event);
1293+ drm_crtc_send_vblank_event(crtc, state->event);
12931294 spin_unlock_irqrestore(&drm->event_lock, flags);
12941295 }
12951296
@@ -1575,32 +1576,25 @@ static int vop_initial(struct vop *vop) · 279 unmodified lines
15751576 return PTR_ERR(vop->dclk);
15761577 }
15771578
1578− ret = clk_prepare(vop->hclk);
1579− if (ret < 0) {
1580− dev_err(vop->dev, "failed to prepare hclk\n");
1581− return ret;
1582− }
1583−
15841579 ret = clk_prepare(vop->dclk);
15851580 if (ret < 0) {
15861581 dev_err(vop->dev, "failed to prepare dclk\n");
1587− goto err_unprepare_hclk;
1582+ return ret;
15881583 }
15891584
1590− ret = clk_prepare(vop->aclk);
1585+ /* Enable both the hclk and aclk to setup the vop */
1586+ ret = clk_prepare_enable(vop->hclk);
15911587 if (ret < 0) {
1592− dev_err(vop->dev, "failed to prepare aclk\n");
1588+ dev_err(vop->dev, "failed to prepare/enable hclk\n");
15931589 goto err_unprepare_dclk;
15941590 }
15951591
1596− /*
1597− * enable hclk, so that we can config vop register.
1598− */
1599− ret = clk_enable(vop->hclk);
1592+ ret = clk_prepare_enable(vop->aclk);
16001593 if (ret < 0) {
1601− dev_err(vop->dev, "failed to prepare aclk\n");
1602− goto err_unprepare_aclk;
1594+ dev_err(vop->dev, "failed to prepare/enable aclk\n");
1595+ goto err_disable_hclk;
16031596 }
1597+
16041598 /*
16051599 * do hclk_reset, reset all vop registers.
16061600 */
@@ -1608,7 +1602,7 @@ static int vop_initial(struct vop *vop) · 1 unmodified line
16081602 if (IS_ERR(ahb_rst)) {
16091603 dev_err(vop->dev, "failed to get ahb reset\n");
16101604 ret = PTR_ERR(ahb_rst);
1611− goto err_disable_hclk;
1605+ goto err_disable_aclk;
16121606 }
16131607 reset_control_assert(ahb_rst);
16141608 usleep_range(10, 20);
@@ -1634,26 +1628,25 @@ static int vop_initial(struct vop *vop) · 19 unmodified lines
16341628 if (IS_ERR(vop->dclk_rst)) {
16351629 dev_err(vop->dev, "failed to get dclk reset\n");
16361630 ret = PTR_ERR(vop->dclk_rst);
1637− goto err_unprepare_aclk;
1631+ goto err_disable_aclk;
16381632 }
16391633 reset_control_assert(vop->dclk_rst);
16401634 usleep_range(10, 20);
16411635 reset_control_deassert(vop->dclk_rst);
16421636
16431637 clk_disable(vop->hclk);
1638+ clk_disable(vop->aclk);
16441639
16451640 vop->is_enabled = false;
16461641
16471642 return 0;
16481643
1644+err_disable_aclk:
1645+ clk_disable_unprepare(vop->aclk);
16491646 err_disable_hclk:
1650− clk_disable(vop->hclk);
1651−err_unprepare_aclk:
1652− clk_unprepare(vop->aclk);
1647+ clk_disable_unprepare(vop->hclk);
16531648 err_unprepare_dclk:
16541649 clk_unprepare(vop->dclk);
1655−err_unprepare_hclk:
1656− clk_unprepare(vop->hclk);
16571650 return ret;
16581651 }
16591652
drivers/gpu/drm/ttm/ttm_lock.c+1−1
@@ -180,7 +180,7 @@ int ttm_write_lock(struct ttm_lock *lock, bool interruptible) · 179 unmodified lines
180180 spin_unlock(&lock->lock);
181181 }
182182 } else
183− wait_event(lock->queue, __ttm_read_lock(lock));
183+ wait_event(lock->queue, __ttm_write_lock(lock));
184184
185185 return ret;
186186 }
drivers/gpu/drm/virtio/virtgpu_display.c+1−1
@@ -412,7 +412,7 @@ static const struct drm_connector_funcs virtio_gpu_connector_funcs = { · 411 unmodified lines
412412 .save = virtio_gpu_conn_save,
413413 .restore = virtio_gpu_conn_restore,
414414 .detect = virtio_gpu_conn_detect,
415− .fill_modes = drm_helper_probe_single_connector_modes,
415+ .fill_modes = drm_helper_probe_single_connector_modes_nomerge,
416416 .destroy = virtio_gpu_conn_destroy,
417417 .reset = drm_atomic_helper_connector_reset,
418418 .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c+1−0
@@ -1233,6 +1233,7 @@ static void vmw_master_drop(struct drm_device *dev, · 1232 unmodified lines
12331233
12341234 vmw_fp->locked_master = drm_master_get(file_priv->master);
12351235 ret = ttm_vt_lock(&vmaster->lock, false, vmw_fp->tfile);
1236+ vmw_kms_legacy_hotspot_clear(dev_priv);
12361237 if (unlikely((ret != 0))) {
12371238 DRM_ERROR("Unable to lock TTM at VT switch.\n");
12381239 drm_master_put(&vmw_fp->locked_master);
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h+1−0
@@ -925,6 +925,7 @@ int vmw_kms_present(struct vmw_private *dev_priv, · 924 unmodified lines
925925 uint32_t num_clips);
926926 int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data,
927927 struct drm_file *file_priv);
928+void vmw_kms_legacy_hotspot_clear(struct vmw_private *dev_priv);
928929
929930 int vmw_dumb_create(struct drm_file *file_priv,
930931 struct drm_device *dev,
drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c+1−1
@@ -390,7 +390,7 @@ void *vmw_fifo_reserve_dx(struct vmw_private *dev_priv, uint32_t bytes, · 389 unmodified lines
390390 else if (ctx_id == SVGA3D_INVALID_ID)
391391 ret = vmw_local_fifo_reserve(dev_priv, bytes);
392392 else {
393− WARN_ON("Command buffer has not been allocated.\n");
393+ WARN(1, "Command buffer has not been allocated.\n");
394394 ret = NULL;
395395 }
396396 if (IS_ERR_OR_NULL(ret)) {
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c+51−13
@@ -133,13 +133,19 @@ void vmw_cursor_update_position(struct vmw_private *dev_priv, · 132 unmodified lines
133133 vmw_mmio_write(++count, fifo_mem + SVGA_FIFO_CURSOR_COUNT);
134134 }
135135
136−int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
137− uint32_t handle, uint32_t width, uint32_t height)
136+
137+/*
138+ * vmw_du_crtc_cursor_set2 - Driver cursor_set2 callback.
139+ */
140+int vmw_du_crtc_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv,
141+ uint32_t handle, uint32_t width, uint32_t height,
142+ int32_t hot_x, int32_t hot_y)
138143 {
139144 struct vmw_private *dev_priv = vmw_priv(crtc->dev);
140145 struct vmw_display_unit *du = vmw_crtc_to_du(crtc);
141146 struct vmw_surface *surface = NULL;
142147 struct vmw_dma_buffer *dmabuf = NULL;
148+ s32 hotspot_x, hotspot_y;
143149 int ret;
144150
145151 /*
@@ -151,6 +157,8 @@ int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv, · 5 unmodified lines
151157 */
152158 drm_modeset_unlock_crtc(crtc);
153159 drm_modeset_lock_all(dev_priv->dev);
160+ hotspot_x = hot_x + du->hotspot_x;
161+ hotspot_y = hot_y + du->hotspot_y;
154162
155163 /* A lot of the code assumes this */
156164 if (handle && (width != 64 || height != 64)) {
@@ -187,31 +195,34 @@ int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv, · 30 unmodified lines
187195 vmw_dmabuf_unreference(&du->cursor_dmabuf);
188196
189197 /* setup new image */
198+ ret = 0;
190199 if (surface) {
191200 /* vmw_user_surface_lookup takes one reference */
192201 du->cursor_surface = surface;
193202
194203 du->cursor_surface->snooper.crtc = crtc;
195204 du->cursor_age = du->cursor_surface->snooper.age;
196− vmw_cursor_update_image(dev_priv, surface->snooper.image,
197− 64, 64, du->hotspot_x, du->hotspot_y);
205+ ret = vmw_cursor_update_image(dev_priv, surface->snooper.image,
206+ 64, 64, hotspot_x, hotspot_y);
198207 } else if (dmabuf) {
199208 /* vmw_user_surface_lookup takes one reference */
200209 du->cursor_dmabuf = dmabuf;
201210
202211 ret = vmw_cursor_update_dmabuf(dev_priv, dmabuf, width, height,
203− du->hotspot_x, du->hotspot_y);
212+ hotspot_x, hotspot_y);
204213 } else {
205214 vmw_cursor_update_position(dev_priv, false, 0, 0);
206− ret = 0;
207215 goto out;
208216 }
209217
210− vmw_cursor_update_position(dev_priv, true,
211− du->cursor_x + du->hotspot_x,
212− du->cursor_y + du->hotspot_y);
218+ if (!ret) {
219+ vmw_cursor_update_position(dev_priv, true,
220+ du->cursor_x + hotspot_x,
221+ du->cursor_y + hotspot_y);
222+ du->core_hotspot_x = hot_x;
223+ du->core_hotspot_y = hot_y;
224+ }
213225
214− ret = 0;
215226 out:
216227 drm_modeset_unlock_all(dev_priv->dev);
217228 drm_modeset_lock_crtc(crtc, crtc->cursor);
@@ -239,8 +250,10 @@ int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) · 21 unmodified lines
239250 drm_modeset_lock_all(dev_priv->dev);
240251
241252 vmw_cursor_update_position(dev_priv, shown,
242− du->cursor_x + du->hotspot_x,
243− du->cursor_y + du->hotspot_y);
253+ du->cursor_x + du->hotspot_x +
254+ du->core_hotspot_x,
255+ du->cursor_y + du->hotspot_y +
256+ du->core_hotspot_y);
244257
245258 drm_modeset_unlock_all(dev_priv->dev);
246259 drm_modeset_lock_crtc(crtc, crtc->cursor);
@@ -334,6 +347,29 @@ err_unreserve: · 87 unmodified lines
334347 ttm_bo_unreserve(bo);
335348 }
336349
350+/**
351+ * vmw_kms_legacy_hotspot_clear - Clear legacy hotspots
352+ *
353+ * @dev_priv: Pointer to the device private struct.
354+ *
355+ * Clears all legacy hotspots.
356+ */
357+void vmw_kms_legacy_hotspot_clear(struct vmw_private *dev_priv)
358+{
359+ struct drm_device *dev = dev_priv->dev;
360+ struct vmw_display_unit *du;
361+ struct drm_crtc *crtc;
362+
363+ drm_modeset_lock_all(dev);
364+ drm_for_each_crtc(crtc, dev) {
365+ du = vmw_crtc_to_du(crtc);
366+
367+ du->hotspot_x = 0;
368+ du->hotspot_y = 0;
369+ }
370+ drm_modeset_unlock_all(dev);
371+}
372+
337373 void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv)
338374 {
339375 struct drm_device *dev = dev_priv->dev;
@@ -351,7 +387,9 @@ void vmw_kms_cursor_post_execbuf(struct vmw_private *dev_priv) · 11 unmodified lines
351387 du->cursor_age = du->cursor_surface->snooper.age;
352388 vmw_cursor_update_image(dev_priv,
353389 du->cursor_surface->snooper.image,
354− 64, 64, du->hotspot_x, du->hotspot_y);
390+ 64, 64,
391+ du->hotspot_x + du->core_hotspot_x,
392+ du->hotspot_y + du->core_hotspot_y);
355393 }
356394
357395 mutex_unlock(&dev->mode_config.mutex);
drivers/gpu/drm/vmwgfx/vmwgfx_kms.h+5−2
@@ -159,6 +159,8 @@ struct vmw_display_unit { · 158 unmodified lines
159159
160160 int hotspot_x;
161161 int hotspot_y;
162+ s32 core_hotspot_x;
163+ s32 core_hotspot_y;
162164
163165 unsigned unit;
164166
@@ -193,8 +195,9 @@ void vmw_du_crtc_restore(struct drm_crtc *crtc); · 28 unmodified lines
193195 void vmw_du_crtc_gamma_set(struct drm_crtc *crtc,
194196 u16 *r, u16 *g, u16 *b,
195197 uint32_t start, uint32_t size);
196−int vmw_du_crtc_cursor_set(struct drm_crtc *crtc, struct drm_file *file_priv,
197− uint32_t handle, uint32_t width, uint32_t height);
198+int vmw_du_crtc_cursor_set2(struct drm_crtc *crtc, struct drm_file *file_priv,
199+ uint32_t handle, uint32_t width, uint32_t height,
200+ int32_t hot_x, int32_t hot_y);
198201 int vmw_du_crtc_cursor_move(struct drm_crtc *crtc, int x, int y);
199202 int vmw_du_connector_dpms(struct drm_connector *connector, int mode);
200203 void vmw_du_connector_save(struct drm_connector *connector);
drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c+1−1
@@ -297,7 +297,7 @@ static int vmw_ldu_crtc_set_config(struct drm_mode_set *set) · 296 unmodified lines
297297 static struct drm_crtc_funcs vmw_legacy_crtc_funcs = {
298298 .save = vmw_du_crtc_save,
299299 .restore = vmw_du_crtc_restore,
300− .cursor_set = vmw_du_crtc_cursor_set,
300+ .cursor_set2 = vmw_du_crtc_cursor_set2,
301301 .cursor_move = vmw_du_crtc_cursor_move,
302302 .gamma_set = vmw_du_crtc_gamma_set,
303303 .destroy = vmw_ldu_crtc_destroy,
drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c+1−1
@@ -533,7 +533,7 @@ out_no_fence: · 532 unmodified lines
533533 static struct drm_crtc_funcs vmw_screen_object_crtc_funcs = {
534534 .save = vmw_du_crtc_save,
535535 .restore = vmw_du_crtc_restore,
536− .cursor_set = vmw_du_crtc_cursor_set,
536+ .cursor_set2 = vmw_du_crtc_cursor_set2,
537537 .cursor_move = vmw_du_crtc_cursor_move,
538538 .gamma_set = vmw_du_crtc_gamma_set,
539539 .destroy = vmw_sou_crtc_destroy,
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c+1−1
@@ -1043,7 +1043,7 @@ out_finish: · 1042 unmodified lines
10431043 static struct drm_crtc_funcs vmw_stdu_crtc_funcs = {
10441044 .save = vmw_du_crtc_save,
10451045 .restore = vmw_du_crtc_restore,
1046− .cursor_set = vmw_du_crtc_cursor_set,
1046+ .cursor_set2 = vmw_du_crtc_cursor_set2,
10471047 .cursor_move = vmw_du_crtc_cursor_move,
10481048 .gamma_set = vmw_du_crtc_gamma_set,
10491049 .destroy = vmw_stdu_crtc_destroy,
drivers/gpu/ipu-v3/ipu-common.c+38−31
@@ -28,6 +28,7 @@ · 27 unmodified lines
2828 #include <linux/irqchip/chained_irq.h>
2929 #include <linux/irqdomain.h>
3030 #include <linux/of_device.h>
31+#include <linux/of_graph.h>
3132
3233 #include <drm/drm_fourcc.h>
3334
@@ -993,11 +994,25 @@ static void platform_device_unregister_children(struct platform_device *pdev) · 959 unmodified lines
993994 struct ipu_platform_reg {
994995 struct ipu_client_platformdata pdata;
995996 const char *name;
996− int reg_offset;
997997 };
998998
999+/* These must be in the order of the corresponding device tree port nodes */
9991000 static const struct ipu_platform_reg client_reg[] = {
10001001 {
1002+ .pdata = {
1003+ .csi = 0,
1004+ .dma[0] = IPUV3_CHANNEL_CSI0,
1005+ .dma[1] = -EINVAL,
1006+ },
1007+ .name = "imx-ipuv3-camera",
1008+ }, {
1009+ .pdata = {
1010+ .csi = 1,
1011+ .dma[0] = IPUV3_CHANNEL_CSI1,
1012+ .dma[1] = -EINVAL,
1013+ },
1014+ .name = "imx-ipuv3-camera",
1015+ }, {
10011016 .pdata = {
10021017 .di = 0,
10031018 .dc = 5,
@@ -1015,22 +1030,6 @@ static const struct ipu_platform_reg client_reg[] = { · 11 unmodified lines
10151030 .dma[1] = -EINVAL,
10161031 },
10171032 .name = "imx-ipuv3-crtc",
1018− }, {
1019− .pdata = {
1020− .csi = 0,
1021− .dma[0] = IPUV3_CHANNEL_CSI0,
1022− .dma[1] = -EINVAL,
1023− },
1024− .reg_offset = IPU_CM_CSI0_REG_OFS,
1025− .name = "imx-ipuv3-camera",
1026− }, {
1027− .pdata = {
1028− .csi = 1,
1029− .dma[0] = IPUV3_CHANNEL_CSI1,
1030− .dma[1] = -EINVAL,
1031− },
1032− .reg_offset = IPU_CM_CSI1_REG_OFS,
1033− .name = "imx-ipuv3-camera",
10341033 },
10351034 };
10361035
@@ -1051,22 +1050,30 @@ static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base) · 14 unmodified lines
10511050 for (i = 0; i < ARRAY_SIZE(client_reg); i++) {
10521051 const struct ipu_platform_reg *reg = &client_reg[i];
10531052 struct platform_device *pdev;
1054− struct resource res;
1055−
1056− if (reg->reg_offset) {
1057− memset(&res, 0, sizeof(res));
1058− res.flags = IORESOURCE_MEM;
1059− res.start = ipu_base + ipu->devtype->cm_ofs + reg->reg_offset;
1060− res.end = res.start + PAGE_SIZE - 1;
1061− pdev = platform_device_register_resndata(dev, reg->name,
1062− id++, &res, 1, &reg->pdata, sizeof(reg->pdata));
1063− } else {
1064− pdev = platform_device_register_data(dev, reg->name,
1065− id++, &reg->pdata, sizeof(reg->pdata));
1053+
1054+ pdev = platform_device_alloc(reg->name, id++);
1055+ if (!pdev) {
1056+ ret = -ENOMEM;
1057+ goto err_register;
1058+ }
1059+
1060+ pdev->dev.parent = dev;
1061+
1062+ /* Associate subdevice with the corresponding port node */
1063+ pdev->dev.of_node = of_graph_get_port_by_id(dev->of_node, i);
1064+ if (!pdev->dev.of_node) {
1065+ dev_err(dev, "missing port@%d node in %s\n", i,
1066+ dev->of_node->full_name);
1067+ ret = -ENODEV;
1068+ goto err_register;
10661069 }
10671070
1068− if (IS_ERR(pdev)) {
1069− ret = PTR_ERR(pdev);
1071+ ret = platform_device_add_data(pdev, &reg->pdata,
1072+ sizeof(reg->pdata));
1073+ if (!ret)
1074+ ret = platform_device_add(pdev);
1075+ if (ret) {
1076+ platform_device_put(pdev);
10701077 goto err_register;
10711078 }
10721079 }
drivers/gpu/vga/vgaarb.c+4−2
@@ -395,8 +395,10 @@ int vga_get(struct pci_dev *pdev, unsigned int rsrc, int interruptible) · 394 unmodified lines
395395 set_current_state(interruptible ?
396396 TASK_INTERRUPTIBLE :
397397 TASK_UNINTERRUPTIBLE);
398− if (signal_pending(current)) {
399− rc = -EINTR;
398+ if (interruptible && signal_pending(current)) {
399+ __set_current_state(TASK_RUNNING);
400+ remove_wait_queue(&vga_wait_queue, &wait);
401+ rc = -ERESTARTSYS;
400402 break;
401403 }
402404 schedule();
drivers/hid/hid-ids.h+1−5
@@ -316,11 +316,6 @@ · 315 unmodified lines
316316 #define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001 0xa001
317317
318318 #define USB_VENDOR_ID_ELAN 0x04f3
319−#define USB_DEVICE_ID_ELAN_TOUCHSCREEN 0x0089
320−#define USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B 0x009b
321−#define USB_DEVICE_ID_ELAN_TOUCHSCREEN_0103 0x0103
322−#define USB_DEVICE_ID_ELAN_TOUCHSCREEN_010c 0x010c
323−#define USB_DEVICE_ID_ELAN_TOUCHSCREEN_016F 0x016f
324319
325320 #define USB_VENDOR_ID_ELECOM 0x056e
326321 #define USB_DEVICE_ID_ELECOM_BM084 0x0061
@@ -609,6 +604,7 @@ · 282 unmodified lines
609604 #define USB_DEVICE_ID_LOGITECH_HARMONY_FIRST 0xc110
610605 #define USB_DEVICE_ID_LOGITECH_HARMONY_LAST 0xc14f
611606 #define USB_DEVICE_ID_LOGITECH_HARMONY_PS3 0x0306
607+#define USB_DEVICE_ID_LOGITECH_KEYBOARD_G710_PLUS 0xc24d
612608 #define USB_DEVICE_ID_LOGITECH_MOUSE_C01A 0xc01a
613609 #define USB_DEVICE_ID_LOGITECH_MOUSE_C05A 0xc05a
614610 #define USB_DEVICE_ID_LOGITECH_MOUSE_C06A 0xc06a
drivers/hid/hid-lg.c+3−2
@@ -665,8 +665,9 @@ static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id) · 664 unmodified lines
665665 struct lg_drv_data *drv_data;
666666 int ret;
667667
668− /* Only work with the 1st interface (G29 presents multiple) */
669− if (iface_num != 0) {
668+ /* G29 only work with the 1st interface */
669+ if ((hdev->product == USB_DEVICE_ID_LOGITECH_G29_WHEEL) &&
670+ (iface_num != 0)) {
670671 dbg_hid("%s: ignoring ifnum %d\n", __func__, iface_num);
671672 return -ENODEV;
672673 }
drivers/hid/usbhid/hid-quirks.c+4−6
@@ -72,11 +72,7 @@ static const struct hid_blacklist { · 71 unmodified lines
7272 { USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_PIXART_USB_OPTICAL_MOUSE, HID_QUIRK_ALWAYS_POLL },
7373 { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
7474 { USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_WIIU, HID_QUIRK_MULTI_INPUT },
75− { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN, HID_QUIRK_ALWAYS_POLL },
76− { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_009B, HID_QUIRK_ALWAYS_POLL },
77− { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_0103, HID_QUIRK_ALWAYS_POLL },
78− { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_010c, HID_QUIRK_ALWAYS_POLL },
79− { USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ELAN_TOUCHSCREEN_016F, HID_QUIRK_ALWAYS_POLL },
75+ { USB_VENDOR_ID_ELAN, HID_ANY_ID, HID_QUIRK_ALWAYS_POLL },
8076 { USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_TS2700, HID_QUIRK_NOGET },
8177 { USB_VENDOR_ID_FORMOSA, USB_DEVICE_ID_FORMOSA_IR_RECEIVER, HID_QUIRK_NO_INIT_REPORTS },
8278 { USB_VENDOR_ID_FREESCALE, USB_DEVICE_ID_FREESCALE_MX28, HID_QUIRK_NOGET },
@@ -84,6 +80,7 @@ static const struct hid_blacklist { · 1 unmodified line
8480 { USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_LOGITECH_OEM_USB_OPTICAL_MOUSE_0B4A, HID_QUIRK_ALWAYS_POLL },
8581 { USB_VENDOR_ID_HP, USB_PRODUCT_ID_HP_PIXART_OEM_USB_OPTICAL_MOUSE, HID_QUIRK_ALWAYS_POLL },
8682 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_C077, HID_QUIRK_ALWAYS_POLL },
83+ { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_KEYBOARD_G710_PLUS, HID_QUIRK_NOGET },
8784 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOUSE_C01A, HID_QUIRK_ALWAYS_POLL },
8885 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOUSE_C05A, HID_QUIRK_ALWAYS_POLL },
8986 { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_MOUSE_C06A, HID_QUIRK_ALWAYS_POLL },
@@ -339,7 +336,8 @@ static const struct hid_blacklist *usbhid_exists_squirk(const u16 idVendor, · 249 unmodified lines
339336
340337 for (; hid_blacklist[n].idVendor; n++)
341338 if (hid_blacklist[n].idVendor == idVendor &&
342− hid_blacklist[n].idProduct == idProduct)
339+ (hid_blacklist[n].idProduct == (__u16) HID_ANY_ID ||
340+ hid_blacklist[n].idProduct == idProduct))
343341 bl_entry = &hid_blacklist[n];
344342
345343 if (bl_entry != NULL)
drivers/iio/adc/qcom-spmi-vadc.c+3−1
@@ -839,8 +839,10 @@ static int vadc_get_dt_data(struct vadc_priv *vadc, struct device_node *node) · 838 unmodified lines
839839
840840 for_each_available_child_of_node(node, child) {
841841 ret = vadc_get_dt_channel_data(vadc->dev, &prop, child);
842− if (ret)
842+ if (ret) {
843+ of_node_put(child);
843844 return ret;
845+ }
844846
845847 vadc->chan_props[index] = prop;
846848
drivers/iio/industrialio-buffer.c+1−1
@@ -302,7 +302,7 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev, · 301 unmodified lines
302302 if (trialmask == NULL)
303303 return -ENOMEM;
304304 if (!indio_dev->masklength) {
305− WARN_ON("Trying to set scanmask prior to registering buffer\n");
305+ WARN(1, "Trying to set scanmask prior to registering buffer\n");
306306 goto err_invalid_mask;
307307 }
308308 bitmap_copy(trialmask, buffer->scan_mask, indio_dev->masklength);
drivers/iio/industrialio-core.c+1−1
@@ -655,7 +655,7 @@ int __iio_device_attr_init(struct device_attribute *dev_attr, · 654 unmodified lines
655655 break;
656656 case IIO_SEPARATE:
657657 if (!chan->indexed) {
658− WARN_ON("Differential channels must be indexed\n");
658+ WARN(1, "Differential channels must be indexed\n");
659659 ret = -EINVAL;
660660 goto error_free_full_postfix;
661661 }
drivers/iio/light/apds9960.c+1−0
@@ -453,6 +453,7 @@ static int apds9960_set_power_state(struct apds9960_data *data, bool on) · 452 unmodified lines
453453 usleep_range(data->als_adc_int_us,
454454 APDS9960_MAX_INT_TIME_IN_US);
455455 } else {
456+ pm_runtime_mark_last_busy(dev);
456457 ret = pm_runtime_put_autosuspend(dev);
457458 }
458459
drivers/iio/proximity/pulsedlight-lidar-lite-v2.c+3−3
@@ -130,10 +130,10 @@ static int lidar_get_measurement(struct lidar_data *data, u16 *reg) · 129 unmodified lines
130130 if (ret < 0)
131131 break;
132132
133− /* return 0 since laser is likely pointed out of range */
133+ /* return -EINVAL since laser is likely pointed out of range */
134134 if (ret & LIDAR_REG_STATUS_INVALID) {
135135 *reg = 0;
136− ret = 0;
136+ ret = -EINVAL;
137137 break;
138138 }
139139
@@ -197,7 +197,7 @@ static irqreturn_t lidar_trigger_handler(int irq, void *private) · 57 unmodified lines
197197 if (!ret) {
198198 iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
199199 iio_get_time_ns());
200− } else {
200+ } else if (ret != -EINVAL) {
201201 dev_err(&data->client->dev, "cannot read LIDAR measurement");
202202 }
203203
drivers/infiniband/core/cma.c+1−4
@@ -1126,10 +1126,7 @@ static bool validate_ipv4_net_dev(struct net_device *net_dev, · 1125 unmodified lines
11261126
11271127 rcu_read_lock();
11281128 err = fib_lookup(dev_net(net_dev), &fl4, &res, 0);
1129− if (err)
1130− return false;
1131−
1132− ret = FIB_RES_DEV(res) == net_dev;
1129+ ret = err == 0 && FIB_RES_DEV(res) == net_dev;
11331130 rcu_read_unlock();
11341131
11351132 return ret;
drivers/infiniband/core/mad.c+5−0
@@ -1811,6 +1811,11 @@ static int validate_mad(const struct ib_mad_hdr *mad_hdr, · 1810 unmodified lines
18111811 if (qp_num == 0)
18121812 valid = 1;
18131813 } else {
1814+ /* CM attributes other than ClassPortInfo only use Send method */
1815+ if ((mad_hdr->mgmt_class == IB_MGMT_CLASS_CM) &&
1816+ (mad_hdr->attr_id != IB_MGMT_CLASSPORTINFO_ATTR_ID) &&
1817+ (mad_hdr->method != IB_MGMT_METHOD_SEND))
1818+ goto out;
18141819 /* Filter GSI packets sent to QP0 */
18151820 if (qp_num != 0)
18161821 valid = 1;
drivers/infiniband/core/sa_query.c+17−15
@@ -512,7 +512,7 @@ static int ib_nl_get_path_rec_attrs_len(ib_sa_comp_mask comp_mask) · 511 unmodified lines
512512 return len;
513513 }
514514
515−static int ib_nl_send_msg(struct ib_sa_query *query)
515+static int ib_nl_send_msg(struct ib_sa_query *query, gfp_t gfp_mask)
516516 {
517517 struct sk_buff *skb = NULL;
518518 struct nlmsghdr *nlh;
@@ -526,7 +526,7 @@ static int ib_nl_send_msg(struct ib_sa_query *query) · 7 unmodified lines
526526 if (len <= 0)
527527 return -EMSGSIZE;
528528
529− skb = nlmsg_new(len, GFP_KERNEL);
529+ skb = nlmsg_new(len, gfp_mask);
530530 if (!skb)
531531 return -ENOMEM;
532532
@@ -544,7 +544,7 @@ static int ib_nl_send_msg(struct ib_sa_query *query) · 11 unmodified lines
544544 /* Repair the nlmsg header length */
545545 nlmsg_end(skb, nlh);
546546
547− ret = ibnl_multicast(skb, nlh, RDMA_NL_GROUP_LS, GFP_KERNEL);
547+ ret = ibnl_multicast(skb, nlh, RDMA_NL_GROUP_LS, gfp_mask);
548548 if (!ret)
549549 ret = len;
550550 else
@@ -553,7 +553,7 @@ static int ib_nl_send_msg(struct ib_sa_query *query) · 2 unmodified lines
553553 return ret;
554554 }
555555
556−static int ib_nl_make_request(struct ib_sa_query *query)
556+static int ib_nl_make_request(struct ib_sa_query *query, gfp_t gfp_mask)
557557 {
558558 unsigned long flags;
559559 unsigned long delay;
@@ -562,25 +562,27 @@ static int ib_nl_make_request(struct ib_sa_query *query) · 2 unmodified lines
562562 INIT_LIST_HEAD(&query->list);
563563 query->seq = (u32)atomic_inc_return(&ib_nl_sa_request_seq);
564564
565+ /* Put the request on the list first.*/
565566 spin_lock_irqsave(&ib_nl_request_lock, flags);
566− ret = ib_nl_send_msg(query);
567− if (ret <= 0) {
568− ret = -EIO;
569− goto request_out;
570− } else {
571− ret = 0;
572− }
573−
574567 delay = msecs_to_jiffies(sa_local_svc_timeout_ms);
575568 query->timeout = delay + jiffies;
576569 list_add_tail(&query->list, &ib_nl_request_list);
577570 /* Start the timeout if this is the only request */
578571 if (ib_nl_request_list.next == &query->list)
579572 queue_delayed_work(ib_nl_wq, &ib_nl_timed_work, delay);
580−
581−request_out:
582573 spin_unlock_irqrestore(&ib_nl_request_lock, flags);
583574
575+ ret = ib_nl_send_msg(query, gfp_mask);
576+ if (ret <= 0) {
577+ ret = -EIO;
578+ /* Remove the request */
579+ spin_lock_irqsave(&ib_nl_request_lock, flags);
580+ list_del(&query->list);
581+ spin_unlock_irqrestore(&ib_nl_request_lock, flags);
582+ } else {
583+ ret = 0;
584+ }
585+
584586 return ret;
585587 }
586588
@@ -1108,7 +1110,7 @@ static int send_mad(struct ib_sa_query *query, int timeout_ms, gfp_t gfp_mask) · 521 unmodified lines
11081110
11091111 if (query->flags & IB_SA_ENABLE_LOCAL_SERVICE) {
11101112 if (!ibnl_chk_listeners(RDMA_NL_GROUP_LS)) {
1111− if (!ib_nl_make_request(query))
1113+ if (!ib_nl_make_request(query, gfp_mask))
11121114 return id;
11131115 }
11141116 ib_sa_disable_local_svc(query);
drivers/infiniband/core/uverbs_cmd.c+17−10
@@ -62,9 +62,11 @@ static struct uverbs_lock_class rule_lock_class = { .name = "RULE-uobj" }; · 61 unmodified lines
6262 * The ib_uobject locking scheme is as follows:
6363 *
6464 * - ib_uverbs_idr_lock protects the uverbs idrs themselves, so it
65− * needs to be held during all idr operations. When an object is
65+ * needs to be held during all idr write operations. When an object is
6666 * looked up, a reference must be taken on the object's kref before
67− * dropping this lock.
67+ * dropping this lock. For read operations, the rcu_read_lock()
68+ * and rcu_write_lock() but similarly the kref reference is grabbed
69+ * before the rcu_read_unlock().
6870 *
6971 * - Each object also has an rwsem. This rwsem must be held for
7072 * reading while an operation that uses the object is performed.
@@ -96,7 +98,7 @@ static void init_uobj(struct ib_uobject *uobj, u64 user_handle, · 25 unmodified lines
9698
9799 static void release_uobj(struct kref *kref)
98100 {
99− kfree(container_of(kref, struct ib_uobject, ref));
101+ kfree_rcu(container_of(kref, struct ib_uobject, ref), rcu);
100102 }
101103
102104 static void put_uobj(struct ib_uobject *uobj)
@@ -145,7 +147,7 @@ static struct ib_uobject *__idr_get_uobj(struct idr *idr, int id, · 42 unmodified lines
145147 {
146148 struct ib_uobject *uobj;
147149
148− spin_lock(&ib_uverbs_idr_lock);
150+ rcu_read_lock();
149151 uobj = idr_find(idr, id);
150152 if (uobj) {
151153 if (uobj->context == context)
@@ -153,7 +155,7 @@ static struct ib_uobject *__idr_get_uobj(struct idr *idr, int id, · 1 unmodified line
153155 else
154156 uobj = NULL;
155157 }
156− spin_unlock(&ib_uverbs_idr_lock);
158+ rcu_read_unlock();
157159
158160 return uobj;
159161 }
@@ -2446,6 +2448,7 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, · 2286 unmodified lines
24462448 int i, sg_ind;
24472449 int is_ud;
24482450 ssize_t ret = -EINVAL;
2451+ size_t next_size;
24492452
24502453 if (copy_from_user(&cmd, buf, sizeof cmd))
24512454 return -EFAULT;
@@ -2490,7 +2493,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, · 38 unmodified lines
24902493 goto out_put;
24912494 }
24922495
2493− ud = alloc_wr(sizeof(*ud), user_wr->num_sge);
2496+ next_size = sizeof(*ud);
2497+ ud = alloc_wr(next_size, user_wr->num_sge);
24942498 if (!ud) {
24952499 ret = -ENOMEM;
24962500 goto out_put;
@@ -2511,7 +2515,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, · 14 unmodified lines
25112515 user_wr->opcode == IB_WR_RDMA_READ) {
25122516 struct ib_rdma_wr *rdma;
25132517
2514− rdma = alloc_wr(sizeof(*rdma), user_wr->num_sge);
2518+ next_size = sizeof(*rdma);
2519+ rdma = alloc_wr(next_size, user_wr->num_sge);
25152520 if (!rdma) {
25162521 ret = -ENOMEM;
25172522 goto out_put;
@@ -2525,7 +2530,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, · 7 unmodified lines
25252530 user_wr->opcode == IB_WR_ATOMIC_FETCH_AND_ADD) {
25262531 struct ib_atomic_wr *atomic;
25272532
2528− atomic = alloc_wr(sizeof(*atomic), user_wr->num_sge);
2533+ next_size = sizeof(*atomic);
2534+ atomic = alloc_wr(next_size, user_wr->num_sge);
25292535 if (!atomic) {
25302536 ret = -ENOMEM;
25312537 goto out_put;
@@ -2540,7 +2546,8 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, · 8 unmodified lines
25402546 } else if (user_wr->opcode == IB_WR_SEND ||
25412547 user_wr->opcode == IB_WR_SEND_WITH_IMM ||
25422548 user_wr->opcode == IB_WR_SEND_WITH_INV) {
2543− next = alloc_wr(sizeof(*next), user_wr->num_sge);
2549+ next_size = sizeof(*next);
2550+ next = alloc_wr(next_size, user_wr->num_sge);
25442551 if (!next) {
25452552 ret = -ENOMEM;
25462553 goto out_put;
@@ -2572,7 +2579,7 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file, · 25 unmodified lines
25722579
25732580 if (next->num_sge) {
25742581 next->sg_list = (void *) next +
2575− ALIGN(sizeof *next, sizeof (struct ib_sge));
2582+ ALIGN(next_size, sizeof(struct ib_sge));
25762583 if (copy_from_user(next->sg_list,
25772584 buf + sizeof cmd +
25782585 cmd.wr_count * cmd.wqe_size +
drivers/infiniband/core/verbs.c+22−21
@@ -1516,7 +1516,7 @@ EXPORT_SYMBOL(ib_map_mr_sg); · 1515 unmodified lines
15161516 * @sg_nents: number of entries in sg
15171517 * @set_page: driver page assignment function pointer
15181518 *
1519− * Core service helper for drivers to covert the largest
1519+ * Core service helper for drivers to convert the largest
15201520 * prefix of given sg list to a page vector. The sg list
15211521 * prefix converted is the prefix that meet the requirements
15221522 * of ib_map_mr_sg.
@@ -1533,7 +1533,7 @@ int ib_sg_to_pages(struct ib_mr *mr, · 10 unmodified lines
15331533 u64 last_end_dma_addr = 0, last_page_addr = 0;
15341534 unsigned int last_page_off = 0;
15351535 u64 page_mask = ~((u64)mr->page_size - 1);
1536− int i;
1536+ int i, ret;
15371537
15381538 mr->iova = sg_dma_address(&sgl[0]);
15391539 mr->length = 0;
@@ -1544,27 +1544,29 @@ int ib_sg_to_pages(struct ib_mr *mr, · 4 unmodified lines
15441544 u64 end_dma_addr = dma_addr + dma_len;
15451545 u64 page_addr = dma_addr & page_mask;
15461546
1547− if (i && page_addr != dma_addr) {
1548− if (last_end_dma_addr != dma_addr) {
1549− /* gap */
1550− goto done;
1551−
1552− } else if (last_page_off + dma_len <= mr->page_size) {
1553− /* chunk this fragment with the last */
1554− mr->length += dma_len;
1555− last_end_dma_addr += dma_len;
1556− last_page_off += dma_len;
1557− continue;
1558− } else {
1559− /* map starting from the next page */
1560− page_addr = last_page_addr + mr->page_size;
1561− dma_len -= mr->page_size - last_page_off;
1562− }
1547+ /*
1548+ * For the second and later elements, check whether either the
1549+ * end of element i-1 or the start of element i is not aligned
1550+ * on a page boundary.
1551+ */
1552+ if (i && (last_page_off != 0 || page_addr != dma_addr)) {
1553+ /* Stop mapping if there is a gap. */
1554+ if (last_end_dma_addr != dma_addr)
1555+ break;
1556+
1557+ /*
1558+ * Coalesce this element with the last. If it is small
1559+ * enough just update mr->length. Otherwise start
1560+ * mapping from the next page.
1561+ */
1562+ goto next_page;
15631563 }
15641564
15651565 do {
1566− if (unlikely(set_page(mr, page_addr)))
1567− goto done;
1566+ ret = set_page(mr, page_addr);
1567+ if (unlikely(ret < 0))
1568+ return i ? : ret;
1569+next_page:
15681570 page_addr += mr->page_size;
15691571 } while (page_addr < end_dma_addr);
15701572
@@ -1574,7 +1576,6 @@ int ib_sg_to_pages(struct ib_mr *mr, · 3 unmodified lines
15741576 last_page_off = end_dma_addr & ~page_mask;
15751577 }
15761578
1577−done:
15781579 return i;
15791580 }
15801581 EXPORT_SYMBOL(ib_sg_to_pages);
drivers/infiniband/hw/mlx4/main.c+1−1
@@ -456,7 +456,7 @@ static int mlx4_ib_query_device(struct ib_device *ibdev, · 455 unmodified lines
456456 props->max_qp_wr = dev->dev->caps.max_wqes - MLX4_IB_SQ_MAX_SPARE;
457457 props->max_sge = min(dev->dev->caps.max_sq_sg,
458458 dev->dev->caps.max_rq_sg);
459− props->max_sge_rd = props->max_sge;
459+ props->max_sge_rd = MLX4_MAX_SGE_RD;
460460 props->max_cq = dev->dev->quotas.cq;
461461 props->max_cqe = dev->dev->caps.max_cqes;
462462 props->max_mr = dev->dev->quotas.mpt;
drivers/infiniband/hw/mlx4/qp.c+13−6
@@ -34,6 +34,7 @@ · 33 unmodified lines
3434 #include <linux/log2.h>
3535 #include <linux/slab.h>
3636 #include <linux/netdevice.h>
37+#include <linux/vmalloc.h>
3738
3839 #include <rdma/ib_cache.h>
3940 #include <rdma/ib_pack.h>
@@ -795,8 +796,14 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, · 755 unmodified lines
795796 if (err)
796797 goto err_mtt;
797798
798− qp->sq.wrid = kmalloc(qp->sq.wqe_cnt * sizeof (u64), gfp);
799− qp->rq.wrid = kmalloc(qp->rq.wqe_cnt * sizeof (u64), gfp);
799+ qp->sq.wrid = kmalloc(qp->sq.wqe_cnt * sizeof(u64), gfp);
800+ if (!qp->sq.wrid)
801+ qp->sq.wrid = __vmalloc(qp->sq.wqe_cnt * sizeof(u64),
802+ gfp, PAGE_KERNEL);
803+ qp->rq.wrid = kmalloc(qp->rq.wqe_cnt * sizeof(u64), gfp);
804+ if (!qp->rq.wrid)
805+ qp->rq.wrid = __vmalloc(qp->rq.wqe_cnt * sizeof(u64),
806+ gfp, PAGE_KERNEL);
800807 if (!qp->sq.wrid || !qp->rq.wrid) {
801808 err = -ENOMEM;
802809 goto err_wrid;
@@ -886,8 +893,8 @@ err_wrid: · 83 unmodified lines
886893 if (qp_has_rq(init_attr))
887894 mlx4_ib_db_unmap_user(to_mucontext(pd->uobject->context), &qp->db);
888895 } else {
889− kfree(qp->sq.wrid);
890− kfree(qp->rq.wrid);
896+ kvfree(qp->sq.wrid);
897+ kvfree(qp->rq.wrid);
891898 }
892899
893900 err_mtt:
@@ -1062,8 +1069,8 @@ static void destroy_qp_common(struct mlx4_ib_dev *dev, struct mlx4_ib_qp *qp, · 168 unmodified lines
10621069 &qp->db);
10631070 ib_umem_release(qp->umem);
10641071 } else {
1065− kfree(qp->sq.wrid);
1066− kfree(qp->rq.wrid);
1072+ kvfree(qp->sq.wrid);
1073+ kvfree(qp->rq.wrid);
10671074 if (qp->mlx4_ib_qp_type & (MLX4_IB_QPT_PROXY_SMI_OWNER |
10681075 MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_GSI))
10691076 free_proxy_bufs(&dev->ib_dev, qp);
drivers/infiniband/hw/mlx4/srq.c+8−3
@@ -34,6 +34,7 @@ · 33 unmodified lines
3434 #include <linux/mlx4/qp.h>
3535 #include <linux/mlx4/srq.h>
3636 #include <linux/slab.h>
37+#include <linux/vmalloc.h>
3738
3839 #include "mlx4_ib.h"
3940 #include "user.h"
@@ -172,8 +173,12 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, · 132 unmodified lines
172173
173174 srq->wrid = kmalloc(srq->msrq.max * sizeof (u64), GFP_KERNEL);
174175 if (!srq->wrid) {
175− err = -ENOMEM;
176− goto err_mtt;
176+ srq->wrid = __vmalloc(srq->msrq.max * sizeof(u64),
177+ GFP_KERNEL, PAGE_KERNEL);
178+ if (!srq->wrid) {
179+ err = -ENOMEM;
180+ goto err_mtt;
181+ }
177182 }
178183 }
179184
@@ -204,7 +209,7 @@ err_wrid: · 24 unmodified lines
204209 if (pd->uobject)
205210 mlx4_ib_db_unmap_user(to_mucontext(pd->uobject->context), &srq->db);
206211 else
207− kfree(srq->wrid);
212+ kvfree(srq->wrid);
208213
209214 err_mtt:
210215 mlx4_mtt_cleanup(dev->dev, &srq->mtt);
drivers/infiniband/hw/mlx5/mr.c+13−1
@@ -381,7 +381,19 @@ static void __cache_work_func(struct mlx5_cache_ent *ent) · 380 unmodified lines
381381 }
382382 }
383383 } else if (ent->cur > 2 * ent->limit) {
384− if (!someone_adding(cache) &&
384+ /*
385+ * The remove_keys() logic is performed as garbage collection
386+ * task. Such task is intended to be run when no other active
387+ * processes are running.
388+ *
389+ * The need_resched() will return TRUE if there are user tasks
390+ * to be activated in near future.
391+ *
392+ * In such case, we don't execute remove_keys() and postpone
393+ * the garbage collection work to try to run in next cycle,
394+ * in order to free CPU resources to other tasks.
395+ */
396+ if (!need_resched() && !someone_adding(cache) &&
385397 time_after(jiffies, cache->last_add + 300 * HZ)) {
386398 remove_keys(dev, i, 1);
387399 if (ent->cur > ent->limit)
drivers/infiniband/hw/qib/qib_qsfp.c+2−2
@@ -292,7 +292,7 @@ int qib_refresh_qsfp_cache(struct qib_pportdata *ppd, struct qib_qsfp_cache *cp) · 291 unmodified lines
292292 qib_dev_porterr(ppd->dd, ppd->port,
293293 "QSFP byte0 is 0x%02X, S/B 0x0C/D\n", peek[0]);
294294
295− if ((peek[2] & 2) == 0) {
295+ if ((peek[2] & 4) == 0) {
296296 /*
297297 * If cable is paged, rather than "flat memory", we need to
298298 * set the page to zero, Even if it already appears to be zero.
@@ -538,7 +538,7 @@ int qib_qsfp_dump(struct qib_pportdata *ppd, char *buf, int len) · 239 unmodified lines
538538 sofar += scnprintf(buf + sofar, len - sofar, "Date:%.*s\n",
539539 QSFP_DATE_LEN, cd.date);
540540 sofar += scnprintf(buf + sofar, len - sofar, "Lot:%.*s\n",
541− QSFP_LOT_LEN, cd.date);
541+ QSFP_LOT_LEN, cd.lot);
542542
543543 while (bidx < QSFP_DEFAULT_HDR_CNT) {
544544 int iidx;
drivers/infiniband/hw/qib/qib_verbs.h+1−1
@@ -329,9 +329,9 @@ struct qib_sge { · 328 unmodified lines
329329 struct qib_mr {
330330 struct ib_mr ibmr;
331331 struct ib_umem *umem;
332− struct qib_mregion mr; /* must be last */
333332 u64 *pages;
334333 u32 npages;
334+ struct qib_mregion mr; /* must be last */
335335 };
336336
337337 /*
drivers/infiniband/ulp/iser/iser_verbs.c+1−1
@@ -1293,7 +1293,7 @@ u8 iser_check_task_pi_status(struct iscsi_iser_task *iser_task, · 1292 unmodified lines
12931293 if (mr_status.fail_status & IB_MR_CHECK_SIG_STATUS) {
12941294 sector_t sector_off = mr_status.sig_err.sig_err_offset;
12951295
1296− do_div(sector_off, sector_size + 8);
1296+ sector_div(sector_off, sector_size + 8);
12971297 *sector = scsi_get_lba(iser_task->sc) + sector_off;
12981298
12991299 pr_err("PI error found type %d at sector %llx "
drivers/infiniband/ulp/isert/ib_isert.c+3−10
@@ -157,16 +157,9 @@ isert_create_qp(struct isert_conn *isert_conn, · 156 unmodified lines
157157 attr.recv_cq = comp->cq;
158158 attr.cap.max_send_wr = ISERT_QP_MAX_REQ_DTOS;
159159 attr.cap.max_recv_wr = ISERT_QP_MAX_RECV_DTOS + 1;
160− /*
161− * FIXME: Use devattr.max_sge - 2 for max_send_sge as
162− * work-around for RDMA_READs with ConnectX-2.
163− *
164− * Also, still make sure to have at least two SGEs for
165− * outgoing control PDU responses.
166− */
167− attr.cap.max_send_sge = max(2, device->dev_attr.max_sge - 2);
168− isert_conn->max_sge = attr.cap.max_send_sge;
169−
160+ attr.cap.max_send_sge = device->dev_attr.max_sge;
161+ isert_conn->max_sge = min(device->dev_attr.max_sge,
162+ device->dev_attr.max_sge_rd);
170163 attr.cap.max_recv_sge = 1;
171164 attr.sq_sig_type = IB_SIGNAL_REQ_WR;
172165 attr.qp_type = IB_QPT_RC;
drivers/infiniband/ulp/srp/ib_srp.c+26−22
@@ -488,7 +488,7 @@ static int srp_create_ch_ib(struct srp_rdma_ch *ch) · 487 unmodified lines
488488 struct ib_qp *qp;
489489 struct ib_fmr_pool *fmr_pool = NULL;
490490 struct srp_fr_pool *fr_pool = NULL;
491− const int m = 1 + dev->use_fast_reg;
491+ const int m = dev->use_fast_reg ? 3 : 1;
492492 struct ib_cq_init_attr cq_attr = {};
493493 int ret;
494494
@@ -994,16 +994,16 @@ static int srp_connect_ch(struct srp_rdma_ch *ch, bool multich) · 499 unmodified lines
994994
995995 ret = srp_lookup_path(ch);
996996 if (ret)
997− return ret;
997+ goto out;
998998
999999 while (1) {
10001000 init_completion(&ch->done);
10011001 ret = srp_send_req(ch, multich);
10021002 if (ret)
1003− return ret;
1003+ goto out;
10041004 ret = wait_for_completion_interruptible(&ch->done);
10051005 if (ret < 0)
1006− return ret;
1006+ goto out;
10071007
10081008 /*
10091009 * The CM event handling code will set status to
@@ -1011,15 +1011,16 @@ static int srp_connect_ch(struct srp_rdma_ch *ch, bool multich) · 1 unmodified line
10111011 * back, or SRP_DLID_REDIRECT if we get a lid/qp
10121012 * redirect REJ back.
10131013 */
1014− switch (ch->status) {
1014+ ret = ch->status;
1015+ switch (ret) {
10151016 case 0:
10161017 ch->connected = true;
1017− return 0;
1018+ goto out;
10181019
10191020 case SRP_PORT_REDIRECT:
10201021 ret = srp_lookup_path(ch);
10211022 if (ret)
1022− return ret;
1023+ goto out;
10231024 break;
10241025
10251026 case SRP_DLID_REDIRECT:
@@ -1028,13 +1029,16 @@ static int srp_connect_ch(struct srp_rdma_ch *ch, bool multich) · 2 unmodified lines
10281029 case SRP_STALE_CONN:
10291030 shost_printk(KERN_ERR, target->scsi_host, PFX
10301031 "giving up on stale connection\n");
1031− ch->status = -ECONNRESET;
1032− return ch->status;
1032+ ret = -ECONNRESET;
1033+ goto out;
10331034
10341035 default:
1035− return ch->status;
1036+ goto out;
10361037 }
10371038 }
1039+
1040+out:
1041+ return ret <= 0 ? ret : -ENODEV;
10381042 }
10391043
10401044 static int srp_inv_rkey(struct srp_rdma_ch *ch, u32 rkey)
@@ -1309,7 +1313,7 @@ reset_state: · 268 unmodified lines
13091313 }
13101314
13111315 static int srp_map_finish_fr(struct srp_map_state *state,
1312− struct srp_rdma_ch *ch)
1316+ struct srp_rdma_ch *ch, int sg_nents)
13131317 {
13141318 struct srp_target_port *target = ch->target;
13151319 struct srp_device *dev = target->srp_host->srp_dev;
@@ -1324,10 +1328,10 @@ static int srp_map_finish_fr(struct srp_map_state *state, · 8 unmodified lines
13241328
13251329 WARN_ON_ONCE(!dev->use_fast_reg);
13261330
1327− if (state->sg_nents == 0)
1331+ if (sg_nents == 0)
13281332 return 0;
13291333
1330− if (state->sg_nents == 1 && target->global_mr) {
1334+ if (sg_nents == 1 && target->global_mr) {
13311335 srp_map_desc(state, sg_dma_address(state->sg),
13321336 sg_dma_len(state->sg),
13331337 target->global_mr->rkey);
@@ -1341,8 +1345,7 @@ static int srp_map_finish_fr(struct srp_map_state *state, · 7 unmodified lines
13411345 rkey = ib_inc_rkey(desc->mr->rkey);
13421346 ib_update_fast_reg_key(desc->mr, rkey);
13431347
1344− n = ib_map_mr_sg(desc->mr, state->sg, state->sg_nents,
1345− dev->mr_page_size);
1348+ n = ib_map_mr_sg(desc->mr, state->sg, sg_nents, dev->mr_page_size);
13461349 if (unlikely(n < 0))
13471350 return n;
13481351
@@ -1448,16 +1451,15 @@ static int srp_map_sg_fr(struct srp_map_state *state, struct srp_rdma_ch *ch, · 99 unmodified lines
14481451 state->fr.next = req->fr_list;
14491452 state->fr.end = req->fr_list + ch->target->cmd_sg_cnt;
14501453 state->sg = scat;
1451− state->sg_nents = scsi_sg_count(req->scmnd);
14521454
1453− while (state->sg_nents) {
1455+ while (count) {
14541456 int i, n;
14551457
1456− n = srp_map_finish_fr(state, ch);
1458+ n = srp_map_finish_fr(state, ch, count);
14571459 if (unlikely(n < 0))
14581460 return n;
14591461
1460− state->sg_nents -= n;
1462+ count -= n;
14611463 for (i = 0; i < n; i++)
14621464 state->sg = sg_next(state->sg);
14631465 }
@@ -1517,10 +1519,12 @@ static int srp_map_idb(struct srp_rdma_ch *ch, struct srp_request *req, · 53 unmodified lines
15171519
15181520 if (dev->use_fast_reg) {
15191521 state.sg = idb_sg;
1520− state.sg_nents = 1;
15211522 sg_set_buf(idb_sg, req->indirect_desc, idb_len);
15221523 idb_sg->dma_address = req->indirect_dma_addr; /* hack! */
1523− ret = srp_map_finish_fr(&state, ch);
1524+#ifdef CONFIG_NEED_SG_DMA_LENGTH
1525+ idb_sg->dma_length = idb_sg->length; /* hack^2 */
1526+#endif
1527+ ret = srp_map_finish_fr(&state, ch, 1);
15241528 if (ret < 0)
15251529 return ret;
15261530 } else if (dev->use_fmr) {
@@ -1655,7 +1659,7 @@ static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_rdma_ch *ch, · 128 unmodified lines
16551659 return ret;
16561660 req->nmdesc++;
16571661 } else {
1658− idb_rkey = target->global_mr->rkey;
1662+ idb_rkey = cpu_to_be32(target->global_mr->rkey);
16591663 }
16601664
16611665 indirect_hdr->table_desc.va = cpu_to_be64(req->indirect_dma_addr);
drivers/infiniband/ulp/srp/ib_srp.h+1−4
@@ -300,10 +300,7 @@ struct srp_map_state { · 299 unmodified lines
300300 dma_addr_t base_dma_addr;
301301 u32 dma_len;
302302 u32 total_len;
303− union {
304− unsigned int npages;
305− int sg_nents;
306− };
303+ unsigned int npages;
307304 unsigned int nmdesc;
308305 unsigned int ndesc;
309306 };
drivers/irqchip/irq-versatile-fpga.c+5−0
@@ -210,7 +210,12 @@ int __init fpga_irq_of_init(struct device_node *node, · 209 unmodified lines
210210 parent_irq = -1;
211211 }
212212
213+#ifdef CONFIG_ARCH_VERSATILE
214+ fpga_irq_init(base, node->name, IRQ_SIC_START, parent_irq, valid_mask,
215+ node);
216+#else
213217 fpga_irq_init(base, node->name, 0, parent_irq, valid_mask, node);
218+#endif
214219
215220 writel(clear_mask, base + IRQ_ENABLE_CLEAR);
216221 writel(clear_mask, base + FIQ_ENABLE_CLEAR);
drivers/isdn/hisax/config.c+1−1
@@ -1896,7 +1896,7 @@ static void EChannel_proc_rcv(struct hisax_d_if *d_if) · 1895 unmodified lines
18961896 ptr--;
18971897 *ptr++ = '\n';
18981898 *ptr = 0;
1899− HiSax_putstatus(cs, NULL, "%s", cs->dlog);
1899+ HiSax_putstatus(cs, NULL, cs->dlog);
19001900 } else
19011901 HiSax_putstatus(cs, "LogEcho: ",
19021902 "warning Frame too big (%d)",
drivers/isdn/hisax/hfc_pci.c+1−1
@@ -901,7 +901,7 @@ Begin: · 900 unmodified lines
901901 ptr--;
902902 *ptr++ = '\n';
903903 *ptr = 0;
904− HiSax_putstatus(cs, NULL, "%s", cs->dlog);
904+ HiSax_putstatus(cs, NULL, cs->dlog);
905905 } else
906906 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", total - 3);
907907 }
drivers/isdn/hisax/hfc_sx.c+1−1
@@ -674,7 +674,7 @@ receive_emsg(struct IsdnCardState *cs) · 673 unmodified lines
674674 ptr--;
675675 *ptr++ = '\n';
676676 *ptr = 0;
677− HiSax_putstatus(cs, NULL, "%s", cs->dlog);
677+ HiSax_putstatus(cs, NULL, cs->dlog);
678678 } else
679679 HiSax_putstatus(cs, "LogEcho: ", "warning Frame too big (%d)", skb->len);
680680 }
drivers/isdn/hisax/q931.c+3−3
@@ -1179,7 +1179,7 @@ LogFrame(struct IsdnCardState *cs, u_char *buf, int size) · 1178 unmodified lines
11791179 dp--;
11801180 *dp++ = '\n';
11811181 *dp = 0;
1182− HiSax_putstatus(cs, NULL, "%s", cs->dlog);
1182+ HiSax_putstatus(cs, NULL, cs->dlog);
11831183 } else
11841184 HiSax_putstatus(cs, "LogFrame: ", "warning Frame too big (%d)", size);
11851185 }
@@ -1246,7 +1246,7 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir) · 60 unmodified lines
12461246 }
12471247 if (finish) {
12481248 *dp = 0;
1249− HiSax_putstatus(cs, NULL, "%s", cs->dlog);
1249+ HiSax_putstatus(cs, NULL, cs->dlog);
12501250 return;
12511251 }
12521252 if ((0xfe & buf[0]) == PROTO_DIS_N0) { /* 1TR6 */
@@ -1509,5 +1509,5 @@ dlogframe(struct IsdnCardState *cs, struct sk_buff *skb, int dir) · 256 unmodified lines
15091509 dp += sprintf(dp, "Unknown protocol %x!", buf[0]);
15101510 }
15111511 *dp = 0;
1512− HiSax_putstatus(cs, NULL, "%s", cs->dlog);
1512+ HiSax_putstatus(cs, NULL, cs->dlog);
15131513 }
drivers/lightnvm/Kconfig+1−0
@@ -18,6 +18,7 @@ if NVM · 17 unmodified lines
1818
1919 config NVM_DEBUG
2020 bool "Open-Channel SSD debugging support"
21+ default n
2122 ---help---
2223 Exposes a debug management interface to create/remove targets at:
2324
drivers/lightnvm/core.c+88−70
@@ -74,7 +74,7 @@ EXPORT_SYMBOL(nvm_unregister_target); · 73 unmodified lines
7474 void *nvm_dev_dma_alloc(struct nvm_dev *dev, gfp_t mem_flags,
7575 dma_addr_t *dma_handler)
7676 {
77− return dev->ops->dev_dma_alloc(dev->q, dev->ppalist_pool, mem_flags,
77+ return dev->ops->dev_dma_alloc(dev, dev->ppalist_pool, mem_flags,
7878 dma_handler);
7979 }
8080 EXPORT_SYMBOL(nvm_dev_dma_alloc);
@@ -97,15 +97,47 @@ static struct nvmm_type *nvm_find_mgr_type(const char *name) · 16 unmodified lines
9797 return NULL;
9898 }
9999
100+struct nvmm_type *nvm_init_mgr(struct nvm_dev *dev)
101+{
102+ struct nvmm_type *mt;
103+ int ret;
104+
105+ lockdep_assert_held(&nvm_lock);
106+
107+ list_for_each_entry(mt, &nvm_mgrs, list) {
108+ ret = mt->register_mgr(dev);
109+ if (ret < 0) {
110+ pr_err("nvm: media mgr failed to init (%d) on dev %s\n",
111+ ret, dev->name);
112+ return NULL; /* initialization failed */
113+ } else if (ret > 0)
114+ return mt;
115+ }
116+
117+ return NULL;
118+}
119+
100120 int nvm_register_mgr(struct nvmm_type *mt)
101121 {
122+ struct nvm_dev *dev;
102123 int ret = 0;
103124
104125 down_write(&nvm_lock);
105− if (nvm_find_mgr_type(mt->name))
126+ if (nvm_find_mgr_type(mt->name)) {
106127 ret = -EEXIST;
107− else
128+ goto finish;
129+ } else {
108130 list_add(&mt->list, &nvm_mgrs);
131+ }
132+
133+ /* try to register media mgr if any device have none configured */
134+ list_for_each_entry(dev, &nvm_devices, devices) {
135+ if (dev->mt)
136+ continue;
137+
138+ dev->mt = nvm_init_mgr(dev);
139+ }
140+finish:
109141 up_write(&nvm_lock);
110142
111143 return ret;
@@ -160,11 +192,6 @@ int nvm_erase_blk(struct nvm_dev *dev, struct nvm_block *blk) · 48 unmodified lines
160192 }
161193 EXPORT_SYMBOL(nvm_erase_blk);
162194
163−static void nvm_core_free(struct nvm_dev *dev)
164−{
165− kfree(dev);
166−}
167−
168195 static int nvm_core_init(struct nvm_dev *dev)
169196 {
170197 struct nvm_id *id = &dev->identity;
@@ -179,12 +206,21 @@ static int nvm_core_init(struct nvm_dev *dev) · 8 unmodified lines
179206 dev->sec_size = grp->csecs;
180207 dev->oob_size = grp->sos;
181208 dev->sec_per_pg = grp->fpg_sz / grp->csecs;
182− dev->addr_mode = id->ppat;
183− dev->addr_format = id->ppaf;
209+ memcpy(&dev->ppaf, &id->ppaf, sizeof(struct nvm_addr_format));
184210
185211 dev->plane_mode = NVM_PLANE_SINGLE;
186212 dev->max_rq_size = dev->ops->max_phys_sect * dev->sec_size;
187213
214+ if (grp->mtype != 0) {
215+ pr_err("nvm: memory type not supported\n");
216+ return -EINVAL;
217+ }
218+
219+ if (grp->fmtype != 0 && grp->fmtype != 1) {
220+ pr_err("nvm: flash type not supported\n");
221+ return -EINVAL;
222+ }
223+
188224 if (grp->mpos & 0x020202)
189225 dev->plane_mode = NVM_PLANE_DOUBLE;
190226 if (grp->mpos & 0x040404)
@@ -213,21 +249,17 @@ static void nvm_free(struct nvm_dev *dev) · 22 unmodified lines
213249
214250 if (dev->mt)
215251 dev->mt->unregister_mgr(dev);
216−
217− nvm_core_free(dev);
218252 }
219253
220254 static int nvm_init(struct nvm_dev *dev)
221255 {
222− struct nvmm_type *mt;
223− int ret = 0;
256+ int ret = -EINVAL;
224257
225258 if (!dev->q || !dev->ops)
226− return -EINVAL;
259+ return ret;
227260
228− if (dev->ops->identity(dev->q, &dev->identity)) {
261+ if (dev->ops->identity(dev, &dev->identity)) {
229262 pr_err("nvm: device could not be identified\n");
230− ret = -EINVAL;
231263 goto err;
232264 }
233265
@@ -251,29 +283,12 @@ static int nvm_init(struct nvm_dev *dev) · 17 unmodified lines
251283 goto err;
252284 }
253285
254− /* register with device with a supported manager */
255− list_for_each_entry(mt, &nvm_mgrs, list) {
256− ret = mt->register_mgr(dev);
257− if (ret < 0)
258− goto err; /* initialization failed */
259− if (ret > 0) {
260− dev->mt = mt;
261− break; /* successfully initialized */
262− }
263− }
264−
265− if (!ret) {
266− pr_info("nvm: no compatible manager found.\n");
267− return 0;
268− }
269−
270286 pr_info("nvm: registered %s [%u/%u/%u/%u/%u/%u]\n",
271287 dev->name, dev->sec_per_pg, dev->nr_planes,
272288 dev->pgs_per_blk, dev->blks_per_lun, dev->nr_luns,
273289 dev->nr_chnls);
274290 return 0;
275291 err:
276− nvm_free(dev);
277292 pr_err("nvm: failed to initialize nvm\n");
278293 return ret;
279294 }
@@ -308,22 +323,27 @@ int nvm_register(struct request_queue *q, char *disk_name, · 28 unmodified lines
308323 if (ret)
309324 goto err_init;
310325
311− down_write(&nvm_lock);
312− list_add(&dev->devices, &nvm_devices);
313− up_write(&nvm_lock);
326+ if (dev->ops->max_phys_sect > 256) {
327+ pr_info("nvm: max sectors supported is 256.\n");
328+ ret = -EINVAL;
329+ goto err_init;
330+ }
314331
315332 if (dev->ops->max_phys_sect > 1) {
316− dev->ppalist_pool = dev->ops->create_dma_pool(dev->q,
317− "ppalist");
333+ dev->ppalist_pool = dev->ops->create_dma_pool(dev, "ppalist");
318334 if (!dev->ppalist_pool) {
319335 pr_err("nvm: could not create ppa pool\n");
320− return -ENOMEM;
336+ ret = -ENOMEM;
337+ goto err_init;
321338 }
322− } else if (dev->ops->max_phys_sect > 256) {
323− pr_info("nvm: max sectors supported is 256.\n");
324− return -EINVAL;
325339 }
326340
341+ /* register device with a supported media manager */
342+ down_write(&nvm_lock);
343+ dev->mt = nvm_init_mgr(dev);
344+ list_add(&dev->devices, &nvm_devices);
345+ up_write(&nvm_lock);
346+
327347 return 0;
328348 err_init:
329349 kfree(dev);
@@ -333,19 +353,22 @@ EXPORT_SYMBOL(nvm_register); · 3 unmodified lines
333353
334354 void nvm_unregister(char *disk_name)
335355 {
336− struct nvm_dev *dev = nvm_find_nvm_dev(disk_name);
356+ struct nvm_dev *dev;
337357
358+ down_write(&nvm_lock);
359+ dev = nvm_find_nvm_dev(disk_name);
338360 if (!dev) {
339361 pr_err("nvm: could not find device %s to unregister\n",
340362 disk_name);
363+ up_write(&nvm_lock);
341364 return;
342365 }
343366
344− nvm_exit(dev);
345−
346− down_write(&nvm_lock);
347367 list_del(&dev->devices);
348368 up_write(&nvm_lock);
369+
370+ nvm_exit(dev);
371+ kfree(dev);
349372 }
350373 EXPORT_SYMBOL(nvm_unregister);
351374
@@ -358,38 +381,24 @@ static int nvm_create_target(struct nvm_dev *dev, · 6 unmodified lines
358381 {
359382 struct nvm_ioctl_create_simple *s = &create->conf.s;
360383 struct request_queue *tqueue;
361− struct nvmm_type *mt;
362384 struct gendisk *tdisk;
363385 struct nvm_tgt_type *tt;
364386 struct nvm_target *t;
365387 void *targetdata;
366− int ret = 0;
367388
368389 if (!dev->mt) {
369− /* register with device with a supported NVM manager */
370− list_for_each_entry(mt, &nvm_mgrs, list) {
371− ret = mt->register_mgr(dev);
372− if (ret < 0)
373− return ret; /* initialization failed */
374− if (ret > 0) {
375− dev->mt = mt;
376− break; /* successfully initialized */
377− }
378− }
379−
380− if (!ret) {
381− pr_info("nvm: no compatible nvm manager found.\n");
382− return -ENODEV;
383− }
390+ pr_info("nvm: device has no media manager registered.\n");
391+ return -ENODEV;
384392 }
385393
394+ down_write(&nvm_lock);
386395 tt = nvm_find_target_type(create->tgttype);
387396 if (!tt) {
388397 pr_err("nvm: target type %s not found\n", create->tgttype);
398+ up_write(&nvm_lock);
389399 return -EINVAL;
390400 }
391401
392− down_write(&nvm_lock);
393402 list_for_each_entry(t, &dev->online_targets, list) {
394403 if (!strcmp(create->tgtname, t->disk->disk_name)) {
395404 pr_err("nvm: target name already exists.\n");
@@ -457,11 +466,11 @@ static void nvm_remove_target(struct nvm_target *t) · 61 unmodified lines
457466 lockdep_assert_held(&nvm_lock);
458467
459468 del_gendisk(tdisk);
469+ blk_cleanup_queue(q);
470+
460471 if (tt->exit)
461472 tt->exit(tdisk->private_data);
462473
463− blk_cleanup_queue(q);
464−
465474 put_disk(tdisk);
466475
467476 list_del(&t->list);
@@ -473,7 +482,9 @@ static int __nvm_configure_create(struct nvm_ioctl_create *create) · 5 unmodified lines
473482 struct nvm_dev *dev;
474483 struct nvm_ioctl_create_simple *s;
475484
485+ down_write(&nvm_lock);
476486 dev = nvm_find_nvm_dev(create->dev);
487+ up_write(&nvm_lock);
477488 if (!dev) {
478489 pr_err("nvm: device not found\n");
479490 return -EINVAL;
@@ -532,7 +543,9 @@ static int nvm_configure_show(const char *val) · 52 unmodified lines
532543 return -EINVAL;
533544 }
534545
546+ down_write(&nvm_lock);
535547 dev = nvm_find_nvm_dev(devname);
548+ up_write(&nvm_lock);
536549 if (!dev) {
537550 pr_err("nvm: device not found\n");
538551 return -EINVAL;
@@ -541,7 +554,7 @@ static int nvm_configure_show(const char *val) · 2 unmodified lines
541554 if (!dev->mt)
542555 return 0;
543556
544− dev->mt->free_blocks_print(dev);
557+ dev->mt->lun_info_print(dev);
545558
546559 return 0;
547560 }
@@ -677,8 +690,10 @@ static long nvm_ioctl_info(struct file *file, void __user *arg) · 129 unmodified lines
677690 info->tgtsize = tgt_iter;
678691 up_write(&nvm_lock);
679692
680− if (copy_to_user(arg, info, sizeof(struct nvm_ioctl_info)))
693+ if (copy_to_user(arg, info, sizeof(struct nvm_ioctl_info))) {
694+ kfree(info);
681695 return -EFAULT;
696+ }
682697
683698 kfree(info);
684699 return 0;
@@ -721,8 +736,11 @@ static long nvm_ioctl_get_devices(struct file *file, void __user *arg) · 36 unmodified lines
721736
722737 devices->nr_devices = i;
723738
724− if (copy_to_user(arg, devices, sizeof(struct nvm_ioctl_get_devices)))
739+ if (copy_to_user(arg, devices,
740+ sizeof(struct nvm_ioctl_get_devices))) {
741+ kfree(devices);
725742 return -EFAULT;
743+ }
726744
727745 kfree(devices);
728746 return 0;
drivers/lightnvm/gennvm.c+72−33
@@ -60,23 +60,27 @@ static int gennvm_luns_init(struct nvm_dev *dev, struct gen_nvm *gn) · 59 unmodified lines
6060 lun->vlun.lun_id = i % dev->luns_per_chnl;
6161 lun->vlun.chnl_id = i / dev->luns_per_chnl;
6262 lun->vlun.nr_free_blocks = dev->blks_per_lun;
63+ lun->vlun.nr_inuse_blocks = 0;
64+ lun->vlun.nr_bad_blocks = 0;
6365 }
6466 return 0;
6567 }
6668
67−static int gennvm_block_bb(u32 lun_id, void *bb_bitmap, unsigned int nr_blocks,
69+static int gennvm_block_bb(struct ppa_addr ppa, int nr_blocks, u8 *blks,
6870 void *private)
6971 {
7072 struct gen_nvm *gn = private;
71− struct gen_lun *lun = &gn->luns[lun_id];
73+ struct nvm_dev *dev = gn->dev;
74+ struct gen_lun *lun;
7275 struct nvm_block *blk;
7376 int i;
7477
75− if (unlikely(bitmap_empty(bb_bitmap, nr_blocks)))
76− return 0;
78+ lun = &gn->luns[(dev->nr_luns * ppa.g.ch) + ppa.g.lun];
79+
80+ for (i = 0; i < nr_blocks; i++) {
81+ if (blks[i] == 0)
82+ continue;
7783
78− i = -1;
79− while ((i = find_next_bit(bb_bitmap, nr_blocks, i + 1)) < nr_blocks) {
8084 blk = &lun->vlun.blocks[i];
8185 if (!blk) {
8286 pr_err("gennvm: BB data is out of bounds.\n");
@@ -84,6 +88,7 @@ static int gennvm_block_bb(u32 lun_id, void *bb_bitmap, unsigned int nr_blocks, · 1 unmodified line
8488 }
8589
8690 list_move_tail(&blk->list, &lun->bb_list);
91+ lun->vlun.nr_bad_blocks++;
8792 }
8893
8994 return 0;
@@ -136,6 +141,7 @@ static int gennvm_block_map(u64 slba, u32 nlb, __le64 *entries, void *private) · 46 unmodified lines
136141 list_move_tail(&blk->list, &lun->used_list);
137142 blk->type = 1;
138143 lun->vlun.nr_free_blocks--;
144+ lun->vlun.nr_inuse_blocks++;
139145 }
140146 }
141147
@@ -164,22 +170,32 @@ static int gennvm_blocks_init(struct nvm_dev *dev, struct gen_nvm *gn) · 22 unmodified lines
164170 block->id = cur_block_id++;
165171
166172 /* First block is reserved for device */
167− if (unlikely(lun_iter == 0 && blk_iter == 0))
173+ if (unlikely(lun_iter == 0 && blk_iter == 0)) {
174+ lun->vlun.nr_free_blocks--;
168175 continue;
176+ }
169177
170178 list_add_tail(&block->list, &lun->free_list);
171179 }
172180
173181 if (dev->ops->get_bb_tbl) {
174− ret = dev->ops->get_bb_tbl(dev->q, lun->vlun.id,
175− dev->blks_per_lun, gennvm_block_bb, gn);
182+ struct ppa_addr ppa;
183+
184+ ppa.ppa = 0;
185+ ppa.g.ch = lun->vlun.chnl_id;
186+ ppa.g.lun = lun->vlun.id;
187+ ppa = generic_to_dev_addr(dev, ppa);
188+
189+ ret = dev->ops->get_bb_tbl(dev, ppa,
190+ dev->blks_per_lun,
191+ gennvm_block_bb, gn);
176192 if (ret)
177193 pr_err("gennvm: could not read BB table\n");
178194 }
179195 }
180196
181197 if (dev->ops->get_l2p_tbl) {
182− ret = dev->ops->get_l2p_tbl(dev->q, 0, dev->total_pages,
198+ ret = dev->ops->get_l2p_tbl(dev, 0, dev->total_pages,
183199 gennvm_block_map, dev);
184200 if (ret) {
185201 pr_err("gennvm: could not read L2P table.\n");
@@ -190,15 +206,27 @@ static int gennvm_blocks_init(struct nvm_dev *dev, struct gen_nvm *gn) · 4 unmodified lines
190206 return 0;
191207 }
192208
209+static void gennvm_free(struct nvm_dev *dev)
210+{
211+ gennvm_blocks_free(dev);
212+ gennvm_luns_free(dev);
213+ kfree(dev->mp);
214+ dev->mp = NULL;
215+}
216+
193217 static int gennvm_register(struct nvm_dev *dev)
194218 {
195219 struct gen_nvm *gn;
196220 int ret;
197221
222+ if (!try_module_get(THIS_MODULE))
223+ return -ENODEV;
224+
198225 gn = kzalloc(sizeof(struct gen_nvm), GFP_KERNEL);
199226 if (!gn)
200227 return -ENOMEM;
201228
229+ gn->dev = dev;
202230 gn->nr_luns = dev->nr_luns;
203231 dev->mp = gn;
204232
@@ -216,16 +244,15 @@ static int gennvm_register(struct nvm_dev *dev) · 11 unmodified lines
216244
217245 return 1;
218246 err:
219− kfree(gn);
247+ gennvm_free(dev);
248+ module_put(THIS_MODULE);
220249 return ret;
221250 }
222251
223252 static void gennvm_unregister(struct nvm_dev *dev)
224253 {
225− gennvm_blocks_free(dev);
226− gennvm_luns_free(dev);
227− kfree(dev->mp);
228− dev->mp = NULL;
254+ gennvm_free(dev);
255+ module_put(THIS_MODULE);
229256 }
230257
231258 static struct nvm_block *gennvm_get_blk(struct nvm_dev *dev,
@@ -240,23 +267,21 @@ static struct nvm_block *gennvm_get_blk(struct nvm_dev *dev, · 8 unmodified lines
240267 if (list_empty(&lun->free_list)) {
241268 pr_err_ratelimited("gennvm: lun %u have no free pages available",
242269 lun->vlun.id);
243− spin_unlock(&vlun->lock);
244270 goto out;
245271 }
246272
247− while (!is_gc && lun->vlun.nr_free_blocks < lun->reserved_blocks) {
248− spin_unlock(&vlun->lock);
273+ if (!is_gc && lun->vlun.nr_free_blocks < lun->reserved_blocks)
249274 goto out;
250− }
251275
252276 blk = list_first_entry(&lun->free_list, struct nvm_block, list);
253277 list_move_tail(&blk->list, &lun->used_list);
254278 blk->type = 1;
255279
256280 lun->vlun.nr_free_blocks--;
281+ lun->vlun.nr_inuse_blocks++;
257282
258− spin_unlock(&vlun->lock);
259283 out:
284+ spin_unlock(&vlun->lock);
260285 return blk;
261286 }
262287
@@ -271,16 +296,21 @@ static void gennvm_put_blk(struct nvm_dev *dev, struct nvm_block *blk) · 8 unmodified lines
271296 case 1:
272297 list_move_tail(&blk->list, &lun->free_list);
273298 lun->vlun.nr_free_blocks++;
299+ lun->vlun.nr_inuse_blocks--;
274300 blk->type = 0;
275301 break;
276302 case 2:
277303 list_move_tail(&blk->list, &lun->bb_list);
304+ lun->vlun.nr_bad_blocks++;
305+ lun->vlun.nr_inuse_blocks--;
278306 break;
279307 default:
280308 WARN_ON_ONCE(1);
281309 pr_err("gennvm: erroneous block type (%lu -> %u)\n",
282310 blk->id, blk->type);
283311 list_move_tail(&blk->list, &lun->bb_list);
312+ lun->vlun.nr_bad_blocks++;
313+ lun->vlun.nr_inuse_blocks--;
284314 }
285315
286316 spin_unlock(&vlun->lock);
@@ -292,10 +322,10 @@ static void gennvm_addr_to_generic_mode(struct nvm_dev *dev, struct nvm_rq *rqd) · 5 unmodified lines
292322
293323 if (rqd->nr_pages > 1) {
294324 for (i = 0; i < rqd->nr_pages; i++)
295− rqd->ppa_list[i] = addr_to_generic_mode(dev,
325+ rqd->ppa_list[i] = dev_to_generic_addr(dev,
296326 rqd->ppa_list[i]);
297327 } else {
298− rqd->ppa_addr = addr_to_generic_mode(dev, rqd->ppa_addr);
328+ rqd->ppa_addr = dev_to_generic_addr(dev, rqd->ppa_addr);
299329 }
300330 }
301331
@@ -305,10 +335,10 @@ static void gennvm_generic_to_addr_mode(struct nvm_dev *dev, struct nvm_rq *rqd) · 3 unmodified lines
305335
306336 if (rqd->nr_pages > 1) {
307337 for (i = 0; i < rqd->nr_pages; i++)
308− rqd->ppa_list[i] = generic_to_addr_mode(dev,
338+ rqd->ppa_list[i] = generic_to_dev_addr(dev,
309339 rqd->ppa_list[i]);
310340 } else {
311− rqd->ppa_addr = generic_to_addr_mode(dev, rqd->ppa_addr);
341+ rqd->ppa_addr = generic_to_dev_addr(dev, rqd->ppa_addr);
312342 }
313343 }
314344
@@ -321,7 +351,7 @@ static int gennvm_submit_io(struct nvm_dev *dev, struct nvm_rq *rqd) · 6 unmodified lines
321351 gennvm_generic_to_addr_mode(dev, rqd);
322352
323353 rqd->dev = dev;
324− return dev->ops->submit_io(dev->q, rqd);
354+ return dev->ops->submit_io(dev, rqd);
325355 }
326356
327357 static void gennvm_blk_set_type(struct nvm_dev *dev, struct ppa_addr *ppa,
@@ -354,10 +384,10 @@ static void gennvm_mark_blk_bad(struct nvm_dev *dev, struct nvm_rq *rqd) · 26 unmodified lines
354384 {
355385 int i;
356386
357− if (!dev->ops->set_bb)
387+ if (!dev->ops->set_bb_tbl)
358388 return;
359389
360− if (dev->ops->set_bb(dev->q, rqd, 1))
390+ if (dev->ops->set_bb_tbl(dev, rqd, 1))
361391 return;
362392
363393 gennvm_addr_to_generic_mode(dev, rqd);
@@ -425,7 +455,7 @@ static int gennvm_erase_blk(struct nvm_dev *dev, struct nvm_block *blk, · 61 unmodified lines
425455
426456 gennvm_generic_to_addr_mode(dev, &rqd);
427457
428− ret = dev->ops->erase_block(dev->q, &rqd);
458+ ret = dev->ops->erase_block(dev, &rqd);
429459
430460 if (plane_cnt)
431461 nvm_dev_dma_free(dev, rqd.ppa_list, rqd.dma_ppa_list);
@@ -440,15 +470,24 @@ static struct nvm_lun *gennvm_get_lun(struct nvm_dev *dev, int lunid) · 8 unmodified lines
440470 return &gn->luns[lunid].vlun;
441471 }
442472
443−static void gennvm_free_blocks_print(struct nvm_dev *dev)
473+static void gennvm_lun_info_print(struct nvm_dev *dev)
444474 {
445475 struct gen_nvm *gn = dev->mp;
446476 struct gen_lun *lun;
447477 unsigned int i;
448478
449− gennvm_for_each_lun(gn, lun, i)
450− pr_info("%s: lun%8u\t%u\n",
451− dev->name, i, lun->vlun.nr_free_blocks);
479+
480+ gennvm_for_each_lun(gn, lun, i) {
481+ spin_lock(&lun->vlun.lock);
482+
483+ pr_info("%s: lun%8u\t%u\t%u\t%u\n",
484+ dev->name, i,
485+ lun->vlun.nr_free_blocks,
486+ lun->vlun.nr_inuse_blocks,
487+ lun->vlun.nr_bad_blocks);
488+
489+ spin_unlock(&lun->vlun.lock);
490+ }
452491 }
453492
454493 static struct nvmm_type gennvm = {
@@ -466,7 +505,7 @@ static struct nvmm_type gennvm = { · 11 unmodified lines
466505 .erase_blk = gennvm_erase_blk,
467506
468507 .get_lun = gennvm_get_lun,
469− .free_blocks_print = gennvm_free_blocks_print,
508+ .lun_info_print = gennvm_lun_info_print,
470509 };
471510
472511 static int __init gennvm_module_init(void)
drivers/lightnvm/gennvm.h+2−0
@@ -35,6 +35,8 @@ struct gen_lun { · 34 unmodified lines
3535 };
3636
3737 struct gen_nvm {
38+ struct nvm_dev *dev;
39+
3840 int nr_luns;
3941 struct gen_lun *luns;
4042 };
drivers/lightnvm/rrpc.c+52−5
@@ -123,12 +123,42 @@ static u64 block_to_addr(struct rrpc *rrpc, struct rrpc_block *rblk) · 122 unmodified lines
123123 return blk->id * rrpc->dev->pgs_per_blk;
124124 }
125125
126+static struct ppa_addr linear_to_generic_addr(struct nvm_dev *dev,
127+ struct ppa_addr r)
128+{
129+ struct ppa_addr l;
130+ int secs, pgs, blks, luns;
131+ sector_t ppa = r.ppa;
132+
133+ l.ppa = 0;
134+
135+ div_u64_rem(ppa, dev->sec_per_pg, &secs);
136+ l.g.sec = secs;
137+
138+ sector_div(ppa, dev->sec_per_pg);
139+ div_u64_rem(ppa, dev->sec_per_blk, &pgs);
140+ l.g.pg = pgs;
141+
142+ sector_div(ppa, dev->pgs_per_blk);
143+ div_u64_rem(ppa, dev->blks_per_lun, &blks);
144+ l.g.blk = blks;
145+
146+ sector_div(ppa, dev->blks_per_lun);
147+ div_u64_rem(ppa, dev->luns_per_chnl, &luns);
148+ l.g.lun = luns;
149+
150+ sector_div(ppa, dev->luns_per_chnl);
151+ l.g.ch = ppa;
152+
153+ return l;
154+}
155+
126156 static struct ppa_addr rrpc_ppa_to_gaddr(struct nvm_dev *dev, u64 addr)
127157 {
128158 struct ppa_addr paddr;
129159
130160 paddr.ppa = addr;
131− return __linear_to_generic_addr(dev, paddr);
161+ return linear_to_generic_addr(dev, paddr);
132162 }
133163
134164 /* requires lun->lock taken */
@@ -152,7 +182,7 @@ static struct rrpc_block *rrpc_get_blk(struct rrpc *rrpc, struct rrpc_lun *rlun, · 17 unmodified lines
152182 struct nvm_block *blk;
153183 struct rrpc_block *rblk;
154184
155− blk = nvm_get_blk(rrpc->dev, rlun->parent, 0);
185+ blk = nvm_get_blk(rrpc->dev, rlun->parent, flags);
156186 if (!blk)
157187 return NULL;
158188
@@ -172,6 +202,20 @@ static void rrpc_put_blk(struct rrpc *rrpc, struct rrpc_block *rblk) · 13 unmodified lines
172202 nvm_put_blk(rrpc->dev, rblk->parent);
173203 }
174204
205+static void rrpc_put_blks(struct rrpc *rrpc)
206+{
207+ struct rrpc_lun *rlun;
208+ int i;
209+
210+ for (i = 0; i < rrpc->nr_luns; i++) {
211+ rlun = &rrpc->luns[i];
212+ if (rlun->cur)
213+ rrpc_put_blk(rrpc, rlun->cur);
214+ if (rlun->gc_cur)
215+ rrpc_put_blk(rrpc, rlun->gc_cur);
216+ }
217+}
218+
175219 static struct rrpc_lun *get_next_lun(struct rrpc *rrpc)
176220 {
177221 int next = atomic_inc_return(&rrpc->next_lun);
@@ -972,7 +1016,7 @@ static int rrpc_map_init(struct rrpc *rrpc) · 794 unmodified lines
9721016 return 0;
9731017
9741018 /* Bring up the mapping table from device */
975− ret = dev->ops->get_l2p_tbl(dev->q, 0, dev->total_pages,
1019+ ret = dev->ops->get_l2p_tbl(dev, 0, dev->total_pages,
9761020 rrpc_l2p_update, rrpc);
9771021 if (ret) {
9781022 pr_err("nvm: rrpc: could not read L2P table.\n");
@@ -1194,18 +1238,21 @@ static int rrpc_luns_configure(struct rrpc *rrpc) · 215 unmodified lines
11941238
11951239 rblk = rrpc_get_blk(rrpc, rlun, 0);
11961240 if (!rblk)
1197− return -EINVAL;
1241+ goto err;
11981242
11991243 rrpc_set_lun_cur(rlun, rblk);
12001244
12011245 /* Emergency gc block */
12021246 rblk = rrpc_get_blk(rrpc, rlun, 1);
12031247 if (!rblk)
1204− return -EINVAL;
1248+ goto err;
12051249 rlun->gc_cur = rblk;
12061250 }
12071251
12081252 return 0;
1253+err:
1254+ rrpc_put_blks(rrpc);
1255+ return -EINVAL;
12091256 }
12101257
12111258 static struct nvm_tgt_type tt_rrpc;
drivers/md/dm-crypt.c+13−9
@@ -112,7 +112,8 @@ struct iv_tcw_private { · 111 unmodified lines
112112 * and encrypts / decrypts at the same time.
113113 */
114114 enum flags { DM_CRYPT_SUSPENDED, DM_CRYPT_KEY_VALID,
115− DM_CRYPT_SAME_CPU, DM_CRYPT_NO_OFFLOAD };
115+ DM_CRYPT_SAME_CPU, DM_CRYPT_NO_OFFLOAD,
116+ DM_CRYPT_EXIT_THREAD};
116117
117118 /*
118119 * The fields in here must be read only after initialization.
@@ -1203,20 +1204,18 @@ continue_locked: · 1084 unmodified lines
12031204 if (!RB_EMPTY_ROOT(&cc->write_tree))
12041205 goto pop_from_list;
12051206
1207+ if (unlikely(test_bit(DM_CRYPT_EXIT_THREAD, &cc->flags))) {
1208+ spin_unlock_irq(&cc->write_thread_wait.lock);
1209+ break;
1210+ }
1211+
12061212 __set_current_state(TASK_INTERRUPTIBLE);
12071213 __add_wait_queue(&cc->write_thread_wait, &wait);
12081214
12091215 spin_unlock_irq(&cc->write_thread_wait.lock);
12101216
1211− if (unlikely(kthread_should_stop())) {
1212− set_task_state(current, TASK_RUNNING);
1213− remove_wait_queue(&cc->write_thread_wait, &wait);
1214− break;
1215− }
1216−
12171217 schedule();
12181218
1219− set_task_state(current, TASK_RUNNING);
12201219 spin_lock_irq(&cc->write_thread_wait.lock);
12211220 __remove_wait_queue(&cc->write_thread_wait, &wait);
12221221 goto continue_locked;
@@ -1531,8 +1530,13 @@ static void crypt_dtr(struct dm_target *ti) · 308 unmodified lines
15311530 if (!cc)
15321531 return;
15331532
1534− if (cc->write_thread)
1533+ if (cc->write_thread) {
1534+ spin_lock_irq(&cc->write_thread_wait.lock);
1535+ set_bit(DM_CRYPT_EXIT_THREAD, &cc->flags);
1536+ wake_up_locked(&cc->write_thread_wait);
1537+ spin_unlock_irq(&cc->write_thread_wait.lock);
15351538 kthread_stop(cc->write_thread);
1539+ }
15361540
15371541 if (cc->io_queue)
15381542 destroy_workqueue(cc->io_queue);
drivers/md/dm-mpath.c+16−14
@@ -1537,32 +1537,34 @@ static int multipath_prepare_ioctl(struct dm_target *ti, · 1536 unmodified lines
15371537 struct block_device **bdev, fmode_t *mode)
15381538 {
15391539 struct multipath *m = ti->private;
1540− struct pgpath *pgpath;
15411540 unsigned long flags;
15421541 int r;
15431542
1544− r = 0;
1545−
15461543 spin_lock_irqsave(&m->lock, flags);
15471544
15481545 if (!m->current_pgpath)
15491546 __choose_pgpath(m, 0);
15501547
1551− pgpath = m->current_pgpath;
1552−
1553− if (pgpath) {
1554− *bdev = pgpath->path.dev->bdev;
1555− *mode = pgpath->path.dev->mode;
1548+ if (m->current_pgpath) {
1549+ if (!m->queue_io) {
1550+ *bdev = m->current_pgpath->path.dev->bdev;
1551+ *mode = m->current_pgpath->path.dev->mode;
1552+ r = 0;
1553+ } else {
1554+ /* pg_init has not started or completed */
1555+ r = -ENOTCONN;
1556+ }
1557+ } else {
1558+ /* No path is available */
1559+ if (m->queue_if_no_path)
1560+ r = -ENOTCONN;
1561+ else
1562+ r = -EIO;
15561563 }
15571564
1558− if ((pgpath && m->queue_io) || (!pgpath && m->queue_if_no_path))
1559− r = -ENOTCONN;
1560− else if (!*bdev)
1561− r = -EIO;
1562−
15631565 spin_unlock_irqrestore(&m->lock, flags);
15641566
1565− if (r == -ENOTCONN && !fatal_signal_pending(current)) {
1567+ if (r == -ENOTCONN) {
15661568 spin_lock_irqsave(&m->lock, flags);
15671569 if (!m->current_pg) {
15681570 /* Path status changed, redo selection */
drivers/md/dm-thin-metadata.c+29−5
@@ -1206,6 +1206,12 @@ static int __reserve_metadata_snap(struct dm_pool_metadata *pmd) · 1205 unmodified lines
12061206 struct dm_block *copy, *sblock;
12071207 dm_block_t held_root;
12081208
1209+ /*
1210+ * We commit to ensure the btree roots which we increment in a
1211+ * moment are up to date.
1212+ */
1213+ __commit_transaction(pmd);
1214+
12091215 /*
12101216 * Copy the superblock.
12111217 */
@@ -1538,7 +1544,7 @@ static int __remove(struct dm_thin_device *td, dm_block_t block) · 326 unmodified lines
15381544 static int __remove_range(struct dm_thin_device *td, dm_block_t begin, dm_block_t end)
15391545 {
15401546 int r;
1541− unsigned count;
1547+ unsigned count, total_count = 0;
15421548 struct dm_pool_metadata *pmd = td->pmd;
15431549 dm_block_t keys[1] = { td->id };
15441550 __le64 value;
@@ -1561,11 +1567,29 @@ static int __remove_range(struct dm_thin_device *td, dm_block_t begin, dm_block_ · 16 unmodified lines
15611567 if (r)
15621568 return r;
15631569
1564− r = dm_btree_remove_leaves(&pmd->bl_info, mapping_root, &begin, end, &mapping_root, &count);
1565− if (r)
1566− return r;
1570+ /*
1571+ * Remove leaves stops at the first unmapped entry, so we have to
1572+ * loop round finding mapped ranges.
1573+ */
1574+ while (begin < end) {
1575+ r = dm_btree_lookup_next(&pmd->bl_info, mapping_root, &begin, &begin, &value);
1576+ if (r == -ENODATA)
1577+ break;
1578+
1579+ if (r)
1580+ return r;
1581+
1582+ if (begin >= end)
1583+ break;
1584+
1585+ r = dm_btree_remove_leaves(&pmd->bl_info, mapping_root, &begin, end, &mapping_root, &count);
1586+ if (r)
1587+ return r;
1588+
1589+ total_count += count;
1590+ }
15671591
1568− td->mapped_blocks -= count;
1592+ td->mapped_blocks -= total_count;
15691593 td->changed = 1;
15701594
15711595 /*
drivers/md/dm-thin.c+3−3
@@ -2432,6 +2432,7 @@ static void set_pool_mode(struct pool *pool, enum pool_mode new_mode) · 2431 unmodified lines
24322432 case PM_WRITE:
24332433 if (old_mode != new_mode)
24342434 notify_of_pool_mode_change(pool, "write");
2435+ pool->pf.error_if_no_space = pt->requested_pf.error_if_no_space;
24352436 dm_pool_metadata_read_write(pool->pmd);
24362437 pool->process_bio = process_bio;
24372438 pool->process_discard = process_discard_bio;
@@ -4249,10 +4250,9 @@ static void thin_io_hints(struct dm_target *ti, struct queue_limits *limits) · 1811 unmodified lines
42494250 {
42504251 struct thin_c *tc = ti->private;
42514252 struct pool *pool = tc->pool;
4252− struct queue_limits *pool_limits = dm_get_queue_limits(pool->pool_md);
42534253
4254− if (!pool_limits->discard_granularity)
4255− return; /* pool's discard support is disabled */
4254+ if (!pool->pf.discard_enabled)
4255+ return;
42564256
42574257 limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT;
42584258 limits->max_discard_sectors = 2048 * 1024 * 16; /* 16G */
drivers/md/dm.c+4−3
@@ -591,7 +591,7 @@ retry: · 590 unmodified lines
591591
592592 out:
593593 dm_put_live_table(md, *srcu_idx);
594− if (r == -ENOTCONN) {
594+ if (r == -ENOTCONN && !fatal_signal_pending(current)) {
595595 msleep(10);
596596 goto retry;
597597 }
@@ -603,9 +603,10 @@ static int dm_blk_ioctl(struct block_device *bdev, fmode_t mode, · 5 unmodified lines
603603 {
604604 struct mapped_device *md = bdev->bd_disk->private_data;
605605 struct dm_target *tgt;
606+ struct block_device *tgt_bdev = NULL;
606607 int srcu_idx, r;
607608
608− r = dm_get_live_table_for_ioctl(md, &tgt, &bdev, &mode, &srcu_idx);
609+ r = dm_get_live_table_for_ioctl(md, &tgt, &tgt_bdev, &mode, &srcu_idx);
609610 if (r < 0)
610611 return r;
611612
@@ -620,7 +621,7 @@ static int dm_blk_ioctl(struct block_device *bdev, fmode_t mode, · 8 unmodified lines
620621 goto out;
621622 }
622623
623− r = __blkdev_driver_ioctl(bdev, mode, cmd, arg);
624+ r = __blkdev_driver_ioctl(tgt_bdev, mode, cmd, arg);
624625 out:
625626 dm_put_live_table(md, srcu_idx);
626627 return r;
drivers/md/persistent-data/dm-btree.c+99−2
@@ -63,6 +63,11 @@ int lower_bound(struct btree_node *n, uint64_t key) · 62 unmodified lines
6363 return bsearch(n, key, 0);
6464 }
6565
66+static int upper_bound(struct btree_node *n, uint64_t key)
67+{
68+ return bsearch(n, key, 1);
69+}
70+
6671 void inc_children(struct dm_transaction_manager *tm, struct btree_node *n,
6772 struct dm_btree_value_type *vt)
6873 {
@@ -252,6 +257,16 @@ static void pop_frame(struct del_stack *s) · 183 unmodified lines
252257 dm_tm_unlock(s->tm, f->b);
253258 }
254259
260+static void unlock_all_frames(struct del_stack *s)
261+{
262+ struct frame *f;
263+
264+ while (unprocessed_frames(s)) {
265+ f = s->spine + s->top--;
266+ dm_tm_unlock(s->tm, f->b);
267+ }
268+}
269+
255270 int dm_btree_del(struct dm_btree_info *info, dm_block_t root)
256271 {
257272 int r;
@@ -308,9 +323,13 @@ int dm_btree_del(struct dm_btree_info *info, dm_block_t root) · 50 unmodified lines
308323 pop_frame(s);
309324 }
310325 }
311−
312326 out:
327+ if (r) {
328+ /* cleanup all frames of del_stack */
329+ unlock_all_frames(s);
330+ }
313331 kfree(s);
332+
314333 return r;
315334 }
316335 EXPORT_SYMBOL_GPL(dm_btree_del);
@@ -392,6 +411,82 @@ int dm_btree_lookup(struct dm_btree_info *info, dm_block_t root, · 75 unmodified lines
392411 }
393412 EXPORT_SYMBOL_GPL(dm_btree_lookup);
394413
414+static int dm_btree_lookup_next_single(struct dm_btree_info *info, dm_block_t root,
415+ uint64_t key, uint64_t *rkey, void *value_le)
416+{
417+ int r, i;
418+ uint32_t flags, nr_entries;
419+ struct dm_block *node;
420+ struct btree_node *n;
421+
422+ r = bn_read_lock(info, root, &node);
423+ if (r)
424+ return r;
425+
426+ n = dm_block_data(node);
427+ flags = le32_to_cpu(n->header.flags);
428+ nr_entries = le32_to_cpu(n->header.nr_entries);
429+
430+ if (flags & INTERNAL_NODE) {
431+ i = lower_bound(n, key);
432+ if (i < 0 || i >= nr_entries) {
433+ r = -ENODATA;
434+ goto out;
435+ }
436+
437+ r = dm_btree_lookup_next_single(info, value64(n, i), key, rkey, value_le);
438+ if (r == -ENODATA && i < (nr_entries - 1)) {
439+ i++;
440+ r = dm_btree_lookup_next_single(info, value64(n, i), key, rkey, value_le);
441+ }
442+
443+ } else {
444+ i = upper_bound(n, key);
445+ if (i < 0 || i >= nr_entries) {
446+ r = -ENODATA;
447+ goto out;
448+ }
449+
450+ *rkey = le64_to_cpu(n->keys[i]);
451+ memcpy(value_le, value_ptr(n, i), info->value_type.size);
452+ }
453+out:
454+ dm_tm_unlock(info->tm, node);
455+ return r;
456+}
457+
458+int dm_btree_lookup_next(struct dm_btree_info *info, dm_block_t root,
459+ uint64_t *keys, uint64_t *rkey, void *value_le)
460+{
461+ unsigned level;
462+ int r = -ENODATA;
463+ __le64 internal_value_le;
464+ struct ro_spine spine;
465+
466+ init_ro_spine(&spine, info);
467+ for (level = 0; level < info->levels - 1u; level++) {
468+ r = btree_lookup_raw(&spine, root, keys[level],
469+ lower_bound, rkey,
470+ &internal_value_le, sizeof(uint64_t));
471+ if (r)
472+ goto out;
473+
474+ if (*rkey != keys[level]) {
475+ r = -ENODATA;
476+ goto out;
477+ }
478+
479+ root = le64_to_cpu(internal_value_le);
480+ }
481+
482+ r = dm_btree_lookup_next_single(info, root, keys[level], rkey, value_le);
483+out:
484+ exit_ro_spine(&spine);
485+ return r;
486+}
487+
488+EXPORT_SYMBOL_GPL(dm_btree_lookup_next);
489+
395490 /*
396491 * Splits a node by creating a sibling node and shifting half the nodes
397492 * contents across. Assumes there is a parent node, and it has room for
@@ -473,8 +568,10 @@ static int btree_split_sibling(struct shadow_spine *s, unsigned parent_index, · 75 unmodified lines
473568
474569 r = insert_at(sizeof(__le64), pn, parent_index + 1,
475570 le64_to_cpu(rn->keys[0]), &location);
476− if (r)
571+ if (r) {
572+ unlock_block(s->info, right);
477573 return r;
574+ }
478575
479576 if (key < le64_to_cpu(rn->keys[0])) {
480577 unlock_block(s->info, right);
drivers/md/persistent-data/dm-btree.h+11−3
@@ -109,6 +109,13 @@ int dm_btree_del(struct dm_btree_info *info, dm_block_t root); · 108 unmodified lines
109109 int dm_btree_lookup(struct dm_btree_info *info, dm_block_t root,
110110 uint64_t *keys, void *value_le);
111111
112+/*
113+ * Tries to find the first key where the bottom level key is >= to that
114+ * given. Useful for skipping empty sections of the btree.
115+ */
116+int dm_btree_lookup_next(struct dm_btree_info *info, dm_block_t root,
117+ uint64_t *keys, uint64_t *rkey, void *value_le);
118+
112119 /*
113120 * Insertion (or overwrite an existing value). O(ln(n))
114121 */
@@ -135,9 +142,10 @@ int dm_btree_remove(struct dm_btree_info *info, dm_block_t root, · 20 unmodified lines
135142 uint64_t *keys, dm_block_t *new_root);
136143
137144 /*
138− * Removes values between 'keys' and keys2, where keys2 is keys with the
139− * final key replaced with 'end_key'. 'end_key' is the one-past-the-end
140− * value. 'keys' may be altered.
145+ * Removes a _contiguous_ run of values starting from 'keys' and not
146+ * reaching keys2 (where keys2 is keys with the final key replaced with
147+ * 'end_key'). 'end_key' is the one-past-the-end value. 'keys' may be
148+ * altered.
141149 */
142150 int dm_btree_remove_leaves(struct dm_btree_info *info, dm_block_t root,
143151 uint64_t *keys, uint64_t end_key,
drivers/md/persistent-data/dm-space-map-metadata.c+22−10
@@ -136,7 +136,7 @@ static int brb_push(struct bop_ring_buffer *brb, · 135 unmodified lines
136136 return 0;
137137 }
138138
139−static int brb_pop(struct bop_ring_buffer *brb, struct block_op *result)
139+static int brb_peek(struct bop_ring_buffer *brb, struct block_op *result)
140140 {
141141 struct block_op *bop;
142142
@@ -147,6 +147,17 @@ static int brb_pop(struct bop_ring_buffer *brb, struct block_op *result) · 4 unmodified lines
147147 result->type = bop->type;
148148 result->block = bop->block;
149149
150+ return 0;
151+}
152+
153+static int brb_pop(struct bop_ring_buffer *brb)
154+{
155+ struct block_op *bop;
156+
157+ if (brb_empty(brb))
158+ return -ENODATA;
159+
160+ bop = brb->bops + brb->begin;
150161 brb->begin = brb_next(brb, brb->begin);
151162
152163 return 0;
@@ -211,7 +222,7 @@ static int apply_bops(struct sm_metadata *smm) · 58 unmodified lines
211222 while (!brb_empty(&smm->uncommitted)) {
212223 struct block_op bop;
213224
214− r = brb_pop(&smm->uncommitted, &bop);
225+ r = brb_peek(&smm->uncommitted, &bop);
215226 if (r) {
216227 DMERR("bug in bop ring buffer");
217228 break;
@@ -220,6 +231,8 @@ static int apply_bops(struct sm_metadata *smm) · 2 unmodified lines
220231 r = commit_bop(smm, &bop);
221232 if (r)
222233 break;
234+
235+ brb_pop(&smm->uncommitted);
223236 }
224237
225238 return r;
@@ -683,7 +696,6 @@ static struct dm_space_map bootstrap_ops = { · 457 unmodified lines
683696 static int sm_metadata_extend(struct dm_space_map *sm, dm_block_t extra_blocks)
684697 {
685698 int r, i;
686− enum allocation_event ev;
687699 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
688700 dm_block_t old_len = smm->ll.nr_blocks;
689701
@@ -705,11 +717,12 @@ static int sm_metadata_extend(struct dm_space_map *sm, dm_block_t extra_blocks) · 15 unmodified lines
705717 * allocate any new blocks.
706718 */
707719 do {
708− for (i = old_len; !r && i < smm->begin; i++) {
709− r = sm_ll_inc(&smm->ll, i, &ev);
710− if (r)
711− goto out;
712− }
720+ for (i = old_len; !r && i < smm->begin; i++)
721+ r = add_bop(smm, BOP_INC, i);
722+
723+ if (r)
724+ goto out;
725+
713726 old_len = smm->begin;
714727
715728 r = apply_bops(smm);
@@ -754,7 +767,6 @@ int dm_sm_metadata_create(struct dm_space_map *sm, · 38 unmodified lines
754767 {
755768 int r;
756769 dm_block_t i;
757− enum allocation_event ev;
758770 struct sm_metadata *smm = container_of(sm, struct sm_metadata, sm);
759771
760772 smm->begin = superblock + 1;
@@ -782,7 +794,7 @@ int dm_sm_metadata_create(struct dm_space_map *sm, · 21 unmodified lines
782794 * allocated blocks that they were built from.
783795 */
784796 for (i = superblock; !r && i < smm->begin; i++)
785− r = sm_ll_inc(&smm->ll, i, &ev);
797+ r = add_bop(smm, BOP_INC, i);
786798
787799 if (r)
788800 return r;
drivers/misc/cxl/native.c+1−1
@@ -497,6 +497,7 @@ static u64 calculate_sr(struct cxl_context *ctx) · 496 unmodified lines
497497 {
498498 u64 sr = 0;
499499
500+ set_endian(sr);
500501 if (ctx->master)
501502 sr |= CXL_PSL_SR_An_MP;
502503 if (mfspr(SPRN_LPCR) & LPCR_TC)
@@ -506,7 +507,6 @@ static u64 calculate_sr(struct cxl_context *ctx) · 3 unmodified lines
506507 sr |= CXL_PSL_SR_An_HV;
507508 } else {
508509 sr |= CXL_PSL_SR_An_PR | CXL_PSL_SR_An_R;
509− set_endian(sr);
510510 sr &= ~(CXL_PSL_SR_An_HV);
511511 if (!test_tsk_thread_flag(current, TIF_32BIT))
512512 sr |= CXL_PSL_SR_An_SF;
drivers/net/can/bfin_can.c+0−2
@@ -501,8 +501,6 @@ static int bfin_can_err(struct net_device *dev, u16 isrc, u16 status) · 500 unmodified lines
501501 cf->data[2] |= CAN_ERR_PROT_FORM;
502502 else if (status & SER)
503503 cf->data[2] |= CAN_ERR_PROT_STUFF;
504− else
505− cf->data[2] |= CAN_ERR_PROT_UNSPEC;
506504 }
507505
508506 priv->can.state = state;
drivers/net/can/c_can/c_can.c+2−5
@@ -962,7 +962,6 @@ static int c_can_handle_bus_err(struct net_device *dev, · 961 unmodified lines
962962 * type of the last error to occur on the CAN bus
963963 */
964964 cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
965− cf->data[2] |= CAN_ERR_PROT_UNSPEC;
966965
967966 switch (lec_type) {
968967 case LEC_STUFF_ERROR:
@@ -975,8 +974,7 @@ static int c_can_handle_bus_err(struct net_device *dev, · 6 unmodified lines
975974 break;
976975 case LEC_ACK_ERROR:
977976 netdev_dbg(dev, "ack error\n");
978− cf->data[3] |= (CAN_ERR_PROT_LOC_ACK |
979− CAN_ERR_PROT_LOC_ACK_DEL);
977+ cf->data[3] = CAN_ERR_PROT_LOC_ACK;
980978 break;
981979 case LEC_BIT1_ERROR:
982980 netdev_dbg(dev, "bit1 error\n");
@@ -988,8 +986,7 @@ static int c_can_handle_bus_err(struct net_device *dev, · 5 unmodified lines
988986 break;
989987 case LEC_CRC_ERROR:
990988 netdev_dbg(dev, "CRC error\n");
991− cf->data[3] |= (CAN_ERR_PROT_LOC_CRC_SEQ |
992− CAN_ERR_PROT_LOC_CRC_DEL);
989+ cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
993990 break;
994991 default:
995992 break;
drivers/net/can/cc770/cc770.c+1−1
@@ -578,7 +578,7 @@ static int cc770_err(struct net_device *dev, u8 status) · 577 unmodified lines
578578 cf->data[2] |= CAN_ERR_PROT_BIT0;
579579 break;
580580 case STAT_LEC_CRC:
581− cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ;
581+ cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
582582 break;
583583 }
584584 }
drivers/net/can/flexcan.c+2−2
@@ -535,13 +535,13 @@ static void do_bus_err(struct net_device *dev, · 534 unmodified lines
535535 if (reg_esr & FLEXCAN_ESR_ACK_ERR) {
536536 netdev_dbg(dev, "ACK_ERR irq\n");
537537 cf->can_id |= CAN_ERR_ACK;
538− cf->data[3] |= CAN_ERR_PROT_LOC_ACK;
538+ cf->data[3] = CAN_ERR_PROT_LOC_ACK;
539539 tx_errors = 1;
540540 }
541541 if (reg_esr & FLEXCAN_ESR_CRC_ERR) {
542542 netdev_dbg(dev, "CRC_ERR irq\n");
543543 cf->data[2] |= CAN_ERR_PROT_BIT;
544− cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ;
544+ cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
545545 rx_errors = 1;
546546 }
547547 if (reg_esr & FLEXCAN_ESR_FRM_ERR) {
drivers/net/can/janz-ican3.c+0−1
@@ -1096,7 +1096,6 @@ static int ican3_handle_cevtind(struct ican3_dev *mod, struct ican3_msg *msg) · 1095 unmodified lines
10961096 cf->data[2] |= CAN_ERR_PROT_STUFF;
10971097 break;
10981098 default:
1099− cf->data[2] |= CAN_ERR_PROT_UNSPEC;
11001099 cf->data[3] = ecc & ECC_SEG;
11011100 break;
11021101 }
drivers/net/can/m_can/m_can.c+2−5
@@ -487,7 +487,6 @@ static int m_can_handle_lec_err(struct net_device *dev, · 486 unmodified lines
487487 * type of the last error to occur on the CAN bus
488488 */
489489 cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
490− cf->data[2] |= CAN_ERR_PROT_UNSPEC;
491490
492491 switch (lec_type) {
493492 case LEC_STUFF_ERROR:
@@ -500,8 +499,7 @@ static int m_can_handle_lec_err(struct net_device *dev, · 6 unmodified lines
500499 break;
501500 case LEC_ACK_ERROR:
502501 netdev_dbg(dev, "ack error\n");
503− cf->data[3] |= (CAN_ERR_PROT_LOC_ACK |
504− CAN_ERR_PROT_LOC_ACK_DEL);
502+ cf->data[3] = CAN_ERR_PROT_LOC_ACK;
505503 break;
506504 case LEC_BIT1_ERROR:
507505 netdev_dbg(dev, "bit1 error\n");
@@ -513,8 +511,7 @@ static int m_can_handle_lec_err(struct net_device *dev, · 5 unmodified lines
513511 break;
514512 case LEC_CRC_ERROR:
515513 netdev_dbg(dev, "CRC error\n");
516− cf->data[3] |= (CAN_ERR_PROT_LOC_CRC_SEQ |
517− CAN_ERR_PROT_LOC_CRC_DEL);
514+ cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
518515 break;
519516 default:
520517 break;
drivers/net/can/pch_can.c+1−2
@@ -559,8 +559,7 @@ static void pch_can_error(struct net_device *ndev, u32 status) · 558 unmodified lines
559559 stats->rx_errors++;
560560 break;
561561 case PCH_CRC_ERR:
562− cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ |
563− CAN_ERR_PROT_LOC_CRC_DEL;
562+ cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
564563 priv->can.can_stats.bus_error++;
565564 stats->rx_errors++;
566565 break;
drivers/net/can/rcar_can.c+5−6
@@ -241,17 +241,16 @@ static void rcar_can_error(struct net_device *ndev) · 240 unmodified lines
241241 u8 ecsr;
242242
243243 netdev_dbg(priv->ndev, "Bus error interrupt:\n");
244− if (skb) {
244+ if (skb)
245245 cf->can_id |= CAN_ERR_BUSERROR | CAN_ERR_PROT;
246− cf->data[2] = CAN_ERR_PROT_UNSPEC;
247− }
246+
248247 ecsr = readb(&priv->regs->ecsr);
249248 if (ecsr & RCAR_CAN_ECSR_ADEF) {
250249 netdev_dbg(priv->ndev, "ACK Delimiter Error\n");
251250 tx_errors++;
252251 writeb(~RCAR_CAN_ECSR_ADEF, &priv->regs->ecsr);
253252 if (skb)
254− cf->data[3] |= CAN_ERR_PROT_LOC_ACK_DEL;
253+ cf->data[3] = CAN_ERR_PROT_LOC_ACK_DEL;
255254 }
256255 if (ecsr & RCAR_CAN_ECSR_BE0F) {
257256 netdev_dbg(priv->ndev, "Bit Error (dominant)\n");
@@ -272,7 +271,7 @@ static void rcar_can_error(struct net_device *ndev) · 14 unmodified lines
272271 rx_errors++;
273272 writeb(~RCAR_CAN_ECSR_CEF, &priv->regs->ecsr);
274273 if (skb)
275− cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ;
274+ cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
276275 }
277276 if (ecsr & RCAR_CAN_ECSR_AEF) {
278277 netdev_dbg(priv->ndev, "ACK Error\n");
@@ -280,7 +279,7 @@ static void rcar_can_error(struct net_device *ndev) · 1 unmodified line
280279 writeb(~RCAR_CAN_ECSR_AEF, &priv->regs->ecsr);
281280 if (skb) {
282281 cf->can_id |= CAN_ERR_ACK;
283− cf->data[3] |= CAN_ERR_PROT_LOC_ACK;
282+ cf->data[3] = CAN_ERR_PROT_LOC_ACK;
284283 }
285284 }
286285 if (ecsr & RCAR_CAN_ECSR_FEF) {
drivers/net/can/sja1000/sja1000.c+3−1
@@ -218,6 +218,9 @@ static void sja1000_start(struct net_device *dev) · 217 unmodified lines
218218 priv->write_reg(priv, SJA1000_RXERR, 0x0);
219219 priv->read_reg(priv, SJA1000_ECC);
220220
221+ /* clear interrupt flags */
222+ priv->read_reg(priv, SJA1000_IR);
223+
221224 /* leave reset mode */
222225 set_normal_mode(dev);
223226 }
@@ -446,7 +449,6 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status) · 222 unmodified lines
446449 cf->data[2] |= CAN_ERR_PROT_STUFF;
447450 break;
448451 default:
449− cf->data[2] |= CAN_ERR_PROT_UNSPEC;
450452 cf->data[3] = ecc & ECC_SEG;
451453 break;
452454 }
drivers/net/can/sun4i_can.c+0−1
@@ -575,7 +575,6 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status) · 574 unmodified lines
575575 cf->data[2] |= CAN_ERR_PROT_STUFF;
576576 break;
577577 default:
578− cf->data[2] |= CAN_ERR_PROT_UNSPEC;
579578 cf->data[3] = (ecc & SUN4I_STA_ERR_SEG_CODE)
580579 >> 16;
581580 break;
drivers/net/can/ti_hecc.c+2−5
@@ -722,7 +722,6 @@ static int ti_hecc_error(struct net_device *ndev, int int_status, · 721 unmodified lines
722722 if (err_status & HECC_BUS_ERROR) {
723723 ++priv->can.can_stats.bus_error;
724724 cf->can_id |= CAN_ERR_BUSERROR | CAN_ERR_PROT;
725− cf->data[2] |= CAN_ERR_PROT_UNSPEC;
726725 if (err_status & HECC_CANES_FE) {
727726 hecc_set_bit(priv, HECC_CANES, HECC_CANES_FE);
728727 cf->data[2] |= CAN_ERR_PROT_FORM;
@@ -737,13 +736,11 @@ static int ti_hecc_error(struct net_device *ndev, int int_status, · 8 unmodified lines
737736 }
738737 if (err_status & HECC_CANES_CRCE) {
739738 hecc_set_bit(priv, HECC_CANES, HECC_CANES_CRCE);
740− cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ |
741− CAN_ERR_PROT_LOC_CRC_DEL;
739+ cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
742740 }
743741 if (err_status & HECC_CANES_ACKE) {
744742 hecc_set_bit(priv, HECC_CANES, HECC_CANES_ACKE);
745− cf->data[3] |= CAN_ERR_PROT_LOC_ACK |
746− CAN_ERR_PROT_LOC_ACK_DEL;
743+ cf->data[3] = CAN_ERR_PROT_LOC_ACK;
747744 }
748745 }
749746
drivers/net/can/usb/ems_usb.c+0−1
@@ -377,7 +377,6 @@ static void ems_usb_rx_err(struct ems_usb *dev, struct ems_cpc_msg *msg) · 376 unmodified lines
377377 cf->data[2] |= CAN_ERR_PROT_STUFF;
378378 break;
379379 default:
380− cf->data[2] |= CAN_ERR_PROT_UNSPEC;
381380 cf->data[3] = ecc & SJA1000_ECC_SEG;
382381 break;
383382 }
drivers/net/can/usb/esd_usb2.c+0−1
@@ -282,7 +282,6 @@ static void esd_usb2_rx_event(struct esd_usb2_net_priv *priv, · 281 unmodified lines
282282 cf->data[2] |= CAN_ERR_PROT_STUFF;
283283 break;
284284 default:
285− cf->data[2] |= CAN_ERR_PROT_UNSPEC;
286285 cf->data[3] = ecc & SJA1000_ECC_SEG;
287286 break;
288287 }
drivers/net/can/usb/kvaser_usb.c+2−3
@@ -944,10 +944,9 @@ static void kvaser_usb_rx_error(const struct kvaser_usb *dev, · 943 unmodified lines
944944 cf->can_id |= CAN_ERR_BUSERROR | CAN_ERR_PROT;
945945
946946 if (es->leaf.error_factor & M16C_EF_ACKE)
947− cf->data[3] |= (CAN_ERR_PROT_LOC_ACK);
947+ cf->data[3] = CAN_ERR_PROT_LOC_ACK;
948948 if (es->leaf.error_factor & M16C_EF_CRCE)
949− cf->data[3] |= (CAN_ERR_PROT_LOC_CRC_SEQ |
950− CAN_ERR_PROT_LOC_CRC_DEL);
949+ cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
951950 if (es->leaf.error_factor & M16C_EF_FORME)
952951 cf->data[2] |= CAN_ERR_PROT_FORM;
953952 if (es->leaf.error_factor & M16C_EF_STFE)
drivers/net/can/usb/usb_8dev.c+1−3
@@ -401,9 +401,7 @@ static void usb_8dev_rx_err_msg(struct usb_8dev_priv *priv, · 400 unmodified lines
401401 tx_errors = 1;
402402 break;
403403 case USB_8DEV_STATUSMSG_CRC:
404− cf->data[2] |= CAN_ERR_PROT_UNSPEC;
405− cf->data[3] |= CAN_ERR_PROT_LOC_CRC_SEQ |
406− CAN_ERR_PROT_LOC_CRC_DEL;
404+ cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
407405 rx_errors = 1;
408406 break;
409407 case USB_8DEV_STATUSMSG_BIT0:
drivers/net/can/xilinx_can.c+3−6
@@ -608,17 +608,15 @@ static void xcan_err_interrupt(struct net_device *ndev, u32 isr) · 607 unmodified lines
608608
609609 /* Check for error interrupt */
610610 if (isr & XCAN_IXR_ERROR_MASK) {
611− if (skb) {
611+ if (skb)
612612 cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR;
613− cf->data[2] |= CAN_ERR_PROT_UNSPEC;
614− }
615613
616614 /* Check for Ack error interrupt */
617615 if (err_status & XCAN_ESR_ACKER_MASK) {
618616 stats->tx_errors++;
619617 if (skb) {
620618 cf->can_id |= CAN_ERR_ACK;
621− cf->data[3] |= CAN_ERR_PROT_LOC_ACK;
619+ cf->data[3] = CAN_ERR_PROT_LOC_ACK;
622620 }
623621 }
624622
@@ -654,8 +652,7 @@ static void xcan_err_interrupt(struct net_device *ndev, u32 isr) · 29 unmodified lines
654652 stats->rx_errors++;
655653 if (skb) {
656654 cf->can_id |= CAN_ERR_PROT;
657− cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ |
658− CAN_ERR_PROT_LOC_CRC_DEL;
655+ cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
659656 }
660657 }
661658 priv->can.can_stats.bus_error++;
drivers/net/ethernet/Kconfig+1−0
@@ -29,6 +29,7 @@ source "drivers/net/ethernet/apm/Kconfig" · 28 unmodified lines
2929 source "drivers/net/ethernet/apple/Kconfig"
3030 source "drivers/net/ethernet/arc/Kconfig"
3131 source "drivers/net/ethernet/atheros/Kconfig"
32+source "drivers/net/ethernet/aurora/Kconfig"
3233 source "drivers/net/ethernet/cadence/Kconfig"
3334 source "drivers/net/ethernet/adi/Kconfig"
3435 source "drivers/net/ethernet/broadcom/Kconfig"
drivers/net/ethernet/Makefile+1−0
@@ -15,6 +15,7 @@ obj-$(CONFIG_NET_XGENE) += apm/ · 14 unmodified lines
1515 obj-$(CONFIG_NET_VENDOR_APPLE) += apple/
1616 obj-$(CONFIG_NET_VENDOR_ARC) += arc/
1717 obj-$(CONFIG_NET_VENDOR_ATHEROS) += atheros/
18+obj-$(CONFIG_NET_VENDOR_AURORA) += aurora/
1819 obj-$(CONFIG_NET_CADENCE) += cadence/
1920 obj-$(CONFIG_NET_BFIN) += adi/
2021 obj-$(CONFIG_NET_VENDOR_BROADCOM) += broadcom/
drivers/net/ethernet/apm/xgene/xgene_enet_main.c+17−14
@@ -450,12 +450,12 @@ static netdev_tx_t xgene_enet_start_xmit(struct sk_buff *skb, · 449 unmodified lines
450450 return NETDEV_TX_OK;
451451 }
452452
453− pdata->ring_ops->wr_cmd(tx_ring, count);
454453 skb_tx_timestamp(skb);
455454
456455 pdata->stats.tx_packets++;
457456 pdata->stats.tx_bytes += skb->len;
458457
458+ pdata->ring_ops->wr_cmd(tx_ring, count);
459459 return NETDEV_TX_OK;
460460 }
461461
@@ -688,10 +688,10 @@ static int xgene_enet_open(struct net_device *ndev) · 226 unmodified lines
688688 mac_ops->tx_enable(pdata);
689689 mac_ops->rx_enable(pdata);
690690
691+ xgene_enet_napi_enable(pdata);
691692 ret = xgene_enet_register_irq(ndev);
692693 if (ret)
693694 return ret;
694− xgene_enet_napi_enable(pdata);
695695
696696 if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII)
697697 phy_start(pdata->phy_dev);
@@ -715,13 +715,13 @@ static int xgene_enet_close(struct net_device *ndev) · 17 unmodified lines
715715 else
716716 cancel_delayed_work_sync(&pdata->link_work);
717717
718− xgene_enet_napi_disable(pdata);
719− xgene_enet_free_irq(ndev);
720− xgene_enet_process_ring(pdata->rx_ring, -1);
721−
722718 mac_ops->tx_disable(pdata);
723719 mac_ops->rx_disable(pdata);
724720
721+ xgene_enet_free_irq(ndev);
722+ xgene_enet_napi_disable(pdata);
723+ xgene_enet_process_ring(pdata->rx_ring, -1);
724+
725725 return 0;
726726 }
727727
@@ -1474,15 +1474,15 @@ static int xgene_enet_probe(struct platform_device *pdev) · 746 unmodified lines
14741474 }
14751475 ndev->hw_features = ndev->features;
14761476
1477− ret = register_netdev(ndev);
1477+ ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64));
14781478 if (ret) {
1479− netdev_err(ndev, "Failed to register netdev\n");
1479+ netdev_err(ndev, "No usable DMA configuration\n");
14801480 goto err;
14811481 }
14821482
1483− ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64));
1483+ ret = register_netdev(ndev);
14841484 if (ret) {
1485− netdev_err(ndev, "No usable DMA configuration\n");
1485+ netdev_err(ndev, "Failed to register netdev\n");
14861486 goto err;
14871487 }
14881488
@@ -1490,14 +1490,17 @@ static int xgene_enet_probe(struct platform_device *pdev) · 1 unmodified line
14901490 if (ret)
14911491 goto err;
14921492
1493− xgene_enet_napi_add(pdata);
14941493 mac_ops = pdata->mac_ops;
1495− if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII)
1494+ if (pdata->phy_mode == PHY_INTERFACE_MODE_RGMII) {
14961495 ret = xgene_enet_mdio_config(pdata);
1497− else
1496+ if (ret)
1497+ goto err;
1498+ } else {
14981499 INIT_DELAYED_WORK(&pdata->link_work, mac_ops->link_state);
1500+ }
14991501
1500− return ret;
1502+ xgene_enet_napi_add(pdata);
1503+ return 0;
15011504 err:
15021505 unregister_netdev(ndev);
15031506 free_netdev(ndev);
drivers/net/ethernet/atheros/alx/main.c+2−0
@@ -1534,6 +1534,8 @@ static const struct pci_device_id alx_pci_tbl[] = { · 1533 unmodified lines
15341534 .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG },
15351535 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_E2200),
15361536 .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG },
1537+ { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_E2400),
1538+ .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG },
15371539 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_AR8162),
15381540 .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG },
15391541 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_AR8171) },
drivers/net/ethernet/atheros/alx/reg.h+1−0
@@ -37,6 +37,7 @@ · 36 unmodified lines
3737
3838 #define ALX_DEV_ID_AR8161 0x1091
3939 #define ALX_DEV_ID_E2200 0xe091
40+#define ALX_DEV_ID_E2400 0xe0a1
4041 #define ALX_DEV_ID_AR8162 0x1090
4142 #define ALX_DEV_ID_AR8171 0x10A1
4243 #define ALX_DEV_ID_AR8172 0x10A0
drivers/net/ethernet/aurora/Kconfig+20−0
@@ -0,0 +1,20 @@
1+config NET_VENDOR_AURORA
2+ bool "Aurora VLSI devices"
3+ help
4+ If you have a network (Ethernet) device belonging to this class,
5+ say Y.
6+
7+ Note that the answer to this question doesn't directly affect the
8+ kernel: saying N will just cause the configurator to skip all
9+ questions about Aurora devices. If you say Y, you will be asked
10+ for your specific device in the following questions.
11+
12+if NET_VENDOR_AURORA
13+
14+config AURORA_NB8800
15+ tristate "Aurora AU-NB8800 support"
16+ select PHYLIB
17+ help
18+ Support for the AU-NB8800 gigabit Ethernet controller.
19+
20+endif
drivers/net/ethernet/aurora/Makefile+1−0
@@ -0,0 +1 @@
1+obj-$(CONFIG_AURORA_NB8800) += nb8800.o
drivers/net/ethernet/aurora/nb8800.c+1552−0
@@ -0,0 +1,1552 @@
1+/*
2+ * Copyright (C) 2015 Mans Rullgard <mans@mansr.com>
3+ *
4+ * Mostly rewritten, based on driver from Sigma Designs. Original
5+ * copyright notice below.
6+ *
7+ *
8+ * Driver for tangox SMP864x/SMP865x/SMP867x/SMP868x builtin Ethernet Mac.
9+ *
10+ * Copyright (C) 2005 Maxime Bizon <mbizon@freebox.fr>
11+ *
12+ * This program is free software; you can redistribute it and/or modify
13+ * it under the terms of the GNU General Public License as published by
14+ * the Free Software Foundation; either version 2 of the License, or
15+ * (at your option) any later version.
16+ *
17+ * This program is distributed in the hope that it will be useful,
18+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
19+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+ * GNU General Public License for more details.
21+ */
22+
23+#include <linux/module.h>
24+#include <linux/etherdevice.h>
25+#include <linux/delay.h>
26+#include <linux/ethtool.h>
27+#include <linux/interrupt.h>
28+#include <linux/platform_device.h>
29+#include <linux/of_device.h>
30+#include <linux/of_mdio.h>
31+#include <linux/of_net.h>
32+#include <linux/dma-mapping.h>
33+#include <linux/phy.h>
34+#include <linux/cache.h>
35+#include <linux/jiffies.h>
36+#include <linux/io.h>
37+#include <linux/iopoll.h>
38+#include <asm/barrier.h>
39+
40+#include "nb8800.h"
41+
42+static void nb8800_tx_done(struct net_device *dev);
43+static int nb8800_dma_stop(struct net_device *dev);
44+
45+static inline u8 nb8800_readb(struct nb8800_priv *priv, int reg)
46+{
47+ return readb_relaxed(priv->base + reg);
48+}
49+
50+static inline u32 nb8800_readl(struct nb8800_priv *priv, int reg)
51+{
52+ return readl_relaxed(priv->base + reg);
53+}
54+
55+static inline void nb8800_writeb(struct nb8800_priv *priv, int reg, u8 val)
56+{
57+ writeb_relaxed(val, priv->base + reg);
58+}
59+
60+static inline void nb8800_writew(struct nb8800_priv *priv, int reg, u16 val)
61+{
62+ writew_relaxed(val, priv->base + reg);
63+}
64+
65+static inline void nb8800_writel(struct nb8800_priv *priv, int reg, u32 val)
66+{
67+ writel_relaxed(val, priv->base + reg);
68+}
69+
70+static inline void nb8800_maskb(struct nb8800_priv *priv, int reg,
71+ u32 mask, u32 val)
72+{
73+ u32 old = nb8800_readb(priv, reg);
74+ u32 new = (old & ~mask) | (val & mask);
75+
76+ if (new != old)
77+ nb8800_writeb(priv, reg, new);
78+}
79+
80+static inline void nb8800_maskl(struct nb8800_priv *priv, int reg,
81+ u32 mask, u32 val)
82+{
83+ u32 old = nb8800_readl(priv, reg);
84+ u32 new = (old & ~mask) | (val & mask);
85+
86+ if (new != old)
87+ nb8800_writel(priv, reg, new);
88+}
89+
90+static inline void nb8800_modb(struct nb8800_priv *priv, int reg, u8 bits,
91+ bool set)
92+{
93+ nb8800_maskb(priv, reg, bits, set ? bits : 0);
94+}
95+
96+static inline void nb8800_setb(struct nb8800_priv *priv, int reg, u8 bits)
97+{
98+ nb8800_maskb(priv, reg, bits, bits);
99+}
100+
101+static inline void nb8800_clearb(struct nb8800_priv *priv, int reg, u8 bits)
102+{
103+ nb8800_maskb(priv, reg, bits, 0);
104+}
105+
106+static inline void nb8800_modl(struct nb8800_priv *priv, int reg, u32 bits,
107+ bool set)
108+{
109+ nb8800_maskl(priv, reg, bits, set ? bits : 0);
110+}
111+
112+static inline void nb8800_setl(struct nb8800_priv *priv, int reg, u32 bits)
113+{
114+ nb8800_maskl(priv, reg, bits, bits);
115+}
116+
117+static inline void nb8800_clearl(struct nb8800_priv *priv, int reg, u32 bits)
118+{
119+ nb8800_maskl(priv, reg, bits, 0);
120+}
121+
122+static int nb8800_mdio_wait(struct mii_bus *bus)
123+{
124+ struct nb8800_priv *priv = bus->priv;
125+ u32 val;
126+
127+ return readl_poll_timeout_atomic(priv->base + NB8800_MDIO_CMD,
128+ val, !(val & MDIO_CMD_GO), 1, 1000);
129+}
130+
131+static int nb8800_mdio_cmd(struct mii_bus *bus, u32 cmd)
132+{
133+ struct nb8800_priv *priv = bus->priv;
134+ int err;
135+
136+ err = nb8800_mdio_wait(bus);
137+ if (err)
138+ return err;
139+
140+ nb8800_writel(priv, NB8800_MDIO_CMD, cmd);
141+ udelay(10);
142+ nb8800_writel(priv, NB8800_MDIO_CMD, cmd | MDIO_CMD_GO);
143+
144+ return nb8800_mdio_wait(bus);
145+}
146+
147+static int nb8800_mdio_read(struct mii_bus *bus, int phy_id, int reg)
148+{
149+ struct nb8800_priv *priv = bus->priv;
150+ u32 val;
151+ int err;
152+
153+ err = nb8800_mdio_cmd(bus, MDIO_CMD_ADDR(phy_id) | MDIO_CMD_REG(reg));
154+ if (err)
155+ return err;
156+
157+ val = nb8800_readl(priv, NB8800_MDIO_STS);
158+ if (val & MDIO_STS_ERR)
159+ return 0xffff;
160+
161+ return val & 0xffff;
162+}
163+
164+static int nb8800_mdio_write(struct mii_bus *bus, int phy_id, int reg, u16 val)
165+{
166+ u32 cmd = MDIO_CMD_ADDR(phy_id) | MDIO_CMD_REG(reg) |
167+ MDIO_CMD_DATA(val) | MDIO_CMD_WR;
168+
169+ return nb8800_mdio_cmd(bus, cmd);
170+}
171+
172+static void nb8800_mac_tx(struct net_device *dev, bool enable)
173+{
174+ struct nb8800_priv *priv = netdev_priv(dev);
175+
176+ while (nb8800_readl(priv, NB8800_TXC_CR) & TCR_EN)
177+ cpu_relax();
178+
179+ nb8800_modb(priv, NB8800_TX_CTL1, TX_EN, enable);
180+}
181+
182+static void nb8800_mac_rx(struct net_device *dev, bool enable)
183+{
184+ nb8800_modb(netdev_priv(dev), NB8800_RX_CTL, RX_EN, enable);
185+}
186+
187+static void nb8800_mac_af(struct net_device *dev, bool enable)
188+{
189+ nb8800_modb(netdev_priv(dev), NB8800_RX_CTL, RX_AF_EN, enable);
190+}
191+
192+static void nb8800_start_rx(struct net_device *dev)
193+{
194+ nb8800_setl(netdev_priv(dev), NB8800_RXC_CR, RCR_EN);
195+}
196+
197+static int nb8800_alloc_rx(struct net_device *dev, unsigned int i, bool napi)
198+{
199+ struct nb8800_priv *priv = netdev_priv(dev);
200+ struct nb8800_rx_desc *rxd = &priv->rx_descs[i];
201+ struct nb8800_rx_buf *rxb = &priv->rx_bufs[i];
202+ int size = L1_CACHE_ALIGN(RX_BUF_SIZE);
203+ dma_addr_t dma_addr;
204+ struct page *page;
205+ unsigned long offset;
206+ void *data;
207+
208+ data = napi ? napi_alloc_frag(size) : netdev_alloc_frag(size);
209+ if (!data)
210+ return -ENOMEM;
211+
212+ page = virt_to_head_page(data);
213+ offset = data - page_address(page);
214+
215+ dma_addr = dma_map_page(&dev->dev, page, offset, RX_BUF_SIZE,
216+ DMA_FROM_DEVICE);
217+
218+ if (dma_mapping_error(&dev->dev, dma_addr)) {
219+ skb_free_frag(data);
220+ return -ENOMEM;
221+ }
222+
223+ rxb->page = page;
224+ rxb->offset = offset;
225+ rxd->desc.s_addr = dma_addr;
226+
227+ return 0;
228+}
229+
230+static void nb8800_receive(struct net_device *dev, unsigned int i,
231+ unsigned int len)
232+{
233+ struct nb8800_priv *priv = netdev_priv(dev);
234+ struct nb8800_rx_desc *rxd = &priv->rx_descs[i];
235+ struct page *page = priv->rx_bufs[i].page;
236+ int offset = priv->rx_bufs[i].offset;
237+ void *data = page_address(page) + offset;
238+ dma_addr_t dma = rxd->desc.s_addr;
239+ struct sk_buff *skb;
240+ unsigned int size;
241+ int err;
242+
243+ size = len <= RX_COPYBREAK ? len : RX_COPYHDR;
244+
245+ skb = napi_alloc_skb(&priv->napi, size);
246+ if (!skb) {
247+ netdev_err(dev, "rx skb allocation failed\n");
248+ dev->stats.rx_dropped++;
249+ return;
250+ }
251+
252+ if (len <= RX_COPYBREAK) {
253+ dma_sync_single_for_cpu(&dev->dev, dma, len, DMA_FROM_DEVICE);
254+ memcpy(skb_put(skb, len), data, len);
255+ dma_sync_single_for_device(&dev->dev, dma, len,
256+ DMA_FROM_DEVICE);
257+ } else {
258+ err = nb8800_alloc_rx(dev, i, true);
259+ if (err) {
260+ netdev_err(dev, "rx buffer allocation failed\n");
261+ dev->stats.rx_dropped++;
262+ return;
263+ }
264+
265+ dma_unmap_page(&dev->dev, dma, RX_BUF_SIZE, DMA_FROM_DEVICE);
266+ memcpy(skb_put(skb, RX_COPYHDR), data, RX_COPYHDR);
267+ skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page,
268+ offset + RX_COPYHDR, len - RX_COPYHDR,
269+ RX_BUF_SIZE);
270+ }
271+
272+ skb->protocol = eth_type_trans(skb, dev);
273+ napi_gro_receive(&priv->napi, skb);
274+}
275+
276+static void nb8800_rx_error(struct net_device *dev, u32 report)
277+{
278+ if (report & RX_LENGTH_ERR)
279+ dev->stats.rx_length_errors++;
280+
281+ if (report & RX_FCS_ERR)
282+ dev->stats.rx_crc_errors++;
283+
284+ if (report & RX_FIFO_OVERRUN)
285+ dev->stats.rx_fifo_errors++;
286+
287+ if (report & RX_ALIGNMENT_ERROR)
288+ dev->stats.rx_frame_errors++;
289+
290+ dev->stats.rx_errors++;
291+}
292+
293+static int nb8800_poll(struct napi_struct *napi, int budget)
294+{
295+ struct net_device *dev = napi->dev;
296+ struct nb8800_priv *priv = netdev_priv(dev);
297+ struct nb8800_rx_desc *rxd;
298+ unsigned int last = priv->rx_eoc;
299+ unsigned int next;
300+ int work = 0;
301+
302+ nb8800_tx_done(dev);
303+
304+again:
305+ while (work < budget) {
306+ struct nb8800_rx_buf *rxb;
307+ unsigned int len;
308+
309+ next = (last + 1) % RX_DESC_COUNT;
310+
311+ rxb = &priv->rx_bufs[next];
312+ rxd = &priv->rx_descs[next];
313+
314+ if (!rxd->report)
315+ break;
316+
317+ len = RX_BYTES_TRANSFERRED(rxd->report);
318+
319+ if (IS_RX_ERROR(rxd->report))
320+ nb8800_rx_error(dev, rxd->report);
321+ else
322+ nb8800_receive(dev, next, len);
323+
324+ dev->stats.rx_packets++;
325+ dev->stats.rx_bytes += len;
326+
327+ if (rxd->report & RX_MULTICAST_PKT)
328+ dev->stats.multicast++;
329+
330+ rxd->report = 0;
331+ last = next;
332+ work++;
333+ }
334+
335+ if (work) {
336+ priv->rx_descs[last].desc.config |= DESC_EOC;
337+ wmb(); /* ensure new EOC is written before clearing old */
338+ priv->rx_descs[priv->rx_eoc].desc.config &= ~DESC_EOC;
339+ priv->rx_eoc = last;
340+ nb8800_start_rx(dev);
341+ }
342+
343+ if (work < budget) {
344+ nb8800_writel(priv, NB8800_RX_ITR, priv->rx_itr_irq);
345+
346+ /* If a packet arrived after we last checked but
347+ * before writing RX_ITR, the interrupt will be
348+ * delayed, so we retrieve it now.
349+ */
350+ if (priv->rx_descs[next].report)
351+ goto again;
352+
353+ napi_complete_done(napi, work);
354+ }
355+
356+ return work;
357+}
358+
359+static void __nb8800_tx_dma_start(struct net_device *dev)
360+{
361+ struct nb8800_priv *priv = netdev_priv(dev);
362+ struct nb8800_tx_buf *txb;
363+ u32 txc_cr;
364+
365+ txb = &priv->tx_bufs[priv->tx_queue];
366+ if (!txb->ready)
367+ return;
368+
369+ txc_cr = nb8800_readl(priv, NB8800_TXC_CR);
370+ if (txc_cr & TCR_EN)
371+ return;
372+
373+ nb8800_writel(priv, NB8800_TX_DESC_ADDR, txb->dma_desc);
374+ wmb(); /* ensure desc addr is written before starting DMA */
375+ nb8800_writel(priv, NB8800_TXC_CR, txc_cr | TCR_EN);
376+
377+ priv->tx_queue = (priv->tx_queue + txb->chain_len) % TX_DESC_COUNT;
378+}
379+
380+static void nb8800_tx_dma_start(struct net_device *dev)
381+{
382+ struct nb8800_priv *priv = netdev_priv(dev);
383+
384+ spin_lock_irq(&priv->tx_lock);
385+ __nb8800_tx_dma_start(dev);
386+ spin_unlock_irq(&priv->tx_lock);
387+}
388+
389+static void nb8800_tx_dma_start_irq(struct net_device *dev)
390+{
391+ struct nb8800_priv *priv = netdev_priv(dev);
392+
393+ spin_lock(&priv->tx_lock);
394+ __nb8800_tx_dma_start(dev);
395+ spin_unlock(&priv->tx_lock);
396+}
397+
398+static int nb8800_xmit(struct sk_buff *skb, struct net_device *dev)
399+{
400+ struct nb8800_priv *priv = netdev_priv(dev);
401+ struct nb8800_tx_desc *txd;
402+ struct nb8800_tx_buf *txb;
403+ struct nb8800_dma_desc *desc;
404+ dma_addr_t dma_addr;
405+ unsigned int dma_len;
406+ unsigned int align;
407+ unsigned int next;
408+
409+ if (atomic_read(&priv->tx_free) <= NB8800_DESC_LOW) {
410+ netif_stop_queue(dev);
411+ return NETDEV_TX_BUSY;
412+ }
413+
414+ align = (8 - (uintptr_t)skb->data) & 7;
415+
416+ dma_len = skb->len - align;
417+ dma_addr = dma_map_single(&dev->dev, skb->data + align,
418+ dma_len, DMA_TO_DEVICE);
419+
420+ if (dma_mapping_error(&dev->dev, dma_addr)) {
421+ netdev_err(dev, "tx dma mapping error\n");
422+ kfree_skb(skb);
423+ dev->stats.tx_dropped++;
424+ return NETDEV_TX_OK;
425+ }
426+
427+ if (atomic_dec_return(&priv->tx_free) <= NB8800_DESC_LOW) {
428+ netif_stop_queue(dev);
429+ skb->xmit_more = 0;
430+ }
431+
432+ next = priv->tx_next;
433+ txb = &priv->tx_bufs[next];
434+ txd = &priv->tx_descs[next];
435+ desc = &txd->desc[0];
436+
437+ next = (next + 1) % TX_DESC_COUNT;
438+
439+ if (align) {
440+ memcpy(txd->buf, skb->data, align);
441+
442+ desc->s_addr =
443+ txb->dma_desc + offsetof(struct nb8800_tx_desc, buf);
444+ desc->n_addr = txb->dma_desc + sizeof(txd->desc[0]);
445+ desc->config = DESC_BTS(2) | DESC_DS | align;
446+
447+ desc++;
448+ }
449+
450+ desc->s_addr = dma_addr;
451+ desc->n_addr = priv->tx_bufs[next].dma_desc;
452+ desc->config = DESC_BTS(2) | DESC_DS | DESC_EOF | dma_len;
453+
454+ if (!skb->xmit_more)
455+ desc->config |= DESC_EOC;
456+
457+ txb->skb = skb;
458+ txb->dma_addr = dma_addr;
459+ txb->dma_len = dma_len;
460+
461+ if (!priv->tx_chain) {
462+ txb->chain_len = 1;
463+ priv->tx_chain = txb;
464+ } else {
465+ priv->tx_chain->chain_len++;
466+ }
467+
468+ netdev_sent_queue(dev, skb->len);
469+
470+ priv->tx_next = next;
471+
472+ if (!skb->xmit_more) {
473+ smp_wmb();
474+ priv->tx_chain->ready = true;
475+ priv->tx_chain = NULL;
476+ nb8800_tx_dma_start(dev);
477+ }
478+
479+ return NETDEV_TX_OK;
480+}
481+
482+static void nb8800_tx_error(struct net_device *dev, u32 report)
483+{
484+ if (report & TX_LATE_COLLISION)
485+ dev->stats.collisions++;
486+
487+ if (report & TX_PACKET_DROPPED)
488+ dev->stats.tx_dropped++;
489+
490+ if (report & TX_FIFO_UNDERRUN)
491+ dev->stats.tx_fifo_errors++;
492+
493+ dev->stats.tx_errors++;
494+}
495+
496+static void nb8800_tx_done(struct net_device *dev)
497+{
498+ struct nb8800_priv *priv = netdev_priv(dev);
499+ unsigned int limit = priv->tx_next;
500+ unsigned int done = priv->tx_done;
501+ unsigned int packets = 0;
502+ unsigned int len = 0;
503+
504+ while (done != limit) {
505+ struct nb8800_tx_desc *txd = &priv->tx_descs[done];
506+ struct nb8800_tx_buf *txb = &priv->tx_bufs[done];
507+ struct sk_buff *skb;
508+
509+ if (!txd->report)
510+ break;
511+
512+ skb = txb->skb;
513+ len += skb->len;
514+
515+ dma_unmap_single(&dev->dev, txb->dma_addr, txb->dma_len,
516+ DMA_TO_DEVICE);
517+
518+ if (IS_TX_ERROR(txd->report)) {
519+ nb8800_tx_error(dev, txd->report);
520+ kfree_skb(skb);
521+ } else {
522+ consume_skb(skb);
523+ }
524+
525+ dev->stats.tx_packets++;
526+ dev->stats.tx_bytes += TX_BYTES_TRANSFERRED(txd->report);
527+ dev->stats.collisions += TX_EARLY_COLLISIONS(txd->report);
528+
529+ txb->skb = NULL;
530+ txb->ready = false;
531+ txd->report = 0;
532+
533+ done = (done + 1) % TX_DESC_COUNT;
534+ packets++;
535+ }
536+
537+ if (packets) {
538+ smp_mb__before_atomic();
539+ atomic_add(packets, &priv->tx_free);
540+ netdev_completed_queue(dev, packets, len);
541+ netif_wake_queue(dev);
542+ priv->tx_done = done;
543+ }
544+}
545+
546+static irqreturn_t nb8800_irq(int irq, void *dev_id)
547+{
548+ struct net_device *dev = dev_id;
549+ struct nb8800_priv *priv = netdev_priv(dev);
550+ irqreturn_t ret = IRQ_NONE;
551+ u32 val;
552+
553+ /* tx interrupt */
554+ val = nb8800_readl(priv, NB8800_TXC_SR);
555+ if (val) {
556+ nb8800_writel(priv, NB8800_TXC_SR, val);
557+
558+ if (val & TSR_DI)
559+ nb8800_tx_dma_start_irq(dev);
560+
561+ if (val & TSR_TI)
562+ napi_schedule_irqoff(&priv->napi);
563+
564+ if (unlikely(val & TSR_DE))
565+ netdev_err(dev, "TX DMA error\n");
566+
567+ /* should never happen with automatic status retrieval */
568+ if (unlikely(val & TSR_TO))
569+ netdev_err(dev, "TX Status FIFO overflow\n");
570+
571+ ret = IRQ_HANDLED;
572+ }
573+
574+ /* rx interrupt */
575+ val = nb8800_readl(priv, NB8800_RXC_SR);
576+ if (val) {
577+ nb8800_writel(priv, NB8800_RXC_SR, val);
578+
579+ if (likely(val & (RSR_RI | RSR_DI))) {
580+ nb8800_writel(priv, NB8800_RX_ITR, priv->rx_itr_poll);
581+ napi_schedule_irqoff(&priv->napi);
582+ }
583+
584+ if (unlikely(val & RSR_DE))
585+ netdev_err(dev, "RX DMA error\n");
586+
587+ /* should never happen with automatic status retrieval */
588+ if (unlikely(val & RSR_RO))
589+ netdev_err(dev, "RX Status FIFO overflow\n");
590+
591+ ret = IRQ_HANDLED;
592+ }
593+
594+ return ret;
595+}
596+
597+static void nb8800_mac_config(struct net_device *dev)
598+{
599+ struct nb8800_priv *priv = netdev_priv(dev);
600+ bool gigabit = priv->speed == SPEED_1000;
601+ u32 mac_mode_mask = RGMII_MODE | HALF_DUPLEX | GMAC_MODE;
602+ u32 mac_mode = 0;
603+ u32 slot_time;
604+ u32 phy_clk;
605+ u32 ict;
606+
607+ if (!priv->duplex)
608+ mac_mode |= HALF_DUPLEX;
609+
610+ if (gigabit) {
611+ if (priv->phy_mode == PHY_INTERFACE_MODE_RGMII)
612+ mac_mode |= RGMII_MODE;
613+
614+ mac_mode |= GMAC_MODE;
615+ phy_clk = 125000000;
616+
617+ /* Should be 512 but register is only 8 bits */
618+ slot_time = 255;
619+ } else {
620+ phy_clk = 25000000;
621+ slot_time = 128;
622+ }
623+
624+ ict = DIV_ROUND_UP(phy_clk, clk_get_rate(priv->clk));
625+
626+ nb8800_writeb(priv, NB8800_IC_THRESHOLD, ict);
627+ nb8800_writeb(priv, NB8800_SLOT_TIME, slot_time);
628+ nb8800_maskb(priv, NB8800_MAC_MODE, mac_mode_mask, mac_mode);
629+}
630+
631+static void nb8800_pause_config(struct net_device *dev)
632+{
633+ struct nb8800_priv *priv = netdev_priv(dev);
634+ struct phy_device *phydev = priv->phydev;
635+ u32 rxcr;
636+
637+ if (priv->pause_aneg) {
638+ if (!phydev || !phydev->link)
639+ return;
640+
641+ priv->pause_rx = phydev->pause;
642+ priv->pause_tx = phydev->pause ^ phydev->asym_pause;
643+ }
644+
645+ nb8800_modb(priv, NB8800_RX_CTL, RX_PAUSE_EN, priv->pause_rx);
646+
647+ rxcr = nb8800_readl(priv, NB8800_RXC_CR);
648+ if (!!(rxcr & RCR_FL) == priv->pause_tx)
649+ return;
650+
651+ if (netif_running(dev)) {
652+ napi_disable(&priv->napi);
653+ netif_tx_lock_bh(dev);
654+ nb8800_dma_stop(dev);
655+ nb8800_modl(priv, NB8800_RXC_CR, RCR_FL, priv->pause_tx);
656+ nb8800_start_rx(dev);
657+ netif_tx_unlock_bh(dev);
658+ napi_enable(&priv->napi);
659+ } else {
660+ nb8800_modl(priv, NB8800_RXC_CR, RCR_FL, priv->pause_tx);
661+ }
662+}
663+
664+static void nb8800_link_reconfigure(struct net_device *dev)
665+{
666+ struct nb8800_priv *priv = netdev_priv(dev);
667+ struct phy_device *phydev = priv->phydev;
668+ int change = 0;
669+
670+ if (phydev->link) {
671+ if (phydev->speed != priv->speed) {
672+ priv->speed = phydev->speed;
673+ change = 1;
674+ }
675+
676+ if (phydev->duplex != priv->duplex) {
677+ priv->duplex = phydev->duplex;
678+ change = 1;
679+ }
680+
681+ if (change)
682+ nb8800_mac_config(dev);
683+
684+ nb8800_pause_config(dev);
685+ }
686+
687+ if (phydev->link != priv->link) {
688+ priv->link = phydev->link;
689+ change = 1;
690+ }
691+
692+ if (change)
693+ phy_print_status(priv->phydev);
694+}
695+
696+static void nb8800_update_mac_addr(struct net_device *dev)
697+{
698+ struct nb8800_priv *priv = netdev_priv(dev);
699+ int i;
700+
701+ for (i = 0; i < ETH_ALEN; i++)
702+ nb8800_writeb(priv, NB8800_SRC_ADDR(i), dev->dev_addr[i]);
703+
704+ for (i = 0; i < ETH_ALEN; i++)
705+ nb8800_writeb(priv, NB8800_UC_ADDR(i), dev->dev_addr[i]);
706+}
707+
708+static int nb8800_set_mac_address(struct net_device *dev, void *addr)
709+{
710+ struct sockaddr *sock = addr;
711+
712+ if (netif_running(dev))
713+ return -EBUSY;
714+
715+ ether_addr_copy(dev->dev_addr, sock->sa_data);
716+ nb8800_update_mac_addr(dev);
717+
718+ return 0;
719+}
720+
721+static void nb8800_mc_init(struct net_device *dev, int val)
722+{
723+ struct nb8800_priv *priv = netdev_priv(dev);
724+
725+ nb8800_writeb(priv, NB8800_MC_INIT, val);
726+ readb_poll_timeout_atomic(priv->base + NB8800_MC_INIT, val, !val,
727+ 1, 1000);
728+}
729+
730+static void nb8800_set_rx_mode(struct net_device *dev)
731+{
732+ struct nb8800_priv *priv = netdev_priv(dev);
733+ struct netdev_hw_addr *ha;
734+ int i;
735+
736+ if (dev->flags & (IFF_PROMISC | IFF_ALLMULTI)) {
737+ nb8800_mac_af(dev, false);
738+ return;
739+ }
740+
741+ nb8800_mac_af(dev, true);
742+ nb8800_mc_init(dev, 0);
743+
744+ netdev_for_each_mc_addr(ha, dev) {
745+ for (i = 0; i < ETH_ALEN; i++)
746+ nb8800_writeb(priv, NB8800_MC_ADDR(i), ha->addr[i]);
747+
748+ nb8800_mc_init(dev, 0xff);
749+ }
750+}
751+
752+#define RX_DESC_SIZE (RX_DESC_COUNT * sizeof(struct nb8800_rx_desc))
753+#define TX_DESC_SIZE (TX_DESC_COUNT * sizeof(struct nb8800_tx_desc))
754+
755+static void nb8800_dma_free(struct net_device *dev)
756+{
757+ struct nb8800_priv *priv = netdev_priv(dev);
758+ unsigned int i;
759+
760+ if (priv->rx_bufs) {
761+ for (i = 0; i < RX_DESC_COUNT; i++)
762+ if (priv->rx_bufs[i].page)
763+ put_page(priv->rx_bufs[i].page);
764+
765+ kfree(priv->rx_bufs);
766+ priv->rx_bufs = NULL;
767+ }
768+
769+ if (priv->tx_bufs) {
770+ for (i = 0; i < TX_DESC_COUNT; i++)
771+ kfree_skb(priv->tx_bufs[i].skb);
772+
773+ kfree(priv->tx_bufs);
774+ priv->tx_bufs = NULL;
775+ }
776+
777+ if (priv->rx_descs) {
778+ dma_free_coherent(dev->dev.parent, RX_DESC_SIZE, priv->rx_descs,
779+ priv->rx_desc_dma);
780+ priv->rx_descs = NULL;
781+ }
782+
783+ if (priv->tx_descs) {
784+ dma_free_coherent(dev->dev.parent, TX_DESC_SIZE, priv->tx_descs,
785+ priv->tx_desc_dma);
786+ priv->tx_descs = NULL;
787+ }
788+}
789+
790+static void nb8800_dma_reset(struct net_device *dev)
791+{
792+ struct nb8800_priv *priv = netdev_priv(dev);
793+ struct nb8800_rx_desc *rxd;
794+ struct nb8800_tx_desc *txd;
795+ unsigned int i;
796+
797+ for (i = 0; i < RX_DESC_COUNT; i++) {
798+ dma_addr_t rx_dma = priv->rx_desc_dma + i * sizeof(*rxd);
799+
800+ rxd = &priv->rx_descs[i];
801+ rxd->desc.n_addr = rx_dma + sizeof(*rxd);
802+ rxd->desc.r_addr =
803+ rx_dma + offsetof(struct nb8800_rx_desc, report);
804+ rxd->desc.config = priv->rx_dma_config;
805+ rxd->report = 0;
806+ }
807+
808+ rxd->desc.n_addr = priv->rx_desc_dma;
809+ rxd->desc.config |= DESC_EOC;
810+
811+ priv->rx_eoc = RX_DESC_COUNT - 1;
812+
813+ for (i = 0; i < TX_DESC_COUNT; i++) {
814+ struct nb8800_tx_buf *txb = &priv->tx_bufs[i];
815+ dma_addr_t r_dma = txb->dma_desc +
816+ offsetof(struct nb8800_tx_desc, report);
817+
818+ txd = &priv->tx_descs[i];
819+ txd->desc[0].r_addr = r_dma;
820+ txd->desc[1].r_addr = r_dma;
821+ txd->report = 0;
822+ }
823+
824+ priv->tx_next = 0;
825+ priv->tx_queue = 0;
826+ priv->tx_done = 0;
827+ atomic_set(&priv->tx_free, TX_DESC_COUNT);
828+
829+ nb8800_writel(priv, NB8800_RX_DESC_ADDR, priv->rx_desc_dma);
830+
831+ wmb(); /* ensure all setup is written before starting */
832+}
833+
834+static int nb8800_dma_init(struct net_device *dev)
835+{
836+ struct nb8800_priv *priv = netdev_priv(dev);
837+ unsigned int n_rx = RX_DESC_COUNT;
838+ unsigned int n_tx = TX_DESC_COUNT;
839+ unsigned int i;
840+ int err;
841+
842+ priv->rx_descs = dma_alloc_coherent(dev->dev.parent, RX_DESC_SIZE,
843+ &priv->rx_desc_dma, GFP_KERNEL);
844+ if (!priv->rx_descs)
845+ goto err_out;
846+
847+ priv->rx_bufs = kcalloc(n_rx, sizeof(*priv->rx_bufs), GFP_KERNEL);
848+ if (!priv->rx_bufs)
849+ goto err_out;
850+
851+ for (i = 0; i < n_rx; i++) {
852+ err = nb8800_alloc_rx(dev, i, false);
853+ if (err)
854+ goto err_out;
855+ }
856+
857+ priv->tx_descs = dma_alloc_coherent(dev->dev.parent, TX_DESC_SIZE,
858+ &priv->tx_desc_dma, GFP_KERNEL);
859+ if (!priv->tx_descs)
860+ goto err_out;
861+
862+ priv->tx_bufs = kcalloc(n_tx, sizeof(*priv->tx_bufs), GFP_KERNEL);
863+ if (!priv->tx_bufs)
864+ goto err_out;
865+
866+ for (i = 0; i < n_tx; i++)
867+ priv->tx_bufs[i].dma_desc =
868+ priv->tx_desc_dma + i * sizeof(struct nb8800_tx_desc);
869+
870+ nb8800_dma_reset(dev);
871+
872+ return 0;
873+
874+err_out:
875+ nb8800_dma_free(dev);
876+
877+ return -ENOMEM;
878+}
879+
880+static int nb8800_dma_stop(struct net_device *dev)
881+{
882+ struct nb8800_priv *priv = netdev_priv(dev);
883+ struct nb8800_tx_buf *txb = &priv->tx_bufs[0];
884+ struct nb8800_tx_desc *txd = &priv->tx_descs[0];
885+ int retry = 5;
886+ u32 txcr;
887+ u32 rxcr;
888+ int err;
889+ unsigned int i;
890+
891+ /* wait for tx to finish */
892+ err = readl_poll_timeout_atomic(priv->base + NB8800_TXC_CR, txcr,
893+ !(txcr & TCR_EN) &&
894+ priv->tx_done == priv->tx_next,
895+ 1000, 1000000);
896+ if (err)
897+ return err;
898+
899+ /* The rx DMA only stops if it reaches the end of chain.
900+ * To make this happen, we set the EOC flag on all rx
901+ * descriptors, put the device in loopback mode, and send
902+ * a few dummy frames. The interrupt handler will ignore
903+ * these since NAPI is disabled and no real frames are in
904+ * the tx queue.
905+ */
906+
907+ for (i = 0; i < RX_DESC_COUNT; i++)
908+ priv->rx_descs[i].desc.config |= DESC_EOC;
909+
910+ txd->desc[0].s_addr =
911+ txb->dma_desc + offsetof(struct nb8800_tx_desc, buf);
912+ txd->desc[0].config = DESC_BTS(2) | DESC_DS | DESC_EOF | DESC_EOC | 8;
913+ memset(txd->buf, 0, sizeof(txd->buf));
914+
915+ nb8800_mac_af(dev, false);
916+ nb8800_setb(priv, NB8800_MAC_MODE, LOOPBACK_EN);
917+
918+ do {
919+ nb8800_writel(priv, NB8800_TX_DESC_ADDR, txb->dma_desc);
920+ wmb();
921+ nb8800_writel(priv, NB8800_TXC_CR, txcr | TCR_EN);
922+
923+ err = readl_poll_timeout_atomic(priv->base + NB8800_RXC_CR,
924+ rxcr, !(rxcr & RCR_EN),
925+ 1000, 100000);
926+ } while (err && --retry);
927+
928+ nb8800_mac_af(dev, true);
929+ nb8800_clearb(priv, NB8800_MAC_MODE, LOOPBACK_EN);
930+ nb8800_dma_reset(dev);
931+
932+ return retry ? 0 : -ETIMEDOUT;
933+}
934+
935+static void nb8800_pause_adv(struct net_device *dev)
936+{
937+ struct nb8800_priv *priv = netdev_priv(dev);
938+ u32 adv = 0;
939+
940+ if (!priv->phydev)
941+ return;
942+
943+ if (priv->pause_rx)
944+ adv |= ADVERTISED_Pause | ADVERTISED_Asym_Pause;
945+ if (priv->pause_tx)
946+ adv ^= ADVERTISED_Asym_Pause;
947+
948+ priv->phydev->supported |= adv;
949+ priv->phydev->advertising |= adv;
950+}
951+
952+static int nb8800_open(struct net_device *dev)
953+{
954+ struct nb8800_priv *priv = netdev_priv(dev);
955+ int err;
956+
957+ /* clear any pending interrupts */
958+ nb8800_writel(priv, NB8800_RXC_SR, 0xf);
959+ nb8800_writel(priv, NB8800_TXC_SR, 0xf);
960+
961+ err = nb8800_dma_init(dev);
962+ if (err)
963+ return err;
964+
965+ err = request_irq(dev->irq, nb8800_irq, 0, dev_name(&dev->dev), dev);
966+ if (err)
967+ goto err_free_dma;
968+
969+ nb8800_mac_rx(dev, true);
970+ nb8800_mac_tx(dev, true);
971+
972+ priv->phydev = of_phy_connect(dev, priv->phy_node,
973+ nb8800_link_reconfigure, 0,
974+ priv->phy_mode);
975+ if (!priv->phydev)
976+ goto err_free_irq;
977+
978+ nb8800_pause_adv(dev);
979+
980+ netdev_reset_queue(dev);
981+ napi_enable(&priv->napi);
982+ netif_start_queue(dev);
983+
984+ nb8800_start_rx(dev);
985+ phy_start(priv->phydev);
986+
987+ return 0;
988+
989+err_free_irq:
990+ free_irq(dev->irq, dev);
991+err_free_dma:
992+ nb8800_dma_free(dev);
993+
994+ return err;
995+}
996+
997+static int nb8800_stop(struct net_device *dev)
998+{
999+ struct nb8800_priv *priv = netdev_priv(dev);
1000+
1001+ phy_stop(priv->phydev);
1002+
1003+ netif_stop_queue(dev);
1004+ napi_disable(&priv->napi);
1005+
1006+ nb8800_dma_stop(dev);
1007+ nb8800_mac_rx(dev, false);
1008+ nb8800_mac_tx(dev, false);
1009+
1010+ phy_disconnect(priv->phydev);
1011+ priv->phydev = NULL;
1012+
1013+ free_irq(dev->irq, dev);
1014+
1015+ nb8800_dma_free(dev);
1016+
1017+ return 0;
1018+}
1019+
1020+static int nb8800_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1021+{
1022+ struct nb8800_priv *priv = netdev_priv(dev);
1023+
1024+ return phy_mii_ioctl(priv->phydev, rq, cmd);
1025+}
1026+
1027+static const struct net_device_ops nb8800_netdev_ops = {
1028+ .ndo_open = nb8800_open,
1029+ .ndo_stop = nb8800_stop,
1030+ .ndo_start_xmit = nb8800_xmit,
1031+ .ndo_set_mac_address = nb8800_set_mac_address,
1032+ .ndo_set_rx_mode = nb8800_set_rx_mode,
1033+ .ndo_do_ioctl = nb8800_ioctl,
1034+ .ndo_change_mtu = eth_change_mtu,
1035+ .ndo_validate_addr = eth_validate_addr,
1036+};
1037+
1038+static int nb8800_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1039+{
1040+ struct nb8800_priv *priv = netdev_priv(dev);
1041+
1042+ if (!priv->phydev)
1043+ return -ENODEV;
1044+
1045+ return phy_ethtool_gset(priv->phydev, cmd);
1046+}
1047+
1048+static int nb8800_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1049+{
1050+ struct nb8800_priv *priv = netdev_priv(dev);
1051+
1052+ if (!priv->phydev)
1053+ return -ENODEV;
1054+
1055+ return phy_ethtool_sset(priv->phydev, cmd);
1056+}
1057+
1058+static int nb8800_nway_reset(struct net_device *dev)
1059+{
1060+ struct nb8800_priv *priv = netdev_priv(dev);
1061+
1062+ if (!priv->phydev)
1063+ return -ENODEV;
1064+
1065+ return genphy_restart_aneg(priv->phydev);
1066+}
1067+
1068+static void nb8800_get_pauseparam(struct net_device *dev,
1069+ struct ethtool_pauseparam *pp)
1070+{
1071+ struct nb8800_priv *priv = netdev_priv(dev);
1072+
1073+ pp->autoneg = priv->pause_aneg;
1074+ pp->rx_pause = priv->pause_rx;
1075+ pp->tx_pause = priv->pause_tx;
1076+}
1077+
1078+static int nb8800_set_pauseparam(struct net_device *dev,
1079+ struct ethtool_pauseparam *pp)
1080+{
1081+ struct nb8800_priv *priv = netdev_priv(dev);
1082+
1083+ priv->pause_aneg = pp->autoneg;
1084+ priv->pause_rx = pp->rx_pause;
1085+ priv->pause_tx = pp->tx_pause;
1086+
1087+ nb8800_pause_adv(dev);
1088+
1089+ if (!priv->pause_aneg)
1090+ nb8800_pause_config(dev);
1091+ else if (priv->phydev)
1092+ phy_start_aneg(priv->phydev);
1093+
1094+ return 0;
1095+}
1096+
1097+static const char nb8800_stats_names[][ETH_GSTRING_LEN] = {
1098+ "rx_bytes_ok",
1099+ "rx_frames_ok",
1100+ "rx_undersize_frames",
1101+ "rx_fragment_frames",
1102+ "rx_64_byte_frames",
1103+ "rx_127_byte_frames",
1104+ "rx_255_byte_frames",
1105+ "rx_511_byte_frames",
1106+ "rx_1023_byte_frames",
1107+ "rx_max_size_frames",
1108+ "rx_oversize_frames",
1109+ "rx_bad_fcs_frames",
1110+ "rx_broadcast_frames",
1111+ "rx_multicast_frames",
1112+ "rx_control_frames",
1113+ "rx_pause_frames",
1114+ "rx_unsup_control_frames",
1115+ "rx_align_error_frames",
1116+ "rx_overrun_frames",
1117+ "rx_jabber_frames",
1118+ "rx_bytes",
1119+ "rx_frames",
1120+
1121+ "tx_bytes_ok",
1122+ "tx_frames_ok",
1123+ "tx_64_byte_frames",
1124+ "tx_127_byte_frames",
1125+ "tx_255_byte_frames",
1126+ "tx_511_byte_frames",
1127+ "tx_1023_byte_frames",
1128+ "tx_max_size_frames",
1129+ "tx_oversize_frames",
1130+ "tx_broadcast_frames",
1131+ "tx_multicast_frames",
1132+ "tx_control_frames",
1133+ "tx_pause_frames",
1134+ "tx_underrun_frames",
1135+ "tx_single_collision_frames",
1136+ "tx_multi_collision_frames",
1137+ "tx_deferred_collision_frames",
1138+ "tx_late_collision_frames",
1139+ "tx_excessive_collision_frames",
1140+ "tx_bytes",
1141+ "tx_frames",
1142+ "tx_collisions",
1143+};
1144+
1145+#define NB8800_NUM_STATS ARRAY_SIZE(nb8800_stats_names)
1146+
1147+static int nb8800_get_sset_count(struct net_device *dev, int sset)
1148+{
1149+ if (sset == ETH_SS_STATS)
1150+ return NB8800_NUM_STATS;
1151+
1152+ return -EOPNOTSUPP;
1153+}
1154+
1155+static void nb8800_get_strings(struct net_device *dev, u32 sset, u8 *buf)
1156+{
1157+ if (sset == ETH_SS_STATS)
1158+ memcpy(buf, &nb8800_stats_names, sizeof(nb8800_stats_names));
1159+}
1160+
1161+static u32 nb8800_read_stat(struct net_device *dev, int index)
1162+{
1163+ struct nb8800_priv *priv = netdev_priv(dev);
1164+
1165+ nb8800_writeb(priv, NB8800_STAT_INDEX, index);
1166+
1167+ return nb8800_readl(priv, NB8800_STAT_DATA);
1168+}
1169+
1170+static void nb8800_get_ethtool_stats(struct net_device *dev,
1171+ struct ethtool_stats *estats, u64 *st)
1172+{
1173+ unsigned int i;
1174+ u32 rx, tx;
1175+
1176+ for (i = 0; i < NB8800_NUM_STATS / 2; i++) {
1177+ rx = nb8800_read_stat(dev, i);
1178+ tx = nb8800_read_stat(dev, i | 0x80);
1179+ st[i] = rx;
1180+ st[i + NB8800_NUM_STATS / 2] = tx;
1181+ }
1182+}
1183+
1184+static const struct ethtool_ops nb8800_ethtool_ops = {
1185+ .get_settings = nb8800_get_settings,
1186+ .set_settings = nb8800_set_settings,
1187+ .nway_reset = nb8800_nway_reset,
1188+ .get_link = ethtool_op_get_link,
1189+ .get_pauseparam = nb8800_get_pauseparam,
1190+ .set_pauseparam = nb8800_set_pauseparam,
1191+ .get_sset_count = nb8800_get_sset_count,
1192+ .get_strings = nb8800_get_strings,
1193+ .get_ethtool_stats = nb8800_get_ethtool_stats,
1194+};
1195+
1196+static int nb8800_hw_init(struct net_device *dev)
1197+{
1198+ struct nb8800_priv *priv = netdev_priv(dev);
1199+ u32 val;
1200+
1201+ val = TX_RETRY_EN | TX_PAD_EN | TX_APPEND_FCS;
1202+ nb8800_writeb(priv, NB8800_TX_CTL1, val);
1203+
1204+ /* Collision retry count */
1205+ nb8800_writeb(priv, NB8800_TX_CTL2, 5);
1206+
1207+ val = RX_PAD_STRIP | RX_AF_EN;
1208+ nb8800_writeb(priv, NB8800_RX_CTL, val);
1209+
1210+ /* Chosen by fair dice roll */
1211+ nb8800_writeb(priv, NB8800_RANDOM_SEED, 4);
1212+
1213+ /* TX cycles per deferral period */
1214+ nb8800_writeb(priv, NB8800_TX_SDP, 12);
1215+
1216+ /* The following three threshold values have been
1217+ * experimentally determined for good results.
1218+ */
1219+
1220+ /* RX/TX FIFO threshold for partial empty (64-bit entries) */
1221+ nb8800_writeb(priv, NB8800_PE_THRESHOLD, 0);
1222+
1223+ /* RX/TX FIFO threshold for partial full (64-bit entries) */
1224+ nb8800_writeb(priv, NB8800_PF_THRESHOLD, 255);
1225+
1226+ /* Buffer size for transmit (64-bit entries) */
1227+ nb8800_writeb(priv, NB8800_TX_BUFSIZE, 64);
1228+
1229+ /* Configure tx DMA */
1230+
1231+ val = nb8800_readl(priv, NB8800_TXC_CR);
1232+ val &= TCR_LE; /* keep endian setting */
1233+ val |= TCR_DM; /* DMA descriptor mode */
1234+ val |= TCR_RS; /* automatically store tx status */
1235+ val |= TCR_DIE; /* interrupt on DMA chain completion */
1236+ val |= TCR_TFI(7); /* interrupt after 7 frames transmitted */
1237+ val |= TCR_BTS(2); /* 32-byte bus transaction size */
1238+ nb8800_writel(priv, NB8800_TXC_CR, val);
1239+
1240+ /* TX complete interrupt after 10 ms or 7 frames (see above) */
1241+ val = clk_get_rate(priv->clk) / 100;
1242+ nb8800_writel(priv, NB8800_TX_ITR, val);
1243+
1244+ /* Configure rx DMA */
1245+
1246+ val = nb8800_readl(priv, NB8800_RXC_CR);
1247+ val &= RCR_LE; /* keep endian setting */
1248+ val |= RCR_DM; /* DMA descriptor mode */
1249+ val |= RCR_RS; /* automatically store rx status */
1250+ val |= RCR_DIE; /* interrupt at end of DMA chain */
1251+ val |= RCR_RFI(7); /* interrupt after 7 frames received */
1252+ val |= RCR_BTS(2); /* 32-byte bus transaction size */
1253+ nb8800_writel(priv, NB8800_RXC_CR, val);
1254+
1255+ /* The rx interrupt can fire before the DMA has completed
1256+ * unless a small delay is added. 50 us is hopefully enough.
1257+ */
1258+ priv->rx_itr_irq = clk_get_rate(priv->clk) / 20000;
1259+
1260+ /* In NAPI poll mode we want to disable interrupts, but the
1261+ * hardware does not permit this. Delay 10 ms instead.
1262+ */
1263+ priv->rx_itr_poll = clk_get_rate(priv->clk) / 100;
1264+
1265+ nb8800_writel(priv, NB8800_RX_ITR, priv->rx_itr_irq);
1266+
1267+ priv->rx_dma_config = RX_BUF_SIZE | DESC_BTS(2) | DESC_DS | DESC_EOF;
1268+
1269+ /* Flow control settings */
1270+
1271+ /* Pause time of 0.1 ms */
1272+ val = 100000 / 512;
1273+ nb8800_writeb(priv, NB8800_PQ1, val >> 8);
1274+ nb8800_writeb(priv, NB8800_PQ2, val & 0xff);
1275+
1276+ /* Auto-negotiate by default */
1277+ priv->pause_aneg = true;
1278+ priv->pause_rx = true;
1279+ priv->pause_tx = true;
1280+
1281+ nb8800_mc_init(dev, 0);
1282+
1283+ return 0;
1284+}
1285+
1286+static int nb8800_tangox_init(struct net_device *dev)
1287+{
1288+ struct nb8800_priv *priv = netdev_priv(dev);
1289+ u32 pad_mode = PAD_MODE_MII;
1290+
1291+ switch (priv->phy_mode) {
1292+ case PHY_INTERFACE_MODE_MII:
1293+ case PHY_INTERFACE_MODE_GMII:
1294+ pad_mode = PAD_MODE_MII;
1295+ break;
1296+
1297+ case PHY_INTERFACE_MODE_RGMII:
1298+ pad_mode = PAD_MODE_RGMII;
1299+ break;
1300+
1301+ case PHY_INTERFACE_MODE_RGMII_TXID:
1302+ pad_mode = PAD_MODE_RGMII | PAD_MODE_GTX_CLK_DELAY;
1303+ break;
1304+
1305+ default:
1306+ dev_err(dev->dev.parent, "unsupported phy mode %s\n",
1307+ phy_modes(priv->phy_mode));
1308+ return -EINVAL;
1309+ }
1310+
1311+ nb8800_writeb(priv, NB8800_TANGOX_PAD_MODE, pad_mode);
1312+
1313+ return 0;
1314+}
1315+
1316+static int nb8800_tangox_reset(struct net_device *dev)
1317+{
1318+ struct nb8800_priv *priv = netdev_priv(dev);
1319+ int clk_div;
1320+
1321+ nb8800_writeb(priv, NB8800_TANGOX_RESET, 0);
1322+ usleep_range(1000, 10000);
1323+ nb8800_writeb(priv, NB8800_TANGOX_RESET, 1);
1324+
1325+ wmb(); /* ensure reset is cleared before proceeding */
1326+
1327+ clk_div = DIV_ROUND_UP(clk_get_rate(priv->clk), 2 * MAX_MDC_CLOCK);
1328+ nb8800_writew(priv, NB8800_TANGOX_MDIO_CLKDIV, clk_div);
1329+
1330+ return 0;
1331+}
1332+
1333+static const struct nb8800_ops nb8800_tangox_ops = {
1334+ .init = nb8800_tangox_init,
1335+ .reset = nb8800_tangox_reset,
1336+};
1337+
1338+static int nb8800_tango4_init(struct net_device *dev)
1339+{
1340+ struct nb8800_priv *priv = netdev_priv(dev);
1341+ int err;
1342+
1343+ err = nb8800_tangox_init(dev);
1344+ if (err)
1345+ return err;
1346+
1347+ /* On tango4 interrupt on DMA completion per frame works and gives
1348+ * better performance despite generating more rx interrupts.
1349+ */
1350+
1351+ /* Disable unnecessary interrupt on rx completion */
1352+ nb8800_clearl(priv, NB8800_RXC_CR, RCR_RFI(7));
1353+
1354+ /* Request interrupt on descriptor DMA completion */
1355+ priv->rx_dma_config |= DESC_ID;
1356+
1357+ return 0;
1358+}
1359+
1360+static const struct nb8800_ops nb8800_tango4_ops = {
1361+ .init = nb8800_tango4_init,
1362+ .reset = nb8800_tangox_reset,
1363+};
1364+
1365+static const struct of_device_id nb8800_dt_ids[] = {
1366+ {
1367+ .compatible = "aurora,nb8800",
1368+ },
1369+ {
1370+ .compatible = "sigma,smp8642-ethernet",
1371+ .data = &nb8800_tangox_ops,
1372+ },
1373+ {
1374+ .compatible = "sigma,smp8734-ethernet",
1375+ .data = &nb8800_tango4_ops,
1376+ },
1377+ { }
1378+};
1379+
1380+static int nb8800_probe(struct platform_device *pdev)
1381+{
1382+ const struct of_device_id *match;
1383+ const struct nb8800_ops *ops = NULL;
1384+ struct nb8800_priv *priv;
1385+ struct resource *res;
1386+ struct net_device *dev;
1387+ struct mii_bus *bus;
1388+ const unsigned char *mac;
1389+ void __iomem *base;
1390+ int irq;
1391+ int ret;
1392+
1393+ match = of_match_device(nb8800_dt_ids, &pdev->dev);
1394+ if (match)
1395+ ops = match->data;
1396+
1397+ irq = platform_get_irq(pdev, 0);
1398+ if (irq <= 0) {
1399+ dev_err(&pdev->dev, "No IRQ\n");
1400+ return -EINVAL;
1401+ }
1402+
1403+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1404+ base = devm_ioremap_resource(&pdev->dev, res);
1405+ if (IS_ERR(base))
1406+ return PTR_ERR(base);
1407+
1408+ dev_dbg(&pdev->dev, "AU-NB8800 Ethernet at %pa\n", &res->start);
1409+
1410+ dev = alloc_etherdev(sizeof(*priv));
1411+ if (!dev)
1412+ return -ENOMEM;
1413+
1414+ platform_set_drvdata(pdev, dev);
1415+ SET_NETDEV_DEV(dev, &pdev->dev);
1416+
1417+ priv = netdev_priv(dev);
1418+ priv->base = base;
1419+
1420+ priv->phy_mode = of_get_phy_mode(pdev->dev.of_node);
1421+ if (priv->phy_mode < 0)
1422+ priv->phy_mode = PHY_INTERFACE_MODE_RGMII;
1423+
1424+ priv->clk = devm_clk_get(&pdev->dev, NULL);
1425+ if (IS_ERR(priv->clk)) {
1426+ dev_err(&pdev->dev, "failed to get clock\n");
1427+ ret = PTR_ERR(priv->clk);
1428+ goto err_free_dev;
1429+ }
1430+
1431+ ret = clk_prepare_enable(priv->clk);
1432+ if (ret)
1433+ goto err_free_dev;
1434+
1435+ spin_lock_init(&priv->tx_lock);
1436+
1437+ if (ops && ops->reset) {
1438+ ret = ops->reset(dev);
1439+ if (ret)
1440+ goto err_free_dev;
1441+ }
1442+
1443+ bus = devm_mdiobus_alloc(&pdev->dev);
1444+ if (!bus) {
1445+ ret = -ENOMEM;
1446+ goto err_disable_clk;
1447+ }
1448+
1449+ bus->name = "nb8800-mii";
1450+ bus->read = nb8800_mdio_read;
1451+ bus->write = nb8800_mdio_write;
1452+ bus->parent = &pdev->dev;
1453+ snprintf(bus->id, MII_BUS_ID_SIZE, "%lx.nb8800-mii",
1454+ (unsigned long)res->start);
1455+ bus->priv = priv;
1456+
1457+ ret = of_mdiobus_register(bus, pdev->dev.of_node);
1458+ if (ret) {
1459+ dev_err(&pdev->dev, "failed to register MII bus\n");
1460+ goto err_disable_clk;
1461+ }
1462+
1463+ priv->phy_node = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
1464+ if (!priv->phy_node) {
1465+ dev_err(&pdev->dev, "no PHY specified\n");
1466+ ret = -ENODEV;
1467+ goto err_free_bus;
1468+ }
1469+
1470+ priv->mii_bus = bus;
1471+
1472+ ret = nb8800_hw_init(dev);
1473+ if (ret)
1474+ goto err_free_bus;
1475+
1476+ if (ops && ops->init) {
1477+ ret = ops->init(dev);
1478+ if (ret)
1479+ goto err_free_bus;
1480+ }
1481+
1482+ dev->netdev_ops = &nb8800_netdev_ops;
1483+ dev->ethtool_ops = &nb8800_ethtool_ops;
1484+ dev->flags |= IFF_MULTICAST;
1485+ dev->irq = irq;
1486+
1487+ mac = of_get_mac_address(pdev->dev.of_node);
1488+ if (mac)
1489+ ether_addr_copy(dev->dev_addr, mac);
1490+
1491+ if (!is_valid_ether_addr(dev->dev_addr))
1492+ eth_hw_addr_random(dev);
1493+
1494+ nb8800_update_mac_addr(dev);
1495+
1496+ netif_carrier_off(dev);
1497+
1498+ ret = register_netdev(dev);
1499+ if (ret) {
1500+ netdev_err(dev, "failed to register netdev\n");
1501+ goto err_free_dma;
1502+ }
1503+
1504+ netif_napi_add(dev, &priv->napi, nb8800_poll, NAPI_POLL_WEIGHT);
1505+
1506+ netdev_info(dev, "MAC address %pM\n", dev->dev_addr);
1507+
1508+ return 0;
1509+
1510+err_free_dma:
1511+ nb8800_dma_free(dev);
1512+err_free_bus:
1513+ mdiobus_unregister(bus);
1514+err_disable_clk:
1515+ clk_disable_unprepare(priv->clk);
1516+err_free_dev:
1517+ free_netdev(dev);
1518+
1519+ return ret;
1520+}
1521+
1522+static int nb8800_remove(struct platform_device *pdev)
1523+{
1524+ struct net_device *ndev = platform_get_drvdata(pdev);
1525+ struct nb8800_priv *priv = netdev_priv(ndev);
1526+
1527+ unregister_netdev(ndev);
1528+
1529+ mdiobus_unregister(priv->mii_bus);
1530+
1531+ clk_disable_unprepare(priv->clk);
1532+
1533+ nb8800_dma_free(ndev);
1534+ free_netdev(ndev);
1535+
1536+ return 0;
1537+}
1538+
1539+static struct platform_driver nb8800_driver = {
1540+ .driver = {
1541+ .name = "nb8800",
1542+ .of_match_table = nb8800_dt_ids,
1543+ },
1544+ .probe = nb8800_probe,
1545+ .remove = nb8800_remove,
1546+};
1547+
1548+module_platform_driver(nb8800_driver);
1549+
1550+MODULE_DESCRIPTION("Aurora AU-NB8800 Ethernet driver");
1551+MODULE_AUTHOR("Mans Rullgard <mans@mansr.com>");
1552+MODULE_LICENSE("GPL");
drivers/net/ethernet/aurora/nb8800.h+316−0
@@ -0,0 +1,316 @@
1+#ifndef _NB8800_H_
2+#define _NB8800_H_
3+
4+#include <linux/types.h>
5+#include <linux/skbuff.h>
6+#include <linux/phy.h>
7+#include <linux/clk.h>
8+#include <linux/bitops.h>
9+
10+#define RX_DESC_COUNT 256
11+#define TX_DESC_COUNT 256
12+
13+#define NB8800_DESC_LOW 4
14+
15+#define RX_BUF_SIZE 1552
16+
17+#define RX_COPYBREAK 256
18+#define RX_COPYHDR 128
19+
20+#define MAX_MDC_CLOCK 2500000
21+
22+/* Stargate Solutions SSN8800 core registers */
23+#define NB8800_TX_CTL1 0x000
24+#define TX_TPD BIT(5)
25+#define TX_APPEND_FCS BIT(4)
26+#define TX_PAD_EN BIT(3)
27+#define TX_RETRY_EN BIT(2)
28+#define TX_EN BIT(0)
29+
30+#define NB8800_TX_CTL2 0x001
31+
32+#define NB8800_RX_CTL 0x004
33+#define RX_BC_DISABLE BIT(7)
34+#define RX_RUNT BIT(6)
35+#define RX_AF_EN BIT(5)
36+#define RX_PAUSE_EN BIT(3)
37+#define RX_SEND_CRC BIT(2)
38+#define RX_PAD_STRIP BIT(1)
39+#define RX_EN BIT(0)
40+
41+#define NB8800_RANDOM_SEED 0x008
42+#define NB8800_TX_SDP 0x14
43+#define NB8800_TX_TPDP1 0x18
44+#define NB8800_TX_TPDP2 0x19
45+#define NB8800_SLOT_TIME 0x1c
46+
47+#define NB8800_MDIO_CMD 0x020
48+#define MDIO_CMD_GO BIT(31)
49+#define MDIO_CMD_WR BIT(26)
50+#define MDIO_CMD_ADDR(x) ((x) << 21)
51+#define MDIO_CMD_REG(x) ((x) << 16)
52+#define MDIO_CMD_DATA(x) ((x) << 0)
53+
54+#define NB8800_MDIO_STS 0x024
55+#define MDIO_STS_ERR BIT(31)
56+
57+#define NB8800_MC_ADDR(i) (0x028 + (i))
58+#define NB8800_MC_INIT 0x02e
59+#define NB8800_UC_ADDR(i) (0x03c + (i))
60+
61+#define NB8800_MAC_MODE 0x044
62+#define RGMII_MODE BIT(7)
63+#define HALF_DUPLEX BIT(4)
64+#define BURST_EN BIT(3)
65+#define LOOPBACK_EN BIT(2)
66+#define GMAC_MODE BIT(0)
67+
68+#define NB8800_IC_THRESHOLD 0x050
69+#define NB8800_PE_THRESHOLD 0x051
70+#define NB8800_PF_THRESHOLD 0x052
71+#define NB8800_TX_BUFSIZE 0x054
72+#define NB8800_FIFO_CTL 0x056
73+#define NB8800_PQ1 0x060
74+#define NB8800_PQ2 0x061
75+#define NB8800_SRC_ADDR(i) (0x06a + (i))
76+#define NB8800_STAT_DATA 0x078
77+#define NB8800_STAT_INDEX 0x07c
78+#define NB8800_STAT_CLEAR 0x07d
79+
80+#define NB8800_SLEEP_MODE 0x07e
81+#define SLEEP_MODE BIT(0)
82+
83+#define NB8800_WAKEUP 0x07f
84+#define WAKEUP BIT(0)
85+
86+/* Aurora NB8800 host interface registers */
87+#define NB8800_TXC_CR 0x100
88+#define TCR_LK BIT(12)
89+#define TCR_DS BIT(11)
90+#define TCR_BTS(x) (((x) & 0x7) << 8)
91+#define TCR_DIE BIT(7)
92+#define TCR_TFI(x) (((x) & 0x7) << 4)
93+#define TCR_LE BIT(3)
94+#define TCR_RS BIT(2)
95+#define TCR_DM BIT(1)
96+#define TCR_EN BIT(0)
97+
98+#define NB8800_TXC_SR 0x104
99+#define TSR_DE BIT(3)
100+#define TSR_DI BIT(2)
101+#define TSR_TO BIT(1)
102+#define TSR_TI BIT(0)
103+
104+#define NB8800_TX_SAR 0x108
105+#define NB8800_TX_DESC_ADDR 0x10c
106+
107+#define NB8800_TX_REPORT_ADDR 0x110
108+#define TX_BYTES_TRANSFERRED(x) (((x) >> 16) & 0xffff)
109+#define TX_FIRST_DEFERRAL BIT(7)
110+#define TX_EARLY_COLLISIONS(x) (((x) >> 3) & 0xf)
111+#define TX_LATE_COLLISION BIT(2)
112+#define TX_PACKET_DROPPED BIT(1)
113+#define TX_FIFO_UNDERRUN BIT(0)
114+#define IS_TX_ERROR(r) ((r) & 0x07)
115+
116+#define NB8800_TX_FIFO_SR 0x114
117+#define NB8800_TX_ITR 0x118
118+
119+#define NB8800_RXC_CR 0x200
120+#define RCR_FL BIT(13)
121+#define RCR_LK BIT(12)
122+#define RCR_DS BIT(11)
123+#define RCR_BTS(x) (((x) & 7) << 8)
124+#define RCR_DIE BIT(7)
125+#define RCR_RFI(x) (((x) & 7) << 4)
126+#define RCR_LE BIT(3)
127+#define RCR_RS BIT(2)
128+#define RCR_DM BIT(1)
129+#define RCR_EN BIT(0)
130+
131+#define NB8800_RXC_SR 0x204
132+#define RSR_DE BIT(3)
133+#define RSR_DI BIT(2)
134+#define RSR_RO BIT(1)
135+#define RSR_RI BIT(0)
136+
137+#define NB8800_RX_SAR 0x208
138+#define NB8800_RX_DESC_ADDR 0x20c
139+
140+#define NB8800_RX_REPORT_ADDR 0x210
141+#define RX_BYTES_TRANSFERRED(x) (((x) >> 16) & 0xFFFF)
142+#define RX_MULTICAST_PKT BIT(9)
143+#define RX_BROADCAST_PKT BIT(8)
144+#define RX_LENGTH_ERR BIT(7)
145+#define RX_FCS_ERR BIT(6)
146+#define RX_RUNT_PKT BIT(5)
147+#define RX_FIFO_OVERRUN BIT(4)
148+#define RX_LATE_COLLISION BIT(3)
149+#define RX_ALIGNMENT_ERROR BIT(2)
150+#define RX_ERROR_MASK 0xfc
151+#define IS_RX_ERROR(r) ((r) & RX_ERROR_MASK)
152+
153+#define NB8800_RX_FIFO_SR 0x214
154+#define NB8800_RX_ITR 0x218
155+
156+/* Sigma Designs SMP86xx additional registers */
157+#define NB8800_TANGOX_PAD_MODE 0x400
158+#define PAD_MODE_MASK 0x7
159+#define PAD_MODE_MII 0x0
160+#define PAD_MODE_RGMII 0x1
161+#define PAD_MODE_GTX_CLK_INV BIT(3)
162+#define PAD_MODE_GTX_CLK_DELAY BIT(4)
163+
164+#define NB8800_TANGOX_MDIO_CLKDIV 0x420
165+#define NB8800_TANGOX_RESET 0x424
166+
167+/* Hardware DMA descriptor */
168+struct nb8800_dma_desc {
169+ u32 s_addr; /* start address */
170+ u32 n_addr; /* next descriptor address */
171+ u32 r_addr; /* report address */
172+ u32 config;
173+} __aligned(8);
174+
175+#define DESC_ID BIT(23)
176+#define DESC_EOC BIT(22)
177+#define DESC_EOF BIT(21)
178+#define DESC_LK BIT(20)
179+#define DESC_DS BIT(19)
180+#define DESC_BTS(x) (((x) & 0x7) << 16)
181+
182+/* DMA descriptor and associated data for rx.
183+ * Allocated from coherent memory.
184+ */
185+struct nb8800_rx_desc {
186+ /* DMA descriptor */
187+ struct nb8800_dma_desc desc;
188+
189+ /* Status report filled in by hardware */
190+ u32 report;
191+};
192+
193+/* Address of buffer on rx ring */
194+struct nb8800_rx_buf {
195+ struct page *page;
196+ unsigned long offset;
197+};
198+
199+/* DMA descriptors and associated data for tx.
200+ * Allocated from coherent memory.
201+ */
202+struct nb8800_tx_desc {
203+ /* DMA descriptor. The second descriptor is used if packet
204+ * data is unaligned.
205+ */
206+ struct nb8800_dma_desc desc[2];
207+
208+ /* Status report filled in by hardware */
209+ u32 report;
210+
211+ /* Bounce buffer for initial unaligned part of packet */
212+ u8 buf[8] __aligned(8);
213+};
214+
215+/* Packet in tx queue */
216+struct nb8800_tx_buf {
217+ /* Currently queued skb */
218+ struct sk_buff *skb;
219+
220+ /* DMA address of the first descriptor */
221+ dma_addr_t dma_desc;
222+
223+ /* DMA address of packet data */
224+ dma_addr_t dma_addr;
225+
226+ /* Length of DMA mapping, less than skb->len if alignment
227+ * buffer is used.
228+ */
229+ unsigned int dma_len;
230+
231+ /* Number of packets in chain starting here */
232+ unsigned int chain_len;
233+
234+ /* Packet chain ready to be submitted to hardware */
235+ bool ready;
236+};
237+
238+struct nb8800_priv {
239+ struct napi_struct napi;
240+
241+ void __iomem *base;
242+
243+ /* RX DMA descriptors */
244+ struct nb8800_rx_desc *rx_descs;
245+
246+ /* RX buffers referenced by DMA descriptors */
247+ struct nb8800_rx_buf *rx_bufs;
248+
249+ /* Current end of chain */
250+ u32 rx_eoc;
251+
252+ /* Value for rx interrupt time register in NAPI interrupt mode */
253+ u32 rx_itr_irq;
254+
255+ /* Value for rx interrupt time register in NAPI poll mode */
256+ u32 rx_itr_poll;
257+
258+ /* Value for config field of rx DMA descriptors */
259+ u32 rx_dma_config;
260+
261+ /* TX DMA descriptors */
262+ struct nb8800_tx_desc *tx_descs;
263+
264+ /* TX packet queue */
265+ struct nb8800_tx_buf *tx_bufs;
266+
267+ /* Number of free tx queue entries */
268+ atomic_t tx_free;
269+
270+ /* First free tx queue entry */
271+ u32 tx_next;
272+
273+ /* Next buffer to transmit */
274+ u32 tx_queue;
275+
276+ /* Start of current packet chain */
277+ struct nb8800_tx_buf *tx_chain;
278+
279+ /* Next buffer to reclaim */
280+ u32 tx_done;
281+
282+ /* Lock for DMA activation */
283+ spinlock_t tx_lock;
284+
285+ struct mii_bus *mii_bus;
286+ struct device_node *phy_node;
287+ struct phy_device *phydev;
288+
289+ /* PHY connection type from DT */
290+ int phy_mode;
291+
292+ /* Current link status */
293+ int speed;
294+ int duplex;
295+ int link;
296+
297+ /* Pause settings */
298+ bool pause_aneg;
299+ bool pause_rx;
300+ bool pause_tx;
301+
302+ /* DMA base address of rx descriptors, see rx_descs above */
303+ dma_addr_t rx_desc_dma;
304+
305+ /* DMA base address of tx descriptors, see tx_descs above */
306+ dma_addr_t tx_desc_dma;
307+
308+ struct clk *clk;
309+};
310+
311+struct nb8800_ops {
312+ int (*init)(struct net_device *dev);
313+ int (*reset)(struct net_device *dev);
314+};
315+
316+#endif /* _NB8800_H_ */
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c+2−2
@@ -10139,8 +10139,8 @@ static void __bnx2x_del_vxlan_port(struct bnx2x *bp, u16 port) · 10138 unmodified lines
1013910139 DP(BNX2X_MSG_SP, "Invalid vxlan port\n");
1014010140 return;
1014110141 }
10142− bp->vxlan_dst_port--;
10143− if (bp->vxlan_dst_port)
10142+ bp->vxlan_dst_port_count--;
10143+ if (bp->vxlan_dst_port_count)
1014410144 return;
1014510145
1014610146 if (netif_running(bp->dev)) {
drivers/net/ethernet/broadcom/bnxt/bnxt.c+31−13
@@ -3625,6 +3625,7 @@ static int bnxt_hwrm_func_qcaps(struct bnxt *bp) · 3624 unmodified lines
36253625 pf->fw_fid = le16_to_cpu(resp->fid);
36263626 pf->port_id = le16_to_cpu(resp->port_id);
36273627 memcpy(pf->mac_addr, resp->perm_mac_address, ETH_ALEN);
3628+ memcpy(bp->dev->dev_addr, pf->mac_addr, ETH_ALEN);
36283629 pf->max_rsscos_ctxs = le16_to_cpu(resp->max_rsscos_ctx);
36293630 pf->max_cp_rings = le16_to_cpu(resp->max_cmpl_rings);
36303631 pf->max_tx_rings = le16_to_cpu(resp->max_tx_rings);
@@ -3648,8 +3649,11 @@ static int bnxt_hwrm_func_qcaps(struct bnxt *bp) · 17 unmodified lines
36483649
36493650 vf->fw_fid = le16_to_cpu(resp->fid);
36503651 memcpy(vf->mac_addr, resp->perm_mac_address, ETH_ALEN);
3651− if (!is_valid_ether_addr(vf->mac_addr))
3652− random_ether_addr(vf->mac_addr);
3652+ if (is_valid_ether_addr(vf->mac_addr))
3653+ /* overwrite netdev dev_adr with admin VF MAC */
3654+ memcpy(bp->dev->dev_addr, vf->mac_addr, ETH_ALEN);
3655+ else
3656+ random_ether_addr(bp->dev->dev_addr);
36533657
36543658 vf->max_rsscos_ctxs = le16_to_cpu(resp->max_rsscos_ctx);
36553659 vf->max_cp_rings = le16_to_cpu(resp->max_cmpl_rings);
@@ -3880,6 +3884,8 @@ static int bnxt_alloc_rfs_vnics(struct bnxt *bp) · 224 unmodified lines
38803884 #endif
38813885 }
38823886
3887+static int bnxt_cfg_rx_mode(struct bnxt *);
3888+
38833889 static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init)
38843890 {
38853891 int rc = 0;
@@ -3946,11 +3952,9 @@ static int bnxt_init_chip(struct bnxt *bp, bool irq_re_init) · 60 unmodified lines
39463952 bp->vnic_info[0].rx_mask |=
39473953 CFA_L2_SET_RX_MASK_REQ_MASK_PROMISCUOUS;
39483954
3949− rc = bnxt_hwrm_cfa_l2_set_rx_mask(bp, 0);
3950− if (rc) {
3951− netdev_err(bp->dev, "HWRM cfa l2 rx mask failure rc: %x\n", rc);
3955+ rc = bnxt_cfg_rx_mode(bp);
3956+ if (rc)
39523957 goto err_out;
3953− }
39543958
39553959 rc = bnxt_hwrm_set_coal(bp);
39563960 if (rc)
@@ -4865,7 +4869,7 @@ static void bnxt_set_rx_mode(struct net_device *dev) · 908 unmodified lines
48654869 }
48664870 }
48674871
4868−static void bnxt_cfg_rx_mode(struct bnxt *bp)
4872+static int bnxt_cfg_rx_mode(struct bnxt *bp)
48694873 {
48704874 struct net_device *dev = bp->dev;
48714875 struct bnxt_vnic_info *vnic = &bp->vnic_info[0];
@@ -4914,6 +4918,7 @@ static void bnxt_cfg_rx_mode(struct bnxt *bp) · 42 unmodified lines
49144918 netdev_err(bp->dev, "HWRM vnic filter failure rc: %x\n",
49154919 rc);
49164920 vnic->uc_filter_count = i;
4921+ return rc;
49174922 }
49184923 }
49194924
@@ -4922,6 +4927,8 @@ skip_uc: · 2 unmodified lines
49224927 if (rc)
49234928 netdev_err(bp->dev, "HWRM cfa l2 rx mask failure rc: %x\n",
49244929 rc);
4930+
4931+ return rc;
49254932 }
49264933
49274934 static netdev_features_t bnxt_fix_features(struct net_device *dev,
@@ -5212,13 +5219,27 @@ init_err: · 284 unmodified lines
52125219 static int bnxt_change_mac_addr(struct net_device *dev, void *p)
52135220 {
52145221 struct sockaddr *addr = p;
5222+ struct bnxt *bp = netdev_priv(dev);
5223+ int rc = 0;
52155224
52165225 if (!is_valid_ether_addr(addr->sa_data))
52175226 return -EADDRNOTAVAIL;
52185227
5228+#ifdef CONFIG_BNXT_SRIOV
5229+ if (BNXT_VF(bp) && is_valid_ether_addr(bp->vf.mac_addr))
5230+ return -EADDRNOTAVAIL;
5231+#endif
5232+
5233+ if (ether_addr_equal(addr->sa_data, dev->dev_addr))
5234+ return 0;
5235+
52195236 memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
5237+ if (netif_running(dev)) {
5238+ bnxt_close_nic(bp, false, false);
5239+ rc = bnxt_open_nic(bp, false, false);
5240+ }
52205241
5221− return 0;
5242+ return rc;
52225243 }
52235244
52245245 /* rtnl_lock held */
@@ -5686,15 +5707,12 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · 461 unmodified lines
56865707 bnxt_set_tpa_flags(bp);
56875708 bnxt_set_ring_params(bp);
56885709 dflt_rings = netif_get_num_default_rss_queues();
5689− if (BNXT_PF(bp)) {
5690− memcpy(dev->dev_addr, bp->pf.mac_addr, ETH_ALEN);
5710+ if (BNXT_PF(bp))
56915711 bp->pf.max_irqs = max_irqs;
5692− } else {
56935712 #if defined(CONFIG_BNXT_SRIOV)
5694− memcpy(dev->dev_addr, bp->vf.mac_addr, ETH_ALEN);
5713+ else
56955714 bp->vf.max_irqs = max_irqs;
56965715 #endif
5697− }
56985716 bnxt_get_max_rings(bp, &max_rx_rings, &max_tx_rings);
56995717 bp->rx_nr_rings = min_t(int, dflt_rings, max_rx_rings);
57005718 bp->tx_nr_rings_per_tc = min_t(int, dflt_rings, max_tx_rings);
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c+3−4
@@ -804,10 +804,9 @@ void bnxt_update_vf_mac(struct bnxt *bp) · 803 unmodified lines
804804 if (!is_valid_ether_addr(resp->perm_mac_address))
805805 goto update_vf_mac_exit;
806806
807− if (ether_addr_equal(resp->perm_mac_address, bp->vf.mac_addr))
808− goto update_vf_mac_exit;
809−
810− memcpy(bp->vf.mac_addr, resp->perm_mac_address, ETH_ALEN);
807+ if (!ether_addr_equal(resp->perm_mac_address, bp->vf.mac_addr))
808+ memcpy(bp->vf.mac_addr, resp->perm_mac_address, ETH_ALEN);
809+ /* overwrite netdev dev_adr with admin VF MAC */
811810 memcpy(bp->dev->dev_addr, bp->vf.mac_addr, ETH_ALEN);
812811 update_vf_mac_exit:
813812 mutex_unlock(&bp->hwrm_cmd_lock);
drivers/net/ethernet/cadence/macb.c+4−0
@@ -1682,6 +1682,8 @@ static void macb_init_hw(struct macb *bp) · 1681 unmodified lines
16821682 macb_set_hwaddr(bp);
16831683
16841684 config = macb_mdc_clk_div(bp);
1685+ if (bp->phy_interface == PHY_INTERFACE_MODE_SGMII)
1686+ config |= GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL);
16851687 config |= MACB_BF(RBOF, NET_IP_ALIGN); /* Make eth data aligned */
16861688 config |= MACB_BIT(PAE); /* PAuse Enable */
16871689 config |= MACB_BIT(DRFCS); /* Discard Rx FCS */
@@ -2416,6 +2418,8 @@ static int macb_init(struct platform_device *pdev) · 728 unmodified lines
24162418 /* Set MII management clock divider */
24172419 val = macb_mdc_clk_div(bp);
24182420 val |= macb_dbw(bp);
2421+ if (bp->phy_interface == PHY_INTERFACE_MODE_SGMII)
2422+ val |= GEM_BIT(SGMIIEN) | GEM_BIT(PCSSEL);
24192423 macb_writel(bp, NCFGR, val);
24202424
24212425 return 0;
drivers/net/ethernet/cadence/macb.h+5−0
@@ -215,12 +215,17 @@ · 214 unmodified lines
215215 /* GEM specific NCFGR bitfields. */
216216 #define GEM_GBE_OFFSET 10 /* Gigabit mode enable */
217217 #define GEM_GBE_SIZE 1
218+#define GEM_PCSSEL_OFFSET 11
219+#define GEM_PCSSEL_SIZE 1
218220 #define GEM_CLK_OFFSET 18 /* MDC clock division */
219221 #define GEM_CLK_SIZE 3
220222 #define GEM_DBW_OFFSET 21 /* Data bus width */
221223 #define GEM_DBW_SIZE 2
222224 #define GEM_RXCOEN_OFFSET 24
223225 #define GEM_RXCOEN_SIZE 1
226+#define GEM_SGMIIEN_OFFSET 27
227+#define GEM_SGMIIEN_SIZE 1
228+
224229
225230 /* Constants for data bus width. */
226231 #define GEM_DBW32 0 /* 32 bit AMBA AHB data bus width */
drivers/net/ethernet/cavium/thunder/nic.h+2−3
@@ -120,10 +120,9 @@ · 119 unmodified lines
120120 * Calculated for SCLK of 700Mhz
121121 * value written should be a 1/16th of what is expected
122122 *
123− * 1 tick per 0.05usec = value of 2.2
124− * This 10% would be covered in CQ timer thresh value
123+ * 1 tick per 0.025usec
125124 */
126−#define NICPF_CLK_PER_INT_TICK 2
125+#define NICPF_CLK_PER_INT_TICK 1
127126
128127 /* Time to wait before we decide that a SQ is stuck.
129128 *
drivers/net/ethernet/cavium/thunder/nic_main.c+20−3
@@ -37,6 +37,7 @@ struct nicpf { · 36 unmodified lines
3737 #define NIC_GET_BGX_FROM_VF_LMAC_MAP(map) ((map >> 4) & 0xF)
3838 #define NIC_GET_LMAC_FROM_VF_LMAC_MAP(map) (map & 0xF)
3939 u8 vf_lmac_map[MAX_LMAC];
40+ u8 lmac_cnt;
4041 struct delayed_work dwork;
4142 struct workqueue_struct *check_link;
4243 u8 link[MAX_LMAC];
@@ -279,6 +280,7 @@ static void nic_set_lmac_vf_mapping(struct nicpf *nic) · 236 unmodified lines
279280 u64 lmac_credit;
280281
281282 nic->num_vf_en = 0;
283+ nic->lmac_cnt = 0;
282284
283285 for (bgx = 0; bgx < NIC_MAX_BGX; bgx++) {
284286 if (!(bgx_map & (1 << bgx)))
@@ -288,6 +290,7 @@ static void nic_set_lmac_vf_mapping(struct nicpf *nic) · 3 unmodified lines
288290 nic->vf_lmac_map[next_bgx_lmac++] =
289291 NIC_SET_VF_LMAC_MAP(bgx, lmac);
290292 nic->num_vf_en += lmac_cnt;
293+ nic->lmac_cnt += lmac_cnt;
291294
292295 /* Program LMAC credits */
293296 lmac_credit = (1ull << 1); /* channel credit enable */
@@ -715,6 +718,13 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf) · 421 unmodified lines
715718 case NIC_MBOX_MSG_CFG_DONE:
716719 /* Last message of VF config msg sequence */
717720 nic->vf_enabled[vf] = true;
721+ if (vf >= nic->lmac_cnt)
722+ goto unlock;
723+
724+ bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
725+ lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
726+
727+ bgx_lmac_rx_tx_enable(nic->node, bgx, lmac, true);
718728 goto unlock;
719729 case NIC_MBOX_MSG_SHUTDOWN:
720730 /* First msg in VF teardown sequence */
@@ -722,6 +732,14 @@ static void nic_handle_mbx_intr(struct nicpf *nic, int vf) · 1 unmodified line
722732 if (vf >= nic->num_vf_en)
723733 nic->sqs_used[vf - nic->num_vf_en] = false;
724734 nic->pqs_vf[vf] = 0;
735+
736+ if (vf >= nic->lmac_cnt)
737+ break;
738+
739+ bgx = NIC_GET_BGX_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
740+ lmac = NIC_GET_LMAC_FROM_VF_LMAC_MAP(nic->vf_lmac_map[vf]);
741+
742+ bgx_lmac_rx_tx_enable(nic->node, bgx, lmac, false);
725743 break;
726744 case NIC_MBOX_MSG_ALLOC_SQS:
727745 nic_alloc_sqs(nic, &mbx.sqs_alloc);
@@ -940,7 +958,7 @@ static void nic_poll_for_link(struct work_struct *work) · 212 unmodified lines
940958
941959 mbx.link_status.msg = NIC_MBOX_MSG_BGX_LINK_CHANGE;
942960
943− for (vf = 0; vf < nic->num_vf_en; vf++) {
961+ for (vf = 0; vf < nic->lmac_cnt; vf++) {
944962 /* Poll only if VF is UP */
945963 if (!nic->vf_enabled[vf])

11 more lines aren’t shown here.

drivers/net/ethernet/cavium/thunder/nicvf_ethtool.c+15−1

This diff is large: its 37 lines aren’t shown here.

drivers/net/ethernet/cavium/thunder/nicvf_main.c+1−3

This diff is large: its 18 lines aren’t shown here.

drivers/net/ethernet/cavium/thunder/nicvf_queues.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/net/ethernet/cavium/thunder/nicvf_queues.h+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/net/ethernet/cavium/thunder/thunder_bgx.c+24−4

This diff is large: its 63 lines aren’t shown here.

drivers/net/ethernet/cavium/thunder/thunder_bgx.h+2−0

This diff is large: its 9 lines aren’t shown here.

drivers/net/ethernet/dec/tulip/tulip_core.c+7−2

This diff is large: its 23 lines aren’t shown here.

drivers/net/ethernet/dec/tulip/winbond-840.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/net/ethernet/freescale/Kconfig+2−1

This diff is large: its 10 lines aren’t shown here.

drivers/net/ethernet/freescale/gianfar.c+3−3

This diff is large: its 13 lines aren’t shown here.

drivers/net/ethernet/freescale/gianfar_ptp.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/net/ethernet/intel/fm10k/fm10k_netdev.c+3−1

This diff is large: its 12 lines aren’t shown here.

drivers/net/ethernet/marvell/mvneta.c+27−6

This diff is large: its 93 lines aren’t shown here.

drivers/net/ethernet/mellanox/mlx4/cmd.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/net/ethernet/nxp/lpc_eth.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/net/ethernet/renesas/ravb_main.c+4−2

This diff is large: its 22 lines aren’t shown here.

drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c+7−6

This diff is large: its 24 lines aren’t shown here.

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c+8−1

This diff is large: its 30 lines aren’t shown here.

drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c+13−15

This diff is large: its 46 lines aren’t shown here.

drivers/net/ethernet/ti/cpsw-common.c+3−0

This diff is large: its 10 lines aren’t shown here.

drivers/net/macvtap.c+2−2

This diff is large: its 18 lines aren’t shown here.

drivers/net/phy/broadcom.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/net/phy/phy.c+2−1

This diff is large: its 10 lines aren’t shown here.

drivers/net/tun.c+2−2

This diff is large: its 18 lines aren’t shown here.

drivers/net/usb/cdc_ncm.c+4−4

This diff is large: its 28 lines aren’t shown here.

drivers/net/usb/qmi_wwan.c+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/net/virtio_net.c+19−15

This diff is large: its 97 lines aren’t shown here.

drivers/net/vmxnet3/vmxnet3_drv.c+60−11

This diff is large: its 182 lines aren’t shown here.

drivers/net/vrf.c+1−10

This diff is large: its 25 lines aren’t shown here.

drivers/net/wan/hdlc_fr.c+5−5

This diff is large: its 27 lines aren’t shown here.

drivers/net/wan/x25_asy.c+1−5

This diff is large: its 18 lines aren’t shown here.

drivers/net/wireless/ath/ath10k/core.c+47−2

This diff is large: its 101 lines aren’t shown here.

drivers/net/wireless/ath/ath10k/core.h+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/net/wireless/ath/ath10k/hw.h+15−2

This diff is large: its 45 lines aren’t shown here.

drivers/net/wireless/ath/ath10k/mac.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/net/wireless/ath/ath10k/pci.c+43−10

This diff is large: its 118 lines aren’t shown here.

drivers/net/wireless/iwlwifi/iwl-7000.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/net/wireless/iwlwifi/iwl-8000.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/net/wireless/iwlwifi/mvm/d3.c+2−6

This diff is large: its 35 lines aren’t shown here.

drivers/net/wireless/iwlwifi/mvm/mac80211.c+8−3

This diff is large: its 26 lines aren’t shown here.

drivers/net/wireless/iwlwifi/mvm/sta.c+47−41

This diff is large: its 197 lines aren’t shown here.

drivers/net/wireless/iwlwifi/mvm/sta.h+2−2

This diff is large: its 11 lines aren’t shown here.

drivers/net/wireless/iwlwifi/pcie/drv.c+18−1

This diff is large: its 52 lines aren’t shown here.

drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/nvme/host/Makefile+2−1

This diff is large: its 7 lines aren’t shown here.

drivers/nvme/host/lightnvm.c+130−57

This diff is large: its 400 lines aren’t shown here.

drivers/nvme/host/nvme.h+14−0

This diff is large: its 23 lines aren’t shown here.

drivers/nvme/host/pci.c+37−14

This diff is large: its 111 lines aren’t shown here.

drivers/of/address.c+3−2

This diff is large: its 13 lines aren’t shown here.

drivers/of/fdt.c+6−1

This diff is large: its 36 lines aren’t shown here.

drivers/of/irq.c+2−1

This diff is large: its 17 lines aren’t shown here.

drivers/of/of_reserved_mem.c+7−1

This diff is large: its 15 lines aren’t shown here.

drivers/parisc/iommu-helpers.h+8−7

This diff is large: its 31 lines aren’t shown here.

drivers/pci/host/pcie-altera.c+16−7

This diff is large: its 84 lines aren’t shown here.

drivers/pci/host/pcie-designware.c+0−1

This diff is large: its 8 lines aren’t shown here.

drivers/pci/host/pcie-hisi.c+2−2

This diff is large: its 18 lines aren’t shown here.

drivers/pci/msi.c+2−2

This diff is large: its 18 lines aren’t shown here.

drivers/pci/pci-driver.c+14−2

This diff is large: its 24 lines aren’t shown here.

drivers/pci/pci-sysfs.c+4−1

This diff is large: its 12 lines aren’t shown here.

drivers/pci/pci.h+0−2

This diff is large: its 7 lines aren’t shown here.

drivers/pinctrl/Kconfig+0−4

This diff is large: its 15 lines aren’t shown here.

drivers/pinctrl/freescale/pinctrl-imx1-core.c+6−2

This diff is large: its 24 lines aren’t shown here.

drivers/pinctrl/mediatek/pinctrl-mtk-common.c+4−7

This diff is large: its 32 lines aren’t shown here.

drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/pinctrl/sh-pfc/pfc-sh7734.c+3−3

This diff is large: its 15 lines aren’t shown here.

drivers/remoteproc/remoteproc_core.c+2−0

This diff is large: its 9 lines aren’t shown here.

drivers/remoteproc/remoteproc_debugfs.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/rtc/rtc-ds1307.c+8−36

This diff is large: its 88 lines aren’t shown here.

drivers/scsi/Kconfig+2−0

This diff is large: its 16 lines aren’t shown here.

drivers/scsi/advansys.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/scsi/hosts.c+11−0

This diff is large: its 18 lines aren’t shown here.

drivers/scsi/hpsa.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/scsi/mpt3sas/Kconfig+9−0

This diff is large: its 13 lines aren’t shown here.

drivers/scsi/mpt3sas/mpt3sas_scsih.c+1−2

This diff is large: its 10 lines aren’t shown here.

drivers/scsi/mvsas/mv_init.c+2−2

This diff is large: its 18 lines aren’t shown here.

drivers/scsi/qla2xxx/qla_nx.c+2−1

This diff is large: its 17 lines aren’t shown here.

drivers/scsi/qla2xxx/tcm_qla2xxx.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/scsi/scsi_debug.c+5−4

This diff is large: its 23 lines aren’t shown here.

drivers/scsi/scsi_scan.c+6−3

This diff is large: its 16 lines aren’t shown here.

drivers/scsi/scsi_sysfs.c+11−11

This diff is large: its 43 lines aren’t shown here.

drivers/scsi/sd.c+48−21

This diff is large: its 123 lines aren’t shown here.

drivers/scsi/sd.h+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/scsi/st.c+3−2

This diff is large: its 27 lines aren’t shown here.

drivers/soc/mediatek/Kconfig+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/soc/ti/knav_qmss_queue.c+4−4

This diff is large: its 22 lines aren’t shown here.

drivers/spi/spi-bcm63xx.c+2−2

This diff is large: its 11 lines aren’t shown here.

drivers/spi/spi-mt65xx.c+18−8

This diff is large: its 40 lines aren’t shown here.

drivers/spi/spi-pl022.c+22−6

This diff is large: its 57 lines aren’t shown here.

drivers/spi/spi.c+2−0

This diff is large: its 16 lines aren’t shown here.

drivers/staging/iio/iio_simple_dummy_events.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h+0−1

This diff is large: its 8 lines aren’t shown here.

drivers/staging/lustre/lustre/libcfs/module.c+0−17

This diff is large: its 24 lines aren’t shown here.

drivers/staging/lustre/lustre/obdecho/echo_client.c+11−9

This diff is large: its 50 lines aren’t shown here.

drivers/target/iscsi/iscsi_target.c+12−1

This diff is large: its 27 lines aren’t shown here.

drivers/target/iscsi/iscsi_target_nego.c+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/target/iscsi/iscsi_target_parameters.c+5−5

This diff is large: its 45 lines aren’t shown here.

drivers/target/target_core_sbc.c+11−6

This diff is large: its 56 lines aren’t shown here.

drivers/target/target_core_stat.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/target/target_core_tmr.c+6−1

This diff is large: its 27 lines aren’t shown here.

drivers/target/target_core_transport.c+14−12

This diff is large: its 75 lines aren’t shown here.

drivers/target/target_core_user.c+1−3

This diff is large: its 18 lines aren’t shown here.

drivers/thermal/Kconfig+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/thermal/imx_thermal.c+41−15

This diff is large: its 110 lines aren’t shown here.

drivers/thermal/of-thermal.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/thermal/power_allocator.c+7−17

This diff is large: its 89 lines aren’t shown here.

drivers/thermal/rcar_thermal.c+21−28

This diff is large: its 79 lines aren’t shown here.

drivers/thermal/rockchip_thermal.c+240−88

This diff is large: its 572 lines aren’t shown here.

drivers/usb/class/cdc-acm.c+5−0

This diff is large: its 12 lines aren’t shown here.

drivers/usb/core/config.c+2−1

This diff is large: its 10 lines aren’t shown here.

drivers/usb/core/hub.c+14−8

This diff is large: its 73 lines aren’t shown here.

drivers/usb/core/port.c+2−2

This diff is large: its 18 lines aren’t shown here.

drivers/usb/core/quirks.c+9−0

This diff is large: its 23 lines aren’t shown here.

drivers/usb/dwc2/platform.c+53−28

This diff is large: its 126 lines aren’t shown here.

drivers/usb/dwc3/gadget.c+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/usb/gadget/function/f_fs.c+3−3

This diff is large: its 27 lines aren’t shown here.

drivers/usb/gadget/function/f_midi.c+2−1

This diff is large: its 17 lines aren’t shown here.

drivers/usb/gadget/function/uvc_configfs.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/usb/gadget/udc/pxa27x_udc.c+3−0

This diff is large: its 10 lines aren’t shown here.

drivers/usb/host/ohci-at91.c+5−6

This diff is large: its 39 lines aren’t shown here.

drivers/usb/host/whci/qset.c+4−0

This diff is large: its 11 lines aren’t shown here.

drivers/usb/host/xhci-hub.c+42−5

This diff is large: its 79 lines aren’t shown here.

drivers/usb/host/xhci-pci.c+6−2

This diff is large: its 17 lines aren’t shown here.

drivers/usb/host/xhci-ring.c+2−1

This diff is large: its 10 lines aren’t shown here.

drivers/usb/host/xhci.c+8−0

This diff is large: its 17 lines aren’t shown here.

drivers/usb/musb/Kconfig+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/usb/musb/musb_core.c+7−1

This diff is large: its 29 lines aren’t shown here.

drivers/usb/phy/phy-msm-usb.c+3−3

This diff is large: its 20 lines aren’t shown here.

drivers/usb/phy/phy-mxs-usb.c+5−0

This diff is large: its 18 lines aren’t shown here.

drivers/usb/renesas_usbhs/mod_gadget.c+9−2

This diff is large: its 25 lines aren’t shown here.

drivers/usb/serial/cp210x.c+0−1

This diff is large: its 8 lines aren’t shown here.

drivers/usb/serial/usb-serial-simple.c+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/usb/storage/uas.c+4−0

This diff is large: its 11 lines aren’t shown here.

drivers/usb/storage/unusual_devs.h+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/usb/storage/unusual_uas.h+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/vfio/Kconfig+0−15

This diff is large: its 22 lines aren’t shown here.

drivers/vfio/pci/vfio_pci.c+5−5

This diff is large: its 43 lines aren’t shown here.

drivers/vfio/platform/vfio_platform.c+0−1

This diff is large: its 8 lines aren’t shown here.

drivers/vfio/platform/vfio_platform_common.c+1−4

This diff is large: its 15 lines aren’t shown here.

drivers/vfio/vfio.c+7−181

This diff is large: its 307 lines aren’t shown here.

drivers/vhost/vhost.c+4−4

This diff is large: its 36 lines aren’t shown here.

drivers/virtio/virtio.c+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/virtio/virtio_ring.c+35−13

This diff is large: its 131 lines aren’t shown here.

drivers/watchdog/Kconfig+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/watchdog/mtk_wdt.c+1−0

This diff is large: its 8 lines aren’t shown here.

drivers/watchdog/omap_wdt.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/watchdog/pnx4008_wdt.c+4−4

This diff is large: its 36 lines aren’t shown here.

drivers/watchdog/tegra_wdt.c+3−1

This diff is large: its 12 lines aren’t shown here.

drivers/watchdog/w83977f_wdt.c+1−1

This diff is large: its 9 lines aren’t shown here.

drivers/xen/events/events_base.c+3−2

This diff is large: its 26 lines aren’t shown here.

drivers/xen/evtchn.c+107−16

This diff is large: its 207 lines aren’t shown here.

drivers/xen/gntdev.c+1−1

This diff is large: its 9 lines aren’t shown here.

fs/9p/vfs_inode.c+2−2

This diff is large: its 12 lines aren’t shown here.

fs/block_dev.c+6−3

This diff is large: its 18 lines aren’t shown here.

fs/btrfs/backref.c+1−1

This diff is large: its 9 lines aren’t shown here.

fs/btrfs/ctree.h+4−0

This diff is large: its 18 lines aren’t shown here.

fs/btrfs/extent-tree.c+100−23

This diff is large: its 196 lines aren’t shown here.

fs/btrfs/file.c+7−3

This diff is large: its 25 lines aren’t shown here.

fs/btrfs/inode.c+1−23

This diff is large: its 39 lines aren’t shown here.

fs/btrfs/qgroup.c+4−1

This diff is large: its 21 lines aren’t shown here.

fs/btrfs/scrub.c+56−6

This diff is large: its 104 lines aren’t shown here.

fs/btrfs/tests/free-space-tests.c+3−1

This diff is large: its 12 lines aren’t shown here.

fs/btrfs/transaction.c+32−0

This diff is large: its 39 lines aren’t shown here.

fs/btrfs/transaction.h+4−0

This diff is large: its 11 lines aren’t shown here.

fs/btrfs/volumes.c+6−7

This diff is large: its 48 lines aren’t shown here.

fs/btrfs/volumes.h+1−1

This diff is large: its 9 lines aren’t shown here.

fs/cifs/inode.c+3−3

This diff is large: its 15 lines aren’t shown here.

fs/direct-io.c+10−1

This diff is large: its 25 lines aren’t shown here.

fs/dlm/lowcomms.c+2−2

This diff is large: its 18 lines aren’t shown here.

fs/exofs/inode.c+1−4

This diff is large: its 12 lines aren’t shown here.

fs/ext4/crypto.c+1−1

This diff is large: its 9 lines aren’t shown here.

fs/ext4/ext4.h+44−7

This diff is large: its 71 lines aren’t shown here.

fs/ext4/symlink.c+1−1

This diff is large: its 9 lines aren’t shown here.

fs/ext4/sysfs.c+1−1

This diff is large: its 9 lines aren’t shown here.

fs/fuse/cuse.c+2−0

This diff is large: its 9 lines aren’t shown here.

fs/fuse/file.c+1−1

This diff is large: its 16 lines aren’t shown here.

fs/jbd2/transaction.c+9−3

This diff is large: its 54 lines aren’t shown here.

fs/namei.c+0−1

This diff is large: its 8 lines aren’t shown here.

fs/nfs/inode.c+12−5

This diff is large: its 40 lines aren’t shown here.

fs/nfs/internal.h+1−1

This diff is large: its 9 lines aren’t shown here.

fs/nfs/nfs42proc.c+2−1

This diff is large: its 17 lines aren’t shown here.

fs/nfs/nfs4client.c+1−1

This diff is large: its 9 lines aren’t shown here.

fs/nfs/nfs4file.c+27−32

This diff is large: its 131 lines aren’t shown here.

fs/nfs/nfs4proc.c+1−1

This diff is large: its 9 lines aren’t shown here.

fs/nfs/nfs4xdr.c+1−0

This diff is large: its 8 lines aren’t shown here.

fs/nfs/objlayout/objio_osd.c+1−4

This diff is large: its 12 lines aren’t shown here.

fs/nfs/pagelist.c+1−1

This diff is large: its 9 lines aren’t shown here.

fs/nfs/pnfs.c+33−27

This diff is large: its 86 lines aren’t shown here.

fs/ocfs2/namei.c+1−3

This diff is large: its 15 lines aren’t shown here.

fs/overlayfs/copy_up.c+6−17

This diff is large: its 68 lines aren’t shown here.

fs/overlayfs/inode.c+8−11

This diff is large: its 50 lines aren’t shown here.

fs/overlayfs/overlayfs.h+1−2

This diff is large: its 9 lines aren’t shown here.

fs/splice.c+8−0

This diff is large: its 22 lines aren’t shown here.

fs/sysv/inode.c+2−9

This diff is large: its 18 lines aren’t shown here.

include/asm-generic/tlb.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/clocksource/arm_arch_timer.h+6−0

This diff is large: its 13 lines aren’t shown here.

include/drm/drmP.h+10−0

This diff is large: its 31 lines aren’t shown here.

include/kvm/arm_vgic.h+6−0

This diff is large: its 13 lines aren’t shown here.

include/linux/acpi.h+2−2

This diff is large: its 11 lines aren’t shown here.

include/linux/bitops.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/linux/blkdev.h+1−2

This diff is large: its 24 lines aren’t shown here.

include/linux/bpf.h+4−1

This diff is large: its 20 lines aren’t shown here.

include/linux/cgroup-defs.h+3−10

This diff is large: its 34 lines aren’t shown here.

include/linux/cgroup.h+23−24

This diff is large: its 90 lines aren’t shown here.

include/linux/cpufreq.h+1−0

This diff is large: its 8 lines aren’t shown here.

include/linux/dns_resolver.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/linux/ipv6.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/linux/irqchip/arm-gic-v3.h+1−0

This diff is large: its 8 lines aren’t shown here.

include/linux/jump_label.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/linux/kmemleak.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/linux/kref.h+0−33

This diff is large: its 47 lines aren’t shown here.

include/linux/libata.h+1−0

This diff is large: its 8 lines aren’t shown here.

include/linux/lightnvm.h+58−139

This diff is large: its 331 lines aren’t shown here.

include/linux/lockdep.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/linux/mlx4/device.h+11−0

This diff is large: its 18 lines aren’t shown here.

include/linux/net.h+9−4

This diff is large: its 41 lines aren’t shown here.

include/linux/netdevice.h+2−1

This diff is large: its 10 lines aren’t shown here.

include/linux/nfs_xdr.h+1−0

This diff is large: its 8 lines aren’t shown here.

include/linux/of_irq.h+12−7

This diff is large: its 60 lines aren’t shown here.

include/linux/pci.h+9−0

This diff is large: its 19 lines aren’t shown here.

include/linux/perf_event.h+4−2

This diff is large: its 14 lines aren’t shown here.

include/linux/proportions.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/linux/scpi_protocol.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/linux/stop_machine.h+3−3

This diff is large: its 25 lines aren’t shown here.

include/linux/syscalls.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/linux/thermal.h+2−1

This diff is large: its 10 lines aren’t shown here.

include/linux/types.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/linux/uprobes.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/linux/usb/quirks.h+3−0

This diff is large: its 8 lines aren’t shown here.

include/linux/vfio.h+0−3

This diff is large: its 10 lines aren’t shown here.

include/linux/wait.h+5−5

This diff is large: its 24 lines aren’t shown here.

include/net/af_unix.h+1−0

This diff is large: its 8 lines aren’t shown here.

include/net/ip6_route.h+4−13

This diff is large: its 32 lines aren’t shown here.

include/net/ipv6.h+21−1

This diff is large: its 50 lines aren’t shown here.

include/net/mac80211.h+4−2

This diff is large: its 13 lines aren’t shown here.

include/net/ndisc.h+1−2

This diff is large: its 10 lines aren’t shown here.

include/net/sch_generic.h+3−0

This diff is large: its 10 lines aren’t shown here.

include/net/sctp/structs.h+8−8

This diff is large: its 39 lines aren’t shown here.

include/net/sock.h+25−7

This diff is large: its 59 lines aren’t shown here.

include/rdma/ib_mad.h+2−0

This diff is large: its 9 lines aren’t shown here.

include/rdma/ib_verbs.h+1−0

This diff is large: its 8 lines aren’t shown here.

include/scsi/scsi_host.h+3−0

This diff is large: its 10 lines aren’t shown here.

include/sound/hda_register.h+3−0

This diff is large: its 10 lines aren’t shown here.

include/sound/soc-dapm.h+1−0

This diff is large: its 8 lines aren’t shown here.

include/target/target_core_base.h+1−1

This diff is large: its 9 lines aren’t shown here.

include/uapi/linux/nfs.h+0−11

This diff is large: its 18 lines aren’t shown here.

include/uapi/linux/vfio.h+0−7

This diff is large: its 14 lines aren’t shown here.

include/video/imx-ipu-v3.h+0−1

This diff is large: its 8 lines aren’t shown here.

init/Kconfig+0−7

This diff is large: its 14 lines aren’t shown here.

kernel/bpf/arraymap.c+8−2

This diff is large: its 28 lines aren’t shown here.

kernel/bpf/hashtab.c+25−9

This diff is large: its 60 lines aren’t shown here.

kernel/bpf/inode.c+3−3

This diff is large: its 27 lines aren’t shown here.

kernel/bpf/syscall.c+27−13

This diff is large: its 91 lines aren’t shown here.

kernel/bpf/verifier.c+1−2

This diff is large: its 10 lines aren’t shown here.

kernel/cgroup.c+78−21

This diff is large: its 226 lines aren’t shown here.

kernel/cgroup_freezer.c+10−13

This diff is large: its 46 lines aren’t shown here.

kernel/cgroup_pids.c+20−57

This diff is large: its 153 lines aren’t shown here.

kernel/cpuset.c+21−12

This diff is large: its 88 lines aren’t shown here.

kernel/events/callchain.c+1−1

This diff is large: its 9 lines aren’t shown here.

kernel/events/core.c+64−26

This diff is large: its 238 lines aren’t shown here.

kernel/events/ring_buffer.c+1−1

This diff is large: its 9 lines aren’t shown here.

kernel/events/uprobes.c+1−1

This diff is large: its 9 lines aren’t shown here.

kernel/fork.c+3−6

This diff is large: its 30 lines aren’t shown here.

kernel/irq_work.c+1−1

This diff is large: its 7 lines aren’t shown here.

kernel/jump_label.c+1−1

This diff is large: its 9 lines aren’t shown here.

kernel/locking/lockdep.c+1−1

This diff is large: its 9 lines aren’t shown here.

kernel/locking/lockdep_proc.c+1−1

This diff is large: its 9 lines aren’t shown here.

kernel/pid.c+2−2

This diff is large: its 18 lines aren’t shown here.

kernel/sched/clock.c+1−1

This diff is large: its 9 lines aren’t shown here.

kernel/sched/core.c+36−12

This diff is large: its 99 lines aren’t shown here.

kernel/sched/cputime.c+3−0

This diff is large: its 10 lines aren’t shown here.

kernel/sched/fair.c+1−1

This diff is large: its 9 lines aren’t shown here.

kernel/sched/rt.c+1−1

This diff is large: its 9 lines aren’t shown here.

kernel/sched/sched.h+3−0

This diff is large: its 10 lines aren’t shown here.

kernel/sched/wait.c+14−14

This diff is large: its 75 lines aren’t shown here.

kernel/stop_machine.c+2−2

This diff is large: its 15 lines aren’t shown here.

kernel/trace/ring_buffer.c+9−8

This diff is large: its 46 lines aren’t shown here.

kernel/trace/trace_event_perf.c+1−1

This diff is large: its 9 lines aren’t shown here.

kernel/trace/trace_events.c+16−0

This diff is large: its 30 lines aren’t shown here.

lib/btree.c+1−1

This diff is large: its 9 lines aren’t shown here.

lib/proportions.c+1−1

This diff is large: its 9 lines aren’t shown here.

mm/backing-dev.c+16−3

This diff is large: its 33 lines aren’t shown here.

mm/hugetlb.c+20−7

This diff is large: its 59 lines aren’t shown here.

mm/memcontrol.c+25−24

This diff is large: its 121 lines aren’t shown here.

mm/oom_kill.c+2−0

This diff is large: its 9 lines aren’t shown here.

mm/page-writeback.c+1−1

This diff is large: its 9 lines aren’t shown here.

mm/page_alloc.c+2−1

This diff is large: its 11 lines aren’t shown here.

mm/shmem.c+14−20

This diff is large: its 73 lines aren’t shown here.

mm/vmstat.c+5−3

This diff is large: its 44 lines aren’t shown here.

net/bluetooth/af_bluetooth.c+3−3

This diff is large: its 23 lines aren’t shown here.

net/bluetooth/smp.c+6−1

This diff is large: its 15 lines aren’t shown here.

net/caif/caif_socket.c+2−2

This diff is large: its 18 lines aren’t shown here.

net/core/datagram.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/core/neighbour.c+2−2

This diff is large: its 18 lines aren’t shown here.

net/core/netclassid_cgroup.c+20−8

This diff is large: its 56 lines aren’t shown here.

net/core/netprio_cgroup.c+5−4

This diff is large: its 19 lines aren’t shown here.

net/core/scm.c+2−0

This diff is large: its 9 lines aren’t shown here.

net/core/sock.c+5−7

This diff is large: its 55 lines aren’t shown here.

net/core/stream.c+3−3

This diff is large: its 27 lines aren’t shown here.

net/dccp/ipv6.c+23−14

This diff is large: its 96 lines aren’t shown here.

net/dccp/proto.c+1−2

This diff is large: its 10 lines aren’t shown here.

net/decnet/af_decnet.c+4−4

This diff is large: its 25 lines aren’t shown here.

net/dns_resolver/dns_query.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/hsr/hsr_device.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/ipv4/igmp.c+3−2

This diff is large: its 19 lines aren’t shown here.

net/ipv4/ipmr.c+8−15

This diff is large: its 79 lines aren’t shown here.

net/ipv4/tcp.c+3−4

This diff is large: its 28 lines aren’t shown here.

net/ipv4/tcp_input.c+20−3

This diff is large: its 55 lines aren’t shown here.

net/ipv4/tcp_ipv4.c+2−1

This diff is large: its 10 lines aren’t shown here.

net/ipv4/tcp_timer.c+13−1

This diff is large: its 28 lines aren’t shown here.

net/ipv4/udp.c+0−1

This diff is large: its 8 lines aren’t shown here.

net/ipv6/addrconf.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/ipv6/af_inet6.c+10−5

This diff is large: its 36 lines aren’t shown here.

net/ipv6/datagram.c+3−1

This diff is large: its 12 lines aren’t shown here.

net/ipv6/exthdrs.c+2−1

This diff is large: its 17 lines aren’t shown here.

net/ipv6/icmp.c+0−14

This diff is large: its 28 lines aren’t shown here.

net/ipv6/inet6_connection_sock.c+9−12

This diff is large: its 55 lines aren’t shown here.

net/ipv6/ip6_tunnel.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/ipv6/ip6mr.c+8−11

This diff is large: its 68 lines aren’t shown here.

net/ipv6/ipv6_sockglue.c+22−11

This diff is large: its 84 lines aren’t shown here.

net/ipv6/ndisc.c+3−7

This diff is large: its 35 lines aren’t shown here.

net/ipv6/netfilter/nf_conntrack_reasm.c+3−2

This diff is large: its 26 lines aren’t shown here.

net/ipv6/raw.c+6−2

This diff is large: its 29 lines aren’t shown here.

net/ipv6/reassembly.c+7−3

This diff is large: its 38 lines aren’t shown here.

net/ipv6/route.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/ipv6/syncookies.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/ipv6/tcp_ipv6.c+19−13

This diff is large: its 89 lines aren’t shown here.

net/ipv6/udp.c+6−2

This diff is large: its 29 lines aren’t shown here.

net/iucv/af_iucv.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/l2tp/l2tp_ip6.c+6−2

This diff is large: its 29 lines aren’t shown here.

net/mac80211/agg-tx.c+2−1

This diff is large: its 17 lines aren’t shown here.

net/mac80211/cfg.c+6−2

This diff is large: its 15 lines aren’t shown here.

net/mac80211/iface.c+3−2

This diff is large: its 26 lines aren’t shown here.

net/mac80211/main.c+1−2

This diff is large: its 10 lines aren’t shown here.

net/mac80211/mesh_pathtbl.c+4−4

This diff is large: its 31 lines aren’t shown here.

net/mac80211/scan.c+5−4

This diff is large: its 30 lines aren’t shown here.

net/nfc/llcp_sock.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/openvswitch/dp_notify.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/openvswitch/vport-geneve.c+0−1

This diff is large: its 8 lines aren’t shown here.

net/openvswitch/vport-gre.c+0−1

This diff is large: its 8 lines aren’t shown here.

net/openvswitch/vport-netdev.c+6−2

This diff is large: its 16 lines aren’t shown here.

net/openvswitch/vport.c+4−4

This diff is large: its 29 lines aren’t shown here.

net/openvswitch/vport.h+7−1

This diff is large: its 15 lines aren’t shown here.

net/packet/af_packet.c+2−2

This diff is large: its 11 lines aren’t shown here.

net/rds/connection.c+0−6

This diff is large: its 13 lines aren’t shown here.

net/rds/send.c+3−1

This diff is large: its 15 lines aren’t shown here.

net/rxrpc/ar-ack.c+3−1

This diff is large: its 12 lines aren’t shown here.

net/rxrpc/ar-output.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/sched/sch_api.c+18−9

This diff is large: its 80 lines aren’t shown here.

net/sched/sch_generic.c+1−1

This diff is large: its 9 lines aren’t shown here.

net/sched/sch_mq.c+2−2

This diff is large: its 18 lines aren’t shown here.

net/sched/sch_mqprio.c+2−2

This diff is large: its 18 lines aren’t shown here.

net/sctp/ipv6.c+10−3

This diff is large: its 41 lines aren’t shown here.

net/sctp/socket.c+25−14

This diff is large: its 91 lines aren’t shown here.

net/socket.c+7−14

This diff is large: its 43 lines aren’t shown here.

net/sunrpc/sched.c+3−3

This diff is large: its 15 lines aren’t shown here.

net/sunrpc/svc.c+13−0

This diff is large: its 20 lines aren’t shown here.

net/sunrpc/xprtsock.c+7−7

This diff is large: its 63 lines aren’t shown here.

net/tipc/link.c+2−0

This diff is large: its 16 lines aren’t shown here.

net/tipc/socket.c+7−3

This diff is large: its 38 lines aren’t shown here.

net/tipc/udp_media.c+5−2

This diff is large: its 14 lines aren’t shown here.

net/unix/af_unix.c+231−37

This diff is large: its 459 lines aren’t shown here.

scripts/link-vmlinux.sh+1−1

This diff is large: its 9 lines aren’t shown here.

security/keys/encrypted-keys/encrypted.c+2−0

This diff is large: its 9 lines aren’t shown here.

security/keys/trusted.c+4−1

This diff is large: its 18 lines aren’t shown here.

security/keys/user_defined.c+4−1

This diff is large: its 12 lines aren’t shown here.

security/selinux/ss/conditional.c+2−2

This diff is large: its 18 lines aren’t shown here.

sound/firewire/dice/dice.c+4−0

This diff is large: its 21 lines aren’t shown here.

sound/pci/hda/hda_intel.c+30−0

This diff is large: its 67 lines aren’t shown here.

sound/pci/hda/patch_ca0132.c+2−1

This diff is large: its 10 lines aren’t shown here.

sound/pci/hda/patch_conexant.c+3−2

This diff is large: its 20 lines aren’t shown here.

sound/pci/hda/patch_hdmi.c+8−1

This diff is large: its 23 lines aren’t shown here.

sound/pci/hda/patch_realtek.c+54−1

This diff is large: its 169 lines aren’t shown here.

sound/pci/hda/patch_sigmatel.c+29−16

This diff is large: its 59 lines aren’t shown here.

sound/pci/rme96.c+26−15

This diff is large: its 79 lines aren’t shown here.

sound/soc/codecs/arizona.c+5−11

This diff is large: its 42 lines aren’t shown here.

sound/soc/codecs/es8328.c+8−8

This diff is large: its 27 lines aren’t shown here.

sound/soc/codecs/nau8825.c+31−0

This diff is large: its 45 lines aren’t shown here.

sound/soc/codecs/rl6231.c+4−2

This diff is large: its 13 lines aren’t shown here.

sound/soc/codecs/rt5645.c+57−4

This diff is large: its 114 lines aren’t shown here.

sound/soc/codecs/rt5670.h+6−6

This diff is large: its 19 lines aren’t shown here.

sound/soc/codecs/rt5677.c+61−39

This diff is large: its 179 lines aren’t shown here.

sound/soc/codecs/wm8960.c+1−1

This diff is large: its 9 lines aren’t shown here.

sound/soc/codecs/wm8962.c+2−2

This diff is large: its 11 lines aren’t shown here.

sound/soc/davinci/davinci-mcasp.c+10−2

This diff is large: its 26 lines aren’t shown here.

sound/soc/fsl/Kconfig+2−0

This diff is large: its 9 lines aren’t shown here.

sound/soc/fsl/fsl_sai.c+2−1

This diff is large: its 10 lines aren’t shown here.

sound/soc/intel/Kconfig+1−1

This diff is large: its 9 lines aren’t shown here.

sound/soc/intel/skylake/skl-topology.c+1−0

This diff is large: its 8 lines aren’t shown here.

sound/soc/rockchip/rockchip_spdif.c+1−1

This diff is large: its 9 lines aren’t shown here.

sound/soc/rockchip/rockchip_spdif.h+3−3

This diff is large: its 13 lines aren’t shown here.

sound/soc/sh/rcar/gen.c+1−1

This diff is large: its 9 lines aren’t shown here.

sound/soc/sh/rcar/src.c+7−0

This diff is large: its 21 lines aren’t shown here.

sound/soc/soc-core.c+3−3

This diff is large: its 16 lines aren’t shown here.

sound/soc/soc-dapm.c+7−0

This diff is large: its 21 lines aren’t shown here.

sound/soc/soc-ops.c+1−1

This diff is large: its 9 lines aren’t shown here.

sound/soc/soc-topology.c+2−1

This diff is large: its 17 lines aren’t shown here.

sound/soc/sti/uniperif_player.c+6−3

This diff is large: its 42 lines aren’t shown here.

sound/soc/sti/uniperif_reader.c+1−2

This diff is large: its 17 lines aren’t shown here.

sound/soc/sunxi/sun4i-codec.c+14−13

This diff is large: its 59 lines aren’t shown here.

sound/usb/midi.c+46−0

This diff is large: its 81 lines aren’t shown here.

sound/usb/quirks-table.h+11−0

This diff is large: its 18 lines aren’t shown here.

sound/usb/quirks.c+1−0

This diff is large: its 8 lines aren’t shown here.

sound/usb/usbaudio.h+1−0

This diff is large: its 8 lines aren’t shown here.

tools/testing/nvdimm/test/nfit.c+15−34

This diff is large: its 169 lines aren’t shown here.

tools/testing/selftests/futex/README+1−1

This diff is large: its 9 lines aren’t shown here.

tools/testing/selftests/seccomp/seccomp_bpf.c+7−4

This diff is large: its 31 lines aren’t shown here.

tools/virtio/linux/kernel.h+6−0

This diff is large: its 11 lines aren’t shown here.

tools/virtio/linux/virtio.h+0−6

This diff is large: its 13 lines aren’t shown here.

tools/virtio/linux/virtio_config.h+13−7

This diff is large: its 47 lines aren’t shown here.

virt/kvm/arm/vgic-v3.c+3−8

This diff is large: its 37 lines aren’t shown here.

virt/kvm/arm/vgic.c+1−1

This diff is large: its 9 lines aren’t shown here.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

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

Repository code

Go to file
t