History

Merge 4.5-rc2 into usb-next

We want the USB fixes in here as well.

Greg Kroah-Hartman committed 10 years ago

Commit 4f97f8f2 parents 0e781c2 36f90b0267 files · +3988 −1770Browse files

Unified · Split

267 files
  1. .mailmap +1 −0
  2. Documentation/Intel-IOMMU.txt +1 −1
  3. Documentation/virtual/kvm/api.txt +1 −1
  4. Makefile +1 −1
  5. arch/arm/boot/compressed/Makefile +9 −0
  6. arch/arm/include/uapi/asm/unistd.h +1 −0
  7. arch/arm/kernel/calls.S +1 −0
  8. arch/arm64/Makefile +2 −0
  9. arch/arm64/configs/defconfig +25 −17
  10. arch/arm64/include/asm/pgtable.h +10 −11
  11. arch/arm64/kernel/head.S +5 −0
  12. arch/arm64/kernel/image.h +25 −15
  13. arch/arm64/mm/dump.c +1 −1
  14. arch/arm64/mm/kasan_init.c +9 −0
  15. arch/arm64/mm/pageattr.c +3 −0
  16. arch/arm64/mm/proc-macros.S +12 −0
  17. arch/arm64/mm/proc.S +2 −2
  18. arch/mips/bcm63xx/nvram.c +11 −0
  19. arch/mips/include/asm/mach-bcm63xx/bcm63xx_nvram.h +2 −0
  20. arch/powerpc/include/asm/book3s/64/hash.h +3 −1
  21. arch/powerpc/include/asm/book3s/64/pgtable.h +0 −1
  22. arch/powerpc/include/asm/kvm_host.h +1 −2
  23. arch/powerpc/include/asm/systbl.h +1 −0
  24. arch/powerpc/include/asm/unistd.h +1 −1
  25. arch/powerpc/include/uapi/asm/unistd.h +1 −0
  26. arch/powerpc/kernel/eeh_pe.c +15 −18
  27. arch/powerpc/kernel/misc_64.S +0 −28
  28. arch/powerpc/kernel/module_64.c +9 −3
  29. arch/powerpc/kvm/book3s_64_mmu.c +0 −3
  30. arch/powerpc/kvm/book3s_hv.c +18 −0
  31. arch/powerpc/kvm/book3s_hv_rmhandlers.S +3 −1
  32. arch/powerpc/kvm/powerpc.c +10 −10
  33. arch/powerpc/mm/mem.c +2 −2
  34. arch/powerpc/perf/power8-pmu.c +1 −1
  35. arch/s390/include/asm/irqflags.h +7 −2
  36. arch/s390/include/asm/kvm_host.h +0 −1
  37. arch/s390/include/asm/pci_io.h +9 −5
  38. arch/s390/include/asm/processor.h +2 −2
  39. arch/s390/include/asm/ptrace.h +3 −3
  40. arch/s390/include/uapi/asm/unistd.h +2 −1
  41. arch/s390/kernel/compat_wrapper.c +1 −0
  42. arch/s390/kernel/crash_dump.c +0 −2
  43. arch/s390/kernel/debug.c +1 −1
  44. arch/s390/kernel/dumpstack.c +4 −5
  45. arch/s390/kernel/early.c +4 −4
  46. arch/s390/kernel/ftrace.c +1 −1
  47. arch/s390/kernel/ipl.c +2 −2
  48. arch/s390/kernel/kprobes.c +8 −8
  49. arch/s390/kernel/perf_event.c +5 −7
  50. arch/s390/kernel/process.c +6 −6
  51. arch/s390/kernel/ptrace.c +2 −4
  52. arch/s390/kernel/setup.c +6 −10
  53. arch/s390/kernel/signal.c +6 −7
  54. arch/s390/kernel/smp.c +0 −2
  55. arch/s390/kernel/stacktrace.c +5 −6
  56. arch/s390/kernel/syscalls.S +1 −0
  57. arch/s390/kernel/traps.c +5 −6
  58. arch/s390/kvm/Kconfig +1 −0
  59. arch/s390/kvm/Makefile +1 −1
  60. arch/s390/kvm/guestdbg.c +2 −2
  61. arch/s390/kvm/kvm-s390.c +42 −79
  62. arch/s390/mm/fault.c +3 −3
  63. arch/s390/mm/init.c +1 −1
  64. arch/s390/mm/mmap.c +6 −6
  65. arch/s390/mm/pgtable.c +1 −1
  66. arch/s390/numa/numa.c +2 −4
  67. arch/s390/oprofile/backtrace.c +4 −5
  68. arch/s390/pci/pci.c +31 −30
  69. arch/s390/pci/pci_event.c +5 −0
  70. arch/sh/include/asm/barrier.h +0 −1
  71. arch/x86/Kconfig +1 −2
  72. arch/x86/include/asm/irq.h +3 −2
  73. arch/x86/include/asm/pgtable_types.h +2 −4
  74. arch/x86/kernel/apic/io_apic.c +5 −1
  75. arch/x86/kernel/apic/vector.c +145 −76
  76. arch/x86/kernel/apic/x2apic_uv_x.c +4 −1
  77. arch/x86/kernel/cpu/perf_event_intel.c +3 −4
  78. arch/x86/kernel/cpu/perf_event_intel_uncore.c +3 −0
  79. arch/x86/kernel/cpu/perf_event_intel_uncore.h +1 −0
  80. arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c +20 −0
  81. arch/x86/kernel/head64.c +8 −0
  82. arch/x86/kernel/irq.c +10 −1
  83. arch/x86/mm/pageattr.c +2 −2
  84. arch/x86/platform/efi/quirks.c +13 −4
  85. arch/x86/platform/intel-mid/intel-mid.c +3 −5
  86. arch/x86/platform/intel-quark/imr.c +13 −5
  87. block/blk-merge.c +19 −7
  88. drivers/acpi/video_detect.c +0 −8
  89. drivers/base/platform-msi.c +2 −0
  90. drivers/base/platform.c +9 −4
  91. drivers/base/power/domain.c +20 −17
  92. drivers/clocksource/Kconfig +12 −0
  93. drivers/clocksource/tcb_clksrc.c +2 −1
  94. drivers/cpufreq/cpufreq-dt.c +7 −8
  95. drivers/cpufreq/cpufreq.c +3 −3
  96. drivers/cpufreq/cpufreq_governor.c +8 −3
  97. drivers/cpufreq/pxa2xx-cpufreq.c +1 −1
  98. drivers/cpuidle/coupled.c +0 −1
  99. drivers/cpuidle/cpuidle.c +1 −1
  100. drivers/gpu/drm/amd/amdgpu/amdgpu.h +22 −22
  101. drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 −2
  102. drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +4 −0
  103. drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 −1
  104. drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c +18 −7
  105. drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +1 −1
  106. drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 −4
  107. drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +22 −1
  108. drivers/gpu/drm/amd/amdgpu/tonga_dpm.c +2 −15
  109. drivers/gpu/drm/amd/powerplay/amd_powerplay.c +5 −0
  110. drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c +32 −9
  111. drivers/gpu/drm/drm_atomic_helper.c +20 −4
  112. drivers/gpu/drm/etnaviv/common.xml.h +51 −8
  113. drivers/gpu/drm/etnaviv/etnaviv_drv.c +0 −1
  114. drivers/gpu/drm/etnaviv/etnaviv_drv.h +1 −1
  115. drivers/gpu/drm/etnaviv/etnaviv_dump.c +4 −2
  116. drivers/gpu/drm/etnaviv/etnaviv_gem.c +26 −10
  117. drivers/gpu/drm/etnaviv/etnaviv_gem.h +1 −0
  118. drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c +9 −1
  119. drivers/gpu/drm/etnaviv/etnaviv_gpu.c +127 −62
  120. drivers/gpu/drm/etnaviv/etnaviv_gpu.h +9 −0
  121. drivers/gpu/drm/etnaviv/state_hi.xml.h +24 −2
  122. drivers/gpu/drm/radeon/dce6_afmt.c +2 −10
  123. drivers/gpu/drm/radeon/evergreen_hdmi.c +10 −0
  124. drivers/gpu/drm/radeon/evergreend.h +5 −0
  125. drivers/gpu/drm/radeon/radeon.h +1 −1
  126. drivers/gpu/drm/radeon/radeon_atombios.c +36 −13
  127. drivers/gpu/drm/radeon/radeon_audio.c +13 −7
  128. drivers/gpu/drm/radeon/radeon_audio.h +1 −0
  129. drivers/gpu/drm/radeon/radeon_display.c +4 −2
  130. drivers/gpu/drm/radeon/radeon_gem.c +1 −0
  131. drivers/gpu/drm/radeon/vce_v1_0.c +6 −6
  132. drivers/gpu/drm/rockchip/Makefile +4 −4
  133. drivers/gpu/drm/rockchip/dw-mipi-dsi.c +2 −1
  134. drivers/gpu/drm/rockchip/rockchip_drm_drv.c +0 −4
  135. drivers/gpu/drm/rockchip/rockchip_drm_fb.c +21 −3
  136. drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h +11 −0
  137. drivers/gpu/drm/rockchip/rockchip_drm_gem.c +2 −7
  138. drivers/gpu/drm/rockchip/rockchip_drm_vop.c +9 −7
  139. drivers/gpu/drm/vc4/vc4_v3d.c +7 −10
  140. drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +7 −0
  141. drivers/hwmon/dell-smm-hwmon.c +11 −0
  142. drivers/hwmon/fam15h_power.c +9 −1
  143. drivers/i2c/busses/i2c-designware-core.c +2 −1
  144. drivers/i2c/busses/i2c-piix4.c +21 −29
  145. drivers/iio/imu/adis_buffer.c +1 −1
  146. drivers/iommu/amd_iommu.c +1 −1
  147. drivers/iommu/intel-iommu.c +1 −1
  148. drivers/iommu/io-pgtable-arm.c +1 −0
  149. drivers/irqchip/Kconfig +1 −0
  150. drivers/irqchip/irq-atmel-aic-common.c +1 −1
  151. drivers/irqchip/irq-gic-v3-its.c +6 −2
  152. drivers/irqchip/irq-mxs.c +1 −0
  153. drivers/irqchip/irq-s3c24xx.c +1 −1
  154. drivers/of/irq.c +3 −15
  155. drivers/pci/hotplug/acpiphp_glue.c +3 −1
  156. drivers/s390/cio/chp.c +8 −13
  157. drivers/s390/cio/chp.h +1 −1
  158. drivers/s390/cio/chsc.c +24 −19
  159. drivers/s390/crypto/zcrypt_error.h +9 −6
  160. drivers/s390/crypto/zcrypt_msgtype50.c +5 −4
  161. drivers/s390/crypto/zcrypt_msgtype6.c +10 −10
  162. drivers/scsi/hisi_sas/Kconfig +2 −0
  163. drivers/scsi/sd.c +6 −3
  164. drivers/scsi/sr.c +4 −0
  165. drivers/staging/panel/panel.c +15 −19
  166. drivers/staging/speakup/main.c +13 −8
  167. drivers/staging/speakup/selection.c +4 −1
  168. drivers/staging/speakup/serialio.c +12 −1
  169. drivers/tty/n_tty.c +2 −5
  170. drivers/tty/serial/8250/8250_pci.c +29 −0
  171. drivers/tty/tty_io.c +38 −6
  172. drivers/tty/tty_mutex.c +8 −0
  173. drivers/tty/vt/vt.c +1 −0
  174. drivers/usb/class/cdc-acm.c +13 −1
  175. drivers/usb/class/cdc-acm.h +1 −0
  176. drivers/usb/core/hub.c +5 −3
  177. drivers/usb/serial/cp210x.c +1 −0
  178. drivers/usb/serial/ftdi_sio.c +1 −0
  179. drivers/usb/serial/ftdi_sio_ids.h +1 −0
  180. drivers/usb/serial/mxu11x0.c +20 −0
  181. drivers/usb/serial/option.c +17 −1
  182. drivers/usb/serial/visor.c +9 −2
  183. drivers/vfio/vfio.c +10 −14
  184. drivers/virtio/virtio_pci_common.c +2 −0
  185. drivers/xen/tmem.c +1 −1
  186. fs/btrfs/async-thread.c +1 −1
  187. fs/btrfs/disk-io.c +1 −1
  188. fs/btrfs/free-space-tree.c +16 −2
  189. fs/btrfs/inode.c +28 −8
  190. fs/btrfs/relocation.c +2 −1
  191. fs/btrfs/sysfs.c +35 −0
  192. fs/btrfs/sysfs.h +4 −1
  193. fs/btrfs/tests/btrfs-tests.c +5 −5
  194. fs/btrfs/tests/extent-io-tests.c +6 −6
  195. fs/btrfs/tests/inode-tests.c +4 −4
  196. fs/btrfs/tree-log.c +11 −3
  197. fs/timerfd.c +1 −1
  198. include/drm/drm_atomic_helper.h +4 −0
  199. include/linux/cleancache.h +7 −9
  200. include/linux/ftrace.h +0 −1
  201. include/linux/hrtimer.h +31 −3
  202. include/linux/iommu.h +12 −4
  203. include/linux/irqdomain.h +1 −0
  204. include/linux/perf_event.h +3 −6
  205. include/linux/swiotlb.h +3 −0
  206. include/linux/tty.h +1 −0
  207. include/trace/events/fence.h +1 −1
  208. include/uapi/drm/etnaviv_drm.h +3 −0
  209. kernel/bpf/arraymap.c +11 −10
  210. kernel/events/core.c +599 −600
  211. kernel/events/hw_breakpoint.c +1 −1
  212. kernel/events/ring_buffer.c +20 −20
  213. kernel/futex.c +9 −9
  214. kernel/irq/handle.c +3 −2
  215. kernel/irq/irqdomain.c +8 −3
  216. kernel/locking/rtmutex.c +72 −63
  217. kernel/pid.c +1 −1
  218. kernel/power/Kconfig +1 −1
  219. kernel/sched/core.c +1 −1
  220. kernel/sched/fair.c +23 −7
  221. kernel/sched/idle.c +1 −1
  222. kernel/seccomp.c +11 −11
  223. kernel/time/hrtimer.c +37 −18
  224. kernel/time/itimer.c +1 −1
  225. kernel/time/ntp.c +12 −2
  226. kernel/time/posix-timers.c +1 −1
  227. kernel/time/tick-sched.c +9 −7
  228. kernel/time/timer_list.c +1 −1
  229. kernel/trace/bpf_trace.c +10 −4
  230. kernel/trace/trace.c +1 −1
  231. lib/debugobjects.c +1 −1
  232. mm/cleancache.c +2 −2
  233. scripts/mod/modpost.c +2 −1
  234. security/keys/key.c +2 −1
  235. sound/core/Kconfig +3 −3
  236. sound/core/compress_offload.c +11 −0
  237. sound/core/seq/oss/seq_oss_init.c +1 −1
  238. sound/core/seq/oss/seq_oss_synth.c +1 −1
  239. sound/drivers/dummy.c +1 −1
  240. sound/firewire/bebob/bebob_stream.c +9 −5
  241. sound/isa/Kconfig +4 −0
  242. sound/pci/Kconfig +3 −0
  243. sound/pci/hda/hda_intel.c +13 −0
  244. sound/pci/hda/patch_hdmi.c +1 −0
  245. sound/sparc/Kconfig +1 −0
  246. sound/usb/quirks.c +13 −1
  247. tools/perf/Makefile.perf +24 −1
  248. tools/perf/arch/x86/tests/intel-cqm.c +1 −1
  249. tools/perf/config/Makefile +4 −0
  250. tools/perf/tests/make +40 −15
  251. tools/perf/ui/browsers/annotate.c +2 −2
  252. tools/perf/util/hist.c +2 −0
  253. tools/perf/util/session.c +1 −1
  254. tools/perf/util/stat.c +0 −1
  255. tools/perf/util/symbol.c +1 −1
  256. tools/testing/selftests/timers/valid-adjtimex.c +138 −1
  257. tools/virtio/asm/barrier.h +13 −9
  258. tools/virtio/linux/compiler.h +9 −0
  259. tools/virtio/linux/kernel.h +1 −0
  260. tools/virtio/ringtest/Makefile +22 −0
  261. tools/virtio/ringtest/README +2 −0
  262. tools/virtio/ringtest/main.c +366 −0
  263. tools/virtio/ringtest/main.h +119 −0
  264. tools/virtio/ringtest/ring.c +272 −0
  265. tools/virtio/ringtest/run-on-all.sh +24 −0
  266. tools/virtio/ringtest/virtio_ring_0_9.c +316 −0
  267. tools/virtio/ringtest/virtio_ring_poll.c +2 −0
.mailmap+1−0
@@ -21,6 +21,7 @@ Andrey Ryabinin <ryabinin.a.a@gmail.com> <a.ryabinin@samsung.com> · 20 unmodified lines
2121 Andrew Morton <akpm@linux-foundation.org>
2222 Andrew Vasquez <andrew.vasquez@qlogic.com>
2323 Andy Adamson <andros@citi.umich.edu>
24+Antonio Ospite <ao2@ao2.it> <ao2@amarulasolutions.com>
2425 Archit Taneja <archit@ti.com>
2526 Arnaud Patard <arnaud.patard@rtp-net.org>
2627 Arnd Bergmann <arnd@arndb.de>
Documentation/Intel-IOMMU.txt+1−1
@@ -3,7 +3,7 @@ Linux IOMMU Support · 2 unmodified lines
33
44 The architecture spec can be obtained from the below location.
55
6−http://www.intel.com/technology/virtualization/
6+http://www.intel.com/content/dam/www/public/us/en/documents/product-specifications/vt-directed-io-spec.pdf
77
88 This guide gives a quick cheat sheet for some basic understanding.
99
Documentation/virtual/kvm/api.txt+1−1
@@ -3025,7 +3025,7 @@ len must be a multiple of sizeof(struct kvm_s390_irq). It must be > 0 · 3024 unmodified lines
30253025 and it must not exceed (max_vcpus + 32) * sizeof(struct kvm_s390_irq),
30263026 which is the maximum number of possibly pending cpu-local interrupts.
30273027
3028−4.90 KVM_SMI
3028+4.96 KVM_SMI
30293029
30303030 Capability: KVM_CAP_X86_SMM
30313031 Architectures: x86
Makefile+1−1
@@ -1,7 +1,7 @@
11 VERSION = 4
22 PATCHLEVEL = 5
33 SUBLEVEL = 0
4−EXTRAVERSION = -rc1
4+EXTRAVERSION = -rc2
55 NAME = Blurry Fish Butt
66
77 # *DOCUMENTATION*
arch/arm/boot/compressed/Makefile+9−0
@@ -106,6 +106,15 @@ ORIG_CFLAGS := $(KBUILD_CFLAGS) · 105 unmodified lines
106106 KBUILD_CFLAGS = $(subst -pg, , $(ORIG_CFLAGS))
107107 endif
108108
109+# -fstack-protector-strong triggers protection checks in this code,
110+# but it is being used too early to link to meaningful stack_chk logic.
111+nossp_flags := $(call cc-option, -fno-stack-protector)
112+CFLAGS_atags_to_fdt.o := $(nossp_flags)
113+CFLAGS_fdt.o := $(nossp_flags)
114+CFLAGS_fdt_ro.o := $(nossp_flags)
115+CFLAGS_fdt_rw.o := $(nossp_flags)
116+CFLAGS_fdt_wip.o := $(nossp_flags)
117+
109118 ccflags-y := -fpic -mno-single-pic-base -fno-builtin -I$(obj)
110119 asflags-y := -DZIMAGE
111120
arch/arm/include/uapi/asm/unistd.h+1−0
@@ -417,6 +417,7 @@ · 416 unmodified lines
417417 #define __NR_userfaultfd (__NR_SYSCALL_BASE+388)
418418 #define __NR_membarrier (__NR_SYSCALL_BASE+389)
419419 #define __NR_mlock2 (__NR_SYSCALL_BASE+390)
420+#define __NR_copy_file_range (__NR_SYSCALL_BASE+391)
420421
421422 /*
422423 * The following SWIs are ARM private.
arch/arm/kernel/calls.S+1−0
@@ -400,6 +400,7 @@ · 399 unmodified lines
400400 CALL(sys_userfaultfd)
401401 CALL(sys_membarrier)
402402 CALL(sys_mlock2)
403+ CALL(sys_copy_file_range)
403404 #ifndef syscalls_counted
404405 .equ syscalls_padding, ((NR_syscalls + 3) & ~3) - NR_syscalls
405406 #define syscalls_counted
arch/arm64/Makefile+2−0
@@ -27,6 +27,8 @@ $(warning LSE atomics not supported by binutils) · 26 unmodified lines
2727 endif
2828
2929 KBUILD_CFLAGS += -mgeneral-regs-only $(lseinstr)
30+KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
31+KBUILD_CFLAGS += $(call cc-option, -mpc-relative-literal-loads)
3032 KBUILD_AFLAGS += $(lseinstr)
3133
3234 ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
arch/arm64/configs/defconfig+25−17
@@ -16,7 +16,6 @@ CONFIG_IKCONFIG_PROC=y · 15 unmodified lines
1616 CONFIG_LOG_BUF_SHIFT=14
1717 CONFIG_MEMCG=y
1818 CONFIG_MEMCG_SWAP=y
19−CONFIG_MEMCG_KMEM=y
2019 CONFIG_CGROUP_HUGETLB=y
2120 # CONFIG_UTS_NS is not set
2221 # CONFIG_IPC_NS is not set
@@ -37,15 +36,13 @@ CONFIG_ARCH_EXYNOS7=y · 14 unmodified lines
3736 CONFIG_ARCH_LAYERSCAPE=y
3837 CONFIG_ARCH_HISI=y
3938 CONFIG_ARCH_MEDIATEK=y
39+CONFIG_ARCH_QCOM=y
4040 CONFIG_ARCH_ROCKCHIP=y
4141 CONFIG_ARCH_SEATTLE=y
4242 CONFIG_ARCH_RENESAS=y
4343 CONFIG_ARCH_R8A7795=y
4444 CONFIG_ARCH_STRATIX10=y
4545 CONFIG_ARCH_TEGRA=y
46−CONFIG_ARCH_TEGRA_132_SOC=y
47−CONFIG_ARCH_TEGRA_210_SOC=y
48−CONFIG_ARCH_QCOM=y
4946 CONFIG_ARCH_SPRD=y
5047 CONFIG_ARCH_THUNDER=y
5148 CONFIG_ARCH_UNIPHIER=y
@@ -54,14 +51,19 @@ CONFIG_ARCH_XGENE=y · 2 unmodified lines
5451 CONFIG_ARCH_ZYNQMP=y
5552 CONFIG_PCI=y
5653 CONFIG_PCI_MSI=y
54+CONFIG_PCI_IOV=y
55+CONFIG_PCI_RCAR_GEN2_PCIE=y
5756 CONFIG_PCI_HOST_GENERIC=y
5857 CONFIG_PCI_XGENE=y
59−CONFIG_SMP=y
58+CONFIG_PCI_LAYERSCAPE=y
59+CONFIG_PCI_HISI=y
60+CONFIG_PCIE_QCOM=y
6061 CONFIG_SCHED_MC=y
6162 CONFIG_PREEMPT=y
6263 CONFIG_KSM=y
6364 CONFIG_TRANSPARENT_HUGEPAGE=y
6465 CONFIG_CMA=y
66+CONFIG_XEN=y
6567 CONFIG_CMDLINE="console=ttyAMA0"
6668 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
6769 CONFIG_COMPAT=y
@@ -100,7 +102,11 @@ CONFIG_PATA_OF_PLATFORM=y · 32 unmodified lines
100102 CONFIG_NETDEVICES=y
101103 CONFIG_TUN=y
102104 CONFIG_VIRTIO_NET=y
105+CONFIG_AMD_XGBE=y
103106 CONFIG_NET_XGENE=y
107+CONFIG_E1000E=y
108+CONFIG_IGB=y
109+CONFIG_IGBVF=y
104110 CONFIG_SKY2=y
105111 CONFIG_RAVB=y
106112 CONFIG_SMC91X=y
@@ -117,25 +123,23 @@ CONFIG_SERIAL_8250_CONSOLE=y · 10 unmodified lines
117123 CONFIG_SERIAL_8250_DW=y
118124 CONFIG_SERIAL_8250_MT6577=y
119125 CONFIG_SERIAL_8250_UNIPHIER=y
126+CONFIG_SERIAL_OF_PLATFORM=y
120127 CONFIG_SERIAL_AMBA_PL011=y
121128 CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
122129 CONFIG_SERIAL_SAMSUNG=y
123−CONFIG_SERIAL_SAMSUNG_UARTS_4=y
124−CONFIG_SERIAL_SAMSUNG_UARTS=4
125130 CONFIG_SERIAL_SAMSUNG_CONSOLE=y
131+CONFIG_SERIAL_TEGRA=y
126132 CONFIG_SERIAL_SH_SCI=y
127133 CONFIG_SERIAL_SH_SCI_NR_UARTS=11
128134 CONFIG_SERIAL_SH_SCI_CONSOLE=y
129−CONFIG_SERIAL_TEGRA=y
130135 CONFIG_SERIAL_MSM=y
131136 CONFIG_SERIAL_MSM_CONSOLE=y
132−CONFIG_SERIAL_OF_PLATFORM=y
133137 CONFIG_SERIAL_XILINX_PS_UART=y
134138 CONFIG_SERIAL_XILINX_PS_UART_CONSOLE=y
135139 CONFIG_VIRTIO_CONSOLE=y
136140 # CONFIG_HW_RANDOM is not set
137−CONFIG_I2C=y
138141 CONFIG_I2C_QUP=y
142+CONFIG_I2C_UNIPHIER_F=y
139143 CONFIG_I2C_RCAR=y
140144 CONFIG_SPI=y
141145 CONFIG_SPI_PL022=y
@@ -176,8 +180,6 @@ CONFIG_MMC_SDHCI_PLTFM=y · 34 unmodified lines
176180 CONFIG_MMC_SDHCI_TEGRA=y
177181 CONFIG_MMC_SPI=y
178182 CONFIG_MMC_DW=y
179−CONFIG_MMC_DW_IDMAC=y
180−CONFIG_MMC_DW_PLTFM=y
181183 CONFIG_MMC_DW_EXYNOS=y
182184 CONFIG_NEW_LEDS=y
183185 CONFIG_LEDS_CLASS=y
@@ -187,28 +189,33 @@ CONFIG_LEDS_TRIGGER_HEARTBEAT=y · 3 unmodified lines
187189 CONFIG_LEDS_TRIGGER_CPU=y
188190 CONFIG_RTC_CLASS=y
189191 CONFIG_RTC_DRV_EFI=y
192+CONFIG_RTC_DRV_PL031=y
190193 CONFIG_RTC_DRV_XGENE=y
191194 CONFIG_DMADEVICES=y
192−CONFIG_RCAR_DMAC=y
193195 CONFIG_QCOM_BAM_DMA=y
194196 CONFIG_TEGRA20_APB_DMA=y
197+CONFIG_RCAR_DMAC=y
198+CONFIG_VFIO=y
199+CONFIG_VFIO_PCI=y
195200 CONFIG_VIRTIO_PCI=y
196201 CONFIG_VIRTIO_BALLOON=y
197202 CONFIG_VIRTIO_MMIO=y
203+CONFIG_XEN_GNTDEV=y
204+CONFIG_XEN_GRANT_DEV_ALLOC=y
198205 CONFIG_COMMON_CLK_CS2000_CP=y
199206 CONFIG_COMMON_CLK_QCOM=y
200207 CONFIG_MSM_GCC_8916=y
201208 CONFIG_HWSPINLOCK_QCOM=y
202−# CONFIG_IOMMU_SUPPORT is not set
209+CONFIG_ARM_SMMU=y
203210 CONFIG_QCOM_SMEM=y
204211 CONFIG_QCOM_SMD=y
205212 CONFIG_QCOM_SMD_RPM=y
213+CONFIG_ARCH_TEGRA_132_SOC=y
214+CONFIG_ARCH_TEGRA_210_SOC=y
215+CONFIG_HISILICON_IRQ_MBIGEN=y
206216 CONFIG_PHY_XGENE=y
207217 CONFIG_EXT2_FS=y
208218 CONFIG_EXT3_FS=y
209−# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set
210−# CONFIG_EXT3_FS_XATTR is not set
211−CONFIG_EXT4_FS=y
212219 CONFIG_FANOTIFY=y
213220 CONFIG_FANOTIFY_ACCESS_PERMISSIONS=y
214221 CONFIG_QUOTA=y
@@ -239,6 +246,7 @@ CONFIG_LOCKUP_DETECTOR=y · 24 unmodified lines
239246 # CONFIG_FTRACE is not set
240247 CONFIG_MEMTEST=y
241248 CONFIG_SECURITY=y
249+CONFIG_CRYPTO_ECHAINIV=y
242250 CONFIG_CRYPTO_ANSI_CPRNG=y
243251 CONFIG_ARM64_CRYPTO=y
244252 CONFIG_CRYPTO_SHA1_ARM64_CE=y
arch/arm64/include/asm/pgtable.h+10−11
@@ -67,11 +67,11 @@ extern void __pgd_error(const char *file, int line, unsigned long val); · 66 unmodified lines
6767 #define PROT_DEFAULT (PTE_TYPE_PAGE | PTE_AF | PTE_SHARED)
6868 #define PROT_SECT_DEFAULT (PMD_TYPE_SECT | PMD_SECT_AF | PMD_SECT_S)
6969
70−#define PROT_DEVICE_nGnRnE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_DEVICE_nGnRnE))
71−#define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_DEVICE_nGnRE))
72−#define PROT_NORMAL_NC (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_NORMAL_NC))
73−#define PROT_NORMAL_WT (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_NORMAL_WT))
74−#define PROT_NORMAL (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_NORMAL))
70+#define PROT_DEVICE_nGnRnE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRnE))
71+#define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_DEVICE_nGnRE))
72+#define PROT_NORMAL_NC (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_NC))
73+#define PROT_NORMAL_WT (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL_WT))
74+#define PROT_NORMAL (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_ATTRINDX(MT_NORMAL))
7575
7676 #define PROT_SECT_DEVICE_nGnRE (PROT_SECT_DEFAULT | PMD_SECT_PXN | PMD_SECT_UXN | PMD_ATTRINDX(MT_DEVICE_nGnRE))
7777 #define PROT_SECT_NORMAL (PROT_SECT_DEFAULT | PMD_SECT_PXN | PMD_SECT_UXN | PMD_ATTRINDX(MT_NORMAL))
@@ -81,7 +81,7 @@ extern void __pgd_error(const char *file, int line, unsigned long val); · 3 unmodified lines
8181
8282 #define PAGE_KERNEL __pgprot(_PAGE_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_WRITE)
8383 #define PAGE_KERNEL_RO __pgprot(_PAGE_DEFAULT | PTE_PXN | PTE_UXN | PTE_DIRTY | PTE_RDONLY)
84−#define PAGE_KERNEL_ROX __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_RDONLY)
84+#define PAGE_KERNEL_ROX __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_RDONLY)
8585 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_WRITE)
8686 #define PAGE_KERNEL_EXEC_CONT __pgprot(_PAGE_DEFAULT | PTE_UXN | PTE_DIRTY | PTE_WRITE | PTE_CONT)
8787
@@ -153,6 +153,7 @@ extern struct page *empty_zero_page; · 65 unmodified lines
153153 #define pte_write(pte) (!!(pte_val(pte) & PTE_WRITE))
154154 #define pte_exec(pte) (!(pte_val(pte) & PTE_UXN))
155155 #define pte_cont(pte) (!!(pte_val(pte) & PTE_CONT))
156+#define pte_user(pte) (!!(pte_val(pte) & PTE_USER))
156157
157158 #ifdef CONFIG_ARM64_HW_AFDBM
158159 #define pte_hw_dirty(pte) (pte_write(pte) && !(pte_val(pte) & PTE_RDONLY))
@@ -163,8 +164,6 @@ extern struct page *empty_zero_page; · 4 unmodified lines
163164 #define pte_dirty(pte) (pte_sw_dirty(pte) || pte_hw_dirty(pte))
164165
165166 #define pte_valid(pte) (!!(pte_val(pte) & PTE_VALID))
166−#define pte_valid_user(pte) \
167− ((pte_val(pte) & (PTE_VALID | PTE_USER)) == (PTE_VALID | PTE_USER))
168167 #define pte_valid_not_user(pte) \
169168 ((pte_val(pte) & (PTE_VALID | PTE_USER)) == PTE_VALID)
170169 #define pte_valid_young(pte) \
@@ -278,13 +277,13 @@ extern void __sync_icache_dcache(pte_t pteval, unsigned long addr); · 107 unmodified lines
278277 static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
279278 pte_t *ptep, pte_t pte)
280279 {
281− if (pte_valid_user(pte)) {
282− if (!pte_special(pte) && pte_exec(pte))
283− __sync_icache_dcache(pte, addr);
280+ if (pte_valid(pte)) {
284281 if (pte_sw_dirty(pte) && pte_write(pte))
285282 pte_val(pte) &= ~PTE_RDONLY;
286283 else
287284 pte_val(pte) |= PTE_RDONLY;
285+ if (pte_user(pte) && pte_exec(pte) && !pte_special(pte))
286+ __sync_icache_dcache(pte, addr);
288287 }
289288
290289 /*
arch/arm64/kernel/head.S+5−0
@@ -514,9 +514,14 @@ CPU_LE( movk x0, #0x30d0, lsl #16 ) // Clear EE and E0E on LE systems · 513 unmodified lines
514514 #endif
515515
516516 /* EL2 debug */
517+ mrs x0, id_aa64dfr0_el1 // Check ID_AA64DFR0_EL1 PMUVer
518+ sbfx x0, x0, #8, #4
519+ cmp x0, #1
520+ b.lt 4f // Skip if no PMU present
517521 mrs x0, pmcr_el0 // Disable debug access traps
518522 ubfx x0, x0, #11, #5 // to EL2 and allow access to
519523 msr mdcr_el2, x0 // all PMU counters from EL1
524+4:
520525
521526 /* Stage-2 translation */
522527 msr vttbr_el2, xzr
arch/arm64/kernel/image.h+25−15
@@ -64,6 +64,16 @@ · 63 unmodified lines
6464
6565 #ifdef CONFIG_EFI
6666
67+/*
68+ * Prevent the symbol aliases below from being emitted into the kallsyms
69+ * table, by forcing them to be absolute symbols (which are conveniently
70+ * ignored by scripts/kallsyms) rather than section relative symbols.
71+ * The distinction is only relevant for partial linking, and only for symbols
72+ * that are defined within a section declaration (which is not the case for
73+ * the definitions below) so the resulting values will be identical.
74+ */
75+#define KALLSYMS_HIDE(sym) ABSOLUTE(sym)
76+
6777 /*
6878 * The EFI stub has its own symbol namespace prefixed by __efistub_, to
6979 * isolate it from the kernel proper. The following symbols are legally
@@ -73,25 +83,25 @@ · 3 unmodified lines
7383 * linked at. The routines below are all implemented in assembler in a
7484 * position independent manner
7585 */
76−__efistub_memcmp = __pi_memcmp;
77−__efistub_memchr = __pi_memchr;
78−__efistub_memcpy = __pi_memcpy;
79−__efistub_memmove = __pi_memmove;
80−__efistub_memset = __pi_memset;
81−__efistub_strlen = __pi_strlen;
82−__efistub_strcmp = __pi_strcmp;
83−__efistub_strncmp = __pi_strncmp;
84−__efistub___flush_dcache_area = __pi___flush_dcache_area;
86+__efistub_memcmp = KALLSYMS_HIDE(__pi_memcmp);
87+__efistub_memchr = KALLSYMS_HIDE(__pi_memchr);
88+__efistub_memcpy = KALLSYMS_HIDE(__pi_memcpy);
89+__efistub_memmove = KALLSYMS_HIDE(__pi_memmove);
90+__efistub_memset = KALLSYMS_HIDE(__pi_memset);
91+__efistub_strlen = KALLSYMS_HIDE(__pi_strlen);
92+__efistub_strcmp = KALLSYMS_HIDE(__pi_strcmp);
93+__efistub_strncmp = KALLSYMS_HIDE(__pi_strncmp);
94+__efistub___flush_dcache_area = KALLSYMS_HIDE(__pi___flush_dcache_area);
8595
8696 #ifdef CONFIG_KASAN
87−__efistub___memcpy = __pi_memcpy;
88−__efistub___memmove = __pi_memmove;
89−__efistub___memset = __pi_memset;
97+__efistub___memcpy = KALLSYMS_HIDE(__pi_memcpy);
98+__efistub___memmove = KALLSYMS_HIDE(__pi_memmove);
99+__efistub___memset = KALLSYMS_HIDE(__pi_memset);
90100 #endif
91101
92−__efistub__text = _text;
93−__efistub__end = _end;
94−__efistub__edata = _edata;
102+__efistub__text = KALLSYMS_HIDE(_text);
103+__efistub__end = KALLSYMS_HIDE(_end);
104+__efistub__edata = KALLSYMS_HIDE(_edata);
95105
96106 #endif
97107
arch/arm64/mm/dump.c+1−1
@@ -46,7 +46,7 @@ enum address_markers_idx { · 45 unmodified lines
4646 PCI_START_NR,
4747 PCI_END_NR,
4848 MODULES_START_NR,
49− MODUELS_END_NR,
49+ MODULES_END_NR,
5050 KERNEL_SPACE_NR,
5151 };
5252
arch/arm64/mm/kasan_init.c+9−0
@@ -120,6 +120,7 @@ static void __init cpu_set_ttbr1(unsigned long ttbr1) · 119 unmodified lines
120120 void __init kasan_init(void)
121121 {
122122 struct memblock_region *reg;
123+ int i;
123124
124125 /*
125126 * We are going to perform proper setup of shadow memory.
@@ -155,6 +156,14 @@ void __init kasan_init(void) · 29 unmodified lines
155156 pfn_to_nid(virt_to_pfn(start)));
156157 }
157158
159+ /*
160+ * KAsan may reuse the contents of kasan_zero_pte directly, so we
161+ * should make sure that it maps the zero page read-only.
162+ */
163+ for (i = 0; i < PTRS_PER_PTE; i++)
164+ set_pte(&kasan_zero_pte[i],
165+ pfn_pte(virt_to_pfn(kasan_zero_page), PAGE_KERNEL_RO));
166+
158167 memset(kasan_zero_page, 0, PAGE_SIZE);
159168 cpu_set_ttbr1(__pa(swapper_pg_dir));
160169 flush_tlb_all();
arch/arm64/mm/pageattr.c+3−0
@@ -57,6 +57,9 @@ static int change_memory_common(unsigned long addr, int numpages, · 56 unmodified lines
5757 if (end < MODULES_VADDR || end >= MODULES_END)
5858 return -EINVAL;
5959
60+ if (!numpages)
61+ return 0;
62+
6063 data.set_mask = set_mask;
6164 data.clear_mask = clear_mask;
6265
arch/arm64/mm/proc-macros.S+12−0
@@ -84,3 +84,15 @@ · 83 unmodified lines
8484 b.lo 9998b
8585 dsb \domain
8686 .endm
87+
88+/*
89+ * reset_pmuserenr_el0 - reset PMUSERENR_EL0 if PMUv3 present
90+ */
91+ .macro reset_pmuserenr_el0, tmpreg
92+ mrs \tmpreg, id_aa64dfr0_el1 // Check ID_AA64DFR0_EL1 PMUVer
93+ sbfx \tmpreg, \tmpreg, #8, #4
94+ cmp \tmpreg, #1 // Skip if no PMU present
95+ b.lt 9000f
96+ msr pmuserenr_el0, xzr // Disable PMU access from EL0
97+9000:
98+ .endm
arch/arm64/mm/proc.S+2−2
@@ -117,7 +117,7 @@ ENTRY(cpu_do_resume) · 116 unmodified lines
117117 */
118118 ubfx x11, x11, #1, #1
119119 msr oslar_el1, x11
120− msr pmuserenr_el0, xzr // Disable PMU access from EL0
120+ reset_pmuserenr_el0 x0 // Disable PMU access from EL0
121121 mov x0, x12
122122 dsb nsh // Make sure local tlb invalidation completed
123123 isb
@@ -154,7 +154,7 @@ ENTRY(__cpu_setup) · 30 unmodified lines
154154 msr cpacr_el1, x0 // Enable FP/ASIMD
155155 mov x0, #1 << 12 // Reset mdscr_el1 and disable
156156 msr mdscr_el1, x0 // access to the DCC from EL0
157− msr pmuserenr_el0, xzr // Disable PMU access from EL0
157+ reset_pmuserenr_el0 x0 // Disable PMU access from EL0
158158 /*
159159 * Memory region attributes for LPAE:
160160 *
arch/mips/bcm63xx/nvram.c+11−0
@@ -19,6 +19,8 @@ · 18 unmodified lines
1919
2020 #include <bcm63xx_nvram.h>
2121
22+#define BCM63XX_DEFAULT_PSI_SIZE 64
23+
2224 static struct bcm963xx_nvram nvram;
2325 static int mac_addr_used;
2426
@@ -85,3 +87,12 @@ int bcm63xx_nvram_get_mac_address(u8 *mac) · 60 unmodified lines
8587 return 0;
8688 }
8789 EXPORT_SYMBOL(bcm63xx_nvram_get_mac_address);
90+
91+int bcm63xx_nvram_get_psi_size(void)
92+{
93+ if (nvram.psi_size > 0)
94+ return nvram.psi_size;
95+
96+ return BCM63XX_DEFAULT_PSI_SIZE;
97+}
98+EXPORT_SYMBOL(bcm63xx_nvram_get_psi_size);
arch/mips/include/asm/mach-bcm63xx/bcm63xx_nvram.h+2−0
@@ -30,4 +30,6 @@ u8 *bcm63xx_nvram_get_name(void); · 29 unmodified lines
3030 */
3131 int bcm63xx_nvram_get_mac_address(u8 *mac);
3232
33+int bcm63xx_nvram_get_psi_size(void);
34+
3335 #endif /* BCM63XX_NVRAM_H */
arch/powerpc/include/asm/book3s/64/hash.h+3−1
@@ -50,7 +50,9 @@ · 49 unmodified lines
5050 * set of bits not changed in pmd_modify.
5151 */
5252 #define _HPAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \
53− _PAGE_ACCESSED | _PAGE_THP_HUGE)
53+ _PAGE_ACCESSED | _PAGE_THP_HUGE | _PAGE_PTE | \
54+ _PAGE_SOFT_DIRTY)
55+
5456
5557 #ifdef CONFIG_PPC_64K_PAGES
5658 #include <asm/book3s/64/hash-64k.h>
arch/powerpc/include/asm/book3s/64/pgtable.h+0−1
@@ -223,7 +223,6 @@ static inline pte_t *pmdp_ptep(pmd_t *pmd) · 222 unmodified lines
223223 #define pmd_pfn(pmd) pte_pfn(pmd_pte(pmd))
224224 #define pmd_dirty(pmd) pte_dirty(pmd_pte(pmd))
225225 #define pmd_young(pmd) pte_young(pmd_pte(pmd))
226−#define pmd_dirty(pmd) pte_dirty(pmd_pte(pmd))
227226 #define pmd_mkold(pmd) pte_pmd(pte_mkold(pmd_pte(pmd)))
228227 #define pmd_wrprotect(pmd) pte_pmd(pte_wrprotect(pmd_pte(pmd)))
229228 #define pmd_mkdirty(pmd) pte_pmd(pte_mkdirty(pmd_pte(pmd)))
arch/powerpc/include/asm/kvm_host.h+1−2
@@ -38,8 +38,7 @@ · 37 unmodified lines
3838
3939 #define KVM_MAX_VCPUS NR_CPUS
4040 #define KVM_MAX_VCORES NR_CPUS
41−#define KVM_USER_MEM_SLOTS 32
42−#define KVM_MEM_SLOTS_NUM KVM_USER_MEM_SLOTS
41+#define KVM_USER_MEM_SLOTS 512
4342
4443 #ifdef CONFIG_KVM_MMIO
4544 #define KVM_COALESCED_MMIO_PAGE_OFFSET 1
arch/powerpc/include/asm/systbl.h+1−0
@@ -383,3 +383,4 @@ SYSCALL(ni_syscall) · 382 unmodified lines
383383 SYSCALL(ni_syscall)
384384 SYSCALL(ni_syscall)
385385 SYSCALL(mlock2)
386+SYSCALL(copy_file_range)
arch/powerpc/include/asm/unistd.h+1−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
1212 #include <uapi/asm/unistd.h>
1313
1414
15−#define NR_syscalls 379
15+#define NR_syscalls 380
1616
1717 #define __NR__exit __NR_exit
1818
arch/powerpc/include/uapi/asm/unistd.h+1−0
@@ -389,5 +389,6 @@ · 388 unmodified lines
389389 #define __NR_userfaultfd 364
390390 #define __NR_membarrier 365
391391 #define __NR_mlock2 378
392+#define __NR_copy_file_range 379
392393
393394 #endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */
arch/powerpc/kernel/eeh_pe.c+15−18
@@ -883,32 +883,29 @@ void eeh_pe_restore_bars(struct eeh_pe *pe) · 882 unmodified lines
883883 const char *eeh_pe_loc_get(struct eeh_pe *pe)
884884 {
885885 struct pci_bus *bus = eeh_pe_bus_get(pe);
886− struct device_node *dn = pci_bus_to_OF_node(bus);
886+ struct device_node *dn;
887887 const char *loc = NULL;
888888
889− if (!dn)
890− goto out;
889+ while (bus) {
890+ dn = pci_bus_to_OF_node(bus);
891+ if (!dn) {
892+ bus = bus->parent;
893+ continue;
894+ }
891895
892− /* PHB PE or root PE ? */
893− if (pci_is_root_bus(bus)) {
894− loc = of_get_property(dn, "ibm,loc-code", NULL);
895− if (!loc)
896+ if (pci_is_root_bus(bus))
896897 loc = of_get_property(dn, "ibm,io-base-loc-code", NULL);
898+ else
899+ loc = of_get_property(dn, "ibm,slot-location-code",
900+ NULL);
901+
897902 if (loc)
898− goto out;
903+ return loc;
899904
900− /* Check the root port */
901− dn = dn->child;
902− if (!dn)
903− goto out;
905+ bus = bus->parent;
904906 }
905907
906− loc = of_get_property(dn, "ibm,loc-code", NULL);
907− if (!loc)
908− loc = of_get_property(dn, "ibm,slot-location-code", NULL);
909−
910−out:
911− return loc ? loc : "N/A";
908+ return "N/A";
912909 }
913910
914911 /**
arch/powerpc/kernel/misc_64.S+0−28
@@ -701,31 +701,3 @@ _GLOBAL(kexec_sequence) · 700 unmodified lines
701701 li r5,0
702702 blr /* image->start(physid, image->start, 0); */
703703 #endif /* CONFIG_KEXEC */
704−
705−#ifdef CONFIG_MODULES
706−#if defined(_CALL_ELF) && _CALL_ELF == 2
707−
708−#ifdef CONFIG_MODVERSIONS
709−.weak __crc_TOC.
710−.section "___kcrctab+TOC.","a"
711−.globl __kcrctab_TOC.
712−__kcrctab_TOC.:
713− .llong __crc_TOC.
714−#endif
715−
716−/*
717− * Export a fake .TOC. since both modpost and depmod will complain otherwise.
718− * Both modpost and depmod strip the leading . so we do the same here.
719− */
720−.section "__ksymtab_strings","a"
721−__kstrtab_TOC.:
722− .asciz "TOC."
723−
724−.section "___ksymtab+TOC.","a"
725−/* This symbol name is important: it's used by modpost to find exported syms */
726−.globl __ksymtab_TOC.
727−__ksymtab_TOC.:
728− .llong 0 /* .value */
729− .llong __kstrtab_TOC.
730−#endif /* ELFv2 */
731−#endif /* MODULES */
arch/powerpc/kernel/module_64.c+9−3
@@ -326,7 +326,10 @@ static void dedotify_versions(struct modversion_info *vers, · 325 unmodified lines
326326 }
327327 }
328328
329−/* Undefined symbols which refer to .funcname, hack to funcname (or .TOC.) */
329+/*
330+ * Undefined symbols which refer to .funcname, hack to funcname. Make .TOC.
331+ * seem to be defined (value set later).
332+ */
330333 static void dedotify(Elf64_Sym *syms, unsigned int numsyms, char *strtab)
331334 {
332335 unsigned int i;
@@ -334,8 +337,11 @@ static void dedotify(Elf64_Sym *syms, unsigned int numsyms, char *strtab) · 1 unmodified line
334337 for (i = 1; i < numsyms; i++) {
335338 if (syms[i].st_shndx == SHN_UNDEF) {
336339 char *name = strtab + syms[i].st_name;
337− if (name[0] == '.')
340+ if (name[0] == '.') {
341+ if (strcmp(name+1, "TOC.") == 0)
342+ syms[i].st_shndx = SHN_ABS;
338343 memmove(name, name+1, strlen(name));
344+ }
339345 }
340346 }
341347 }
@@ -351,7 +357,7 @@ static Elf64_Sym *find_dot_toc(Elf64_Shdr *sechdrs, · 9 unmodified lines
351357 numsyms = sechdrs[symindex].sh_size / sizeof(Elf64_Sym);
352358
353359 for (i = 1; i < numsyms; i++) {
354− if (syms[i].st_shndx == SHN_UNDEF
360+ if (syms[i].st_shndx == SHN_ABS
355361 && strcmp(strtab + syms[i].st_name, "TOC.") == 0)
356362 return &syms[i];
357363 }
arch/powerpc/kvm/book3s_64_mmu.c+0−3
@@ -377,15 +377,12 @@ no_seg_found: · 376 unmodified lines
377377
378378 static void kvmppc_mmu_book3s_64_slbmte(struct kvm_vcpu *vcpu, u64 rs, u64 rb)
379379 {
380− struct kvmppc_vcpu_book3s *vcpu_book3s;
381380 u64 esid, esid_1t;
382381 int slb_nr;
383382 struct kvmppc_slb *slbe;
384383
385384 dprintk("KVM MMU: slbmte(0x%llx, 0x%llx)\n", rs, rb);
386385
387− vcpu_book3s = to_book3s(vcpu);
388−
389386 esid = GET_ESID(rb);
390387 esid_1t = GET_ESID_1T(rb);
391388 slb_nr = rb & 0xfff;
arch/powerpc/kvm/book3s_hv.c+18−0
@@ -833,6 +833,24 @@ static int kvmppc_handle_exit_hv(struct kvm_run *run, struct kvm_vcpu *vcpu, · 832 unmodified lines
833833
834834 vcpu->stat.sum_exits++;
835835
836+ /*
837+ * This can happen if an interrupt occurs in the last stages
838+ * of guest entry or the first stages of guest exit (i.e. after
839+ * setting paca->kvm_hstate.in_guest to KVM_GUEST_MODE_GUEST_HV
840+ * and before setting it to KVM_GUEST_MODE_HOST_HV).
841+ * That can happen due to a bug, or due to a machine check
842+ * occurring at just the wrong time.
843+ */
844+ if (vcpu->arch.shregs.msr & MSR_HV) {
845+ printk(KERN_EMERG "KVM trap in HV mode!\n");
846+ printk(KERN_EMERG "trap=0x%x | pc=0x%lx | msr=0x%llx\n",
847+ vcpu->arch.trap, kvmppc_get_pc(vcpu),
848+ vcpu->arch.shregs.msr);
849+ kvmppc_dump_regs(vcpu);
850+ run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
851+ run->hw.hardware_exit_reason = vcpu->arch.trap;
852+ return RESUME_HOST;
853+ }
836854 run->exit_reason = KVM_EXIT_UNKNOWN;
837855 run->ready_for_interrupt_injection = 1;
838856 switch (vcpu->arch.trap) {
arch/powerpc/kvm/book3s_hv_rmhandlers.S+3−1
@@ -2153,7 +2153,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) · 2152 unmodified lines
21532153
21542154 /* Emulate H_SET_DABR/X on P8 for the sake of compat mode guests */
21552155 2: rlwimi r5, r4, 5, DAWRX_DR | DAWRX_DW
2156− rlwimi r5, r4, 1, DAWRX_WT
2156+ rlwimi r5, r4, 2, DAWRX_WT
21572157 clrrdi r4, r4, 3
21582158 std r4, VCPU_DAWR(r3)
21592159 std r5, VCPU_DAWRX(r3)
@@ -2404,6 +2404,8 @@ machine_check_realmode: · 244 unmodified lines
24042404 * guest as machine check causing guest to crash.
24052405 */
24062406 ld r11, VCPU_MSR(r9)
2407+ rldicl. r0, r11, 64-MSR_HV_LG, 63 /* check if it happened in HV mode */
2408+ bne mc_cont /* if so, exit to host */
24072409 andi. r10, r11, MSR_RI /* check for unrecoverable exception */
24082410 beq 1f /* Deliver a machine check to guest */
24092411 ld r10, VCPU_PC(r9)
arch/powerpc/kvm/powerpc.c+10−10
@@ -919,21 +919,17 @@ int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) · 918 unmodified lines
919919 r = -ENXIO;
920920 break;
921921 }
922− vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0] = val.vval;
922+ val.vval = vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0];
923923 break;
924924 case KVM_REG_PPC_VSCR:
925925 if (!cpu_has_feature(CPU_FTR_ALTIVEC)) {
926926 r = -ENXIO;
927927 break;
928928 }
929− vcpu->arch.vr.vscr.u[3] = set_reg_val(reg->id, val);
929+ val = get_reg_val(reg->id, vcpu->arch.vr.vscr.u[3]);
930930 break;
931931 case KVM_REG_PPC_VRSAVE:
932− if (!cpu_has_feature(CPU_FTR_ALTIVEC)) {
933− r = -ENXIO;
934− break;
935− }
936− vcpu->arch.vrsave = set_reg_val(reg->id, val);
932+ val = get_reg_val(reg->id, vcpu->arch.vrsave);
937933 break;
938934 #endif /* CONFIG_ALTIVEC */
939935 default:
@@ -974,17 +970,21 @@ int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg) · 34 unmodified lines
974970 r = -ENXIO;
975971 break;
976972 }
977− val.vval = vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0];
973+ vcpu->arch.vr.vr[reg->id - KVM_REG_PPC_VR0] = val.vval;
978974 break;
979975 case KVM_REG_PPC_VSCR:
980976 if (!cpu_has_feature(CPU_FTR_ALTIVEC)) {
981977 r = -ENXIO;
982978 break;
983979 }
984− val = get_reg_val(reg->id, vcpu->arch.vr.vscr.u[3]);
980+ vcpu->arch.vr.vscr.u[3] = set_reg_val(reg->id, val);
985981 break;
986982 case KVM_REG_PPC_VRSAVE:
987− val = get_reg_val(reg->id, vcpu->arch.vrsave);
983+ if (!cpu_has_feature(CPU_FTR_ALTIVEC)) {
984+ r = -ENXIO;
985+ break;
986+ }
987+ vcpu->arch.vrsave = set_reg_val(reg->id, val);
988988 break;
989989 #endif /* CONFIG_ALTIVEC */
990990 default:
arch/powerpc/mm/mem.c+2−2
@@ -560,12 +560,12 @@ subsys_initcall(add_system_ram_resources); · 559 unmodified lines
560560 */
561561 int devmem_is_allowed(unsigned long pfn)
562562 {
563+ if (page_is_rtas_user_buf(pfn))
564+ return 1;
563565 if (iomem_is_exclusive(PFN_PHYS(pfn)))
564566 return 0;
565567 if (!page_is_ram(pfn))
566568 return 1;
567− if (page_is_rtas_user_buf(pfn))
568− return 1;
569569 return 0;
570570 }
571571 #endif /* CONFIG_STRICT_DEVMEM */
arch/powerpc/perf/power8-pmu.c+1−1
@@ -816,7 +816,7 @@ static struct power_pmu power8_pmu = { · 815 unmodified lines
816816 .get_constraint = power8_get_constraint,
817817 .get_alternatives = power8_get_alternatives,
818818 .disable_pmc = power8_disable_pmc,
819− .flags = PPMU_HAS_SSLOT | PPMU_HAS_SIER | PPMU_ARCH_207S,
819+ .flags = PPMU_HAS_SIER | PPMU_ARCH_207S,
820820 .n_generic = ARRAY_SIZE(power8_generic_events),
821821 .generic_events = power8_generic_events,
822822 .cache_events = &power8_cache_events,
arch/s390/include/asm/irqflags.h+7−2
@@ -8,6 +8,8 @@ · 7 unmodified lines
88
99 #include <linux/types.h>
1010
11+#define ARCH_IRQ_ENABLED (3UL << (BITS_PER_LONG - 8))
12+
1113 /* store then OR system mask. */
1214 #define __arch_local_irq_stosm(__or) \
1315 ({ \
@@ -54,14 +56,17 @@ static inline notrace void arch_local_irq_enable(void) · 40 unmodified lines
5456 __arch_local_irq_stosm(0x03);
5557 }
5658
59+/* This only restores external and I/O interrupt state */
5760 static inline notrace void arch_local_irq_restore(unsigned long flags)
5861 {
59− __arch_local_irq_ssm(flags);
62+ /* only disabled->disabled and disabled->enabled is valid */
63+ if (flags & ARCH_IRQ_ENABLED)
64+ arch_local_irq_enable();
6065 }
6166
6267 static inline notrace bool arch_irqs_disabled_flags(unsigned long flags)
6368 {
64− return !(flags & (3UL << (BITS_PER_LONG - 8)));
69+ return !(flags & ARCH_IRQ_ENABLED);
6570 }
6671
6772 static inline notrace bool arch_irqs_disabled(void)
arch/s390/include/asm/kvm_host.h+0−1
@@ -546,7 +546,6 @@ struct kvm_vcpu_arch { · 545 unmodified lines
546546 struct kvm_s390_sie_block *sie_block;
547547 unsigned int host_acrs[NUM_ACRS];
548548 struct fpu host_fpregs;
549− struct fpu guest_fpregs;
550549 struct kvm_s390_local_interrupt local_int;
551550 struct hrtimer ckc_timer;
552551 struct kvm_s390_pgm_info pgm;
arch/s390/include/asm/pci_io.h+9−5
@@ -8,10 +8,13 @@ · 7 unmodified lines
88 #include <asm/pci_insn.h>
99
1010 /* I/O Map */
11−#define ZPCI_IOMAP_MAX_ENTRIES 0x7fff
12−#define ZPCI_IOMAP_ADDR_BASE 0x8000000000000000ULL
13−#define ZPCI_IOMAP_ADDR_IDX_MASK 0x7fff000000000000ULL
14−#define ZPCI_IOMAP_ADDR_OFF_MASK 0x0000ffffffffffffULL
11+#define ZPCI_IOMAP_SHIFT 48
12+#define ZPCI_IOMAP_ADDR_BASE 0x8000000000000000UL
13+#define ZPCI_IOMAP_ADDR_OFF_MASK ((1UL << ZPCI_IOMAP_SHIFT) - 1)
14+#define ZPCI_IOMAP_MAX_ENTRIES \
15+ ((ULONG_MAX - ZPCI_IOMAP_ADDR_BASE + 1) / (1UL << ZPCI_IOMAP_SHIFT))
16+#define ZPCI_IOMAP_ADDR_IDX_MASK \
17+ (~ZPCI_IOMAP_ADDR_OFF_MASK - ZPCI_IOMAP_ADDR_BASE)
1518
1619 struct zpci_iomap_entry {
1720 u32 fh;
@@ -21,8 +24,9 @@ struct zpci_iomap_entry { · 3 unmodified lines
2124
2225 extern struct zpci_iomap_entry *zpci_iomap_start;
2326
27+#define ZPCI_ADDR(idx) (ZPCI_IOMAP_ADDR_BASE | ((u64) idx << ZPCI_IOMAP_SHIFT))
2428 #define ZPCI_IDX(addr) \
25− (((__force u64) addr & ZPCI_IOMAP_ADDR_IDX_MASK) >> 48)
29+ (((__force u64) addr & ZPCI_IOMAP_ADDR_IDX_MASK) >> ZPCI_IOMAP_SHIFT)
2630 #define ZPCI_OFFSET(addr) \
2731 ((__force u64) addr & ZPCI_IOMAP_ADDR_OFF_MASK)
2832
arch/s390/include/asm/processor.h+2−2
@@ -166,14 +166,14 @@ extern __vector128 init_task_fpu_regs[__NUM_VXRS]; · 165 unmodified lines
166166 */
167167 #define start_thread(regs, new_psw, new_stackp) do { \
168168 regs->psw.mask = PSW_USER_BITS | PSW_MASK_EA | PSW_MASK_BA; \
169− regs->psw.addr = new_psw | PSW_ADDR_AMODE; \
169+ regs->psw.addr = new_psw; \
170170 regs->gprs[15] = new_stackp; \
171171 execve_tail(); \
172172 } while (0)
173173
174174 #define start_thread31(regs, new_psw, new_stackp) do { \
175175 regs->psw.mask = PSW_USER_BITS | PSW_MASK_BA; \
176− regs->psw.addr = new_psw | PSW_ADDR_AMODE; \
176+ regs->psw.addr = new_psw; \
177177 regs->gprs[15] = new_stackp; \
178178 crst_table_downgrade(current->mm, 1UL << 31); \
179179 execve_tail(); \
arch/s390/include/asm/ptrace.h+3−3
@@ -149,7 +149,7 @@ static inline int test_pt_regs_flag(struct pt_regs *regs, int flag) · 148 unmodified lines
149149 #define arch_has_block_step() (1)
150150
151151 #define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0)
152−#define instruction_pointer(regs) ((regs)->psw.addr & PSW_ADDR_INSN)
152+#define instruction_pointer(regs) ((regs)->psw.addr)
153153 #define user_stack_pointer(regs)((regs)->gprs[15])
154154 #define profile_pc(regs) instruction_pointer(regs)
155155
@@ -161,7 +161,7 @@ static inline long regs_return_value(struct pt_regs *regs) · 5 unmodified lines
161161 static inline void instruction_pointer_set(struct pt_regs *regs,
162162 unsigned long val)
163163 {
164− regs->psw.addr = val | PSW_ADDR_AMODE;
164+ regs->psw.addr = val;
165165 }
166166
167167 int regs_query_register_offset(const char *name);
@@ -171,7 +171,7 @@ unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n); · 3 unmodified lines
171171
172172 static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
173173 {
174− return regs->gprs[15] & PSW_ADDR_INSN;
174+ return regs->gprs[15];
175175 }
176176
177177 #endif /* __ASSEMBLY__ */
arch/s390/include/uapi/asm/unistd.h+2−1
@@ -310,7 +310,8 @@ · 309 unmodified lines
310310 #define __NR_recvmsg 372
311311 #define __NR_shutdown 373
312312 #define __NR_mlock2 374
313−#define NR_syscalls 375
313+#define __NR_copy_file_range 375
314+#define NR_syscalls 376
314315
315316 /*
316317 * There are some system calls that are not present on 64 bit, some
arch/s390/kernel/compat_wrapper.c+1−0
@@ -177,3 +177,4 @@ COMPAT_SYSCALL_WRAP3(getsockname, int, fd, struct sockaddr __user *, usockaddr, · 176 unmodified lines
177177 COMPAT_SYSCALL_WRAP3(getpeername, int, fd, struct sockaddr __user *, usockaddr, int __user *, usockaddr_len);
178178 COMPAT_SYSCALL_WRAP6(sendto, int, fd, void __user *, buff, size_t, len, unsigned int, flags, struct sockaddr __user *, addr, int, addr_len);
179179 COMPAT_SYSCALL_WRAP3(mlock2, unsigned long, start, size_t, len, int, flags);
180+COMPAT_SYSCALL_WRAP6(copy_file_range, int, fd_in, loff_t __user *, off_in, int, fd_out, loff_t __user *, off_out, size_t, len, unsigned int, flags);
arch/s390/kernel/crash_dump.c+0−2
@@ -59,8 +59,6 @@ struct save_area * __init save_area_alloc(bool is_boot_cpu) · 58 unmodified lines
5959 struct save_area *sa;
6060
6161 sa = (void *) memblock_alloc(sizeof(*sa), 8);
62− if (!sa)
63− return NULL;
6462 if (is_boot_cpu)
6563 list_add(&sa->list, &dump_save_areas);
6664 else
arch/s390/kernel/debug.c+1−1
@@ -1470,7 +1470,7 @@ debug_dflt_header_fn(debug_info_t * id, struct debug_view *view, · 1469 unmodified lines
14701470 except_str = "*";
14711471 else
14721472 except_str = "-";
1473− caller = ((unsigned long) entry->caller) & PSW_ADDR_INSN;
1473+ caller = (unsigned long) entry->caller;
14741474 rc += sprintf(out_buf, "%02i %011lld:%06lu %1u %1s %02i %p ",
14751475 area, (long long)time_spec.tv_sec,
14761476 time_spec.tv_nsec / 1000, level, except_str,
arch/s390/kernel/dumpstack.c+4−5
@@ -34,22 +34,21 @@ __show_trace(unsigned long sp, unsigned long low, unsigned long high) · 33 unmodified lines
3434 unsigned long addr;
3535
3636 while (1) {
37− sp = sp & PSW_ADDR_INSN;
3837 if (sp < low || sp > high - sizeof(*sf))
3938 return sp;
4039 sf = (struct stack_frame *) sp;
41− addr = sf->gprs[8] & PSW_ADDR_INSN;
40+ addr = sf->gprs[8];
4241 printk("([<%016lx>] %pSR)\n", addr, (void *)addr);
4342 /* Follow the backchain. */
4443 while (1) {
4544 low = sp;
46− sp = sf->back_chain & PSW_ADDR_INSN;
45+ sp = sf->back_chain;
4746 if (!sp)
4847 break;
4948 if (sp <= low || sp > high - sizeof(*sf))
5049 return sp;
5150 sf = (struct stack_frame *) sp;
52− addr = sf->gprs[8] & PSW_ADDR_INSN;
51+ addr = sf->gprs[8];
5352 printk(" [<%016lx>] %pSR\n", addr, (void *)addr);
5453 }
5554 /* Zero backchain detected, check for interrupt frame. */
@@ -57,7 +56,7 @@ __show_trace(unsigned long sp, unsigned long low, unsigned long high) · 1 unmodified line
5756 if (sp <= low || sp > high - sizeof(*regs))
5857 return sp;
5958 regs = (struct pt_regs *) sp;
60− addr = regs->psw.addr & PSW_ADDR_INSN;
59+ addr = regs->psw.addr;
6160 printk(" [<%016lx>] %pSR\n", addr, (void *)addr);
6261 low = sp;
6362 sp = regs->gprs[15];
arch/s390/kernel/early.c+4−4
@@ -252,14 +252,14 @@ static void early_pgm_check_handler(void) · 251 unmodified lines
252252 unsigned long addr;
253253
254254 addr = S390_lowcore.program_old_psw.addr;
255− fixup = search_exception_tables(addr & PSW_ADDR_INSN);
255+ fixup = search_exception_tables(addr);
256256 if (!fixup)
257257 disabled_wait(0);
258258 /* Disable low address protection before storing into lowcore. */
259259 __ctl_store(cr0, 0, 0);
260260 cr0_new = cr0 & ~(1UL << 28);
261261 __ctl_load(cr0_new, 0, 0);
262− S390_lowcore.program_old_psw.addr = extable_fixup(fixup)|PSW_ADDR_AMODE;
262+ S390_lowcore.program_old_psw.addr = extable_fixup(fixup);
263263 __ctl_load(cr0, 0, 0);
264264 }
265265
@@ -268,9 +268,9 @@ static noinline __init void setup_lowcore_early(void) · 2 unmodified lines
268268 psw_t psw;
269269
270270 psw.mask = PSW_MASK_BASE | PSW_DEFAULT_KEY | PSW_MASK_EA | PSW_MASK_BA;
271− psw.addr = PSW_ADDR_AMODE | (unsigned long) s390_base_ext_handler;
271+ psw.addr = (unsigned long) s390_base_ext_handler;
272272 S390_lowcore.external_new_psw = psw;
273− psw.addr = PSW_ADDR_AMODE | (unsigned long) s390_base_pgm_handler;
273+ psw.addr = (unsigned long) s390_base_pgm_handler;
274274 S390_lowcore.program_new_psw = psw;
275275 s390_base_pgm_handler_fn = early_pgm_check_handler;
276276 }
arch/s390/kernel/ftrace.c+1−1
@@ -203,7 +203,7 @@ unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip) · 202 unmodified lines
203203 goto out;
204204 if (unlikely(atomic_read(&current->tracing_graph_pause)))
205205 goto out;
206− ip = (ip & PSW_ADDR_INSN) - MCOUNT_INSN_SIZE;
206+ ip -= MCOUNT_INSN_SIZE;
207207 trace.func = ip;
208208 trace.depth = current->curr_ret_stack + 1;
209209 /* Only trace if the calling function expects to. */
arch/s390/kernel/ipl.c+2−2
@@ -2057,12 +2057,12 @@ void s390_reset_system(void) · 2056 unmodified lines
20572057 /* Set new machine check handler */
20582058 S390_lowcore.mcck_new_psw.mask = PSW_KERNEL_BITS | PSW_MASK_DAT;
20592059 S390_lowcore.mcck_new_psw.addr =
2060− PSW_ADDR_AMODE | (unsigned long) s390_base_mcck_handler;
2060+ (unsigned long) s390_base_mcck_handler;
20612061
20622062 /* Set new program check handler */
20632063 S390_lowcore.program_new_psw.mask = PSW_KERNEL_BITS | PSW_MASK_DAT;
20642064 S390_lowcore.program_new_psw.addr =
2065− PSW_ADDR_AMODE | (unsigned long) s390_base_pgm_handler;
2065+ (unsigned long) s390_base_pgm_handler;
20662066
20672067 /*
20682068 * Clear subchannel ID and number to signal new kernel that no CCW or
arch/s390/kernel/kprobes.c+8−8
@@ -226,7 +226,7 @@ static void enable_singlestep(struct kprobe_ctlblk *kcb, · 225 unmodified lines
226226 __ctl_load(per_kprobe, 9, 11);
227227 regs->psw.mask |= PSW_MASK_PER;
228228 regs->psw.mask &= ~(PSW_MASK_IO | PSW_MASK_EXT);
229− regs->psw.addr = ip | PSW_ADDR_AMODE;
229+ regs->psw.addr = ip;
230230 }
231231 NOKPROBE_SYMBOL(enable_singlestep);
232232
@@ -238,7 +238,7 @@ static void disable_singlestep(struct kprobe_ctlblk *kcb, · 5 unmodified lines
238238 __ctl_load(kcb->kprobe_saved_ctl, 9, 11);
239239 regs->psw.mask &= ~PSW_MASK_PER;
240240 regs->psw.mask |= kcb->kprobe_saved_imask;
241− regs->psw.addr = ip | PSW_ADDR_AMODE;
241+ regs->psw.addr = ip;
242242 }
243243 NOKPROBE_SYMBOL(disable_singlestep);
244244
@@ -310,7 +310,7 @@ static int kprobe_handler(struct pt_regs *regs) · 65 unmodified lines
310310 */
311311 preempt_disable();
312312 kcb = get_kprobe_ctlblk();
313− p = get_kprobe((void *)((regs->psw.addr & PSW_ADDR_INSN) - 2));
313+ p = get_kprobe((void *)(regs->psw.addr - 2));
314314
315315 if (p) {
316316 if (kprobe_running()) {
@@ -460,7 +460,7 @@ static int trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs) · 143 unmodified lines
460460 break;
461461 }
462462
463− regs->psw.addr = orig_ret_address | PSW_ADDR_AMODE;
463+ regs->psw.addr = orig_ret_address;
464464
465465 pop_kprobe(get_kprobe_ctlblk());
466466 kretprobe_hash_unlock(current, &flags);
@@ -490,7 +490,7 @@ NOKPROBE_SYMBOL(trampoline_probe_handler); · 23 unmodified lines
490490 static void resume_execution(struct kprobe *p, struct pt_regs *regs)
491491 {
492492 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
493− unsigned long ip = regs->psw.addr & PSW_ADDR_INSN;
493+ unsigned long ip = regs->psw.addr;
494494 int fixup = probe_get_fixup_type(p->ainsn.insn);
495495
496496 /* Check if the kprobes location is an enabled ftrace caller */
@@ -605,9 +605,9 @@ static int kprobe_trap_handler(struct pt_regs *regs, int trapnr) · 108 unmodified lines
605605 * In case the user-specified fault handler returned
606606 * zero, try to fix up.
607607 */
608− entry = search_exception_tables(regs->psw.addr & PSW_ADDR_INSN);
608+ entry = search_exception_tables(regs->psw.addr);
609609 if (entry) {
610− regs->psw.addr = extable_fixup(entry) | PSW_ADDR_AMODE;
610+ regs->psw.addr = extable_fixup(entry);
611611 return 1;
612612 }
613613
@@ -683,7 +683,7 @@ int setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs) · 69 unmodified lines
683683 memcpy(&kcb->jprobe_saved_regs, regs, sizeof(struct pt_regs));
684684
685685 /* setup return addr to the jprobe handler routine */
686− regs->psw.addr = (unsigned long) jp->entry | PSW_ADDR_AMODE;
686+ regs->psw.addr = (unsigned long) jp->entry;
687687 regs->psw.mask &= ~(PSW_MASK_IO | PSW_MASK_EXT);
688688
689689 /* r15 is the stack pointer */
arch/s390/kernel/perf_event.c+5−7
@@ -74,7 +74,7 @@ static unsigned long guest_is_user_mode(struct pt_regs *regs) · 73 unmodified lines
7474
7575 static unsigned long instruction_pointer_guest(struct pt_regs *regs)
7676 {
77− return sie_block(regs)->gpsw.addr & PSW_ADDR_INSN;
77+ return sie_block(regs)->gpsw.addr;
7878 }
7979
8080 unsigned long perf_instruction_pointer(struct pt_regs *regs)
@@ -231,29 +231,27 @@ static unsigned long __store_trace(struct perf_callchain_entry *entry, · 150 unmodified lines
231231 struct pt_regs *regs;
232232
233233 while (1) {
234− sp = sp & PSW_ADDR_INSN;
235234 if (sp < low || sp > high - sizeof(*sf))
236235 return sp;
237236 sf = (struct stack_frame *) sp;
238− perf_callchain_store(entry, sf->gprs[8] & PSW_ADDR_INSN);
237+ perf_callchain_store(entry, sf->gprs[8]);
239238 /* Follow the backchain. */
240239 while (1) {
241240 low = sp;
242− sp = sf->back_chain & PSW_ADDR_INSN;
241+ sp = sf->back_chain;
243242 if (!sp)
244243 break;
245244 if (sp <= low || sp > high - sizeof(*sf))
246245 return sp;
247246 sf = (struct stack_frame *) sp;
248− perf_callchain_store(entry,
249− sf->gprs[8] & PSW_ADDR_INSN);
247+ perf_callchain_store(entry, sf->gprs[8]);
250248 }
251249 /* Zero backchain detected, check for interrupt frame. */
252250 sp = (unsigned long) (sf + 1);
253251 if (sp <= low || sp > high - sizeof(*regs))
254252 return sp;
255253 regs = (struct pt_regs *) sp;
256− perf_callchain_store(entry, sf->gprs[8] & PSW_ADDR_INSN);
254+ perf_callchain_store(entry, sf->gprs[8]);
257255 low = sp;
258256 sp = regs->gprs[15];
259257 }
arch/s390/kernel/process.c+6−6
@@ -56,10 +56,10 @@ unsigned long thread_saved_pc(struct task_struct *tsk) · 55 unmodified lines
5656 return 0;
5757 low = task_stack_page(tsk);
5858 high = (struct stack_frame *) task_pt_regs(tsk);
59− sf = (struct stack_frame *) (tsk->thread.ksp & PSW_ADDR_INSN);
59+ sf = (struct stack_frame *) tsk->thread.ksp;
6060 if (sf <= low || sf > high)
6161 return 0;
62− sf = (struct stack_frame *) (sf->back_chain & PSW_ADDR_INSN);
62+ sf = (struct stack_frame *) sf->back_chain;
6363 if (sf <= low || sf > high)
6464 return 0;
6565 return sf->gprs[8];
@@ -154,7 +154,7 @@ int copy_thread(unsigned long clone_flags, unsigned long new_stackp, · 88 unmodified lines
154154 memset(&frame->childregs, 0, sizeof(struct pt_regs));
155155 frame->childregs.psw.mask = PSW_KERNEL_BITS | PSW_MASK_DAT |
156156 PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK;
157− frame->childregs.psw.addr = PSW_ADDR_AMODE |
157+ frame->childregs.psw.addr =
158158 (unsigned long) kernel_thread_starter;
159159 frame->childregs.gprs[9] = new_stackp; /* function */
160160 frame->childregs.gprs[10] = arg;
@@ -220,14 +220,14 @@ unsigned long get_wchan(struct task_struct *p) · 59 unmodified lines
220220 return 0;
221221 low = task_stack_page(p);
222222 high = (struct stack_frame *) task_pt_regs(p);
223− sf = (struct stack_frame *) (p->thread.ksp & PSW_ADDR_INSN);
223+ sf = (struct stack_frame *) p->thread.ksp;
224224 if (sf <= low || sf > high)
225225 return 0;
226226 for (count = 0; count < 16; count++) {
227− sf = (struct stack_frame *) (sf->back_chain & PSW_ADDR_INSN);
227+ sf = (struct stack_frame *) sf->back_chain;
228228 if (sf <= low || sf > high)
229229 return 0;
230− return_address = sf->gprs[8] & PSW_ADDR_INSN;
230+ return_address = sf->gprs[8];
231231 if (!in_sched_functions(return_address))
232232 return return_address;
233233 }
arch/s390/kernel/ptrace.c+2−4
@@ -84,7 +84,7 @@ void update_cr_regs(struct task_struct *task) · 83 unmodified lines
8484 if (test_tsk_thread_flag(task, TIF_UPROBE_SINGLESTEP))
8585 new.control |= PER_EVENT_IFETCH;
8686 new.start = 0;
87− new.end = PSW_ADDR_INSN;
87+ new.end = -1UL;
8888 }
8989
9090 /* Take care of the PER enablement bit in the PSW. */
@@ -148,7 +148,7 @@ static inline unsigned long __peek_user_per(struct task_struct *child, · 57 unmodified lines
148148 else if (addr == (addr_t) &dummy->cr11)
149149 /* End address of the active per set. */
150150 return test_thread_flag(TIF_SINGLE_STEP) ?
151− PSW_ADDR_INSN : child->thread.per_user.end;
151+ -1UL : child->thread.per_user.end;
152152 else if (addr == (addr_t) &dummy->bits)
153153 /* Single-step bit. */
154154 return test_thread_flag(TIF_SINGLE_STEP) ?
@@ -495,8 +495,6 @@ long arch_ptrace(struct task_struct *child, long request, · 340 unmodified lines
495495 }
496496 return 0;
497497 default:
498− /* Removing high order bit from addr (only for 31 bit). */
499− addr &= PSW_ADDR_INSN;
500498 return ptrace_request(child, request, addr, data);
501499 }
502500 }
arch/s390/kernel/setup.c+6−10
@@ -301,25 +301,21 @@ static void __init setup_lowcore(void) · 300 unmodified lines
301301 BUILD_BUG_ON(sizeof(struct lowcore) != LC_PAGES * 4096);
302302 lc = __alloc_bootmem_low(LC_PAGES * PAGE_SIZE, LC_PAGES * PAGE_SIZE, 0);
303303 lc->restart_psw.mask = PSW_KERNEL_BITS;
304− lc->restart_psw.addr =
305− PSW_ADDR_AMODE | (unsigned long) restart_int_handler;
304+ lc->restart_psw.addr = (unsigned long) restart_int_handler;
306305 lc->external_new_psw.mask = PSW_KERNEL_BITS |
307306 PSW_MASK_DAT | PSW_MASK_MCHECK;
308− lc->external_new_psw.addr =
309− PSW_ADDR_AMODE | (unsigned long) ext_int_handler;
307+ lc->external_new_psw.addr = (unsigned long) ext_int_handler;
310308 lc->svc_new_psw.mask = PSW_KERNEL_BITS |
311309 PSW_MASK_DAT | PSW_MASK_IO | PSW_MASK_EXT | PSW_MASK_MCHECK;
312− lc->svc_new_psw.addr = PSW_ADDR_AMODE | (unsigned long) system_call;
310+ lc->svc_new_psw.addr = (unsigned long) system_call;
313311 lc->program_new_psw.mask = PSW_KERNEL_BITS |
314312 PSW_MASK_DAT | PSW_MASK_MCHECK;
315− lc->program_new_psw.addr =
316− PSW_ADDR_AMODE | (unsigned long) pgm_check_handler;
313+ lc->program_new_psw.addr = (unsigned long) pgm_check_handler;
317314 lc->mcck_new_psw.mask = PSW_KERNEL_BITS;
318− lc->mcck_new_psw.addr =
319− PSW_ADDR_AMODE | (unsigned long) mcck_int_handler;
315+ lc->mcck_new_psw.addr = (unsigned long) mcck_int_handler;
320316 lc->io_new_psw.mask = PSW_KERNEL_BITS |
321317 PSW_MASK_DAT | PSW_MASK_MCHECK;
322− lc->io_new_psw.addr = PSW_ADDR_AMODE | (unsigned long) io_int_handler;
318+ lc->io_new_psw.addr = (unsigned long) io_int_handler;
323319 lc->clock_comparator = -1ULL;
324320 lc->kernel_stack = ((unsigned long) &init_thread_union)
325321 + THREAD_SIZE - STACK_FRAME_OVERHEAD - sizeof(struct pt_regs);
arch/s390/kernel/signal.c+6−7
@@ -331,13 +331,13 @@ static int setup_frame(int sig, struct k_sigaction *ka, · 330 unmodified lines
331331 /* Set up to return from userspace. If provided, use a stub
332332 already in userspace. */
333333 if (ka->sa.sa_flags & SA_RESTORER) {
334− restorer = (unsigned long) ka->sa.sa_restorer | PSW_ADDR_AMODE;
334+ restorer = (unsigned long) ka->sa.sa_restorer;
335335 } else {
336336 /* Signal frame without vector registers are short ! */
337337 __u16 __user *svc = (void __user *) frame + frame_size - 2;
338338 if (__put_user(S390_SYSCALL_OPCODE | __NR_sigreturn, svc))
339339 return -EFAULT;
340− restorer = (unsigned long) svc | PSW_ADDR_AMODE;
340+ restorer = (unsigned long) svc;
341341 }
342342
343343 /* Set up registers for signal handler */
@@ -347,7 +347,7 @@ static int setup_frame(int sig, struct k_sigaction *ka, · 3 unmodified lines
347347 regs->psw.mask = PSW_MASK_EA | PSW_MASK_BA |
348348 (PSW_USER_BITS & PSW_MASK_ASC) |
349349 (regs->psw.mask & ~PSW_MASK_ASC);
350− regs->psw.addr = (unsigned long) ka->sa.sa_handler | PSW_ADDR_AMODE;
350+ regs->psw.addr = (unsigned long) ka->sa.sa_handler;
351351
352352 regs->gprs[2] = sig;
353353 regs->gprs[3] = (unsigned long) &frame->sc;
@@ -394,13 +394,12 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, · 40 unmodified lines
394394 /* Set up to return from userspace. If provided, use a stub
395395 already in userspace. */
396396 if (ksig->ka.sa.sa_flags & SA_RESTORER) {
397− restorer = (unsigned long)
398− ksig->ka.sa.sa_restorer | PSW_ADDR_AMODE;
397+ restorer = (unsigned long) ksig->ka.sa.sa_restorer;
399398 } else {
400399 __u16 __user *svc = &frame->svc_insn;
401400 if (__put_user(S390_SYSCALL_OPCODE | __NR_rt_sigreturn, svc))
402401 return -EFAULT;
403− restorer = (unsigned long) svc | PSW_ADDR_AMODE;
402+ restorer = (unsigned long) svc;
404403 }
405404
406405 /* Create siginfo on the signal stack */
@@ -426,7 +425,7 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, · 19 unmodified lines
426425 regs->psw.mask = PSW_MASK_EA | PSW_MASK_BA |
427426 (PSW_USER_BITS & PSW_MASK_ASC) |
428427 (regs->psw.mask & ~PSW_MASK_ASC);
429− regs->psw.addr = (unsigned long) ksig->ka.sa.sa_handler | PSW_ADDR_AMODE;
428+ regs->psw.addr = (unsigned long) ksig->ka.sa.sa_handler;
430429
431430 regs->gprs[2] = ksig->sig;
432431 regs->gprs[3] = (unsigned long) &frame->info;
arch/s390/kernel/smp.c+0−2
@@ -623,8 +623,6 @@ void __init smp_save_dump_cpus(void) · 622 unmodified lines
623623 return;
624624 /* Allocate a page as dumping area for the store status sigps */
625625 page = memblock_alloc_base(PAGE_SIZE, PAGE_SIZE, 1UL << 31);
626− if (!page)
627− panic("could not allocate memory for save area\n");
628626 /* Set multi-threading state to the previous system. */
629627 pcpu_set_smt(sclp.mtid_prev);
630628 boot_cpu_addr = stap();
arch/s390/kernel/stacktrace.c+5−6
@@ -21,12 +21,11 @@ static unsigned long save_context_stack(struct stack_trace *trace, · 20 unmodified lines
2121 unsigned long addr;
2222
2323 while(1) {
24− sp &= PSW_ADDR_INSN;
2524 if (sp < low || sp > high)
2625 return sp;
2726 sf = (struct stack_frame *)sp;
2827 while(1) {
29− addr = sf->gprs[8] & PSW_ADDR_INSN;
28+ addr = sf->gprs[8];
3029 if (!trace->skip)
3130 trace->entries[trace->nr_entries++] = addr;
3231 else
@@ -34,7 +33,7 @@ static unsigned long save_context_stack(struct stack_trace *trace, · 1 unmodified line
3433 if (trace->nr_entries >= trace->max_entries)
3534 return sp;
3635 low = sp;
37− sp = sf->back_chain & PSW_ADDR_INSN;
36+ sp = sf->back_chain;
3837 if (!sp)
3938 break;
4039 if (sp <= low || sp > high - sizeof(*sf))
@@ -46,7 +45,7 @@ static unsigned long save_context_stack(struct stack_trace *trace, · 5 unmodified lines
4645 if (sp <= low || sp > high - sizeof(*regs))
4746 return sp;
4847 regs = (struct pt_regs *)sp;
49− addr = regs->psw.addr & PSW_ADDR_INSN;
48+ addr = regs->psw.addr;
5049 if (savesched || !in_sched_functions(addr)) {
5150 if (!trace->skip)
5251 trace->entries[trace->nr_entries++] = addr;
@@ -65,7 +64,7 @@ void save_stack_trace(struct stack_trace *trace) · 12 unmodified lines
6564 register unsigned long sp asm ("15");
6665 unsigned long orig_sp, new_sp;
6766
68− orig_sp = sp & PSW_ADDR_INSN;
67+ orig_sp = sp;
6968 new_sp = save_context_stack(trace, orig_sp,
7069 S390_lowcore.panic_stack - PAGE_SIZE,
7170 S390_lowcore.panic_stack, 1);
@@ -86,7 +85,7 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace) · 14 unmodified lines
8685 {
8786 unsigned long sp, low, high;
8887
89− sp = tsk->thread.ksp & PSW_ADDR_INSN;
88+ sp = tsk->thread.ksp;
9089 low = (unsigned long) task_stack_page(tsk);
9190 high = (unsigned long) task_pt_regs(tsk);
9291 save_context_stack(trace, sp, low, high, 0);
arch/s390/kernel/syscalls.S+1−0
@@ -383,3 +383,4 @@ SYSCALL(sys_recvfrom,compat_sys_recvfrom) · 382 unmodified lines
383383 SYSCALL(sys_recvmsg,compat_sys_recvmsg)
384384 SYSCALL(sys_shutdown,sys_shutdown)
385385 SYSCALL(sys_mlock2,compat_sys_mlock2)
386+SYSCALL(sys_copy_file_range,compat_sys_copy_file_range) /* 375 */
arch/s390/kernel/traps.c+5−6
@@ -32,8 +32,7 @@ static inline void __user *get_trap_ip(struct pt_regs *regs) · 31 unmodified lines
3232 address = *(unsigned long *)(current->thread.trap_tdb + 24);
3333 else
3434 address = regs->psw.addr;
35− return (void __user *)
36− ((address - (regs->int_code >> 16)) & PSW_ADDR_INSN);
35+ return (void __user *) (address - (regs->int_code >> 16));
3736 }
3837
3938 static inline void report_user_fault(struct pt_regs *regs, int signr)
@@ -46,7 +45,7 @@ static inline void report_user_fault(struct pt_regs *regs, int signr) · 6 unmodified lines
4645 return;
4746 printk("User process fault: interruption code %04x ilc:%d ",
4847 regs->int_code & 0xffff, regs->int_code >> 17);
49− print_vma_addr("in ", regs->psw.addr & PSW_ADDR_INSN);
48+ print_vma_addr("in ", regs->psw.addr);
5049 printk("\n");
5150 show_regs(regs);
5251 }
@@ -69,13 +68,13 @@ void do_report_trap(struct pt_regs *regs, int si_signo, int si_code, char *str) · 16 unmodified lines
6968 report_user_fault(regs, si_signo);
7069 } else {
7170 const struct exception_table_entry *fixup;
72− fixup = search_exception_tables(regs->psw.addr & PSW_ADDR_INSN);
71+ fixup = search_exception_tables(regs->psw.addr);
7372 if (fixup)
74− regs->psw.addr = extable_fixup(fixup) | PSW_ADDR_AMODE;
73+ regs->psw.addr = extable_fixup(fixup);
7574 else {
7675 enum bug_trap_type btt;
7776
78− btt = report_bug(regs->psw.addr & PSW_ADDR_INSN, regs);
77+ btt = report_bug(regs->psw.addr, regs);
7978 if (btt == BUG_TRAP_TYPE_WARN)
8079 return;
8180 die(regs, str);
arch/s390/kvm/Kconfig+1−0
@@ -29,6 +29,7 @@ config KVM · 28 unmodified lines
2929 select HAVE_KVM_IRQFD
3030 select HAVE_KVM_IRQ_ROUTING
3131 select SRCU
32+ select KVM_VFIO
3233 ---help---
3334 Support hosting paravirtualized guest machines using the SIE
3435 virtualization capability on the mainframe. This should work
arch/s390/kvm/Makefile+1−1
@@ -7,7 +7,7 @@ · 6 unmodified lines
77 # as published by the Free Software Foundation.
88
99 KVM := ../../../virt/kvm
10−common-objs = $(KVM)/kvm_main.o $(KVM)/eventfd.o $(KVM)/async_pf.o $(KVM)/irqchip.o
10+common-objs = $(KVM)/kvm_main.o $(KVM)/eventfd.o $(KVM)/async_pf.o $(KVM)/irqchip.o $(KVM)/vfio.o
1111
1212 ccflags-y := -Ivirt/kvm -Iarch/s390/kvm
1313
arch/s390/kvm/guestdbg.c+2−2
@@ -116,7 +116,7 @@ static void enable_all_hw_wp(struct kvm_vcpu *vcpu) · 115 unmodified lines
116116 if (*cr9 & PER_EVENT_STORE && *cr9 & PER_CONTROL_ALTERATION) {
117117 *cr9 &= ~PER_CONTROL_ALTERATION;
118118 *cr10 = 0;
119− *cr11 = PSW_ADDR_INSN;
119+ *cr11 = -1UL;
120120 } else {
121121 *cr9 &= ~PER_CONTROL_ALTERATION;
122122 *cr9 |= PER_EVENT_STORE;
@@ -159,7 +159,7 @@ void kvm_s390_patch_guest_per_regs(struct kvm_vcpu *vcpu) · 36 unmodified lines
159159 vcpu->arch.sie_block->gcr[0] &= ~0x800ul;
160160 vcpu->arch.sie_block->gcr[9] |= PER_EVENT_IFETCH;
161161 vcpu->arch.sie_block->gcr[10] = 0;
162− vcpu->arch.sie_block->gcr[11] = PSW_ADDR_INSN;
162+ vcpu->arch.sie_block->gcr[11] = -1UL;
163163 }
164164
165165 if (guestdbg_hw_bp_enabled(vcpu)) {
arch/s390/kvm/kvm-s390.c+42−79
@@ -1423,44 +1423,18 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu) · 1422 unmodified lines
14231423 return 0;
14241424 }
14251425
1426−/*
1427− * Backs up the current FP/VX register save area on a particular
1428− * destination. Used to switch between different register save
1429− * areas.
1430− */
1431−static inline void save_fpu_to(struct fpu *dst)
1432−{
1433− dst->fpc = current->thread.fpu.fpc;
1434− dst->regs = current->thread.fpu.regs;
1435−}
1436−
1437−/*
1438− * Switches the FP/VX register save area from which to lazy
1439− * restore register contents.
1440− */
1441−static inline void load_fpu_from(struct fpu *from)
1442−{
1443− current->thread.fpu.fpc = from->fpc;
1444− current->thread.fpu.regs = from->regs;
1445−}
1446−
14471426 void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
14481427 {
14491428 /* Save host register state */
14501429 save_fpu_regs();
1451− save_fpu_to(&vcpu->arch.host_fpregs);
1452−
1453− if (test_kvm_facility(vcpu->kvm, 129)) {
1454− current->thread.fpu.fpc = vcpu->run->s.regs.fpc;
1455− /*
1456− * Use the register save area in the SIE-control block
1457− * for register restore and save in kvm_arch_vcpu_put()
1458− */
1459− current->thread.fpu.vxrs =
1460− (__vector128 *)&vcpu->run->s.regs.vrs;
1461− } else
1462− load_fpu_from(&vcpu->arch.guest_fpregs);
1430+ vcpu->arch.host_fpregs.fpc = current->thread.fpu.fpc;
1431+ vcpu->arch.host_fpregs.regs = current->thread.fpu.regs;
14631432
1433+ /* Depending on MACHINE_HAS_VX, data stored to vrs either
1434+ * has vector register or floating point register format.
1435+ */
1436+ current->thread.fpu.regs = vcpu->run->s.regs.vrs;
1437+ current->thread.fpu.fpc = vcpu->run->s.regs.fpc;
14641438 if (test_fp_ctl(current->thread.fpu.fpc))
14651439 /* User space provided an invalid FPC, let's clear it */
14661440 current->thread.fpu.fpc = 0;
@@ -1476,19 +1450,13 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu) · 9 unmodified lines
14761450 atomic_andnot(CPUSTAT_RUNNING, &vcpu->arch.sie_block->cpuflags);
14771451 gmap_disable(vcpu->arch.gmap);
14781452
1453+ /* Save guest register state */
14791454 save_fpu_regs();
1455+ vcpu->run->s.regs.fpc = current->thread.fpu.fpc;
14801456
1481− if (test_kvm_facility(vcpu->kvm, 129))
1482− /*
1483− * kvm_arch_vcpu_load() set up the register save area to
1484− * the &vcpu->run->s.regs.vrs and, thus, the vector registers
1485− * are already saved. Only the floating-point control must be
1486− * copied.
1487− */
1488− vcpu->run->s.regs.fpc = current->thread.fpu.fpc;
1489− else
1490− save_fpu_to(&vcpu->arch.guest_fpregs);
1491− load_fpu_from(&vcpu->arch.host_fpregs);
1457+ /* Restore host register state */
1458+ current->thread.fpu.fpc = vcpu->arch.host_fpregs.fpc;
1459+ current->thread.fpu.regs = vcpu->arch.host_fpregs.regs;
14921460
14931461 save_access_regs(vcpu->run->s.regs.acrs);
14941462 restore_access_regs(vcpu->arch.host_acrs);
@@ -1506,8 +1474,9 @@ static void kvm_s390_vcpu_initial_reset(struct kvm_vcpu *vcpu) · 11 unmodified lines
15061474 memset(vcpu->arch.sie_block->gcr, 0, 16 * sizeof(__u64));
15071475 vcpu->arch.sie_block->gcr[0] = 0xE0UL;
15081476 vcpu->arch.sie_block->gcr[14] = 0xC2000000UL;
1509− vcpu->arch.guest_fpregs.fpc = 0;
1510− asm volatile("lfpc %0" : : "Q" (vcpu->arch.guest_fpregs.fpc));
1477+ /* make sure the new fpc will be lazily loaded */
1478+ save_fpu_regs();
1479+ current->thread.fpu.fpc = 0;
15111480 vcpu->arch.sie_block->gbea = 1;
15121481 vcpu->arch.sie_block->pp = 0;
15131482 vcpu->arch.pfault_token = KVM_S390_PFAULT_TOKEN_INVALID;
@@ -1648,17 +1617,6 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, · 134 unmodified lines
16481617 vcpu->arch.local_int.wq = &vcpu->wq;
16491618 vcpu->arch.local_int.cpuflags = &vcpu->arch.sie_block->cpuflags;
16501619
1651− /*
1652− * Allocate a save area for floating-point registers. If the vector
1653− * extension is available, register contents are saved in the SIE
1654− * control block. The allocated save area is still required in
1655− * particular places, for example, in kvm_s390_vcpu_store_status().
1656− */
1657− vcpu->arch.guest_fpregs.fprs = kzalloc(sizeof(freg_t) * __NUM_FPRS,
1658− GFP_KERNEL);
1659− if (!vcpu->arch.guest_fpregs.fprs)
1660− goto out_free_sie_block;
1661−
16621620 rc = kvm_vcpu_init(vcpu, kvm, id);
16631621 if (rc)
16641622 goto out_free_sie_block;
@@ -1879,19 +1837,27 @@ int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu, · 214 unmodified lines
18791837
18801838 int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
18811839 {
1840+ /* make sure the new values will be lazily loaded */
1841+ save_fpu_regs();
18821842 if (test_fp_ctl(fpu->fpc))
18831843 return -EINVAL;
1884− memcpy(vcpu->arch.guest_fpregs.fprs, &fpu->fprs, sizeof(fpu->fprs));
1885− vcpu->arch.guest_fpregs.fpc = fpu->fpc;
1886− save_fpu_regs();
1887− load_fpu_from(&vcpu->arch.guest_fpregs);
1844+ current->thread.fpu.fpc = fpu->fpc;
1845+ if (MACHINE_HAS_VX)
1846+ convert_fp_to_vx(current->thread.fpu.vxrs, (freg_t *)fpu->fprs);
1847+ else
1848+ memcpy(current->thread.fpu.fprs, &fpu->fprs, sizeof(fpu->fprs));
18881849 return 0;
18891850 }
18901851
18911852 int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
18921853 {
1893− memcpy(&fpu->fprs, vcpu->arch.guest_fpregs.fprs, sizeof(fpu->fprs));
1894− fpu->fpc = vcpu->arch.guest_fpregs.fpc;
1854+ /* make sure we have the latest values */
1855+ save_fpu_regs();
1856+ if (MACHINE_HAS_VX)
1857+ convert_vx_to_fp((freg_t *)fpu->fprs, current->thread.fpu.vxrs);
1858+ else
1859+ memcpy(fpu->fprs, current->thread.fpu.fprs, sizeof(fpu->fprs));
1860+ fpu->fpc = current->thread.fpu.fpc;
18951861 return 0;
18961862 }
18971863
@@ -2396,6 +2362,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) · 498 unmodified lines
23962362 int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long gpa)
23972363 {
23982364 unsigned char archmode = 1;
2365+ freg_t fprs[NUM_FPRS];
23992366 unsigned int px;
24002367 u64 clkcomp;
24012368 int rc;
@@ -2411,8 +2378,16 @@ int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long gpa) · 9 unmodified lines
24112378 gpa = px;
24122379 } else
24132380 gpa -= __LC_FPREGS_SAVE_AREA;
2414− rc = write_guest_abs(vcpu, gpa + __LC_FPREGS_SAVE_AREA,
2415− vcpu->arch.guest_fpregs.fprs, 128);
2381+
2382+ /* manually convert vector registers if necessary */
2383+ if (MACHINE_HAS_VX) {
2384+ convert_vx_to_fp(fprs, current->thread.fpu.vxrs);
2385+ rc = write_guest_abs(vcpu, gpa + __LC_FPREGS_SAVE_AREA,
2386+ fprs, 128);
2387+ } else {
2388+ rc = write_guest_abs(vcpu, gpa + __LC_FPREGS_SAVE_AREA,
2389+ vcpu->run->s.regs.vrs, 128);
2390+ }
24162391 rc |= write_guest_abs(vcpu, gpa + __LC_GPREGS_SAVE_AREA,
24172392 vcpu->run->s.regs.gprs, 128);
24182393 rc |= write_guest_abs(vcpu, gpa + __LC_PSW_SAVE_AREA,
@@ -2420,7 +2395,7 @@ int kvm_s390_store_status_unloaded(struct kvm_vcpu *vcpu, unsigned long gpa) · 1 unmodified line
24202395 rc |= write_guest_abs(vcpu, gpa + __LC_PREFIX_SAVE_AREA,
24212396 &px, 4);
24222397 rc |= write_guest_abs(vcpu, gpa + __LC_FP_CREG_SAVE_AREA,
2423− &vcpu->arch.guest_fpregs.fpc, 4);
2398+ &vcpu->run->s.regs.fpc, 4);
24242399 rc |= write_guest_abs(vcpu, gpa + __LC_TOD_PROGREG_SAVE_AREA,
24252400 &vcpu->arch.sie_block->todpr, 4);
24262401 rc |= write_guest_abs(vcpu, gpa + __LC_CPU_TIMER_SAVE_AREA,
@@ -2443,19 +2418,7 @@ int kvm_s390_vcpu_store_status(struct kvm_vcpu *vcpu, unsigned long addr) · 16 unmodified lines
24432418 * it into the save area
24442419 */
24452420 save_fpu_regs();
2446− if (test_kvm_facility(vcpu->kvm, 129)) {
2447− /*
2448− * If the vector extension is available, the vector registers
2449− * which overlaps with floating-point registers are saved in
2450− * the SIE-control block. Hence, extract the floating-point
2451− * registers and the FPC value and store them in the
2452− * guest_fpregs structure.
2453− */
2454− vcpu->arch.guest_fpregs.fpc = current->thread.fpu.fpc;
2455− convert_vx_to_fp(vcpu->arch.guest_fpregs.fprs,
2456− current->thread.fpu.vxrs);
2457− } else
2458− save_fpu_to(&vcpu->arch.guest_fpregs);
2421+ vcpu->run->s.regs.fpc = current->thread.fpu.fpc;
24592422 save_access_regs(vcpu->run->s.regs.acrs);
24602423
24612424 return kvm_s390_store_status_unloaded(vcpu, addr);
arch/s390/mm/fault.c+3−3
@@ -228,7 +228,7 @@ static inline void report_user_fault(struct pt_regs *regs, long signr) · 227 unmodified lines
228228 return;
229229 printk(KERN_ALERT "User process fault: interruption code %04x ilc:%d ",
230230 regs->int_code & 0xffff, regs->int_code >> 17);
231− print_vma_addr(KERN_CONT "in ", regs->psw.addr & PSW_ADDR_INSN);
231+ print_vma_addr(KERN_CONT "in ", regs->psw.addr);
232232 printk(KERN_CONT "\n");
233233 printk(KERN_ALERT "failing address: %016lx TEID: %016lx\n",
234234 regs->int_parm_long & __FAIL_ADDR_MASK, regs->int_parm_long);
@@ -256,9 +256,9 @@ static noinline void do_no_context(struct pt_regs *regs) · 21 unmodified lines
256256 const struct exception_table_entry *fixup;
257257
258258 /* Are we prepared to handle this kernel fault? */
259− fixup = search_exception_tables(regs->psw.addr & PSW_ADDR_INSN);
259+ fixup = search_exception_tables(regs->psw.addr);
260260 if (fixup) {
261− regs->psw.addr = extable_fixup(fixup) | PSW_ADDR_AMODE;
261+ regs->psw.addr = extable_fixup(fixup);
262262 return;
263263 }
264264
arch/s390/mm/init.c+1−1
@@ -98,7 +98,7 @@ void __init paging_init(void) · 97 unmodified lines
9898 __ctl_load(S390_lowcore.kernel_asce, 1, 1);
9999 __ctl_load(S390_lowcore.kernel_asce, 7, 7);
100100 __ctl_load(S390_lowcore.kernel_asce, 13, 13);
101− arch_local_irq_restore(4UL << (BITS_PER_LONG - 8));
101+ __arch_local_irq_stosm(0x04);
102102
103103 sparse_memory_present_with_active_regions(MAX_NUMNODES);
104104 sparse_init();
arch/s390/mm/mmap.c+6−6
@@ -169,12 +169,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0, · 168 unmodified lines
169169
170170 int s390_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
171171 {
172− if (is_compat_task() || (TASK_SIZE >= (1UL << 53)))
172+ if (is_compat_task() || TASK_SIZE >= TASK_MAX_SIZE)
173173 return 0;
174174 if (!(flags & MAP_FIXED))
175175 addr = 0;
176176 if ((addr + len) >= TASK_SIZE)
177− return crst_table_upgrade(current->mm, 1UL << 53);
177+ return crst_table_upgrade(current->mm, TASK_MAX_SIZE);
178178 return 0;
179179 }
180180
@@ -189,9 +189,9 @@ s390_get_unmapped_area(struct file *filp, unsigned long addr, · 8 unmodified lines
189189 area = arch_get_unmapped_area(filp, addr, len, pgoff, flags);
190190 if (!(area & ~PAGE_MASK))
191191 return area;
192− if (area == -ENOMEM && !is_compat_task() && TASK_SIZE < (1UL << 53)) {
192+ if (area == -ENOMEM && !is_compat_task() && TASK_SIZE < TASK_MAX_SIZE) {
193193 /* Upgrade the page table to 4 levels and retry. */
194− rc = crst_table_upgrade(mm, 1UL << 53);
194+ rc = crst_table_upgrade(mm, TASK_MAX_SIZE);
195195 if (rc)
196196 return (unsigned long) rc;
197197 area = arch_get_unmapped_area(filp, addr, len, pgoff, flags);
@@ -211,9 +211,9 @@ s390_get_unmapped_area_topdown(struct file *filp, const unsigned long addr, · 13 unmodified lines
211211 area = arch_get_unmapped_area_topdown(filp, addr, len, pgoff, flags);
212212 if (!(area & ~PAGE_MASK))
213213 return area;
214− if (area == -ENOMEM && !is_compat_task() && TASK_SIZE < (1UL << 53)) {
214+ if (area == -ENOMEM && !is_compat_task() && TASK_SIZE < TASK_MAX_SIZE) {
215215 /* Upgrade the page table to 4 levels and retry. */
216− rc = crst_table_upgrade(mm, 1UL << 53);
216+ rc = crst_table_upgrade(mm, TASK_MAX_SIZE);
217217 if (rc)
218218 return (unsigned long) rc;
219219 area = arch_get_unmapped_area_topdown(filp, addr, len,
arch/s390/mm/pgtable.c+1−1
@@ -55,7 +55,7 @@ int crst_table_upgrade(struct mm_struct *mm, unsigned long limit) · 54 unmodified lines
5555 unsigned long entry;
5656 int flush;
5757
58− BUG_ON(limit > (1UL << 53));
58+ BUG_ON(limit > TASK_MAX_SIZE);
5959 flush = 0;
6060 repeat:
6161 table = crst_table_alloc(mm);
arch/s390/numa/numa.c+2−4
@@ -57,9 +57,7 @@ static __init pg_data_t *alloc_node_data(void) · 56 unmodified lines
5757 {
5858 pg_data_t *res;
5959
60− res = (pg_data_t *) memblock_alloc(sizeof(pg_data_t), 1);
61− if (!res)
62− panic("Could not allocate memory for node data!\n");
60+ res = (pg_data_t *) memblock_alloc(sizeof(pg_data_t), 8);
6361 memset(res, 0, sizeof(pg_data_t));
6462 return res;
6563 }
@@ -162,7 +160,7 @@ static int __init numa_init_late(void) · 96 unmodified lines
162160 register_one_node(nid);
163161 return 0;
164162 }
165−device_initcall(numa_init_late);
163+arch_initcall(numa_init_late);
166164
167165 static int __init parse_debug(char *parm)
168166 {
arch/s390/oprofile/backtrace.c+4−5
@@ -16,24 +16,23 @@ __show_trace(unsigned int *depth, unsigned long sp, · 15 unmodified lines
1616 struct pt_regs *regs;
1717
1818 while (*depth) {
19− sp = sp & PSW_ADDR_INSN;
2019 if (sp < low || sp > high - sizeof(*sf))
2120 return sp;
2221 sf = (struct stack_frame *) sp;
2322 (*depth)--;
24− oprofile_add_trace(sf->gprs[8] & PSW_ADDR_INSN);
23+ oprofile_add_trace(sf->gprs[8]);
2524
2625 /* Follow the backchain. */
2726 while (*depth) {
2827 low = sp;
29− sp = sf->back_chain & PSW_ADDR_INSN;
28+ sp = sf->back_chain;
3029 if (!sp)
3130 break;
3231 if (sp <= low || sp > high - sizeof(*sf))
3332 return sp;
3433 sf = (struct stack_frame *) sp;
3534 (*depth)--;
36− oprofile_add_trace(sf->gprs[8] & PSW_ADDR_INSN);
35+ oprofile_add_trace(sf->gprs[8]);
3736
3837 }
3938
@@ -46,7 +45,7 @@ __show_trace(unsigned int *depth, unsigned long sp, · 6 unmodified lines
4645 return sp;
4746 regs = (struct pt_regs *) sp;
4847 (*depth)--;
49− oprofile_add_trace(sf->gprs[8] & PSW_ADDR_INSN);
48+ oprofile_add_trace(sf->gprs[8]);
5049 low = sp;
5150 sp = regs->gprs[15];
5251 }
arch/s390/pci/pci.c+31−30
@@ -68,9 +68,12 @@ static struct airq_struct zpci_airq = { · 67 unmodified lines
6868 .isc = PCI_ISC,
6969 };
7070
71−/* I/O Map */
71+#define ZPCI_IOMAP_ENTRIES \
72+ min(((unsigned long) CONFIG_PCI_NR_FUNCTIONS * PCI_BAR_COUNT), \
73+ ZPCI_IOMAP_MAX_ENTRIES)
74+
7275 static DEFINE_SPINLOCK(zpci_iomap_lock);
73−static DECLARE_BITMAP(zpci_iomap, ZPCI_IOMAP_MAX_ENTRIES);
76+static unsigned long *zpci_iomap_bitmap;
7477 struct zpci_iomap_entry *zpci_iomap_start;
7578 EXPORT_SYMBOL_GPL(zpci_iomap_start);
7679
@@ -265,27 +268,20 @@ void __iomem *pci_iomap_range(struct pci_dev *pdev, · 188 unmodified lines
265268 unsigned long max)
266269 {
267270 struct zpci_dev *zdev = to_zpci(pdev);
268− u64 addr;
269271 int idx;
270272
271− if ((bar & 7) != bar)
273+ if (!pci_resource_len(pdev, bar))
272274 return NULL;
273275
274276 idx = zdev->bars[bar].map_idx;
275277 spin_lock(&zpci_iomap_lock);
276− if (zpci_iomap_start[idx].count++) {
277− BUG_ON(zpci_iomap_start[idx].fh != zdev->fh ||
278− zpci_iomap_start[idx].bar != bar);
279− } else {
280− zpci_iomap_start[idx].fh = zdev->fh;
281− zpci_iomap_start[idx].bar = bar;
282− }
283278 /* Detect overrun */
284− BUG_ON(!zpci_iomap_start[idx].count);
279+ WARN_ON(!++zpci_iomap_start[idx].count);
280+ zpci_iomap_start[idx].fh = zdev->fh;
281+ zpci_iomap_start[idx].bar = bar;
285282 spin_unlock(&zpci_iomap_lock);
286283
287− addr = ZPCI_IOMAP_ADDR_BASE | ((u64) idx << 48);
288− return (void __iomem *) addr + offset;
284+ return (void __iomem *) ZPCI_ADDR(idx) + offset;
289285 }
290286 EXPORT_SYMBOL(pci_iomap_range);
291287
@@ -297,12 +293,11 @@ EXPORT_SYMBOL(pci_iomap); · 5 unmodified lines
297293
298294 void pci_iounmap(struct pci_dev *pdev, void __iomem *addr)
299295 {
300− unsigned int idx;
296+ unsigned int idx = ZPCI_IDX(addr);
301297
302− idx = (((__force u64) addr) & ~ZPCI_IOMAP_ADDR_BASE) >> 48;
303298 spin_lock(&zpci_iomap_lock);
304299 /* Detect underrun */
305− BUG_ON(!zpci_iomap_start[idx].count);
300+ WARN_ON(!zpci_iomap_start[idx].count);
306301 if (!--zpci_iomap_start[idx].count) {
307302 zpci_iomap_start[idx].fh = 0;
308303 zpci_iomap_start[idx].bar = 0;
@@ -544,15 +539,15 @@ static void zpci_irq_exit(void) · 235 unmodified lines
544539
545540 static int zpci_alloc_iomap(struct zpci_dev *zdev)
546541 {
547− int entry;
542+ unsigned long entry;
548543
549544 spin_lock(&zpci_iomap_lock);
550− entry = find_first_zero_bit(zpci_iomap, ZPCI_IOMAP_MAX_ENTRIES);
551− if (entry == ZPCI_IOMAP_MAX_ENTRIES) {
545+ entry = find_first_zero_bit(zpci_iomap_bitmap, ZPCI_IOMAP_ENTRIES);
546+ if (entry == ZPCI_IOMAP_ENTRIES) {
552547 spin_unlock(&zpci_iomap_lock);
553548 return -ENOSPC;
554549 }
555− set_bit(entry, zpci_iomap);
550+ set_bit(entry, zpci_iomap_bitmap);
556551 spin_unlock(&zpci_iomap_lock);
557552 return entry;
558553 }
@@ -561,7 +556,7 @@ static void zpci_free_iomap(struct zpci_dev *zdev, int entry) · 2 unmodified lines
561556 {
562557 spin_lock(&zpci_iomap_lock);
563558 memset(&zpci_iomap_start[entry], 0, sizeof(struct zpci_iomap_entry));
564− clear_bit(entry, zpci_iomap);
559+ clear_bit(entry, zpci_iomap_bitmap);
565560 spin_unlock(&zpci_iomap_lock);
566561 }
567562
@@ -611,8 +606,7 @@ static int zpci_setup_bus_resources(struct zpci_dev *zdev, · 43 unmodified lines
611606 if (zdev->bars[i].val & 4)
612607 flags |= IORESOURCE_MEM_64;
613608
614− addr = ZPCI_IOMAP_ADDR_BASE + ((u64) entry << 48);
615−
609+ addr = ZPCI_ADDR(entry);
616610 size = 1UL << zdev->bars[i].size;
617611
618612 res = __alloc_res(zdev, addr, size, flags);
@@ -873,23 +867,30 @@ static int zpci_mem_init(void) · 254 unmodified lines
873867 zdev_fmb_cache = kmem_cache_create("PCI_FMB_cache", sizeof(struct zpci_fmb),
874868 16, 0, NULL);
875869 if (!zdev_fmb_cache)
876− goto error_zdev;
870+ goto error_fmb;
877871
878− /* TODO: use realloc */
879− zpci_iomap_start = kzalloc(ZPCI_IOMAP_MAX_ENTRIES * sizeof(*zpci_iomap_start),
880− GFP_KERNEL);
872+ zpci_iomap_start = kcalloc(ZPCI_IOMAP_ENTRIES,
873+ sizeof(*zpci_iomap_start), GFP_KERNEL);
881874 if (!zpci_iomap_start)
882875 goto error_iomap;
883− return 0;
884876
877+ zpci_iomap_bitmap = kcalloc(BITS_TO_LONGS(ZPCI_IOMAP_ENTRIES),
878+ sizeof(*zpci_iomap_bitmap), GFP_KERNEL);
879+ if (!zpci_iomap_bitmap)
880+ goto error_iomap_bitmap;
881+
882+ return 0;
883+error_iomap_bitmap:
884+ kfree(zpci_iomap_start);
885885 error_iomap:
886886 kmem_cache_destroy(zdev_fmb_cache);
887−error_zdev:
887+error_fmb:
888888 return -ENOMEM;
889889 }
890890
891891 static void zpci_mem_exit(void)
892892 {
893+ kfree(zpci_iomap_bitmap);
893894 kfree(zpci_iomap_start);
894895 kmem_cache_destroy(zdev_fmb_cache);
895896 }
arch/s390/pci/pci_event.c+5−0
@@ -53,6 +53,11 @@ static void __zpci_event_error(struct zpci_ccdf_err *ccdf) · 52 unmodified lines
5353
5454 pr_err("%s: Event 0x%x reports an error for PCI function 0x%x\n",
5555 pdev ? pci_name(pdev) : "n/a", ccdf->pec, ccdf->fid);
56+
57+ if (!pdev)
58+ return;
59+
60+ pdev->error_state = pci_channel_io_perm_failure;
5661 }
5762
5863 void zpci_event_error(void *data)
arch/sh/include/asm/barrier.h+0−1
@@ -33,7 +33,6 @@ · 32 unmodified lines
3333 #endif
3434
3535 #define __smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0)
36−#define smp_store_mb(var, value) __smp_store_mb(var, value)
3736
3837 #include <asm-generic/barrier.h>
3938
arch/x86/Kconfig+1−2
@@ -509,11 +509,10 @@ config X86_INTEL_CE · 508 unmodified lines
509509
510510 config X86_INTEL_MID
511511 bool "Intel MID platform support"
512− depends on X86_32
513512 depends on X86_EXTENDED_PLATFORM
514513 depends on X86_PLATFORM_DEVICES
515514 depends on PCI
516− depends on PCI_GOANY
515+ depends on X86_64 || (PCI_GOANY && X86_32)
517516 depends on X86_IO_APIC
518517 select SFI
519518 select I2C
arch/x86/include/asm/irq.h+3−2
@@ -23,11 +23,13 @@ extern void irq_ctx_init(int cpu); · 22 unmodified lines
2323
2424 #define __ARCH_HAS_DO_SOFTIRQ
2525
26+struct irq_desc;
27+
2628 #ifdef CONFIG_HOTPLUG_CPU
2729 #include <linux/cpumask.h>
2830 extern int check_irq_vectors_for_cpu_disable(void);
2931 extern void fixup_irqs(void);
30−extern void irq_force_complete_move(int);
32+extern void irq_force_complete_move(struct irq_desc *desc);
3133 #endif
3234
3335 #ifdef CONFIG_HAVE_KVM
@@ -37,7 +39,6 @@ extern void kvm_set_posted_intr_wakeup_handler(void (*handler)(void)); · 3 unmodified lines
3739 extern void (*x86_platform_ipi_callback)(void);
3840 extern void native_init_IRQ(void);
3941
40−struct irq_desc;
4142 extern bool handle_irq(struct irq_desc *desc, struct pt_regs *regs);
4243
4344 extern __visible unsigned int do_IRQ(struct pt_regs *regs);
arch/x86/include/asm/pgtable_types.h+2−4
@@ -366,20 +366,18 @@ static inline enum page_cache_mode pgprot2cachemode(pgprot_t pgprot) · 365 unmodified lines
366366 }
367367 static inline pgprot_t pgprot_4k_2_large(pgprot_t pgprot)
368368 {
369+ pgprotval_t val = pgprot_val(pgprot);
369370 pgprot_t new;
370− unsigned long val;
371371
372− val = pgprot_val(pgprot);
373372 pgprot_val(new) = (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) |
374373 ((val & _PAGE_PAT) << (_PAGE_BIT_PAT_LARGE - _PAGE_BIT_PAT));
375374 return new;
376375 }
377376 static inline pgprot_t pgprot_large_2_4k(pgprot_t pgprot)
378377 {
378+ pgprotval_t val = pgprot_val(pgprot);
379379 pgprot_t new;
380− unsigned long val;
381380
382− val = pgprot_val(pgprot);
383381 pgprot_val(new) = (val & ~(_PAGE_PAT | _PAGE_PAT_LARGE)) |
384382 ((val & _PAGE_PAT_LARGE) >>
385383 (_PAGE_BIT_PAT_LARGE - _PAGE_BIT_PAT));
arch/x86/kernel/apic/io_apic.c+5−1
@@ -2521,6 +2521,7 @@ void __init setup_ioapic_dest(void) · 2520 unmodified lines
25212521 {
25222522 int pin, ioapic, irq, irq_entry;
25232523 const struct cpumask *mask;
2524+ struct irq_desc *desc;
25242525 struct irq_data *idata;
25252526 struct irq_chip *chip;
25262527
@@ -2536,7 +2537,9 @@ void __init setup_ioapic_dest(void) · 9 unmodified lines
25362537 if (irq < 0 || !mp_init_irq_at_boot(ioapic, irq))
25372538 continue;
25382539
2539− idata = irq_get_irq_data(irq);
2540+ desc = irq_to_desc(irq);
2541+ raw_spin_lock_irq(&desc->lock);
2542+ idata = irq_desc_get_irq_data(desc);
25402543
25412544 /*
25422545 * Honour affinities which have been set in early boot
@@ -2550,6 +2553,7 @@ void __init setup_ioapic_dest(void) · 7 unmodified lines
25502553 /* Might be lapic_chip for irq 0 */
25512554 if (chip->irq_set_affinity)
25522555 chip->irq_set_affinity(idata, mask, false);
2556+ raw_spin_unlock_irq(&desc->lock);
25532557 }
25542558 }
25552559 #endif
arch/x86/kernel/apic/vector.c+145−76
@@ -31,7 +31,7 @@ struct apic_chip_data { · 30 unmodified lines
3131 struct irq_domain *x86_vector_domain;
3232 EXPORT_SYMBOL_GPL(x86_vector_domain);
3333 static DEFINE_RAW_SPINLOCK(vector_lock);
34−static cpumask_var_t vector_cpumask;
34+static cpumask_var_t vector_cpumask, vector_searchmask, searched_cpumask;
3535 static struct irq_chip lapic_controller;
3636 #ifdef CONFIG_X86_IO_APIC
3737 static struct apic_chip_data *legacy_irq_data[NR_IRQS_LEGACY];
@@ -118,35 +118,47 @@ static int __assign_irq_vector(int irq, struct apic_chip_data *d, · 80 unmodified lines
118118 */
119119 static int current_vector = FIRST_EXTERNAL_VECTOR + VECTOR_OFFSET_START;
120120 static int current_offset = VECTOR_OFFSET_START % 16;
121− int cpu, err;
121+ int cpu, vector;
122122
123− if (d->move_in_progress)
123+ /*
124+ * If there is still a move in progress or the previous move has not
125+ * been cleaned up completely, tell the caller to come back later.
126+ */
127+ if (d->move_in_progress ||
128+ cpumask_intersects(d->old_domain, cpu_online_mask))
124129 return -EBUSY;
125130
126131 /* Only try and allocate irqs on cpus that are present */
127− err = -ENOSPC;
128132 cpumask_clear(d->old_domain);
133+ cpumask_clear(searched_cpumask);
129134 cpu = cpumask_first_and(mask, cpu_online_mask);
130135 while (cpu < nr_cpu_ids) {
131− int new_cpu, vector, offset;
136+ int new_cpu, offset;
132137
138+ /* Get the possible target cpus for @mask/@cpu from the apic */
133139 apic->vector_allocation_domain(cpu, vector_cpumask, mask);
134140
141+ /*
142+ * Clear the offline cpus from @vector_cpumask for searching
143+ * and verify whether the result overlaps with @mask. If true,
144+ * then the call to apic->cpu_mask_to_apicid_and() will
145+ * succeed as well. If not, no point in trying to find a
146+ * vector in this mask.
147+ */
148+ cpumask_and(vector_searchmask, vector_cpumask, cpu_online_mask);
149+ if (!cpumask_intersects(vector_searchmask, mask))
150+ goto next_cpu;
151+
135152 if (cpumask_subset(vector_cpumask, d->domain)) {
136− err = 0;
137153 if (cpumask_equal(vector_cpumask, d->domain))
138− break;
154+ goto success;
139155 /*
140− * New cpumask using the vector is a proper subset of
141− * the current in use mask. So cleanup the vector
142− * allocation for the members that are not used anymore.
156+ * Mark the cpus which are not longer in the mask for
157+ * cleanup.
143158 */
144− cpumask_andnot(d->old_domain, d->domain,
145− vector_cpumask);
146− d->move_in_progress =
147− cpumask_intersects(d->old_domain, cpu_online_mask);
148− cpumask_and(d->domain, d->domain, vector_cpumask);
149− break;
159+ cpumask_andnot(d->old_domain, d->domain, vector_cpumask);
160+ vector = d->cfg.vector;
161+ goto update;
150162 }
151163
152164 vector = current_vector;
@@ -158,45 +170,60 @@ next: · 5 unmodified lines
158170 vector = FIRST_EXTERNAL_VECTOR + offset;
159171 }
160172
161− if (unlikely(current_vector == vector)) {
162− cpumask_or(d->old_domain, d->old_domain,
163− vector_cpumask);
164− cpumask_andnot(vector_cpumask, mask, d->old_domain);
165− cpu = cpumask_first_and(vector_cpumask,
166− cpu_online_mask);
167− continue;
168− }
173+ /* If the search wrapped around, try the next cpu */
174+ if (unlikely(current_vector == vector))
175+ goto next_cpu;
169176
170177 if (test_bit(vector, used_vectors))
171178 goto next;
172179
173− for_each_cpu_and(new_cpu, vector_cpumask, cpu_online_mask) {
180+ for_each_cpu(new_cpu, vector_searchmask) {
174181 if (!IS_ERR_OR_NULL(per_cpu(vector_irq, new_cpu)[vector]))
175182 goto next;
176183 }
177184 /* Found one! */
178185 current_vector = vector;
179186 current_offset = offset;
180− if (d->cfg.vector) {
187+ /* Schedule the old vector for cleanup on all cpus */
188+ if (d->cfg.vector)
181189 cpumask_copy(d->old_domain, d->domain);
182− d->move_in_progress =
183− cpumask_intersects(d->old_domain, cpu_online_mask);
184− }
185− for_each_cpu_and(new_cpu, vector_cpumask, cpu_online_mask)
190+ for_each_cpu(new_cpu, vector_searchmask)
186191 per_cpu(vector_irq, new_cpu)[vector] = irq_to_desc(irq);
187− d->cfg.vector = vector;
188− cpumask_copy(d->domain, vector_cpumask);
189− err = 0;
190− break;
191− }
192+ goto update;
192193
193− if (!err) {
194− /* cache destination APIC IDs into cfg->dest_apicid */
195− err = apic->cpu_mask_to_apicid_and(mask, d->domain,
196− &d->cfg.dest_apicid);
194+next_cpu:
195+ /*
196+ * We exclude the current @vector_cpumask from the requested
197+ * @mask and try again with the next online cpu in the
198+ * result. We cannot modify @mask, so we use @vector_cpumask
199+ * as a temporary buffer here as it will be reassigned when
200+ * calling apic->vector_allocation_domain() above.
201+ */
202+ cpumask_or(searched_cpumask, searched_cpumask, vector_cpumask);
203+ cpumask_andnot(vector_cpumask, mask, searched_cpumask);
204+ cpu = cpumask_first_and(vector_cpumask, cpu_online_mask);
205+ continue;
197206 }
207+ return -ENOSPC;
198208
199− return err;
209+update:
210+ /*
211+ * Exclude offline cpus from the cleanup mask and set the
212+ * move_in_progress flag when the result is not empty.
213+ */
214+ cpumask_and(d->old_domain, d->old_domain, cpu_online_mask);
215+ d->move_in_progress = !cpumask_empty(d->old_domain);
216+ d->cfg.vector = vector;
217+ cpumask_copy(d->domain, vector_cpumask);
218+success:
219+ /*
220+ * Cache destination APIC IDs into cfg->dest_apicid. This cannot fail
221+ * as we already established, that mask & d->domain & cpu_online_mask
222+ * is not empty.
223+ */
224+ BUG_ON(apic->cpu_mask_to_apicid_and(mask, d->domain,
225+ &d->cfg.dest_apicid));
226+ return 0;
200227 }
201228
202229 static int assign_irq_vector(int irq, struct apic_chip_data *data,
@@ -226,10 +253,8 @@ static int assign_irq_vector_policy(int irq, int node, · 23 unmodified lines
226253 static void clear_irq_vector(int irq, struct apic_chip_data *data)
227254 {
228255 struct irq_desc *desc;
229− unsigned long flags;
230256 int cpu, vector;
231257
232− raw_spin_lock_irqsave(&vector_lock, flags);
233258 BUG_ON(!data->cfg.vector);
234259
235260 vector = data->cfg.vector;
@@ -239,10 +264,13 @@ static void clear_irq_vector(int irq, struct apic_chip_data *data) · 3 unmodified lines
239264 data->cfg.vector = 0;
240265 cpumask_clear(data->domain);
241266
242− if (likely(!data->move_in_progress)) {
243− raw_spin_unlock_irqrestore(&vector_lock, flags);
267+ /*
268+ * If move is in progress or the old_domain mask is not empty,
269+ * i.e. the cleanup IPI has not been processed yet, we need to remove
270+ * the old references to desc from all cpus vector tables.
271+ */
272+ if (!data->move_in_progress && cpumask_empty(data->old_domain))
244273 return;
245− }
246274
247275 desc = irq_to_desc(irq);
248276 for_each_cpu_and(cpu, data->old_domain, cpu_online_mask) {
@@ -255,7 +283,6 @@ static void clear_irq_vector(int irq, struct apic_chip_data *data) · 6 unmodified lines
255283 }
256284 }
257285 data->move_in_progress = 0;
258− raw_spin_unlock_irqrestore(&vector_lock, flags);
259286 }
260287
261288 void init_irq_alloc_info(struct irq_alloc_info *info,
@@ -276,19 +303,24 @@ void copy_irq_alloc_info(struct irq_alloc_info *dst, struct irq_alloc_info *src) · 14 unmodified lines
276303 static void x86_vector_free_irqs(struct irq_domain *domain,
277304 unsigned int virq, unsigned int nr_irqs)
278305 {
306+ struct apic_chip_data *apic_data;
279307 struct irq_data *irq_data;
308+ unsigned long flags;
280309 int i;
281310
282311 for (i = 0; i < nr_irqs; i++) {
283312 irq_data = irq_domain_get_irq_data(x86_vector_domain, virq + i);
284313 if (irq_data && irq_data->chip_data) {
314+ raw_spin_lock_irqsave(&vector_lock, flags);
285315 clear_irq_vector(virq + i, irq_data->chip_data);
286− free_apic_chip_data(irq_data->chip_data);
316+ apic_data = irq_data->chip_data;
317+ irq_domain_reset_irq_data(irq_data);
318+ raw_spin_unlock_irqrestore(&vector_lock, flags);
319+ free_apic_chip_data(apic_data);
287320 #ifdef CONFIG_X86_IO_APIC
288321 if (virq + i < nr_legacy_irqs())
289322 legacy_irq_data[virq + i] = NULL;
290323 #endif
291− irq_domain_reset_irq_data(irq_data);
292324 }
293325 }
294326 }
@@ -406,6 +438,8 @@ int __init arch_early_irq_init(void) · 111 unmodified lines
406438 arch_init_htirq_domain(x86_vector_domain);
407439
408440 BUG_ON(!alloc_cpumask_var(&vector_cpumask, GFP_KERNEL));
441+ BUG_ON(!alloc_cpumask_var(&vector_searchmask, GFP_KERNEL));
442+ BUG_ON(!alloc_cpumask_var(&searched_cpumask, GFP_KERNEL));
409443
410444 return arch_early_ioapic_init();
411445 }
@@ -494,14 +528,7 @@ static int apic_set_affinity(struct irq_data *irq_data, · 82 unmodified lines
494528 return -EINVAL;
495529
496530 err = assign_irq_vector(irq, data, dest);
497− if (err) {
498− if (assign_irq_vector(irq, data,
499− irq_data_get_affinity_mask(irq_data)))
500− pr_err("Failed to recover vector for irq %d\n", irq);
501− return err;
502− }
503−
504− return IRQ_SET_MASK_OK;
531+ return err ? err : IRQ_SET_MASK_OK;
505532 }
506533
507534 static struct irq_chip lapic_controller = {
@@ -513,20 +540,12 @@ static struct irq_chip lapic_controller = { · 5 unmodified lines
513540 #ifdef CONFIG_SMP
514541 static void __send_cleanup_vector(struct apic_chip_data *data)
515542 {
516− cpumask_var_t cleanup_mask;
517−
518− if (unlikely(!alloc_cpumask_var(&cleanup_mask, GFP_ATOMIC))) {
519− unsigned int i;
520−
521− for_each_cpu_and(i, data->old_domain, cpu_online_mask)
522− apic->send_IPI_mask(cpumask_of(i),
523− IRQ_MOVE_CLEANUP_VECTOR);
524− } else {
525− cpumask_and(cleanup_mask, data->old_domain, cpu_online_mask);
526− apic->send_IPI_mask(cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR);
527− free_cpumask_var(cleanup_mask);
528− }
543+ raw_spin_lock(&vector_lock);
544+ cpumask_and(data->old_domain, data->old_domain, cpu_online_mask);
529545 data->move_in_progress = 0;
546+ if (!cpumask_empty(data->old_domain))
547+ apic->send_IPI_mask(data->old_domain, IRQ_MOVE_CLEANUP_VECTOR);
548+ raw_spin_unlock(&vector_lock);
530549 }
531550
532551 void send_cleanup_vector(struct irq_cfg *cfg)
@@ -570,12 +589,25 @@ asmlinkage __visible void smp_irq_move_cleanup_interrupt(void) · 37 unmodified lines
570589 goto unlock;
571590
572591 /*
573− * Check if the irq migration is in progress. If so, we
574− * haven't received the cleanup request yet for this irq.
592+ * Nothing to cleanup if irq migration is in progress
593+ * or this cpu is not set in the cleanup mask.
575594 */
576− if (data->move_in_progress)
595+ if (data->move_in_progress ||
596+ !cpumask_test_cpu(me, data->old_domain))
577597 goto unlock;
578598
599+ /*
600+ * We have two cases to handle here:
601+ * 1) vector is unchanged but the target mask got reduced
602+ * 2) vector and the target mask has changed
603+ *
604+ * #1 is obvious, but in #2 we have two vectors with the same
605+ * irq descriptor: the old and the new vector. So we need to
606+ * make sure that we only cleanup the old vector. The new
607+ * vector has the current @vector number in the config and
608+ * this cpu is part of the target mask. We better leave that
609+ * one alone.
610+ */
579611 if (vector == data->cfg.vector &&
580612 cpumask_test_cpu(me, data->domain))
581613 goto unlock;
@@ -593,6 +625,7 @@ asmlinkage __visible void smp_irq_move_cleanup_interrupt(void) · 11 unmodified lines
593625 goto unlock;
594626 }
595627 __this_cpu_write(vector_irq[vector], VECTOR_UNUSED);
628+ cpumask_clear_cpu(me, data->old_domain);
596629 unlock:
597630 raw_spin_unlock(&desc->lock);
598631 }
@@ -621,12 +654,48 @@ void irq_complete_move(struct irq_cfg *cfg) · 22 unmodified lines
621654 __irq_complete_move(cfg, ~get_irq_regs()->orig_ax);
622655 }
623656
624−void irq_force_complete_move(int irq)
657+/*
658+ * Called with @desc->lock held and interrupts disabled.
659+ */
660+void irq_force_complete_move(struct irq_desc *desc)
625661 {
626− struct irq_cfg *cfg = irq_cfg(irq);
662+ struct irq_data *irqdata = irq_desc_get_irq_data(desc);
663+ struct apic_chip_data *data = apic_chip_data(irqdata);
664+ struct irq_cfg *cfg = data ? &data->cfg : NULL;
627665
628− if (cfg)
629− __irq_complete_move(cfg, cfg->vector);
666+ if (!cfg)
667+ return;
668+
669+ __irq_complete_move(cfg, cfg->vector);
670+
671+ /*
672+ * This is tricky. If the cleanup of @data->old_domain has not been
673+ * done yet, then the following setaffinity call will fail with
674+ * -EBUSY. This can leave the interrupt in a stale state.
675+ *
676+ * The cleanup cannot make progress because we hold @desc->lock. So in
677+ * case @data->old_domain is not yet cleaned up, we need to drop the
678+ * lock and acquire it again. @desc cannot go away, because the
679+ * hotplug code holds the sparse irq lock.
680+ */
681+ raw_spin_lock(&vector_lock);
682+ /* Clean out all offline cpus (including ourself) first. */
683+ cpumask_and(data->old_domain, data->old_domain, cpu_online_mask);
684+ while (!cpumask_empty(data->old_domain)) {
685+ raw_spin_unlock(&vector_lock);
686+ raw_spin_unlock(&desc->lock);
687+ cpu_relax();
688+ raw_spin_lock(&desc->lock);
689+ /*
690+ * Reevaluate apic_chip_data. It might have been cleared after
691+ * we dropped @desc->lock.
692+ */
693+ data = apic_chip_data(irqdata);
694+ if (!data)
695+ return;
696+ raw_spin_lock(&vector_lock);
697+ }
698+ raw_spin_unlock(&vector_lock);
630699 }
631700 #endif
632701
arch/x86/kernel/apic/x2apic_uv_x.c+4−1
@@ -889,7 +889,10 @@ void __init uv_system_init(void) · 888 unmodified lines
889889 return;
890890 }
891891 pr_info("UV: Found %s hub\n", hub);
892− map_low_mmrs();
892+
893+ /* We now only need to map the MMRs on UV1 */
894+ if (is_uv1_hub())
895+ map_low_mmrs();
893896
894897 m_n_config.v = uv_read_local_mmr(UVH_RH_GAM_CONFIG_MMR );
895898 m_val = m_n_config.s.m_skt;
arch/x86/kernel/cpu/perf_event_intel.c+3−4
@@ -1960,7 +1960,8 @@ intel_bts_constraints(struct perf_event *event) · 1959 unmodified lines
19601960
19611961 static int intel_alt_er(int idx, u64 config)
19621962 {
1963− int alt_idx;
1963+ int alt_idx = idx;
1964+
19641965 if (!(x86_pmu.flags & PMU_FL_HAS_RSP_1))
19651966 return idx;
19661967
@@ -2897,14 +2898,12 @@ static void intel_pmu_cpu_starting(int cpu) · 930 unmodified lines
28972898 return;
28982899
28992900 if (!(x86_pmu.flags & PMU_FL_NO_HT_SHARING)) {
2900− void **onln = &cpuc->kfree_on_online[X86_PERF_KFREE_SHARED];
2901−
29022901 for_each_cpu(i, topology_sibling_cpumask(cpu)) {
29032902 struct intel_shared_regs *pc;
29042903
29052904 pc = per_cpu(cpu_hw_events, i).shared_regs;
29062905 if (pc && pc->core_id == core_id) {
2907− *onln = cpuc->shared_regs;
2906+ cpuc->kfree_on_online[0] = cpuc->shared_regs;
29082907 cpuc->shared_regs = pc;
29092908 break;
29102909 }
arch/x86/kernel/cpu/perf_event_intel_uncore.c+3−0
@@ -995,6 +995,9 @@ static int __init uncore_pci_init(void) · 994 unmodified lines
995995 case 87: /* Knights Landing */
996996 ret = knl_uncore_pci_init();
997997 break;
998+ case 94: /* SkyLake */
999+ ret = skl_uncore_pci_init();
1000+ break;
9981001 default:
9991002 return 0;
10001003 }
arch/x86/kernel/cpu/perf_event_intel_uncore.h+1−0
@@ -336,6 +336,7 @@ int snb_uncore_pci_init(void); · 335 unmodified lines
336336 int ivb_uncore_pci_init(void);
337337 int hsw_uncore_pci_init(void);
338338 int bdw_uncore_pci_init(void);
339+int skl_uncore_pci_init(void);
339340 void snb_uncore_cpu_init(void);
340341 void nhm_uncore_cpu_init(void);
341342 int snb_pci2phy_map_init(int devid);
arch/x86/kernel/cpu/perf_event_intel_uncore_snb.c+20−0
@@ -8,6 +8,7 @@ · 7 unmodified lines
88 #define PCI_DEVICE_ID_INTEL_HSW_IMC 0x0c00
99 #define PCI_DEVICE_ID_INTEL_HSW_U_IMC 0x0a04
1010 #define PCI_DEVICE_ID_INTEL_BDW_IMC 0x1604
11+#define PCI_DEVICE_ID_INTEL_SKL_IMC 0x191f
1112
1213 /* SNB event control */
1314 #define SNB_UNC_CTL_EV_SEL_MASK 0x000000ff
@@ -524,6 +525,14 @@ static const struct pci_device_id bdw_uncore_pci_ids[] = { · 510 unmodified lines
524525 { /* end: all zeroes */ },
525526 };
526527
528+static const struct pci_device_id skl_uncore_pci_ids[] = {
529+ { /* IMC */
530+ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SKL_IMC),
531+ .driver_data = UNCORE_PCI_DEV_DATA(SNB_PCI_UNCORE_IMC, 0),
532+ },
533+ { /* end: all zeroes */ },
534+};
535+
527536 static struct pci_driver snb_uncore_pci_driver = {
528537 .name = "snb_uncore",
529538 .id_table = snb_uncore_pci_ids,
@@ -544,6 +553,11 @@ static struct pci_driver bdw_uncore_pci_driver = { · 14 unmodified lines
544553 .id_table = bdw_uncore_pci_ids,
545554 };
546555
556+static struct pci_driver skl_uncore_pci_driver = {
557+ .name = "skl_uncore",
558+ .id_table = skl_uncore_pci_ids,
559+};
560+
547561 struct imc_uncore_pci_dev {
548562 __u32 pci_id;
549563 struct pci_driver *driver;
@@ -558,6 +572,7 @@ static const struct imc_uncore_pci_dev desktop_imc_pci_ids[] = { · 8 unmodified lines
558572 IMC_DEV(HSW_IMC, &hsw_uncore_pci_driver), /* 4th Gen Core Processor */
559573 IMC_DEV(HSW_U_IMC, &hsw_uncore_pci_driver), /* 4th Gen Core ULT Mobile Processor */
560574 IMC_DEV(BDW_IMC, &bdw_uncore_pci_driver), /* 5th Gen Core U */
575+ IMC_DEV(SKL_IMC, &skl_uncore_pci_driver), /* 6th Gen Core */
561576 { /* end marker */ }
562577 };
563578
@@ -610,6 +625,11 @@ int bdw_uncore_pci_init(void) · 46 unmodified lines
610625 return imc_uncore_pci_init();
611626 }
612627
628+int skl_uncore_pci_init(void)
629+{
630+ return imc_uncore_pci_init();
631+}
632+
613633 /* end of Sandy Bridge uncore support */
614634
615635 /* Nehalem uncore support */
arch/x86/kernel/head64.c+8−0
@@ -192,5 +192,13 @@ void __init x86_64_start_reservations(char *real_mode_data) · 191 unmodified lines
192192
193193 reserve_ebda_region();
194194
195+ switch (boot_params.hdr.hardware_subarch) {
196+ case X86_SUBARCH_INTEL_MID:
197+ x86_intel_mid_early_setup();
198+ break;
199+ default:
200+ break;
201+ }
202+
195203 start_kernel();
196204 }
arch/x86/kernel/irq.c+10−1
@@ -462,7 +462,7 @@ void fixup_irqs(void) · 461 unmodified lines
462462 * non intr-remapping case, we can't wait till this interrupt
463463 * arrives at this cpu before completing the irq move.
464464 */
465− irq_force_complete_move(irq);
465+ irq_force_complete_move(desc);
466466
467467 if (cpumask_any_and(affinity, cpu_online_mask) >= nr_cpu_ids) {
468468 break_affinity = 1;
@@ -470,6 +470,15 @@ void fixup_irqs(void) · 1 unmodified line
470470 }
471471
472472 chip = irq_data_get_irq_chip(data);
473+ /*
474+ * The interrupt descriptor might have been cleaned up
475+ * already, but it is not yet removed from the radix tree
476+ */
477+ if (!chip) {
478+ raw_spin_unlock(&desc->lock);
479+ continue;
480+ }
481+
473482 if (!irqd_can_move_in_process_context(data) && chip->irq_mask)
474483 chip->irq_mask(data);
475484
arch/x86/mm/pageattr.c+2−2
@@ -33,7 +33,7 @@ struct cpa_data { · 32 unmodified lines
3333 pgd_t *pgd;
3434 pgprot_t mask_set;
3535 pgprot_t mask_clr;
36− int numpages;
36+ unsigned long numpages;
3737 int flags;
3838 unsigned long pfn;
3939 unsigned force_split : 1;
@@ -1350,7 +1350,7 @@ static int __change_page_attr_set_clr(struct cpa_data *cpa, int checkalias) · 1310 unmodified lines
13501350 * CPA operation. Either a large page has been
13511351 * preserved or a single page update happened.
13521352 */
1353− BUG_ON(cpa->numpages > numpages);
1353+ BUG_ON(cpa->numpages > numpages || !cpa->numpages);
13541354 numpages -= cpa->numpages;
13551355 if (cpa->flags & (CPA_PAGES_ARRAY | CPA_ARRAY))
13561356 cpa->curpage++;
arch/x86/platform/efi/quirks.c+13−4
@@ -8,6 +8,7 @@ · 7 unmodified lines
88 #include <linux/memblock.h>
99 #include <linux/bootmem.h>
1010 #include <linux/acpi.h>
11+#include <linux/dmi.h>
1112 #include <asm/efi.h>
1213 #include <asm/uv/uv.h>
1314
@@ -248,6 +249,16 @@ out: · 234 unmodified lines
248249 return ret;
249250 }
250251
252+static const struct dmi_system_id sgi_uv1_dmi[] = {
253+ { NULL, "SGI UV1",
254+ { DMI_MATCH(DMI_PRODUCT_NAME, "Stoutland Platform"),
255+ DMI_MATCH(DMI_PRODUCT_VERSION, "1.0"),
256+ DMI_MATCH(DMI_BIOS_VENDOR, "SGI.COM"),
257+ }
258+ },
259+ { } /* NULL entry stops DMI scanning */
260+};
261+
251262 void __init efi_apply_memmap_quirks(void)
252263 {
253264 /*
@@ -260,10 +271,8 @@ void __init efi_apply_memmap_quirks(void) · 6 unmodified lines
260271 efi_unmap_memmap();
261272 }
262273
263− /*
264− * UV doesn't support the new EFI pagetable mapping yet.
265− */
266− if (is_uv_system())
274+ /* UV2+ BIOS has a fix for this issue. UV1 still needs the quirk. */
275+ if (dmi_check_system(sgi_uv1_dmi))
267276 set_bit(EFI_OLD_MEMMAP, &efi.flags);
268277 }
269278
arch/x86/platform/intel-mid/intel-mid.c+3−5
@@ -138,7 +138,7 @@ static void intel_mid_arch_setup(void) · 137 unmodified lines
138138 intel_mid_ops = get_intel_mid_ops[__intel_mid_cpu_chip]();
139139 else {
140140 intel_mid_ops = get_intel_mid_ops[INTEL_MID_CPU_CHIP_PENWELL]();
141− pr_info("ARCH: Unknown SoC, assuming PENWELL!\n");
141+ pr_info("ARCH: Unknown SoC, assuming Penwell!\n");
142142 }
143143
144144 out:
@@ -214,12 +214,10 @@ static inline int __init setup_x86_intel_mid_timer(char *arg) · 69 unmodified lines
214214 else if (strcmp("lapic_and_apbt", arg) == 0)
215215 intel_mid_timer_options = INTEL_MID_TIMER_LAPIC_APBT;
216216 else {
217− pr_warn("X86 INTEL_MID timer option %s not recognised"
218− " use x86_intel_mid_timer=apbt_only or lapic_and_apbt\n",
219− arg);
217+ pr_warn("X86 INTEL_MID timer option %s not recognised use x86_intel_mid_timer=apbt_only or lapic_and_apbt\n",
218+ arg);
220219 return -EINVAL;
221220 }
222221 return 0;
223222 }
224223 __setup("x86_intel_mid_timer=", setup_x86_intel_mid_timer);
225−
arch/x86/platform/intel-quark/imr.c+13−5
@@ -220,11 +220,12 @@ static int imr_dbgfs_state_show(struct seq_file *s, void *unused) · 219 unmodified lines
220220 if (imr_is_enabled(&imr)) {
221221 base = imr_to_phys(imr.addr_lo);
222222 end = imr_to_phys(imr.addr_hi) + IMR_MASK;
223+ size = end - base + 1;
223224 } else {
224225 base = 0;
225226 end = 0;
227+ size = 0;
226228 }
227− size = end - base;
228229 seq_printf(s, "imr%02i: base=%pa, end=%pa, size=0x%08zx "
229230 "rmask=0x%08x, wmask=0x%08x, %s, %s\n", i,
230231 &base, &end, size, imr.rmask, imr.wmask,
@@ -579,6 +580,7 @@ static void __init imr_fixup_memmap(struct imr_device *idev) · 348 unmodified lines
579580 {
580581 phys_addr_t base = virt_to_phys(&_text);
581582 size_t size = virt_to_phys(&__end_rodata) - base;
583+ unsigned long start, end;
582584 int i;
583585 int ret;
584586
@@ -586,18 +588,24 @@ static void __init imr_fixup_memmap(struct imr_device *idev) · 1 unmodified line
586588 for (i = 0; i < idev->max_imr; i++)
587589 imr_clear(i);
588590
591+ start = (unsigned long)_text;
592+ end = (unsigned long)__end_rodata - 1;
593+
589594 /*
590595 * Setup a locked IMR around the physical extent of the kernel
591596 * from the beginning of the .text secton to the end of the
592597 * .rodata section as one physically contiguous block.
598+ *
599+ * We don't round up @size since it is already PAGE_SIZE aligned.
600+ * See vmlinux.lds.S for details.
593601 */
594602 ret = imr_add_range(base, size, IMR_CPU, IMR_CPU, true);
595603 if (ret < 0) {
596− pr_err("unable to setup IMR for kernel: (%p - %p)\n",
597− &_text, &__end_rodata);
604+ pr_err("unable to setup IMR for kernel: %zu KiB (%lx - %lx)\n",
605+ size / 1024, start, end);
598606 } else {
599− pr_info("protecting kernel .text - .rodata: %zu KiB (%p - %p)\n",
600− size / 1024, &_text, &__end_rodata);
607+ pr_info("protecting kernel .text - .rodata: %zu KiB (%lx - %lx)\n",
608+ size / 1024, start, end);
601609 }
602610
603611 }
block/blk-merge.c+19−7
@@ -70,6 +70,18 @@ static struct bio *blk_bio_write_same_split(struct request_queue *q, · 69 unmodified lines
7070 return bio_split(bio, q->limits.max_write_same_sectors, GFP_NOIO, bs);
7171 }
7272
73+static inline unsigned get_max_io_size(struct request_queue *q,
74+ struct bio *bio)
75+{
76+ unsigned sectors = blk_max_size_offset(q, bio->bi_iter.bi_sector);
77+ unsigned mask = queue_logical_block_size(q) - 1;
78+
79+ /* aligned to logical block size */
80+ sectors &= ~(mask >> 9);
81+
82+ return sectors;
83+}
84+
7385 static struct bio *blk_bio_segment_split(struct request_queue *q,
7486 struct bio *bio,
7587 struct bio_set *bs,
@@ -81,6 +93,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, · 5 unmodified lines
8193 unsigned front_seg_size = bio->bi_seg_front_size;
8294 bool do_split = true;
8395 struct bio *new = NULL;
96+ const unsigned max_sectors = get_max_io_size(q, bio);
8497
8598 bio_for_each_segment(bv, bio, iter) {
8699 /*
@@ -90,20 +103,19 @@ static struct bio *blk_bio_segment_split(struct request_queue *q, · 3 unmodified lines
90103 if (bvprvp && bvec_gap_to_prev(q, bvprvp, bv.bv_offset))
91104 goto split;
92105
93− if (sectors + (bv.bv_len >> 9) >
94− blk_max_size_offset(q, bio->bi_iter.bi_sector)) {
106+ if (sectors + (bv.bv_len >> 9) > max_sectors) {
95107 /*
96108 * Consider this a new segment if we're splitting in
97109 * the middle of this vector.
98110 */
99111 if (nsegs < queue_max_segments(q) &&
100− sectors < blk_max_size_offset(q,
101− bio->bi_iter.bi_sector)) {
112+ sectors < max_sectors) {
102113 nsegs++;
103− sectors = blk_max_size_offset(q,
104− bio->bi_iter.bi_sector);
114+ sectors = max_sectors;
105115 }
106− goto split;
116+ if (sectors)
117+ goto split;
118+ /* Make this single bvec as the 1st segment */
107119 }
108120
109121 if (bvprvp && blk_queue_cluster(q)) {
drivers/acpi/video_detect.c+0−8
@@ -135,14 +135,6 @@ static const struct dmi_system_id video_detect_dmi_table[] = { · 134 unmodified lines
135135 DMI_MATCH(DMI_PRODUCT_NAME, "UL30A"),
136136 },
137137 },
138− {
139− .callback = video_detect_force_vendor,
140− .ident = "Dell Inspiron 5737",
141− .matches = {
142− DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
143− DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5737"),
144− },
145− },
146138
147139 /*
148140 * These models have a working acpi_video backlight control, and using
drivers/base/platform-msi.c+2−0
@@ -284,6 +284,7 @@ out_free_priv_data: · 283 unmodified lines
284284
285285 return err;
286286 }
287+EXPORT_SYMBOL_GPL(platform_msi_domain_alloc_irqs);
287288
288289 /**
289290 * platform_msi_domain_free_irqs - Free MSI interrupts for @dev
@@ -301,6 +302,7 @@ void platform_msi_domain_free_irqs(struct device *dev) · 11 unmodified lines
301302 msi_domain_free_irqs(dev->msi_domain, dev);
302303 platform_msi_free_descs(dev, 0, MAX_DEV_MSIS);
303304 }
305+EXPORT_SYMBOL_GPL(platform_msi_domain_free_irqs);
304306
305307 /**
306308 * platform_msi_get_host_data - Query the private data associated with
drivers/base/platform.c+9−4
@@ -558,10 +558,15 @@ static int platform_drv_probe(struct device *_dev) · 557 unmodified lines
558558 return ret;
559559
560560 ret = dev_pm_domain_attach(_dev, true);
561− if (ret != -EPROBE_DEFER && drv->probe) {
562− ret = drv->probe(dev);
563− if (ret)
564− dev_pm_domain_detach(_dev, true);
561+ if (ret != -EPROBE_DEFER) {
562+ if (drv->probe) {
563+ ret = drv->probe(dev);
564+ if (ret)
565+ dev_pm_domain_detach(_dev, true);
566+ } else {
567+ /* don't fail if just dev_pm_domain_attach failed */
568+ ret = 0;
569+ }
565570 }
566571
567572 if (drv->prevent_deferred_probe && ret == -EPROBE_DEFER) {
drivers/base/power/domain.c+20−17
@@ -162,7 +162,7 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool timed) · 161 unmodified lines
162162
163163 /**
164164 * genpd_queue_power_off_work - Queue up the execution of genpd_poweroff().
165− * @genpd: PM domait to power off.
165+ * @genpd: PM domain to power off.
166166 *
167167 * Queue up the execution of genpd_poweroff() unless it's already been done
168168 * before.
@@ -172,16 +172,15 @@ static void genpd_queue_power_off_work(struct generic_pm_domain *genpd) · 3 unmodified lines
172172 queue_work(pm_wq, &genpd->power_off_work);
173173 }
174174
175−static int genpd_poweron(struct generic_pm_domain *genpd);
176−
177175 /**
178176 * __genpd_poweron - Restore power to a given PM domain and its masters.
179177 * @genpd: PM domain to power up.
178+ * @depth: nesting count for lockdep.
180179 *
181180 * Restore power to @genpd and all of its masters so that it is possible to
182181 * resume a device belonging to it.
183182 */
184−static int __genpd_poweron(struct generic_pm_domain *genpd)
183+static int __genpd_poweron(struct generic_pm_domain *genpd, unsigned int depth)
185184 {
186185 struct gpd_link *link;
187186 int ret = 0;
@@ -196,11 +195,16 @@ static int __genpd_poweron(struct generic_pm_domain *genpd) · 8 unmodified lines
196195 * with it.
197196 */
198197 list_for_each_entry(link, &genpd->slave_links, slave_node) {
199− genpd_sd_counter_inc(link->master);
198+ struct generic_pm_domain *master = link->master;
199+
200+ genpd_sd_counter_inc(master);
201+
202+ mutex_lock_nested(&master->lock, depth + 1);
203+ ret = __genpd_poweron(master, depth + 1);
204+ mutex_unlock(&master->lock);
200205
201− ret = genpd_poweron(link->master);
202206 if (ret) {
203− genpd_sd_counter_dec(link->master);
207+ genpd_sd_counter_dec(master);
204208 goto err;
205209 }
206210 }
@@ -232,11 +236,12 @@ static int genpd_poweron(struct generic_pm_domain *genpd) · 25 unmodified lines
232236 int ret;
233237
234238 mutex_lock(&genpd->lock);
235− ret = __genpd_poweron(genpd);
239+ ret = __genpd_poweron(genpd, 0);
236240 mutex_unlock(&genpd->lock);
237241 return ret;
238242 }
239243
244+
240245 static int genpd_save_dev(struct generic_pm_domain *genpd, struct device *dev)
241246 {
242247 return GENPD_DEV_CALLBACK(genpd, int, save_state, dev);
@@ -484,7 +489,7 @@ static int pm_genpd_runtime_resume(struct device *dev) · 241 unmodified lines
484489 }
485490
486491 mutex_lock(&genpd->lock);
487− ret = __genpd_poweron(genpd);
492+ ret = __genpd_poweron(genpd, 0);
488493 mutex_unlock(&genpd->lock);
489494
490495 if (ret)
@@ -1339,8 +1344,8 @@ int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, · 848 unmodified lines
13391344 if (!link)
13401345 return -ENOMEM;
13411346
1342− mutex_lock(&genpd->lock);
1343− mutex_lock_nested(&subdomain->lock, SINGLE_DEPTH_NESTING);
1347+ mutex_lock(&subdomain->lock);
1348+ mutex_lock_nested(&genpd->lock, SINGLE_DEPTH_NESTING);
13441349
13451350 if (genpd->status == GPD_STATE_POWER_OFF
13461351 && subdomain->status != GPD_STATE_POWER_OFF) {
@@ -1363,8 +1368,8 @@ int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, · 16 unmodified lines
13631368 genpd_sd_counter_inc(genpd);
13641369
13651370 out:
1366− mutex_unlock(&subdomain->lock);
13671371 mutex_unlock(&genpd->lock);
1372+ mutex_unlock(&subdomain->lock);
13681373 if (ret)
13691374 kfree(link);
13701375 return ret;
@@ -1385,7 +1390,8 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, · 14 unmodified lines
13851390 if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(subdomain))
13861391 return -EINVAL;
13871392
1388− mutex_lock(&genpd->lock);
1393+ mutex_lock(&subdomain->lock);
1394+ mutex_lock_nested(&genpd->lock, SINGLE_DEPTH_NESTING);
13891395
13901396 if (!list_empty(&subdomain->slave_links) || subdomain->device_count) {
13911397 pr_warn("%s: unable to remove subdomain %s\n", genpd->name,
@@ -1398,22 +1404,19 @@ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd, · 6 unmodified lines
13981404 if (link->slave != subdomain)
13991405 continue;
14001406
1401− mutex_lock_nested(&subdomain->lock, SINGLE_DEPTH_NESTING);
1402−
14031407 list_del(&link->master_node);
14041408 list_del(&link->slave_node);
14051409 kfree(link);
14061410 if (subdomain->status != GPD_STATE_POWER_OFF)
14071411 genpd_sd_counter_dec(genpd);
14081412
1409− mutex_unlock(&subdomain->lock);
1410−
14111413 ret = 0;
14121414 break;
14131415 }
14141416
14151417 out:
14161418 mutex_unlock(&genpd->lock);
1419+ mutex_unlock(&subdomain->lock);
14171420
14181421 return ret;
14191422 }
drivers/clocksource/Kconfig+12−0
@@ -30,6 +30,8 @@ config CLKSRC_MMIO · 29 unmodified lines
3030 config DIGICOLOR_TIMER
3131 bool "Digicolor timer driver" if COMPILE_TEST
3232 depends on GENERIC_CLOCKEVENTS
33+ select CLKSRC_MMIO
34+ depends on HAS_IOMEM
3335 help
3436 Enables the support for the digicolor timer driver.
3537
@@ -55,6 +57,7 @@ config ARMADA_370_XP_TIMER · 19 unmodified lines
5557 bool "Armada 370 and XP timer driver" if COMPILE_TEST
5658 depends on ARM
5759 select CLKSRC_OF
60+ select CLKSRC_MMIO
5861 help
5962 Enables the support for the Armada 370 and XP timer driver.
6063
@@ -76,6 +79,7 @@ config ORION_TIMER · 15 unmodified lines
7679 config SUN4I_TIMER
7780 bool "Sun4i timer driver" if COMPILE_TEST
7881 depends on GENERIC_CLOCKEVENTS
82+ depends on HAS_IOMEM
7983 select CLKSRC_MMIO
8084 help
8185 Enables support for the Sun4i timer.
@@ -89,6 +93,7 @@ config SUN5I_HSTIMER · 7 unmodified lines
8993
9094 config TEGRA_TIMER
9195 bool "Tegra timer driver" if COMPILE_TEST
96+ select CLKSRC_MMIO
9297 depends on ARM
9398 help
9499 Enables support for the Tegra driver.
@@ -96,6 +101,7 @@ config TEGRA_TIMER · 1 unmodified line
96101 config VT8500_TIMER
97102 bool "VT8500 timer driver" if COMPILE_TEST
98103 depends on GENERIC_CLOCKEVENTS
104+ depends on HAS_IOMEM
99105 help
100106 Enables support for the VT8500 driver.
101107
@@ -131,6 +137,7 @@ config CLKSRC_NOMADIK_MTU_SCHED_CLOCK · 29 unmodified lines
131137 config CLKSRC_DBX500_PRCMU
132138 bool "Clocksource PRCMU Timer" if COMPILE_TEST
133139 depends on GENERIC_CLOCKEVENTS
140+ depends on HAS_IOMEM
134141 help
135142 Use the always on PRCMU Timer as clocksource
136143
@@ -248,6 +255,7 @@ config CLKSRC_EXYNOS_MCT · 111 unmodified lines
248255 config CLKSRC_SAMSUNG_PWM
249256 bool "PWM timer drvier for Samsung S3C, S5P" if COMPILE_TEST
250257 depends on GENERIC_CLOCKEVENTS
258+ depends on HAS_IOMEM
251259 help
252260 This is a new clocksource driver for the PWM timer found in
253261 Samsung S3C, S5P and Exynos SoCs, replacing an earlier driver
@@ -257,12 +265,14 @@ config CLKSRC_SAMSUNG_PWM · 3 unmodified lines
257265 config FSL_FTM_TIMER
258266 bool "Freescale FlexTimer Module driver" if COMPILE_TEST
259267 depends on GENERIC_CLOCKEVENTS
268+ depends on HAS_IOMEM
260269 select CLKSRC_MMIO
261270 help
262271 Support for Freescale FlexTimer Module (FTM) timer.
263272
264273 config VF_PIT_TIMER
265274 bool
275+ select CLKSRC_MMIO
266276 help
267277 Support for Period Interrupt Timer on Freescale Vybrid Family SoCs.
268278
@@ -360,6 +370,7 @@ config CLKSRC_TANGO_XTAL · 91 unmodified lines
360370 config CLKSRC_PXA
361371 bool "Clocksource for PXA or SA-11x0 platform" if COMPILE_TEST
362372 depends on GENERIC_CLOCKEVENTS
373+ depends on HAS_IOMEM
363374 select CLKSRC_MMIO
364375 help
365376 This enables OST0 support available on PXA and SA-11x0
@@ -394,6 +405,7 @@ config CLKSRC_ST_LPC · 28 unmodified lines
394405 bool "Low power clocksource found in the LPC" if COMPILE_TEST
395406 select CLKSRC_OF if OF
396407 depends on HAS_IOMEM
408+ select CLKSRC_MMIO
397409 help
398410 Enable this option to use the Low Power controller timer
399411 as clocksource.
drivers/clocksource/tcb_clksrc.c+2−1
@@ -98,7 +98,8 @@ static int tc_shutdown(struct clock_event_device *d) · 97 unmodified lines
9898
9999 __raw_writel(0xff, regs + ATMEL_TC_REG(2, IDR));
100100 __raw_writel(ATMEL_TC_CLKDIS, regs + ATMEL_TC_REG(2, CCR));
101− clk_disable(tcd->clk);
101+ if (!clockevent_state_detached(d))
102+ clk_disable(tcd->clk);
102103
103104 return 0;
104105 }
drivers/cpufreq/cpufreq-dt.c+7−8
@@ -142,15 +142,16 @@ static int allocate_resources(int cpu, struct device **cdev, · 141 unmodified lines
142142
143143 try_again:
144144 cpu_reg = regulator_get_optional(cpu_dev, reg);
145− if (IS_ERR(cpu_reg)) {
145+ ret = PTR_ERR_OR_ZERO(cpu_reg);
146+ if (ret) {
146147 /*
147148 * If cpu's regulator supply node is present, but regulator is
148149 * not yet registered, we should try defering probe.
149150 */
150− if (PTR_ERR(cpu_reg) == -EPROBE_DEFER) {
151+ if (ret == -EPROBE_DEFER) {
151152 dev_dbg(cpu_dev, "cpu%d regulator not ready, retry\n",
152153 cpu);
153− return -EPROBE_DEFER;
154+ return ret;
154155 }
155156
156157 /* Try with "cpu-supply" */
@@ -159,18 +160,16 @@ try_again: · 2 unmodified lines
159160 goto try_again;
160161 }
161162
162− dev_dbg(cpu_dev, "no regulator for cpu%d: %ld\n",
163− cpu, PTR_ERR(cpu_reg));
163+ dev_dbg(cpu_dev, "no regulator for cpu%d: %d\n", cpu, ret);
164164 }
165165
166166 cpu_clk = clk_get(cpu_dev, NULL);
167− if (IS_ERR(cpu_clk)) {
167+ ret = PTR_ERR_OR_ZERO(cpu_clk);
168+ if (ret) {
168169 /* put regulator */
169170 if (!IS_ERR(cpu_reg))
170171 regulator_put(cpu_reg);
171172
172− ret = PTR_ERR(cpu_clk);
173−
174173 /*
175174 * If cpu's clk node is present, but clock is not yet
176175 * registered, we should try defering probe.
drivers/cpufreq/cpufreq.c+3−3
@@ -48,11 +48,11 @@ static struct cpufreq_policy *next_policy(struct cpufreq_policy *policy, · 47 unmodified lines
4848 bool active)
4949 {
5050 do {
51− policy = list_next_entry(policy, policy_list);
52−
5351 /* No more policies in the list */
54− if (&policy->policy_list == &cpufreq_policy_list)
52+ if (list_is_last(&policy->policy_list, &cpufreq_policy_list))
5553 return NULL;
54+
55+ policy = list_next_entry(policy, policy_list);
5656 } while (!suitable_policy(policy, active));
5757
5858 return policy;
drivers/cpufreq/cpufreq_governor.c+8−3
@@ -387,16 +387,18 @@ static int cpufreq_governor_init(struct cpufreq_policy *policy, · 386 unmodified lines
387387 if (!have_governor_per_policy())
388388 cdata->gdbs_data = dbs_data;
389389
390+ policy->governor_data = dbs_data;
391+
390392 ret = sysfs_create_group(get_governor_parent_kobj(policy),
391393 get_sysfs_attr(dbs_data));
392394 if (ret)
393395 goto reset_gdbs_data;
394396
395− policy->governor_data = dbs_data;
396−
397397 return 0;
398398
399399 reset_gdbs_data:
400+ policy->governor_data = NULL;
401+
400402 if (!have_governor_per_policy())
401403 cdata->gdbs_data = NULL;
402404 cdata->exit(dbs_data, !policy->governor->initialized);
@@ -417,16 +419,19 @@ static int cpufreq_governor_exit(struct cpufreq_policy *policy, · 14 unmodified lines
417419 if (!cdbs->shared || cdbs->shared->policy)
418420 return -EBUSY;
419421
420− policy->governor_data = NULL;
421422 if (!--dbs_data->usage_count) {
422423 sysfs_remove_group(get_governor_parent_kobj(policy),
423424 get_sysfs_attr(dbs_data));
424425
426+ policy->governor_data = NULL;
427+
425428 if (!have_governor_per_policy())
426429 cdata->gdbs_data = NULL;
427430
428431 cdata->exit(dbs_data, policy->governor->initialized == 1);
429432 kfree(dbs_data);
433+ } else {
434+ policy->governor_data = NULL;
430435 }
431436
432437 free_common_dbs_info(policy, cdata);
drivers/cpufreq/pxa2xx-cpufreq.c+1−1
@@ -202,7 +202,7 @@ static void __init pxa_cpufreq_init_voltages(void) · 201 unmodified lines
202202 }
203203 }
204204 #else
205−static int pxa_cpufreq_change_voltage(struct pxa_freqs *pxa_freq)
205+static int pxa_cpufreq_change_voltage(const struct pxa_freqs *pxa_freq)
206206 {
207207 return 0;
208208 }
drivers/cpuidle/coupled.c+0−1
@@ -119,7 +119,6 @@ struct cpuidle_coupled { · 118 unmodified lines
119119
120120 #define CPUIDLE_COUPLED_NOT_IDLE (-1)
121121
122−static DEFINE_MUTEX(cpuidle_coupled_lock);
123122 static DEFINE_PER_CPU(struct call_single_data, cpuidle_coupled_poke_cb);
124123
125124 /*
drivers/cpuidle/cpuidle.c+1−1
@@ -153,7 +153,7 @@ int cpuidle_enter_freeze(struct cpuidle_driver *drv, struct cpuidle_device *dev) · 152 unmodified lines
153153 * be frozen safely.
154154 */
155155 index = find_deepest_state(drv, dev, UINT_MAX, 0, true);
156− if (index >= 0)
156+ if (index > 0)
157157 enter_freeze_proper(drv, dev, index);
158158
159159 return index;
drivers/gpu/drm/amd/amdgpu/amdgpu.h+22−22
@@ -2278,60 +2278,60 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring) · 2277 unmodified lines
22782278 #define amdgpu_dpm_enable_bapm(adev, e) (adev)->pm.funcs->enable_bapm((adev), (e))
22792279
22802280 #define amdgpu_dpm_get_temperature(adev) \
2281− (adev)->pp_enabled ? \
2281+ ((adev)->pp_enabled ? \
22822282 (adev)->powerplay.pp_funcs->get_temperature((adev)->powerplay.pp_handle) : \
2283− (adev)->pm.funcs->get_temperature((adev))
2283+ (adev)->pm.funcs->get_temperature((adev)))
22842284
22852285 #define amdgpu_dpm_set_fan_control_mode(adev, m) \
2286− (adev)->pp_enabled ? \
2286+ ((adev)->pp_enabled ? \
22872287 (adev)->powerplay.pp_funcs->set_fan_control_mode((adev)->powerplay.pp_handle, (m)) : \
2288− (adev)->pm.funcs->set_fan_control_mode((adev), (m))
2288+ (adev)->pm.funcs->set_fan_control_mode((adev), (m)))
22892289
22902290 #define amdgpu_dpm_get_fan_control_mode(adev) \
2291− (adev)->pp_enabled ? \
2291+ ((adev)->pp_enabled ? \
22922292 (adev)->powerplay.pp_funcs->get_fan_control_mode((adev)->powerplay.pp_handle) : \
2293− (adev)->pm.funcs->get_fan_control_mode((adev))
2293+ (adev)->pm.funcs->get_fan_control_mode((adev)))
22942294
22952295 #define amdgpu_dpm_set_fan_speed_percent(adev, s) \
2296− (adev)->pp_enabled ? \
2296+ ((adev)->pp_enabled ? \
22972297 (adev)->powerplay.pp_funcs->set_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \
2298− (adev)->pm.funcs->set_fan_speed_percent((adev), (s))
2298+ (adev)->pm.funcs->set_fan_speed_percent((adev), (s)))
22992299
23002300 #define amdgpu_dpm_get_fan_speed_percent(adev, s) \
2301− (adev)->pp_enabled ? \
2301+ ((adev)->pp_enabled ? \
23022302 (adev)->powerplay.pp_funcs->get_fan_speed_percent((adev)->powerplay.pp_handle, (s)) : \
2303− (adev)->pm.funcs->get_fan_speed_percent((adev), (s))
2303+ (adev)->pm.funcs->get_fan_speed_percent((adev), (s)))
23042304
23052305 #define amdgpu_dpm_get_sclk(adev, l) \
2306− (adev)->pp_enabled ? \
2306+ ((adev)->pp_enabled ? \
23072307 (adev)->powerplay.pp_funcs->get_sclk((adev)->powerplay.pp_handle, (l)) : \
2308− (adev)->pm.funcs->get_sclk((adev), (l))
2308+ (adev)->pm.funcs->get_sclk((adev), (l)))
23092309
23102310 #define amdgpu_dpm_get_mclk(adev, l) \
2311− (adev)->pp_enabled ? \
2311+ ((adev)->pp_enabled ? \
23122312 (adev)->powerplay.pp_funcs->get_mclk((adev)->powerplay.pp_handle, (l)) : \
2313− (adev)->pm.funcs->get_mclk((adev), (l))
2313+ (adev)->pm.funcs->get_mclk((adev), (l)))
23142314
23152315
23162316 #define amdgpu_dpm_force_performance_level(adev, l) \
2317− (adev)->pp_enabled ? \
2317+ ((adev)->pp_enabled ? \
23182318 (adev)->powerplay.pp_funcs->force_performance_level((adev)->powerplay.pp_handle, (l)) : \
2319− (adev)->pm.funcs->force_performance_level((adev), (l))
2319+ (adev)->pm.funcs->force_performance_level((adev), (l)))
23202320
23212321 #define amdgpu_dpm_powergate_uvd(adev, g) \
2322− (adev)->pp_enabled ? \
2322+ ((adev)->pp_enabled ? \
23232323 (adev)->powerplay.pp_funcs->powergate_uvd((adev)->powerplay.pp_handle, (g)) : \
2324− (adev)->pm.funcs->powergate_uvd((adev), (g))
2324+ (adev)->pm.funcs->powergate_uvd((adev), (g)))
23252325
23262326 #define amdgpu_dpm_powergate_vce(adev, g) \
2327− (adev)->pp_enabled ? \
2327+ ((adev)->pp_enabled ? \
23282328 (adev)->powerplay.pp_funcs->powergate_vce((adev)->powerplay.pp_handle, (g)) : \
2329− (adev)->pm.funcs->powergate_vce((adev), (g))
2329+ (adev)->pm.funcs->powergate_vce((adev), (g)))
23302330
23312331 #define amdgpu_dpm_debugfs_print_current_performance_level(adev, m) \
2332− (adev)->pp_enabled ? \
2332+ ((adev)->pp_enabled ? \
23332333 (adev)->powerplay.pp_funcs->print_current_performance_level((adev)->powerplay.pp_handle, (m)) : \
2334− (adev)->pm.funcs->debugfs_print_current_performance_level((adev), (m))
2334+ (adev)->pm.funcs->debugfs_print_current_performance_level((adev), (m)))
23352335
23362336 #define amdgpu_dpm_get_current_power_state(adev) \
23372337 (adev)->powerplay.pp_funcs->get_current_power_state((adev)->powerplay.pp_handle)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c+2−2
@@ -478,9 +478,9 @@ static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser, int error, bo · 477 unmodified lines
478478 struct amdgpu_fpriv *fpriv = parser->filp->driver_priv;
479479 unsigned i;
480480
481− amdgpu_vm_move_pt_bos_in_lru(parser->adev, &fpriv->vm);
482−
483481 if (!error) {
482+ amdgpu_vm_move_pt_bos_in_lru(parser->adev, &fpriv->vm);
483+
484484 /* Sort the buffer list from the smallest to largest buffer,
485485 * which affects the order of buffers in the LRU list.
486486 * This assures that the smallest buffers are added first
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c+4−0
@@ -333,6 +333,10 @@ int amdgpu_fbdev_init(struct amdgpu_device *adev) · 332 unmodified lines
333333 if (!adev->mode_info.mode_config_initialized)
334334 return 0;
335335
336+ /* don't init fbdev if there are no connectors */
337+ if (list_empty(&adev->ddev->mode_config.connector_list))
338+ return 0;
339+
336340 /* select 8 bpp console on low vram cards */
337341 if (adev->mc.real_vram_size <= (32*1024*1024))
338342 bpp_sel = 8;
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c+2−1
@@ -399,7 +399,8 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain, · 398 unmodified lines
399399 }
400400 if (fpfn > bo->placements[i].fpfn)
401401 bo->placements[i].fpfn = fpfn;
402− if (lpfn && lpfn < bo->placements[i].lpfn)
402+ if (!bo->placements[i].lpfn ||
403+ (lpfn && lpfn < bo->placements[i].lpfn))
403404 bo->placements[i].lpfn = lpfn;
404405 bo->placements[i].flags |= TTM_PL_FLAG_NO_EVICT;
405406 }
drivers/gpu/drm/amd/amdgpu/amdgpu_powerplay.c+18−7
@@ -99,13 +99,24 @@ static int amdgpu_pp_early_init(void *handle) · 98 unmodified lines
9999
100100 #ifdef CONFIG_DRM_AMD_POWERPLAY
101101 switch (adev->asic_type) {
102− case CHIP_TONGA:
103− case CHIP_FIJI:
104− adev->pp_enabled = (amdgpu_powerplay > 0) ? true : false;
105− break;
106− default:
107− adev->pp_enabled = (amdgpu_powerplay > 0) ? true : false;
108− break;
102+ case CHIP_TONGA:
103+ case CHIP_FIJI:
104+ adev->pp_enabled = (amdgpu_powerplay == 0) ? false : true;
105+ break;
106+ case CHIP_CARRIZO:
107+ case CHIP_STONEY:
108+ adev->pp_enabled = (amdgpu_powerplay > 0) ? true : false;
109+ break;
110+ /* These chips don't have powerplay implemenations */
111+ case CHIP_BONAIRE:
112+ case CHIP_HAWAII:
113+ case CHIP_KABINI:
114+ case CHIP_MULLINS:
115+ case CHIP_KAVERI:
116+ case CHIP_TOPAZ:
117+ default:
118+ adev->pp_enabled = false;
119+ break;
109120 }
110121 #else
111122 adev->pp_enabled = false;
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c+1−1
@@ -487,7 +487,7 @@ static int amdgpu_debugfs_ring_info(struct seq_file *m, void *data) · 486 unmodified lines
487487 seq_printf(m, "rptr: 0x%08x [%5d]\n",
488488 rptr, rptr);
489489
490− rptr_next = ~0;
490+ rptr_next = le32_to_cpu(*ring->next_rptr_cpu_addr);
491491
492492 seq_printf(m, "driver's copy of the wptr: 0x%08x [%5d]\n",
493493 ring->wptr, ring->wptr);
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c+3−4
@@ -1282,7 +1282,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm) · 1281 unmodified lines
12821282 {
12831283 const unsigned align = min(AMDGPU_VM_PTB_ALIGN_SIZE,
12841284 AMDGPU_VM_PTE_COUNT * 8);
1285− unsigned pd_size, pd_entries, pts_size;
1285+ unsigned pd_size, pd_entries;
12861286 int i, r;
12871287
12881288 for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
@@ -1300,8 +1300,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm) · 11 unmodified lines
13001300 pd_entries = amdgpu_vm_num_pdes(adev);
13011301
13021302 /* allocate page table array */
1303− pts_size = pd_entries * sizeof(struct amdgpu_vm_pt);
1304− vm->page_tables = kzalloc(pts_size, GFP_KERNEL);
1303+ vm->page_tables = drm_calloc_large(pd_entries, sizeof(struct amdgpu_vm_pt));
13051304 if (vm->page_tables == NULL) {
13061305 DRM_ERROR("Cannot allocate memory for page table array\n");
13071306 return -ENOMEM;
@@ -1361,7 +1360,7 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm) · 53 unmodified lines
13611360
13621361 for (i = 0; i < amdgpu_vm_num_pdes(adev); i++)
13631362 amdgpu_bo_unref(&vm->page_tables[i].entry.robj);
1364− kfree(vm->page_tables);
1363+ drm_free_large(vm->page_tables);
13651364
13661365 amdgpu_bo_unref(&vm->page_directory);
13671366 fence_put(vm->page_directory_fence);
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c+22−1
@@ -4186,7 +4186,18 @@ static int gfx_v8_0_soft_reset(void *handle) · 4185 unmodified lines
41864186 gfx_v8_0_cp_gfx_enable(adev, false);
41874187
41884188 /* Disable MEC parsing/prefetching */
4189− /* XXX todo */
4189+ gfx_v8_0_cp_compute_enable(adev, false);
4190+
4191+ if (grbm_soft_reset || srbm_soft_reset) {
4192+ tmp = RREG32(mmGMCON_DEBUG);
4193+ tmp = REG_SET_FIELD(tmp,
4194+ GMCON_DEBUG, GFX_STALL, 1);
4195+ tmp = REG_SET_FIELD(tmp,
4196+ GMCON_DEBUG, GFX_CLEAR, 1);
4197+ WREG32(mmGMCON_DEBUG, tmp);
4198+
4199+ udelay(50);
4200+ }
41904201
41914202 if (grbm_soft_reset) {
41924203 tmp = RREG32(mmGRBM_SOFT_RESET);
@@ -4215,6 +4226,16 @@ static int gfx_v8_0_soft_reset(void *handle) · 22 unmodified lines
42154226 WREG32(mmSRBM_SOFT_RESET, tmp);
42164227 tmp = RREG32(mmSRBM_SOFT_RESET);
42174228 }
4229+
4230+ if (grbm_soft_reset || srbm_soft_reset) {
4231+ tmp = RREG32(mmGMCON_DEBUG);
4232+ tmp = REG_SET_FIELD(tmp,
4233+ GMCON_DEBUG, GFX_STALL, 0);
4234+ tmp = REG_SET_FIELD(tmp,
4235+ GMCON_DEBUG, GFX_CLEAR, 0);
4236+ WREG32(mmGMCON_DEBUG, tmp);
4237+ }
4238+
42184239 /* Wait a little for things to settle down */
42194240 udelay(50);
42204241 gfx_v8_0_print_status((void *)adev);
drivers/gpu/drm/amd/amdgpu/tonga_dpm.c+2−15
@@ -122,25 +122,12 @@ static int tonga_dpm_hw_fini(void *handle) · 121 unmodified lines
122122
123123 static int tonga_dpm_suspend(void *handle)
124124 {
125− return 0;
125+ return tonga_dpm_hw_fini(handle);
126126 }
127127
128128 static int tonga_dpm_resume(void *handle)
129129 {
130− int ret;
131− struct amdgpu_device *adev = (struct amdgpu_device *)handle;
132−
133− mutex_lock(&adev->pm.mutex);
134−
135− ret = tonga_smu_start(adev);
136− if (ret) {
137− DRM_ERROR("SMU start failed\n");
138− goto fail;
139− }
140−
141−fail:
142− mutex_unlock(&adev->pm.mutex);
143− return ret;
130+ return tonga_dpm_hw_init(handle);
144131 }
145132
146133 static int tonga_dpm_set_clockgating_state(void *handle,
drivers/gpu/drm/amd/powerplay/amd_powerplay.c+5−0
@@ -64,6 +64,11 @@ static int pp_sw_init(void *handle) · 63 unmodified lines
6464 if (ret == 0)
6565 ret = hwmgr->hwmgr_func->backend_init(hwmgr);
6666
67+ if (ret)
68+ printk("amdgpu: powerplay initialization failed\n");
69+ else
70+ printk("amdgpu: powerplay initialized\n");
71+
6772 return ret;
6873 }
6974
drivers/gpu/drm/amd/powerplay/smumgr/cz_smumgr.c+32−9
@@ -272,6 +272,9 @@ static int cz_start_smu(struct pp_smumgr *smumgr) · 271 unmodified lines
272272 UCODE_ID_CP_MEC_JT1_MASK |
273273 UCODE_ID_CP_MEC_JT2_MASK;
274274
275+ if (smumgr->chip_id == CHIP_STONEY)
276+ fw_to_check &= ~(UCODE_ID_SDMA1_MASK | UCODE_ID_CP_MEC_JT2_MASK);
277+
275278 cz_request_smu_load_fw(smumgr);
276279 cz_check_fw_load_finish(smumgr, fw_to_check);
277280
@@ -282,7 +285,7 @@ static int cz_start_smu(struct pp_smumgr *smumgr) · 4 unmodified lines
282285 return ret;
283286 }
284287
285−static uint8_t cz_translate_firmware_enum_to_arg(
288+static uint8_t cz_translate_firmware_enum_to_arg(struct pp_smumgr *smumgr,
286289 enum cz_scratch_entry firmware_enum)
287290 {
288291 uint8_t ret = 0;
@@ -292,7 +295,10 @@ static uint8_t cz_translate_firmware_enum_to_arg( · 3 unmodified lines
292295 ret = UCODE_ID_SDMA0;
293296 break;
294297 case CZ_SCRATCH_ENTRY_UCODE_ID_SDMA1:
295− ret = UCODE_ID_SDMA1;
298+ if (smumgr->chip_id == CHIP_STONEY)
299+ ret = UCODE_ID_SDMA0;
300+ else
301+ ret = UCODE_ID_SDMA1;
296302 break;
297303 case CZ_SCRATCH_ENTRY_UCODE_ID_CP_CE:
298304 ret = UCODE_ID_CP_CE;
@@ -307,7 +313,10 @@ static uint8_t cz_translate_firmware_enum_to_arg( · 8 unmodified lines
307313 ret = UCODE_ID_CP_MEC_JT1;
308314 break;
309315 case CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT2:
310− ret = UCODE_ID_CP_MEC_JT2;
316+ if (smumgr->chip_id == CHIP_STONEY)
317+ ret = UCODE_ID_CP_MEC_JT1;
318+ else
319+ ret = UCODE_ID_CP_MEC_JT2;
311320 break;
312321 case CZ_SCRATCH_ENTRY_UCODE_ID_GMCON_RENG:
313322 ret = UCODE_ID_GMCON_RENG;
@@ -396,7 +405,7 @@ static int cz_smu_populate_single_scratch_task( · 82 unmodified lines
396405 struct SMU_Task *task = &toc->tasks[cz_smu->toc_entry_used_count++];
397406
398407 task->type = type;
399− task->arg = cz_translate_firmware_enum_to_arg(fw_enum);
408+ task->arg = cz_translate_firmware_enum_to_arg(smumgr, fw_enum);
400409 task->next = is_last ? END_OF_TASK_LIST : cz_smu->toc_entry_used_count;
401410
402411 for (i = 0; i < cz_smu->scratch_buffer_length; i++)
@@ -433,7 +442,7 @@ static int cz_smu_populate_single_ucode_load_task( · 30 unmodified lines
433442 struct SMU_Task *task = &toc->tasks[cz_smu->toc_entry_used_count++];
434443
435444 task->type = TASK_TYPE_UCODE_LOAD;
436− task->arg = cz_translate_firmware_enum_to_arg(fw_enum);
445+ task->arg = cz_translate_firmware_enum_to_arg(smumgr, fw_enum);
437446 task->next = is_last ? END_OF_TASK_LIST : cz_smu->toc_entry_used_count;
438447
439448 for (i = 0; i < cz_smu->driver_buffer_length; i++)
@@ -509,8 +518,14 @@ static int cz_smu_construct_toc_for_vddgfx_exit(struct pp_smumgr *smumgr) · 69 unmodified lines
509518 CZ_SCRATCH_ENTRY_UCODE_ID_CP_ME, false);
510519 cz_smu_populate_single_ucode_load_task(smumgr,
511520 CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, false);
512− cz_smu_populate_single_ucode_load_task(smumgr,
521+
522+ if (smumgr->chip_id == CHIP_STONEY)
523+ cz_smu_populate_single_ucode_load_task(smumgr,
524+ CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, false);
525+ else
526+ cz_smu_populate_single_ucode_load_task(smumgr,
513527 CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT2, false);
528+
514529 cz_smu_populate_single_ucode_load_task(smumgr,
515530 CZ_SCRATCH_ENTRY_UCODE_ID_RLC_G, false);
516531
@@ -551,7 +566,11 @@ static int cz_smu_construct_toc_for_bootup(struct pp_smumgr *smumgr) · 34 unmodified lines
551566
552567 cz_smu_populate_single_ucode_load_task(smumgr,
553568 CZ_SCRATCH_ENTRY_UCODE_ID_SDMA0, false);
554− cz_smu_populate_single_ucode_load_task(smumgr,
569+ if (smumgr->chip_id == CHIP_STONEY)
570+ cz_smu_populate_single_ucode_load_task(smumgr,
571+ CZ_SCRATCH_ENTRY_UCODE_ID_SDMA0, false);
572+ else
573+ cz_smu_populate_single_ucode_load_task(smumgr,
555574 CZ_SCRATCH_ENTRY_UCODE_ID_SDMA1, false);
556575 cz_smu_populate_single_ucode_load_task(smumgr,
557576 CZ_SCRATCH_ENTRY_UCODE_ID_CP_CE, false);
@@ -561,7 +580,11 @@ static int cz_smu_construct_toc_for_bootup(struct pp_smumgr *smumgr) · 3 unmodified lines
561580 CZ_SCRATCH_ENTRY_UCODE_ID_CP_ME, false);
562581 cz_smu_populate_single_ucode_load_task(smumgr,
563582 CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, false);
564− cz_smu_populate_single_ucode_load_task(smumgr,
583+ if (smumgr->chip_id == CHIP_STONEY)
584+ cz_smu_populate_single_ucode_load_task(smumgr,
585+ CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT1, false);
586+ else
587+ cz_smu_populate_single_ucode_load_task(smumgr,
565588 CZ_SCRATCH_ENTRY_UCODE_ID_CP_MEC_JT2, false);
566589 cz_smu_populate_single_ucode_load_task(smumgr,
567590 CZ_SCRATCH_ENTRY_UCODE_ID_RLC_G, true);
@@ -618,7 +641,7 @@ static int cz_smu_populate_firmware_entries(struct pp_smumgr *smumgr) · 50 unmodified lines
618641
619642 for (i = 0; i < sizeof(firmware_list)/sizeof(*firmware_list); i++) {
620643
621− firmware_type = cz_translate_firmware_enum_to_arg(
644+ firmware_type = cz_translate_firmware_enum_to_arg(smumgr,
622645 firmware_list[i]);
623646
624647 ucode_id = cz_convert_fw_type_to_cgs(firmware_type);
drivers/gpu/drm/drm_atomic_helper.c+20−4
@@ -946,9 +946,23 @@ static void wait_for_fences(struct drm_device *dev, · 945 unmodified lines
946946 }
947947 }
948948
949−static bool framebuffer_changed(struct drm_device *dev,
950− struct drm_atomic_state *old_state,
951− struct drm_crtc *crtc)
949+/**
950+ * drm_atomic_helper_framebuffer_changed - check if framebuffer has changed
951+ * @dev: DRM device
952+ * @old_state: atomic state object with old state structures
953+ * @crtc: DRM crtc
954+ *
955+ * Checks whether the framebuffer used for this CRTC changes as a result of
956+ * the atomic update. This is useful for drivers which cannot use
957+ * drm_atomic_helper_wait_for_vblanks() and need to reimplement its
958+ * functionality.
959+ *
960+ * Returns:
961+ * true if the framebuffer changed.
962+ */
963+bool drm_atomic_helper_framebuffer_changed(struct drm_device *dev,
964+ struct drm_atomic_state *old_state,
965+ struct drm_crtc *crtc)
952966 {
953967 struct drm_plane *plane;
954968 struct drm_plane_state *old_plane_state;
@@ -965,6 +979,7 @@ static bool framebuffer_changed(struct drm_device *dev, · 10 unmodified lines
965979
966980 return false;
967981 }
982+EXPORT_SYMBOL(drm_atomic_helper_framebuffer_changed);
968983
969984 /**
970985 * drm_atomic_helper_wait_for_vblanks - wait for vblank on crtcs
@@ -999,7 +1014,8 @@ drm_atomic_helper_wait_for_vblanks(struct drm_device *dev, · 28 unmodified lines
9991014 if (old_state->legacy_cursor_update)
10001015 continue;
10011016
1002− if (!framebuffer_changed(dev, old_state, crtc))
1017+ if (!drm_atomic_helper_framebuffer_changed(dev,
1018+ old_state, crtc))
10031019 continue;
10041020
10051021 ret = drm_crtc_vblank_get(crtc);
drivers/gpu/drm/etnaviv/common.xml.h+51−8
@@ -8,8 +8,8 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng · 7 unmodified lines
88 git clone git://0x04.net/rules-ng-ng
99
1010 The rules-ng-ng source files this header was generated from are:
11−- state_vg.xml ( 5973 bytes, from 2015-03-25 11:26:01)
12−- common.xml ( 18437 bytes, from 2015-03-25 11:27:41)
11+- state_hi.xml ( 24309 bytes, from 2015-12-12 09:02:53)
12+- common.xml ( 18379 bytes, from 2015-12-12 09:02:53)
1313
1414 Copyright (C) 2015
1515 */
@@ -30,15 +30,19 @@ Copyright (C) 2015 · 14 unmodified lines
3030 #define ENDIAN_MODE_NO_SWAP 0x00000000
3131 #define ENDIAN_MODE_SWAP_16 0x00000001
3232 #define ENDIAN_MODE_SWAP_32 0x00000002
33+#define chipModel_GC200 0x00000200
3334 #define chipModel_GC300 0x00000300
3435 #define chipModel_GC320 0x00000320
36+#define chipModel_GC328 0x00000328
3537 #define chipModel_GC350 0x00000350
3638 #define chipModel_GC355 0x00000355
3739 #define chipModel_GC400 0x00000400
3840 #define chipModel_GC410 0x00000410
3941 #define chipModel_GC420 0x00000420
42+#define chipModel_GC428 0x00000428
4043 #define chipModel_GC450 0x00000450
4144 #define chipModel_GC500 0x00000500
45+#define chipModel_GC520 0x00000520
4246 #define chipModel_GC530 0x00000530
4347 #define chipModel_GC600 0x00000600
4448 #define chipModel_GC700 0x00000700
@@ -46,9 +50,16 @@ Copyright (C) 2015 · 1 unmodified line
4650 #define chipModel_GC860 0x00000860
4751 #define chipModel_GC880 0x00000880
4852 #define chipModel_GC1000 0x00001000
53+#define chipModel_GC1500 0x00001500
4954 #define chipModel_GC2000 0x00002000
5055 #define chipModel_GC2100 0x00002100
56+#define chipModel_GC2200 0x00002200
57+#define chipModel_GC2500 0x00002500
58+#define chipModel_GC3000 0x00003000
5159 #define chipModel_GC4000 0x00004000
60+#define chipModel_GC5000 0x00005000
61+#define chipModel_GC5200 0x00005200
62+#define chipModel_GC6400 0x00006400
5263 #define RGBA_BITS_R 0x00000001
5364 #define RGBA_BITS_G 0x00000002
5465 #define RGBA_BITS_B 0x00000004
@@ -160,7 +171,7 @@ Copyright (C) 2015 · 105 unmodified lines
160171 #define chipMinorFeatures2_UNK8 0x00000100
161172 #define chipMinorFeatures2_UNK9 0x00000200
162173 #define chipMinorFeatures2_UNK10 0x00000400
163−#define chipMinorFeatures2_SAMPLERBASE_16 0x00000800
174+#define chipMinorFeatures2_HALTI1 0x00000800
164175 #define chipMinorFeatures2_UNK12 0x00001000
165176 #define chipMinorFeatures2_UNK13 0x00002000
166177 #define chipMinorFeatures2_UNK14 0x00004000
@@ -189,7 +200,7 @@ Copyright (C) 2015 · 22 unmodified lines
189200 #define chipMinorFeatures3_UNK5 0x00000020
190201 #define chipMinorFeatures3_UNK6 0x00000040
191202 #define chipMinorFeatures3_UNK7 0x00000080
192−#define chipMinorFeatures3_UNK8 0x00000100
203+#define chipMinorFeatures3_FAST_MSAA 0x00000100
193204 #define chipMinorFeatures3_UNK9 0x00000200
194205 #define chipMinorFeatures3_BUG_FIXES10 0x00000400
195206 #define chipMinorFeatures3_UNK11 0x00000800
@@ -199,7 +210,7 @@ Copyright (C) 2015 · 3 unmodified lines
199210 #define chipMinorFeatures3_UNK15 0x00008000
200211 #define chipMinorFeatures3_UNK16 0x00010000
201212 #define chipMinorFeatures3_UNK17 0x00020000
202−#define chipMinorFeatures3_UNK18 0x00040000
213+#define chipMinorFeatures3_ACE 0x00040000
203214 #define chipMinorFeatures3_UNK19 0x00080000
204215 #define chipMinorFeatures3_UNK20 0x00100000
205216 #define chipMinorFeatures3_UNK21 0x00200000
@@ -207,7 +218,7 @@ Copyright (C) 2015 · 1 unmodified line
207218 #define chipMinorFeatures3_UNK23 0x00800000
208219 #define chipMinorFeatures3_UNK24 0x01000000
209220 #define chipMinorFeatures3_UNK25 0x02000000
210−#define chipMinorFeatures3_UNK26 0x04000000
221+#define chipMinorFeatures3_NEW_HZ 0x04000000
211222 #define chipMinorFeatures3_UNK27 0x08000000
212223 #define chipMinorFeatures3_UNK28 0x10000000
213224 #define chipMinorFeatures3_UNK29 0x20000000
@@ -229,9 +240,9 @@ Copyright (C) 2015 · 15 unmodified lines
229240 #define chipMinorFeatures4_UNK13 0x00002000
230241 #define chipMinorFeatures4_UNK14 0x00004000
231242 #define chipMinorFeatures4_UNK15 0x00008000
232−#define chipMinorFeatures4_UNK16 0x00010000
243+#define chipMinorFeatures4_HALTI2 0x00010000
233244 #define chipMinorFeatures4_UNK17 0x00020000
234−#define chipMinorFeatures4_UNK18 0x00040000
245+#define chipMinorFeatures4_SMALL_MSAA 0x00040000
235246 #define chipMinorFeatures4_UNK19 0x00080000
236247 #define chipMinorFeatures4_UNK20 0x00100000
237248 #define chipMinorFeatures4_UNK21 0x00200000
@@ -245,5 +256,37 @@ Copyright (C) 2015 · 7 unmodified lines
245256 #define chipMinorFeatures4_UNK29 0x20000000
246257 #define chipMinorFeatures4_UNK30 0x40000000
247258 #define chipMinorFeatures4_UNK31 0x80000000
259+#define chipMinorFeatures5_UNK0 0x00000001
260+#define chipMinorFeatures5_UNK1 0x00000002
261+#define chipMinorFeatures5_UNK2 0x00000004
262+#define chipMinorFeatures5_UNK3 0x00000008
263+#define chipMinorFeatures5_UNK4 0x00000010
264+#define chipMinorFeatures5_UNK5 0x00000020
265+#define chipMinorFeatures5_UNK6 0x00000040
266+#define chipMinorFeatures5_UNK7 0x00000080
267+#define chipMinorFeatures5_UNK8 0x00000100
268+#define chipMinorFeatures5_HALTI3 0x00000200
269+#define chipMinorFeatures5_UNK10 0x00000400
270+#define chipMinorFeatures5_UNK11 0x00000800
271+#define chipMinorFeatures5_UNK12 0x00001000
272+#define chipMinorFeatures5_UNK13 0x00002000
273+#define chipMinorFeatures5_UNK14 0x00004000
274+#define chipMinorFeatures5_UNK15 0x00008000
275+#define chipMinorFeatures5_UNK16 0x00010000
276+#define chipMinorFeatures5_UNK17 0x00020000
277+#define chipMinorFeatures5_UNK18 0x00040000
278+#define chipMinorFeatures5_UNK19 0x00080000
279+#define chipMinorFeatures5_UNK20 0x00100000
280+#define chipMinorFeatures5_UNK21 0x00200000
281+#define chipMinorFeatures5_UNK22 0x00400000
282+#define chipMinorFeatures5_UNK23 0x00800000
283+#define chipMinorFeatures5_UNK24 0x01000000
284+#define chipMinorFeatures5_UNK25 0x02000000
285+#define chipMinorFeatures5_UNK26 0x04000000
286+#define chipMinorFeatures5_UNK27 0x08000000
287+#define chipMinorFeatures5_UNK28 0x10000000
288+#define chipMinorFeatures5_UNK29 0x20000000
289+#define chipMinorFeatures5_UNK30 0x40000000
290+#define chipMinorFeatures5_UNK31 0x80000000
248291
249292 #endif /* COMMON_XML */
drivers/gpu/drm/etnaviv/etnaviv_drv.c+0−1
@@ -668,7 +668,6 @@ static struct platform_driver etnaviv_platform_driver = { · 667 unmodified lines
668668 .probe = etnaviv_pdev_probe,
669669 .remove = etnaviv_pdev_remove,
670670 .driver = {
671− .owner = THIS_MODULE,
672671 .name = "etnaviv",
673672 .of_match_table = dt_match,
674673 },
drivers/gpu/drm/etnaviv/etnaviv_drv.h+1−1
@@ -85,7 +85,7 @@ struct drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device *dev, · 84 unmodified lines
8585 struct dma_buf_attachment *attach, struct sg_table *sg);
8686 int etnaviv_gem_prime_pin(struct drm_gem_object *obj);
8787 void etnaviv_gem_prime_unpin(struct drm_gem_object *obj);
88−void *etnaviv_gem_vaddr(struct drm_gem_object *obj);
88+void *etnaviv_gem_vmap(struct drm_gem_object *obj);
8989 int etnaviv_gem_cpu_prep(struct drm_gem_object *obj, u32 op,
9090 struct timespec *timeout);
9191 int etnaviv_gem_cpu_fini(struct drm_gem_object *obj);
drivers/gpu/drm/etnaviv/etnaviv_dump.c+4−2
@@ -201,7 +201,9 @@ void etnaviv_core_dump(struct etnaviv_gpu *gpu) · 200 unmodified lines
201201
202202 obj = vram->object;
203203
204+ mutex_lock(&obj->lock);
204205 pages = etnaviv_gem_get_pages(obj);
206+ mutex_unlock(&obj->lock);
205207 if (pages) {
206208 int j;
207209
@@ -213,8 +215,8 @@ void etnaviv_core_dump(struct etnaviv_gpu *gpu) · 5 unmodified lines
213215
214216 iter.hdr->iova = cpu_to_le64(vram->iova);
215217
216− vaddr = etnaviv_gem_vaddr(&obj->base);
217− if (vaddr && !IS_ERR(vaddr))
218+ vaddr = etnaviv_gem_vmap(&obj->base);
219+ if (vaddr)
218220 memcpy(iter.data, vaddr, obj->base.size);
219221
220222 etnaviv_core_dump_header(&iter, ETDUMP_BUF_BO, iter.data +
drivers/gpu/drm/etnaviv/etnaviv_gem.c+26−10
@@ -353,25 +353,39 @@ void etnaviv_gem_put_iova(struct etnaviv_gpu *gpu, struct drm_gem_object *obj) · 352 unmodified lines
353353 drm_gem_object_unreference_unlocked(obj);
354354 }
355355
356−void *etnaviv_gem_vaddr(struct drm_gem_object *obj)
356+void *etnaviv_gem_vmap(struct drm_gem_object *obj)
357357 {
358358 struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj);
359359
360− mutex_lock(&etnaviv_obj->lock);
361− if (!etnaviv_obj->vaddr) {
362− struct page **pages = etnaviv_gem_get_pages(etnaviv_obj);
363−
364− if (IS_ERR(pages))
365− return ERR_CAST(pages);
360+ if (etnaviv_obj->vaddr)
361+ return etnaviv_obj->vaddr;
366362
367− etnaviv_obj->vaddr = vmap(pages, obj->size >> PAGE_SHIFT,
368− VM_MAP, pgprot_writecombine(PAGE_KERNEL));
369− }
363+ mutex_lock(&etnaviv_obj->lock);
364+ /*
365+ * Need to check again, as we might have raced with another thread
366+ * while waiting for the mutex.
367+ */
368+ if (!etnaviv_obj->vaddr)
369+ etnaviv_obj->vaddr = etnaviv_obj->ops->vmap(etnaviv_obj);
370370 mutex_unlock(&etnaviv_obj->lock);
371371
372372 return etnaviv_obj->vaddr;
373373 }
374374
375+static void *etnaviv_gem_vmap_impl(struct etnaviv_gem_object *obj)
376+{
377+ struct page **pages;
378+
379+ lockdep_assert_held(&obj->lock);
380+
381+ pages = etnaviv_gem_get_pages(obj);
382+ if (IS_ERR(pages))
383+ return NULL;
384+
385+ return vmap(pages, obj->base.size >> PAGE_SHIFT,
386+ VM_MAP, pgprot_writecombine(PAGE_KERNEL));
387+}
388+
375389 static inline enum dma_data_direction etnaviv_op_to_dma_dir(u32 op)
376390 {
377391 if (op & ETNA_PREP_READ)
@@ -522,6 +536,7 @@ static void etnaviv_gem_shmem_release(struct etnaviv_gem_object *etnaviv_obj) · 144 unmodified lines
522536 static const struct etnaviv_gem_ops etnaviv_gem_shmem_ops = {
523537 .get_pages = etnaviv_gem_shmem_get_pages,
524538 .release = etnaviv_gem_shmem_release,
539+ .vmap = etnaviv_gem_vmap_impl,
525540 };
526541
527542 void etnaviv_gem_free_object(struct drm_gem_object *obj)
@@ -866,6 +881,7 @@ static void etnaviv_gem_userptr_release(struct etnaviv_gem_object *etnaviv_obj) · 338 unmodified lines
866881 static const struct etnaviv_gem_ops etnaviv_gem_userptr_ops = {
867882 .get_pages = etnaviv_gem_userptr_get_pages,
868883 .release = etnaviv_gem_userptr_release,
884+ .vmap = etnaviv_gem_vmap_impl,
869885 };
870886
871887 int etnaviv_gem_new_userptr(struct drm_device *dev, struct drm_file *file,
drivers/gpu/drm/etnaviv/etnaviv_gem.h+1−0
@@ -78,6 +78,7 @@ struct etnaviv_gem_object *to_etnaviv_bo(struct drm_gem_object *obj) · 77 unmodified lines
7878 struct etnaviv_gem_ops {
7979 int (*get_pages)(struct etnaviv_gem_object *);
8080 void (*release)(struct etnaviv_gem_object *);
81+ void *(*vmap)(struct etnaviv_gem_object *);
8182 };
8283
8384 static inline bool is_active(struct etnaviv_gem_object *etnaviv_obj)
drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c+9−1
@@ -31,7 +31,7 @@ struct sg_table *etnaviv_gem_prime_get_sg_table(struct drm_gem_object *obj) · 30 unmodified lines
3131
3232 void *etnaviv_gem_prime_vmap(struct drm_gem_object *obj)
3333 {
34− return etnaviv_gem_vaddr(obj);
34+ return etnaviv_gem_vmap(obj);
3535 }
3636
3737 void etnaviv_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr)
@@ -77,9 +77,17 @@ static void etnaviv_gem_prime_release(struct etnaviv_gem_object *etnaviv_obj) · 39 unmodified lines
7777 drm_prime_gem_destroy(&etnaviv_obj->base, etnaviv_obj->sgt);
7878 }
7979
80+static void *etnaviv_gem_prime_vmap_impl(struct etnaviv_gem_object *etnaviv_obj)
81+{
82+ lockdep_assert_held(&etnaviv_obj->lock);
83+
84+ return dma_buf_vmap(etnaviv_obj->base.import_attach->dmabuf);
85+}
86+
8087 static const struct etnaviv_gem_ops etnaviv_gem_prime_ops = {
8188 /* .get_pages should never be called */
8289 .release = etnaviv_gem_prime_release,
90+ .vmap = etnaviv_gem_prime_vmap_impl,
8391 };
8492
8593 struct drm_gem_object *etnaviv_gem_prime_import_sg_table(struct drm_device *dev,
drivers/gpu/drm/etnaviv/etnaviv_gpu.c+127−62
@@ -72,6 +72,14 @@ int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value) · 71 unmodified lines
7272 *value = gpu->identity.minor_features3;
7373 break;
7474
75+ case ETNAVIV_PARAM_GPU_FEATURES_5:
76+ *value = gpu->identity.minor_features4;
77+ break;
78+
79+ case ETNAVIV_PARAM_GPU_FEATURES_6:
80+ *value = gpu->identity.minor_features5;
81+ break;
82+
7583 case ETNAVIV_PARAM_GPU_STREAM_COUNT:
7684 *value = gpu->identity.stream_count;
7785 break;
@@ -112,6 +120,10 @@ int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value) · 34 unmodified lines
112120 *value = gpu->identity.num_constants;
113121 break;
114122
123+ case ETNAVIV_PARAM_GPU_NUM_VARYINGS:
124+ *value = gpu->identity.varyings_count;
125+ break;
126+
115127 default:
116128 DBG("%s: invalid param: %u", dev_name(gpu->dev), param);
117129 return -EINVAL;
@@ -120,46 +132,56 @@ int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value) · 2 unmodified lines
120132 return 0;
121133 }
122134
135+
136+#define etnaviv_is_model_rev(gpu, mod, rev) \
137+ ((gpu)->identity.model == chipModel_##mod && \
138+ (gpu)->identity.revision == rev)
139+#define etnaviv_field(val, field) \
140+ (((val) & field##__MASK) >> field##__SHIFT)
141+
123142 static void etnaviv_hw_specs(struct etnaviv_gpu *gpu)
124143 {
125144 if (gpu->identity.minor_features0 &
126145 chipMinorFeatures0_MORE_MINOR_FEATURES) {
127− u32 specs[2];
146+ u32 specs[4];
147+ unsigned int streams;
128148
129149 specs[0] = gpu_read(gpu, VIVS_HI_CHIP_SPECS);
130150 specs[1] = gpu_read(gpu, VIVS_HI_CHIP_SPECS_2);
131−
132− gpu->identity.stream_count =
133− (specs[0] & VIVS_HI_CHIP_SPECS_STREAM_COUNT__MASK)
134− >> VIVS_HI_CHIP_SPECS_STREAM_COUNT__SHIFT;
135− gpu->identity.register_max =
136− (specs[0] & VIVS_HI_CHIP_SPECS_REGISTER_MAX__MASK)
137− >> VIVS_HI_CHIP_SPECS_REGISTER_MAX__SHIFT;
138− gpu->identity.thread_count =
139− (specs[0] & VIVS_HI_CHIP_SPECS_THREAD_COUNT__MASK)
140− >> VIVS_HI_CHIP_SPECS_THREAD_COUNT__SHIFT;
141− gpu->identity.vertex_cache_size =
142− (specs[0] & VIVS_HI_CHIP_SPECS_VERTEX_CACHE_SIZE__MASK)
143− >> VIVS_HI_CHIP_SPECS_VERTEX_CACHE_SIZE__SHIFT;
144− gpu->identity.shader_core_count =
145− (specs[0] & VIVS_HI_CHIP_SPECS_SHADER_CORE_COUNT__MASK)
146− >> VIVS_HI_CHIP_SPECS_SHADER_CORE_COUNT__SHIFT;
147− gpu->identity.pixel_pipes =
148− (specs[0] & VIVS_HI_CHIP_SPECS_PIXEL_PIPES__MASK)
149− >> VIVS_HI_CHIP_SPECS_PIXEL_PIPES__SHIFT;
151+ specs[2] = gpu_read(gpu, VIVS_HI_CHIP_SPECS_3);
152+ specs[3] = gpu_read(gpu, VIVS_HI_CHIP_SPECS_4);
153+
154+ gpu->identity.stream_count = etnaviv_field(specs[0],
155+ VIVS_HI_CHIP_SPECS_STREAM_COUNT);
156+ gpu->identity.register_max = etnaviv_field(specs[0],
157+ VIVS_HI_CHIP_SPECS_REGISTER_MAX);
158+ gpu->identity.thread_count = etnaviv_field(specs[0],
159+ VIVS_HI_CHIP_SPECS_THREAD_COUNT);
160+ gpu->identity.vertex_cache_size = etnaviv_field(specs[0],
161+ VIVS_HI_CHIP_SPECS_VERTEX_CACHE_SIZE);
162+ gpu->identity.shader_core_count = etnaviv_field(specs[0],
163+ VIVS_HI_CHIP_SPECS_SHADER_CORE_COUNT);
164+ gpu->identity.pixel_pipes = etnaviv_field(specs[0],
165+ VIVS_HI_CHIP_SPECS_PIXEL_PIPES);
150166 gpu->identity.vertex_output_buffer_size =
151− (specs[0] & VIVS_HI_CHIP_SPECS_VERTEX_OUTPUT_BUFFER_SIZE__MASK)
152− >> VIVS_HI_CHIP_SPECS_VERTEX_OUTPUT_BUFFER_SIZE__SHIFT;
153−
154− gpu->identity.buffer_size =
155− (specs[1] & VIVS_HI_CHIP_SPECS_2_BUFFER_SIZE__MASK)
156− >> VIVS_HI_CHIP_SPECS_2_BUFFER_SIZE__SHIFT;
157− gpu->identity.instruction_count =
158− (specs[1] & VIVS_HI_CHIP_SPECS_2_INSTRUCTION_COUNT__MASK)
159− >> VIVS_HI_CHIP_SPECS_2_INSTRUCTION_COUNT__SHIFT;
160− gpu->identity.num_constants =
161− (specs[1] & VIVS_HI_CHIP_SPECS_2_NUM_CONSTANTS__MASK)
162− >> VIVS_HI_CHIP_SPECS_2_NUM_CONSTANTS__SHIFT;
167+ etnaviv_field(specs[0],
168+ VIVS_HI_CHIP_SPECS_VERTEX_OUTPUT_BUFFER_SIZE);
169+
170+ gpu->identity.buffer_size = etnaviv_field(specs[1],
171+ VIVS_HI_CHIP_SPECS_2_BUFFER_SIZE);
172+ gpu->identity.instruction_count = etnaviv_field(specs[1],
173+ VIVS_HI_CHIP_SPECS_2_INSTRUCTION_COUNT);
174+ gpu->identity.num_constants = etnaviv_field(specs[1],
175+ VIVS_HI_CHIP_SPECS_2_NUM_CONSTANTS);
176+
177+ gpu->identity.varyings_count = etnaviv_field(specs[2],
178+ VIVS_HI_CHIP_SPECS_3_VARYINGS_COUNT);
179+
180+ /* This overrides the value from older register if non-zero */
181+ streams = etnaviv_field(specs[3],
182+ VIVS_HI_CHIP_SPECS_4_STREAM_COUNT);
183+ if (streams)
184+ gpu->identity.stream_count = streams;
163185 }
164186
165187 /* Fill in the stream count if not specified */
@@ -173,7 +195,7 @@ static void etnaviv_hw_specs(struct etnaviv_gpu *gpu) · 7 unmodified lines
173195 /* Convert the register max value */
174196 if (gpu->identity.register_max)
175197 gpu->identity.register_max = 1 << gpu->identity.register_max;
176− else if (gpu->identity.model == 0x0400)
198+ else if (gpu->identity.model == chipModel_GC400)
177199 gpu->identity.register_max = 32;
178200 else
179201 gpu->identity.register_max = 64;
@@ -181,10 +203,10 @@ static void etnaviv_hw_specs(struct etnaviv_gpu *gpu) · 1 unmodified line
181203 /* Convert thread count */
182204 if (gpu->identity.thread_count)
183205 gpu->identity.thread_count = 1 << gpu->identity.thread_count;
184− else if (gpu->identity.model == 0x0400)
206+ else if (gpu->identity.model == chipModel_GC400)
185207 gpu->identity.thread_count = 64;
186− else if (gpu->identity.model == 0x0500 ||
187− gpu->identity.model == 0x0530)
208+ else if (gpu->identity.model == chipModel_GC500 ||
209+ gpu->identity.model == chipModel_GC530)
188210 gpu->identity.thread_count = 128;
189211 else
190212 gpu->identity.thread_count = 256;
@@ -206,7 +228,7 @@ static void etnaviv_hw_specs(struct etnaviv_gpu *gpu) · 15 unmodified lines
206228 if (gpu->identity.vertex_output_buffer_size) {
207229 gpu->identity.vertex_output_buffer_size =
208230 1 << gpu->identity.vertex_output_buffer_size;
209− } else if (gpu->identity.model == 0x0400) {
231+ } else if (gpu->identity.model == chipModel_GC400) {
210232 if (gpu->identity.revision < 0x4000)
211233 gpu->identity.vertex_output_buffer_size = 512;
212234 else if (gpu->identity.revision < 0x4200)
@@ -219,9 +241,8 @@ static void etnaviv_hw_specs(struct etnaviv_gpu *gpu) · 6 unmodified lines
219241
220242 switch (gpu->identity.instruction_count) {
221243 case 0:
222− if ((gpu->identity.model == 0x2000 &&
223− gpu->identity.revision == 0x5108) ||
224− gpu->identity.model == 0x880)
244+ if (etnaviv_is_model_rev(gpu, GC2000, 0x5108) ||
245+ gpu->identity.model == chipModel_GC880)
225246 gpu->identity.instruction_count = 512;
226247 else
227248 gpu->identity.instruction_count = 256;
@@ -242,6 +263,30 @@ static void etnaviv_hw_specs(struct etnaviv_gpu *gpu) · 14 unmodified lines
242263
243264 if (gpu->identity.num_constants == 0)
244265 gpu->identity.num_constants = 168;
266+
267+ if (gpu->identity.varyings_count == 0) {
268+ if (gpu->identity.minor_features1 & chipMinorFeatures1_HALTI0)
269+ gpu->identity.varyings_count = 12;
270+ else
271+ gpu->identity.varyings_count = 8;
272+ }
273+
274+ /*
275+ * For some cores, two varyings are consumed for position, so the
276+ * maximum varying count needs to be reduced by one.
277+ */
278+ if (etnaviv_is_model_rev(gpu, GC5000, 0x5434) ||
279+ etnaviv_is_model_rev(gpu, GC4000, 0x5222) ||
280+ etnaviv_is_model_rev(gpu, GC4000, 0x5245) ||
281+ etnaviv_is_model_rev(gpu, GC4000, 0x5208) ||
282+ etnaviv_is_model_rev(gpu, GC3000, 0x5435) ||
283+ etnaviv_is_model_rev(gpu, GC2200, 0x5244) ||
284+ etnaviv_is_model_rev(gpu, GC2100, 0x5108) ||
285+ etnaviv_is_model_rev(gpu, GC2000, 0x5108) ||
286+ etnaviv_is_model_rev(gpu, GC1500, 0x5246) ||
287+ etnaviv_is_model_rev(gpu, GC880, 0x5107) ||
288+ etnaviv_is_model_rev(gpu, GC880, 0x5106))
289+ gpu->identity.varyings_count -= 1;
245290 }
246291
247292 static void etnaviv_hw_identify(struct etnaviv_gpu *gpu)
@@ -251,12 +296,10 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu) · 3 unmodified lines
251296 chipIdentity = gpu_read(gpu, VIVS_HI_CHIP_IDENTITY);
252297
253298 /* Special case for older graphic cores. */
254− if (((chipIdentity & VIVS_HI_CHIP_IDENTITY_FAMILY__MASK)
255− >> VIVS_HI_CHIP_IDENTITY_FAMILY__SHIFT) == 0x01) {
256− gpu->identity.model = 0x500; /* gc500 */
257− gpu->identity.revision =
258− (chipIdentity & VIVS_HI_CHIP_IDENTITY_REVISION__MASK)
259− >> VIVS_HI_CHIP_IDENTITY_REVISION__SHIFT;
299+ if (etnaviv_field(chipIdentity, VIVS_HI_CHIP_IDENTITY_FAMILY) == 0x01) {
300+ gpu->identity.model = chipModel_GC500;
301+ gpu->identity.revision = etnaviv_field(chipIdentity,
302+ VIVS_HI_CHIP_IDENTITY_REVISION);
260303 } else {
261304
262305 gpu->identity.model = gpu_read(gpu, VIVS_HI_CHIP_MODEL);
@@ -269,13 +312,12 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu) · 6 unmodified lines
269312 * same. Only for GC400 family.
270313 */
271314 if ((gpu->identity.model & 0xff00) == 0x0400 &&
272− gpu->identity.model != 0x0420) {
315+ gpu->identity.model != chipModel_GC420) {
273316 gpu->identity.model = gpu->identity.model & 0x0400;
274317 }
275318
276319 /* Another special case */
277− if (gpu->identity.model == 0x300 &&
278− gpu->identity.revision == 0x2201) {
320+ if (etnaviv_is_model_rev(gpu, GC300, 0x2201)) {
279321 u32 chipDate = gpu_read(gpu, VIVS_HI_CHIP_DATE);
280322 u32 chipTime = gpu_read(gpu, VIVS_HI_CHIP_TIME);
281323
@@ -295,11 +337,13 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu) · 13 unmodified lines
295337 gpu->identity.features = gpu_read(gpu, VIVS_HI_CHIP_FEATURE);
296338
297339 /* Disable fast clear on GC700. */
298− if (gpu->identity.model == 0x700)
340+ if (gpu->identity.model == chipModel_GC700)
299341 gpu->identity.features &= ~chipFeatures_FAST_CLEAR;
300342
301− if ((gpu->identity.model == 0x500 && gpu->identity.revision < 2) ||
302− (gpu->identity.model == 0x300 && gpu->identity.revision < 0x2000)) {
343+ if ((gpu->identity.model == chipModel_GC500 &&
344+ gpu->identity.revision < 2) ||
345+ (gpu->identity.model == chipModel_GC300 &&
346+ gpu->identity.revision < 0x2000)) {
303347
304348 /*
305349 * GC500 rev 1.x and GC300 rev < 2.0 doesn't have these
@@ -309,6 +353,8 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu) · 3 unmodified lines
309353 gpu->identity.minor_features1 = 0;
310354 gpu->identity.minor_features2 = 0;
311355 gpu->identity.minor_features3 = 0;
356+ gpu->identity.minor_features4 = 0;
357+ gpu->identity.minor_features5 = 0;
312358 } else
313359 gpu->identity.minor_features0 =
314360 gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_0);
@@ -321,6 +367,10 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu) · 6 unmodified lines
321367 gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_2);
322368 gpu->identity.minor_features3 =
323369 gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_3);
370+ gpu->identity.minor_features4 =
371+ gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_4);
372+ gpu->identity.minor_features5 =
373+ gpu_read(gpu, VIVS_HI_CHIP_MINOR_FEATURE_5);
324374 }
325375
326376 /* GC600 idle register reports zero bits where modules aren't present */
@@ -441,10 +491,9 @@ static void etnaviv_gpu_hw_init(struct etnaviv_gpu *gpu) · 114 unmodified lines
441491 {
442492 u16 prefetch;
443493
444− if (gpu->identity.model == chipModel_GC320 &&
445− gpu_read(gpu, VIVS_HI_CHIP_TIME) != 0x2062400 &&
446− (gpu->identity.revision == 0x5007 ||
447− gpu->identity.revision == 0x5220)) {
494+ if ((etnaviv_is_model_rev(gpu, GC320, 0x5007) ||
495+ etnaviv_is_model_rev(gpu, GC320, 0x5220)) &&
496+ gpu_read(gpu, VIVS_HI_CHIP_TIME) != 0x2062400) {
448497 u32 mc_memory_debug;
449498
450499 mc_memory_debug = gpu_read(gpu, VIVS_MC_DEBUG_MEMORY) & ~0xff;
@@ -466,7 +515,7 @@ static void etnaviv_gpu_hw_init(struct etnaviv_gpu *gpu) · 15 unmodified lines
466515 VIVS_HI_AXI_CONFIG_ARCACHE(2));
467516
468517 /* GC2000 rev 5108 needs a special bus config */
469− if (gpu->identity.model == 0x2000 && gpu->identity.revision == 0x5108) {
518+ if (etnaviv_is_model_rev(gpu, GC2000, 0x5108)) {
470519 u32 bus_config = gpu_read(gpu, VIVS_MC_BUS_CONFIG);
471520 bus_config &= ~(VIVS_MC_BUS_CONFIG_FE_BUS_CONFIG__MASK |
472521 VIVS_MC_BUS_CONFIG_TX_BUS_CONFIG__MASK);
@@ -511,8 +560,16 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu) · 38 unmodified lines
511560
512561 if (gpu->identity.model == 0) {
513562 dev_err(gpu->dev, "Unknown GPU model\n");
514− pm_runtime_put_autosuspend(gpu->dev);
515− return -ENXIO;
563+ ret = -ENXIO;
564+ goto fail;
565+ }
566+
567+ /* Exclude VG cores with FE2.0 */
568+ if (gpu->identity.features & chipFeatures_PIPE_VG &&
569+ gpu->identity.features & chipFeatures_FE20) {
570+ dev_info(gpu->dev, "Ignoring GPU with VG and FE2.0\n");
571+ ret = -ENXIO;
572+ goto fail;
516573 }
517574
518575 ret = etnaviv_hw_reset(gpu);
@@ -539,10 +596,9 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu) · 20 unmodified lines
539596 goto fail;
540597 }
541598
542− /* TODO: we will leak here memory - fix it! */
543−
544599 gpu->mmu = etnaviv_iommu_new(gpu, iommu, version);
545600 if (!gpu->mmu) {
601+ iommu_domain_free(iommu);
546602 ret = -ENOMEM;
547603 goto fail;
548604 }
@@ -552,7 +608,7 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu) · 3 unmodified lines
552608 if (!gpu->buffer) {
553609 ret = -ENOMEM;
554610 dev_err(gpu->dev, "could not create command buffer\n");
555− goto fail;
611+ goto destroy_iommu;
556612 }
557613 if (gpu->buffer->paddr - gpu->memory_base > 0x80000000) {
558614 ret = -EINVAL;
@@ -582,6 +638,9 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu) · 23 unmodified lines
582638 free_buffer:
583639 etnaviv_gpu_cmdbuf_free(gpu->buffer);
584640 gpu->buffer = NULL;
641+destroy_iommu:
642+ etnaviv_iommu_destroy(gpu->mmu);
643+ gpu->mmu = NULL;
585644 fail:
586645 pm_runtime_mark_last_busy(gpu->dev);
587646 pm_runtime_put_autosuspend(gpu->dev);
@@ -642,6 +701,10 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m) · 54 unmodified lines
642701 gpu->identity.minor_features2);
643702 seq_printf(m, "\t minor_features3: 0x%08x\n",
644703 gpu->identity.minor_features3);
704+ seq_printf(m, "\t minor_features4: 0x%08x\n",
705+ gpu->identity.minor_features4);
706+ seq_printf(m, "\t minor_features5: 0x%08x\n",
707+ gpu->identity.minor_features5);
645708
646709 seq_puts(m, "\tspecs\n");
647710 seq_printf(m, "\t stream_count: %d\n",
@@ -664,6 +727,8 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m) · 16 unmodified lines
664727 gpu->identity.instruction_count);
665728 seq_printf(m, "\t num_constants: %d\n",
666729 gpu->identity.num_constants);
730+ seq_printf(m, "\t varyings_count: %d\n",
731+ gpu->identity.varyings_count);
667732
668733 seq_printf(m, "\taxi: 0x%08x\n", axi);
669734 seq_printf(m, "\tidle: 0x%08x\n", idle);
drivers/gpu/drm/etnaviv/etnaviv_gpu.h+9−0
@@ -46,6 +46,12 @@ struct etnaviv_chip_identity { · 45 unmodified lines
4646 /* Supported minor feature 3 fields. */
4747 u32 minor_features3;
4848
49+ /* Supported minor feature 4 fields. */
50+ u32 minor_features4;
51+
52+ /* Supported minor feature 5 fields. */
53+ u32 minor_features5;
54+
4955 /* Number of streams supported. */
5056 u32 stream_count;
5157
@@ -75,6 +81,9 @@ struct etnaviv_chip_identity { · 23 unmodified lines
7581
7682 /* Buffer size */
7783 u32 buffer_size;
84+
85+ /* Number of varyings */
86+ u8 varyings_count;
7887 };
7988
8089 struct etnaviv_event {
drivers/gpu/drm/etnaviv/state_hi.xml.h+24−2
@@ -8,8 +8,8 @@ http://0x04.net/cgit/index.cgi/rules-ng-ng · 7 unmodified lines
88 git clone git://0x04.net/rules-ng-ng
99
1010 The rules-ng-ng source files this header was generated from are:
11−- state_hi.xml ( 23420 bytes, from 2015-03-25 11:47:21)
12−- common.xml ( 18437 bytes, from 2015-03-25 11:27:41)
11+- state_hi.xml ( 24309 bytes, from 2015-12-12 09:02:53)
12+- common.xml ( 18437 bytes, from 2015-12-12 09:02:53)
1313
1414 Copyright (C) 2015
1515 */
@@ -182,8 +182,25 @@ Copyright (C) 2015 · 166 unmodified lines
182182
183183 #define VIVS_HI_CHIP_MINOR_FEATURE_3 0x00000088
184184
185+#define VIVS_HI_CHIP_SPECS_3 0x0000008c
186+#define VIVS_HI_CHIP_SPECS_3_VARYINGS_COUNT__MASK 0x000001f0
187+#define VIVS_HI_CHIP_SPECS_3_VARYINGS_COUNT__SHIFT 4
188+#define VIVS_HI_CHIP_SPECS_3_VARYINGS_COUNT(x) (((x) << VIVS_HI_CHIP_SPECS_3_VARYINGS_COUNT__SHIFT) & VIVS_HI_CHIP_SPECS_3_VARYINGS_COUNT__MASK)
189+#define VIVS_HI_CHIP_SPECS_3_GPU_CORE_COUNT__MASK 0x00000007
190+#define VIVS_HI_CHIP_SPECS_3_GPU_CORE_COUNT__SHIFT 0
191+#define VIVS_HI_CHIP_SPECS_3_GPU_CORE_COUNT(x) (((x) << VIVS_HI_CHIP_SPECS_3_GPU_CORE_COUNT__SHIFT) & VIVS_HI_CHIP_SPECS_3_GPU_CORE_COUNT__MASK)
192+
185193 #define VIVS_HI_CHIP_MINOR_FEATURE_4 0x00000094
186194
195+#define VIVS_HI_CHIP_SPECS_4 0x0000009c
196+#define VIVS_HI_CHIP_SPECS_4_STREAM_COUNT__MASK 0x0001f000
197+#define VIVS_HI_CHIP_SPECS_4_STREAM_COUNT__SHIFT 12
198+#define VIVS_HI_CHIP_SPECS_4_STREAM_COUNT(x) (((x) << VIVS_HI_CHIP_SPECS_4_STREAM_COUNT__SHIFT) & VIVS_HI_CHIP_SPECS_4_STREAM_COUNT__MASK)
199+
200+#define VIVS_HI_CHIP_MINOR_FEATURE_5 0x000000a0
201+
202+#define VIVS_HI_CHIP_PRODUCT_ID 0x000000a8
203+
187204 #define VIVS_PM 0x00000000
188205
189206 #define VIVS_PM_POWER_CONTROLS 0x00000100
@@ -206,6 +223,11 @@ Copyright (C) 2015 · 16 unmodified lines
206223 #define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_FE 0x00000001
207224 #define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_DE 0x00000002
208225 #define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_PE 0x00000004
226+#define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_SH 0x00000008
227+#define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_PA 0x00000010
228+#define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_SE 0x00000020
229+#define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_RA 0x00000040
230+#define VIVS_PM_MODULE_STATUS_MODULE_CLOCK_GATED_TX 0x00000080
209231
210232 #define VIVS_PM_PULSE_EATER 0x0000010c
211233
drivers/gpu/drm/radeon/dce6_afmt.c+2−10
@@ -304,18 +304,10 @@ void dce6_dp_audio_set_dto(struct radeon_device *rdev, · 303 unmodified lines
304304 unsigned int div = (RREG32(DENTIST_DISPCLK_CNTL) &
305305 DENTIST_DPREFCLK_WDIVIDER_MASK) >>
306306 DENTIST_DPREFCLK_WDIVIDER_SHIFT;
307−
308− if (div < 128 && div >= 96)
309− div -= 64;
310− else if (div >= 64)
311− div = div / 2 - 16;
312− else if (div >= 8)
313− div /= 4;
314− else
315− div = 0;
307+ div = radeon_audio_decode_dfs_div(div);
316308
317309 if (div)
318− clock = rdev->clock.gpupll_outputfreq * 10 / div;
310+ clock = clock * 100 / div;
319311
320312 WREG32(DCE8_DCCG_AUDIO_DTO1_PHASE, 24000);
321313 WREG32(DCE8_DCCG_AUDIO_DTO1_MODULE, clock);
drivers/gpu/drm/radeon/evergreen_hdmi.c+10−0
@@ -289,6 +289,16 @@ void dce4_dp_audio_set_dto(struct radeon_device *rdev, · 288 unmodified lines
289289 * number (coefficient of two integer numbers. DCCG_AUDIO_DTOx_PHASE
290290 * is the numerator, DCCG_AUDIO_DTOx_MODULE is the denominator
291291 */
292+ if (ASIC_IS_DCE41(rdev)) {
293+ unsigned int div = (RREG32(DCE41_DENTIST_DISPCLK_CNTL) &
294+ DENTIST_DPREFCLK_WDIVIDER_MASK) >>
295+ DENTIST_DPREFCLK_WDIVIDER_SHIFT;
296+ div = radeon_audio_decode_dfs_div(div);
297+
298+ if (div)
299+ clock = 100 * clock / div;
300+ }
301+
292302 WREG32(DCCG_AUDIO_DTO1_PHASE, 24000);
293303 WREG32(DCCG_AUDIO_DTO1_MODULE, clock);
294304 }
drivers/gpu/drm/radeon/evergreend.h+5−0
@@ -511,6 +511,11 @@ · 510 unmodified lines
511511 #define DCCG_AUDIO_DTO1_CNTL 0x05cc
512512 # define DCCG_AUDIO_DTO1_USE_512FBR_DTO (1 << 3)
513513
514+#define DCE41_DENTIST_DISPCLK_CNTL 0x049c
515+# define DENTIST_DPREFCLK_WDIVIDER(x) (((x) & 0x7f) << 24)
516+# define DENTIST_DPREFCLK_WDIVIDER_MASK (0x7f << 24)
517+# define DENTIST_DPREFCLK_WDIVIDER_SHIFT 24
518+
514519 /* DCE 4.0 AFMT */
515520 #define HDMI_CONTROL 0x7030
516521 # define HDMI_KEEPOUT_MODE (1 << 0)
drivers/gpu/drm/radeon/radeon.h+1−1
@@ -268,7 +268,7 @@ struct radeon_clock { · 267 unmodified lines
268268 uint32_t current_dispclk;
269269 uint32_t dp_extclk;
270270 uint32_t max_pixel_clock;
271− uint32_t gpupll_outputfreq;
271+ uint32_t vco_freq;
272272 };
273273
274274 /*
drivers/gpu/drm/radeon/radeon_atombios.c+36−13
@@ -1106,6 +1106,31 @@ union firmware_info { · 1105 unmodified lines
11061106 ATOM_FIRMWARE_INFO_V2_2 info_22;
11071107 };
11081108
1109+union igp_info {
1110+ struct _ATOM_INTEGRATED_SYSTEM_INFO info;
1111+ struct _ATOM_INTEGRATED_SYSTEM_INFO_V2 info_2;
1112+ struct _ATOM_INTEGRATED_SYSTEM_INFO_V6 info_6;
1113+ struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_7 info_7;
1114+ struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_8 info_8;
1115+};
1116+
1117+static void radeon_atombios_get_dentist_vco_freq(struct radeon_device *rdev)
1118+{
1119+ struct radeon_mode_info *mode_info = &rdev->mode_info;
1120+ int index = GetIndexIntoMasterTable(DATA, IntegratedSystemInfo);
1121+ union igp_info *igp_info;
1122+ u8 frev, crev;
1123+ u16 data_offset;
1124+
1125+ if (atom_parse_data_header(mode_info->atom_context, index, NULL,
1126+ &frev, &crev, &data_offset)) {
1127+ igp_info = (union igp_info *)(mode_info->atom_context->bios +
1128+ data_offset);
1129+ rdev->clock.vco_freq =
1130+ le32_to_cpu(igp_info->info_6.ulDentistVCOFreq);
1131+ }
1132+}
1133+
11091134 bool radeon_atom_get_clock_info(struct drm_device *dev)
11101135 {
11111136 struct radeon_device *rdev = dev->dev_private;
@@ -1257,12 +1282,18 @@ bool radeon_atom_get_clock_info(struct drm_device *dev) · 145 unmodified lines
12571282 rdev->mode_info.firmware_flags =
12581283 le16_to_cpu(firmware_info->info.usFirmwareCapability.susAccess);
12591284
1260− if (ASIC_IS_DCE8(rdev)) {
1261− rdev->clock.gpupll_outputfreq =
1285+ if (ASIC_IS_DCE8(rdev))
1286+ rdev->clock.vco_freq =
12621287 le32_to_cpu(firmware_info->info_22.ulGPUPLL_OutputFreq);
1263− if (rdev->clock.gpupll_outputfreq == 0)
1264− rdev->clock.gpupll_outputfreq = 360000; /* 3.6 GHz */
1265− }
1288+ else if (ASIC_IS_DCE5(rdev))
1289+ rdev->clock.vco_freq = rdev->clock.current_dispclk;
1290+ else if (ASIC_IS_DCE41(rdev))
1291+ radeon_atombios_get_dentist_vco_freq(rdev);
1292+ else
1293+ rdev->clock.vco_freq = rdev->clock.current_dispclk;
1294+
1295+ if (rdev->clock.vco_freq == 0)
1296+ rdev->clock.vco_freq = 360000; /* 3.6 GHz */
12661297
12671298 return true;
12681299 }
@@ -1270,14 +1301,6 @@ bool radeon_atom_get_clock_info(struct drm_device *dev) · 1 unmodified line
12701301 return false;
12711302 }
12721303
1273−union igp_info {
1274− struct _ATOM_INTEGRATED_SYSTEM_INFO info;
1275− struct _ATOM_INTEGRATED_SYSTEM_INFO_V2 info_2;
1276− struct _ATOM_INTEGRATED_SYSTEM_INFO_V6 info_6;
1277− struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_7 info_7;
1278− struct _ATOM_INTEGRATED_SYSTEM_INFO_V1_8 info_8;
1279−};
1280−
12811304 bool radeon_atombios_sideport_present(struct radeon_device *rdev)
12821305 {
12831306 struct radeon_mode_info *mode_info = &rdev->mode_info;
drivers/gpu/drm/radeon/radeon_audio.c+13−7
@@ -739,9 +739,6 @@ static void radeon_audio_dp_mode_set(struct drm_encoder *encoder, · 738 unmodified lines
739739 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
740740 struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
741741 struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
742− struct radeon_connector *radeon_connector = to_radeon_connector(connector);
743− struct radeon_connector_atom_dig *dig_connector =
744− radeon_connector->con_priv;
745742
746743 if (!dig || !dig->afmt)
747744 return;
@@ -753,10 +750,7 @@ static void radeon_audio_dp_mode_set(struct drm_encoder *encoder, · 5 unmodified lines
753750 radeon_audio_write_speaker_allocation(encoder);
754751 radeon_audio_write_sad_regs(encoder);
755752 radeon_audio_write_latency_fields(encoder, mode);
756− if (rdev->clock.dp_extclk || ASIC_IS_DCE5(rdev))
757− radeon_audio_set_dto(encoder, rdev->clock.default_dispclk * 10);
758− else
759− radeon_audio_set_dto(encoder, dig_connector->dp_clock);
753+ radeon_audio_set_dto(encoder, rdev->clock.vco_freq * 10);
760754 radeon_audio_set_audio_packet(encoder);
761755 radeon_audio_select_pin(encoder);
762756
@@ -781,3 +775,15 @@ void radeon_audio_dpms(struct drm_encoder *encoder, int mode) · 18 unmodified lines
781775 if (radeon_encoder->audio && radeon_encoder->audio->dpms)
782776 radeon_encoder->audio->dpms(encoder, mode == DRM_MODE_DPMS_ON);
783777 }
778+
779+unsigned int radeon_audio_decode_dfs_div(unsigned int div)
780+{
781+ if (div >= 8 && div < 64)
782+ return (div - 8) * 25 + 200;
783+ else if (div >= 64 && div < 96)
784+ return (div - 64) * 50 + 1600;
785+ else if (div >= 96 && div < 128)
786+ return (div - 96) * 100 + 3200;
787+ else
788+ return 0;
789+}
drivers/gpu/drm/radeon/radeon_audio.h+1−0
@@ -79,5 +79,6 @@ void radeon_audio_fini(struct radeon_device *rdev); · 78 unmodified lines
7979 void radeon_audio_mode_set(struct drm_encoder *encoder,
8080 struct drm_display_mode *mode);
8181 void radeon_audio_dpms(struct drm_encoder *encoder, int mode);
82+unsigned int radeon_audio_decode_dfs_div(unsigned int div);
8283
8384 #endif
drivers/gpu/drm/radeon/radeon_display.c+4−2
@@ -1670,8 +1670,10 @@ int radeon_modeset_init(struct radeon_device *rdev) · 1669 unmodified lines
16701670 /* setup afmt */
16711671 radeon_afmt_init(rdev);
16721672
1673− radeon_fbdev_init(rdev);
1674− drm_kms_helper_poll_init(rdev->ddev);
1673+ if (!list_empty(&rdev->ddev->mode_config.connector_list)) {
1674+ radeon_fbdev_init(rdev);
1675+ drm_kms_helper_poll_init(rdev->ddev);
1676+ }
16751677
16761678 /* do pm late init */
16771679 ret = radeon_pm_late_init(rdev);
drivers/gpu/drm/radeon/radeon_gem.c+1−0
@@ -663,6 +663,7 @@ int radeon_gem_va_ioctl(struct drm_device *dev, void *data, · 662 unmodified lines
663663 bo_va = radeon_vm_bo_find(&fpriv->vm, rbo);
664664 if (!bo_va) {
665665 args->operation = RADEON_VA_RESULT_ERROR;
666+ radeon_bo_unreserve(rbo);
666667 drm_gem_object_unreference_unlocked(gobj);
667668 return -ENOENT;
668669 }
drivers/gpu/drm/radeon/vce_v1_0.c+6−6
@@ -178,12 +178,12 @@ int vce_v1_0_load_fw(struct radeon_device *rdev, uint32_t *data) · 177 unmodified lines
178178 return -EINVAL;
179179 }
180180
181− for (i = 0; i < sign->num; ++i) {
182− if (sign->val[i].chip_id == chip_id)
181+ for (i = 0; i < le32_to_cpu(sign->num); ++i) {
182+ if (le32_to_cpu(sign->val[i].chip_id) == chip_id)
183183 break;
184184 }
185185
186− if (i == sign->num)
186+ if (i == le32_to_cpu(sign->num))
187187 return -EINVAL;
188188
189189 data += (256 - 64) / 4;
@@ -191,18 +191,18 @@ int vce_v1_0_load_fw(struct radeon_device *rdev, uint32_t *data) · 1 unmodified line
191191 data[1] = sign->val[i].nonce[1];
192192 data[2] = sign->val[i].nonce[2];
193193 data[3] = sign->val[i].nonce[3];
194− data[4] = sign->len + 64;
194+ data[4] = cpu_to_le32(le32_to_cpu(sign->len) + 64);
195195
196196 memset(&data[5], 0, 44);
197197 memcpy(&data[16], &sign[1], rdev->vce_fw->size - sizeof(*sign));
198198
199− data += data[4] / 4;
199+ data += le32_to_cpu(data[4]) / 4;
200200 data[0] = sign->val[i].sigval[0];
201201 data[1] = sign->val[i].sigval[1];
202202 data[2] = sign->val[i].sigval[2];
203203 data[3] = sign->val[i].sigval[3];
204204
205− rdev->vce.keyselect = sign->val[i].keyselect;
205+ rdev->vce.keyselect = le32_to_cpu(sign->val[i].keyselect);
206206
207207 return 0;
208208 }
drivers/gpu/drm/rockchip/Makefile+4−4
@@ -2,11 +2,11 @@ · 1 unmodified line
22 # Makefile for the drm device driver. This driver provides support for the
33 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
44
5−rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o rockchip_drm_fbdev.o \
6− rockchip_drm_gem.o
5+rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o \
6+ rockchip_drm_gem.o rockchip_drm_vop.o
7+rockchipdrm-$(CONFIG_DRM_FBDEV_EMULATION) += rockchip_drm_fbdev.o
78
89 obj-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o
910 obj-$(CONFIG_ROCKCHIP_DW_MIPI_DSI) += dw-mipi-dsi.o
1011
11−obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o rockchip_drm_vop.o \
12− rockchip_vop_reg.o
12+obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o rockchip_vop_reg.o
drivers/gpu/drm/rockchip/dw-mipi-dsi.c+2−1
@@ -461,10 +461,11 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi) · 460 unmodified lines
461461
462462 static int dw_mipi_dsi_get_lane_bps(struct dw_mipi_dsi *dsi)
463463 {
464− unsigned int bpp, i, pre;
464+ unsigned int i, pre;
465465 unsigned long mpclk, pllref, tmp;
466466 unsigned int m = 1, n = 1, target_mbps = 1000;
467467 unsigned int max_mbps = dptdin_map[ARRAY_SIZE(dptdin_map) - 1].max_mbps;
468+ int bpp;
468469
469470 bpp = mipi_dsi_pixel_format_to_bpp(dsi->format);
470471 if (bpp < 0) {
drivers/gpu/drm/rockchip/rockchip_drm_drv.c+0−4
@@ -55,14 +55,12 @@ int rockchip_drm_dma_attach_device(struct drm_device *drm_dev, · 54 unmodified lines
5555
5656 return arm_iommu_attach_device(dev, mapping);
5757 }
58−EXPORT_SYMBOL_GPL(rockchip_drm_dma_attach_device);
5958
6059 void rockchip_drm_dma_detach_device(struct drm_device *drm_dev,
6160 struct device *dev)
6261 {
6362 arm_iommu_detach_device(dev);
6463 }
65−EXPORT_SYMBOL_GPL(rockchip_drm_dma_detach_device);
6664
6765 int rockchip_register_crtc_funcs(struct drm_crtc *crtc,
6866 const struct rockchip_crtc_funcs *crtc_funcs)
@@ -77,7 +75,6 @@ int rockchip_register_crtc_funcs(struct drm_crtc *crtc, · 8 unmodified lines
7775
7876 return 0;
7977 }
80−EXPORT_SYMBOL_GPL(rockchip_register_crtc_funcs);
8178
8279 void rockchip_unregister_crtc_funcs(struct drm_crtc *crtc)
8380 {
@@ -89,7 +86,6 @@ void rockchip_unregister_crtc_funcs(struct drm_crtc *crtc) · 5 unmodified lines
8986
9087 priv->crtc_funcs[pipe] = NULL;
9188 }
92−EXPORT_SYMBOL_GPL(rockchip_unregister_crtc_funcs);
9389
9490 static struct drm_crtc *rockchip_crtc_from_pipe(struct drm_device *drm,
9591 int pipe)
drivers/gpu/drm/rockchip/rockchip_drm_fb.c+21−3
@@ -39,7 +39,6 @@ struct drm_gem_object *rockchip_fb_get_gem_obj(struct drm_framebuffer *fb, · 38 unmodified lines
3939
4040 return rk_fb->obj[plane];
4141 }
42−EXPORT_SYMBOL_GPL(rockchip_fb_get_gem_obj);
4342
4443 static void rockchip_drm_fb_destroy(struct drm_framebuffer *fb)
4544 {
@@ -177,8 +176,23 @@ static void rockchip_crtc_wait_for_update(struct drm_crtc *crtc) · 131 unmodified lines
177176 crtc_funcs->wait_for_update(crtc);
178177 }
179178
179+/*
180+ * We can't use drm_atomic_helper_wait_for_vblanks() because rk3288 and rk3066
181+ * have hardware counters for neither vblanks nor scanlines, which results in
182+ * a race where:
183+ * | <-- HW vsync irq and reg take effect
184+ * plane_commit --> |
185+ * get_vblank and wait --> |
186+ * | <-- handle_vblank, vblank->count + 1
187+ * cleanup_fb --> |
188+ * iommu crash --> |
189+ * | <-- HW vsync irq and reg take effect
190+ *
191+ * This function is equivalent but uses rockchip_crtc_wait_for_update() instead
192+ * of waiting for vblank_count to change.
193+ */
180194 static void
181−rockchip_atomic_wait_for_complete(struct drm_atomic_state *old_state)
195+rockchip_atomic_wait_for_complete(struct drm_device *dev, struct drm_atomic_state *old_state)
182196 {
183197 struct drm_crtc_state *old_crtc_state;
184198 struct drm_crtc *crtc;
@@ -194,6 +208,10 @@ rockchip_atomic_wait_for_complete(struct drm_atomic_state *old_state) · 9 unmodified lines
194208 if (!crtc->state->active)
195209 continue;
196210
211+ if (!drm_atomic_helper_framebuffer_changed(dev,
212+ old_state, crtc))
213+ continue;
214+
197215 ret = drm_crtc_vblank_get(crtc);
198216 if (ret != 0)
199217 continue;
@@ -241,7 +259,7 @@ rockchip_atomic_commit_complete(struct rockchip_atomic_commit *commit) · 41 unmodified lines
241259
242260 drm_atomic_helper_commit_planes(dev, state, true);
243261
244− rockchip_atomic_wait_for_complete(state);
262+ rockchip_atomic_wait_for_complete(dev, state);
245263
246264 drm_atomic_helper_cleanup_planes(dev, state);
247265
drivers/gpu/drm/rockchip/rockchip_drm_fbdev.h+11−0
@@ -15,7 +15,18 @@ · 14 unmodified lines
1515 #ifndef _ROCKCHIP_DRM_FBDEV_H
1616 #define _ROCKCHIP_DRM_FBDEV_H
1717
18+#ifdef CONFIG_DRM_FBDEV_EMULATION
1819 int rockchip_drm_fbdev_init(struct drm_device *dev);
1920 void rockchip_drm_fbdev_fini(struct drm_device *dev);
21+#else
22+static inline int rockchip_drm_fbdev_init(struct drm_device *dev)
23+{
24+ return 0;
25+}
26+
27+static inline void rockchip_drm_fbdev_fini(struct drm_device *dev)
28+{
29+}
30+#endif
2031
2132 #endif /* _ROCKCHIP_DRM_FBDEV_H */
drivers/gpu/drm/rockchip/rockchip_drm_gem.c+2−7
@@ -234,13 +234,8 @@ int rockchip_gem_dumb_create(struct drm_file *file_priv, · 233 unmodified lines
234234 /*
235235 * align to 64 bytes since Mali requires it.
236236 */
237− min_pitch = ALIGN(min_pitch, 64);
238−
239− if (args->pitch < min_pitch)
240− args->pitch = min_pitch;
241−
242− if (args->size < args->pitch * args->height)
243− args->size = args->pitch * args->height;
237+ args->pitch = ALIGN(min_pitch, 64);
238+ args->size = args->pitch * args->height;
244239
245240 rk_obj = rockchip_gem_create_with_handle(file_priv, dev, args->size,
246241 &args->handle);
drivers/gpu/drm/rockchip/rockchip_drm_vop.c+9−7
@@ -43,8 +43,8 @@ · 42 unmodified lines
4343
4444 #define REG_SET(x, base, reg, v, mode) \
4545 __REG_SET_##mode(x, base + reg.offset, reg.mask, reg.shift, v)
46−#define REG_SET_MASK(x, base, reg, v, mode) \
47− __REG_SET_##mode(x, base + reg.offset, reg.mask, reg.shift, v)
46+#define REG_SET_MASK(x, base, reg, mask, v, mode) \
47+ __REG_SET_##mode(x, base + reg.offset, mask, reg.shift, v)
4848
4949 #define VOP_WIN_SET(x, win, name, v) \
5050 REG_SET(x, win->base, win->phy->name, v, RELAXED)
@@ -58,16 +58,18 @@ · 7 unmodified lines
5858 #define VOP_INTR_GET(vop, name) \
5959 vop_read_reg(vop, 0, &vop->data->ctrl->name)
6060
61−#define VOP_INTR_SET(vop, name, v) \
62− REG_SET(vop, 0, vop->data->intr->name, v, NORMAL)
61+#define VOP_INTR_SET(vop, name, mask, v) \
62+ REG_SET_MASK(vop, 0, vop->data->intr->name, mask, v, NORMAL)
6363 #define VOP_INTR_SET_TYPE(vop, name, type, v) \
6464 do { \
65− int i, reg = 0; \
65+ int i, reg = 0, mask = 0; \
6666 for (i = 0; i < vop->data->intr->nintrs; i++) { \
67− if (vop->data->intr->intrs[i] & type) \
67+ if (vop->data->intr->intrs[i] & type) { \
6868 reg |= (v) << i; \
69+ mask |= 1 << i; \
70+ } \
6971 } \
70− VOP_INTR_SET(vop, name, reg); \
72+ VOP_INTR_SET(vop, name, mask, reg); \
7173 } while (0)
7274 #define VOP_INTR_GET_TYPE(vop, name, type) \
7375 vop_get_intr_type(vop, &vop->data->intr->name, type)
drivers/gpu/drm/vc4/vc4_v3d.c+7−10
@@ -144,19 +144,16 @@ int vc4_v3d_debugfs_ident(struct seq_file *m, void *unused) · 143 unmodified lines
144144 }
145145 #endif /* CONFIG_DEBUG_FS */
146146
147−/*
148− * Asks the firmware to turn on power to the V3D engine.
149− *
150− * This may be doable with just the clocks interface, though this
151− * packet does some other register setup from the firmware, too.
152− */
153147 int
154148 vc4_v3d_set_power(struct vc4_dev *vc4, bool on)
155149 {
156− if (on)
157− return pm_generic_poweroff(&vc4->v3d->pdev->dev);
158− else
159− return pm_generic_resume(&vc4->v3d->pdev->dev);
150+ /* XXX: This interface is needed for GPU reset, and the way to
151+ * do it is to turn our power domain off and back on. We
152+ * can't just reset from within the driver, because the reset
153+ * bits are in the power domain's register area, and get set
154+ * during the poweron process.
155+ */
156+ return 0;
160157 }
161158
162159 static void vc4_v3d_init_hw(struct drm_device *dev)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c+7−0
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 *
2626 **************************************************************************/
2727 #include <linux/module.h>
28+#include <linux/console.h>
2829
2930 #include <drm/drmP.h>
3031 #include "vmwgfx_drv.h"
@@ -1538,6 +1539,12 @@ static int vmw_probe(struct pci_dev *pdev, const struct pci_device_id *ent) · 1507 unmodified lines
15381539 static int __init vmwgfx_init(void)
15391540 {
15401541 int ret;
1542+
1543+#ifdef CONFIG_VGA_CONSOLE
1544+ if (vgacon_text_force())
1545+ return -EINVAL;
1546+#endif
1547+
15411548 ret = drm_pci_init(&driver, &vmw_pci_driver);
15421549 if (ret)
15431550 DRM_ERROR("Failed initializing DRM.\n");
drivers/hwmon/dell-smm-hwmon.c+11−0
@@ -930,6 +930,17 @@ static struct dmi_system_id i8k_dmi_table[] __initdata = { · 929 unmodified lines
930930 MODULE_DEVICE_TABLE(dmi, i8k_dmi_table);
931931
932932 static struct dmi_system_id i8k_blacklist_dmi_table[] __initdata = {
933+ {
934+ /*
935+ * CPU fan speed going up and down on Dell Studio XPS 8000
936+ * for unknown reasons.
937+ */
938+ .ident = "Dell Studio XPS 8000",
939+ .matches = {
940+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
941+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Studio XPS 8000"),
942+ },
943+ },
933944 {
934945 /*
935946 * CPU fan speed going up and down on Dell Studio XPS 8100
drivers/hwmon/fam15h_power.c+9−1
@@ -90,7 +90,15 @@ static ssize_t show_power(struct device *dev, · 89 unmodified lines
9090 pci_bus_read_config_dword(f4->bus, PCI_DEVFN(PCI_SLOT(f4->devfn), 5),
9191 REG_TDP_LIMIT3, &val);
9292
93− tdp_limit = val >> 16;
93+ /*
94+ * On Carrizo and later platforms, ApmTdpLimit bit field
95+ * is extended to 16:31 from 16:28.
96+ */
97+ if (boot_cpu_data.x86 == 0x15 && boot_cpu_data.x86_model >= 0x60)
98+ tdp_limit = val >> 16;
99+ else
100+ tdp_limit = (val >> 16) & 0x1fff;
101+
94102 curr_pwr_watts = ((u64)(tdp_limit +
95103 data->base_tdp)) << running_avg_range;
96104 curr_pwr_watts -= running_avg_capture;
drivers/i2c/busses/i2c-designware-core.c+2−1
@@ -874,7 +874,8 @@ int i2c_dw_probe(struct dw_i2c_dev *dev) · 873 unmodified lines
874874 i2c_set_adapdata(adap, dev);
875875
876876 i2c_dw_disable_int(dev);
877− r = devm_request_irq(dev->dev, dev->irq, i2c_dw_isr, IRQF_SHARED,
877+ r = devm_request_irq(dev->dev, dev->irq, i2c_dw_isr,
878+ IRQF_SHARED | IRQF_COND_SUSPEND,
878879 dev_name(dev->dev), dev);
879880 if (r) {
880881 dev_err(dev->dev, "failure requesting irq %i: %d\n",
drivers/i2c/busses/i2c-piix4.c+21−29
@@ -137,10 +137,11 @@ static const struct dmi_system_id piix4_dmi_ibm[] = { · 136 unmodified lines
137137 };
138138
139139 /* SB800 globals */
140+static DEFINE_MUTEX(piix4_mutex_sb800);
140141 static const char *piix4_main_port_names_sb800[PIIX4_MAX_ADAPTERS] = {
141− "SDA0", "SDA2", "SDA3", "SDA4"
142+ " port 0", " port 2", " port 3", " port 4"
142143 };
143−static const char *piix4_aux_port_name_sb800 = "SDA1";
144+static const char *piix4_aux_port_name_sb800 = " port 1";
144145
145146 struct i2c_piix4_adapdata {
146147 unsigned short smba;
@@ -148,7 +149,6 @@ struct i2c_piix4_adapdata { · 1 unmodified line
148149 /* SB800 */
149150 bool sb800_main;
150151 unsigned short port;
151− struct mutex *mutex;
152152 };
153153
154154 static int piix4_setup(struct pci_dev *PIIX4_dev,
@@ -275,10 +275,12 @@ static int piix4_setup_sb800(struct pci_dev *PIIX4_dev, · 120 unmodified lines
275275 else
276276 smb_en = (aux) ? 0x28 : 0x2c;
277277
278+ mutex_lock(&piix4_mutex_sb800);
278279 outb_p(smb_en, SB800_PIIX4_SMB_IDX);
279280 smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1);
280281 outb_p(smb_en + 1, SB800_PIIX4_SMB_IDX);
281282 smba_en_hi = inb_p(SB800_PIIX4_SMB_IDX + 1);
283+ mutex_unlock(&piix4_mutex_sb800);
282284
283285 if (!smb_en) {
284286 smb_en_status = smba_en_lo & 0x10;
@@ -559,7 +561,7 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, · 274 unmodified lines
559561 u8 port;
560562 int retval;
561563
562− mutex_lock(adapdata->mutex);
564+ mutex_lock(&piix4_mutex_sb800);
563565
564566 outb_p(SB800_PIIX4_PORT_IDX, SB800_PIIX4_SMB_IDX);
565567 smba_en_lo = inb_p(SB800_PIIX4_SMB_IDX + 1);
@@ -574,7 +576,7 @@ static s32 piix4_access_sb800(struct i2c_adapter *adap, u16 addr, · 8 unmodified lines
574576
575577 outb_p(smba_en_lo, SB800_PIIX4_SMB_IDX + 1);
576578
577− mutex_unlock(adapdata->mutex);
579+ mutex_unlock(&piix4_mutex_sb800);
578580
579581 return retval;
580582 }
@@ -625,6 +627,7 @@ static struct i2c_adapter *piix4_main_adapters[PIIX4_MAX_ADAPTERS]; · 44 unmodified lines
625627 static struct i2c_adapter *piix4_aux_adapter;
626628
627629 static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba,
630+ bool sb800_main, unsigned short port,
628631 const char *name, struct i2c_adapter **padap)
629632 {
630633 struct i2c_adapter *adap;
@@ -639,7 +642,8 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, · 8 unmodified lines
639642
640643 adap->owner = THIS_MODULE;
641644 adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
642− adap->algo = &smbus_algorithm;
645+ adap->algo = sb800_main ? &piix4_smbus_algorithm_sb800
646+ : &smbus_algorithm;
643647
644648 adapdata = kzalloc(sizeof(*adapdata), GFP_KERNEL);
645649 if (adapdata == NULL) {
@@ -649,12 +653,14 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, · 3 unmodified lines
649653 }
650654
651655 adapdata->smba = smba;
656+ adapdata->sb800_main = sb800_main;
657+ adapdata->port = port;
652658
653659 /* set up the sysfs linkage to our parent device */
654660 adap->dev.parent = &dev->dev;
655661
656662 snprintf(adap->name, sizeof(adap->name),
657− "SMBus PIIX4 adapter %s at %04x", name, smba);
663+ "SMBus PIIX4 adapter%s at %04x", name, smba);
658664
659665 i2c_set_adapdata(adap, adapdata);
660666
@@ -673,30 +679,16 @@ static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, · 12 unmodified lines
673679
674680 static int piix4_add_adapters_sb800(struct pci_dev *dev, unsigned short smba)
675681 {
676− struct mutex *mutex;
677682 struct i2c_piix4_adapdata *adapdata;
678683 int port;
679684 int retval;
680685
681− mutex = kzalloc(sizeof(*mutex), GFP_KERNEL);
682− if (mutex == NULL)
683− return -ENOMEM;
684−
685− mutex_init(mutex);
686−
687686 for (port = 0; port < PIIX4_MAX_ADAPTERS; port++) {
688− retval = piix4_add_adapter(dev, smba,
687+ retval = piix4_add_adapter(dev, smba, true, port,
689688 piix4_main_port_names_sb800[port],
690689 &piix4_main_adapters[port]);
691690 if (retval < 0)
692691 goto error;
693−
694− piix4_main_adapters[port]->algo = &piix4_smbus_algorithm_sb800;
695−
696− adapdata = i2c_get_adapdata(piix4_main_adapters[port]);
697− adapdata->sb800_main = true;
698− adapdata->port = port;
699− adapdata->mutex = mutex;
700692 }
701693
702694 return retval;
@@ -714,19 +706,20 @@ error: · 11 unmodified lines
714706 }
715707 }
716708
717− kfree(mutex);
718−
719709 return retval;
720710 }
721711
722712 static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
723713 {
724714 int retval;
715+ bool is_sb800 = false;
725716
726717 if ((dev->vendor == PCI_VENDOR_ID_ATI &&
727718 dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS &&
728719 dev->revision >= 0x40) ||
729720 dev->vendor == PCI_VENDOR_ID_AMD) {
721+ is_sb800 = true;
722+
730723 if (!request_region(SB800_PIIX4_SMB_IDX, 2, "smba_idx")) {
731724 dev_err(&dev->dev,
732725 "SMBus base address index region 0x%x already in use!\n",
@@ -756,7 +749,7 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id) · 23 unmodified lines
756749 return retval;
757750
758751 /* Try to register main SMBus adapter, give up if we can't */
759− retval = piix4_add_adapter(dev, retval, "main",
752+ retval = piix4_add_adapter(dev, retval, false, 0, "",
760753 &piix4_main_adapters[0]);
761754 if (retval < 0)
762755 return retval;
@@ -783,7 +776,8 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id) · 20 unmodified lines
783776 if (retval > 0) {
784777 /* Try to add the aux adapter if it exists,
785778 * piix4_add_adapter will clean up if this fails */
786− piix4_add_adapter(dev, retval, piix4_aux_port_name_sb800,
779+ piix4_add_adapter(dev, retval, false, 0,
780+ is_sb800 ? piix4_aux_port_name_sb800 : "",
787781 &piix4_aux_adapter);
788782 }
789783
@@ -798,10 +792,8 @@ static void piix4_adap_remove(struct i2c_adapter *adap) · 8 unmodified lines
798792 i2c_del_adapter(adap);
799793 if (adapdata->port == 0) {
800794 release_region(adapdata->smba, SMBIOSIZE);
801− if (adapdata->sb800_main) {
802− kfree(adapdata->mutex);
795+ if (adapdata->sb800_main)
803796 release_region(SB800_PIIX4_SMB_IDX, 2);
804− }
805797 }
806798 kfree(adapdata);
807799 kfree(adap);
drivers/iio/imu/adis_buffer.c+1−1
@@ -43,7 +43,7 @@ int adis_update_scan_mode(struct iio_dev *indio_dev, · 42 unmodified lines
4343 return -ENOMEM;
4444
4545 rx = adis->buffer;
46− tx = rx + indio_dev->scan_bytes;
46+ tx = rx + scan_count;
4747
4848 spi_message_init(&adis->msg);
4949
drivers/iommu/amd_iommu.c+1−1
@@ -2049,7 +2049,7 @@ static void do_attach(struct iommu_dev_data *dev_data, · 2048 unmodified lines
20492049 /* Update device table */
20502050 set_dte_entry(dev_data->devid, domain, ats);
20512051 if (alias != dev_data->devid)
2052− set_dte_entry(dev_data->devid, domain, ats);
2052+ set_dte_entry(alias, domain, ats);
20532053
20542054 device_flush_dte(dev_data);
20552055 }
drivers/iommu/intel-iommu.c+1−1
@@ -1489,7 +1489,7 @@ static void iommu_disable_dev_iotlb(struct device_domain_info *info) · 1488 unmodified lines
14891489 {
14901490 struct pci_dev *pdev;
14911491
1492− if (dev_is_pci(info->dev))
1492+ if (!dev_is_pci(info->dev))
14931493 return;
14941494
14951495 pdev = to_pci_dev(info->dev);
drivers/iommu/io-pgtable-arm.c+1−0
@@ -25,6 +25,7 @@ · 24 unmodified lines
2525 #include <linux/sizes.h>
2626 #include <linux/slab.h>
2727 #include <linux/types.h>
28+#include <linux/dma-mapping.h>
2829
2930 #include <asm/barrier.h>
3031
drivers/irqchip/Kconfig+1−0
@@ -159,6 +159,7 @@ config TB10X_IRQC · 158 unmodified lines
159159 config TS4800_IRQ
160160 tristate "TS-4800 IRQ controller"
161161 select IRQ_DOMAIN
162+ depends on HAS_IOMEM
162163 help
163164 Support for the TS-4800 FPGA IRQ controller
164165
drivers/irqchip/irq-atmel-aic-common.c+1−1
@@ -86,7 +86,7 @@ int aic_common_set_priority(int priority, unsigned *val) · 85 unmodified lines
8686 priority > AT91_AIC_IRQ_MAX_PRIORITY)
8787 return -EINVAL;
8888
89− *val &= AT91_AIC_PRIOR;
89+ *val &= ~AT91_AIC_PRIOR;
9090 *val |= priority;
9191
9292 return 0;
drivers/irqchip/irq-gic-v3-its.c+6−2
@@ -875,6 +875,7 @@ static int its_alloc_tables(const char *node_name, struct its_node *its) · 874 unmodified lines
875875 }
876876
877877 alloc_size = (1 << order) * PAGE_SIZE;
878+retry_alloc_baser:
878879 alloc_pages = (alloc_size / psz);
879880 if (alloc_pages > GITS_BASER_PAGES_MAX) {
880881 alloc_pages = GITS_BASER_PAGES_MAX;
@@ -938,13 +939,16 @@ retry_baser: · 57 unmodified lines
938939 * size and retry. If we reach 4K, then
939940 * something is horribly wrong...
940941 */
942+ free_pages((unsigned long)base, order);
943+ its->tables[i] = NULL;
944+
941945 switch (psz) {
942946 case SZ_16K:
943947 psz = SZ_4K;
944− goto retry_baser;
948+ goto retry_alloc_baser;
945949 case SZ_64K:
946950 psz = SZ_16K;
947− goto retry_baser;
951+ goto retry_alloc_baser;
948952 }
949953 }
950954
drivers/irqchip/irq-mxs.c+1−0
@@ -241,6 +241,7 @@ static int __init asm9260_of_init(struct device_node *np, · 240 unmodified lines
241241 writel(0, icoll_priv.intr + i);
242242
243243 icoll_add_domain(np, ASM9260_NUM_IRQS);
244+ set_handle_irq(icoll_handle_irq);
244245
245246 return 0;
246247 }
drivers/irqchip/irq-s3c24xx.c+1−1
@@ -605,7 +605,7 @@ err: · 604 unmodified lines
605605 return ERR_PTR(ret);
606606 }
607607
608−static struct s3c_irq_data init_eint[32] = {
608+static struct s3c_irq_data __maybe_unused init_eint[32] = {
609609 { .type = S3C_IRQTYPE_NONE, }, /* reserved */
610610 { .type = S3C_IRQTYPE_NONE, }, /* reserved */
611611 { .type = S3C_IRQTYPE_NONE, }, /* reserved */
drivers/of/irq.c+3−15
@@ -679,18 +679,6 @@ u32 of_msi_map_rid(struct device *dev, struct device_node *msi_np, u32 rid_in) · 678 unmodified lines
679679 return __of_msi_map_rid(dev, &msi_np, rid_in);
680680 }
681681
682−static struct irq_domain *__of_get_msi_domain(struct device_node *np,
683− enum irq_domain_bus_token token)
684−{
685− struct irq_domain *d;
686−
687− d = irq_find_matching_host(np, token);
688− if (!d)
689− d = irq_find_host(np);
690−
691− return d;
692−}
693−
694682 /**
695683 * of_msi_map_get_device_domain - Use msi-map to find the relevant MSI domain
696684 * @dev: device for which the mapping is to be done.
@@ -706,7 +694,7 @@ struct irq_domain *of_msi_map_get_device_domain(struct device *dev, u32 rid) · 9 unmodified lines
706694 struct device_node *np = NULL;
707695
708696 __of_msi_map_rid(dev, &np, rid);
709− return __of_get_msi_domain(np, DOMAIN_BUS_PCI_MSI);
697+ return irq_find_matching_host(np, DOMAIN_BUS_PCI_MSI);
710698 }
711699
712700 /**
@@ -730,7 +718,7 @@ struct irq_domain *of_msi_get_domain(struct device *dev, · 17 unmodified lines
730718 /* Check for a single msi-parent property */
731719 msi_np = of_parse_phandle(np, "msi-parent", 0);
732720 if (msi_np && !of_property_read_bool(msi_np, "#msi-cells")) {
733− d = __of_get_msi_domain(msi_np, token);
721+ d = irq_find_matching_host(msi_np, token);
734722 if (!d)
735723 of_node_put(msi_np);
736724 return d;
@@ -744,7 +732,7 @@ struct irq_domain *of_msi_get_domain(struct device *dev, · 7 unmodified lines
744732 while (!of_parse_phandle_with_args(np, "msi-parent",
745733 "#msi-cells",
746734 index, &args)) {
747− d = __of_get_msi_domain(args.np, token);
735+ d = irq_find_matching_host(args.np, token);
748736 if (d)
749737 return d;
750738
drivers/pci/hotplug/acpiphp_glue.c+3−1
@@ -953,8 +953,10 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot) · 952 unmodified lines
953953 {
954954 pci_lock_rescan_remove();
955955
956− if (slot->flags & SLOT_IS_GOING_AWAY)
956+ if (slot->flags & SLOT_IS_GOING_AWAY) {
957+ pci_unlock_rescan_remove();
957958 return -ENODEV;
959+ }
958960
959961 /* configure all functions */
960962 if (!(slot->flags & SLOT_ENABLED))
drivers/s390/cio/chp.c+8−13
@@ -139,11 +139,11 @@ static ssize_t chp_measurement_chars_read(struct file *filp, · 138 unmodified lines
139139
140140 device = container_of(kobj, struct device, kobj);
141141 chp = to_channelpath(device);
142− if (!chp->cmg_chars)
142+ if (chp->cmg == -1)
143143 return 0;
144144
145− return memory_read_from_buffer(buf, count, &off,
146− chp->cmg_chars, sizeof(struct cmg_chars));
145+ return memory_read_from_buffer(buf, count, &off, &chp->cmg_chars,
146+ sizeof(chp->cmg_chars));
147147 }
148148
149149 static struct bin_attribute chp_measurement_chars_attr = {
@@ -416,7 +416,8 @@ static void chp_release(struct device *dev) · 266 unmodified lines
416416 * chp_update_desc - update channel-path description
417417 * @chp - channel-path
418418 *
419− * Update the channel-path description of the specified channel-path.
419+ * Update the channel-path description of the specified channel-path
420+ * including channel measurement related information.
420421 * Return zero on success, non-zero otherwise.
421422 */
422423 int chp_update_desc(struct channel_path *chp)
@@ -428,8 +429,10 @@ int chp_update_desc(struct channel_path *chp) · 5 unmodified lines
428429 return rc;
429430
430431 rc = chsc_determine_fmt1_channel_path_desc(chp->chpid, &chp->desc_fmt1);
432+ if (rc)
433+ return rc;
431434
432− return rc;
435+ return chsc_get_channel_measurement_chars(chp);
433436 }
434437
435438 /**
@@ -466,14 +469,6 @@ int chp_new(struct chp_id chpid) · 30 unmodified lines
466469 ret = -ENODEV;
467470 goto out_free;
468471 }
469− /* Get channel-measurement characteristics. */
470− if (css_chsc_characteristics.scmc && css_chsc_characteristics.secm) {
471− ret = chsc_get_channel_measurement_chars(chp);
472− if (ret)
473− goto out_free;
474− } else {
475− chp->cmg = -1;
476− }
477472 dev_set_name(&chp->dev, "chp%x.%02x", chpid.cssid, chpid.id);
478473
479474 /* make it known to the system */
drivers/s390/cio/chp.h+1−1
@@ -48,7 +48,7 @@ struct channel_path { · 47 unmodified lines
4848 /* Channel-measurement related stuff: */
4949 int cmg;
5050 int shared;
51− void *cmg_chars;
51+ struct cmg_chars cmg_chars;
5252 };
5353
5454 /* Return channel_path struct for given chpid. */
drivers/s390/cio/chsc.c+24−19
@@ -14,6 +14,7 @@ · 13 unmodified lines
1414 #include <linux/slab.h>
1515 #include <linux/init.h>
1616 #include <linux/device.h>
17+#include <linux/mutex.h>
1718 #include <linux/pci.h>
1819
1920 #include <asm/cio.h>
@@ -224,8 +225,9 @@ out_unreg: · 204 unmodified lines
224225
225226 void chsc_chp_offline(struct chp_id chpid)
226227 {
227− char dbf_txt[15];
228+ struct channel_path *chp = chpid_to_chp(chpid);
228229 struct chp_link link;
230+ char dbf_txt[15];
229231
230232 sprintf(dbf_txt, "chpr%x.%02x", chpid.cssid, chpid.id);
231233 CIO_TRACE_EVENT(2, dbf_txt);
@@ -236,6 +238,11 @@ void chsc_chp_offline(struct chp_id chpid) · 4 unmodified lines
236238 link.chpid = chpid;
237239 /* Wait until previous actions have settled. */
238240 css_wait_for_slow_path();
241+
242+ mutex_lock(&chp->lock);
243+ chp_update_desc(chp);
244+ mutex_unlock(&chp->lock);
245+
239246 for_each_subchannel_staged(s390_subchannel_remove_chpid, NULL, &link);
240247 }
241248
@@ -690,8 +697,9 @@ static void chsc_process_crw(struct crw *crw0, struct crw *crw1, int overflow) · 448 unmodified lines
690697
691698 void chsc_chp_online(struct chp_id chpid)
692699 {
693− char dbf_txt[15];
700+ struct channel_path *chp = chpid_to_chp(chpid);
694701 struct chp_link link;
702+ char dbf_txt[15];
695703
696704 sprintf(dbf_txt, "cadd%x.%02x", chpid.cssid, chpid.id);
697705 CIO_TRACE_EVENT(2, dbf_txt);
@@ -701,6 +709,11 @@ void chsc_chp_online(struct chp_id chpid) · 3 unmodified lines
701709 link.chpid = chpid;
702710 /* Wait until previous actions have settled. */
703711 css_wait_for_slow_path();
712+
713+ mutex_lock(&chp->lock);
714+ chp_update_desc(chp);
715+ mutex_unlock(&chp->lock);
716+
704717 for_each_subchannel_staged(__s390_process_res_acc, NULL,
705718 &link);
706719 css_schedule_reprobe();
@@ -967,22 +980,19 @@ static void · 260 unmodified lines
967980 chsc_initialize_cmg_chars(struct channel_path *chp, u8 cmcv,
968981 struct cmg_chars *chars)
969982 {
970− struct cmg_chars *cmg_chars;
971983 int i, mask;
972984
973− cmg_chars = chp->cmg_chars;
974985 for (i = 0; i < NR_MEASUREMENT_CHARS; i++) {
975986 mask = 0x80 >> (i + 3);
976987 if (cmcv & mask)
977− cmg_chars->values[i] = chars->values[i];
988+ chp->cmg_chars.values[i] = chars->values[i];
978989 else
979− cmg_chars->values[i] = 0;
990+ chp->cmg_chars.values[i] = 0;
980991 }
981992 }
982993
983994 int chsc_get_channel_measurement_chars(struct channel_path *chp)
984995 {
985− struct cmg_chars *cmg_chars;
986996 int ccode, ret;
987997
988998 struct {
@@ -1006,10 +1016,11 @@ int chsc_get_channel_measurement_chars(struct channel_path *chp) · 17 unmodified lines
10061016 u32 data[NR_MEASUREMENT_CHARS];
10071017 } __attribute__ ((packed)) *scmc_area;
10081018
1009− chp->cmg_chars = NULL;
1010− cmg_chars = kmalloc(sizeof(*cmg_chars), GFP_KERNEL);
1011− if (!cmg_chars)
1012− return -ENOMEM;
1019+ chp->shared = -1;
1020+ chp->cmg = -1;
1021+
1022+ if (!css_chsc_characteristics.scmc || !css_chsc_characteristics.secm)
1023+ return 0;
10131024
10141025 spin_lock_irq(&chsc_page_lock);
10151026 memset(chsc_page, 0, PAGE_SIZE);
@@ -1031,25 +1042,19 @@ int chsc_get_channel_measurement_chars(struct channel_path *chp) · 15 unmodified lines
10311042 scmc_area->response.code);
10321043 goto out;
10331044 }
1034− if (scmc_area->not_valid) {
1035− chp->cmg = -1;
1036− chp->shared = -1;
1045+ if (scmc_area->not_valid)
10371046 goto out;
1038− }
1047+
10391048 chp->cmg = scmc_area->cmg;
10401049 chp->shared = scmc_area->shared;
10411050 if (chp->cmg != 2 && chp->cmg != 3) {
10421051 /* No cmg-dependent data. */
10431052 goto out;
10441053 }
1045− chp->cmg_chars = cmg_chars;
10461054 chsc_initialize_cmg_chars(chp, scmc_area->cmcv,
10471055 (struct cmg_chars *) &scmc_area->data);
10481056 out:
10491057 spin_unlock_irq(&chsc_page_lock);
1050− if (!chp->cmg_chars)
1051− kfree(cmg_chars);
1052−
10531058 return ret;
10541059 }
10551060
drivers/s390/crypto/zcrypt_error.h+9−6
@@ -112,9 +112,10 @@ static inline int convert_error(struct zcrypt_device *zdev, · 111 unmodified lines
112112 atomic_set(&zcrypt_rescan_req, 1);
113113 zdev->online = 0;
114114 pr_err("Cryptographic device %x failed and was set offline\n",
115− zdev->ap_dev->qid);
115+ AP_QID_DEVICE(zdev->ap_dev->qid));
116116 ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d",
117− zdev->ap_dev->qid, zdev->online, ehdr->reply_code);
117+ AP_QID_DEVICE(zdev->ap_dev->qid), zdev->online,
118+ ehdr->reply_code);
118119 return -EAGAIN;
119120 case REP82_ERROR_TRANSPORT_FAIL:
120121 case REP82_ERROR_MACHINE_FAILURE:
@@ -123,16 +124,18 @@ static inline int convert_error(struct zcrypt_device *zdev, · 2 unmodified lines
123124 atomic_set(&zcrypt_rescan_req, 1);
124125 zdev->online = 0;
125126 pr_err("Cryptographic device %x failed and was set offline\n",
126− zdev->ap_dev->qid);
127+ AP_QID_DEVICE(zdev->ap_dev->qid));
127128 ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d",
128− zdev->ap_dev->qid, zdev->online, ehdr->reply_code);
129+ AP_QID_DEVICE(zdev->ap_dev->qid), zdev->online,
130+ ehdr->reply_code);
129131 return -EAGAIN;
130132 default:
131133 zdev->online = 0;
132134 pr_err("Cryptographic device %x failed and was set offline\n",
133− zdev->ap_dev->qid);
135+ AP_QID_DEVICE(zdev->ap_dev->qid));
134136 ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d",
135− zdev->ap_dev->qid, zdev->online, ehdr->reply_code);
137+ AP_QID_DEVICE(zdev->ap_dev->qid), zdev->online,
138+ ehdr->reply_code);
136139 return -EAGAIN; /* repeat the request on a different device. */
137140 }
138141 }
drivers/s390/crypto/zcrypt_msgtype50.c+5−4
@@ -336,9 +336,10 @@ static int convert_type80(struct zcrypt_device *zdev, · 335 unmodified lines
336336 /* The result is too short, the CEX2A card may not do that.. */
337337 zdev->online = 0;
338338 pr_err("Cryptographic device %x failed and was set offline\n",
339− zdev->ap_dev->qid);
339+ AP_QID_DEVICE(zdev->ap_dev->qid));
340340 ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d",
341− zdev->ap_dev->qid, zdev->online, t80h->code);
341+ AP_QID_DEVICE(zdev->ap_dev->qid),
342+ zdev->online, t80h->code);
342343
343344 return -EAGAIN; /* repeat the request on a different device. */
344345 }
@@ -368,9 +369,9 @@ static int convert_response(struct zcrypt_device *zdev, · 23 unmodified lines
368369 default: /* Unknown response type, this should NEVER EVER happen */
369370 zdev->online = 0;
370371 pr_err("Cryptographic device %x failed and was set offline\n",
371− zdev->ap_dev->qid);
372+ AP_QID_DEVICE(zdev->ap_dev->qid));
372373 ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail",
373− zdev->ap_dev->qid, zdev->online);
374+ AP_QID_DEVICE(zdev->ap_dev->qid), zdev->online);
374375 return -EAGAIN; /* repeat the request on a different device. */
375376 }
376377 }
drivers/s390/crypto/zcrypt_msgtype6.c+10−10
@@ -572,9 +572,9 @@ static int convert_type86_ica(struct zcrypt_device *zdev, · 571 unmodified lines
572572 return -EINVAL;
573573 zdev->online = 0;
574574 pr_err("Cryptographic device %x failed and was set offline\n",
575− zdev->ap_dev->qid);
575+ AP_QID_DEVICE(zdev->ap_dev->qid));
576576 ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%drc%d",
577− zdev->ap_dev->qid, zdev->online,
577+ AP_QID_DEVICE(zdev->ap_dev->qid), zdev->online,
578578 msg->hdr.reply_code);
579579 return -EAGAIN; /* repeat the request on a different device. */
580580 }
@@ -715,9 +715,9 @@ static int convert_response_ica(struct zcrypt_device *zdev, · 134 unmodified lines
715715 default: /* Unknown response type, this should NEVER EVER happen */
716716 zdev->online = 0;
717717 pr_err("Cryptographic device %x failed and was set offline\n",
718− zdev->ap_dev->qid);
718+ AP_QID_DEVICE(zdev->ap_dev->qid));
719719 ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail",
720− zdev->ap_dev->qid, zdev->online);
720+ AP_QID_DEVICE(zdev->ap_dev->qid), zdev->online);
721721 return -EAGAIN; /* repeat the request on a different device. */
722722 }
723723 }
@@ -747,9 +747,9 @@ static int convert_response_xcrb(struct zcrypt_device *zdev, · 23 unmodified lines
747747 xcRB->status = 0x0008044DL; /* HDD_InvalidParm */
748748 zdev->online = 0;
749749 pr_err("Cryptographic device %x failed and was set offline\n",
750− zdev->ap_dev->qid);
750+ AP_QID_DEVICE(zdev->ap_dev->qid));
751751 ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail",
752− zdev->ap_dev->qid, zdev->online);
752+ AP_QID_DEVICE(zdev->ap_dev->qid), zdev->online);
753753 return -EAGAIN; /* repeat the request on a different device. */
754754 }
755755 }
@@ -773,9 +773,9 @@ static int convert_response_ep11_xcrb(struct zcrypt_device *zdev, · 17 unmodified lines
773773 default: /* Unknown response type, this should NEVER EVER happen */
774774 zdev->online = 0;
775775 pr_err("Cryptographic device %x failed and was set offline\n",
776− zdev->ap_dev->qid);
776+ AP_QID_DEVICE(zdev->ap_dev->qid));
777777 ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail",
778− zdev->ap_dev->qid, zdev->online);
778+ AP_QID_DEVICE(zdev->ap_dev->qid), zdev->online);
779779 return -EAGAIN; /* repeat the request on a different device. */
780780 }
781781 }
@@ -800,9 +800,9 @@ static int convert_response_rng(struct zcrypt_device *zdev, · 18 unmodified lines
800800 default: /* Unknown response type, this should NEVER EVER happen */
801801 zdev->online = 0;
802802 pr_err("Cryptographic device %x failed and was set offline\n",
803− zdev->ap_dev->qid);
803+ AP_QID_DEVICE(zdev->ap_dev->qid));
804804 ZCRYPT_DBF_DEV(DBF_ERR, zdev, "dev%04xo%dfail",
805− zdev->ap_dev->qid, zdev->online);
805+ AP_QID_DEVICE(zdev->ap_dev->qid), zdev->online);
806806 return -EAGAIN; /* repeat the request on a different device. */
807807 }
808808 }
drivers/scsi/hisi_sas/Kconfig+2−0
@@ -1,5 +1,7 @@
11 config SCSI_HISI_SAS
22 tristate "HiSilicon SAS"
3+ depends on HAS_DMA
4+ depends on ARM64 || COMPILE_TEST
35 select SCSI_SAS_LIBSAS
46 select BLK_DEV_INTEGRITY
57 help
drivers/scsi/sd.c+6−3
@@ -2893,7 +2893,7 @@ static int sd_revalidate_disk(struct gendisk *disk) · 2892 unmodified lines
28932893 sdkp->opt_xfer_blocks <= SD_DEF_XFER_BLOCKS &&
28942894 sdkp->opt_xfer_blocks * sdp->sector_size >= PAGE_CACHE_SIZE)
28952895 rw_max = q->limits.io_opt =
2896− logical_to_sectors(sdp, sdkp->opt_xfer_blocks);
2896+ sdkp->opt_xfer_blocks * sdp->sector_size;
28972897 else
28982898 rw_max = BLK_DEF_MAX_SECTORS;
28992899
@@ -3268,8 +3268,8 @@ static int sd_suspend_common(struct device *dev, bool ignore_stop_errors) · 368 unmodified lines
32683268 struct scsi_disk *sdkp = dev_get_drvdata(dev);
32693269 int ret = 0;
32703270
3271− if (!sdkp)
3272− return 0; /* this can happen */
3271+ if (!sdkp) /* E.g.: runtime suspend following sd_remove() */
3272+ return 0;
32733273
32743274 if (sdkp->WCE && sdkp->media_present) {
32753275 sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
@@ -3308,6 +3308,9 @@ static int sd_resume(struct device *dev) · 32 unmodified lines
33083308 {
33093309 struct scsi_disk *sdkp = dev_get_drvdata(dev);
33103310
3311+ if (!sdkp) /* E.g.: runtime resume at the start of sd_probe() */
3312+ return 0;
3313+
33113314 if (!sdkp->device->manage_start_stop)
33123315 return 0;
33133316
drivers/scsi/sr.c+4−0
@@ -144,6 +144,9 @@ static int sr_runtime_suspend(struct device *dev) · 143 unmodified lines
144144 {
145145 struct scsi_cd *cd = dev_get_drvdata(dev);
146146
147+ if (!cd) /* E.g.: runtime suspend following sr_remove() */
148+ return 0;
149+
147150 if (cd->media_present)
148151 return -EBUSY;
149152 else
@@ -985,6 +988,7 @@ static int sr_remove(struct device *dev) · 835 unmodified lines
985988 scsi_autopm_get_device(cd->device);
986989
987990 del_gendisk(cd->disk);
991+ dev_set_drvdata(dev, NULL);
988992
989993 mutex_lock(&sr_ref_mutex);
990994 kref_put(&cd->kref, sr_kref_release);
drivers/staging/panel/panel.c+15−19
@@ -825,8 +825,7 @@ static void lcd_write_cmd_s(int cmd) · 824 unmodified lines
825825 lcd_send_serial(0x1F); /* R/W=W, RS=0 */
826826 lcd_send_serial(cmd & 0x0F);
827827 lcd_send_serial((cmd >> 4) & 0x0F);
828− /* the shortest command takes at least 40 us */
829− usleep_range(40, 100);
828+ udelay(40); /* the shortest command takes at least 40 us */
830829 spin_unlock_irq(&pprt_lock);
831830 }
832831
@@ -837,8 +836,7 @@ static void lcd_write_data_s(int data) · 4 unmodified lines
837836 lcd_send_serial(0x5F); /* R/W=W, RS=1 */
838837 lcd_send_serial(data & 0x0F);
839838 lcd_send_serial((data >> 4) & 0x0F);
840− /* the shortest data takes at least 40 us */
841− usleep_range(40, 100);
839+ udelay(40); /* the shortest data takes at least 40 us */
842840 spin_unlock_irq(&pprt_lock);
843841 }
844842
@@ -848,20 +846,19 @@ static void lcd_write_cmd_p8(int cmd) · 3 unmodified lines
848846 spin_lock_irq(&pprt_lock);
849847 /* present the data to the data port */
850848 w_dtr(pprt, cmd);
851− /* maintain the data during 20 us before the strobe */
852− usleep_range(20, 100);
849+ udelay(20); /* maintain the data during 20 us before the strobe */
853850
854851 bits.e = BIT_SET;
855852 bits.rs = BIT_CLR;
856853 bits.rw = BIT_CLR;
857854 set_ctrl_bits();
858855
859− usleep_range(40, 100); /* maintain the strobe during 40 us */
856+ udelay(40); /* maintain the strobe during 40 us */
860857
861858 bits.e = BIT_CLR;
862859 set_ctrl_bits();
863860
864− usleep_range(120, 500); /* the shortest command takes at least 120 us */
861+ udelay(120); /* the shortest command takes at least 120 us */
865862 spin_unlock_irq(&pprt_lock);
866863 }
867864
@@ -871,20 +868,19 @@ static void lcd_write_data_p8(int data) · 3 unmodified lines
871868 spin_lock_irq(&pprt_lock);
872869 /* present the data to the data port */
873870 w_dtr(pprt, data);
874− /* maintain the data during 20 us before the strobe */
875− usleep_range(20, 100);
871+ udelay(20); /* maintain the data during 20 us before the strobe */
876872
877873 bits.e = BIT_SET;
878874 bits.rs = BIT_SET;
879875 bits.rw = BIT_CLR;
880876 set_ctrl_bits();
881877
882− usleep_range(40, 100); /* maintain the strobe during 40 us */
878+ udelay(40); /* maintain the strobe during 40 us */
883879
884880 bits.e = BIT_CLR;
885881 set_ctrl_bits();
886882
887− usleep_range(45, 100); /* the shortest data takes at least 45 us */
883+ udelay(45); /* the shortest data takes at least 45 us */
888884 spin_unlock_irq(&pprt_lock);
889885 }
890886
@@ -894,7 +890,7 @@ static void lcd_write_cmd_tilcd(int cmd) · 3 unmodified lines
894890 spin_lock_irq(&pprt_lock);
895891 /* present the data to the control port */
896892 w_ctr(pprt, cmd);
897− usleep_range(60, 120);
893+ udelay(60);
898894 spin_unlock_irq(&pprt_lock);
899895 }
900896
@@ -904,7 +900,7 @@ static void lcd_write_data_tilcd(int data) · 3 unmodified lines
904900 spin_lock_irq(&pprt_lock);
905901 /* present the data to the data port */
906902 w_dtr(pprt, data);
907− usleep_range(60, 120);
903+ udelay(60);
908904 spin_unlock_irq(&pprt_lock);
909905 }
910906
@@ -947,7 +943,7 @@ static void lcd_clear_fast_s(void) · 36 unmodified lines
947943 lcd_send_serial(0x5F); /* R/W=W, RS=1 */
948944 lcd_send_serial(' ' & 0x0F);
949945 lcd_send_serial((' ' >> 4) & 0x0F);
950− usleep_range(40, 100); /* the shortest data takes at least 40 us */
946+ udelay(40); /* the shortest data takes at least 40 us */
951947 }
952948 spin_unlock_irq(&pprt_lock);
953949
@@ -971,7 +967,7 @@ static void lcd_clear_fast_p8(void) · 17 unmodified lines
971967 w_dtr(pprt, ' ');
972968
973969 /* maintain the data during 20 us before the strobe */
974− usleep_range(20, 100);
970+ udelay(20);
975971
976972 bits.e = BIT_SET;
977973 bits.rs = BIT_SET;
@@ -979,13 +975,13 @@ static void lcd_clear_fast_p8(void) · 1 unmodified line
979975 set_ctrl_bits();
980976
981977 /* maintain the strobe during 40 us */
982− usleep_range(40, 100);
978+ udelay(40);
983979
984980 bits.e = BIT_CLR;
985981 set_ctrl_bits();
986982
987983 /* the shortest data takes at least 45 us */
988− usleep_range(45, 100);
984+ udelay(45);
989985 }
990986 spin_unlock_irq(&pprt_lock);
991987
@@ -1007,7 +1003,7 @@ static void lcd_clear_fast_tilcd(void) · 15 unmodified lines
10071003 for (pos = 0; pos < lcd.height * lcd.hwidth; pos++) {
10081004 /* present the data to the data port */
10091005 w_dtr(pprt, ' ');
1010− usleep_range(60, 120);
1006+ udelay(60);
10111007 }
10121008
10131009 spin_unlock_irq(&pprt_lock);
drivers/staging/speakup/main.c+13−8
@@ -264,8 +264,9 @@ static struct notifier_block vt_notifier_block = { · 263 unmodified lines
264264 .notifier_call = vt_notifier_call,
265265 };
266266
267−static unsigned char get_attributes(u16 *pos)
267+static unsigned char get_attributes(struct vc_data *vc, u16 *pos)
268268 {
269+ pos = screen_pos(vc, pos - (u16 *)vc->vc_origin, 1);
269270 return (u_char) (scr_readw(pos) >> 8);
270271 }
271272
@@ -275,7 +276,7 @@ static void speakup_date(struct vc_data *vc) · 3 unmodified lines
275276 spk_y = spk_cy = vc->vc_y;
276277 spk_pos = spk_cp = vc->vc_pos;
277278 spk_old_attr = spk_attr;
278− spk_attr = get_attributes((u_short *) spk_pos);
279+ spk_attr = get_attributes(vc, (u_short *)spk_pos);
279280 }
280281
281282 static void bleep(u_short val)
@@ -469,8 +470,12 @@ static u16 get_char(struct vc_data *vc, u16 *pos, u_char *attribs) · 187 unmodified lines
469470 u16 ch = ' ';
470471
471472 if (vc && pos) {
472− u16 w = scr_readw(pos);
473− u16 c = w & 0xff;
473+ u16 w;
474+ u16 c;
475+
476+ pos = screen_pos(vc, pos - (u16 *)vc->vc_origin, 1);
477+ w = scr_readw(pos);
478+ c = w & 0xff;
474479
475480 if (w & vc->vc_hi_font_mask)
476481 c |= 0x100;
@@ -746,7 +751,7 @@ static int get_line(struct vc_data *vc) · 269 unmodified lines
746751 u_char tmp2;
747752
748753 spk_old_attr = spk_attr;
749− spk_attr = get_attributes((u_short *) spk_pos);
754+ spk_attr = get_attributes(vc, (u_short *)spk_pos);
750755 for (i = 0; i < vc->vc_cols; i++) {
751756 buf[i] = (u_char) get_char(vc, (u_short *) tmp, &tmp2);
752757 tmp += 2;
@@ -811,7 +816,7 @@ static int say_from_to(struct vc_data *vc, u_long from, u_long to, · 58 unmodified lines
811816 u_short saved_punc_mask = spk_punc_mask;
812817
813818 spk_old_attr = spk_attr;
814− spk_attr = get_attributes((u_short *) from);
819+ spk_attr = get_attributes(vc, (u_short *)from);
815820 while (from < to) {
816821 buf[i++] = (char)get_char(vc, (u_short *) from, &tmp);
817822 from += 2;
@@ -886,7 +891,7 @@ static int get_sentence_buf(struct vc_data *vc, int read_punc) · 68 unmodified lines
886891 sentmarks[bn][0] = &sentbuf[bn][0];
887892 i = 0;
888893 spk_old_attr = spk_attr;
889− spk_attr = get_attributes((u_short *) start);
894+ spk_attr = get_attributes(vc, (u_short *)start);
890895
891896 while (start < end) {
892897 sentbuf[bn][i] = (char)get_char(vc, (u_short *) start, &tmp);
@@ -1585,7 +1590,7 @@ static int count_highlight_color(struct vc_data *vc) · 692 unmodified lines
15851590 u16 *ptr;
15861591
15871592 for (ptr = start; ptr < end; ptr++) {
1588− ch = get_attributes(ptr);
1593+ ch = get_attributes(vc, ptr);
15891594 bg = (ch & 0x70) >> 4;
15901595 speakup_console[vc_num]->ht.bgcount[bg]++;
15911596 }
drivers/staging/speakup/selection.c+4−1
@@ -142,7 +142,9 @@ static void __speakup_paste_selection(struct work_struct *work) · 141 unmodified lines
142142 struct tty_ldisc *ld;
143143 DECLARE_WAITQUEUE(wait, current);
144144
145− ld = tty_ldisc_ref_wait(tty);
145+ ld = tty_ldisc_ref(tty);
146+ if (!ld)
147+ goto tty_unref;
146148 tty_buffer_lock_exclusive(&vc->port);
147149
148150 add_wait_queue(&vc->paste_wait, &wait);
@@ -162,6 +164,7 @@ static void __speakup_paste_selection(struct work_struct *work) · 13 unmodified lines
162164
163165 tty_buffer_unlock_exclusive(&vc->port);
164166 tty_ldisc_deref(ld);
167+tty_unref:
165168 tty_kref_put(tty);
166169 }
167170
drivers/staging/speakup/serialio.c+12−1
@@ -6,6 +6,11 @@ · 5 unmodified lines
66 #include "spk_priv.h"
77 #include "serialio.h"
88
9+#include <linux/serial_core.h>
10+/* WARNING: Do not change this to <linux/serial.h> without testing that
11+ * SERIAL_PORT_DFNS does get defined to the appropriate value. */
12+#include <asm/serial.h>
13+
914 #ifndef SERIAL_PORT_DFNS
1015 #define SERIAL_PORT_DFNS
1116 #endif
@@ -23,9 +28,15 @@ const struct old_serial_port *spk_serial_init(int index) · 11 unmodified lines
2328 int baud = 9600, quot = 0;
2429 unsigned int cval = 0;
2530 int cflag = CREAD | HUPCL | CLOCAL | B9600 | CS8;
26− const struct old_serial_port *ser = rs_table + index;
31+ const struct old_serial_port *ser;
2732 int err;
2833
34+ if (index >= ARRAY_SIZE(rs_table)) {
35+ pr_info("no port info for ttyS%d\n", index);
36+ return NULL;
37+ }
38+ ser = rs_table + index;
39+
2940 /* Divisor, bytesize and parity */
3041 quot = ser->baud_base / baud;
3142 cval = cflag & (CSIZE | CSTOPB);
drivers/tty/n_tty.c+2−5
@@ -269,16 +269,13 @@ static void n_tty_check_throttle(struct tty_struct *tty) · 268 unmodified lines
269269
270270 static void n_tty_check_unthrottle(struct tty_struct *tty)
271271 {
272− if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
273− tty->link->ldisc->ops->write_wakeup == n_tty_write_wakeup) {
272+ if (tty->driver->type == TTY_DRIVER_TYPE_PTY) {
274273 if (chars_in_buffer(tty) > TTY_THRESHOLD_UNTHROTTLE)
275274 return;
276275 if (!tty->count)
277276 return;
278277 n_tty_kick_worker(tty);
279− n_tty_write_wakeup(tty->link);
280− if (waitqueue_active(&tty->link->write_wait))
281− wake_up_interruptible_poll(&tty->link->write_wait, POLLOUT);
278+ tty_wakeup(tty->link);
282279 return;
283280 }
284281
drivers/tty/serial/8250/8250_pci.c+29−0
@@ -1379,6 +1379,9 @@ ce4100_serial_setup(struct serial_private *priv, · 1378 unmodified lines
13791379 #define PCI_DEVICE_ID_INTEL_BSW_UART1 0x228a
13801380 #define PCI_DEVICE_ID_INTEL_BSW_UART2 0x228c
13811381
1382+#define PCI_DEVICE_ID_INTEL_BDW_UART1 0x9ce3
1383+#define PCI_DEVICE_ID_INTEL_BDW_UART2 0x9ce4
1384+
13821385 #define BYT_PRV_CLK 0x800
13831386 #define BYT_PRV_CLK_EN (1 << 0)
13841387 #define BYT_PRV_CLK_M_VAL_SHIFT 1
@@ -1461,11 +1464,13 @@ byt_serial_setup(struct serial_private *priv, · 76 unmodified lines
14611464 switch (pdev->device) {
14621465 case PCI_DEVICE_ID_INTEL_BYT_UART1:
14631466 case PCI_DEVICE_ID_INTEL_BSW_UART1:
1467+ case PCI_DEVICE_ID_INTEL_BDW_UART1:
14641468 rx_param->src_id = 3;
14651469 tx_param->dst_id = 2;
14661470 break;
14671471 case PCI_DEVICE_ID_INTEL_BYT_UART2:
14681472 case PCI_DEVICE_ID_INTEL_BSW_UART2:
1473+ case PCI_DEVICE_ID_INTEL_BDW_UART2:
14691474 rx_param->src_id = 5;
14701475 tx_param->dst_id = 4;
14711476 break;
@@ -2062,6 +2067,20 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = { · 590 unmodified lines
20622067 .subdevice = PCI_ANY_ID,
20632068 .setup = byt_serial_setup,
20642069 },
2070+ {
2071+ .vendor = PCI_VENDOR_ID_INTEL,
2072+ .device = PCI_DEVICE_ID_INTEL_BDW_UART1,
2073+ .subvendor = PCI_ANY_ID,
2074+ .subdevice = PCI_ANY_ID,
2075+ .setup = byt_serial_setup,
2076+ },
2077+ {
2078+ .vendor = PCI_VENDOR_ID_INTEL,
2079+ .device = PCI_DEVICE_ID_INTEL_BDW_UART2,
2080+ .subvendor = PCI_ANY_ID,
2081+ .subdevice = PCI_ANY_ID,
2082+ .setup = byt_serial_setup,
2083+ },
20652084 /*
20662085 * ITE
20672086 */
@@ -5506,6 +5525,16 @@ static struct pci_device_id serial_pci_tbl[] = { · 3438 unmodified lines
55065525 PCI_CLASS_COMMUNICATION_SERIAL << 8, 0xff0000,
55075526 pbn_byt },
55085527
5528+ /* Intel Broadwell */
5529+ { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BDW_UART1,
5530+ PCI_ANY_ID, PCI_ANY_ID,
5531+ PCI_CLASS_COMMUNICATION_SERIAL << 8, 0xff0000,
5532+ pbn_byt },
5533+ { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_BDW_UART2,
5534+ PCI_ANY_ID, PCI_ANY_ID,
5535+ PCI_CLASS_COMMUNICATION_SERIAL << 8, 0xff0000,
5536+ pbn_byt },
5537+
55095538 /*
55105539 * Intel Quark x1000
55115540 */
drivers/tty/tty_io.c+38−6
@@ -1463,13 +1463,13 @@ static int tty_reopen(struct tty_struct *tty) · 1462 unmodified lines
14631463 {
14641464 struct tty_driver *driver = tty->driver;
14651465
1466− if (!tty->count)
1467− return -EIO;
1468−
14691466 if (driver->type == TTY_DRIVER_TYPE_PTY &&
14701467 driver->subtype == PTY_TYPE_MASTER)
14711468 return -EIO;
14721469
1470+ if (!tty->count)
1471+ return -EAGAIN;
1472+
14731473 if (test_bit(TTY_EXCLUSIVE, &tty->flags) && !capable(CAP_SYS_ADMIN))
14741474 return -EBUSY;
14751475
@@ -2065,7 +2065,12 @@ retry_open: · 589 unmodified lines
20652065
20662066 if (tty) {
20672067 mutex_unlock(&tty_mutex);
2068− tty_lock(tty);
2068+ retval = tty_lock_interruptible(tty);
2069+ if (retval) {
2070+ if (retval == -EINTR)
2071+ retval = -ERESTARTSYS;
2072+ goto err_unref;
2073+ }
20692074 /* safe to drop the kref from tty_driver_lookup_tty() */
20702075 tty_kref_put(tty);
20712076 retval = tty_reopen(tty);
@@ -2083,7 +2088,11 @@ retry_open: · 11 unmodified lines
20832088
20842089 if (IS_ERR(tty)) {
20852090 retval = PTR_ERR(tty);
2086− goto err_file;
2091+ if (retval != -EAGAIN || signal_pending(current))
2092+ goto err_file;
2093+ tty_free_file(filp);
2094+ schedule();
2095+ goto retry_open;
20872096 }
20882097
20892098 tty_add_file(tty, filp);
@@ -2152,6 +2161,7 @@ retry_open: · 62 unmodified lines
21522161 return 0;
21532162 err_unlock:
21542163 mutex_unlock(&tty_mutex);
2164+err_unref:
21552165 /* after locks to avoid deadlock */
21562166 if (!IS_ERR_OR_NULL(driver))
21572167 tty_driver_kref_put(driver);
@@ -2648,6 +2658,28 @@ static int tiocsetd(struct tty_struct *tty, int __user *p) · 490 unmodified lines
26482658 return ret;
26492659 }
26502660
2661+/**
2662+ * tiocgetd - get line discipline
2663+ * @tty: tty device
2664+ * @p: pointer to user data
2665+ *
2666+ * Retrieves the line discipline id directly from the ldisc.
2667+ *
2668+ * Locking: waits for ldisc reference (in case the line discipline
2669+ * is changing or the tty is being hungup)
2670+ */
2671+
2672+static int tiocgetd(struct tty_struct *tty, int __user *p)
2673+{
2674+ struct tty_ldisc *ld;
2675+ int ret;
2676+
2677+ ld = tty_ldisc_ref_wait(tty);
2678+ ret = put_user(ld->ops->num, p);
2679+ tty_ldisc_deref(ld);
2680+ return ret;
2681+}
2682+
26512683 /**
26522684 * send_break - performed time break
26532685 * @tty: device to break on
@@ -2874,7 +2906,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · 220 unmodified lines
28742906 case TIOCGSID:
28752907 return tiocgsid(tty, real_tty, p);
28762908 case TIOCGETD:
2877− return put_user(tty->ldisc->ops->num, (int __user *)p);
2909+ return tiocgetd(tty, p);
28782910 case TIOCSETD:
28792911 return tiocsetd(tty, p);
28802912 case TIOCVHANGUP:
drivers/tty/tty_mutex.c+8−0
@@ -19,6 +19,14 @@ void __lockfunc tty_lock(struct tty_struct *tty) · 18 unmodified lines
1919 }
2020 EXPORT_SYMBOL(tty_lock);
2121
22+int tty_lock_interruptible(struct tty_struct *tty)
23+{
24+ if (WARN(tty->magic != TTY_MAGIC, "L Bad %p\n", tty))
25+ return -EIO;
26+ tty_kref_get(tty);
27+ return mutex_lock_interruptible(&tty->legacy_mutex);
28+}
29+
2230 void __lockfunc tty_unlock(struct tty_struct *tty)
2331 {
2432 if (WARN(tty->magic != TTY_MAGIC, "U Bad %p\n", tty))
drivers/tty/vt/vt.c+1−0
@@ -4250,6 +4250,7 @@ unsigned short *screen_pos(struct vc_data *vc, int w_offset, int viewed) · 4249 unmodified lines
42504250 {
42514251 return screenpos(vc, 2 * w_offset, viewed);
42524252 }
4253+EXPORT_SYMBOL_GPL(screen_pos);
42534254
42544255 void getconsxy(struct vc_data *vc, unsigned char *p)
42554256 {
drivers/usb/class/cdc-acm.c+13−1
@@ -428,7 +428,8 @@ static void acm_read_bulk_callback(struct urb *urb) · 427 unmodified lines
428428 set_bit(rb->index, &acm->read_urbs_free);
429429 dev_dbg(&acm->data->dev, "%s - non-zero urb status: %d\n",
430430 __func__, status);
431− return;
431+ if ((status != -ENOENT) || (urb->actual_length == 0))
432+ return;
432433 }
433434
434435 usb_mark_last_busy(acm->dev);
@@ -1404,6 +1405,8 @@ made_compressed_probe: · 969 unmodified lines
14041405 usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),
14051406 NULL, acm->writesize, acm_write_bulk, snd);
14061407 snd->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1408+ if (quirks & SEND_ZERO_PACKET)
1409+ snd->urb->transfer_flags |= URB_ZERO_PACKET;
14071410 snd->instance = acm;
14081411 }
14091412
@@ -1838,6 +1841,11 @@ static const struct usb_device_id acm_ids[] = { · 428 unmodified lines
18381841 },
18391842 #endif
18401843
1844+ /*Samsung phone in firmware update mode */
1845+ { USB_DEVICE(0x04e8, 0x685d),
1846+ .driver_info = IGNORE_DEVICE,
1847+ },
1848+
18411849 /* Exclude Infineon Flash Loader utility */
18421850 { USB_DEVICE(0x058b, 0x0041),
18431851 .driver_info = IGNORE_DEVICE,
@@ -1861,6 +1869,10 @@ static const struct usb_device_id acm_ids[] = { · 17 unmodified lines
18611869 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
18621870 USB_CDC_ACM_PROTO_AT_CDMA) },
18631871
1872+ { USB_DEVICE(0x1519, 0x0452), /* Intel 7260 modem */
1873+ .driver_info = SEND_ZERO_PACKET,
1874+ },
1875+
18641876 { }
18651877 };
18661878
drivers/usb/class/cdc-acm.h+1−0
@@ -134,3 +134,4 @@ struct acm { · 133 unmodified lines
134134 #define IGNORE_DEVICE BIT(5)
135135 #define QUIRK_CONTROL_LINE_STATE BIT(6)
136136 #define CLEAR_HALT_CONDITIONS BIT(7)
137+#define SEND_ZERO_PACKET BIT(8)
drivers/usb/core/hub.c+5−3
@@ -5457,7 +5457,6 @@ static int usb_reset_and_verify_device(struct usb_device *udev) · 5456 unmodified lines
54575457 }
54585458
54595459 bos = udev->bos;
5460− udev->bos = NULL;
54615460
54625461 for (i = 0; i < SET_CONFIG_TRIES; ++i) {
54635462
@@ -5550,8 +5549,11 @@ done: · 86 unmodified lines
55505549 usb_set_usb2_hardware_lpm(udev, 1);
55515550 usb_unlocked_enable_lpm(udev);
55525551 usb_enable_ltm(udev);
5553− usb_release_bos_descriptor(udev);
5554− udev->bos = bos;
5552+ /* release the new BOS descriptor allocated by hub_port_init() */
5553+ if (udev->bos != bos) {
5554+ usb_release_bos_descriptor(udev);
5555+ udev->bos = bos;
5556+ }
55555557 return 0;
55565558
55575559 re_enumerate:
drivers/usb/serial/cp210x.c+1−0
@@ -99,6 +99,7 @@ static const struct usb_device_id id_table[] = { · 98 unmodified lines
9999 { USB_DEVICE(0x10C4, 0x81AC) }, /* MSD Dash Hawk */
100100 { USB_DEVICE(0x10C4, 0x81AD) }, /* INSYS USB Modem */
101101 { USB_DEVICE(0x10C4, 0x81C8) }, /* Lipowsky Industrie Elektronik GmbH, Baby-JTAG */
102+ { USB_DEVICE(0x10C4, 0x81D7) }, /* IAI Corp. RCB-CV-USB USB to RS485 Adaptor */
102103 { USB_DEVICE(0x10C4, 0x81E2) }, /* Lipowsky Industrie Elektronik GmbH, Baby-LIN */
103104 { USB_DEVICE(0x10C4, 0x81E7) }, /* Aerocomm Radio */
104105 { USB_DEVICE(0x10C4, 0x81E8) }, /* Zephyr Bioharness */
drivers/usb/serial/ftdi_sio.c+1−0
@@ -824,6 +824,7 @@ static const struct usb_device_id id_table_combined[] = { · 823 unmodified lines
824824 { USB_DEVICE(FTDI_VID, FTDI_TURTELIZER_PID),
825825 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
826826 { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) },
827+ { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_SCU18) },
827828 { USB_DEVICE(FTDI_VID, FTDI_REU_TINY_PID) },
828829
829830 /* Papouch devices based on FTDI chip */
drivers/usb/serial/ftdi_sio_ids.h+1−0
@@ -615,6 +615,7 @@ · 614 unmodified lines
615615 */
616616 #define RATOC_VENDOR_ID 0x0584
617617 #define RATOC_PRODUCT_ID_USB60F 0xb020
618+#define RATOC_PRODUCT_ID_SCU18 0xb03a
618619
619620 /*
620621 * Infineon Technologies
drivers/usb/serial/mxu11x0.c+20−0
@@ -368,6 +368,16 @@ static int mxu1_port_probe(struct usb_serial_port *port) · 367 unmodified lines
368368 return 0;
369369 }
370370
371+static int mxu1_port_remove(struct usb_serial_port *port)
372+{
373+ struct mxu1_port *mxport;
374+
375+ mxport = usb_get_serial_port_data(port);
376+ kfree(mxport);
377+
378+ return 0;
379+}
380+
371381 static int mxu1_startup(struct usb_serial *serial)
372382 {
373383 struct mxu1_device *mxdev;
@@ -427,6 +437,14 @@ err_free_mxdev: · 53 unmodified lines
427437 return err;
428438 }
429439
440+static void mxu1_release(struct usb_serial *serial)
441+{
442+ struct mxu1_device *mxdev;
443+
444+ mxdev = usb_get_serial_data(serial);
445+ kfree(mxdev);
446+}
447+
430448 static int mxu1_write_byte(struct usb_serial_port *port, u32 addr,
431449 u8 mask, u8 byte)
432450 {
@@ -957,7 +975,9 @@ static struct usb_serial_driver mxu11x0_device = { · 524 unmodified lines
957975 .id_table = mxu1_idtable,
958976 .num_ports = 1,
959977 .port_probe = mxu1_port_probe,
978+ .port_remove = mxu1_port_remove,
960979 .attach = mxu1_startup,
980+ .release = mxu1_release,
961981 .open = mxu1_open,
962982 .close = mxu1_close,
963983 .ioctl = mxu1_ioctl,
drivers/usb/serial/option.c+17−1
@@ -268,6 +268,8 @@ static void option_instat_callback(struct urb *urb); · 267 unmodified lines
268268 #define TELIT_PRODUCT_CC864_SINGLE 0x1006
269269 #define TELIT_PRODUCT_DE910_DUAL 0x1010
270270 #define TELIT_PRODUCT_UE910_V2 0x1012
271+#define TELIT_PRODUCT_LE922_USBCFG0 0x1042
272+#define TELIT_PRODUCT_LE922_USBCFG3 0x1043
271273 #define TELIT_PRODUCT_LE920 0x1200
272274 #define TELIT_PRODUCT_LE910 0x1201
273275
@@ -615,6 +617,16 @@ static const struct option_blacklist_info telit_le920_blacklist = { · 341 unmodified lines
615617 .reserved = BIT(1) | BIT(5),
616618 };
617619
620+static const struct option_blacklist_info telit_le922_blacklist_usbcfg0 = {
621+ .sendsetup = BIT(2),
622+ .reserved = BIT(0) | BIT(1) | BIT(3),
623+};
624+
625+static const struct option_blacklist_info telit_le922_blacklist_usbcfg3 = {
626+ .sendsetup = BIT(0),
627+ .reserved = BIT(1) | BIT(2) | BIT(3),
628+};
629+
618630 static const struct usb_device_id option_ids[] = {
619631 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
620632 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
@@ -1160,6 +1172,10 @@ static const struct usb_device_id option_ids[] = { · 539 unmodified lines
11601172 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_CC864_SINGLE) },
11611173 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_DE910_DUAL) },
11621174 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_UE910_V2) },
1175+ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG0),
1176+ .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg0 },
1177+ { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE922_USBCFG3),
1178+ .driver_info = (kernel_ulong_t)&telit_le922_blacklist_usbcfg3 },
11631179 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910),
11641180 .driver_info = (kernel_ulong_t)&telit_le910_blacklist },
11651181 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE920),
@@ -1679,7 +1695,7 @@ static const struct usb_device_id option_ids[] = { · 513 unmodified lines
16791695 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_EU3_P) },
16801696 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PH8),
16811697 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1682− { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX) },
1698+ { USB_DEVICE_INTERFACE_CLASS(CINTERION_VENDOR_ID, CINTERION_PRODUCT_AHXX, 0xff) },
16831699 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_PLXX),
16841700 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
16851701 { USB_DEVICE(CINTERION_VENDOR_ID, CINTERION_PRODUCT_HC28_MDM) },
drivers/usb/serial/visor.c+9−2
@@ -544,6 +544,11 @@ static int treo_attach(struct usb_serial *serial) · 543 unmodified lines
544544 (serial->num_interrupt_in == 0))
545545 return 0;
546546
547+ if (serial->num_bulk_in < 2 || serial->num_interrupt_in < 2) {
548+ dev_err(&serial->interface->dev, "missing endpoints\n");
549+ return -ENODEV;
550+ }
551+
547552 /*
548553 * It appears that Treos and Kyoceras want to use the
549554 * 1st bulk in endpoint to communicate with the 2nd bulk out endpoint,
@@ -597,8 +602,10 @@ static int clie_5_attach(struct usb_serial *serial) · 47 unmodified lines
597602 */
598603
599604 /* some sanity check */
600− if (serial->num_ports < 2)
601− return -1;
605+ if (serial->num_bulk_out < 2) {
606+ dev_err(&serial->interface->dev, "missing bulk out endpoints\n");
607+ return -ENODEV;
608+ }
602609
603610 /* port 0 now uses the modified endpoint Address */
604611 port = serial->port[0];
drivers/vfio/vfio.c+10−14
@@ -123,8 +123,8 @@ struct iommu_group *vfio_iommu_group_get(struct device *dev) · 122 unmodified lines
123123 /*
124124 * With noiommu enabled, an IOMMU group will be created for a device
125125 * that doesn't already have one and doesn't have an iommu_ops on their
126− * bus. We use iommu_present() again in the main code to detect these
127− * fake groups.
126+ * bus. We set iommudata simply to be able to identify these groups
127+ * as special use and for reclamation later.
128128 */
129129 if (group || !noiommu || iommu_present(dev->bus))
130130 return group;
@@ -134,6 +134,7 @@ struct iommu_group *vfio_iommu_group_get(struct device *dev) · 3 unmodified lines
134134 return NULL;
135135
136136 iommu_group_set_name(group, "vfio-noiommu");
137+ iommu_group_set_iommudata(group, &noiommu, NULL);
137138 ret = iommu_group_add_device(group, dev);
138139 iommu_group_put(group);
139140 if (ret)
@@ -158,7 +159,7 @@ EXPORT_SYMBOL_GPL(vfio_iommu_group_get); · 18 unmodified lines
158159 void vfio_iommu_group_put(struct iommu_group *group, struct device *dev)
159160 {
160161 #ifdef CONFIG_VFIO_NOIOMMU
161− if (!iommu_present(dev->bus))
162+ if (iommu_group_get_iommudata(group) == &noiommu)
162163 iommu_group_remove_device(dev);
163164 #endif
164165
@@ -190,16 +191,10 @@ static long vfio_noiommu_ioctl(void *iommu_data, · 25 unmodified lines
190191 return -ENOTTY;
191192 }
192193
193−static int vfio_iommu_present(struct device *dev, void *unused)
194−{
195− return iommu_present(dev->bus) ? 1 : 0;
196−}
197−
198194 static int vfio_noiommu_attach_group(void *iommu_data,
199195 struct iommu_group *iommu_group)
200196 {
201− return iommu_group_for_each_dev(iommu_group, NULL,
202− vfio_iommu_present) ? -EINVAL : 0;
197+ return iommu_group_get_iommudata(iommu_group) == &noiommu ? 0 : -EINVAL;
203198 }
204199
205200 static void vfio_noiommu_detach_group(void *iommu_data,
@@ -323,8 +318,7 @@ static void vfio_group_unlock_and_free(struct vfio_group *group) · 117 unmodified lines
323318 /**
324319 * Group objects - create, release, get, put, search
325320 */
326−static struct vfio_group *vfio_create_group(struct iommu_group *iommu_group,
327− bool iommu_present)
321+static struct vfio_group *vfio_create_group(struct iommu_group *iommu_group)
328322 {
329323 struct vfio_group *group, *tmp;
330324 struct device *dev;
@@ -342,7 +336,9 @@ static struct vfio_group *vfio_create_group(struct iommu_group *iommu_group, · 11 unmodified lines
342336 atomic_set(&group->container_users, 0);
343337 atomic_set(&group->opened, 0);
344338 group->iommu_group = iommu_group;
345− group->noiommu = !iommu_present;
339+#ifdef CONFIG_VFIO_NOIOMMU
340+ group->noiommu = (iommu_group_get_iommudata(iommu_group) == &noiommu);
341+#endif
346342
347343 group->nb.notifier_call = vfio_iommu_group_notifier;
348344
@@ -767,7 +763,7 @@ int vfio_add_group_dev(struct device *dev, · 418 unmodified lines
767763
768764 group = vfio_group_get_from_iommu(iommu_group);
769765 if (!group) {
770− group = vfio_create_group(iommu_group, iommu_present(dev->bus));
766+ group = vfio_create_group(iommu_group);
771767 if (IS_ERR(group)) {
772768 iommu_group_put(iommu_group);
773769 return PTR_ERR(group);
drivers/virtio/virtio_pci_common.c+2−0
@@ -545,6 +545,7 @@ err_enable_device: · 544 unmodified lines
545545 static void virtio_pci_remove(struct pci_dev *pci_dev)
546546 {
547547 struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
548+ struct device *dev = get_device(&vp_dev->vdev.dev);
548549
549550 unregister_virtio_device(&vp_dev->vdev);
550551
@@ -554,6 +555,7 @@ static void virtio_pci_remove(struct pci_dev *pci_dev) · 3 unmodified lines
554555 virtio_pci_modern_remove(vp_dev);
555556
556557 pci_disable_device(pci_dev);
558+ put_device(dev);
557559 }
558560
559561 static struct pci_driver virtio_pci_driver = {
drivers/xen/tmem.c+1−1
@@ -242,7 +242,7 @@ static int tmem_cleancache_init_shared_fs(char *uuid, size_t pagesize) · 241 unmodified lines
242242 return xen_tmem_new_pool(shared_uuid, TMEM_POOL_SHARED, pagesize);
243243 }
244244
245−static struct cleancache_ops tmem_cleancache_ops = {
245+static const struct cleancache_ops tmem_cleancache_ops = {
246246 .put_page = tmem_cleancache_put_page,
247247 .get_page = tmem_cleancache_get_page,
248248 .invalidate_page = tmem_cleancache_flush_page,
fs/btrfs/async-thread.c+1−1
@@ -328,8 +328,8 @@ static inline void __btrfs_queue_work(struct __btrfs_workqueue *wq, · 327 unmodified lines
328328 list_add_tail(&work->ordered_list, &wq->ordered_list);
329329 spin_unlock_irqrestore(&wq->list_lock, flags);
330330 }
331− queue_work(wq->normal_wq, &work->normal_work);
332331 trace_btrfs_work_queued(work);
332+ queue_work(wq->normal_wq, &work->normal_work);
333333 }
334334
335335 void btrfs_queue_work(struct btrfs_workqueue *wq,
fs/btrfs/disk-io.c+1−1
@@ -182,6 +182,7 @@ static struct btrfs_lockdep_keyset { · 181 unmodified lines
182182 { .id = BTRFS_TREE_RELOC_OBJECTID, .name_stem = "treloc" },
183183 { .id = BTRFS_DATA_RELOC_TREE_OBJECTID, .name_stem = "dreloc" },
184184 { .id = BTRFS_UUID_TREE_OBJECTID, .name_stem = "uuid" },
185+ { .id = BTRFS_FREE_SPACE_TREE_OBJECTID, .name_stem = "free-space" },
185186 { .id = 0, .name_stem = "tree" },
186187 };
187188
@@ -1787,7 +1788,6 @@ static int cleaner_kthread(void *arg) · 1599 unmodified lines
17871788 int again;
17881789 struct btrfs_trans_handle *trans;
17891790
1790− set_freezable();
17911791 do {
17921792 again = 0;
17931793
fs/btrfs/free-space-tree.c+16−2
@@ -153,6 +153,20 @@ static inline u32 free_space_bitmap_size(u64 size, u32 sectorsize) · 152 unmodified lines
153153
154154 static unsigned long *alloc_bitmap(u32 bitmap_size)
155155 {
156+ void *mem;
157+
158+ /*
159+ * The allocation size varies, observed numbers were < 4K up to 16K.
160+ * Using vmalloc unconditionally would be too heavy, we'll try
161+ * contiguous allocations first.
162+ */
163+ if (bitmap_size <= PAGE_SIZE)
164+ return kzalloc(bitmap_size, GFP_NOFS);
165+
166+ mem = kzalloc(bitmap_size, GFP_NOFS | __GFP_NOWARN);
167+ if (mem)
168+ return mem;
169+
156170 return __vmalloc(bitmap_size, GFP_NOFS | __GFP_HIGHMEM | __GFP_ZERO,
157171 PAGE_KERNEL);
158172 }
@@ -289,7 +303,7 @@ int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans, · 130 unmodified lines
289303
290304 ret = 0;
291305 out:
292− vfree(bitmap);
306+ kvfree(bitmap);
293307 if (ret)
294308 btrfs_abort_transaction(trans, root, ret);
295309 return ret;
@@ -438,7 +452,7 @@ int convert_free_space_to_extents(struct btrfs_trans_handle *trans, · 142 unmodified lines
438452
439453 ret = 0;
440454 out:
441− vfree(bitmap);
455+ kvfree(bitmap);
442456 if (ret)
443457 btrfs_abort_transaction(trans, root, ret);
444458 return ret;
fs/btrfs/inode.c+28−8
@@ -7116,21 +7116,41 @@ static struct extent_map *btrfs_new_extent_direct(struct inode *inode, · 7115 unmodified lines
71167116 if (ret)
71177117 return ERR_PTR(ret);
71187118
7119− em = create_pinned_em(inode, start, ins.offset, start, ins.objectid,
7120− ins.offset, ins.offset, ins.offset, 0);
7121− if (IS_ERR(em)) {
7122− btrfs_free_reserved_extent(root, ins.objectid, ins.offset, 1);
7123− return em;
7124− }
7125−
7119+ /*
7120+ * Create the ordered extent before the extent map. This is to avoid
7121+ * races with the fast fsync path that would lead to it logging file
7122+ * extent items that point to disk extents that were not yet written to.
7123+ * The fast fsync path collects ordered extents into a local list and
7124+ * then collects all the new extent maps, so we must create the ordered
7125+ * extent first and make sure the fast fsync path collects any new
7126+ * ordered extents after collecting new extent maps as well.
7127+ * The fsync path simply can not rely on inode_dio_wait() because it
7128+ * causes deadlock with AIO.
7129+ */
71267130 ret = btrfs_add_ordered_extent_dio(inode, start, ins.objectid,
71277131 ins.offset, ins.offset, 0);
71287132 if (ret) {
71297133 btrfs_free_reserved_extent(root, ins.objectid, ins.offset, 1);
7130− free_extent_map(em);
71317134 return ERR_PTR(ret);
71327135 }
71337136
7137+ em = create_pinned_em(inode, start, ins.offset, start, ins.objectid,
7138+ ins.offset, ins.offset, ins.offset, 0);
7139+ if (IS_ERR(em)) {
7140+ struct btrfs_ordered_extent *oe;
7141+
7142+ btrfs_free_reserved_extent(root, ins.objectid, ins.offset, 1);
7143+ oe = btrfs_lookup_ordered_extent(inode, start);
7144+ ASSERT(oe);
7145+ if (WARN_ON(!oe))
7146+ return em;
7147+ set_bit(BTRFS_ORDERED_IOERR, &oe->flags);
7148+ set_bit(BTRFS_ORDERED_IO_DONE, &oe->flags);
7149+ btrfs_remove_ordered_extent(inode, oe);
7150+ /* Once for our lookup and once for the ordered extents tree. */
7151+ btrfs_put_ordered_extent(oe);
7152+ btrfs_put_ordered_extent(oe);
7153+ }
71347154 return em;
71357155 }
71367156
fs/btrfs/relocation.c+2−1
@@ -575,7 +575,8 @@ static int is_cowonly_root(u64 root_objectid) · 574 unmodified lines
575575 root_objectid == BTRFS_TREE_LOG_OBJECTID ||
576576 root_objectid == BTRFS_CSUM_TREE_OBJECTID ||
577577 root_objectid == BTRFS_UUID_TREE_OBJECTID ||
578− root_objectid == BTRFS_QUOTA_TREE_OBJECTID)
578+ root_objectid == BTRFS_QUOTA_TREE_OBJECTID ||
579+ root_objectid == BTRFS_FREE_SPACE_TREE_OBJECTID)
579580 return 1;
580581 return 0;
581582 }
fs/btrfs/sysfs.c+35−0
@@ -202,6 +202,7 @@ BTRFS_FEAT_ATTR_INCOMPAT(extended_iref, EXTENDED_IREF); · 201 unmodified lines
202202 BTRFS_FEAT_ATTR_INCOMPAT(raid56, RAID56);
203203 BTRFS_FEAT_ATTR_INCOMPAT(skinny_metadata, SKINNY_METADATA);
204204 BTRFS_FEAT_ATTR_INCOMPAT(no_holes, NO_HOLES);
205+BTRFS_FEAT_ATTR_COMPAT_RO(free_space_tree, FREE_SPACE_TREE);
205206
206207 static struct attribute *btrfs_supported_feature_attrs[] = {
207208 BTRFS_FEAT_ATTR_PTR(mixed_backref),
@@ -213,6 +214,7 @@ static struct attribute *btrfs_supported_feature_attrs[] = { · 5 unmodified lines
213214 BTRFS_FEAT_ATTR_PTR(raid56),
214215 BTRFS_FEAT_ATTR_PTR(skinny_metadata),
215216 BTRFS_FEAT_ATTR_PTR(no_holes),
217+ BTRFS_FEAT_ATTR_PTR(free_space_tree),
216218 NULL
217219 };
218220
@@ -780,6 +782,39 @@ failure: · 561 unmodified lines
780782 return error;
781783 }
782784
785+
786+/*
787+ * Change per-fs features in /sys/fs/btrfs/UUID/features to match current
788+ * values in superblock. Call after any changes to incompat/compat_ro flags
789+ */
790+void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info,
791+ u64 bit, enum btrfs_feature_set set)
792+{
793+ struct btrfs_fs_devices *fs_devs;
794+ struct kobject *fsid_kobj;
795+ u64 features;
796+ int ret;
797+
798+ if (!fs_info)
799+ return;
800+
801+ features = get_features(fs_info, set);
802+ ASSERT(bit & supported_feature_masks[set]);
803+
804+ fs_devs = fs_info->fs_devices;
805+ fsid_kobj = &fs_devs->fsid_kobj;
806+
807+ if (!fsid_kobj->state_initialized)
808+ return;
809+
810+ /*
811+ * FIXME: this is too heavy to update just one value, ideally we'd like
812+ * to use sysfs_update_group but some refactoring is needed first.
813+ */
814+ sysfs_remove_group(fsid_kobj, &btrfs_feature_attr_group);
815+ ret = sysfs_create_group(fsid_kobj, &btrfs_feature_attr_group);
816+}
817+
783818 static int btrfs_init_debugfs(void)
784819 {
785820 #ifdef CONFIG_DEBUG_FS
fs/btrfs/sysfs.h+4−1
@@ -56,7 +56,7 @@ static struct btrfs_feature_attr btrfs_attr_##_name = { \ · 55 unmodified lines
5656 #define BTRFS_FEAT_ATTR_COMPAT(name, feature) \
5757 BTRFS_FEAT_ATTR(name, FEAT_COMPAT, BTRFS_FEATURE_COMPAT, feature)
5858 #define BTRFS_FEAT_ATTR_COMPAT_RO(name, feature) \
59− BTRFS_FEAT_ATTR(name, FEAT_COMPAT_RO, BTRFS_FEATURE_COMPAT, feature)
59+ BTRFS_FEAT_ATTR(name, FEAT_COMPAT_RO, BTRFS_FEATURE_COMPAT_RO, feature)
6060 #define BTRFS_FEAT_ATTR_INCOMPAT(name, feature) \
6161 BTRFS_FEAT_ATTR(name, FEAT_INCOMPAT, BTRFS_FEATURE_INCOMPAT, feature)
6262
@@ -90,4 +90,7 @@ int btrfs_sysfs_add_fsid(struct btrfs_fs_devices *fs_devs, · 27 unmodified lines
9090 struct kobject *parent);
9191 int btrfs_sysfs_add_device(struct btrfs_fs_devices *fs_devs);
9292 void btrfs_sysfs_remove_fsid(struct btrfs_fs_devices *fs_devs);
93+void btrfs_sysfs_feature_update(struct btrfs_fs_info *fs_info,
94+ u64 bit, enum btrfs_feature_set set);
95+
9396 #endif /* _BTRFS_SYSFS_H_ */
fs/btrfs/tests/btrfs-tests.c+5−5
@@ -82,18 +82,18 @@ void btrfs_destroy_test_fs(void) · 81 unmodified lines
8282 struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(void)
8383 {
8484 struct btrfs_fs_info *fs_info = kzalloc(sizeof(struct btrfs_fs_info),
85− GFP_NOFS);
85+ GFP_KERNEL);
8686
8787 if (!fs_info)
8888 return fs_info;
8989 fs_info->fs_devices = kzalloc(sizeof(struct btrfs_fs_devices),
90− GFP_NOFS);
90+ GFP_KERNEL);
9191 if (!fs_info->fs_devices) {
9292 kfree(fs_info);
9393 return NULL;
9494 }
9595 fs_info->super_copy = kzalloc(sizeof(struct btrfs_super_block),
96− GFP_NOFS);
96+ GFP_KERNEL);
9797 if (!fs_info->super_copy) {
9898 kfree(fs_info->fs_devices);
9999 kfree(fs_info);
@@ -180,11 +180,11 @@ btrfs_alloc_dummy_block_group(unsigned long length) · 80 unmodified lines
180180 {
181181 struct btrfs_block_group_cache *cache;
182182
183− cache = kzalloc(sizeof(*cache), GFP_NOFS);
183+ cache = kzalloc(sizeof(*cache), GFP_KERNEL);
184184 if (!cache)
185185 return NULL;
186186 cache->free_space_ctl = kzalloc(sizeof(*cache->free_space_ctl),
187− GFP_NOFS);
187+ GFP_KERNEL);
188188 if (!cache->free_space_ctl) {
189189 kfree(cache);
190190 return NULL;
fs/btrfs/tests/extent-io-tests.c+6−6
@@ -94,7 +94,7 @@ static int test_find_delalloc(void) · 93 unmodified lines
9494 * test.
9595 */
9696 for (index = 0; index < (total_dirty >> PAGE_CACHE_SHIFT); index++) {
97− page = find_or_create_page(inode->i_mapping, index, GFP_NOFS);
97+ page = find_or_create_page(inode->i_mapping, index, GFP_KERNEL);
9898 if (!page) {
9999 test_msg("Failed to allocate test page\n");
100100 ret = -ENOMEM;
@@ -113,7 +113,7 @@ static int test_find_delalloc(void) · 12 unmodified lines
113113 * |--- delalloc ---|
114114 * |--- search ---|
115115 */
116− set_extent_delalloc(&tmp, 0, 4095, NULL, GFP_NOFS);
116+ set_extent_delalloc(&tmp, 0, 4095, NULL, GFP_KERNEL);
117117 start = 0;
118118 end = 0;
119119 found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
@@ -144,7 +144,7 @@ static int test_find_delalloc(void) · 24 unmodified lines
144144 test_msg("Couldn't find the locked page\n");
145145 goto out_bits;
146146 }
147− set_extent_delalloc(&tmp, 4096, max_bytes - 1, NULL, GFP_NOFS);
147+ set_extent_delalloc(&tmp, 4096, max_bytes - 1, NULL, GFP_KERNEL);
148148 start = test_start;
149149 end = 0;
150150 found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
@@ -199,7 +199,7 @@ static int test_find_delalloc(void) · 48 unmodified lines
199199 *
200200 * We are re-using our test_start from above since it works out well.
201201 */
202− set_extent_delalloc(&tmp, max_bytes, total_dirty - 1, NULL, GFP_NOFS);
202+ set_extent_delalloc(&tmp, max_bytes, total_dirty - 1, NULL, GFP_KERNEL);
203203 start = test_start;
204204 end = 0;
205205 found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
@@ -262,7 +262,7 @@ static int test_find_delalloc(void) · 56 unmodified lines
262262 }
263263 ret = 0;
264264 out_bits:
265− clear_extent_bits(&tmp, 0, total_dirty - 1, (unsigned)-1, GFP_NOFS);
265+ clear_extent_bits(&tmp, 0, total_dirty - 1, (unsigned)-1, GFP_KERNEL);
266266 out:
267267 if (locked_page)
268268 page_cache_release(locked_page);
@@ -360,7 +360,7 @@ static int test_eb_bitmaps(void) · 91 unmodified lines
360360
361361 test_msg("Running extent buffer bitmap tests\n");
362362
363− bitmap = kmalloc(len, GFP_NOFS);
363+ bitmap = kmalloc(len, GFP_KERNEL);
364364 if (!bitmap) {
365365 test_msg("Couldn't allocate test bitmap\n");
366366 return -ENOMEM;
fs/btrfs/tests/inode-tests.c+4−4
@@ -974,7 +974,7 @@ static int test_extent_accounting(void) · 973 unmodified lines
974974 (BTRFS_MAX_EXTENT_SIZE >> 1) + 4095,
975975 EXTENT_DELALLOC | EXTENT_DIRTY |
976976 EXTENT_UPTODATE | EXTENT_DO_ACCOUNTING, 0, 0,
977− NULL, GFP_NOFS);
977+ NULL, GFP_KERNEL);
978978 if (ret) {
979979 test_msg("clear_extent_bit returned %d\n", ret);
980980 goto out;
@@ -1045,7 +1045,7 @@ static int test_extent_accounting(void) · 64 unmodified lines
10451045 BTRFS_MAX_EXTENT_SIZE+8191,
10461046 EXTENT_DIRTY | EXTENT_DELALLOC |
10471047 EXTENT_DO_ACCOUNTING | EXTENT_UPTODATE, 0, 0,
1048− NULL, GFP_NOFS);
1048+ NULL, GFP_KERNEL);
10491049 if (ret) {
10501050 test_msg("clear_extent_bit returned %d\n", ret);
10511051 goto out;
@@ -1079,7 +1079,7 @@ static int test_extent_accounting(void) · 27 unmodified lines
10791079 ret = clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, (u64)-1,
10801080 EXTENT_DIRTY | EXTENT_DELALLOC |
10811081 EXTENT_DO_ACCOUNTING | EXTENT_UPTODATE, 0, 0,
1082− NULL, GFP_NOFS);
1082+ NULL, GFP_KERNEL);
10831083 if (ret) {
10841084 test_msg("clear_extent_bit returned %d\n", ret);
10851085 goto out;
@@ -1096,7 +1096,7 @@ out: · 10 unmodified lines
10961096 clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, (u64)-1,
10971097 EXTENT_DIRTY | EXTENT_DELALLOC |
10981098 EXTENT_DO_ACCOUNTING | EXTENT_UPTODATE, 0, 0,
1099− NULL, GFP_NOFS);
1099+ NULL, GFP_KERNEL);
11001100 iput(inode);
11011101 btrfs_free_dummy_root(root);
11021102 return ret;
fs/btrfs/tree-log.c+11−3
@@ -4127,7 +4127,9 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans, · 4126 unmodified lines
41274127 struct inode *inode,
41284128 struct btrfs_path *path,
41294129 struct list_head *logged_list,
4130− struct btrfs_log_ctx *ctx)
4130+ struct btrfs_log_ctx *ctx,
4131+ const u64 start,
4132+ const u64 end)
41314133 {
41324134 struct extent_map *em, *n;
41334135 struct list_head extents;
@@ -4166,7 +4168,13 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans, · 32 unmodified lines
41664168 }
41674169
41684170 list_sort(NULL, &extents, extent_cmp);
4169−
4171+ /*
4172+ * Collect any new ordered extents within the range. This is to
4173+ * prevent logging file extent items without waiting for the disk
4174+ * location they point to being written. We do this only to deal
4175+ * with races against concurrent lockless direct IO writes.
4176+ */
4177+ btrfs_get_logged_extents(inode, logged_list, start, end);
41704178 process:
41714179 while (!list_empty(&extents)) {
41724180 em = list_entry(extents.next, struct extent_map, list);
@@ -4701,7 +4709,7 @@ log_extents: · 528 unmodified lines
47014709 goto out_unlock;
47024710 }
47034711 ret = btrfs_log_changed_extents(trans, root, inode, dst_path,
4704− &logged_list, ctx);
4712+ &logged_list, ctx, start, end);
47054713 if (ret) {
47064714 err = ret;
47074715 goto out_unlock;
fs/timerfd.c+1−1
@@ -153,7 +153,7 @@ static ktime_t timerfd_get_remaining(struct timerfd_ctx *ctx) · 152 unmodified lines
153153 if (isalarm(ctx))
154154 remaining = alarm_expires_remaining(&ctx->t.alarm);
155155 else
156− remaining = hrtimer_expires_remaining(&ctx->t.tmr);
156+ remaining = hrtimer_expires_remaining_adjusted(&ctx->t.tmr);
157157
158158 return remaining.tv64 < 0 ? ktime_set(0, 0): remaining;
159159 }
include/drm/drm_atomic_helper.h+4−0
@@ -42,6 +42,10 @@ int drm_atomic_helper_commit(struct drm_device *dev, · 41 unmodified lines
4242 struct drm_atomic_state *state,
4343 bool async);
4444
45+bool drm_atomic_helper_framebuffer_changed(struct drm_device *dev,
46+ struct drm_atomic_state *old_state,
47+ struct drm_crtc *crtc);
48+
4549 void drm_atomic_helper_wait_for_vblanks(struct drm_device *dev,
4650 struct drm_atomic_state *old_state);
4751
include/linux/cleancache.h+7−9
@@ -37,7 +37,7 @@ struct cleancache_ops { · 36 unmodified lines
3737 void (*invalidate_fs)(int);
3838 };
3939
40−extern int cleancache_register_ops(struct cleancache_ops *ops);
40+extern int cleancache_register_ops(const struct cleancache_ops *ops);
4141 extern void __cleancache_init_fs(struct super_block *);
4242 extern void __cleancache_init_shared_fs(struct super_block *);
4343 extern int __cleancache_get_page(struct page *);
@@ -48,14 +48,14 @@ extern void __cleancache_invalidate_fs(struct super_block *); · 4 unmodified lines
4848
4949 #ifdef CONFIG_CLEANCACHE
5050 #define cleancache_enabled (1)
51−static inline bool cleancache_fs_enabled(struct page *page)
52−{
53− return page->mapping->host->i_sb->cleancache_poolid >= 0;
54−}
5551 static inline bool cleancache_fs_enabled_mapping(struct address_space *mapping)
5652 {
5753 return mapping->host->i_sb->cleancache_poolid >= 0;
5854 }
55+static inline bool cleancache_fs_enabled(struct page *page)
56+{
57+ return cleancache_fs_enabled_mapping(page->mapping);
58+}
5959 #else
6060 #define cleancache_enabled (0)
6161 #define cleancache_fs_enabled(_page) (0)
@@ -89,11 +89,9 @@ static inline void cleancache_init_shared_fs(struct super_block *sb) · 27 unmodified lines
8989
9090 static inline int cleancache_get_page(struct page *page)
9191 {
92− int ret = -1;
93−
9492 if (cleancache_enabled && cleancache_fs_enabled(page))
95− ret = __cleancache_get_page(page);
96− return ret;
93+ return __cleancache_get_page(page);
94+ return -1;
9795 }
9896
9997 static inline void cleancache_put_page(struct page *page)
include/linux/ftrace.h+0−1
@@ -165,7 +165,6 @@ struct ftrace_ops { · 164 unmodified lines
165165 ftrace_func_t saved_func;
166166 int __percpu *disabled;
167167 #ifdef CONFIG_DYNAMIC_FTRACE
168− int nr_trampolines;
169168 struct ftrace_ops_hash local_hash;
170169 struct ftrace_ops_hash *func_hash;
171170 struct ftrace_ops_hash old_hash;
include/linux/hrtimer.h+31−3
@@ -87,7 +87,8 @@ enum hrtimer_restart { · 86 unmodified lines
8787 * @function: timer expiry callback function
8888 * @base: pointer to the timer base (per cpu and per clock)
8989 * @state: state information (See bit values above)
90− * @start_pid: timer statistics field to store the pid of the task which
90+ * @is_rel: Set if the timer was armed relative
91+ * @start_pid: timer statistics field to store the pid of the task which
9192 * started the timer
9293 * @start_site: timer statistics field to store the site where the timer
9394 * was started
@@ -101,7 +102,8 @@ struct hrtimer { · 7 unmodified lines
101102 ktime_t _softexpires;
102103 enum hrtimer_restart (*function)(struct hrtimer *);
103104 struct hrtimer_clock_base *base;
104− unsigned long state;
105+ u8 state;
106+ u8 is_rel;
105107 #ifdef CONFIG_TIMER_STATS
106108 int start_pid;
107109 void *start_site;
@@ -321,6 +323,27 @@ static inline void clock_was_set_delayed(void) { } · 213 unmodified lines
321323
322324 #endif
323325
326+static inline ktime_t
327+__hrtimer_expires_remaining_adjusted(const struct hrtimer *timer, ktime_t now)
328+{
329+ ktime_t rem = ktime_sub(timer->node.expires, now);
330+
331+ /*
332+ * Adjust relative timers for the extra we added in
333+ * hrtimer_start_range_ns() to prevent short timeouts.
334+ */
335+ if (IS_ENABLED(CONFIG_TIME_LOW_RES) && timer->is_rel)
336+ rem.tv64 -= hrtimer_resolution;
337+ return rem;
338+}
339+
340+static inline ktime_t
341+hrtimer_expires_remaining_adjusted(const struct hrtimer *timer)
342+{
343+ return __hrtimer_expires_remaining_adjusted(timer,
344+ timer->base->get_time());
345+}
346+
324347 extern void clock_was_set(void);
325348 #ifdef CONFIG_TIMERFD
326349 extern void timerfd_clock_was_set(void);
@@ -390,7 +413,12 @@ static inline void hrtimer_restart(struct hrtimer *timer) · 63 unmodified lines
390413 }
391414
392415 /* Query timers: */
393−extern ktime_t hrtimer_get_remaining(const struct hrtimer *timer);
416+extern ktime_t __hrtimer_get_remaining(const struct hrtimer *timer, bool adjust);
417+
418+static inline ktime_t hrtimer_get_remaining(const struct hrtimer *timer)
419+{
420+ return __hrtimer_get_remaining(timer, false);
421+}
394422
395423 extern u64 hrtimer_get_next_event(void);
396424
include/linux/iommu.h+12−4
@@ -133,8 +133,9 @@ struct iommu_dm_region { · 132 unmodified lines
133133
134134 /**
135135 * struct iommu_ops - iommu ops and capabilities
136− * @domain_init: init iommu domain
137− * @domain_destroy: destroy iommu domain
136+ * @capable: check capability
137+ * @domain_alloc: allocate iommu domain
138+ * @domain_free: free iommu domain
138139 * @attach_dev: attach device to an iommu domain
139140 * @detach_dev: detach device from an iommu domain
140141 * @map: map a physically contiguous memory region to an iommu domain
@@ -144,8 +145,15 @@ struct iommu_dm_region { · 3 unmodified lines
144145 * @iova_to_phys: translate iova to physical address
145146 * @add_device: add device to iommu grouping
146147 * @remove_device: remove device from iommu grouping
148+ * @device_group: find iommu group for a particular device
147149 * @domain_get_attr: Query domain attributes
148150 * @domain_set_attr: Change domain attributes
151+ * @get_dm_regions: Request list of direct mapping requirements for a device
152+ * @put_dm_regions: Free list of direct mapping requirements for a device
153+ * @domain_window_enable: Configure and enable a particular window for a domain
154+ * @domain_window_disable: Disable a particular window for a domain
155+ * @domain_set_windows: Set the number of windows for a domain
156+ * @domain_get_windows: Return the number of windows for a domain
149157 * @of_xlate: add OF master IDs to iommu grouping
150158 * @pgsize_bitmap: bitmap of supported page sizes
151159 * @priv: per-instance data private to the iommu driver
@@ -182,9 +190,9 @@ struct iommu_ops { · 30 unmodified lines
182190 int (*domain_window_enable)(struct iommu_domain *domain, u32 wnd_nr,
183191 phys_addr_t paddr, u64 size, int prot);
184192 void (*domain_window_disable)(struct iommu_domain *domain, u32 wnd_nr);
185− /* Set the numer of window per domain */
193+ /* Set the number of windows per domain */
186194 int (*domain_set_windows)(struct iommu_domain *domain, u32 w_count);
187− /* Get the numer of window per domain */
195+ /* Get the number of windows per domain */
188196 u32 (*domain_get_windows)(struct iommu_domain *domain);
189197
190198 #ifdef CONFIG_OF_IOMMU
include/linux/irqdomain.h+1−0
@@ -70,6 +70,7 @@ struct irq_fwspec { · 69 unmodified lines
7070 */
7171 enum irq_domain_bus_token {
7272 DOMAIN_BUS_ANY = 0,
73+ DOMAIN_BUS_WIRED,
7374 DOMAIN_BUS_PCI_MSI,
7475 DOMAIN_BUS_PLATFORM_MSI,
7576 DOMAIN_BUS_NEXUS,
include/linux/perf_event.h+3−6
@@ -634,9 +634,6 @@ struct perf_event_context { · 633 unmodified lines
634634 int nr_cgroups; /* cgroup evts */
635635 void *task_ctx_data; /* pmu specific data */
636636 struct rcu_head rcu_head;
637−
638− struct delayed_work orphans_remove;
639− bool orphans_remove_sched;
640637 };
641638
642639 /*
@@ -729,7 +726,7 @@ extern int perf_event_init_task(struct task_struct *child); · 86 unmodified lines
729726 extern void perf_event_exit_task(struct task_struct *child);
730727 extern void perf_event_free_task(struct task_struct *task);
731728 extern void perf_event_delayed_put(struct task_struct *task);
732−extern struct perf_event *perf_event_get(unsigned int fd);
729+extern struct file *perf_event_get(unsigned int fd);
733730 extern const struct perf_event_attr *perf_event_attrs(struct perf_event *event);
734731 extern void perf_event_print_debug(void);
735732 extern void perf_pmu_disable(struct pmu *pmu);
@@ -1044,7 +1041,7 @@ extern void perf_swevent_put_recursion_context(int rctx); · 308 unmodified lines
10441041 extern u64 perf_swevent_set_period(struct perf_event *event);
10451042 extern void perf_event_enable(struct perf_event *event);
10461043 extern void perf_event_disable(struct perf_event *event);
1047−extern int __perf_event_disable(void *info);
1044+extern void perf_event_disable_local(struct perf_event *event);
10481045 extern void perf_event_task_tick(void);
10491046 #else /* !CONFIG_PERF_EVENTS: */
10501047 static inline void *
@@ -1070,7 +1067,7 @@ static inline int perf_event_init_task(struct task_struct *child) { return 0; } · 19 unmodified lines
10701067 static inline void perf_event_exit_task(struct task_struct *child) { }
10711068 static inline void perf_event_free_task(struct task_struct *task) { }
10721069 static inline void perf_event_delayed_put(struct task_struct *task) { }
1073−static inline struct perf_event *perf_event_get(unsigned int fd) { return ERR_PTR(-EINVAL); }
1070+static inline struct file *perf_event_get(unsigned int fd) { return ERR_PTR(-EINVAL); }
10741071 static inline const struct perf_event_attr *perf_event_attrs(struct perf_event *event)
10751072 {
10761073 return ERR_PTR(-EINVAL);
include/linux/swiotlb.h+3−0
@@ -1,10 +1,13 @@
11 #ifndef __LINUX_SWIOTLB_H
22 #define __LINUX_SWIOTLB_H
33
4+#include <linux/dma-direction.h>
5+#include <linux/init.h>
46 #include <linux/types.h>
57
68 struct device;
79 struct dma_attrs;
10+struct page;
811 struct scatterlist;
912
1013 extern int swiotlb_force;
include/linux/tty.h+1−0
@@ -649,6 +649,7 @@ extern long vt_compat_ioctl(struct tty_struct *tty, · 648 unmodified lines
649649 /* tty_mutex.c */
650650 /* functions for preparation of BKL removal */
651651 extern void __lockfunc tty_lock(struct tty_struct *tty);
652+extern int tty_lock_interruptible(struct tty_struct *tty);
652653 extern void __lockfunc tty_unlock(struct tty_struct *tty);
653654 extern void __lockfunc tty_lock_slave(struct tty_struct *tty);
654655 extern void __lockfunc tty_unlock_slave(struct tty_struct *tty);
include/trace/events/fence.h+1−1
@@ -17,7 +17,7 @@ TRACE_EVENT(fence_annotate_wait_on, · 16 unmodified lines
1717
1818 TP_STRUCT__entry(
1919 __string(driver, fence->ops->get_driver_name(fence))
20− __string(timeline, fence->ops->get_driver_name(fence))
20+ __string(timeline, fence->ops->get_timeline_name(fence))
2121 __field(unsigned int, context)
2222 __field(unsigned int, seqno)
2323
include/uapi/drm/etnaviv_drm.h+3−0
@@ -48,6 +48,8 @@ struct drm_etnaviv_timespec { · 47 unmodified lines
4848 #define ETNAVIV_PARAM_GPU_FEATURES_2 0x05
4949 #define ETNAVIV_PARAM_GPU_FEATURES_3 0x06
5050 #define ETNAVIV_PARAM_GPU_FEATURES_4 0x07
51+#define ETNAVIV_PARAM_GPU_FEATURES_5 0x08
52+#define ETNAVIV_PARAM_GPU_FEATURES_6 0x09
5153
5254 #define ETNAVIV_PARAM_GPU_STREAM_COUNT 0x10
5355 #define ETNAVIV_PARAM_GPU_REGISTER_MAX 0x11
@@ -59,6 +61,7 @@ struct drm_etnaviv_timespec { · 5 unmodified lines
5961 #define ETNAVIV_PARAM_GPU_BUFFER_SIZE 0x17
6062 #define ETNAVIV_PARAM_GPU_INSTRUCTION_COUNT 0x18
6163 #define ETNAVIV_PARAM_GPU_NUM_CONSTANTS 0x19
64+#define ETNAVIV_PARAM_GPU_NUM_VARYINGS 0x1a
6265
6366 #define ETNA_MAX_PIPES 4
6467
kernel/bpf/arraymap.c+11−10
@@ -291,10 +291,13 @@ static void *perf_event_fd_array_get_ptr(struct bpf_map *map, int fd) · 290 unmodified lines
291291 {
292292 struct perf_event *event;
293293 const struct perf_event_attr *attr;
294+ struct file *file;
294295
295− event = perf_event_get(fd);
296− if (IS_ERR(event))
297− return event;
296+ file = perf_event_get(fd);
297+ if (IS_ERR(file))
298+ return file;
299+
300+ event = file->private_data;
298301
299302 attr = perf_event_attrs(event);
300303 if (IS_ERR(attr))
@@ -304,24 +307,22 @@ static void *perf_event_fd_array_get_ptr(struct bpf_map *map, int fd) · 3 unmodified lines
304307 goto err;
305308
306309 if (attr->type == PERF_TYPE_RAW)
307− return event;
310+ return file;
308311
309312 if (attr->type == PERF_TYPE_HARDWARE)
310− return event;
313+ return file;
311314
312315 if (attr->type == PERF_TYPE_SOFTWARE &&
313316 attr->config == PERF_COUNT_SW_BPF_OUTPUT)
314− return event;
317+ return file;
315318 err:
316− perf_event_release_kernel(event);
319+ fput(file);
317320 return ERR_PTR(-EINVAL);
318321 }
319322
320323 static void perf_event_fd_array_put_ptr(void *ptr)
321324 {
322− struct perf_event *event = ptr;
323−
324− perf_event_release_kernel(event);
325+ fput((struct file *)ptr);
325326 }
326327
327328 static const struct bpf_map_ops perf_event_array_ops = {
kernel/events/core.c+599−600
@@ -49,8 +49,6 @@ · 48 unmodified lines
4949
5050 #include <asm/irq_regs.h>
5151
52−static struct workqueue_struct *perf_wq;
53−
5452 typedef int (*remote_function_f)(void *);
5553
5654 struct remote_function_call {
@@ -126,44 +124,181 @@ static int cpu_function_call(int cpu, remote_function_f func, void *info) · 69 unmodified lines
126124 return data.ret;
127125 }
128126
129−static void event_function_call(struct perf_event *event,
130− int (*active)(void *),
131− void (*inactive)(void *),
132− void *data)
127+static inline struct perf_cpu_context *
128+__get_cpu_context(struct perf_event_context *ctx)
129+{
130+ return this_cpu_ptr(ctx->pmu->pmu_cpu_context);
131+}
132+
133+static void perf_ctx_lock(struct perf_cpu_context *cpuctx,
134+ struct perf_event_context *ctx)
133135 {
136+ raw_spin_lock(&cpuctx->ctx.lock);
137+ if (ctx)
138+ raw_spin_lock(&ctx->lock);
139+}
140+
141+static void perf_ctx_unlock(struct perf_cpu_context *cpuctx,
142+ struct perf_event_context *ctx)
143+{
144+ if (ctx)
145+ raw_spin_unlock(&ctx->lock);
146+ raw_spin_unlock(&cpuctx->ctx.lock);
147+}
148+
149+#define TASK_TOMBSTONE ((void *)-1L)
150+
151+static bool is_kernel_event(struct perf_event *event)
152+{
153+ return READ_ONCE(event->owner) == TASK_TOMBSTONE;
154+}
155+
156+/*
157+ * On task ctx scheduling...
158+ *
159+ * When !ctx->nr_events a task context will not be scheduled. This means
160+ * we can disable the scheduler hooks (for performance) without leaving
161+ * pending task ctx state.
162+ *
163+ * This however results in two special cases:
164+ *
165+ * - removing the last event from a task ctx; this is relatively straight
166+ * forward and is done in __perf_remove_from_context.
167+ *
168+ * - adding the first event to a task ctx; this is tricky because we cannot
169+ * rely on ctx->is_active and therefore cannot use event_function_call().
170+ * See perf_install_in_context().
171+ *
172+ * This is because we need a ctx->lock serialized variable (ctx->is_active)
173+ * to reliably determine if a particular task/context is scheduled in. The
174+ * task_curr() use in task_function_call() is racy in that a remote context
175+ * switch is not a single atomic operation.
176+ *
177+ * As is, the situation is 'safe' because we set rq->curr before we do the
178+ * actual context switch. This means that task_curr() will fail early, but
179+ * we'll continue spinning on ctx->is_active until we've passed
180+ * perf_event_task_sched_out().
181+ *
182+ * Without this ctx->lock serialized variable we could have race where we find
183+ * the task (and hence the context) would not be active while in fact they are.
184+ *
185+ * If ctx->nr_events, then ctx->is_active and cpuctx->task_ctx are set.
186+ */
187+
188+typedef void (*event_f)(struct perf_event *, struct perf_cpu_context *,
189+ struct perf_event_context *, void *);
190+
191+struct event_function_struct {
192+ struct perf_event *event;
193+ event_f func;
194+ void *data;
195+};
196+
197+static int event_function(void *info)
198+{
199+ struct event_function_struct *efs = info;
200+ struct perf_event *event = efs->event;
134201 struct perf_event_context *ctx = event->ctx;
135− struct task_struct *task = ctx->task;
202+ struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
203+ struct perf_event_context *task_ctx = cpuctx->task_ctx;
204+ int ret = 0;
205+
206+ WARN_ON_ONCE(!irqs_disabled());
207+
208+ perf_ctx_lock(cpuctx, task_ctx);
209+ /*
210+ * Since we do the IPI call without holding ctx->lock things can have
211+ * changed, double check we hit the task we set out to hit.
212+ */
213+ if (ctx->task) {
214+ if (ctx->task != current) {
215+ ret = -EAGAIN;
216+ goto unlock;
217+ }
218+
219+ /*
220+ * We only use event_function_call() on established contexts,
221+ * and event_function() is only ever called when active (or
222+ * rather, we'll have bailed in task_function_call() or the
223+ * above ctx->task != current test), therefore we must have
224+ * ctx->is_active here.
225+ */
226+ WARN_ON_ONCE(!ctx->is_active);
227+ /*
228+ * And since we have ctx->is_active, cpuctx->task_ctx must
229+ * match.
230+ */
231+ WARN_ON_ONCE(task_ctx != ctx);
232+ } else {
233+ WARN_ON_ONCE(&cpuctx->ctx != ctx);
234+ }
235+
236+ efs->func(event, cpuctx, ctx, efs->data);
237+unlock:
238+ perf_ctx_unlock(cpuctx, task_ctx);
239+
240+ return ret;
241+}
242+
243+static void event_function_local(struct perf_event *event, event_f func, void *data)
244+{
245+ struct event_function_struct efs = {
246+ .event = event,
247+ .func = func,
248+ .data = data,
249+ };
250+
251+ int ret = event_function(&efs);
252+ WARN_ON_ONCE(ret);
253+}
254+
255+static void event_function_call(struct perf_event *event, event_f func, void *data)
256+{
257+ struct perf_event_context *ctx = event->ctx;
258+ struct task_struct *task = READ_ONCE(ctx->task); /* verified in event_function */
259+ struct event_function_struct efs = {
260+ .event = event,
261+ .func = func,
262+ .data = data,
263+ };
264+
265+ if (!event->parent) {
266+ /*
267+ * If this is a !child event, we must hold ctx::mutex to
268+ * stabilize the the event->ctx relation. See
269+ * perf_event_ctx_lock().
270+ */
271+ lockdep_assert_held(&ctx->mutex);
272+ }
136273
137274 if (!task) {
138− cpu_function_call(event->cpu, active, data);
275+ cpu_function_call(event->cpu, event_function, &efs);
139276 return;
140277 }
141278
142279 again:
143− if (!task_function_call(task, active, data))
280+ if (task == TASK_TOMBSTONE)
281+ return;
282+
283+ if (!task_function_call(task, event_function, &efs))
144284 return;
145285
146286 raw_spin_lock_irq(&ctx->lock);
147− if (ctx->is_active) {
148− /*
149− * Reload the task pointer, it might have been changed by
150− * a concurrent perf_event_context_sched_out().
151− */
152− task = ctx->task;
153− raw_spin_unlock_irq(&ctx->lock);
154− goto again;
287+ /*
288+ * Reload the task pointer, it might have been changed by
289+ * a concurrent perf_event_context_sched_out().
290+ */
291+ task = ctx->task;
292+ if (task != TASK_TOMBSTONE) {
293+ if (ctx->is_active) {
294+ raw_spin_unlock_irq(&ctx->lock);
295+ goto again;
296+ }
297+ func(event, NULL, ctx, data);
155298 }
156− inactive(data);
157299 raw_spin_unlock_irq(&ctx->lock);
158300 }
159301
160−#define EVENT_OWNER_KERNEL ((void *) -1)
161−
162−static bool is_kernel_event(struct perf_event *event)
163−{
164− return event->owner == EVENT_OWNER_KERNEL;
165−}
166−
167302 #define PERF_FLAG_ALL (PERF_FLAG_FD_NO_GROUP |\
168303 PERF_FLAG_FD_OUTPUT |\
169304 PERF_FLAG_PID_CGROUP |\
@@ -368,28 +503,6 @@ static inline u64 perf_event_clock(struct perf_event *event) · 198 unmodified lines
368503 return event->clock();
369504 }
370505
371−static inline struct perf_cpu_context *
372−__get_cpu_context(struct perf_event_context *ctx)
373−{
374− return this_cpu_ptr(ctx->pmu->pmu_cpu_context);
375−}
376−
377−static void perf_ctx_lock(struct perf_cpu_context *cpuctx,
378− struct perf_event_context *ctx)
379−{
380− raw_spin_lock(&cpuctx->ctx.lock);
381− if (ctx)
382− raw_spin_lock(&ctx->lock);
383−}
384−
385−static void perf_ctx_unlock(struct perf_cpu_context *cpuctx,
386− struct perf_event_context *ctx)
387−{
388− if (ctx)
389− raw_spin_unlock(&ctx->lock);
390− raw_spin_unlock(&cpuctx->ctx.lock);
391−}
392−
393506 #ifdef CONFIG_CGROUP_PERF
394507
395508 static inline bool
@@ -579,13 +692,7 @@ static inline void perf_cgroup_sched_out(struct task_struct *task, · 183 unmodified lines
579692 * we are holding the rcu lock
580693 */
581694 cgrp1 = perf_cgroup_from_task(task, NULL);
582−
583− /*
584− * next is NULL when called from perf_event_enable_on_exec()
585− * that will systematically cause a cgroup_switch()
586− */
587− if (next)
588− cgrp2 = perf_cgroup_from_task(next, NULL);
695+ cgrp2 = perf_cgroup_from_task(next, NULL);
589696
590697 /*
591698 * only schedule out current cgroup events if we know
@@ -611,8 +718,6 @@ static inline void perf_cgroup_sched_in(struct task_struct *prev, · 19 unmodified lines
611718 * we are holding the rcu lock
612719 */
613720 cgrp1 = perf_cgroup_from_task(task, NULL);
614−
615− /* prev can never be NULL */
616721 cgrp2 = perf_cgroup_from_task(prev, NULL);
617722
618723 /*
@@ -917,7 +1022,7 @@ static void put_ctx(struct perf_event_context *ctx) · 298 unmodified lines
9171022 if (atomic_dec_and_test(&ctx->refcount)) {
9181023 if (ctx->parent_ctx)
9191024 put_ctx(ctx->parent_ctx);
920− if (ctx->task)
1025+ if (ctx->task && ctx->task != TASK_TOMBSTONE)
9211026 put_task_struct(ctx->task);
9221027 call_rcu(&ctx->rcu_head, free_ctx);
9231028 }
@@ -934,9 +1039,8 @@ static void put_ctx(struct perf_event_context *ctx) · 10 unmodified lines
9341039 * perf_event_context::mutex nests and those are:
9351040 *
9361041 * - perf_event_exit_task_context() [ child , 0 ]
937− * __perf_event_exit_task()
938− * sync_child_event()
939− * put_event() [ parent, 1 ]
1042+ * perf_event_exit_event()
1043+ * put_event() [ parent, 1 ]
9401044 *
9411045 * - perf_event_init_context() [ parent, 0 ]
9421046 * inherit_task_group()
@@ -979,8 +1083,8 @@ static void put_ctx(struct perf_event_context *ctx) · 36 unmodified lines
9791083 * Lock order:
9801084 * task_struct::perf_event_mutex
9811085 * perf_event_context::mutex
982− * perf_event_context::lock
9831086 * perf_event::child_mutex;
1087+ * perf_event_context::lock
9841088 * perf_event::mmap_mutex
9851089 * mmap_sem
9861090 */
@@ -1078,6 +1182,7 @@ static u64 primary_event_id(struct perf_event *event) · 91 unmodified lines
10781182
10791183 /*
10801184 * Get the perf_event_context for a task and lock it.
1185+ *
10811186 * This has to cope with with the fact that until it is locked,
10821187 * the context could get moved to another task.
10831188 */
@@ -1118,9 +1223,12 @@ retry: · 34 unmodified lines
11181223 goto retry;
11191224 }
11201225
1121− if (!atomic_inc_not_zero(&ctx->refcount)) {
1226+ if (ctx->task == TASK_TOMBSTONE ||
1227+ !atomic_inc_not_zero(&ctx->refcount)) {
11221228 raw_spin_unlock(&ctx->lock);
11231229 ctx = NULL;
1230+ } else {
1231+ WARN_ON_ONCE(ctx->task != task);
11241232 }
11251233 }
11261234 rcu_read_unlock();
@@ -1246,6 +1354,8 @@ ctx_group_list(struct perf_event *event, struct perf_event_context *ctx) · 119 unmodified lines
12461354 static void
12471355 list_add_event(struct perf_event *event, struct perf_event_context *ctx)
12481356 {
1357+ lockdep_assert_held(&ctx->lock);
1358+
12491359 WARN_ON_ONCE(event->attach_state & PERF_ATTACH_CONTEXT);
12501360 event->attach_state |= PERF_ATTACH_CONTEXT;
12511361
@@ -1448,11 +1558,14 @@ list_del_event(struct perf_event *event, struct perf_event_context *ctx) · 196 unmodified lines
14481558
14491559 if (is_cgroup_event(event)) {
14501560 ctx->nr_cgroups--;
1561+ /*
1562+ * Because cgroup events are always per-cpu events, this will
1563+ * always be called from the right CPU.
1564+ */
14511565 cpuctx = __get_cpu_context(ctx);
14521566 /*
1453− * if there are no more cgroup events
1454− * then cler cgrp to avoid stale pointer
1455− * in update_cgrp_time_from_cpuctx()
1567+ * If there are no more cgroup events then clear cgrp to avoid
1568+ * stale pointer in update_cgrp_time_from_cpuctx().
14561569 */
14571570 if (!ctx->nr_cgroups)
14581571 cpuctx->cgrp = NULL;
@@ -1530,45 +1643,11 @@ out: · 71 unmodified lines
15301643 perf_event__header_size(tmp);
15311644 }
15321645
1533−/*
1534− * User event without the task.
1535− */
15361646 static bool is_orphaned_event(struct perf_event *event)
15371647 {
1538− return event && !is_kernel_event(event) && !event->owner;
1648+ return event->state == PERF_EVENT_STATE_EXIT;
15391649 }
15401650
1541−/*
1542− * Event has a parent but parent's task finished and it's
1543− * alive only because of children holding refference.
1544− */
1545−static bool is_orphaned_child(struct perf_event *event)
1546−{
1547− return is_orphaned_event(event->parent);
1548−}
1549−
1550−static void orphans_remove_work(struct work_struct *work);
1551−
1552−static void schedule_orphans_remove(struct perf_event_context *ctx)
1553−{
1554− if (!ctx->task || ctx->orphans_remove_sched || !perf_wq)
1555− return;
1556−
1557− if (queue_delayed_work(perf_wq, &ctx->orphans_remove, 1)) {
1558− get_ctx(ctx);
1559− ctx->orphans_remove_sched = true;
1560− }
1561−}
1562−
1563−static int __init perf_workqueue_init(void)
1564−{
1565− perf_wq = create_singlethread_workqueue("perf");
1566− WARN(!perf_wq, "failed to create perf workqueue\n");
1567− return perf_wq ? 0 : -1;
1568−}
1569−
1570−core_initcall(perf_workqueue_init);
1571−
15721651 static inline int pmu_filter_match(struct perf_event *event)
15731652 {
15741653 struct pmu *pmu = event->pmu;
@@ -1629,9 +1708,6 @@ event_sched_out(struct perf_event *event, · 54 unmodified lines
16291708 if (event->attr.exclusive || !cpuctx->active_oncpu)
16301709 cpuctx->exclusive = 0;
16311710
1632− if (is_orphaned_child(event))
1633− schedule_orphans_remove(ctx);
1634−
16351711 perf_pmu_enable(event->pmu);
16361712 }
16371713
@@ -1655,21 +1731,8 @@ group_sched_out(struct perf_event *group_event, · 17 unmodified lines
16551731 cpuctx->exclusive = 0;
16561732 }
16571733
1658−struct remove_event {
1659− struct perf_event *event;
1660− bool detach_group;
1661−};
1662−
1663−static void ___perf_remove_from_context(void *info)
1664−{
1665− struct remove_event *re = info;
1666− struct perf_event *event = re->event;
1667− struct perf_event_context *ctx = event->ctx;
1668−
1669− if (re->detach_group)
1670− perf_group_detach(event);
1671− list_del_event(event, ctx);
1672−}
1734+#define DETACH_GROUP 0x01UL
1735+#define DETACH_STATE 0x02UL
16731736
16741737 /*
16751738 * Cross CPU call to remove a performance event
@@ -1677,33 +1740,33 @@ static void ___perf_remove_from_context(void *info) · 1 unmodified line
16771740 * We disable the event on the hardware level first. After that we
16781741 * remove it from the context list.
16791742 */
1680−static int __perf_remove_from_context(void *info)
1743+static void
1744+__perf_remove_from_context(struct perf_event *event,
1745+ struct perf_cpu_context *cpuctx,
1746+ struct perf_event_context *ctx,
1747+ void *info)
16811748 {
1682− struct remove_event *re = info;
1683− struct perf_event *event = re->event;
1684− struct perf_event_context *ctx = event->ctx;
1685− struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
1749+ unsigned long flags = (unsigned long)info;
16861750
1687− raw_spin_lock(&ctx->lock);
16881751 event_sched_out(event, cpuctx, ctx);
1689− if (re->detach_group)
1752+ if (flags & DETACH_GROUP)
16901753 perf_group_detach(event);
16911754 list_del_event(event, ctx);
1692− if (!ctx->nr_events && cpuctx->task_ctx == ctx) {
1755+ if (flags & DETACH_STATE)
1756+ event->state = PERF_EVENT_STATE_EXIT;
1757+
1758+ if (!ctx->nr_events && ctx->is_active) {
16931759 ctx->is_active = 0;
1694− cpuctx->task_ctx = NULL;
1760+ if (ctx->task) {
1761+ WARN_ON_ONCE(cpuctx->task_ctx != ctx);
1762+ cpuctx->task_ctx = NULL;
1763+ }
16951764 }
1696− raw_spin_unlock(&ctx->lock);
1697−
1698− return 0;
16991765 }
17001766
17011767 /*
17021768 * Remove the event from a task's (or a CPU's) list of events.
17031769 *
1704− * CPU events are removed with a smp call. For task events we only
1705− * call when the task is on a CPU.
1706− *
17071770 * If event->ctx is a cloned context, callers must make sure that
17081771 * every task struct that event->ctx->task could possibly point to
17091772 * remains valid. This is OK when called from perf_release since
@@ -1711,73 +1774,32 @@ static int __perf_remove_from_context(void *info) · 1 unmodified line
17111774 * When called from perf_event_exit_task, it's OK because the
17121775 * context has been detached from its task.
17131776 */
1714−static void perf_remove_from_context(struct perf_event *event, bool detach_group)
1777+static void perf_remove_from_context(struct perf_event *event, unsigned long flags)
17151778 {
1716− struct perf_event_context *ctx = event->ctx;
1717− struct remove_event re = {
1718− .event = event,
1719− .detach_group = detach_group,
1720− };
1779+ lockdep_assert_held(&event->ctx->mutex);
17211780
1722− lockdep_assert_held(&ctx->mutex);
1723−
1724− event_function_call(event, __perf_remove_from_context,
1725− ___perf_remove_from_context, &re);
1781+ event_function_call(event, __perf_remove_from_context, (void *)flags);
17261782 }
17271783
17281784 /*
17291785 * Cross CPU call to disable a performance event
17301786 */
1731−int __perf_event_disable(void *info)
1732−{
1733− struct perf_event *event = info;
1734− struct perf_event_context *ctx = event->ctx;
1735− struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
1736−
1737− /*
1738− * If this is a per-task event, need to check whether this
1739− * event's task is the current task on this cpu.
1740− *
1741− * Can trigger due to concurrent perf_event_context_sched_out()
1742− * flipping contexts around.
1743− */
1744− if (ctx->task && cpuctx->task_ctx != ctx)
1745− return -EINVAL;
1746−
1747− raw_spin_lock(&ctx->lock);
1748−
1749− /*
1750− * If the event is on, turn it off.
1751− * If it is in error state, leave it in error state.
1752− */
1753− if (event->state >= PERF_EVENT_STATE_INACTIVE) {
1754− update_context_time(ctx);
1755− update_cgrp_time_from_event(event);
1756− update_group_times(event);
1757− if (event == event->group_leader)
1758− group_sched_out(event, cpuctx, ctx);
1759− else
1760− event_sched_out(event, cpuctx, ctx);
1761− event->state = PERF_EVENT_STATE_OFF;
1762− }
1763−
1764− raw_spin_unlock(&ctx->lock);
1765−
1766− return 0;
1767−}
1768−
1769−void ___perf_event_disable(void *info)
1787+static void __perf_event_disable(struct perf_event *event,
1788+ struct perf_cpu_context *cpuctx,
1789+ struct perf_event_context *ctx,
1790+ void *info)
17701791 {
1771− struct perf_event *event = info;
1792+ if (event->state < PERF_EVENT_STATE_INACTIVE)
1793+ return;
17721794
1773− /*
1774− * Since we have the lock this context can't be scheduled
1775− * in, so we can change the state safely.
1776− */
1777− if (event->state == PERF_EVENT_STATE_INACTIVE) {
1778− update_group_times(event);
1779− event->state = PERF_EVENT_STATE_OFF;
1780− }
1795+ update_context_time(ctx);
1796+ update_cgrp_time_from_event(event);
1797+ update_group_times(event);
1798+ if (event == event->group_leader)
1799+ group_sched_out(event, cpuctx, ctx);
1800+ else
1801+ event_sched_out(event, cpuctx, ctx);
1802+ event->state = PERF_EVENT_STATE_OFF;
17811803 }
17821804
17831805 /*
@@ -1788,7 +1810,8 @@ void ___perf_event_disable(void *info) · 4 unmodified lines
17881810 * remains valid. This condition is satisifed when called through
17891811 * perf_event_for_each_child or perf_event_for_each because they
17901812 * hold the top-level event's child_mutex, so any descendant that
1791− * goes to exit will block in sync_child_event.
1813+ * goes to exit will block in perf_event_exit_event().
1814+ *
17921815 * When called from perf_pending_event it's OK because event->ctx
17931816 * is the current context on this CPU and preemption is disabled,
17941817 * hence we can't get into perf_event_task_sched_out for this context.
@@ -1804,8 +1827,12 @@ static void _perf_event_disable(struct perf_event *event) · 9 unmodified lines
18041827 }
18051828 raw_spin_unlock_irq(&ctx->lock);
18061829
1807− event_function_call(event, __perf_event_disable,
1808− ___perf_event_disable, event);
1830+ event_function_call(event, __perf_event_disable, NULL);
1831+}
1832+
1833+void perf_event_disable_local(struct perf_event *event)
1834+{
1835+ event_function_local(event, __perf_event_disable, NULL);
18091836 }
18101837
18111838 /*
@@ -1918,9 +1945,6 @@ event_sched_in(struct perf_event *event, · 106 unmodified lines
19181945 if (event->attr.exclusive)
19191946 cpuctx->exclusive = 1;
19201947
1921− if (is_orphaned_child(event))
1922− schedule_orphans_remove(ctx);
1923−
19241948 out:
19251949 perf_pmu_enable(event->pmu);
19261950
@@ -2039,7 +2063,8 @@ static void add_event_to_ctx(struct perf_event *event, · 112 unmodified lines
20392063 event->tstamp_stopped = tstamp;
20402064 }
20412065
2042−static void task_ctx_sched_out(struct perf_event_context *ctx);
2066+static void task_ctx_sched_out(struct perf_cpu_context *cpuctx,
2067+ struct perf_event_context *ctx);
20432068 static void
20442069 ctx_sched_in(struct perf_event_context *ctx,
20452070 struct perf_cpu_context *cpuctx,
@@ -2058,16 +2083,15 @@ static void perf_event_sched_in(struct perf_cpu_context *cpuctx, · 12 unmodified lines
20582083 ctx_sched_in(ctx, cpuctx, EVENT_FLEXIBLE, task);
20592084 }
20602085
2061−static void ___perf_install_in_context(void *info)
2086+static void ctx_resched(struct perf_cpu_context *cpuctx,
2087+ struct perf_event_context *task_ctx)
20622088 {
2063− struct perf_event *event = info;
2064− struct perf_event_context *ctx = event->ctx;
2065−
2066− /*
2067− * Since the task isn't running, its safe to add the event, us holding
2068− * the ctx->lock ensures the task won't get scheduled in.
2069− */
2070− add_event_to_ctx(event, ctx);
2089+ perf_pmu_disable(cpuctx->ctx.pmu);
2090+ if (task_ctx)
2091+ task_ctx_sched_out(cpuctx, task_ctx);
2092+ cpu_ctx_sched_out(cpuctx, EVENT_ALL);
2093+ perf_event_sched_in(cpuctx, task_ctx, current);
2094+ perf_pmu_enable(cpuctx->ctx.pmu);
20712095 }
20722096
20732097 /*
@@ -2077,55 +2101,31 @@ static void ___perf_install_in_context(void *info) · 3 unmodified lines
20772101 */
20782102 static int __perf_install_in_context(void *info)
20792103 {
2080− struct perf_event *event = info;
2081− struct perf_event_context *ctx = event->ctx;
2104+ struct perf_event_context *ctx = info;
20822105 struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
20832106 struct perf_event_context *task_ctx = cpuctx->task_ctx;
2084− struct task_struct *task = current;
2085−
2086− perf_ctx_lock(cpuctx, task_ctx);
2087− perf_pmu_disable(cpuctx->ctx.pmu);
20882107
2089− /*
2090− * If there was an active task_ctx schedule it out.
2091− */
2092− if (task_ctx)
2093− task_ctx_sched_out(task_ctx);
2094−
2095− /*
2096− * If the context we're installing events in is not the
2097− * active task_ctx, flip them.
2098− */
2099− if (ctx->task && task_ctx != ctx) {
2100− if (task_ctx)
2101− raw_spin_unlock(&task_ctx->lock);
2108+ raw_spin_lock(&cpuctx->ctx.lock);
2109+ if (ctx->task) {
21022110 raw_spin_lock(&ctx->lock);
2111+ /*
2112+ * If we hit the 'wrong' task, we've since scheduled and
2113+ * everything should be sorted, nothing to do!
2114+ */
21032115 task_ctx = ctx;
2104− }
2116+ if (ctx->task != current)
2117+ goto unlock;
21052118
2106− if (task_ctx) {
2107− cpuctx->task_ctx = task_ctx;
2108− task = task_ctx->task;
2119+ /*
2120+ * If task_ctx is set, it had better be to us.
2121+ */
2122+ WARN_ON_ONCE(cpuctx->task_ctx != ctx && cpuctx->task_ctx);
2123+ } else if (task_ctx) {
2124+ raw_spin_lock(&task_ctx->lock);
21092125 }
21102126
2111− cpu_ctx_sched_out(cpuctx, EVENT_ALL);
2112−
2113− update_context_time(ctx);
2114− /*
2115− * update cgrp time only if current cgrp
2116− * matches event->cgrp. Must be done before
2117− * calling add_event_to_ctx()
2118− */
2119− update_cgrp_time_from_event(event);
2120−
2121− add_event_to_ctx(event, ctx);
2122−
2123− /*
2124− * Schedule everything back in
2125− */
2126− perf_event_sched_in(cpuctx, task_ctx, task);
2127−
2128− perf_pmu_enable(cpuctx->ctx.pmu);
2127+ ctx_resched(cpuctx, task_ctx);
2128+unlock:
21292129 perf_ctx_unlock(cpuctx, task_ctx);
21302130
21312131 return 0;
@@ -2133,27 +2133,54 @@ static int __perf_install_in_context(void *info) · 1 unmodified line
21332133
21342134 /*
21352135 * Attach a performance event to a context
2136− *
2137− * First we add the event to the list with the hardware enable bit
2138− * in event->hw_config cleared.
2139− *
2140− * If the event is attached to a task which is on a CPU we use a smp
2141− * call to enable it in the task context. The task might have been
2142− * scheduled away, but we check this in the smp call again.
21432136 */
21442137 static void
21452138 perf_install_in_context(struct perf_event_context *ctx,
21462139 struct perf_event *event,
21472140 int cpu)
21482141 {
2142+ struct task_struct *task = NULL;
2143+
21492144 lockdep_assert_held(&ctx->mutex);
21502145
21512146 event->ctx = ctx;
21522147 if (event->cpu != -1)
21532148 event->cpu = cpu;
21542149
2155− event_function_call(event, __perf_install_in_context,
2156− ___perf_install_in_context, event);
2150+ /*
2151+ * Installing events is tricky because we cannot rely on ctx->is_active
2152+ * to be set in case this is the nr_events 0 -> 1 transition.
2153+ *
2154+ * So what we do is we add the event to the list here, which will allow
2155+ * a future context switch to DTRT and then send a racy IPI. If the IPI
2156+ * fails to hit the right task, this means a context switch must have
2157+ * happened and that will have taken care of business.
2158+ */
2159+ raw_spin_lock_irq(&ctx->lock);
2160+ task = ctx->task;
2161+ /*
2162+ * Worse, we cannot even rely on the ctx actually existing anymore. If
2163+ * between find_get_context() and perf_install_in_context() the task
2164+ * went through perf_event_exit_task() its dead and we should not be
2165+ * adding new events.
2166+ */
2167+ if (task == TASK_TOMBSTONE) {
2168+ raw_spin_unlock_irq(&ctx->lock);
2169+ return;
2170+ }
2171+ update_context_time(ctx);
2172+ /*
2173+ * Update cgrp time only if current cgrp matches event->cgrp.
2174+ * Must be done before calling add_event_to_ctx().
2175+ */
2176+ update_cgrp_time_from_event(event);
2177+ add_event_to_ctx(event, ctx);
2178+ raw_spin_unlock_irq(&ctx->lock);
2179+
2180+ if (task)
2181+ task_function_call(task, __perf_install_in_context, ctx);
2182+ else
2183+ cpu_function_call(cpu, __perf_install_in_context, ctx);
21572184 }
21582185
21592186 /*
@@ -2180,43 +2207,30 @@ static void __perf_event_mark_enabled(struct perf_event *event) · 20 unmodified lines
21802207 /*
21812208 * Cross CPU call to enable a performance event
21822209 */
2183−static int __perf_event_enable(void *info)
2210+static void __perf_event_enable(struct perf_event *event,
2211+ struct perf_cpu_context *cpuctx,
2212+ struct perf_event_context *ctx,
2213+ void *info)
21842214 {
2185− struct perf_event *event = info;
2186− struct perf_event_context *ctx = event->ctx;
21872215 struct perf_event *leader = event->group_leader;
2188− struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
2189− int err;
2216+ struct perf_event_context *task_ctx;
21902217
2191− /*
2192− * There's a time window between 'ctx->is_active' check
2193− * in perf_event_enable function and this place having:
2194− * - IRQs on
2195− * - ctx->lock unlocked
2196− *
2197− * where the task could be killed and 'ctx' deactivated
2198− * by perf_event_exit_task.
2199− */
2200− if (!ctx->is_active)
2201− return -EINVAL;
2218+ if (event->state >= PERF_EVENT_STATE_INACTIVE ||
2219+ event->state <= PERF_EVENT_STATE_ERROR)
2220+ return;
22022221
2203− raw_spin_lock(&ctx->lock);
22042222 update_context_time(ctx);
2205−
2206− if (event->state >= PERF_EVENT_STATE_INACTIVE)
2207− goto unlock;
2208−
2209− /*
2210− * set current task's cgroup time reference point
2211− */
2212− perf_cgroup_set_timestamp(current, ctx);
2213−
22142223 __perf_event_mark_enabled(event);
22152224
2225+ if (!ctx->is_active)
2226+ return;
2227+
22162228 if (!event_filter_match(event)) {
2217− if (is_cgroup_event(event))
2229+ if (is_cgroup_event(event)) {
2230+ perf_cgroup_set_timestamp(current, ctx); // XXX ?
22182231 perf_cgroup_defer_enabled(event);
2219− goto unlock;
2232+ }
2233+ return;
22202234 }
22212235
22222236 /*
@@ -2224,41 +2238,13 @@ static int __perf_event_enable(void *info) · 1 unmodified line
22242238 * then don't put it on unless the group is on.
22252239 */
22262240 if (leader != event && leader->state != PERF_EVENT_STATE_ACTIVE)
2227− goto unlock;
2228−
2229− if (!group_can_go_on(event, cpuctx, 1)) {
2230− err = -EEXIST;
2231− } else {
2232− if (event == leader)
2233− err = group_sched_in(event, cpuctx, ctx);
2234− else
2235− err = event_sched_in(event, cpuctx, ctx);
2236− }
2237−
2238− if (err) {
2239− /*
2240− * If this event can't go on and it's part of a
2241− * group, then the whole group has to come off.
2242− */
2243− if (leader != event) {
2244− group_sched_out(leader, cpuctx, ctx);
2245− perf_mux_hrtimer_restart(cpuctx);
2246− }
2247− if (leader->attr.pinned) {
2248− update_group_times(leader);
2249− leader->state = PERF_EVENT_STATE_ERROR;
2250− }
2251− }
2252−
2253−unlock:
2254− raw_spin_unlock(&ctx->lock);
2241+ return;
22552242
2256− return 0;
2257−}
2243+ task_ctx = cpuctx->task_ctx;
2244+ if (ctx->task)
2245+ WARN_ON_ONCE(task_ctx != ctx);
22582246
2259−void ___perf_event_enable(void *info)
2260−{
2261− __perf_event_mark_enabled((struct perf_event *)info);
2247+ ctx_resched(cpuctx, task_ctx);
22622248 }
22632249
22642250 /*
@@ -2275,7 +2261,8 @@ static void _perf_event_enable(struct perf_event *event) · 10 unmodified lines
22752261 struct perf_event_context *ctx = event->ctx;
22762262
22772263 raw_spin_lock_irq(&ctx->lock);
2278− if (event->state >= PERF_EVENT_STATE_INACTIVE) {
2264+ if (event->state >= PERF_EVENT_STATE_INACTIVE ||
2265+ event->state < PERF_EVENT_STATE_ERROR) {
22792266 raw_spin_unlock_irq(&ctx->lock);
22802267 return;
22812268 }
@@ -2291,8 +2278,7 @@ static void _perf_event_enable(struct perf_event *event) · 9 unmodified lines
22912278 event->state = PERF_EVENT_STATE_OFF;
22922279 raw_spin_unlock_irq(&ctx->lock);
22932280
2294− event_function_call(event, __perf_event_enable,
2295− ___perf_event_enable, event);
2281+ event_function_call(event, __perf_event_enable, NULL);
22962282 }
22972283
22982284 /*
@@ -2342,12 +2328,27 @@ static void ctx_sched_out(struct perf_event_context *ctx, · 43 unmodified lines
23422328 struct perf_cpu_context *cpuctx,
23432329 enum event_type_t event_type)
23442330 {
2345− struct perf_event *event;
23462331 int is_active = ctx->is_active;
2332+ struct perf_event *event;
23472333
2348− ctx->is_active &= ~event_type;
2349− if (likely(!ctx->nr_events))
2334+ lockdep_assert_held(&ctx->lock);
2335+
2336+ if (likely(!ctx->nr_events)) {
2337+ /*
2338+ * See __perf_remove_from_context().
2339+ */
2340+ WARN_ON_ONCE(ctx->is_active);
2341+ if (ctx->task)
2342+ WARN_ON_ONCE(cpuctx->task_ctx);
23502343 return;
2344+ }
2345+
2346+ ctx->is_active &= ~event_type;
2347+ if (ctx->task) {
2348+ WARN_ON_ONCE(cpuctx->task_ctx != ctx);
2349+ if (!ctx->is_active)
2350+ cpuctx->task_ctx = NULL;
2351+ }
23512352
23522353 update_context_time(ctx);
23532354 update_cgrp_time_from_cpuctx(cpuctx);
@@ -2518,17 +2519,21 @@ static void perf_event_context_sched_out(struct task_struct *task, int ctxn, · 164 unmodified lines
25182519 raw_spin_lock(&ctx->lock);
25192520 raw_spin_lock_nested(&next_ctx->lock, SINGLE_DEPTH_NESTING);
25202521 if (context_equiv(ctx, next_ctx)) {
2521− /*
2522− * XXX do we need a memory barrier of sorts
2523− * wrt to rcu_dereference() of perf_event_ctxp
2524− */
2525− task->perf_event_ctxp[ctxn] = next_ctx;
2526− next->perf_event_ctxp[ctxn] = ctx;
2527− ctx->task = next;
2528− next_ctx->task = task;
2522+ WRITE_ONCE(ctx->task, next);
2523+ WRITE_ONCE(next_ctx->task, task);
25292524
25302525 swap(ctx->task_ctx_data, next_ctx->task_ctx_data);
25312526
2527+ /*
2528+ * RCU_INIT_POINTER here is safe because we've not
2529+ * modified the ctx and the above modification of
2530+ * ctx->task and ctx->task_ctx_data are immaterial
2531+ * since those values are always verified under
2532+ * ctx->lock which we're now holding.
2533+ */
2534+ RCU_INIT_POINTER(task->perf_event_ctxp[ctxn], next_ctx);
2535+ RCU_INIT_POINTER(next->perf_event_ctxp[ctxn], ctx);
2536+
25322537 do_switch = 0;
25332538
25342539 perf_event_sync_stat(ctx, next_ctx);
@@ -2541,8 +2546,7 @@ unlock: · 6 unmodified lines
25412546
25422547 if (do_switch) {
25432548 raw_spin_lock(&ctx->lock);
2544− ctx_sched_out(ctx, cpuctx, EVENT_ALL);
2545− cpuctx->task_ctx = NULL;
2549+ task_ctx_sched_out(cpuctx, ctx);
25462550 raw_spin_unlock(&ctx->lock);
25472551 }
25482552 }
@@ -2637,10 +2641,9 @@ void __perf_event_task_sched_out(struct task_struct *task, · 88 unmodified lines
26372641 perf_cgroup_sched_out(task, next);
26382642 }
26392643
2640−static void task_ctx_sched_out(struct perf_event_context *ctx)
2644+static void task_ctx_sched_out(struct perf_cpu_context *cpuctx,
2645+ struct perf_event_context *ctx)
26412646 {
2642− struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
2643−
26442647 if (!cpuctx->task_ctx)
26452648 return;
26462649
@@ -2648,7 +2651,6 @@ static void task_ctx_sched_out(struct perf_event_context *ctx) · 1 unmodified line
26482651 return;
26492652
26502653 ctx_sched_out(ctx, cpuctx, EVENT_ALL);
2651− cpuctx->task_ctx = NULL;
26522654 }
26532655
26542656 /*
@@ -2725,13 +2727,22 @@ ctx_sched_in(struct perf_event_context *ctx, · 70 unmodified lines
27252727 enum event_type_t event_type,
27262728 struct task_struct *task)
27272729 {
2728− u64 now;
27292730 int is_active = ctx->is_active;
2731+ u64 now;
2732+
2733+ lockdep_assert_held(&ctx->lock);
27302734
2731− ctx->is_active |= event_type;
27322735 if (likely(!ctx->nr_events))
27332736 return;
27342737
2738+ ctx->is_active |= event_type;
2739+ if (ctx->task) {
2740+ if (!is_active)
2741+ cpuctx->task_ctx = ctx;
2742+ else
2743+ WARN_ON_ONCE(cpuctx->task_ctx != ctx);
2744+ }
2745+
27352746 now = perf_clock();
27362747 ctx->timestamp = now;
27372748 perf_cgroup_set_timestamp(task, ctx);
@@ -2773,12 +2784,7 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx, · 35 unmodified lines
27732784 * cpu flexible, task flexible.
27742785 */
27752786 cpu_ctx_sched_out(cpuctx, EVENT_FLEXIBLE);
2776−
2777− if (ctx->nr_events)
2778− cpuctx->task_ctx = ctx;
2779−
2780− perf_event_sched_in(cpuctx, cpuctx->task_ctx, task);
2781−
2787+ perf_event_sched_in(cpuctx, ctx, task);
27822788 perf_pmu_enable(ctx->pmu);
27832789 perf_ctx_unlock(cpuctx, ctx);
27842790 }
@@ -2800,6 +2806,16 @@ void __perf_event_task_sched_in(struct task_struct *prev, · 15 unmodified lines
28002806 struct perf_event_context *ctx;
28012807 int ctxn;
28022808
2809+ /*
2810+ * If cgroup events exist on this CPU, then we need to check if we have
2811+ * to switch in PMU state; cgroup event are system-wide mode only.
2812+ *
2813+ * Since cgroup events are CPU events, we must schedule these in before
2814+ * we schedule in the task events.
2815+ */
2816+ if (atomic_read(this_cpu_ptr(&perf_cgroup_events)))
2817+ perf_cgroup_sched_in(prev, task);
2818+
28032819 for_each_task_context_nr(ctxn) {
28042820 ctx = task->perf_event_ctxp[ctxn];
28052821 if (likely(!ctx))
@@ -2807,13 +2823,6 @@ void __perf_event_task_sched_in(struct task_struct *prev, · 1 unmodified line
28072823
28082824 perf_event_context_sched_in(ctx, task);
28092825 }
2810− /*
2811− * if cgroup events exist on this CPU, then we need
2812− * to check if we have to switch in PMU state.
2813− * cgroup event are system-wide mode only
2814− */
2815− if (atomic_read(this_cpu_ptr(&perf_cgroup_events)))
2816− perf_cgroup_sched_in(prev, task);
28172826
28182827 if (atomic_read(&nr_switch_events))
28192828 perf_event_switch(task, prev, true);
@@ -3099,46 +3108,30 @@ static int event_enable_on_exec(struct perf_event *event, · 279 unmodified lines
30993108 static void perf_event_enable_on_exec(int ctxn)
31003109 {
31013110 struct perf_event_context *ctx, *clone_ctx = NULL;
3111+ struct perf_cpu_context *cpuctx;
31023112 struct perf_event *event;
31033113 unsigned long flags;
31043114 int enabled = 0;
3105− int ret;
31063115
31073116 local_irq_save(flags);
31083117 ctx = current->perf_event_ctxp[ctxn];
31093118 if (!ctx || !ctx->nr_events)
31103119 goto out;
31113120
3112− /*
3113− * We must ctxsw out cgroup events to avoid conflict
3114− * when invoking perf_task_event_sched_in() later on
3115− * in this function. Otherwise we end up trying to
3116− * ctxswin cgroup events which are already scheduled
3117− * in.
3118− */
3119− perf_cgroup_sched_out(current, NULL);
3120−
3121− raw_spin_lock(&ctx->lock);
3122− task_ctx_sched_out(ctx);
3123−
3124− list_for_each_entry(event, &ctx->event_list, event_entry) {
3125− ret = event_enable_on_exec(event, ctx);
3126− if (ret)
3127− enabled = 1;
3128− }
3121+ cpuctx = __get_cpu_context(ctx);
3122+ perf_ctx_lock(cpuctx, ctx);
3123+ list_for_each_entry(event, &ctx->event_list, event_entry)
3124+ enabled |= event_enable_on_exec(event, ctx);
31293125
31303126 /*
3131− * Unclone this context if we enabled any event.
3127+ * Unclone and reschedule this context if we enabled any event.
31323128 */
3133− if (enabled)
3129+ if (enabled) {
31343130 clone_ctx = unclone_ctx(ctx);
3131+ ctx_resched(cpuctx, ctx);
3132+ }
3133+ perf_ctx_unlock(cpuctx, ctx);
31353134
3136− raw_spin_unlock(&ctx->lock);
3137−
3138− /*
3139− * Also calls ctxswin for cgroup events, if any:
3140− */
3141− perf_event_context_sched_in(ctx, ctx->task);
31423135 out:
31433136 local_irq_restore(flags);
31443137
@@ -3334,7 +3327,6 @@ static void __perf_event_init_context(struct perf_event_context *ctx) · 189 unmodified lines
33343327 INIT_LIST_HEAD(&ctx->flexible_groups);
33353328 INIT_LIST_HEAD(&ctx->event_list);
33363329 atomic_set(&ctx->refcount, 1);
3337− INIT_DELAYED_WORK(&ctx->orphans_remove, orphans_remove_work);
33383330 }
33393331
33403332 static struct perf_event_context *
@@ -3521,11 +3513,13 @@ static void unaccount_event_cpu(struct perf_event *event, int cpu) · 180 unmodified lines
35213513
35223514 static void unaccount_event(struct perf_event *event)
35233515 {
3516+ bool dec = false;
3517+
35243518 if (event->parent)
35253519 return;
35263520
35273521 if (event->attach_state & PERF_ATTACH_TASK)
3528− static_key_slow_dec_deferred(&perf_sched_events);
3522+ dec = true;
35293523 if (event->attr.mmap || event->attr.mmap_data)
35303524 atomic_dec(&nr_mmap_events);
35313525 if (event->attr.comm)
@@ -3535,12 +3529,15 @@ static void unaccount_event(struct perf_event *event) · 3 unmodified lines
35353529 if (event->attr.freq)
35363530 atomic_dec(&nr_freq_events);
35373531 if (event->attr.context_switch) {
3538− static_key_slow_dec_deferred(&perf_sched_events);
3532+ dec = true;
35393533 atomic_dec(&nr_switch_events);
35403534 }
35413535 if (is_cgroup_event(event))
3542− static_key_slow_dec_deferred(&perf_sched_events);
3536+ dec = true;
35433537 if (has_branch_stack(event))
3538+ dec = true;
3539+
3540+ if (dec)
35443541 static_key_slow_dec_deferred(&perf_sched_events);
35453542
35463543 unaccount_event_cpu(event, event->cpu);
@@ -3556,7 +3553,7 @@ static void unaccount_event(struct perf_event *event) · 9 unmodified lines
35563553 * 3) two matching events on the same context.
35573554 *
35583555 * The former two cases are handled in the allocation path (perf_event_alloc(),
3559− * __free_event()), the latter -- before the first perf_install_in_context().
3556+ * _free_event()), the latter -- before the first perf_install_in_context().
35603557 */
35613558 static int exclusive_event_init(struct perf_event *event)
35623559 {
@@ -3631,29 +3628,6 @@ static bool exclusive_event_installable(struct perf_event *event, · 68 unmodified lines
36313628 return true;
36323629 }
36333630
3634−static void __free_event(struct perf_event *event)
3635−{
3636− if (!event->parent) {
3637− if (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN)
3638− put_callchain_buffers();
3639− }
3640−
3641− perf_event_free_bpf_prog(event);
3642−
3643− if (event->destroy)
3644− event->destroy(event);
3645−
3646− if (event->ctx)
3647− put_ctx(event->ctx);
3648−
3649− if (event->pmu) {
3650− exclusive_event_destroy(event);
3651− module_put(event->pmu->module);
3652− }
3653−
3654− call_rcu(&event->rcu_head, free_event_rcu);
3655−}
3656−
36573631 static void _free_event(struct perf_event *event)
36583632 {
36593633 irq_work_sync(&event->pending);
@@ -3675,7 +3649,25 @@ static void _free_event(struct perf_event *event) · 15 unmodified lines
36753649 if (is_cgroup_event(event))
36763650 perf_detach_cgroup(event);
36773651
3678− __free_event(event);
3652+ if (!event->parent) {
3653+ if (event->attr.sample_type & PERF_SAMPLE_CALLCHAIN)
3654+ put_callchain_buffers();
3655+ }
3656+
3657+ perf_event_free_bpf_prog(event);
3658+
3659+ if (event->destroy)
3660+ event->destroy(event);
3661+
3662+ if (event->ctx)
3663+ put_ctx(event->ctx);
3664+
3665+ if (event->pmu) {
3666+ exclusive_event_destroy(event);
3667+ module_put(event->pmu->module);
3668+ }
3669+
3670+ call_rcu(&event->rcu_head, free_event_rcu);
36793671 }
36803672
36813673 /*
@@ -3702,14 +3694,13 @@ static void perf_remove_from_owner(struct perf_event *event) · 20 unmodified lines
37023694 struct task_struct *owner;
37033695
37043696 rcu_read_lock();
3705− owner = ACCESS_ONCE(event->owner);
37063697 /*
3707− * Matches the smp_wmb() in perf_event_exit_task(). If we observe
3708− * !owner it means the list deletion is complete and we can indeed
3709− * free this event, otherwise we need to serialize on
3698+ * Matches the smp_store_release() in perf_event_exit_task(). If we
3699+ * observe !owner it means the list deletion is complete and we can
3700+ * indeed free this event, otherwise we need to serialize on
37103701 * owner->perf_event_mutex.
37113702 */
3712− smp_read_barrier_depends();
3703+ owner = lockless_dereference(event->owner);
37133704 if (owner) {
37143705 /*
37153706 * Since delayed_put_task_struct() also drops the last
@@ -3737,8 +3728,10 @@ static void perf_remove_from_owner(struct perf_event *event) · 21 unmodified lines
37373728 * ensured they're done, and we can proceed with freeing the
37383729 * event.
37393730 */
3740− if (event->owner)
3731+ if (event->owner) {
37413732 list_del_init(&event->owner_entry);
3733+ smp_store_release(&event->owner, NULL);
3734+ }
37423735 mutex_unlock(&owner->perf_event_mutex);
37433736 put_task_struct(owner);
37443737 }
@@ -3746,36 +3739,98 @@ static void perf_remove_from_owner(struct perf_event *event) · 1 unmodified line
37463739
37473740 static void put_event(struct perf_event *event)
37483741 {
3749− struct perf_event_context *ctx;
3750−
37513742 if (!atomic_long_dec_and_test(&event->refcount))
37523743 return;
37533744
3745+ _free_event(event);
3746+}
3747+
3748+/*
3749+ * Kill an event dead; while event:refcount will preserve the event
3750+ * object, it will not preserve its functionality. Once the last 'user'
3751+ * gives up the object, we'll destroy the thing.
3752+ */
3753+int perf_event_release_kernel(struct perf_event *event)
3754+{
3755+ struct perf_event_context *ctx;
3756+ struct perf_event *child, *tmp;
3757+
37543758 if (!is_kernel_event(event))
37553759 perf_remove_from_owner(event);
37563760
3761+ ctx = perf_event_ctx_lock(event);
3762+ WARN_ON_ONCE(ctx->parent_ctx);
3763+ perf_remove_from_context(event, DETACH_GROUP | DETACH_STATE);
3764+ perf_event_ctx_unlock(event, ctx);
3765+
37573766 /*
3758− * There are two ways this annotation is useful:
3767+ * At this point we must have event->state == PERF_EVENT_STATE_EXIT,
3768+ * either from the above perf_remove_from_context() or through
3769+ * perf_event_exit_event().
37593770 *
3760− * 1) there is a lock recursion from perf_event_exit_task
3761− * see the comment there.
3771+ * Therefore, anybody acquiring event->child_mutex after the below
3772+ * loop _must_ also see this, most importantly inherit_event() which
3773+ * will avoid placing more children on the list.
37623774 *
3763− * 2) there is a lock-inversion with mmap_sem through
3764− * perf_read_group(), which takes faults while
3765− * holding ctx->mutex, however this is called after
3766− * the last filedesc died, so there is no possibility
3767− * to trigger the AB-BA case.
3775+ * Thus this guarantees that we will in fact observe and kill _ALL_
3776+ * child events.
37683777 */
3769− ctx = perf_event_ctx_lock_nested(event, SINGLE_DEPTH_NESTING);
3770− WARN_ON_ONCE(ctx->parent_ctx);
3771− perf_remove_from_context(event, true);
3772− perf_event_ctx_unlock(event, ctx);
3778+ WARN_ON_ONCE(event->state != PERF_EVENT_STATE_EXIT);
37733779
3774− _free_event(event);
3775−}
3780+again:
3781+ mutex_lock(&event->child_mutex);
3782+ list_for_each_entry(child, &event->child_list, child_list) {
37763783
3777−int perf_event_release_kernel(struct perf_event *event)
3778−{
3784+ /*
3785+ * Cannot change, child events are not migrated, see the
3786+ * comment with perf_event_ctx_lock_nested().
3787+ */
3788+ ctx = lockless_dereference(child->ctx);
3789+ /*
3790+ * Since child_mutex nests inside ctx::mutex, we must jump
3791+ * through hoops. We start by grabbing a reference on the ctx.
3792+ *
3793+ * Since the event cannot get freed while we hold the
3794+ * child_mutex, the context must also exist and have a !0
3795+ * reference count.
3796+ */
3797+ get_ctx(ctx);
3798+
3799+ /*
3800+ * Now that we have a ctx ref, we can drop child_mutex, and
3801+ * acquire ctx::mutex without fear of it going away. Then we
3802+ * can re-acquire child_mutex.
3803+ */
3804+ mutex_unlock(&event->child_mutex);
3805+ mutex_lock(&ctx->mutex);
3806+ mutex_lock(&event->child_mutex);
3807+
3808+ /*
3809+ * Now that we hold ctx::mutex and child_mutex, revalidate our
3810+ * state, if child is still the first entry, it didn't get freed
3811+ * and we can continue doing so.
3812+ */
3813+ tmp = list_first_entry_or_null(&event->child_list,
3814+ struct perf_event, child_list);
3815+ if (tmp == child) {
3816+ perf_remove_from_context(child, DETACH_GROUP);
3817+ list_del(&child->child_list);
3818+ free_event(child);
3819+ /*
3820+ * This matches the refcount bump in inherit_event();
3821+ * this can't be the last reference.
3822+ */
3823+ put_event(event);
3824+ }
3825+
3826+ mutex_unlock(&event->child_mutex);
3827+ mutex_unlock(&ctx->mutex);
3828+ put_ctx(ctx);
3829+ goto again;
3830+ }
3831+ mutex_unlock(&event->child_mutex);
3832+
3833+ /* Must be the last reference */
37793834 put_event(event);
37803835 return 0;
37813836 }
@@ -3786,46 +3841,10 @@ EXPORT_SYMBOL_GPL(perf_event_release_kernel); · 4 unmodified lines
37863841 */
37873842 static int perf_release(struct inode *inode, struct file *file)
37883843 {
3789− put_event(file->private_data);
3844+ perf_event_release_kernel(file->private_data);
37903845 return 0;
37913846 }
37923847
3793−/*
3794− * Remove all orphanes events from the context.
3795− */
3796−static void orphans_remove_work(struct work_struct *work)
3797−{
3798− struct perf_event_context *ctx;
3799− struct perf_event *event, *tmp;
3800−
3801− ctx = container_of(work, struct perf_event_context,
3802− orphans_remove.work);
3803−
3804− mutex_lock(&ctx->mutex);
3805− list_for_each_entry_safe(event, tmp, &ctx->event_list, event_entry) {
3806− struct perf_event *parent_event = event->parent;
3807−
3808− if (!is_orphaned_child(event))
3809− continue;
3810−
3811− perf_remove_from_context(event, true);
3812−
3813− mutex_lock(&parent_event->child_mutex);
3814− list_del_init(&event->child_list);
3815− mutex_unlock(&parent_event->child_mutex);
3816−
3817− free_event(event);
3818− put_event(parent_event);
3819− }
3820−
3821− raw_spin_lock_irq(&ctx->lock);
3822− ctx->orphans_remove_sched = false;
3823− raw_spin_unlock_irq(&ctx->lock);
3824− mutex_unlock(&ctx->mutex);
3825−
3826− put_ctx(ctx);
3827−}
3828−
38293848 u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
38303849 {
38313850 struct perf_event *child;
@@ -4054,7 +4073,7 @@ static void _perf_event_reset(struct perf_event *event) · 222 unmodified lines
40544073 /*
40554074 * Holding the top-level event's child_mutex means that any
40564075 * descendant process that has inherited this event will block
4057− * in sync_child_event if it goes to exit, thus satisfying the
4076+ * in perf_event_exit_event() if it goes to exit, thus satisfying the
40584077 * task existence requirements of perf_event_enable/disable.
40594078 */
40604079 static void perf_event_for_each_child(struct perf_event *event,
@@ -4086,36 +4105,14 @@ static void perf_event_for_each(struct perf_event *event, · 25 unmodified lines
40864105 perf_event_for_each_child(sibling, func);
40874106 }
40884107
4089−struct period_event {
4090− struct perf_event *event;
4091− u64 value;
4092−};
4093−
4094−static void ___perf_event_period(void *info)
4095−{
4096− struct period_event *pe = info;
4097− struct perf_event *event = pe->event;
4098− u64 value = pe->value;
4099−
4100− if (event->attr.freq) {
4101− event->attr.sample_freq = value;
4102− } else {
4103− event->attr.sample_period = value;
4104− event->hw.sample_period = value;
4105− }
4106−
4107− local64_set(&event->hw.period_left, 0);
4108−}
4109−
4110−static int __perf_event_period(void *info)
4108+static void __perf_event_period(struct perf_event *event,
4109+ struct perf_cpu_context *cpuctx,
4110+ struct perf_event_context *ctx,
4111+ void *info)
41114112 {
4112− struct period_event *pe = info;
4113− struct perf_event *event = pe->event;
4114− struct perf_event_context *ctx = event->ctx;
4115− u64 value = pe->value;
4113+ u64 value = *((u64 *)info);
41164114 bool active;
41174115
4118− raw_spin_lock(&ctx->lock);
41194116 if (event->attr.freq) {
41204117 event->attr.sample_freq = value;
41214118 } else {
@@ -4135,14 +4132,10 @@ static int __perf_event_period(void *info) · 13 unmodified lines
41354132 event->pmu->start(event, PERF_EF_RELOAD);
41364133 perf_pmu_enable(ctx->pmu);
41374134 }
4138− raw_spin_unlock(&ctx->lock);
4139−
4140− return 0;
41414135 }
41424136
41434137 static int perf_event_period(struct perf_event *event, u64 __user *arg)
41444138 {
4145− struct period_event pe = { .event = event, };
41464139 u64 value;
41474140
41484141 if (!is_sampling_event(event))
@@ -4157,10 +4150,7 @@ static int perf_event_period(struct perf_event *event, u64 __user *arg) · 8 unmodified lines
41574150 if (event->attr.freq && value > sysctl_perf_event_sample_rate)
41584151 return -EINVAL;
41594152
4160− pe.value = value;
4161−
4162− event_function_call(event, __perf_event_period,
4163− ___perf_event_period, &pe);
4153+ event_function_call(event, __perf_event_period, &value);
41644154
41654155 return 0;
41664156 }
@@ -4932,7 +4922,7 @@ static void perf_pending_event(struct irq_work *entry) · 765 unmodified lines
49324922
49334923 if (event->pending_disable) {
49344924 event->pending_disable = 0;
4935− __perf_event_disable(event);
4925+ perf_event_disable_local(event);
49364926 }
49374927
49384928 if (event->pending_wakeup) {
@@ -7753,11 +7743,13 @@ static void account_event_cpu(struct perf_event *event, int cpu) · 2814 unmodified lines
77537743
77547744 static void account_event(struct perf_event *event)
77557745 {
7746+ bool inc = false;
7747+
77567748 if (event->parent)
77577749 return;
77587750
77597751 if (event->attach_state & PERF_ATTACH_TASK)
7760− static_key_slow_inc(&perf_sched_events.key);
7752+ inc = true;
77617753 if (event->attr.mmap || event->attr.mmap_data)
77627754 atomic_inc(&nr_mmap_events);
77637755 if (event->attr.comm)
@@ -7770,11 +7762,14 @@ static void account_event(struct perf_event *event) · 6 unmodified lines
77707762 }
77717763 if (event->attr.context_switch) {
77727764 atomic_inc(&nr_switch_events);
7773− static_key_slow_inc(&perf_sched_events.key);
7765+ inc = true;
77747766 }
77757767 if (has_branch_stack(event))
7776− static_key_slow_inc(&perf_sched_events.key);
7768+ inc = true;
77777769 if (is_cgroup_event(event))
7770+ inc = true;
7771+
7772+ if (inc)
77787773 static_key_slow_inc(&perf_sched_events.key);
77797774
77807775 account_event_cpu(event, event->cpu);
@@ -8422,11 +8417,11 @@ SYSCALL_DEFINE5(perf_event_open, · 641 unmodified lines
84228417 * See perf_event_ctx_lock() for comments on the details
84238418 * of swizzling perf_event::ctx.
84248419 */
8425− perf_remove_from_context(group_leader, false);
8420+ perf_remove_from_context(group_leader, 0);
84268421
84278422 list_for_each_entry(sibling, &group_leader->sibling_list,
84288423 group_entry) {
8429− perf_remove_from_context(sibling, false);
8424+ perf_remove_from_context(sibling, 0);
84308425 put_ctx(gctx);
84318426 }
84328427
@@ -8479,6 +8474,8 @@ SYSCALL_DEFINE5(perf_event_open, · 46 unmodified lines
84798474 perf_event__header_size(event);
84808475 perf_event__id_header_size(event);
84818476
8477+ event->owner = current;
8478+
84828479 perf_install_in_context(ctx, event, event->cpu);
84838480 perf_unpin_context(ctx);
84848481
@@ -8488,8 +8485,6 @@ SYSCALL_DEFINE5(perf_event_open, · 3 unmodified lines
84888485
84898486 put_online_cpus();
84908487
8491− event->owner = current;
8492−
84938488 mutex_lock(&current->perf_event_mutex);
84948489 list_add_tail(&event->owner_entry, &current->perf_event_list);
84958490 mutex_unlock(&current->perf_event_mutex);
@@ -8556,7 +8551,7 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu, · 60 unmodified lines
85568551 }
85578552
85588553 /* Mark owner so we could distinguish it from user events. */
8559− event->owner = EVENT_OWNER_KERNEL;
8554+ event->owner = TASK_TOMBSTONE;
85608555
85618556 account_event(event);
85628557
@@ -8606,7 +8601,7 @@ void perf_pmu_migrate_context(struct pmu *pmu, int src_cpu, int dst_cpu) · 43 unmodified lines
86068601 mutex_lock_double(&src_ctx->mutex, &dst_ctx->mutex);
86078602 list_for_each_entry_safe(event, tmp, &src_ctx->event_list,
86088603 event_entry) {
8609− perf_remove_from_context(event, false);
8604+ perf_remove_from_context(event, 0);
86108605 unaccount_event_cpu(event, src_cpu);
86118606 put_ctx(src_ctx);
86128607 list_add(&event->migrate_entry, &events);
@@ -8673,33 +8668,15 @@ static void sync_child_event(struct perf_event *child_event, · 60 unmodified lines
86738668 &parent_event->child_total_time_enabled);
86748669 atomic64_add(child_event->total_time_running,
86758670 &parent_event->child_total_time_running);
8676−
8677− /*
8678− * Remove this event from the parent's list
8679− */
8680− WARN_ON_ONCE(parent_event->ctx->parent_ctx);
8681− mutex_lock(&parent_event->child_mutex);
8682− list_del_init(&child_event->child_list);
8683− mutex_unlock(&parent_event->child_mutex);
8684−
8685− /*
8686− * Make sure user/parent get notified, that we just
8687− * lost one event.
8688− */
8689− perf_event_wakeup(parent_event);
8690−
8691− /*
8692− * Release the parent event, if this was the last
8693− * reference to it.
8694− */
8695− put_event(parent_event);
86968671 }
86978672
86988673 static void
8699−__perf_event_exit_task(struct perf_event *child_event,
8700− struct perf_event_context *child_ctx,
8701− struct task_struct *child)
8674+perf_event_exit_event(struct perf_event *child_event,
8675+ struct perf_event_context *child_ctx,
8676+ struct task_struct *child)
87028677 {
8678+ struct perf_event *parent_event = child_event->parent;
8679+
87038680 /*
87048681 * Do not destroy the 'original' grouping; because of the context
87058682 * switch optimization the original events could've ended up in a
@@ -8712,57 +8689,86 @@ __perf_event_exit_task(struct perf_event *child_event, · 6 unmodified lines
87128689 * Do destroy all inherited groups, we don't care about those
87138690 * and being thorough is better.
87148691 */
8715− perf_remove_from_context(child_event, !!child_event->parent);
8692+ raw_spin_lock_irq(&child_ctx->lock);
8693+ WARN_ON_ONCE(child_ctx->is_active);
8694+
8695+ if (parent_event)
8696+ perf_group_detach(child_event);
8697+ list_del_event(child_event, child_ctx);
8698+ child_event->state = PERF_EVENT_STATE_EXIT; /* see perf_event_release_kernel() */
8699+ raw_spin_unlock_irq(&child_ctx->lock);
87168700
87178701 /*
8718− * It can happen that the parent exits first, and has events
8719− * that are still around due to the child reference. These
8720− * events need to be zapped.
8702+ * Parent events are governed by their filedesc, retain them.
87218703 */
8722− if (child_event->parent) {
8723− sync_child_event(child_event, child);
8724− free_event(child_event);
8725− } else {
8726− child_event->state = PERF_EVENT_STATE_EXIT;
8704+ if (!parent_event) {
87278705 perf_event_wakeup(child_event);
8706+ return;
87288707 }
8708+ /*
8709+ * Child events can be cleaned up.
8710+ */
8711+
8712+ sync_child_event(child_event, child);
8713+
8714+ /*
8715+ * Remove this event from the parent's list
8716+ */
8717+ WARN_ON_ONCE(parent_event->ctx->parent_ctx);
8718+ mutex_lock(&parent_event->child_mutex);
8719+ list_del_init(&child_event->child_list);
8720+ mutex_unlock(&parent_event->child_mutex);
8721+
8722+ /*
8723+ * Kick perf_poll() for is_event_hup().
8724+ */
8725+ perf_event_wakeup(parent_event);
8726+ free_event(child_event);
8727+ put_event(parent_event);
87298728 }
87308729
87318730 static void perf_event_exit_task_context(struct task_struct *child, int ctxn)
87328731 {
8733− struct perf_event *child_event, *next;
87348732 struct perf_event_context *child_ctx, *clone_ctx = NULL;
8735− unsigned long flags;
8733+ struct perf_event *child_event, *next;
8734+
8735+ WARN_ON_ONCE(child != current);
87368736
8737− if (likely(!child->perf_event_ctxp[ctxn]))
8737+ child_ctx = perf_pin_task_context(child, ctxn);
8738+ if (!child_ctx)
87388739 return;
87398740
8740− local_irq_save(flags);
87418741 /*
8742− * We can't reschedule here because interrupts are disabled,
8743− * and either child is current or it is a task that can't be
8744− * scheduled, so we are now safe from rescheduling changing
8745− * our context.
8742+ * In order to reduce the amount of tricky in ctx tear-down, we hold
8743+ * ctx::mutex over the entire thing. This serializes against almost
8744+ * everything that wants to access the ctx.
8745+ *
8746+ * The exception is sys_perf_event_open() /
8747+ * perf_event_create_kernel_count() which does find_get_context()
8748+ * without ctx::mutex (it cannot because of the move_group double mutex
8749+ * lock thing). See the comments in perf_install_in_context().
87468750 */
8747− child_ctx = rcu_dereference_raw(child->perf_event_ctxp[ctxn]);
8751+ mutex_lock(&child_ctx->mutex);
87488752
87498753 /*
8750− * Take the context lock here so that if find_get_context is
8751− * reading child->perf_event_ctxp, we wait until it has
8752− * incremented the context's refcount before we do put_ctx below.
8754+ * In a single ctx::lock section, de-schedule the events and detach the
8755+ * context from the task such that we cannot ever get it scheduled back
8756+ * in.
87538757 */
8754− raw_spin_lock(&child_ctx->lock);
8755− task_ctx_sched_out(child_ctx);
8756− child->perf_event_ctxp[ctxn] = NULL;
8758+ raw_spin_lock_irq(&child_ctx->lock);
8759+ task_ctx_sched_out(__get_cpu_context(child_ctx), child_ctx);
87578760
87588761 /*
8759− * If this context is a clone; unclone it so it can't get
8760− * swapped to another process while we're removing all
8761− * the events from it.
8762+ * Now that the context is inactive, destroy the task <-> ctx relation
8763+ * and mark the context dead.
87628764 */
8765+ RCU_INIT_POINTER(child->perf_event_ctxp[ctxn], NULL);
8766+ put_ctx(child_ctx); /* cannot be last */
8767+ WRITE_ONCE(child_ctx->task, TASK_TOMBSTONE);
8768+ put_task_struct(current); /* cannot be last */
8769+
87638770 clone_ctx = unclone_ctx(child_ctx);
8764− update_context_time(child_ctx);
8765− raw_spin_unlock_irqrestore(&child_ctx->lock, flags);
8771+ raw_spin_unlock_irq(&child_ctx->lock);
87668772
87678773 if (clone_ctx)
87688774 put_ctx(clone_ctx);
@@ -8774,20 +8780,8 @@ static void perf_event_exit_task_context(struct task_struct *child, int ctxn) · 5 unmodified lines
87748780 */
87758781 perf_event_task(child, child_ctx, 0);
87768782
8777− /*
8778− * We can recurse on the same lock type through:
8779− *
8780− * __perf_event_exit_task()
8781− * sync_child_event()
8782− * put_event()
8783− * mutex_lock(&ctx->mutex)
8784− *
8785− * But since its the parent context it won't be the same instance.
8786− */
8787− mutex_lock(&child_ctx->mutex);
8788−
87898783 list_for_each_entry_safe(child_event, next, &child_ctx->event_list, event_entry)
8790− __perf_event_exit_task(child_event, child_ctx, child);
8784+ perf_event_exit_event(child_event, child_ctx, child);
87918785
87928786 mutex_unlock(&child_ctx->mutex);
87938787
@@ -8812,8 +8806,7 @@ void perf_event_exit_task(struct task_struct *child) · 18 unmodified lines
88128806 * the owner, closes a race against perf_release() where
88138807 * we need to serialize on the owner->perf_event_mutex.
88148808 */
8815− smp_wmb();
8816− event->owner = NULL;
8809+ smp_store_release(&event->owner, NULL);
88178810 }
88188811 mutex_unlock(&child->perf_event_mutex);
88198812
@@ -8896,21 +8889,20 @@ void perf_event_delayed_put(struct task_struct *task) · 76 unmodified lines
88968889 WARN_ON_ONCE(task->perf_event_ctxp[ctxn]);
88978890 }
88988891
8899−struct perf_event *perf_event_get(unsigned int fd)
8892+struct file *perf_event_get(unsigned int fd)
89008893 {
8901− int err;
8902− struct fd f;
8903− struct perf_event *event;
8894+ struct file *file;
89048895
8905− err = perf_fget_light(fd, &f);
8906− if (err)
8907− return ERR_PTR(err);
8896+ file = fget_raw(fd);
8897+ if (!file)
8898+ return ERR_PTR(-EBADF);
89088899
8909− event = f.file->private_data;
8910− atomic_long_inc(&event->refcount);
8911− fdput(f);
8900+ if (file->f_op != &perf_fops) {
8901+ fput(file);
8902+ return ERR_PTR(-EBADF);
8903+ }
89128904
8913− return event;
8905+ return file;
89148906 }
89158907
89168908 const struct perf_event_attr *perf_event_attrs(struct perf_event *event)
@@ -8953,8 +8945,16 @@ inherit_event(struct perf_event *parent_event, · 36 unmodified lines
89538945 if (IS_ERR(child_event))
89548946 return child_event;
89558947
8948+ /*
8949+ * is_orphaned_event() and list_add_tail(&parent_event->child_list)
8950+ * must be under the same lock in order to serialize against
8951+ * perf_event_release_kernel(), such that either we must observe
8952+ * is_orphaned_event() or they will observe us on the child_list.
8953+ */
8954+ mutex_lock(&parent_event->child_mutex);
89568955 if (is_orphaned_event(parent_event) ||
89578956 !atomic_long_inc_not_zero(&parent_event->refcount)) {
8957+ mutex_unlock(&parent_event->child_mutex);
89588958 free_event(child_event);
89598959 return NULL;
89608960 }
@@ -9002,8 +9002,6 @@ inherit_event(struct perf_event *parent_event, · 41 unmodified lines
90029002 /*
90039003 * Link this into the parent event's child list
90049004 */
9005− WARN_ON_ONCE(parent_event->ctx->parent_ctx);
9006− mutex_lock(&parent_event->child_mutex);
90079005 list_add_tail(&child_event->child_list, &parent_event->child_list);
90089006 mutex_unlock(&parent_event->child_mutex);
90099007
@@ -9221,13 +9219,14 @@ static void perf_event_init_cpu(int cpu) · 211 unmodified lines
92219219 #if defined CONFIG_HOTPLUG_CPU || defined CONFIG_KEXEC_CORE
92229220 static void __perf_event_exit_context(void *__info)
92239221 {
9224− struct remove_event re = { .detach_group = true };
92259222 struct perf_event_context *ctx = __info;
9223+ struct perf_cpu_context *cpuctx = __get_cpu_context(ctx);
9224+ struct perf_event *event;
92269225
9227− rcu_read_lock();
9228− list_for_each_entry_rcu(re.event, &ctx->event_list, event_entry)
9229− __perf_remove_from_context(&re);
9230− rcu_read_unlock();
9226+ raw_spin_lock(&ctx->lock);
9227+ list_for_each_entry(event, &ctx->event_list, event_entry)
9228+ __perf_remove_from_context(event, cpuctx, ctx, (void *)DETACH_GROUP);
9229+ raw_spin_unlock(&ctx->lock);
92319230 }
92329231
92339232 static void perf_event_exit_cpu_context(int cpu)
kernel/events/hw_breakpoint.c+1−1
@@ -444,7 +444,7 @@ int modify_user_hw_breakpoint(struct perf_event *bp, struct perf_event_attr *att · 443 unmodified lines
444444 * current task.
445445 */
446446 if (irqs_disabled() && bp->ctx && bp->ctx->task == current)
447− __perf_event_disable(bp);
447+ perf_event_disable_local(bp);
448448 else
449449 perf_event_disable(bp);
450450
kernel/events/ring_buffer.c+20−20
@@ -459,6 +459,25 @@ static void rb_free_aux_page(struct ring_buffer *rb, int idx) · 458 unmodified lines
459459 __free_page(page);
460460 }
461461
462+static void __rb_free_aux(struct ring_buffer *rb)
463+{
464+ int pg;
465+
466+ if (rb->aux_priv) {
467+ rb->free_aux(rb->aux_priv);
468+ rb->free_aux = NULL;
469+ rb->aux_priv = NULL;
470+ }
471+
472+ if (rb->aux_nr_pages) {
473+ for (pg = 0; pg < rb->aux_nr_pages; pg++)
474+ rb_free_aux_page(rb, pg);
475+
476+ kfree(rb->aux_pages);
477+ rb->aux_nr_pages = 0;
478+ }
479+}
480+
462481 int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event,
463482 pgoff_t pgoff, int nr_pages, long watermark, int flags)
464483 {
@@ -547,30 +566,11 @@ out: · 82 unmodified lines
547566 if (!ret)
548567 rb->aux_pgoff = pgoff;
549568 else
550− rb_free_aux(rb);
569+ __rb_free_aux(rb);
551570
552571 return ret;
553572 }
554573
555−static void __rb_free_aux(struct ring_buffer *rb)
556−{
557− int pg;
558−
559− if (rb->aux_priv) {
560− rb->free_aux(rb->aux_priv);
561− rb->free_aux = NULL;
562− rb->aux_priv = NULL;
563− }
564−
565− if (rb->aux_nr_pages) {
566− for (pg = 0; pg < rb->aux_nr_pages; pg++)
567− rb_free_aux_page(rb, pg);
568−
569− kfree(rb->aux_pages);
570− rb->aux_nr_pages = 0;
571− }
572−}
573−
574574 void rb_free_aux(struct ring_buffer *rb)
575575 {
576576 if (atomic_dec_and_test(&rb->aux_refcount))
kernel/futex.c+9−9
@@ -1191,7 +1191,7 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this, · 1190 unmodified lines
11911191 if (pi_state->owner != current)
11921192 return -EINVAL;
11931193
1194− raw_spin_lock(&pi_state->pi_mutex.wait_lock);
1194+ raw_spin_lock_irq(&pi_state->pi_mutex.wait_lock);
11951195 new_owner = rt_mutex_next_owner(&pi_state->pi_mutex);
11961196
11971197 /*
@@ -1217,22 +1217,22 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this, · 19 unmodified lines
12171217 else if (curval != uval)
12181218 ret = -EINVAL;
12191219 if (ret) {
1220− raw_spin_unlock(&pi_state->pi_mutex.wait_lock);
1220+ raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock);
12211221 return ret;
12221222 }
12231223
1224− raw_spin_lock_irq(&pi_state->owner->pi_lock);
1224+ raw_spin_lock(&pi_state->owner->pi_lock);
12251225 WARN_ON(list_empty(&pi_state->list));
12261226 list_del_init(&pi_state->list);
1227− raw_spin_unlock_irq(&pi_state->owner->pi_lock);
1227+ raw_spin_unlock(&pi_state->owner->pi_lock);
12281228
1229− raw_spin_lock_irq(&new_owner->pi_lock);
1229+ raw_spin_lock(&new_owner->pi_lock);
12301230 WARN_ON(!list_empty(&pi_state->list));
12311231 list_add(&pi_state->list, &new_owner->pi_state_list);
12321232 pi_state->owner = new_owner;
1233− raw_spin_unlock_irq(&new_owner->pi_lock);
1233+ raw_spin_unlock(&new_owner->pi_lock);
12341234
1235− raw_spin_unlock(&pi_state->pi_mutex.wait_lock);
1235+ raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock);
12361236
12371237 deboost = rt_mutex_futex_unlock(&pi_state->pi_mutex, &wake_q);
12381238
@@ -2127,11 +2127,11 @@ static int fixup_owner(u32 __user *uaddr, struct futex_q *q, int locked) · 888 unmodified lines
21272127 * we returned due to timeout or signal without taking the
21282128 * rt_mutex. Too late.
21292129 */
2130− raw_spin_lock(&q->pi_state->pi_mutex.wait_lock);
2130+ raw_spin_lock_irq(&q->pi_state->pi_mutex.wait_lock);
21312131 owner = rt_mutex_owner(&q->pi_state->pi_mutex);
21322132 if (!owner)
21332133 owner = rt_mutex_next_owner(&q->pi_state->pi_mutex);
2134− raw_spin_unlock(&q->pi_state->pi_mutex.wait_lock);
2134+ raw_spin_unlock_irq(&q->pi_state->pi_mutex.wait_lock);
21352135 ret = fixup_pi_state_owner(uaddr, q, owner);
21362136 goto out;
21372137 }
kernel/irq/handle.c+3−2
@@ -138,7 +138,8 @@ irqreturn_t handle_irq_event_percpu(struct irq_desc *desc) · 137 unmodified lines
138138 unsigned int flags = 0, irq = desc->irq_data.irq;
139139 struct irqaction *action = desc->action;
140140
141− do {
141+ /* action might have become NULL since we dropped the lock */
142+ while (action) {
142143 irqreturn_t res;
143144
144145 trace_irq_handler_entry(irq, action);
@@ -173,7 +174,7 @@ irqreturn_t handle_irq_event_percpu(struct irq_desc *desc) · 28 unmodified lines
173174
174175 retval |= res;
175176 action = action->next;
176− } while (action);
177+ }
177178
178179 add_interrupt_randomness(irq, flags);
179180
kernel/irq/irqdomain.c+8−3
@@ -575,10 +575,15 @@ unsigned int irq_create_fwspec_mapping(struct irq_fwspec *fwspec) · 574 unmodified lines
575575 unsigned int type = IRQ_TYPE_NONE;
576576 int virq;
577577
578− if (fwspec->fwnode)
579− domain = irq_find_matching_fwnode(fwspec->fwnode, DOMAIN_BUS_ANY);
580− else
578+ if (fwspec->fwnode) {
579+ domain = irq_find_matching_fwnode(fwspec->fwnode,
580+ DOMAIN_BUS_WIRED);
581+ if (!domain)
582+ domain = irq_find_matching_fwnode(fwspec->fwnode,
583+ DOMAIN_BUS_ANY);
584+ } else {
581585 domain = irq_default_domain;
586+ }
582587
583588 if (!domain) {
584589 pr_warn("no irq domain found for %s !\n",
kernel/locking/rtmutex.c+72−63
@@ -99,13 +99,14 @@ static inline void mark_rt_mutex_waiters(struct rt_mutex *lock) · 98 unmodified lines
9999 * 2) Drop lock->wait_lock
100100 * 3) Try to unlock the lock with cmpxchg
101101 */
102−static inline bool unlock_rt_mutex_safe(struct rt_mutex *lock)
102+static inline bool unlock_rt_mutex_safe(struct rt_mutex *lock,
103+ unsigned long flags)
103104 __releases(lock->wait_lock)
104105 {
105106 struct task_struct *owner = rt_mutex_owner(lock);
106107
107108 clear_rt_mutex_waiters(lock);
108− raw_spin_unlock(&lock->wait_lock);
109+ raw_spin_unlock_irqrestore(&lock->wait_lock, flags);
109110 /*
110111 * If a new waiter comes in between the unlock and the cmpxchg
111112 * we have two situations:
@@ -147,11 +148,12 @@ static inline void mark_rt_mutex_waiters(struct rt_mutex *lock) · 35 unmodified lines
147148 /*
148149 * Simple slow path only version: lock->owner is protected by lock->wait_lock.
149150 */
150−static inline bool unlock_rt_mutex_safe(struct rt_mutex *lock)
151+static inline bool unlock_rt_mutex_safe(struct rt_mutex *lock,
152+ unsigned long flags)
151153 __releases(lock->wait_lock)
152154 {
153155 lock->owner = NULL;
154− raw_spin_unlock(&lock->wait_lock);
156+ raw_spin_unlock_irqrestore(&lock->wait_lock, flags);
155157 return true;
156158 }
157159 #endif
@@ -433,7 +435,6 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 275 unmodified lines
433435 int ret = 0, depth = 0;
434436 struct rt_mutex *lock;
435437 bool detect_deadlock;
436− unsigned long flags;
437438 bool requeue = true;
438439
439440 detect_deadlock = rt_mutex_cond_detect_deadlock(orig_waiter, chwalk);
@@ -476,7 +477,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 36 unmodified lines
476477 /*
477478 * [1] Task cannot go away as we did a get_task() before !
478479 */
479− raw_spin_lock_irqsave(&task->pi_lock, flags);
480+ raw_spin_lock_irq(&task->pi_lock);
480481
481482 /*
482483 * [2] Get the waiter on which @task is blocked on.
@@ -560,7 +561,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 77 unmodified lines
560561 * operations.
561562 */
562563 if (!raw_spin_trylock(&lock->wait_lock)) {
563− raw_spin_unlock_irqrestore(&task->pi_lock, flags);
564+ raw_spin_unlock_irq(&task->pi_lock);
564565 cpu_relax();
565566 goto retry;
566567 }
@@ -591,7 +592,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 24 unmodified lines
591592 /*
592593 * No requeue[7] here. Just release @task [8]
593594 */
594− raw_spin_unlock_irqrestore(&task->pi_lock, flags);
595+ raw_spin_unlock(&task->pi_lock);
595596 put_task_struct(task);
596597
597598 /*
@@ -599,14 +600,14 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 1 unmodified line
599600 * If there is no owner of the lock, end of chain.
600601 */
601602 if (!rt_mutex_owner(lock)) {
602− raw_spin_unlock(&lock->wait_lock);
603+ raw_spin_unlock_irq(&lock->wait_lock);
603604 return 0;
604605 }
605606
606607 /* [10] Grab the next task, i.e. owner of @lock */
607608 task = rt_mutex_owner(lock);
608609 get_task_struct(task);
609− raw_spin_lock_irqsave(&task->pi_lock, flags);
610+ raw_spin_lock(&task->pi_lock);
610611
611612 /*
612613 * No requeue [11] here. We just do deadlock detection.
@@ -621,8 +622,8 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 8 unmodified lines
621622 top_waiter = rt_mutex_top_waiter(lock);
622623
623624 /* [13] Drop locks */
624− raw_spin_unlock_irqrestore(&task->pi_lock, flags);
625− raw_spin_unlock(&lock->wait_lock);
625+ raw_spin_unlock(&task->pi_lock);
626+ raw_spin_unlock_irq(&lock->wait_lock);
626627
627628 /* If owner is not blocked, end of chain. */
628629 if (!next_lock)
@@ -643,7 +644,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 14 unmodified lines
643644 rt_mutex_enqueue(lock, waiter);
644645
645646 /* [8] Release the task */
646− raw_spin_unlock_irqrestore(&task->pi_lock, flags);
647+ raw_spin_unlock(&task->pi_lock);
647648 put_task_struct(task);
648649
649650 /*
@@ -661,14 +662,14 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 11 unmodified lines
661662 */
662663 if (prerequeue_top_waiter != rt_mutex_top_waiter(lock))
663664 wake_up_process(rt_mutex_top_waiter(lock)->task);
664− raw_spin_unlock(&lock->wait_lock);
665+ raw_spin_unlock_irq(&lock->wait_lock);
665666 return 0;
666667 }
667668
668669 /* [10] Grab the next task, i.e. the owner of @lock */
669670 task = rt_mutex_owner(lock);
670671 get_task_struct(task);
671− raw_spin_lock_irqsave(&task->pi_lock, flags);
672+ raw_spin_lock(&task->pi_lock);
672673
673674 /* [11] requeue the pi waiters if necessary */
674675 if (waiter == rt_mutex_top_waiter(lock)) {
@@ -722,8 +723,8 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 47 unmodified lines
722723 top_waiter = rt_mutex_top_waiter(lock);
723724
724725 /* [13] Drop the locks */
725− raw_spin_unlock_irqrestore(&task->pi_lock, flags);
726− raw_spin_unlock(&lock->wait_lock);
726+ raw_spin_unlock(&task->pi_lock);
727+ raw_spin_unlock_irq(&lock->wait_lock);
727728
728729 /*
729730 * Make the actual exit decisions [12], based on the stored
@@ -746,7 +747,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 16 unmodified lines
746747 goto again;
747748
748749 out_unlock_pi:
749− raw_spin_unlock_irqrestore(&task->pi_lock, flags);
750+ raw_spin_unlock_irq(&task->pi_lock);
750751 out_put_task:
751752 put_task_struct(task);
752753
@@ -756,7 +757,7 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 3 unmodified lines
756757 /*
757758 * Try to take an rt-mutex
758759 *
759− * Must be called with lock->wait_lock held.
760+ * Must be called with lock->wait_lock held and interrupts disabled
760761 *
761762 * @lock: The lock to be acquired.
762763 * @task: The task which wants to acquire the lock
@@ -766,8 +767,6 @@ static int rt_mutex_adjust_prio_chain(struct task_struct *task, · 3 unmodified lines
766767 static int try_to_take_rt_mutex(struct rt_mutex *lock, struct task_struct *task,
767768 struct rt_mutex_waiter *waiter)
768769 {
769− unsigned long flags;
770−
771770 /*
772771 * Before testing whether we can acquire @lock, we set the
773772 * RT_MUTEX_HAS_WAITERS bit in @lock->owner. This forces all
@@ -852,7 +851,7 @@ static int try_to_take_rt_mutex(struct rt_mutex *lock, struct task_struct *task, · 78 unmodified lines
852851 * case, but conditionals are more expensive than a redundant
853852 * store.
854853 */
855− raw_spin_lock_irqsave(&task->pi_lock, flags);
854+ raw_spin_lock(&task->pi_lock);
856855 task->pi_blocked_on = NULL;
857856 /*
858857 * Finish the lock acquisition. @task is the new owner. If
@@ -861,7 +860,7 @@ static int try_to_take_rt_mutex(struct rt_mutex *lock, struct task_struct *task, · 2 unmodified lines
861860 */
862861 if (rt_mutex_has_waiters(lock))
863862 rt_mutex_enqueue_pi(task, rt_mutex_top_waiter(lock));
864− raw_spin_unlock_irqrestore(&task->pi_lock, flags);
863+ raw_spin_unlock(&task->pi_lock);
865864
866865 takeit:
867866 /* We got the lock. */
@@ -883,7 +882,7 @@ takeit: · 15 unmodified lines
883882 *
884883 * Prepare waiter and propagate pi chain
885884 *
886− * This must be called with lock->wait_lock held.
885+ * This must be called with lock->wait_lock held and interrupts disabled
887886 */
888887 static int task_blocks_on_rt_mutex(struct rt_mutex *lock,
889888 struct rt_mutex_waiter *waiter,
@@ -894,7 +893,6 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock, · 4 unmodified lines
894893 struct rt_mutex_waiter *top_waiter = waiter;
895894 struct rt_mutex *next_lock;
896895 int chain_walk = 0, res;
897− unsigned long flags;
898896
899897 /*
900898 * Early deadlock detection. We really don't want the task to
@@ -908,7 +906,7 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock, · 7 unmodified lines
908906 if (owner == task)
909907 return -EDEADLK;
910908
911− raw_spin_lock_irqsave(&task->pi_lock, flags);
909+ raw_spin_lock(&task->pi_lock);
912910 __rt_mutex_adjust_prio(task);
913911 waiter->task = task;
914912 waiter->lock = lock;
@@ -921,12 +919,12 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock, · 6 unmodified lines
921919
922920 task->pi_blocked_on = waiter;
923921
924− raw_spin_unlock_irqrestore(&task->pi_lock, flags);
922+ raw_spin_unlock(&task->pi_lock);
925923
926924 if (!owner)
927925 return 0;
928926
929− raw_spin_lock_irqsave(&owner->pi_lock, flags);
927+ raw_spin_lock(&owner->pi_lock);
930928 if (waiter == rt_mutex_top_waiter(lock)) {
931929 rt_mutex_dequeue_pi(owner, top_waiter);
932930 rt_mutex_enqueue_pi(owner, waiter);
@@ -941,7 +939,7 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock, · 8 unmodified lines
941939 /* Store the lock on which owner is blocked or NULL */
942940 next_lock = task_blocked_on_lock(owner);
943941
944− raw_spin_unlock_irqrestore(&owner->pi_lock, flags);
942+ raw_spin_unlock(&owner->pi_lock);
945943 /*
946944 * Even if full deadlock detection is on, if the owner is not
947945 * blocked itself, we can avoid finding this out in the chain
@@ -957,12 +955,12 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock, · 9 unmodified lines
957955 */
958956 get_task_struct(owner);
959957
960− raw_spin_unlock(&lock->wait_lock);
958+ raw_spin_unlock_irq(&lock->wait_lock);
961959
962960 res = rt_mutex_adjust_prio_chain(owner, chwalk, lock,
963961 next_lock, waiter, task);
964962
965− raw_spin_lock(&lock->wait_lock);
963+ raw_spin_lock_irq(&lock->wait_lock);
966964
967965 return res;
968966 }
@@ -971,15 +969,14 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock, · 2 unmodified lines
971969 * Remove the top waiter from the current tasks pi waiter tree and
972970 * queue it up.
973971 *
974− * Called with lock->wait_lock held.
972+ * Called with lock->wait_lock held and interrupts disabled.
975973 */
976974 static void mark_wakeup_next_waiter(struct wake_q_head *wake_q,
977975 struct rt_mutex *lock)
978976 {
979977 struct rt_mutex_waiter *waiter;
980− unsigned long flags;
981978
982− raw_spin_lock_irqsave(&current->pi_lock, flags);
979+ raw_spin_lock(&current->pi_lock);
983980
984981 waiter = rt_mutex_top_waiter(lock);
985982
@@ -1001,7 +998,7 @@ static void mark_wakeup_next_waiter(struct wake_q_head *wake_q, · 15 unmodified lines
1001998 */
1002999 lock->owner = (void *) RT_MUTEX_HAS_WAITERS;
10031000
1004− raw_spin_unlock_irqrestore(&current->pi_lock, flags);
1001+ raw_spin_unlock(&current->pi_lock);
10051002
10061003 wake_q_add(wake_q, waiter->task);
10071004 }
@@ -1009,7 +1006,7 @@ static void mark_wakeup_next_waiter(struct wake_q_head *wake_q, · 1 unmodified line
10091006 /*
10101007 * Remove a waiter from a lock and give up
10111008 *
1012− * Must be called with lock->wait_lock held and
1009+ * Must be called with lock->wait_lock held and interrupts disabled. I must
10131010 * have just failed to try_to_take_rt_mutex().
10141011 */
10151012 static void remove_waiter(struct rt_mutex *lock,
@@ -1018,12 +1015,11 @@ static void remove_waiter(struct rt_mutex *lock, · 2 unmodified lines
10181015 bool is_top_waiter = (waiter == rt_mutex_top_waiter(lock));
10191016 struct task_struct *owner = rt_mutex_owner(lock);
10201017 struct rt_mutex *next_lock;
1021− unsigned long flags;
10221018
1023− raw_spin_lock_irqsave(&current->pi_lock, flags);
1019+ raw_spin_lock(&current->pi_lock);
10241020 rt_mutex_dequeue(lock, waiter);
10251021 current->pi_blocked_on = NULL;
1026− raw_spin_unlock_irqrestore(&current->pi_lock, flags);
1022+ raw_spin_unlock(&current->pi_lock);
10271023
10281024 /*
10291025 * Only update priority if the waiter was the highest priority
@@ -1032,7 +1028,7 @@ static void remove_waiter(struct rt_mutex *lock, · 2 unmodified lines
10321028 if (!owner || !is_top_waiter)
10331029 return;
10341030
1035− raw_spin_lock_irqsave(&owner->pi_lock, flags);
1031+ raw_spin_lock(&owner->pi_lock);
10361032
10371033 rt_mutex_dequeue_pi(owner, waiter);
10381034
@@ -1044,7 +1040,7 @@ static void remove_waiter(struct rt_mutex *lock, · 5 unmodified lines
10441040 /* Store the lock on which owner is blocked or NULL */
10451041 next_lock = task_blocked_on_lock(owner);
10461042
1047− raw_spin_unlock_irqrestore(&owner->pi_lock, flags);
1043+ raw_spin_unlock(&owner->pi_lock);
10481044
10491045 /*
10501046 * Don't walk the chain, if the owner task is not blocked
@@ -1056,12 +1052,12 @@ static void remove_waiter(struct rt_mutex *lock, · 5 unmodified lines
10561052 /* gets dropped in rt_mutex_adjust_prio_chain()! */
10571053 get_task_struct(owner);
10581054
1059− raw_spin_unlock(&lock->wait_lock);
1055+ raw_spin_unlock_irq(&lock->wait_lock);
10601056
10611057 rt_mutex_adjust_prio_chain(owner, RT_MUTEX_MIN_CHAINWALK, lock,
10621058 next_lock, NULL, current);
10631059
1064− raw_spin_lock(&lock->wait_lock);
1060+ raw_spin_lock_irq(&lock->wait_lock);
10651061 }
10661062
10671063 /*
@@ -1097,11 +1093,11 @@ void rt_mutex_adjust_pi(struct task_struct *task) · 29 unmodified lines
10971093 * __rt_mutex_slowlock() - Perform the wait-wake-try-to-take loop
10981094 * @lock: the rt_mutex to take
10991095 * @state: the state the task should block in (TASK_INTERRUPTIBLE
1100− * or TASK_UNINTERRUPTIBLE)
1096+ * or TASK_UNINTERRUPTIBLE)
11011097 * @timeout: the pre-initialized and started timer, or NULL for none
11021098 * @waiter: the pre-initialized rt_mutex_waiter
11031099 *
1104− * lock->wait_lock must be held by the caller.
1100+ * Must be called with lock->wait_lock held and interrupts disabled
11051101 */
11061102 static int __sched
11071103 __rt_mutex_slowlock(struct rt_mutex *lock, int state,
@@ -1129,13 +1125,13 @@ __rt_mutex_slowlock(struct rt_mutex *lock, int state, · 21 unmodified lines
11291125 break;
11301126 }
11311127
1132− raw_spin_unlock(&lock->wait_lock);
1128+ raw_spin_unlock_irq(&lock->wait_lock);
11331129
11341130 debug_rt_mutex_print_deadlock(waiter);
11351131
11361132 schedule();
11371133
1138− raw_spin_lock(&lock->wait_lock);
1134+ raw_spin_lock_irq(&lock->wait_lock);
11391135 set_current_state(state);
11401136 }
11411137
@@ -1172,17 +1168,26 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state, · 30 unmodified lines
11721168 enum rtmutex_chainwalk chwalk)
11731169 {
11741170 struct rt_mutex_waiter waiter;
1171+ unsigned long flags;
11751172 int ret = 0;
11761173
11771174 debug_rt_mutex_init_waiter(&waiter);
11781175 RB_CLEAR_NODE(&waiter.pi_tree_entry);
11791176 RB_CLEAR_NODE(&waiter.tree_entry);
11801177
1181− raw_spin_lock(&lock->wait_lock);
1178+ /*
1179+ * Technically we could use raw_spin_[un]lock_irq() here, but this can
1180+ * be called in early boot if the cmpxchg() fast path is disabled
1181+ * (debug, no architecture support). In this case we will acquire the
1182+ * rtmutex with lock->wait_lock held. But we cannot unconditionally
1183+ * enable interrupts in that early boot case. So we need to use the
1184+ * irqsave/restore variants.
1185+ */
1186+ raw_spin_lock_irqsave(&lock->wait_lock, flags);
11821187
11831188 /* Try to acquire the lock again: */
11841189 if (try_to_take_rt_mutex(lock, current, NULL)) {
1185− raw_spin_unlock(&lock->wait_lock);
1190+ raw_spin_unlock_irqrestore(&lock->wait_lock, flags);
11861191 return 0;
11871192 }
11881193
@@ -1211,7 +1216,7 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state, · 22 unmodified lines
12111216 */
12121217 fixup_rt_mutex_waiters(lock);
12131218
1214− raw_spin_unlock(&lock->wait_lock);
1219+ raw_spin_unlock_irqrestore(&lock->wait_lock, flags);
12151220
12161221 /* Remove pending timer: */
12171222 if (unlikely(timeout))
@@ -1227,6 +1232,7 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state, · 9 unmodified lines
12271232 */
12281233 static inline int rt_mutex_slowtrylock(struct rt_mutex *lock)
12291234 {
1235+ unsigned long flags;
12301236 int ret;
12311237
12321238 /*
@@ -1238,10 +1244,10 @@ static inline int rt_mutex_slowtrylock(struct rt_mutex *lock) · 5 unmodified lines
12381244 return 0;
12391245
12401246 /*
1241− * The mutex has currently no owner. Lock the wait lock and
1242− * try to acquire the lock.
1247+ * The mutex has currently no owner. Lock the wait lock and try to
1248+ * acquire the lock. We use irqsave here to support early boot calls.
12431249 */
1244− raw_spin_lock(&lock->wait_lock);
1250+ raw_spin_lock_irqsave(&lock->wait_lock, flags);
12451251
12461252 ret = try_to_take_rt_mutex(lock, current, NULL);
12471253
@@ -1251,7 +1257,7 @@ static inline int rt_mutex_slowtrylock(struct rt_mutex *lock) · 3 unmodified lines
12511257 */
12521258 fixup_rt_mutex_waiters(lock);
12531259
1254− raw_spin_unlock(&lock->wait_lock);
1260+ raw_spin_unlock_irqrestore(&lock->wait_lock, flags);
12551261
12561262 return ret;
12571263 }
@@ -1263,7 +1269,10 @@ static inline int rt_mutex_slowtrylock(struct rt_mutex *lock) · 5 unmodified lines
12631269 static bool __sched rt_mutex_slowunlock(struct rt_mutex *lock,
12641270 struct wake_q_head *wake_q)
12651271 {
1266− raw_spin_lock(&lock->wait_lock);
1272+ unsigned long flags;
1273+
1274+ /* irqsave required to support early boot calls */
1275+ raw_spin_lock_irqsave(&lock->wait_lock, flags);
12671276
12681277 debug_rt_mutex_unlock(lock);
12691278
@@ -1302,10 +1311,10 @@ static bool __sched rt_mutex_slowunlock(struct rt_mutex *lock, · 32 unmodified lines
13021311 */
13031312 while (!rt_mutex_has_waiters(lock)) {
13041313 /* Drops lock->wait_lock ! */
1305− if (unlock_rt_mutex_safe(lock) == true)
1314+ if (unlock_rt_mutex_safe(lock, flags) == true)
13061315 return false;
13071316 /* Relock the rtmutex and try again */
1308− raw_spin_lock(&lock->wait_lock);
1317+ raw_spin_lock_irqsave(&lock->wait_lock, flags);
13091318 }
13101319
13111320 /*
@@ -1316,7 +1325,7 @@ static bool __sched rt_mutex_slowunlock(struct rt_mutex *lock, · 4 unmodified lines
13161325 */
13171326 mark_wakeup_next_waiter(wake_q, lock);
13181327
1319− raw_spin_unlock(&lock->wait_lock);
1328+ raw_spin_unlock_irqrestore(&lock->wait_lock, flags);
13201329
13211330 /* check PI boosting */
13221331 return true;
@@ -1596,10 +1605,10 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock, · 273 unmodified lines
15961605 {
15971606 int ret;
15981607
1599− raw_spin_lock(&lock->wait_lock);
1608+ raw_spin_lock_irq(&lock->wait_lock);
16001609
16011610 if (try_to_take_rt_mutex(lock, task, NULL)) {
1602− raw_spin_unlock(&lock->wait_lock);
1611+ raw_spin_unlock_irq(&lock->wait_lock);
16031612 return 1;
16041613 }
16051614
@@ -1620,7 +1629,7 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock, · 14 unmodified lines
16201629 if (unlikely(ret))
16211630 remove_waiter(lock, waiter);
16221631
1623− raw_spin_unlock(&lock->wait_lock);
1632+ raw_spin_unlock_irq(&lock->wait_lock);
16241633
16251634 debug_rt_mutex_print_deadlock(waiter);
16261635
@@ -1668,7 +1677,7 @@ int rt_mutex_finish_proxy_lock(struct rt_mutex *lock, · 41 unmodified lines
16681677 {
16691678 int ret;
16701679
1671− raw_spin_lock(&lock->wait_lock);
1680+ raw_spin_lock_irq(&lock->wait_lock);
16721681
16731682 set_current_state(TASK_INTERRUPTIBLE);
16741683
@@ -1684,7 +1693,7 @@ int rt_mutex_finish_proxy_lock(struct rt_mutex *lock, · 9 unmodified lines
16841693 */
16851694 fixup_rt_mutex_waiters(lock);
16861695
1687− raw_spin_unlock(&lock->wait_lock);
1696+ raw_spin_unlock_irq(&lock->wait_lock);
16881697
16891698 return ret;
16901699 }
kernel/pid.c+1−1
@@ -588,7 +588,7 @@ void __init pidhash_init(void) · 587 unmodified lines
588588
589589 void __init pidmap_init(void)
590590 {
591− /* Veryify no one has done anything silly */
591+ /* Verify no one has done anything silly: */
592592 BUILD_BUG_ON(PID_MAX_LIMIT >= PIDNS_HASH_ADDING);
593593
594594 /* bump default and minimum pid_max based on number of cpus */
kernel/power/Kconfig+1−1
@@ -235,7 +235,7 @@ config PM_TRACE_RTC · 234 unmodified lines
235235
236236 config APM_EMULATION
237237 tristate "Advanced Power Management Emulation"
238− depends on PM && SYS_SUPPORTS_APM_EMULATION
238+ depends on SYS_SUPPORTS_APM_EMULATION
239239 help
240240 APM is a BIOS specification for saving power using several different
241241 techniques. This is mostly useful for battery powered laptops with
kernel/sched/core.c+1−1
@@ -6840,7 +6840,7 @@ static void sched_init_numa(void) · 6839 unmodified lines
68406840
68416841 sched_domains_numa_masks[i][j] = mask;
68426842
6843− for (k = 0; k < nr_node_ids; k++) {
6843+ for_each_node(k) {
68446844 if (node_distance(j, k) > sched_domains_numa_distance[i])
68456845 continue;
68466846
kernel/sched/fair.c+23−7
@@ -1220,8 +1220,6 @@ static void task_numa_assign(struct task_numa_env *env, · 1219 unmodified lines
12201220 {
12211221 if (env->best_task)
12221222 put_task_struct(env->best_task);
1223− if (p)
1224− get_task_struct(p);
12251223
12261224 env->best_task = p;
12271225 env->best_imp = imp;
@@ -1289,20 +1287,30 @@ static void task_numa_compare(struct task_numa_env *env, · 61 unmodified lines
12891287 long imp = env->p->numa_group ? groupimp : taskimp;
12901288 long moveimp = imp;
12911289 int dist = env->dist;
1290+ bool assigned = false;
12921291
12931292 rcu_read_lock();
12941293
12951294 raw_spin_lock_irq(&dst_rq->lock);
12961295 cur = dst_rq->curr;
12971296 /*
1298− * No need to move the exiting task, and this ensures that ->curr
1299− * wasn't reaped and thus get_task_struct() in task_numa_assign()
1300− * is safe under RCU read lock.
1301− * Note that rcu_read_lock() itself can't protect from the final
1302− * put_task_struct() after the last schedule().
1297+ * No need to move the exiting task or idle task.
13031298 */
13041299 if ((cur->flags & PF_EXITING) || is_idle_task(cur))
13051300 cur = NULL;
1301+ else {
1302+ /*
1303+ * The task_struct must be protected here to protect the
1304+ * p->numa_faults access in the task_weight since the
1305+ * numa_faults could already be freed in the following path:
1306+ * finish_task_switch()
1307+ * --> put_task_struct()
1308+ * --> __put_task_struct()
1309+ * --> task_numa_free()
1310+ */
1311+ get_task_struct(cur);
1312+ }
1313+
13061314 raw_spin_unlock_irq(&dst_rq->lock);
13071315
13081316 /*
@@ -1386,6 +1394,7 @@ balance: · 77 unmodified lines
13861394 */
13871395 if (!load_too_imbalanced(src_load, dst_load, env)) {
13881396 imp = moveimp - 1;
1397+ put_task_struct(cur);
13891398 cur = NULL;
13901399 goto assign;
13911400 }
@@ -1411,9 +1420,16 @@ balance: · 19 unmodified lines
14111420 env->dst_cpu = select_idle_sibling(env->p, env->dst_cpu);
14121421
14131422 assign:
1423+ assigned = true;
14141424 task_numa_assign(env, cur, imp);
14151425 unlock:
14161426 rcu_read_unlock();
1427+ /*
1428+ * The dst_rq->curr isn't assigned. The protection for task_struct is
1429+ * finished.
1430+ */
1431+ if (cur && !assigned)
1432+ put_task_struct(cur);
14171433 }
14181434
14191435 static void task_numa_find_cpu(struct task_numa_env *env,
kernel/sched/idle.c+1−1
@@ -162,7 +162,7 @@ static void cpuidle_idle_call(void) · 161 unmodified lines
162162 */
163163 if (idle_should_freeze()) {
164164 entered_state = cpuidle_enter_freeze(drv, dev);
165− if (entered_state >= 0) {
165+ if (entered_state > 0) {
166166 local_irq_enable();
167167 goto exit_idle;
168168 }
kernel/seccomp.c+11−11
@@ -316,24 +316,24 @@ static inline void seccomp_sync_threads(void) · 315 unmodified lines
316316 put_seccomp_filter(thread);
317317 smp_store_release(&thread->seccomp.filter,
318318 caller->seccomp.filter);
319+
320+ /*
321+ * Don't let an unprivileged task work around
322+ * the no_new_privs restriction by creating
323+ * a thread that sets it up, enters seccomp,
324+ * then dies.
325+ */
326+ if (task_no_new_privs(caller))
327+ task_set_no_new_privs(thread);
328+
319329 /*
320330 * Opt the other thread into seccomp if needed.
321331 * As threads are considered to be trust-realm
322332 * equivalent (see ptrace_may_access), it is safe to
323333 * allow one thread to transition the other.
324334 */
325− if (thread->seccomp.mode == SECCOMP_MODE_DISABLED) {
326− /*
327− * Don't let an unprivileged task work around
328− * the no_new_privs restriction by creating
329− * a thread that sets it up, enters seccomp,
330− * then dies.
331− */
332− if (task_no_new_privs(caller))
333− task_set_no_new_privs(thread);
334−
335+ if (thread->seccomp.mode == SECCOMP_MODE_DISABLED)
335336 seccomp_assign_mode(thread, SECCOMP_MODE_FILTER);
336− }
337337 }
338338 }
339339
kernel/time/hrtimer.c+37−18
@@ -897,10 +897,10 @@ static int enqueue_hrtimer(struct hrtimer *timer, · 896 unmodified lines
897897 */
898898 static void __remove_hrtimer(struct hrtimer *timer,
899899 struct hrtimer_clock_base *base,
900− unsigned long newstate, int reprogram)
900+ u8 newstate, int reprogram)
901901 {
902902 struct hrtimer_cpu_base *cpu_base = base->cpu_base;
903− unsigned int state = timer->state;
903+ u8 state = timer->state;
904904
905905 timer->state = newstate;
906906 if (!(state & HRTIMER_STATE_ENQUEUED))
@@ -930,7 +930,7 @@ static inline int · 23 unmodified lines
930930 remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base, bool restart)
931931 {
932932 if (hrtimer_is_queued(timer)) {
933− unsigned long state = timer->state;
933+ u8 state = timer->state;
934934 int reprogram;
935935
936936 /*
@@ -954,6 +954,22 @@ remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base, bool rest · 17 unmodified lines
954954 return 0;
955955 }
956956
957+static inline ktime_t hrtimer_update_lowres(struct hrtimer *timer, ktime_t tim,
958+ const enum hrtimer_mode mode)
959+{
960+#ifdef CONFIG_TIME_LOW_RES
961+ /*
962+ * CONFIG_TIME_LOW_RES indicates that the system has no way to return
963+ * granular time values. For relative timers we add hrtimer_resolution
964+ * (i.e. one jiffie) to prevent short timeouts.
965+ */
966+ timer->is_rel = mode & HRTIMER_MODE_REL;
967+ if (timer->is_rel)
968+ tim = ktime_add_safe(tim, ktime_set(0, hrtimer_resolution));
969+#endif
970+ return tim;
971+}
972+
957973 /**
958974 * hrtimer_start_range_ns - (re)start an hrtimer on the current CPU
959975 * @timer: the timer to be added
@@ -974,19 +990,10 @@ void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim, · 14 unmodified lines
974990 /* Remove an active timer from the queue: */
975991 remove_hrtimer(timer, base, true);
976992
977− if (mode & HRTIMER_MODE_REL) {
993+ if (mode & HRTIMER_MODE_REL)
978994 tim = ktime_add_safe(tim, base->get_time());
979− /*
980− * CONFIG_TIME_LOW_RES is a temporary way for architectures
981− * to signal that they simply return xtime in
982− * do_gettimeoffset(). In this case we want to round up by
983− * resolution when starting a relative timer, to avoid short
984− * timeouts. This will go away with the GTOD framework.
985− */
986−#ifdef CONFIG_TIME_LOW_RES
987− tim = ktime_add_safe(tim, ktime_set(0, hrtimer_resolution));
988−#endif
989− }
995+
996+ tim = hrtimer_update_lowres(timer, tim, mode);
990997
991998 hrtimer_set_expires_range_ns(timer, tim, delta_ns);
992999
@@ -1074,19 +1081,23 @@ EXPORT_SYMBOL_GPL(hrtimer_cancel); · 81 unmodified lines
10741081 /**
10751082 * hrtimer_get_remaining - get remaining time for the timer
10761083 * @timer: the timer to read
1084+ * @adjust: adjust relative timers when CONFIG_TIME_LOW_RES=y
10771085 */
1078−ktime_t hrtimer_get_remaining(const struct hrtimer *timer)
1086+ktime_t __hrtimer_get_remaining(const struct hrtimer *timer, bool adjust)
10791087 {
10801088 unsigned long flags;
10811089 ktime_t rem;
10821090
10831091 lock_hrtimer_base(timer, &flags);
1084− rem = hrtimer_expires_remaining(timer);
1092+ if (IS_ENABLED(CONFIG_TIME_LOW_RES) && adjust)
1093+ rem = hrtimer_expires_remaining_adjusted(timer);
1094+ else
1095+ rem = hrtimer_expires_remaining(timer);
10851096 unlock_hrtimer_base(timer, &flags);
10861097
10871098 return rem;
10881099 }
1089−EXPORT_SYMBOL_GPL(hrtimer_get_remaining);
1100+EXPORT_SYMBOL_GPL(__hrtimer_get_remaining);
10901101
10911102 #ifdef CONFIG_NO_HZ_COMMON
10921103 /**
@@ -1219,6 +1230,14 @@ static void __run_hrtimer(struct hrtimer_cpu_base *cpu_base, · 126 unmodified lines
12191230 timer_stats_account_hrtimer(timer);
12201231 fn = timer->function;
12211232
1233+ /*
1234+ * Clear the 'is relative' flag for the TIME_LOW_RES case. If the
1235+ * timer is restarted with a period then it becomes an absolute
1236+ * timer. If its not restarted it does not matter.
1237+ */
1238+ if (IS_ENABLED(CONFIG_TIME_LOW_RES))
1239+ timer->is_rel = false;
1240+
12221241 /*
12231242 * Because we run timers from hardirq context, there is no chance
12241243 * they get migrated to another cpu, therefore its safe to unlock
kernel/time/itimer.c+1−1
@@ -26,7 +26,7 @@ · 25 unmodified lines
2626 */
2727 static struct timeval itimer_get_remtime(struct hrtimer *timer)
2828 {
29− ktime_t rem = hrtimer_get_remaining(timer);
29+ ktime_t rem = __hrtimer_get_remaining(timer, true);
3030
3131 /*
3232 * Racy but safe: if the itimer expires after the above
kernel/time/ntp.c+12−2
@@ -685,8 +685,18 @@ int ntp_validate_timex(struct timex *txc) · 684 unmodified lines
685685 if (!capable(CAP_SYS_TIME))
686686 return -EPERM;
687687
688− if (!timeval_inject_offset_valid(&txc->time))
689− return -EINVAL;
688+ if (txc->modes & ADJ_NANO) {
689+ struct timespec ts;
690+
691+ ts.tv_sec = txc->time.tv_sec;
692+ ts.tv_nsec = txc->time.tv_usec;
693+ if (!timespec_inject_offset_valid(&ts))
694+ return -EINVAL;
695+
696+ } else {
697+ if (!timeval_inject_offset_valid(&txc->time))
698+ return -EINVAL;
699+ }
690700 }
691701
692702 /*
kernel/time/posix-timers.c+1−1
@@ -760,7 +760,7 @@ common_timer_get(struct k_itimer *timr, struct itimerspec *cur_setting) · 759 unmodified lines
760760 (timr->it_sigev_notify & ~SIGEV_THREAD_ID) == SIGEV_NONE))
761761 timr->it_overrun += (unsigned int) hrtimer_forward(timer, now, iv);
762762
763− remaining = ktime_sub(hrtimer_get_expires(timer), now);
763+ remaining = __hrtimer_expires_remaining_adjusted(timer, now);
764764 /* Return 0 only, when the timer is expired and not pending */
765765 if (remaining.tv64 <= 0) {
766766 /*
kernel/time/tick-sched.c+9−7
@@ -36,16 +36,17 @@ · 35 unmodified lines
3636 */
3737 static DEFINE_PER_CPU(struct tick_sched, tick_cpu_sched);
3838
39−/*
40− * The time, when the last jiffy update happened. Protected by jiffies_lock.
41− */
42−static ktime_t last_jiffies_update;
43−
4439 struct tick_sched *tick_get_tick_sched(int cpu)
4540 {
4641 return &per_cpu(tick_cpu_sched, cpu);
4742 }
4843
44+#if defined(CONFIG_NO_HZ_COMMON) || defined(CONFIG_HIGH_RES_TIMERS)
45+/*
46+ * The time, when the last jiffy update happened. Protected by jiffies_lock.
47+ */
48+static ktime_t last_jiffies_update;
49+
4950 /*
5051 * Must be called with interrupts disabled !
5152 */
@@ -151,6 +152,7 @@ static void tick_sched_handle(struct tick_sched *ts, struct pt_regs *regs) · 99 unmodified lines
151152 update_process_times(user_mode(regs));
152153 profile_tick(CPU_PROFILING);
153154 }
155+#endif
154156
155157 #ifdef CONFIG_NO_HZ_FULL
156158 cpumask_var_t tick_nohz_full_mask;
@@ -993,9 +995,9 @@ static void tick_nohz_switch_to_nohz(void) · 836 unmodified lines
993995 /* Get the next period */
994996 next = tick_init_jiffy_update();
995997
996− hrtimer_forward_now(&ts->sched_timer, tick_period);
997998 hrtimer_set_expires(&ts->sched_timer, next);
998− tick_program_event(next, 1);
999+ hrtimer_forward_now(&ts->sched_timer, tick_period);
1000+ tick_program_event(hrtimer_get_expires(&ts->sched_timer), 1);
9991001 tick_nohz_activate(ts, NOHZ_MODE_LOWRES);
10001002 }
10011003
kernel/time/timer_list.c+1−1
@@ -69,7 +69,7 @@ print_timer(struct seq_file *m, struct hrtimer *taddr, struct hrtimer *timer, · 68 unmodified lines
6969 print_name_offset(m, taddr);
7070 SEQ_printf(m, ", ");
7171 print_name_offset(m, timer->function);
72− SEQ_printf(m, ", S:%02lx", timer->state);
72+ SEQ_printf(m, ", S:%02x", timer->state);
7373 #ifdef CONFIG_TIMER_STATS
7474 SEQ_printf(m, ", ");
7575 print_name_offset(m, timer->start_site);
kernel/trace/bpf_trace.c+10−4
@@ -191,14 +191,17 @@ static u64 bpf_perf_event_read(u64 r1, u64 index, u64 r3, u64 r4, u64 r5) · 190 unmodified lines
191191 struct bpf_map *map = (struct bpf_map *) (unsigned long) r1;
192192 struct bpf_array *array = container_of(map, struct bpf_array, map);
193193 struct perf_event *event;
194+ struct file *file;
194195
195196 if (unlikely(index >= array->map.max_entries))
196197 return -E2BIG;
197198
198− event = (struct perf_event *)array->ptrs[index];
199− if (!event)
199+ file = (struct file *)array->ptrs[index];
200+ if (unlikely(!file))
200201 return -ENOENT;
201202
203+ event = file->private_data;
204+
202205 /* make sure event is local and doesn't have pmu::count */
203206 if (event->oncpu != smp_processor_id() ||
204207 event->pmu->count)
@@ -228,6 +231,7 @@ static u64 bpf_perf_event_output(u64 r1, u64 r2, u64 index, u64 r4, u64 size) · 23 unmodified lines
228231 void *data = (void *) (long) r4;
229232 struct perf_sample_data sample_data;
230233 struct perf_event *event;
234+ struct file *file;
231235 struct perf_raw_record raw = {
232236 .size = size,
233237 .data = data,
@@ -236,10 +240,12 @@ static u64 bpf_perf_event_output(u64 r1, u64 r2, u64 index, u64 r4, u64 size) · 2 unmodified lines
236240 if (unlikely(index >= array->map.max_entries))
237241 return -E2BIG;
238242
239− event = (struct perf_event *)array->ptrs[index];
240− if (unlikely(!event))
243+ file = (struct file *)array->ptrs[index];
244+ if (unlikely(!file))
241245 return -ENOENT;
242246
247+ event = file->private_data;
248+
243249 if (unlikely(event->attr.type != PERF_TYPE_SOFTWARE ||
244250 event->attr.config != PERF_COUNT_SW_BPF_OUTPUT))
245251 return -EINVAL;
kernel/trace/trace.c+1−1
@@ -1751,7 +1751,7 @@ void trace_buffer_unlock_commit_regs(struct trace_array *tr, · 1750 unmodified lines
17511751 {
17521752 __buffer_unlock_commit(buffer, event);
17531753
1754− ftrace_trace_stack(tr, buffer, flags, 6, pc, regs);
1754+ ftrace_trace_stack(tr, buffer, flags, 0, pc, regs);
17551755 ftrace_trace_userstack(buffer, flags, pc);
17561756 }
17571757 EXPORT_SYMBOL_GPL(trace_buffer_unlock_commit_regs);
lib/debugobjects.c+1−1
@@ -21,7 +21,7 @@ · 20 unmodified lines
2121 #define ODEBUG_HASH_BITS 14
2222 #define ODEBUG_HASH_SIZE (1 << ODEBUG_HASH_BITS)
2323
24−#define ODEBUG_POOL_SIZE 512
24+#define ODEBUG_POOL_SIZE 1024
2525 #define ODEBUG_POOL_MIN_LEVEL 256
2626
2727 #define ODEBUG_CHUNK_SHIFT PAGE_SHIFT
mm/cleancache.c+2−2
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 * cleancache_ops is set by cleancache_register_ops to contain the pointers
2323 * to the cleancache "backend" implementation functions.
2424 */
25−static struct cleancache_ops *cleancache_ops __read_mostly;
25+static const struct cleancache_ops *cleancache_ops __read_mostly;
2626
2727 /*
2828 * Counters available via /sys/kernel/debug/cleancache (if debugfs is
@@ -49,7 +49,7 @@ static void cleancache_register_ops_sb(struct super_block *sb, void *unused) · 20 unmodified lines
4949 /*
5050 * Register operations for cleancache. Returns 0 on success.
5151 */
52−int cleancache_register_ops(struct cleancache_ops *ops)
52+int cleancache_register_ops(const struct cleancache_ops *ops)
5353 {
5454 if (cmpxchg(&cleancache_ops, NULL, ops))
5555 return -EBUSY;
scripts/mod/modpost.c+2−1
@@ -594,7 +594,8 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname) · 593 unmodified lines
594594 if (strncmp(symname, "_restgpr0_", sizeof("_restgpr0_") - 1) == 0 ||
595595 strncmp(symname, "_savegpr0_", sizeof("_savegpr0_") - 1) == 0 ||
596596 strncmp(symname, "_restvr_", sizeof("_restvr_") - 1) == 0 ||
597− strncmp(symname, "_savevr_", sizeof("_savevr_") - 1) == 0)
597+ strncmp(symname, "_savevr_", sizeof("_savevr_") - 1) == 0 ||
598+ strcmp(symname, ".TOC.") == 0)
598599 return 1;
599600 /* Do not ignore this symbol */
600601 return 0;
security/keys/key.c+2−1
@@ -430,7 +430,8 @@ static int __key_instantiate_and_link(struct key *key, · 429 unmodified lines
430430
431431 /* and link it into the destination keyring */
432432 if (keyring) {
433− set_bit(KEY_FLAG_KEEP, &key->flags);
433+ if (test_bit(KEY_FLAG_KEEP, &keyring->flags))
434+ set_bit(KEY_FLAG_KEEP, &key->flags);
434435
435436 __key_link(key, _edit);
436437 }
sound/core/Kconfig+3−3
@@ -97,11 +97,11 @@ config SND_PCM_TIMER · 96 unmodified lines
9797 bool "PCM timer interface" if EXPERT
9898 default y
9999 help
100− If you disable this option, pcm timer will be inavailable, so
101− those stubs used pcm timer (e.g. dmix, dsnoop & co) may work
100+ If you disable this option, pcm timer will be unavailable, so
101+ those stubs that use pcm timer (e.g. dmix, dsnoop & co) may work
102102 incorrectlly.
103103
104− For some embedded device, we may disable it to reduce memory
104+ For some embedded devices, we may disable it to reduce memory
105105 footprint, about 20KB on x86_64 platform.
106106
107107 config SND_SEQUENCER_OSS
sound/core/compress_offload.c+11−0
@@ -46,6 +46,13 @@ · 45 unmodified lines
4646 #include <sound/compress_offload.h>
4747 #include <sound/compress_driver.h>
4848
49+/* struct snd_compr_codec_caps overflows the ioctl bit size for some
50+ * architectures, so we need to disable the relevant ioctls.
51+ */
52+#if _IOC_SIZEBITS < 14
53+#define COMPR_CODEC_CAPS_OVERFLOW
54+#endif
55+
4956 /* TODO:
5057 * - add substream support for multiple devices in case of
5158 * SND_DYNAMIC_MINORS is not used
@@ -440,6 +447,7 @@ out: · 388 unmodified lines
440447 return retval;
441448 }
442449
450+#ifndef COMPR_CODEC_CAPS_OVERFLOW
443451 static int
444452 snd_compr_get_codec_caps(struct snd_compr_stream *stream, unsigned long arg)
445453 {
@@ -463,6 +471,7 @@ out: · 17 unmodified lines
463471 kfree(caps);
464472 return retval;
465473 }
474+#endif /* !COMPR_CODEC_CAPS_OVERFLOW */
466475
467476 /* revisit this with snd_pcm_preallocate_xxx */
468477 static int snd_compr_allocate_buffer(struct snd_compr_stream *stream,
@@ -801,9 +810,11 @@ static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg) · 332 unmodified lines
801810 case _IOC_NR(SNDRV_COMPRESS_GET_CAPS):
802811 retval = snd_compr_get_caps(stream, arg);
803812 break;
813+#ifndef COMPR_CODEC_CAPS_OVERFLOW
804814 case _IOC_NR(SNDRV_COMPRESS_GET_CODEC_CAPS):
805815 retval = snd_compr_get_codec_caps(stream, arg);
806816 break;
817+#endif
807818 case _IOC_NR(SNDRV_COMPRESS_SET_PARAMS):
808819 retval = snd_compr_set_params(stream, arg);
809820 break;
sound/core/seq/oss/seq_oss_init.c+1−1
@@ -202,7 +202,7 @@ snd_seq_oss_open(struct file *file, int level) · 201 unmodified lines
202202
203203 dp->index = i;
204204 if (i >= SNDRV_SEQ_OSS_MAX_CLIENTS) {
205− pr_err("ALSA: seq_oss: too many applications\n");
205+ pr_debug("ALSA: seq_oss: too many applications\n");
206206 rc = -ENOMEM;
207207 goto _error;
208208 }
sound/core/seq/oss/seq_oss_synth.c+1−1
@@ -308,7 +308,7 @@ snd_seq_oss_synth_cleanup(struct seq_oss_devinfo *dp) · 307 unmodified lines
308308 struct seq_oss_synth *rec;
309309 struct seq_oss_synthinfo *info;
310310
311− if (snd_BUG_ON(dp->max_synthdev >= SNDRV_SEQ_OSS_MAX_SYNTH_DEVS))
311+ if (snd_BUG_ON(dp->max_synthdev > SNDRV_SEQ_OSS_MAX_SYNTH_DEVS))
312312 return;
313313 for (i = 0; i < dp->max_synthdev; i++) {
314314 info = &dp->synths[i];
sound/drivers/dummy.c+1−1
@@ -87,7 +87,7 @@ MODULE_PARM_DESC(pcm_substreams, "PCM substreams # (1-128) for dummy driver."); · 86 unmodified lines
8787 module_param(fake_buffer, bool, 0444);
8888 MODULE_PARM_DESC(fake_buffer, "Fake buffer allocations.");
8989 #ifdef CONFIG_HIGH_RES_TIMERS
90−module_param(hrtimer, bool, 0644);
90+module_param(hrtimer, bool, 0444);
9191 MODULE_PARM_DESC(hrtimer, "Use hrtimer as the timer source.");
9292 #endif
9393
sound/firewire/bebob/bebob_stream.c+9−5
@@ -47,14 +47,16 @@ static const unsigned int bridgeco_freq_table[] = { · 46 unmodified lines
4747 [6] = 0x07,
4848 };
4949
50−static unsigned int
51−get_formation_index(unsigned int rate)
50+static int
51+get_formation_index(unsigned int rate, unsigned int *index)
5252 {
5353 unsigned int i;
5454
5555 for (i = 0; i < ARRAY_SIZE(snd_bebob_rate_table); i++) {
56− if (snd_bebob_rate_table[i] == rate)
57− return i;
56+ if (snd_bebob_rate_table[i] == rate) {
57+ *index = i;
58+ return 0;
59+ }
5860 }
5961 return -EINVAL;
6062 }
@@ -425,7 +427,9 @@ make_both_connections(struct snd_bebob *bebob, unsigned int rate) · 364 unmodified lines
425427 goto end;
426428
427429 /* confirm params for both streams */
428− index = get_formation_index(rate);
430+ err = get_formation_index(rate, &index);
431+ if (err < 0)
432+ goto end;
429433 pcm_channels = bebob->tx_stream_formations[index].pcm;
430434 midi_channels = bebob->tx_stream_formations[index].midi;
431435 err = amdtp_am824_set_parameters(&bebob->tx_stream, rate,
sound/isa/Kconfig+4−0
@@ -3,6 +3,7 @@ · 2 unmodified lines
33 config SND_WSS_LIB
44 tristate
55 select SND_PCM
6+ select SND_TIMER
67
78 config SND_SB_COMMON
89 tristate
@@ -42,6 +43,7 @@ config SND_AD1816A · 33 unmodified lines
4243 select SND_OPL3_LIB
4344 select SND_MPU401_UART
4445 select SND_PCM
46+ select SND_TIMER
4547 help
4648 Say Y here to include support for Analog Devices SoundPort
4749 AD1816A or compatible sound chips.
@@ -209,6 +211,7 @@ config SND_GUSCLASSIC · 161 unmodified lines
209211 tristate "Gravis UltraSound Classic"
210212 select SND_RAWMIDI
211213 select SND_PCM
214+ select SND_TIMER
212215 help
213216 Say Y here to include support for Gravis UltraSound Classic
214217 soundcards.
@@ -221,6 +224,7 @@ config SND_GUSEXTREME · 6 unmodified lines
221224 select SND_OPL3_LIB
222225 select SND_MPU401_UART
223226 select SND_PCM
227+ select SND_TIMER
224228 help
225229 Say Y here to include support for Gravis UltraSound Extreme
226230 soundcards.
sound/pci/Kconfig+3−0
@@ -155,6 +155,7 @@ config SND_AZT3328 · 154 unmodified lines
155155 select SND_PCM
156156 select SND_RAWMIDI
157157 select SND_AC97_CODEC
158+ select SND_TIMER
158159 depends on ZONE_DMA
159160 help
160161 Say Y here to include support for Aztech AZF3328 (PCI168)
@@ -463,6 +464,7 @@ config SND_EMU10K1 · 302 unmodified lines
463464 select SND_HWDEP
464465 select SND_RAWMIDI
465466 select SND_AC97_CODEC
467+ select SND_TIMER
466468 depends on ZONE_DMA
467469 help
468470 Say Y to include support for Sound Blaster PCI 512, Live!,
@@ -889,6 +891,7 @@ config SND_YMFPCI · 420 unmodified lines
889891 select SND_OPL3_LIB
890892 select SND_MPU401_UART
891893 select SND_AC97_CODEC
894+ select SND_TIMER
892895 help
893896 Say Y here to include support for Yamaha PCI audio chips -
894897 YMF724, YMF724F, YMF740, YMF740C, YMF744, YMF754.
sound/pci/hda/hda_intel.c+13−0
@@ -90,6 +90,8 @@ enum { · 89 unmodified lines
9090 #define NVIDIA_HDA_ENABLE_COHBIT 0x01
9191
9292 /* Defines for Intel SCH HDA snoop control */
93+#define INTEL_HDA_CGCTL 0x48
94+#define INTEL_HDA_CGCTL_MISCBDCGE (0x1 << 6)
9395 #define INTEL_SCH_HDA_DEVC 0x78
9496 #define INTEL_SCH_HDA_DEVC_NOSNOOP (0x1<<11)
9597
@@ -534,10 +536,21 @@ static void hda_intel_init_chip(struct azx *chip, bool full_reset) · 438 unmodified lines
534536 {
535537 struct hdac_bus *bus = azx_bus(chip);
536538 struct pci_dev *pci = chip->pci;
539+ u32 val;
537540
538541 if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
539542 snd_hdac_set_codec_wakeup(bus, true);
543+ if (IS_BROXTON(pci)) {
544+ pci_read_config_dword(pci, INTEL_HDA_CGCTL, &val);
545+ val = val & ~INTEL_HDA_CGCTL_MISCBDCGE;
546+ pci_write_config_dword(pci, INTEL_HDA_CGCTL, val);
547+ }
540548 azx_init_chip(chip, full_reset);
549+ if (IS_BROXTON(pci)) {
550+ pci_read_config_dword(pci, INTEL_HDA_CGCTL, &val);
551+ val = val | INTEL_HDA_CGCTL_MISCBDCGE;
552+ pci_write_config_dword(pci, INTEL_HDA_CGCTL, val);
553+ }
541554 if (chip->driver_caps & AZX_DCAPS_I915_POWERWELL)
542555 snd_hdac_set_codec_wakeup(bus, false);
543556
sound/pci/hda/patch_hdmi.c+1−0
@@ -3653,6 +3653,7 @@ HDA_CODEC_ENTRY(0x10de0070, "GPU 70 HDMI/DP", patch_nvhdmi), · 3652 unmodified lines
36533653 HDA_CODEC_ENTRY(0x10de0071, "GPU 71 HDMI/DP", patch_nvhdmi),
36543654 HDA_CODEC_ENTRY(0x10de0072, "GPU 72 HDMI/DP", patch_nvhdmi),
36553655 HDA_CODEC_ENTRY(0x10de007d, "GPU 7d HDMI/DP", patch_nvhdmi),
3656+HDA_CODEC_ENTRY(0x10de0083, "GPU 83 HDMI/DP", patch_nvhdmi),
36563657 HDA_CODEC_ENTRY(0x10de8001, "MCP73 HDMI", patch_nvhdmi_2ch),
36573658 HDA_CODEC_ENTRY(0x11069f80, "VX900 HDMI/DP", patch_via_hdmi),
36583659 HDA_CODEC_ENTRY(0x11069f81, "VX900 HDMI/DP", patch_via_hdmi),
sound/sparc/Kconfig+1−0
@@ -22,6 +22,7 @@ config SND_SUN_AMD7930 · 21 unmodified lines
2222 config SND_SUN_CS4231
2323 tristate "Sun CS4231"
2424 select SND_PCM
25+ select SND_TIMER
2526 help
2627 Say Y here to include support for CS4231 sound device on Sun.
2728
sound/usb/quirks.c+13−1
@@ -1205,8 +1205,12 @@ void snd_usb_set_interface_quirk(struct usb_device *dev) · 1204 unmodified lines
12051205 * "Playback Design" products need a 50ms delay after setting the
12061206 * USB interface.
12071207 */
1208− if (le16_to_cpu(dev->descriptor.idVendor) == 0x23ba)
1208+ switch (le16_to_cpu(dev->descriptor.idVendor)) {
1209+ case 0x23ba: /* Playback Design */
1210+ case 0x0644: /* TEAC Corp. */
12091211 mdelay(50);
1212+ break;
1213+ }
12101214 }
12111215
12121216 void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe,
@@ -1221,6 +1225,14 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, · 8 unmodified lines
12211225 (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
12221226 mdelay(20);
12231227
1228+ /*
1229+ * "TEAC Corp." products need a 20ms delay after each
1230+ * class compliant request
1231+ */
1232+ if ((le16_to_cpu(dev->descriptor.idVendor) == 0x0644) &&
1233+ (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS)
1234+ mdelay(20);
1235+
12241236 /* Marantz/Denon devices with USB DAC functionality need a delay
12251237 * after each class compliant request
12261238 */
tools/perf/Makefile.perf+24−1
@@ -77,6 +77,9 @@ include config/utilities.mak · 76 unmodified lines
7777 # Define NO_AUXTRACE if you do not want AUX area tracing support
7878 #
7979 # Define NO_LIBBPF if you do not want BPF support
80+#
81+# Define FEATURES_DUMP to provide features detection dump file
82+# and bypass the feature detection
8083
8184 # As per kernel Makefile, avoid funny character set dependencies
8285 unexport LC_ALL
@@ -166,6 +169,15 @@ ifeq ($(config),1) · 83 unmodified lines
166169 include config/Makefile
167170 endif
168171
172+# The FEATURE_DUMP_EXPORT holds location of the actual
173+# FEATURE_DUMP file to be used to bypass feature detection
174+# (for bpf or any other subproject)
175+ifeq ($(FEATURES_DUMP),)
176+FEATURE_DUMP_EXPORT := $(realpath $(OUTPUT)FEATURE-DUMP)
177+else
178+FEATURE_DUMP_EXPORT := $(FEATURES_DUMP)
179+endif
180+
169181 export prefix bindir sharedir sysconfdir DESTDIR
170182
171183 # sparse is architecture-neutral, which means that we need to tell it
@@ -436,7 +448,7 @@ $(LIBAPI)-clean: · 264 unmodified lines
436448 $(Q)$(MAKE) -C $(LIB_DIR) O=$(OUTPUT) clean >/dev/null
437449
438450 $(LIBBPF): fixdep FORCE
439− $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) $(OUTPUT)libbpf.a FEATURES_DUMP=$(realpath $(OUTPUT)FEATURE-DUMP)
451+ $(Q)$(MAKE) -C $(BPF_DIR) O=$(OUTPUT) $(OUTPUT)libbpf.a FEATURES_DUMP=$(FEATURE_DUMP_EXPORT)
440452
441453 $(LIBBPF)-clean:
442454 $(call QUIET_CLEAN, libbpf)
@@ -610,6 +622,17 @@ clean: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean · 167 unmodified lines
610622 $(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
611623 $(python-clean)
612624
625+#
626+# To provide FEATURE-DUMP into $(FEATURE_DUMP_COPY)
627+# file if defined, with no further action.
628+feature-dump:
629+ifdef FEATURE_DUMP_COPY
630+ @cp $(OUTPUT)FEATURE-DUMP $(FEATURE_DUMP_COPY)
631+ @echo "FEATURE-DUMP file copied into $(FEATURE_DUMP_COPY)"
632+else
633+ @echo "FEATURE-DUMP file available in $(OUTPUT)FEATURE-DUMP"
634+endif
635+
613636 #
614637 # Trick: if ../../.git does not exist - we are building out of tree for example,
615638 # then force version regeneration:
tools/perf/arch/x86/tests/intel-cqm.c+1−1
@@ -17,7 +17,7 @@ static pid_t spawn(void) · 16 unmodified lines
1717 if (pid)
1818 return pid;
1919
20− while(1);
20+ while(1)
2121 sleep(5);
2222 return 0;
2323 }
tools/perf/config/Makefile+4−0
@@ -181,7 +181,11 @@ LDFLAGS += -Wl,-z,noexecstack · 180 unmodified lines
181181
182182 EXTLIBS = -lpthread -lrt -lm -ldl
183183
184+ifeq ($(FEATURES_DUMP),)
184185 include $(srctree)/tools/build/Makefile.feature
186+else
187+include $(FEATURES_DUMP)
188+endif
185189
186190 ifeq ($(feature-stackprotector-all), 1)
187191 CFLAGS += -fstack-protector-all
tools/perf/tests/make+40−15
@@ -5,7 +5,7 @@ ifeq ($(MAKECMDGOALS),) · 4 unmodified lines
55 # no target specified, trigger the whole suite
66 all:
77 @echo "Testing Makefile"; $(MAKE) -sf tests/make MK=Makefile
8− @echo "Testing Makefile.perf"; $(MAKE) -sf tests/make MK=Makefile.perf
8+ @echo "Testing Makefile.perf"; $(MAKE) -sf tests/make MK=Makefile.perf SET_PARALLEL=1 SET_O=1
99 else
1010 # run only specific test over 'Makefile'
1111 %:
@@ -13,6 +13,26 @@ else · 1 unmodified line
1313 endif
1414 else
1515 PERF := .
16+PERF_O := $(PERF)
17+O_OPT :=
18+
19+ifneq ($(O),)
20+ FULL_O := $(shell readlink -f $(O) || echo $(O))
21+ PERF_O := $(FULL_O)
22+ ifeq ($(SET_O),1)
23+ O_OPT := 'O=$(FULL_O)'
24+ endif
25+ K_O_OPT := 'O=$(FULL_O)'
26+endif
27+
28+PARALLEL_OPT=
29+ifeq ($(SET_PARALLEL),1)
30+ cores := $(shell (getconf _NPROCESSORS_ONLN || egrep -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
31+ ifeq ($(cores),0)
32+ cores := 1
33+ endif
34+ PARALLEL_OPT="-j$(cores)"
35+endif
1636
1737 # As per kernel Makefile, avoid funny character set dependencies
1838 unexport LC_ALL
@@ -156,11 +176,11 @@ test_make_doc := $(test_ok) · 137 unmodified lines
156176 test_make_help_O := $(test_ok)
157177 test_make_doc_O := $(test_ok)
158178
159−test_make_python_perf_so := test -f $(PERF)/python/perf.so
179+test_make_python_perf_so := test -f $(PERF_O)/python/perf.so
160180
161−test_make_perf_o := test -f $(PERF)/perf.o
162−test_make_util_map_o := test -f $(PERF)/util/map.o
163−test_make_util_pmu_bison_o := test -f $(PERF)/util/pmu-bison.o
181+test_make_perf_o := test -f $(PERF_O)/perf.o
182+test_make_util_map_o := test -f $(PERF_O)/util/map.o
183+test_make_util_pmu_bison_o := test -f $(PERF_O)/util/pmu-bison.o
164184
165185 define test_dest_files
166186 for file in $(1); do \
@@ -227,7 +247,7 @@ test_make_perf_o_O := test -f $$TMP_O/perf.o · 60 unmodified lines
227247 test_make_util_map_o_O := test -f $$TMP_O/util/map.o
228248 test_make_util_pmu_bison_o_O := test -f $$TMP_O/util/pmu-bison.o
229249
230−test_default = test -x $(PERF)/perf
250+test_default = test -x $(PERF_O)/perf
231251 test = $(if $(test_$1),$(test_$1),$(test_default))
232252
233253 test_default_O = test -x $$TMP_O/perf
@@ -247,12 +267,12 @@ endif · 13 unmodified lines
247267
248268 MAKEFLAGS := --no-print-directory
249269
250−clean := @(cd $(PERF); make -s -f $(MK) clean >/dev/null)
270+clean := @(cd $(PERF); make -s -f $(MK) $(O_OPT) clean >/dev/null)
251271
252272 $(run):
253273 $(call clean)
254274 @TMP_DEST=$$(mktemp -d); \
255− cmd="cd $(PERF) && make -f $(MK) DESTDIR=$$TMP_DEST $($@)"; \
275+ cmd="cd $(PERF) && make -f $(MK) $(PARALLEL_OPT) $(O_OPT) DESTDIR=$$TMP_DEST $($@)"; \
256276 echo "- $@: $$cmd" && echo $$cmd > $@ && \
257277 ( eval $$cmd ) >> $@ 2>&1; \
258278 echo " test: $(call test,$@)" >> $@ 2>&1; \
@@ -263,7 +283,7 @@ $(run_O): · 4 unmodified lines
263283 $(call clean)
264284 @TMP_O=$$(mktemp -d); \
265285 TMP_DEST=$$(mktemp -d); \
266− cmd="cd $(PERF) && make -f $(MK) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \
286+ cmd="cd $(PERF) && make -f $(MK) $(PARALLEL_OPT) O=$$TMP_O DESTDIR=$$TMP_DEST $($(patsubst %_O,%,$@))"; \
267287 echo "- $@: $$cmd" && echo $$cmd > $@ && \
268288 ( eval $$cmd ) >> $@ 2>&1 && \
269289 echo " test: $(call test_O,$@)" >> $@ 2>&1; \
@@ -276,17 +296,22 @@ tarpkg: · 6 unmodified lines
276296 ( eval $$cmd ) >> $@ 2>&1 && \
277297 rm -f $@
278298
299+KERNEL_O := ../..
300+ifneq ($(O),)
301+ KERNEL_O := $(O)
302+endif
303+
279304 make_kernelsrc:
280− @echo "- make -C <kernelsrc> tools/perf"
305+ @echo "- make -C <kernelsrc> $(PARALLEL_OPT) $(K_O_OPT) tools/perf"
281306 $(call clean); \
282− (make -C ../.. tools/perf) > $@ 2>&1 && \
283− test -x perf && rm -f $@ || (cat $@ ; false)
307+ (make -C ../.. $(PARALLEL_OPT) $(K_O_OPT) tools/perf) > $@ 2>&1 && \
308+ test -x $(KERNEL_O)/tools/perf/perf && rm -f $@ || (cat $@ ; false)
284309
285310 make_kernelsrc_tools:
286− @echo "- make -C <kernelsrc>/tools perf"
311+ @echo "- make -C <kernelsrc>/tools $(PARALLEL_OPT) $(K_O_OPT) perf"
287312 $(call clean); \
288− (make -C ../../tools perf) > $@ 2>&1 && \
289− test -x perf && rm -f $@ || (cat $@ ; false)
313+ (make -C ../../tools $(PARALLEL_OPT) $(K_O_OPT) perf) > $@ 2>&1 && \
314+ test -x $(KERNEL_O)/tools/perf/perf && rm -f $@ || (cat $@ ; false)
290315
291316 all: $(run) $(run_O) tarpkg make_kernelsrc make_kernelsrc_tools
292317 @echo OK
tools/perf/ui/browsers/annotate.c+2−2
@@ -755,11 +755,11 @@ static int annotate_browser__run(struct annotate_browser *browser, · 754 unmodified lines
755755 nd = browser->curr_hot;
756756 break;
757757 case K_UNTAB:
758− if (nd != NULL)
758+ if (nd != NULL) {
759759 nd = rb_next(nd);
760760 if (nd == NULL)
761761 nd = rb_first(&browser->entries);
762− else
762+ } else
763763 nd = browser->curr_hot;
764764 break;
765765 case K_F1:
tools/perf/util/hist.c+2−0
@@ -131,6 +131,8 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *h) · 130 unmodified lines
131131 symlen = unresolved_col_width + 4 + 2;
132132 hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL,
133133 symlen);
134+ hists__new_col_len(hists, HISTC_MEM_DCACHELINE,
135+ symlen);
134136 }
135137
136138 if (h->mem_info->iaddr.sym) {
tools/perf/util/session.c+1−1
@@ -1149,7 +1149,7 @@ static struct machine *machines__find_for_cpumode(struct machines *machines, · 1148 unmodified lines
11491149
11501150 machine = machines__find(machines, pid);
11511151 if (!machine)
1152− machine = machines__find(machines, DEFAULT_GUEST_KERNEL_ID);
1152+ machine = machines__findnew(machines, DEFAULT_GUEST_KERNEL_ID);
11531153 return machine;
11541154 }
11551155
tools/perf/util/stat.c+0−1
@@ -310,7 +310,6 @@ int perf_stat_process_counter(struct perf_stat_config *config, · 309 unmodified lines
310310 int i, ret;
311311
312312 aggr->val = aggr->ena = aggr->run = 0;
313− init_stats(ps->res_stats);
314313
315314 if (counter->per_pkg)
316315 zero_per_pkg(counter);
tools/perf/util/symbol.c+1−1
@@ -1466,7 +1466,7 @@ int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter) · 1465 unmodified lines
14661466 * Read the build id if possible. This is required for
14671467 * DSO_BINARY_TYPE__BUILDID_DEBUGINFO to work
14681468 */
1469− if (filename__read_build_id(dso->name, build_id, BUILD_ID_SIZE) > 0)
1469+ if (filename__read_build_id(dso->long_name, build_id, BUILD_ID_SIZE) > 0)
14701470 dso__set_build_id(dso, build_id);
14711471
14721472 /*
tools/testing/selftests/timers/valid-adjtimex.c+138−1
@@ -45,7 +45,17 @@ static inline int ksft_exit_fail(void) · 44 unmodified lines
4545 }
4646 #endif
4747
48−#define NSEC_PER_SEC 1000000000L
48+#define NSEC_PER_SEC 1000000000LL
49+#define USEC_PER_SEC 1000000LL
50+
51+#define ADJ_SETOFFSET 0x0100
52+
53+#include <sys/syscall.h>
54+static int clock_adjtime(clockid_t id, struct timex *tx)
55+{
56+ return syscall(__NR_clock_adjtime, id, tx);
57+}
58+
4959
5060 /* clear NTP time_status & time_state */
5161 int clear_time_state(void)
@@ -193,10 +203,137 @@ out: · 141 unmodified lines
193203 }
194204
195205
206+int set_offset(long long offset, int use_nano)
207+{
208+ struct timex tmx = {};
209+ int ret;
210+
211+ tmx.modes = ADJ_SETOFFSET;
212+ if (use_nano) {
213+ tmx.modes |= ADJ_NANO;
214+
215+ tmx.time.tv_sec = offset / NSEC_PER_SEC;
216+ tmx.time.tv_usec = offset % NSEC_PER_SEC;
217+
218+ if (offset < 0 && tmx.time.tv_usec) {
219+ tmx.time.tv_sec -= 1;
220+ tmx.time.tv_usec += NSEC_PER_SEC;
221+ }
222+ } else {
223+ tmx.time.tv_sec = offset / USEC_PER_SEC;
224+ tmx.time.tv_usec = offset % USEC_PER_SEC;
225+
226+ if (offset < 0 && tmx.time.tv_usec) {
227+ tmx.time.tv_sec -= 1;
228+ tmx.time.tv_usec += USEC_PER_SEC;
229+ }
230+ }
231+
232+ ret = clock_adjtime(CLOCK_REALTIME, &tmx);
233+ if (ret < 0) {
234+ printf("(sec: %ld usec: %ld) ", tmx.time.tv_sec, tmx.time.tv_usec);
235+ printf("[FAIL]\n");
236+ return -1;
237+ }
238+ return 0;
239+}
240+
241+int set_bad_offset(long sec, long usec, int use_nano)
242+{
243+ struct timex tmx = {};
244+ int ret;
245+
246+ tmx.modes = ADJ_SETOFFSET;
247+ if (use_nano)
248+ tmx.modes |= ADJ_NANO;
249+
250+ tmx.time.tv_sec = sec;
251+ tmx.time.tv_usec = usec;
252+ ret = clock_adjtime(CLOCK_REALTIME, &tmx);
253+ if (ret >= 0) {
254+ printf("Invalid (sec: %ld usec: %ld) did not fail! ", tmx.time.tv_sec, tmx.time.tv_usec);
255+ printf("[FAIL]\n");
256+ return -1;
257+ }
258+ return 0;
259+}
260+
261+int validate_set_offset(void)
262+{
263+ printf("Testing ADJ_SETOFFSET... ");
264+
265+ /* Test valid values */
266+ if (set_offset(NSEC_PER_SEC - 1, 1))
267+ return -1;
268+
269+ if (set_offset(-NSEC_PER_SEC + 1, 1))
270+ return -1;
271+
272+ if (set_offset(-NSEC_PER_SEC - 1, 1))
273+ return -1;
274+
275+ if (set_offset(5 * NSEC_PER_SEC, 1))
276+ return -1;
277+
278+ if (set_offset(-5 * NSEC_PER_SEC, 1))
279+ return -1;
280+
281+ if (set_offset(5 * NSEC_PER_SEC + NSEC_PER_SEC / 2, 1))
282+ return -1;
283+
284+ if (set_offset(-5 * NSEC_PER_SEC - NSEC_PER_SEC / 2, 1))
285+ return -1;
286+
287+ if (set_offset(USEC_PER_SEC - 1, 0))
288+ return -1;
289+
290+ if (set_offset(-USEC_PER_SEC + 1, 0))
291+ return -1;
292+
293+ if (set_offset(-USEC_PER_SEC - 1, 0))
294+ return -1;
295+
296+ if (set_offset(5 * USEC_PER_SEC, 0))
297+ return -1;
298+
299+ if (set_offset(-5 * USEC_PER_SEC, 0))
300+ return -1;
301+
302+ if (set_offset(5 * USEC_PER_SEC + USEC_PER_SEC / 2, 0))
303+ return -1;
304+
305+ if (set_offset(-5 * USEC_PER_SEC - USEC_PER_SEC / 2, 0))
306+ return -1;
307+
308+ /* Test invalid values */
309+ if (set_bad_offset(0, -1, 1))
310+ return -1;
311+ if (set_bad_offset(0, -1, 0))
312+ return -1;
313+ if (set_bad_offset(0, 2 * NSEC_PER_SEC, 1))
314+ return -1;
315+ if (set_bad_offset(0, 2 * USEC_PER_SEC, 0))
316+ return -1;
317+ if (set_bad_offset(0, NSEC_PER_SEC, 1))
318+ return -1;
319+ if (set_bad_offset(0, USEC_PER_SEC, 0))
320+ return -1;
321+ if (set_bad_offset(0, -NSEC_PER_SEC, 1))
322+ return -1;
323+ if (set_bad_offset(0, -USEC_PER_SEC, 0))
324+ return -1;
325+
326+ printf("[OK]\n");
327+ return 0;
328+}
329+
196330 int main(int argc, char **argv)
197331 {
198332 if (validate_freq())
199333 return ksft_exit_fail();
200334
335+ if (validate_set_offset())
336+ return ksft_exit_fail();
337+
201338 return ksft_exit_pass();
202339 }
tools/virtio/asm/barrier.h+13−9
@@ -1,15 +1,19 @@
11 #if defined(__i386__) || defined(__x86_64__)
22 #define barrier() asm volatile("" ::: "memory")
3−#define mb() __sync_synchronize()
4−
5−#define smp_mb() mb()
6−# define dma_rmb() barrier()
7−# define dma_wmb() barrier()
8−# define smp_rmb() barrier()
9−# define smp_wmb() barrier()
3+#define virt_mb() __sync_synchronize()
4+#define virt_rmb() barrier()
5+#define virt_wmb() barrier()
6+/* Atomic store should be enough, but gcc generates worse code in that case. */
7+#define virt_store_mb(var, value) do { \
8+ typeof(var) virt_store_mb_value = (value); \
9+ __atomic_exchange(&(var), &virt_store_mb_value, &virt_store_mb_value, \
10+ __ATOMIC_SEQ_CST); \
11+ barrier(); \
12+} while (0);
1013 /* Weak barriers should be used. If not - it's a bug */
11−# define rmb() abort()
12−# define wmb() abort()
14+# define mb() abort()
15+# define rmb() abort()
16+# define wmb() abort()
1317 #else
1418 #error Please fill in barrier macros
1519 #endif
tools/virtio/linux/compiler.h+9−0
@@ -0,0 +1,9 @@
1+#ifndef LINUX_COMPILER_H
2+#define LINUX_COMPILER_H
3+
4+#define WRITE_ONCE(var, val) \
5+ (*((volatile typeof(val) *)(&(var))) = (val))
6+
7+#define READ_ONCE(var) (*((volatile typeof(val) *)(&(var))))
8+
9+#endif
tools/virtio/linux/kernel.h+1−0
@@ -8,6 +8,7 @@ · 7 unmodified lines
88 #include <assert.h>
99 #include <stdarg.h>
1010
11+#include <linux/compiler.h>
1112 #include <linux/types.h>
1213 #include <linux/printk.h>
1314 #include <linux/bug.h>
tools/virtio/ringtest/Makefile+22−0
@@ -0,0 +1,22 @@
1+all:
2+
3+all: ring virtio_ring_0_9 virtio_ring_poll
4+
5+CFLAGS += -Wall
6+CFLAGS += -pthread -O2 -ggdb
7+LDFLAGS += -pthread -O2 -ggdb
8+
9+main.o: main.c main.h
10+ring.o: ring.c main.h
11+virtio_ring_0_9.o: virtio_ring_0_9.c main.h
12+virtio_ring_poll.o: virtio_ring_poll.c virtio_ring_0_9.c main.h
13+ring: ring.o main.o
14+virtio_ring_0_9: virtio_ring_0_9.o main.o
15+virtio_ring_poll: virtio_ring_poll.o main.o
16+clean:
17+ -rm main.o
18+ -rm ring.o ring
19+ -rm virtio_ring_0_9.o virtio_ring_0_9
20+ -rm virtio_ring_poll.o virtio_ring_poll
21+
22+.PHONY: all clean
tools/virtio/ringtest/README+2−0
@@ -0,0 +1,2 @@
1+Partial implementation of various ring layouts, useful to tune virtio design.
2+Uses shared memory heavily.
tools/virtio/ringtest/main.c+366−0
@@ -0,0 +1,366 @@
1+/*
2+ * Copyright (C) 2016 Red Hat, Inc.
3+ * Author: Michael S. Tsirkin <mst@redhat.com>
4+ * This work is licensed under the terms of the GNU GPL, version 2.
5+ *
6+ * Command line processing and common functions for ring benchmarking.
7+ */
8+#define _GNU_SOURCE
9+#include <getopt.h>
10+#include <pthread.h>
11+#include <assert.h>
12+#include <sched.h>
13+#include "main.h"
14+#include <sys/eventfd.h>
15+#include <stdlib.h>
16+#include <stdio.h>
17+#include <unistd.h>
18+#include <limits.h>
19+
20+int runcycles = 10000000;
21+int max_outstanding = INT_MAX;
22+int batch = 1;
23+
24+bool do_sleep = false;
25+bool do_relax = false;
26+bool do_exit = true;
27+
28+unsigned ring_size = 256;
29+
30+static int kickfd = -1;
31+static int callfd = -1;
32+
33+void notify(int fd)
34+{
35+ unsigned long long v = 1;
36+ int r;
37+
38+ vmexit();
39+ r = write(fd, &v, sizeof v);
40+ assert(r == sizeof v);
41+ vmentry();
42+}
43+
44+void wait_for_notify(int fd)
45+{
46+ unsigned long long v = 1;
47+ int r;
48+
49+ vmexit();
50+ r = read(fd, &v, sizeof v);
51+ assert(r == sizeof v);
52+ vmentry();
53+}
54+
55+void kick(void)
56+{
57+ notify(kickfd);
58+}
59+
60+void wait_for_kick(void)
61+{
62+ wait_for_notify(kickfd);
63+}
64+
65+void call(void)
66+{
67+ notify(callfd);
68+}
69+
70+void wait_for_call(void)
71+{
72+ wait_for_notify(callfd);
73+}
74+
75+void set_affinity(const char *arg)
76+{
77+ cpu_set_t cpuset;
78+ int ret;
79+ pthread_t self;
80+ long int cpu;
81+ char *endptr;
82+
83+ if (!arg)
84+ return;
85+
86+ cpu = strtol(arg, &endptr, 0);
87+ assert(!*endptr);
88+
89+ assert(cpu >= 0 || cpu < CPU_SETSIZE);
90+
91+ self = pthread_self();
92+ CPU_ZERO(&cpuset);
93+ CPU_SET(cpu, &cpuset);
94+
95+ ret = pthread_setaffinity_np(self, sizeof(cpu_set_t), &cpuset);
96+ assert(!ret);
97+}
98+
99+static void run_guest(void)
100+{
101+ int completed_before;
102+ int completed = 0;
103+ int started = 0;
104+ int bufs = runcycles;
105+ int spurious = 0;
106+ int r;
107+ unsigned len;
108+ void *buf;
109+ int tokick = batch;
110+
111+ for (;;) {
112+ if (do_sleep)
113+ disable_call();
114+ completed_before = completed;
115+ do {
116+ if (started < bufs &&
117+ started - completed < max_outstanding) {
118+ r = add_inbuf(0, NULL, "Hello, world!");
119+ if (__builtin_expect(r == 0, true)) {
120+ ++started;
121+ if (!--tokick) {
122+ tokick = batch;
123+ if (do_sleep)
124+ kick_available();
125+ }
126+
127+ }
128+ } else
129+ r = -1;
130+
131+ /* Flush out completed bufs if any */
132+ if (get_buf(&len, &buf)) {
133+ ++completed;
134+ if (__builtin_expect(completed == bufs, false))
135+ return;
136+ r = 0;
137+ }
138+ } while (r == 0);
139+ if (completed == completed_before)
140+ ++spurious;
141+ assert(completed <= bufs);
142+ assert(started <= bufs);
143+ if (do_sleep) {
144+ if (enable_call())
145+ wait_for_call();
146+ } else {
147+ poll_used();
148+ }
149+ }
150+}
151+
152+static void run_host(void)
153+{
154+ int completed_before;
155+ int completed = 0;
156+ int spurious = 0;
157+ int bufs = runcycles;
158+ unsigned len;
159+ void *buf;
160+
161+ for (;;) {
162+ if (do_sleep) {
163+ if (enable_kick())
164+ wait_for_kick();
165+ } else {
166+ poll_avail();
167+ }
168+ if (do_sleep)
169+ disable_kick();
170+ completed_before = completed;
171+ while (__builtin_expect(use_buf(&len, &buf), true)) {
172+ if (do_sleep)
173+ call_used();
174+ ++completed;
175+ if (__builtin_expect(completed == bufs, false))
176+ return;
177+ }
178+ if (completed == completed_before)
179+ ++spurious;
180+ assert(completed <= bufs);
181+ if (completed == bufs)
182+ break;
183+ }
184+}
185+
186+void *start_guest(void *arg)
187+{
188+ set_affinity(arg);
189+ run_guest();
190+ pthread_exit(NULL);
191+}
192+
193+void *start_host(void *arg)
194+{
195+ set_affinity(arg);
196+ run_host();
197+ pthread_exit(NULL);
198+}
199+
200+static const char optstring[] = "";
201+static const struct option longopts[] = {
202+ {
203+ .name = "help",
204+ .has_arg = no_argument,
205+ .val = 'h',
206+ },
207+ {
208+ .name = "host-affinity",
209+ .has_arg = required_argument,
210+ .val = 'H',
211+ },
212+ {
213+ .name = "guest-affinity",
214+ .has_arg = required_argument,
215+ .val = 'G',
216+ },
217+ {
218+ .name = "ring-size",
219+ .has_arg = required_argument,
220+ .val = 'R',
221+ },
222+ {
223+ .name = "run-cycles",
224+ .has_arg = required_argument,
225+ .val = 'C',
226+ },
227+ {
228+ .name = "outstanding",
229+ .has_arg = required_argument,
230+ .val = 'o',
231+ },
232+ {
233+ .name = "batch",
234+ .has_arg = required_argument,
235+ .val = 'b',
236+ },
237+ {
238+ .name = "sleep",
239+ .has_arg = no_argument,
240+ .val = 's',
241+ },
242+ {
243+ .name = "relax",
244+ .has_arg = no_argument,
245+ .val = 'x',
246+ },
247+ {
248+ .name = "exit",
249+ .has_arg = no_argument,
250+ .val = 'e',
251+ },
252+ {
253+ }
254+};
255+
256+static void help(void)
257+{
258+ fprintf(stderr, "Usage: <test> [--help]"
259+ " [--host-affinity H]"
260+ " [--guest-affinity G]"
261+ " [--ring-size R (default: %d)]"
262+ " [--run-cycles C (default: %d)]"
263+ " [--batch b]"
264+ " [--outstanding o]"
265+ " [--sleep]"
266+ " [--relax]"
267+ " [--exit]"
268+ "\n",
269+ ring_size,
270+ runcycles);
271+}
272+
273+int main(int argc, char **argv)
274+{
275+ int ret;
276+ pthread_t host, guest;
277+ void *tret;
278+ char *host_arg = NULL;
279+ char *guest_arg = NULL;
280+ char *endptr;
281+ long int c;
282+
283+ kickfd = eventfd(0, 0);
284+ assert(kickfd >= 0);
285+ callfd = eventfd(0, 0);
286+ assert(callfd >= 0);
287+
288+ for (;;) {
289+ int o = getopt_long(argc, argv, optstring, longopts, NULL);
290+ switch (o) {
291+ case -1:
292+ goto done;
293+ case '?':
294+ help();
295+ exit(2);
296+ case 'H':
297+ host_arg = optarg;
298+ break;
299+ case 'G':
300+ guest_arg = optarg;
301+ break;
302+ case 'R':
303+ ring_size = strtol(optarg, &endptr, 0);
304+ assert(ring_size && !(ring_size & (ring_size - 1)));
305+ assert(!*endptr);
306+ break;
307+ case 'C':
308+ c = strtol(optarg, &endptr, 0);
309+ assert(!*endptr);
310+ assert(c > 0 && c < INT_MAX);
311+ runcycles = c;
312+ break;
313+ case 'o':
314+ c = strtol(optarg, &endptr, 0);
315+ assert(!*endptr);
316+ assert(c > 0 && c < INT_MAX);
317+ max_outstanding = c;
318+ break;
319+ case 'b':
320+ c = strtol(optarg, &endptr, 0);
321+ assert(!*endptr);
322+ assert(c > 0 && c < INT_MAX);
323+ batch = c;
324+ break;
325+ case 's':
326+ do_sleep = true;
327+ break;
328+ case 'x':
329+ do_relax = true;
330+ break;
331+ case 'e':
332+ do_exit = true;
333+ break;
334+ default:
335+ help();
336+ exit(4);
337+ break;
338+ }
339+ }
340+
341+ /* does nothing here, used to make sure all smp APIs compile */
342+ smp_acquire();
343+ smp_release();
344+ smp_mb();
345+done:
346+
347+ if (batch > max_outstanding)
348+ batch = max_outstanding;
349+
350+ if (optind < argc) {
351+ help();
352+ exit(4);
353+ }
354+ alloc_ring();
355+
356+ ret = pthread_create(&host, NULL, start_host, host_arg);
357+ assert(!ret);
358+ ret = pthread_create(&guest, NULL, start_guest, guest_arg);
359+ assert(!ret);
360+
361+ ret = pthread_join(guest, &tret);
362+ assert(!ret);
363+ ret = pthread_join(host, &tret);
364+ assert(!ret);
365+ return 0;
366+}
tools/virtio/ringtest/main.h+119−0
@@ -0,0 +1,119 @@
1+/*
2+ * Copyright (C) 2016 Red Hat, Inc.
3+ * Author: Michael S. Tsirkin <mst@redhat.com>
4+ * This work is licensed under the terms of the GNU GPL, version 2.
5+ *
6+ * Common macros and functions for ring benchmarking.
7+ */
8+#ifndef MAIN_H
9+#define MAIN_H
10+
11+#include <stdbool.h>
12+
13+extern bool do_exit;
14+
15+#if defined(__x86_64__) || defined(__i386__)
16+#include "x86intrin.h"
17+
18+static inline void wait_cycles(unsigned long long cycles)
19+{
20+ unsigned long long t;
21+
22+ t = __rdtsc();
23+ while (__rdtsc() - t < cycles) {}
24+}
25+
26+#define VMEXIT_CYCLES 500
27+#define VMENTRY_CYCLES 500
28+
29+#else
30+static inline void wait_cycles(unsigned long long cycles)
31+{
32+ _Exit(5);
33+}
34+#define VMEXIT_CYCLES 0
35+#define VMENTRY_CYCLES 0
36+#endif
37+
38+static inline void vmexit(void)
39+{
40+ if (!do_exit)
41+ return;
42+
43+ wait_cycles(VMEXIT_CYCLES);
44+}
45+static inline void vmentry(void)
46+{
47+ if (!do_exit)
48+ return;
49+
50+ wait_cycles(VMENTRY_CYCLES);
51+}
52+
53+/* implemented by ring */
54+void alloc_ring(void);
55+/* guest side */
56+int add_inbuf(unsigned, void *, void *);
57+void *get_buf(unsigned *, void **);
58+void disable_call();
59+bool enable_call();
60+void kick_available();
61+void poll_used();
62+/* host side */
63+void disable_kick();
64+bool enable_kick();
65+bool use_buf(unsigned *, void **);
66+void call_used();
67+void poll_avail();
68+
69+/* implemented by main */
70+extern bool do_sleep;
71+void kick(void);
72+void wait_for_kick(void);
73+void call(void);
74+void wait_for_call(void);
75+
76+extern unsigned ring_size;
77+
78+/* Compiler barrier - similar to what Linux uses */
79+#define barrier() asm volatile("" ::: "memory")
80+
81+/* Is there a portable way to do this? */
82+#if defined(__x86_64__) || defined(__i386__)
83+#define cpu_relax() asm ("rep; nop" ::: "memory")
84+#else
85+#define cpu_relax() assert(0)
86+#endif
87+
88+extern bool do_relax;
89+
90+static inline void busy_wait(void)
91+{
92+ if (do_relax)
93+ cpu_relax();
94+ else
95+ /* prevent compiler from removing busy loops */
96+ barrier();
97+}
98+
99+/*
100+ * Not using __ATOMIC_SEQ_CST since gcc docs say they are only synchronized
101+ * with other __ATOMIC_SEQ_CST calls.
102+ */
103+#define smp_mb() __sync_synchronize()
104+
105+/*
106+ * This abuses the atomic builtins for thread fences, and
107+ * adds a compiler barrier.
108+ */
109+#define smp_release() do { \
110+ barrier(); \
111+ __atomic_thread_fence(__ATOMIC_RELEASE); \
112+} while (0)
113+
114+#define smp_acquire() do { \
115+ __atomic_thread_fence(__ATOMIC_ACQUIRE); \
116+ barrier(); \
117+} while (0)
118+
119+#endif
tools/virtio/ringtest/ring.c+272−0
@@ -0,0 +1,272 @@
1+/*
2+ * Copyright (C) 2016 Red Hat, Inc.
3+ * Author: Michael S. Tsirkin <mst@redhat.com>
4+ * This work is licensed under the terms of the GNU GPL, version 2.
5+ *
6+ * Simple descriptor-based ring. virtio 0.9 compatible event index is used for
7+ * signalling, unconditionally.
8+ */
9+#define _GNU_SOURCE
10+#include "main.h"
11+#include <stdlib.h>
12+#include <stdio.h>
13+#include <string.h>
14+
15+/* Next - Where next entry will be written.
16+ * Prev - "Next" value when event triggered previously.
17+ * Event - Peer requested event after writing this entry.
18+ */
19+static inline bool need_event(unsigned short event,
20+ unsigned short next,
21+ unsigned short prev)
22+{
23+ return (unsigned short)(next - event - 1) < (unsigned short)(next - prev);
24+}
25+
26+/* Design:
27+ * Guest adds descriptors with unique index values and DESC_HW in flags.
28+ * Host overwrites used descriptors with correct len, index, and DESC_HW clear.
29+ * Flags are always set last.
30+ */
31+#define DESC_HW 0x1
32+
33+struct desc {
34+ unsigned short flags;
35+ unsigned short index;
36+ unsigned len;
37+ unsigned long long addr;
38+};
39+
40+/* how much padding is needed to avoid false cache sharing */
41+#define HOST_GUEST_PADDING 0x80
42+
43+/* Mostly read */
44+struct event {
45+ unsigned short kick_index;
46+ unsigned char reserved0[HOST_GUEST_PADDING - 2];
47+ unsigned short call_index;
48+ unsigned char reserved1[HOST_GUEST_PADDING - 2];
49+};
50+
51+struct data {
52+ void *buf; /* descriptor is writeable, we can't get buf from there */
53+ void *data;
54+} *data;
55+
56+struct desc *ring;
57+struct event *event;
58+
59+struct guest {
60+ unsigned avail_idx;
61+ unsigned last_used_idx;
62+ unsigned num_free;
63+ unsigned kicked_avail_idx;
64+ unsigned char reserved[HOST_GUEST_PADDING - 12];
65+} guest;
66+
67+struct host {
68+ /* we do not need to track last avail index
69+ * unless we have more than one in flight.
70+ */
71+ unsigned used_idx;
72+ unsigned called_used_idx;
73+ unsigned char reserved[HOST_GUEST_PADDING - 4];
74+} host;
75+
76+/* implemented by ring */
77+void alloc_ring(void)
78+{
79+ int ret;
80+ int i;
81+
82+ ret = posix_memalign((void **)&ring, 0x1000, ring_size * sizeof *ring);
83+ if (ret) {
84+ perror("Unable to allocate ring buffer.\n");
85+ exit(3);
86+ }
87+ event = malloc(sizeof *event);
88+ if (!event) {
89+ perror("Unable to allocate event buffer.\n");
90+ exit(3);
91+ }
92+ memset(event, 0, sizeof *event);
93+ guest.avail_idx = 0;
94+ guest.kicked_avail_idx = -1;
95+ guest.last_used_idx = 0;
96+ host.used_idx = 0;
97+ host.called_used_idx = -1;
98+ for (i = 0; i < ring_size; ++i) {
99+ struct desc desc = {
100+ .index = i,
101+ };
102+ ring[i] = desc;
103+ }
104+ guest.num_free = ring_size;
105+ data = malloc(ring_size * sizeof *data);
106+ if (!data) {
107+ perror("Unable to allocate data buffer.\n");
108+ exit(3);
109+ }
110+ memset(data, 0, ring_size * sizeof *data);
111+}
112+
113+/* guest side */
114+int add_inbuf(unsigned len, void *buf, void *datap)
115+{
116+ unsigned head, index;
117+
118+ if (!guest.num_free)
119+ return -1;
120+
121+ guest.num_free--;
122+ head = (ring_size - 1) & (guest.avail_idx++);
123+
124+ /* Start with a write. On MESI architectures this helps
125+ * avoid a shared state with consumer that is polling this descriptor.
126+ */
127+ ring[head].addr = (unsigned long)(void*)buf;
128+ ring[head].len = len;
129+ /* read below might bypass write above. That is OK because it's just an
130+ * optimization. If this happens, we will get the cache line in a
131+ * shared state which is unfortunate, but probably not worth it to
132+ * add an explicit full barrier to avoid this.
133+ */
134+ barrier();
135+ index = ring[head].index;
136+ data[index].buf = buf;
137+ data[index].data = datap;
138+ /* Barrier A (for pairing) */
139+ smp_release();
140+ ring[head].flags = DESC_HW;
141+
142+ return 0;
143+}
144+
145+void *get_buf(unsigned *lenp, void **bufp)
146+{
147+ unsigned head = (ring_size - 1) & guest.last_used_idx;
148+ unsigned index;
149+ void *datap;
150+
151+ if (ring[head].flags & DESC_HW)
152+ return NULL;
153+ /* Barrier B (for pairing) */
154+ smp_acquire();
155+ *lenp = ring[head].len;
156+ index = ring[head].index & (ring_size - 1);
157+ datap = data[index].data;
158+ *bufp = data[index].buf;
159+ data[index].buf = NULL;
160+ data[index].data = NULL;
161+ guest.num_free++;
162+ guest.last_used_idx++;
163+ return datap;
164+}
165+
166+void poll_used(void)
167+{
168+ unsigned head = (ring_size - 1) & guest.last_used_idx;
169+
170+ while (ring[head].flags & DESC_HW)
171+ busy_wait();
172+}
173+
174+void disable_call()
175+{
176+ /* Doing nothing to disable calls might cause
177+ * extra interrupts, but reduces the number of cache misses.
178+ */
179+}
180+
181+bool enable_call()
182+{
183+ unsigned head = (ring_size - 1) & guest.last_used_idx;
184+
185+ event->call_index = guest.last_used_idx;
186+ /* Flush call index write */
187+ /* Barrier D (for pairing) */
188+ smp_mb();
189+ return ring[head].flags & DESC_HW;
190+}
191+
192+void kick_available(void)
193+{
194+ /* Flush in previous flags write */
195+ /* Barrier C (for pairing) */
196+ smp_mb();
197+ if (!need_event(event->kick_index,
198+ guest.avail_idx,
199+ guest.kicked_avail_idx))
200+ return;
201+
202+ guest.kicked_avail_idx = guest.avail_idx;
203+ kick();
204+}
205+
206+/* host side */
207+void disable_kick()
208+{
209+ /* Doing nothing to disable kicks might cause
210+ * extra interrupts, but reduces the number of cache misses.
211+ */
212+}
213+
214+bool enable_kick()
215+{
216+ unsigned head = (ring_size - 1) & host.used_idx;
217+
218+ event->kick_index = host.used_idx;
219+ /* Barrier C (for pairing) */
220+ smp_mb();
221+ return !(ring[head].flags & DESC_HW);
222+}
223+
224+void poll_avail(void)
225+{
226+ unsigned head = (ring_size - 1) & host.used_idx;
227+
228+ while (!(ring[head].flags & DESC_HW))
229+ busy_wait();
230+}
231+
232+bool use_buf(unsigned *lenp, void **bufp)
233+{
234+ unsigned head = (ring_size - 1) & host.used_idx;
235+
236+ if (!(ring[head].flags & DESC_HW))
237+ return false;
238+
239+ /* make sure length read below is not speculated */
240+ /* Barrier A (for pairing) */
241+ smp_acquire();
242+
243+ /* simple in-order completion: we don't need
244+ * to touch index at all. This also means we
245+ * can just modify the descriptor in-place.
246+ */
247+ ring[head].len--;
248+ /* Make sure len is valid before flags.
249+ * Note: alternative is to write len and flags in one access -
250+ * possible on 64 bit architectures but wmb is free on Intel anyway
251+ * so I have no way to test whether it's a gain.
252+ */
253+ /* Barrier B (for pairing) */
254+ smp_release();
255+ ring[head].flags = 0;
256+ host.used_idx++;
257+ return true;
258+}
259+
260+void call_used(void)
261+{
262+ /* Flush in previous flags write */
263+ /* Barrier D (for pairing) */
264+ smp_mb();
265+ if (!need_event(event->call_index,
266+ host.used_idx,
267+ host.called_used_idx))
268+ return;
269+
270+ host.called_used_idx = host.used_idx;
271+ call();
272+}
tools/virtio/ringtest/run-on-all.sh+24−0
@@ -0,0 +1,24 @@
1+#!/bin/sh
2+
3+#use last CPU for host. Why not the first?
4+#many devices tend to use cpu0 by default so
5+#it tends to be busier
6+HOST_AFFINITY=$(cd /dev/cpu; ls|grep -v '[a-z]'|sort -n|tail -1)
7+
8+#run command on all cpus
9+for cpu in $(cd /dev/cpu; ls|grep -v '[a-z]'|sort -n);
10+do
11+ #Don't run guest and host on same CPU
12+ #It actually works ok if using signalling
13+ if
14+ (echo "$@" | grep -e "--sleep" > /dev/null) || \
15+ test $HOST_AFFINITY '!=' $cpu
16+ then
17+ echo "GUEST AFFINITY $cpu"
18+ "$@" --host-affinity $HOST_AFFINITY --guest-affinity $cpu
19+ fi
20+done
21+echo "NO GUEST AFFINITY"
22+"$@" --host-affinity $HOST_AFFINITY
23+echo "NO AFFINITY"
24+"$@"
tools/virtio/ringtest/virtio_ring_0_9.c+316−0
@@ -0,0 +1,316 @@
1+/*
2+ * Copyright (C) 2016 Red Hat, Inc.
3+ * Author: Michael S. Tsirkin <mst@redhat.com>
4+ * This work is licensed under the terms of the GNU GPL, version 2.
5+ *
6+ * Partial implementation of virtio 0.9. event index is used for signalling,
7+ * unconditionally. Design roughly follows linux kernel implementation in order
8+ * to be able to judge its performance.
9+ */
10+#define _GNU_SOURCE
11+#include "main.h"
12+#include <stdlib.h>
13+#include <stdio.h>
14+#include <assert.h>
15+#include <string.h>
16+#include <linux/virtio_ring.h>
17+
18+struct data {
19+ void *data;
20+} *data;
21+
22+struct vring ring;
23+
24+/* enabling the below activates experimental ring polling code
25+ * (which skips index reads on consumer in favor of looking at
26+ * high bits of ring id ^ 0x8000).
27+ */
28+/* #ifdef RING_POLL */
29+
30+/* how much padding is needed to avoid false cache sharing */
31+#define HOST_GUEST_PADDING 0x80
32+
33+struct guest {
34+ unsigned short avail_idx;
35+ unsigned short last_used_idx;
36+ unsigned short num_free;
37+ unsigned short kicked_avail_idx;
38+ unsigned short free_head;
39+ unsigned char reserved[HOST_GUEST_PADDING - 10];
40+} guest;
41+
42+struct host {
43+ /* we do not need to track last avail index
44+ * unless we have more than one in flight.
45+ */
46+ unsigned short used_idx;
47+ unsigned short called_used_idx;
48+ unsigned char reserved[HOST_GUEST_PADDING - 4];
49+} host;
50+
51+/* implemented by ring */
52+void alloc_ring(void)
53+{
54+ int ret;
55+ int i;
56+ void *p;
57+
58+ ret = posix_memalign(&p, 0x1000, vring_size(ring_size, 0x1000));
59+ if (ret) {
60+ perror("Unable to allocate ring buffer.\n");
61+ exit(3);
62+ }
63+ memset(p, 0, vring_size(ring_size, 0x1000));
64+ vring_init(&ring, ring_size, p, 0x1000);
65+
66+ guest.avail_idx = 0;
67+ guest.kicked_avail_idx = -1;
68+ guest.last_used_idx = 0;
69+ /* Put everything in free lists. */
70+ guest.free_head = 0;
71+ for (i = 0; i < ring_size - 1; i++)
72+ ring.desc[i].next = i + 1;
73+ host.used_idx = 0;
74+ host.called_used_idx = -1;
75+ guest.num_free = ring_size;
76+ data = malloc(ring_size * sizeof *data);
77+ if (!data) {
78+ perror("Unable to allocate data buffer.\n");
79+ exit(3);
80+ }
81+ memset(data, 0, ring_size * sizeof *data);
82+}
83+
84+/* guest side */
85+int add_inbuf(unsigned len, void *buf, void *datap)
86+{
87+ unsigned head, avail;
88+ struct vring_desc *desc;
89+
90+ if (!guest.num_free)
91+ return -1;
92+
93+ head = guest.free_head;
94+ guest.num_free--;
95+
96+ desc = ring.desc;
97+ desc[head].flags = VRING_DESC_F_NEXT;
98+ desc[head].addr = (unsigned long)(void *)buf;
99+ desc[head].len = len;
100+ /* We do it like this to simulate the way
101+ * we'd have to flip it if we had multiple
102+ * descriptors.
103+ */
104+ desc[head].flags &= ~VRING_DESC_F_NEXT;
105+ guest.free_head = desc[head].next;
106+
107+ data[head].data = datap;
108+
109+#ifdef RING_POLL
110+ /* Barrier A (for pairing) */
111+ smp_release();
112+ avail = guest.avail_idx++;
113+ ring.avail->ring[avail & (ring_size - 1)] =
114+ (head | (avail & ~(ring_size - 1))) ^ 0x8000;
115+#else
116+ avail = (ring_size - 1) & (guest.avail_idx++);
117+ ring.avail->ring[avail] = head;
118+ /* Barrier A (for pairing) */
119+ smp_release();
120+#endif
121+ ring.avail->idx = guest.avail_idx;
122+ return 0;
123+}
124+
125+void *get_buf(unsigned *lenp, void **bufp)
126+{
127+ unsigned head;
128+ unsigned index;
129+ void *datap;
130+
131+#ifdef RING_POLL
132+ head = (ring_size - 1) & guest.last_used_idx;
133+ index = ring.used->ring[head].id;
134+ if ((index ^ guest.last_used_idx ^ 0x8000) & ~(ring_size - 1))
135+ return NULL;
136+ /* Barrier B (for pairing) */
137+ smp_acquire();
138+ index &= ring_size - 1;
139+#else
140+ if (ring.used->idx == guest.last_used_idx)
141+ return NULL;
142+ /* Barrier B (for pairing) */
143+ smp_acquire();
144+ head = (ring_size - 1) & guest.last_used_idx;
145+ index = ring.used->ring[head].id;
146+#endif
147+ *lenp = ring.used->ring[head].len;
148+ datap = data[index].data;
149+ *bufp = (void*)(unsigned long)ring.desc[index].addr;
150+ data[index].data = NULL;
151+ ring.desc[index].next = guest.free_head;
152+ guest.free_head = index;
153+ guest.num_free++;
154+ guest.last_used_idx++;
155+ return datap;
156+}
157+
158+void poll_used(void)
159+{
160+#ifdef RING_POLL
161+ unsigned head = (ring_size - 1) & guest.last_used_idx;
162+
163+ for (;;) {
164+ unsigned index = ring.used->ring[head].id;
165+
166+ if ((index ^ guest.last_used_idx ^ 0x8000) & ~(ring_size - 1))
167+ busy_wait();
168+ else
169+ break;
170+ }
171+#else
172+ unsigned head = guest.last_used_idx;
173+
174+ while (ring.used->idx == head)
175+ busy_wait();
176+#endif
177+}
178+
179+void disable_call()
180+{
181+ /* Doing nothing to disable calls might cause
182+ * extra interrupts, but reduces the number of cache misses.
183+ */
184+}
185+
186+bool enable_call()
187+{
188+ unsigned short last_used_idx;
189+
190+ vring_used_event(&ring) = (last_used_idx = guest.last_used_idx);
191+ /* Flush call index write */
192+ /* Barrier D (for pairing) */
193+ smp_mb();
194+#ifdef RING_POLL
195+ {
196+ unsigned short head = last_used_idx & (ring_size - 1);
197+ unsigned index = ring.used->ring[head].id;
198+
199+ return (index ^ last_used_idx ^ 0x8000) & ~(ring_size - 1);
200+ }
201+#else
202+ return ring.used->idx == last_used_idx;
203+#endif
204+}
205+
206+void kick_available(void)
207+{
208+ /* Flush in previous flags write */
209+ /* Barrier C (for pairing) */
210+ smp_mb();
211+ if (!vring_need_event(vring_avail_event(&ring),
212+ guest.avail_idx,
213+ guest.kicked_avail_idx))
214+ return;
215+
216+ guest.kicked_avail_idx = guest.avail_idx;
217+ kick();
218+}
219+
220+/* host side */
221+void disable_kick()
222+{
223+ /* Doing nothing to disable kicks might cause
224+ * extra interrupts, but reduces the number of cache misses.
225+ */
226+}
227+
228+bool enable_kick()
229+{
230+ unsigned head = host.used_idx;
231+
232+ vring_avail_event(&ring) = head;
233+ /* Barrier C (for pairing) */
234+ smp_mb();
235+#ifdef RING_POLL
236+ {
237+ unsigned index = ring.avail->ring[head & (ring_size - 1)];
238+
239+ return (index ^ head ^ 0x8000) & ~(ring_size - 1);
240+ }
241+#else
242+ return head == ring.avail->idx;
243+#endif
244+}
245+
246+void poll_avail(void)
247+{
248+ unsigned head = host.used_idx;
249+#ifdef RING_POLL
250+ for (;;) {
251+ unsigned index = ring.avail->ring[head & (ring_size - 1)];
252+ if ((index ^ head ^ 0x8000) & ~(ring_size - 1))
253+ busy_wait();
254+ else
255+ break;
256+ }
257+#else
258+ while (ring.avail->idx == head)
259+ busy_wait();
260+#endif
261+}
262+
263+bool use_buf(unsigned *lenp, void **bufp)
264+{
265+ unsigned used_idx = host.used_idx;
266+ struct vring_desc *desc;
267+ unsigned head;
268+
269+#ifdef RING_POLL
270+ head = ring.avail->ring[used_idx & (ring_size - 1)];
271+ if ((used_idx ^ head ^ 0x8000) & ~(ring_size - 1))
272+ return false;
273+ /* Barrier A (for pairing) */
274+ smp_acquire();
275+
276+ used_idx &= ring_size - 1;
277+ desc = &ring.desc[head & (ring_size - 1)];
278+#else
279+ if (used_idx == ring.avail->idx)
280+ return false;
281+
282+ /* Barrier A (for pairing) */
283+ smp_acquire();
284+
285+ used_idx &= ring_size - 1;
286+ head = ring.avail->ring[used_idx];
287+ desc = &ring.desc[head];
288+#endif
289+
290+ *lenp = desc->len;
291+ *bufp = (void *)(unsigned long)desc->addr;
292+
293+ /* now update used ring */
294+ ring.used->ring[used_idx].id = head;
295+ ring.used->ring[used_idx].len = desc->len - 1;
296+ /* Barrier B (for pairing) */
297+ smp_release();
298+ host.used_idx++;
299+ ring.used->idx = host.used_idx;
300+
301+ return true;
302+}
303+
304+void call_used(void)
305+{
306+ /* Flush in previous flags write */
307+ /* Barrier D (for pairing) */
308+ smp_mb();
309+ if (!vring_need_event(vring_used_event(&ring),
310+ host.used_idx,
311+ host.called_used_idx))
312+ return;
313+
314+ host.called_used_idx = host.used_idx;
315+ call();
316+}
tools/virtio/ringtest/virtio_ring_poll.c+2−0
@@ -0,0 +1,2 @@
1+#define RING_POLL 1
2+#include "virtio_ring_0_9.c"

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