Home Home > GIT Browse > SLE15-AZURE
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlaf Hering <ohering@suse.de>2019-05-14 23:26:16 +0200
committerOlaf Hering <ohering@suse.de>2019-05-14 23:26:16 +0200
commit375957d1484d9f4d9285dad97b0071e9039688ef (patch)
treeba64668356d72430a4beb709c880a0d25d0ec384
parentf1dc5eb39886e2810d8ac37908eebdb9dd78f0e3 (diff)
parentc190c41fb2e45114027544fa93d23be179c35bf0 (diff)
Merge remote-tracking branch 'kerncvs/SLE15' into SLE15-AZURE
-rw-r--r--blacklist.conf3
-rw-r--r--patches.arch/intel_idle-add-support-for-Jacobsville.patch13
-rw-r--r--patches.arch/kvm-x86-report-stibp-on-get_supported_cpuid.patch47
-rw-r--r--patches.arch/locking-atomics-asm-generic-move-some-macros-from-linux-bitops-h-to-a-new-linux-bits-h-file.patch90
-rw-r--r--patches.arch/powercap-intel_rapl-add-support-for-Jacobsville.patch6
-rw-r--r--patches.arch/x86-bugs-add-amd-s-variant-of-ssb_no.patch4
-rw-r--r--patches.arch/x86-cpu-Add-Atom-Tremont-Jacobsville.patch10
-rw-r--r--patches.arch/x86-cpu-sanitize-fam6_atom-naming.patch602
-rw-r--r--patches.arch/x86-kvm-expose-x86_feature_md_clear-to-guests.patch45
-rw-r--r--patches.arch/x86-kvm-vmx-add-mds-protection-when-l1d-flush-is-not-active.patch52
-rw-r--r--patches.arch/x86-msr-index-cleanup-bit-defines.patch102
-rw-r--r--patches.arch/x86-speculation-consolidate-cpu-whitelists.patch167
-rw-r--r--patches.arch/x86-speculation-mds-add-basic-bug-infrastructure-for-mds.patch148
-rw-r--r--patches.arch/x86-speculation-mds-add-bug_msbds_only.patch86
-rw-r--r--patches.arch/x86-speculation-mds-add-mds-full-nosmt-cmdline-option.patch85
-rw-r--r--patches.arch/x86-speculation-mds-add-mds_clear_cpu_buffers.patch216
-rw-r--r--patches.arch/x86-speculation-mds-add-mitigation-control-for-mds.patch186
-rw-r--r--patches.arch/x86-speculation-mds-add-mitigation-mode-vmwerv.patch131
-rw-r--r--patches.arch/x86-speculation-mds-add-mitigations-support-for-mds.patch62
-rw-r--r--patches.arch/x86-speculation-mds-add-smt-warning-message.patch50
-rw-r--r--patches.arch/x86-speculation-mds-add-sysfs-reporting-for-mds.patch120
-rw-r--r--patches.arch/x86-speculation-mds-clear-cpu-buffers-on-exit-to-user.patch192
-rw-r--r--patches.arch/x86-speculation-mds-conditionally-clear-cpu-buffers-on-idle-entry.patch224
-rw-r--r--patches.arch/x86-speculation-mds-print-smt-vulnerable-on-msbds-with-mitigations-off.patch49
-rw-r--r--patches.arch/x86-speculation-move-arch_smt_update-call-to-after-mitigation-decisions.patch45
-rw-r--r--patches.arch/x86-speculation-simplify-the-cpu-bug-detection-logic.patch84
-rw-r--r--patches.arch/x86-speculation-support-enhanced-ibrs-on-future-cpus.patch12
-rw-r--r--patches.drivers/ALSA-core-Don-t-refer-to-snd_cards-array-directly.patch181
-rw-r--r--patches.drivers/ALSA-emu10k1-Drop-superfluous-id-uniquification-beha.patch50
-rw-r--r--patches.drivers/ALSA-seq-Correct-unlock-sequence-at-snd_seq_client_i.patch50
-rw-r--r--patches.drivers/ALSA-seq-Protect-racy-pool-manipulation-from-OSS-seq.patch132
-rw-r--r--patches.drivers/ALSA-seq-Simplify-snd_seq_kernel_client_enqueue-help.patch143
-rw-r--r--patches.drivers/ASoC-Intel-avoid-Oops-if-DMA-setup-fails.patch66
-rw-r--r--patches.drivers/ASoC-cs4270-Set-auto-increment-bit-for-register-writ.patch39
-rw-r--r--patches.drivers/ASoC-fix-valid-stream-condition.patch40
-rw-r--r--patches.drivers/ASoC-hdmi-codec-fix-S-PDIF-DAI.patch175
-rw-r--r--patches.drivers/ASoC-nau8810-fix-the-issue-of-widget-with-prefixed-n.patch39
-rw-r--r--patches.drivers/ASoC-nau8824-fix-the-issue-of-the-widget-with-prefix.patch110
-rw-r--r--patches.drivers/ASoC-samsung-odroid-Fix-clock-configuration-for-4410.patch49
-rw-r--r--patches.drivers/ASoC-soc-pcm-fix-a-codec-fixup-issue-in-TDM-case.patch64
-rw-r--r--patches.drivers/ASoC-tlv320aic32x4-Fix-Common-Pins.patch35
-rw-r--r--patches.drivers/ASoC-wm_adsp-Add-locking-to-wm_adsp2_bus_error.patch69
-rw-r--r--patches.drivers/Bluetooth-Align-minimum-encryption-key-size-for-LE-a.patch58
-rw-r--r--patches.drivers/Bluetooth-hidp-fix-buffer-overflow.patch38
-rw-r--r--patches.drivers/Revert-tty-pty-Fix-race-condition-between-release_on.patch69
-rw-r--r--patches.drivers/clk-rockchip-Fix-video-codec-clocks-on-rk3288.patch85
-rw-r--r--patches.drivers/clk-rockchip-fix-wrong-clock-definitions-for-rk3328.patch92
-rw-r--r--patches.drivers/dmaengine-axi-dmac-Don-t-check-the-number-of-frames-.patch45
-rw-r--r--patches.drivers/dmaengine-tegra210-dma-free-dma-controller-in-remove.patch90
-rw-r--r--patches.drivers/dwc2-gadget-Fix-completed-transfer-size-calculation-.patch39
-rw-r--r--patches.drivers/intel_th-pci-Add-Comet-Lake-support.patch38
-rw-r--r--patches.drivers/iommu-vt-d-don-t-request-page-request-irq-under-dmar_global_lock101
-rw-r--r--patches.drivers/iommu-vt-d-make-kernel-parameter-igfx_off-work-with-viommu42
-rw-r--r--patches.drivers/iommu-vt-d-set-intel_iommu_gfx_mapped-correctly49
-rw-r--r--patches.drivers/media-cx18-update-pos-correctly-in-cx18_read_pos.patch37
-rw-r--r--patches.drivers/media-cx23885-check-allocation-return.patch43
-rw-r--r--patches.drivers/media-davinci-isif-avoid-uninitialized-variable-use.patch78
-rw-r--r--patches.drivers/media-ivtv-update-pos-correctly-in-ivtv_read_pos.patch37
-rw-r--r--patches.drivers/media-ov2659-fix-unbalanced-mutex_lock-unlock.patch39
-rw-r--r--patches.drivers/media-serial_ir-Fix-use-after-free-in-serial_ir_init.patch141
-rw-r--r--patches.drivers/media-tw5864-Fix-possible-NULL-pointer-dereference-i.patch46
-rw-r--r--patches.drivers/media-vivid-use-vfree-instead-of-kfree-for-dev-bitma.patch41
-rw-r--r--patches.drivers/media-wl128x-Fix-an-error-code-in-fm_download_firmwa.patch40
-rw-r--r--patches.drivers/media-wl128x-prevent-two-potential-buffer-overflows.patch64
-rw-r--r--patches.drivers/mtd-docg3-Fix-passing-zero-to-PTR_ERR-warning-in-doc.patch38
-rw-r--r--patches.drivers/mtd-docg3-fix-a-possible-memory-leak-of-mtd-name.patch46
-rw-r--r--patches.drivers/mtd-nand-omap-Fix-comment-in-platform-data-using-wro.patch34
-rw-r--r--patches.drivers/mtd-part-fix-incorrect-format-specifier-for-an-unsig.patch40
-rw-r--r--patches.drivers/net-ibmvnic-Update-MAC-address-settings-after-adapte.patch160
-rw-r--r--patches.drivers/net-ibmvnic-Update-carrier-state-after-link-state-ch.patch66
-rw-r--r--patches.drivers/omapfb-add-missing-of_node_put-after-of_device_is_av.patch64
-rw-r--r--patches.drivers/phy-sun4i-usb-Make-sure-to-disable-PHY0-passby-for-p.patch50
-rw-r--r--patches.drivers/platform-x86-alienware-wmi-printing-the-wrong-error-.patch38
-rw-r--r--patches.drivers/platform-x86-dell-rbtn-Add-missing-include.patch45
-rw-r--r--patches.drivers/platform-x86-intel_pmc_ipc-adding-error-handling.patch49
-rw-r--r--patches.drivers/platform-x86-intel_punit_ipc-Revert-Fix-resource-ior.patch61
-rw-r--r--patches.drivers/platform-x86-sony-laptop-Fix-unintentional-fall-thro.patch57
-rw-r--r--patches.drivers/pwm-Fix-deadlock-warning-when-removing-PWM-device.patch277
-rw-r--r--patches.drivers/pwm-meson-Consider-128-a-valid-pre-divider.patch54
-rw-r--r--patches.drivers/pwm-meson-Don-t-disable-PWM-when-setting-duty-repeat.patch44
-rw-r--r--patches.drivers/pwm-meson-Use-the-spin-lock-only-to-protect-register.patch144
-rw-r--r--patches.drivers/pwm-tiehrpwm-Update-shadow-register-for-disabling-PW.patch48
-rw-r--r--patches.drivers/sc16is7xx-missing-unregister-delete-driver-on-error-.patch56
-rw-r--r--patches.drivers/sc16is7xx-move-label-err_spi-to-correct-section.patch49
-rw-r--r--patches.drivers/sc16is7xx-put-err_spi-and-err_i2c-into-correct-ifdef.patch45
-rw-r--r--patches.drivers/spi-a3700-Clear-DATA_OUT-when-performing-a-read.patch38
-rw-r--r--patches.drivers/ssb-Fix-possible-NULL-pointer-dereference-in-ssb_hos.patch99
-rw-r--r--patches.drivers/usb-storage-Set-virt_boundary_mask-to-avoid-SG-overf.patch92
-rw-r--r--patches.drm/0004-drm-i915-gvt-Fix-incorrect-mask-of-mmio-0x22028-in-g.patch39
-rw-r--r--patches.drm/0005-drm-meson-add-size-and-alignment-requirements-for-du.patch53
-rw-r--r--patches.drm/drm-fb-helper-dpms_legacy-Only-set-on-connectors-in-.patch57
-rw-r--r--patches.drm/drm-i915-Fix-I915_EXEC_RING_MASK.patch42
-rw-r--r--patches.drm/drm-mediatek-fix-possible-object-reference-leak.patch48
-rw-r--r--patches.drm/drm-rockchip-shutdown-drm-subsystem-on-shutdown.patch74
-rw-r--r--patches.fixes/0001-btrfs-qgroup-Move-reserved-data-accounting-from-btrf.patch43
-rw-r--r--patches.fixes/0001-btrfs-reloc-Fix-NULL-pointer-dereference-due-to-expa.patch5
-rw-r--r--patches.fixes/0001-dt-bindings-net-Fix-a-typo-in-the-phy-mode-list-for-.patch37
-rw-r--r--patches.fixes/0001-media-pvrusb2-Prevent-a-buffer-overflow.patch61
-rw-r--r--patches.fixes/0001-mtd-spi-nor-intel-spi-Avoid-crossing-4K-address-boun.patch73
-rw-r--r--patches.fixes/Revert-ide-unexport-DISK_EVENT_MEDIA_CHANGE-for-ide-.patch71
-rw-r--r--patches.fixes/kernel-sysctl.c-add-missing-range-check-in-do_proc_d.patch56
-rw-r--r--patches.fixes/kernel-sysctl.c-fix-out-of-bounds-access-when-settin.patch93
-rw-r--r--patches.fixes/linux-kernel.h-Use-parentheses-around-argument-in-u6.patch72
-rw-r--r--patches.fixes/net-rds-force-to-destroy-connection-if-t_sock-is-NUL.patch143
-rw-r--r--patches.fixes/nvme-multipath-avoid-crash-on-invalid-subsystem-cntl.patch10
-rw-r--r--patches.fixes/proc-kcore-don-t-bounds-check-against-address-0.patch82
-rw-r--r--patches.fixes/proc-revalidate-kernel-thread-inodes-to-root-root.patch51
-rw-r--r--patches.fixes/proc-sysctl-fix-return-error-for-proc_doulongvec_min.patch106
-rw-r--r--patches.fixes/vfio-mdev-Avoid-release-parent-reference-during-erro.patch40
-rw-r--r--patches.fixes/vfio-mdev-Fix-aborting-mdev-child-device-removal-if-.patch77
-rw-r--r--patches.fixes/vfio-pci-use-correct-format-characters.patch83
-rw-r--r--patches.fixes/vfio_pci-Enable-memory-accesses-before-calling-pci_m.patch69
-rw-r--r--patches.fixes/vhost-vsock-fix-reset-orphans-race-with-close-timeou.patch65
-rw-r--r--patches.fixes/virtio-Honour-may_reduce_num-in-vring_create_virtque.patch66
-rw-r--r--patches.fixes/virtio-blk-limit-number-of-hw-queues-by-nr_cpu_ids.patch46
-rw-r--r--patches.fixes/virtio_pci-fix-a-NULL-pointer-reference-in-vp_del_vq.patch70
-rw-r--r--patches.fixes/vsock-virtio-fix-kernel-panic-after-device-hot-unplu.patch103
-rw-r--r--patches.fixes/vsock-virtio-fix-kernel-panic-from-virtio_transport_.patch109
-rw-r--r--patches.fixes/vsock-virtio-reset-connected-sockets-on-device-remov.patch37
-rw-r--r--patches.kabi/Re-export-snd_cards-for-kABI.patch26
-rw-r--r--patches.kabi/snd_seq_kernel_client_enqueue-kabi-compat.patch50
-rw-r--r--patches.suse/0001-btrfs-Factor-out-common-delayed-refs-init-code.patch85
-rw-r--r--patches.suse/0001-btrfs-add-a-helper-to-return-a-head-ref.patch86
-rw-r--r--patches.suse/0001-btrfs-delayed-ref-Introduce-better-documented-delaye.patch187
-rw-r--r--patches.suse/0001-btrfs-track-refs-in-a-rb_tree-instead-of-a-list.patch404
-rw-r--r--patches.suse/0001-drm-ttm-Remove-warning-about-inconsistent-mapping-in.patch33
-rw-r--r--patches.suse/0002-btrfs-Use-init_delayed_ref_common-in-add_delayed_tre.patch75
-rw-r--r--patches.suse/0002-btrfs-extent-tree-Open-code-process_func-in-__btrfs_.patch83
-rw-r--r--patches.suse/0002-btrfs-move-extent_op-cleanup-to-a-helper.patch130
-rw-r--r--patches.suse/0003-btrfs-Use-init_delayed_ref_common-in-add_delayed_dat.patch73
-rw-r--r--patches.suse/0003-btrfs-breakout-empty-head-cleanup-to-a-helper.patch124
-rw-r--r--patches.suse/0003-x86-idle-Control-Indirect-Branch-Speculation-in-idle.patch16
-rw-r--r--patches.suse/0004-btrfs-Open-code-add_delayed_tree_ref.patch128
-rw-r--r--patches.suse/0004-btrfs-move-ref_mod-modification-into-the-if-ref-logi.patch46
-rw-r--r--patches.suse/0005-btrfs-Open-code-add_delayed_data_ref.patch125
-rw-r--r--patches.suse/0005-btrfs-move-all-ref-head-cleanup-to-the-helper-functi.patch211
-rw-r--r--patches.suse/0006-btrfs-Introduce-init_delayed_ref_head.patch102
-rw-r--r--patches.suse/0006-btrfs-remove-delayed_ref_node-from-ref_head.patch780
-rw-r--r--patches.suse/0007-btrfs-Use-init_delayed_ref_head-in-add_delayed_ref_h.patch102
-rw-r--r--patches.suse/0008-btrfs-split-delayed-ref-head-initialization-and-addi.patch159
-rw-r--r--patches.suse/Revert-block-unexport-DISK_EVENT_MEDIA_CHANGE-for.patch145
-rw-r--r--patches.suse/block-check_events-don-t-bother-with-events-if-un.patch99
-rw-r--r--patches.suse/block-disk_events-introduce-event-flags.patch133
-rw-r--r--patches.suse/btrfs-Take-trans-lock-before-access-running-trans-in.patch19
-rw-r--r--patches.suse/btrfs-fix-race-condition-between-delayed-refs-and-blockgroup-removal.patch82
-rw-r--r--patches.suse/lpfc-validate-command-in-lpfc_sli4_scmd_to_wqidx_dis.patch32
-rw-r--r--patches.suse/revert-btrfs-qgroup-move-half-of-the-qgroup-accounting-time-out-of-commit-trans.patch104
-rw-r--r--series.conf138
148 files changed, 12670 insertions, 167 deletions
diff --git a/blacklist.conf b/blacklist.conf
index 6b6dc2c26e..3e6e1e47b4 100644
--- a/blacklist.conf
+++ b/blacklist.conf
@@ -58,6 +58,7 @@ tools/testing/selftests/ # Selftests should be run from upstream
fs/f2fs/ # Not compiled, has some fatal flaws (see bsc#1109665)
security/smack # we don't enable Smack
+drivers/ide # IDE not shipped since SLE12
# Blacklisted CVE entries
# -----------------------
@@ -1109,3 +1110,5 @@ f58213637206e190453e3bd91f98f535566290a3 # regulator: missing regulator_lock() A
f7a621728a6a23bfd2c6ac4d3e42e1303aefde0f # regulator: missing regulator_lock() API in SLE15
8be64b6d87bd47d81753b60ddafe70102ebfd76b # regulator: missing regulator_lock() API in SLE15
+98fdaaca9537b997062f1abc0aa87c61b50ce40a # Duplicate of fc89a38d99d4b1b33ca5b0e2329f5ddea02ecfb5: drm/i915/opregion: fix version check
+a0f52c3d357af218a9c1f7cd906ab70426176a1a # Duplicate of 16eb0f34cdf4cf04cd92762c7a79f98aa51e053f: drm/i915/opregion: rvda is relative from opregion base in opregion 2.1+
diff --git a/patches.arch/intel_idle-add-support-for-Jacobsville.patch b/patches.arch/intel_idle-add-support-for-Jacobsville.patch
index 81b2bc5dba..9e2a8e615b 100644
--- a/patches.arch/intel_idle-add-support-for-Jacobsville.patch
+++ b/patches.arch/intel_idle-add-support-for-Jacobsville.patch
@@ -13,21 +13,16 @@ Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Michal Suchanek <msuchanek@suse.de>
---
- drivers/idle/intel_idle.c | 1 +
+ drivers/idle/intel_idle.c | 1 +
1 file changed, 1 insertion(+)
-diff --git a/drivers/idle/intel_idle.c b/drivers/idle/intel_idle.c
-index 216d7ec88c0c..008eb4d58a86 100644
--- a/drivers/idle/intel_idle.c
+++ b/drivers/idle/intel_idle.c
-@@ -1099,6 +1099,7 @@ static const struct x86_cpu_id intel_idle_ids[] __initconst = {
+@@ -1099,6 +1099,7 @@ static const struct x86_cpu_id intel_idl
ICPU(INTEL_FAM6_ATOM_GOLDMONT, idle_cpu_bxt),
- ICPU(INTEL_FAM6_ATOM_GEMINI_LAKE, idle_cpu_bxt),
- ICPU(INTEL_FAM6_ATOM_DENVERTON, idle_cpu_dnv),
+ ICPU(INTEL_FAM6_ATOM_GOLDMONT_PLUS, idle_cpu_bxt),
+ ICPU(INTEL_FAM6_ATOM_GOLDMONT_X, idle_cpu_dnv),
+ ICPU(INTEL_FAM6_ATOM_TREMONT_X, idle_cpu_dnv),
{}
};
---
-2.20.1
-
diff --git a/patches.arch/kvm-x86-report-stibp-on-get_supported_cpuid.patch b/patches.arch/kvm-x86-report-stibp-on-get_supported_cpuid.patch
new file mode 100644
index 0000000000..bec39883f1
--- /dev/null
+++ b/patches.arch/kvm-x86-report-stibp-on-get_supported_cpuid.patch
@@ -0,0 +1,47 @@
+From: Eduardo Habkost <ehabkost@redhat.com>
+Date: Wed, 5 Dec 2018 17:19:56 -0200
+Subject: kvm: x86: Report STIBP on GET_SUPPORTED_CPUID
+Git-commit: d7b09c827a6cf291f66637a36f46928dd1423184
+Patch-mainline: v5.0-rc1
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+Months ago, we have added code to allow direct access to MSR_IA32_SPEC_CTRL
+to the guest, which makes STIBP available to guests. This was implemented
+by commits d28b387fb74d ("KVM/VMX: Allow direct access to
+MSR_IA32_SPEC_CTRL") and b2ac58f90540 ("KVM/SVM: Allow direct access to
+MSR_IA32_SPEC_CTRL").
+
+However, we never updated GET_SUPPORTED_CPUID to let userspace know that
+STIBP can be enabled in CPUID. Fix that by updating
+kvm_cpuid_8000_0008_ebx_x86_features and kvm_cpuid_7_0_edx_x86_features.
+
+Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
+Reviewed-by: Jim Mattson <jmattson@google.com>
+Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
+Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ arch/x86/kvm/cpuid.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+--- a/arch/x86/kvm/cpuid.c
++++ b/arch/x86/kvm/cpuid.c
+@@ -367,7 +367,8 @@ static inline int __do_cpuid_ent(struct
+
+ /* cpuid 0x80000008.ebx */
+ const u32 kvm_cpuid_8000_0008_ebx_x86_features =
+- F(AMD_IBPB) | F(AMD_IBRS) | F(AMD_SSBD) | F(VIRT_SSBD) | F(AMD_SSB_NO);
++ F(AMD_IBPB) | F(AMD_IBRS) | F(AMD_SSBD) | F(VIRT_SSBD) |
++ F(AMD_SSB_NO) | F(AMD_STIBP);
+
+ /* cpuid 0xC0000001.edx */
+ const u32 kvm_cpuid_C000_0001_edx_x86_features =
+@@ -395,7 +396,7 @@ static inline int __do_cpuid_ent(struct
+ /* cpuid 7.0.edx*/
+ const u32 kvm_cpuid_7_0_edx_x86_features =
+ F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) |
+- F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES);
++ F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES) | F(INTEL_STIBP);
+
+ /* all calls to cpuid_count() should be made on the same cpu */
+ get_cpu();
diff --git a/patches.arch/locking-atomics-asm-generic-move-some-macros-from-linux-bitops-h-to-a-new-linux-bits-h-file.patch b/patches.arch/locking-atomics-asm-generic-move-some-macros-from-linux-bitops-h-to-a-new-linux-bits-h-file.patch
new file mode 100644
index 0000000000..e431bdf60d
--- /dev/null
+++ b/patches.arch/locking-atomics-asm-generic-move-some-macros-from-linux-bitops-h-to-a-new-linux-bits-h-file.patch
@@ -0,0 +1,90 @@
+From: Will Deacon <will.deacon@arm.com>
+Date: Tue, 19 Jun 2018 13:53:08 +0100
+Subject: locking/atomics, asm-generic: Move some macros from <linux/bitops.h>
+ to a new <linux/bits.h> file
+Git-commit: 8bd9cb51daac89337295b6f037b0486911e1b408
+Patch-mainline: v4.19-rc1
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+In preparation for implementing the asm-generic atomic bitops in terms
+of atomic_long_*(), we need to prevent <asm/atomic.h> implementations from
+pulling in <linux/bitops.h>. A common reason for this include is for the
+BITS_PER_BYTE definition, so move this and some other BIT() and masking
+macros into a new header file, <linux/bits.h>.
+
+Signed-off-by: Will Deacon <will.deacon@arm.com>
+Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: linux-arm-kernel@lists.infradead.org
+Cc: yamada.masahiro@socionext.com
+Link: https://lore.kernel.org/lkml/1529412794-17720-4-git-send-email-will.deacon@arm.com
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ include/linux/bitops.h | 21 +--------------------
+ include/linux/bits.h | 26 ++++++++++++++++++++++++++
+ 2 files changed, 27 insertions(+), 20 deletions(-)
+
+--- a/include/linux/bitops.h
++++ b/include/linux/bitops.h
+@@ -1,28 +1,9 @@
+ #ifndef _LINUX_BITOPS_H
+ #define _LINUX_BITOPS_H
+ #include <asm/types.h>
++#include <linux/bits.h>
+
+-#ifdef __KERNEL__
+-#define BIT(nr) (1UL << (nr))
+-#define BIT_ULL(nr) (1ULL << (nr))
+-#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
+-#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
+-#define BIT_ULL_MASK(nr) (1ULL << ((nr) % BITS_PER_LONG_LONG))
+-#define BIT_ULL_WORD(nr) ((nr) / BITS_PER_LONG_LONG)
+-#define BITS_PER_BYTE 8
+ #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
+-#endif
+-
+-/*
+- * Create a contiguous bitmask starting at bit position @l and ending at
+- * position @h. For example
+- * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
+- */
+-#define GENMASK(h, l) \
+- (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+-
+-#define GENMASK_ULL(h, l) \
+- (((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
+
+ extern unsigned int __sw_hweight8(unsigned int w);
+ extern unsigned int __sw_hweight16(unsigned int w);
+--- /dev/null
++++ b/include/linux/bits.h
+@@ -0,0 +1,26 @@
++/* SPDX-License-Identifier: GPL-2.0 */
++#ifndef __LINUX_BITS_H
++#define __LINUX_BITS_H
++#include <asm/bitsperlong.h>
++
++#define BIT(nr) (1UL << (nr))
++#define BIT_ULL(nr) (1ULL << (nr))
++#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
++#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
++#define BIT_ULL_MASK(nr) (1ULL << ((nr) % BITS_PER_LONG_LONG))
++#define BIT_ULL_WORD(nr) ((nr) / BITS_PER_LONG_LONG)
++#define BITS_PER_BYTE 8
++
++/*
++ * Create a contiguous bitmask starting at bit position @l and ending at
++ * position @h. For example
++ * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
++ */
++#define GENMASK(h, l) \
++ (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
++
++#define GENMASK_ULL(h, l) \
++ (((~0ULL) - (1ULL << (l)) + 1) & \
++ (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
++
++#endif /* __LINUX_BITS_H */
diff --git a/patches.arch/powercap-intel_rapl-add-support-for-Jacobsville.patch b/patches.arch/powercap-intel_rapl-add-support-for-Jacobsville.patch
index 5a3982f1bf..5a1ed53480 100644
--- a/patches.arch/powercap-intel_rapl-add-support-for-Jacobsville.patch
+++ b/patches.arch/powercap-intel_rapl-add-support-for-Jacobsville.patch
@@ -13,15 +13,15 @@ Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Michal Suchanek <msuchanek@suse.de>
---
- drivers/powercap/intel_rapl.c | 1 +
+ drivers/powercap/intel_rapl.c | 1 +
1 file changed, 1 insertion(+)
--- a/drivers/powercap/intel_rapl.c
+++ b/drivers/powercap/intel_rapl.c
@@ -1166,6 +1166,7 @@ static const struct x86_cpu_id rapl_ids[
RAPL_CPU(INTEL_FAM6_ATOM_GOLDMONT, rapl_defaults_core),
- RAPL_CPU(INTEL_FAM6_ATOM_GEMINI_LAKE, rapl_defaults_core),
- RAPL_CPU(INTEL_FAM6_ATOM_DENVERTON, rapl_defaults_core),
+ RAPL_CPU(INTEL_FAM6_ATOM_GOLDMONT_PLUS, rapl_defaults_core),
+ RAPL_CPU(INTEL_FAM6_ATOM_GOLDMONT_X, rapl_defaults_core),
+ RAPL_CPU(INTEL_FAM6_ATOM_TREMONT_X, rapl_defaults_core),
RAPL_CPU(INTEL_FAM6_XEON_PHI_KNL, rapl_defaults_hsw_server),
diff --git a/patches.arch/x86-bugs-add-amd-s-variant-of-ssb_no.patch b/patches.arch/x86-bugs-add-amd-s-variant-of-ssb_no.patch
index 2114216f45..ea0130ee81 100644
--- a/patches.arch/x86-bugs-add-amd-s-variant-of-ssb_no.patch
+++ b/patches.arch/x86-bugs-add-amd-s-variant-of-ssb_no.patch
@@ -44,7 +44,7 @@ Acked-by: Borislav Petkov <bp@suse.de>
#define X86_FEATURE_DTHERM (14*32+ 0) /* Digital Thermal Sensor */
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
-@@ -948,7 +948,8 @@ static void __init cpu_set_bug_bits(stru
+@@ -946,7 +946,8 @@ static void __init cpu_set_bug_bits(stru
rdmsrl(MSR_IA32_ARCH_CAPABILITIES, ia32_cap);
if (!x86_match_cpu(cpu_no_spec_store_bypass) &&
@@ -53,7 +53,7 @@ Acked-by: Borislav Petkov <bp@suse.de>
+ !cpu_has(c, X86_FEATURE_AMD_SSB_NO))
setup_force_cpu_bug(X86_BUG_SPEC_STORE_BYPASS);
- if (x86_match_cpu(cpu_no_speculation))
+ if (x86_match_cpu(cpu_no_meltdown))
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -367,7 +367,7 @@ static inline int __do_cpuid_ent(struct
diff --git a/patches.arch/x86-cpu-Add-Atom-Tremont-Jacobsville.patch b/patches.arch/x86-cpu-Add-Atom-Tremont-Jacobsville.patch
index 5788f25bbc..243d8cc12c 100644
--- a/patches.arch/x86-cpu-Add-Atom-Tremont-Jacobsville.patch
+++ b/patches.arch/x86-cpu-Add-Atom-Tremont-Jacobsville.patch
@@ -31,7 +31,7 @@ Cc: x86-ml <x86@kernel.org>
Link: https://lkml.kernel.org/r/20190125195902.17109-4-tony.luck@intel.com
Acked-by: Michal Suchanek <msuchanek@suse.de>
---
- arch/x86/include/asm/intel-family.h | 3 ++-
+ arch/x86/include/asm/intel-family.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--- a/arch/x86/include/asm/intel-family.h
@@ -45,10 +45,10 @@ Acked-by: Michal Suchanek <msuchanek@suse.de>
*
* Things ending in "2" are usually because we have no better
* name for them. There's no processor called "SILVERMONT2".
-@@ -63,6 +63,7 @@
- #define INTEL_FAM6_ATOM_GOLDMONT 0x5C
- #define INTEL_FAM6_ATOM_DENVERTON 0x5F /* Goldmont Microserver */
- #define INTEL_FAM6_ATOM_GEMINI_LAKE 0x7A
+@@ -67,6 +67,7 @@
+ #define INTEL_FAM6_ATOM_GOLDMONT 0x5C /* Apollo Lake */
+ #define INTEL_FAM6_ATOM_GOLDMONT_X 0x5F /* Denverton */
+ #define INTEL_FAM6_ATOM_GOLDMONT_PLUS 0x7A /* Gemini Lake */
+#define INTEL_FAM6_ATOM_TREMONT_X 0x86 /* Jacobswille */
/* Xeon Phi */
diff --git a/patches.arch/x86-cpu-sanitize-fam6_atom-naming.patch b/patches.arch/x86-cpu-sanitize-fam6_atom-naming.patch
new file mode 100644
index 0000000000..5cdecdb444
--- /dev/null
+++ b/patches.arch/x86-cpu-sanitize-fam6_atom-naming.patch
@@ -0,0 +1,602 @@
+From: Peter Zijlstra <peterz@infradead.org>
+Date: Tue, 7 Aug 2018 10:17:27 -0700
+Subject: x86/cpu: Sanitize FAM6_ATOM naming
+Git-commit: f2c4db1bd80720cd8cb2a5aa220d9bc9f374f04e
+Patch-mainline: v5.1-rc1
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+commit f2c4db1bd80720cd8cb2a5aa220d9bc9f374f04e upstream
+
+Going primarily by:
+
+ https://en.wikipedia.org/wiki/List_of_Intel_Atom_microprocessors
+
+with additional information gleaned from other related pages; notably:
+
+ - Bonnell shrink was called Saltwell
+ - Moorefield is the Merriefield refresh which makes it Airmont
+
+The general naming scheme is: FAM6_ATOM_UARCH_SOCTYPE
+
+ for i in `git grep -l FAM6_ATOM` ; do
+ sed -i -e 's/ATOM_PINEVIEW/ATOM_BONNELL/g' \
+ -e 's/ATOM_LINCROFT/ATOM_BONNELL_MID/' \
+ -e 's/ATOM_PENWELL/ATOM_SALTWELL_MID/g' \
+ -e 's/ATOM_CLOVERVIEW/ATOM_SALTWELL_TABLET/g' \
+ -e 's/ATOM_CEDARVIEW/ATOM_SALTWELL/g' \
+ -e 's/ATOM_SILVERMONT1/ATOM_SILVERMONT/g' \
+ -e 's/ATOM_SILVERMONT2/ATOM_SILVERMONT_X/g' \
+ -e 's/ATOM_MERRIFIELD/ATOM_SILVERMONT_MID/g' \
+ -e 's/ATOM_MOOREFIELD/ATOM_AIRMONT_MID/g' \
+ -e 's/ATOM_DENVERTON/ATOM_GOLDMONT_X/g' \
+ -e 's/ATOM_GEMINI_LAKE/ATOM_GOLDMONT_PLUS/g' ${i}
+ done
+
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
+Cc: Jiri Olsa <jolsa@redhat.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Stephane Eranian <eranian@google.com>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: Vince Weaver <vincent.weaver@maine.edu>
+Cc: dave.hansen@linux.intel.com
+Cc: len.brown@intel.com
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+[ 4.14.y speck backport, commit id there: f0fae1c931dd3a49cd42855836fc3f075960d4be ]
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ arch/x86/events/intel/core.c | 18 +++----
+ arch/x86/events/intel/cstate.c | 4 -
+ arch/x86/events/msr.c | 4 -
+ arch/x86/include/asm/intel-family.h | 30 ++++++-----
+ arch/x86/kernel/cpu/common.c | 28 +++++-----
+ arch/x86/kernel/tsc.c | 2
+ arch/x86/platform/atom/punit_atom_debug.c | 4 -
+ arch/x86/platform/intel-mid/device_libs/platform_bt.c | 2
+ drivers/acpi/acpi_lpss.c | 2
+ drivers/acpi/x86/utils.c | 2
+ drivers/cpufreq/intel_pstate.c | 4 -
+ drivers/edac/pnd2_edac.c | 2
+ drivers/idle/intel_idle.c | 18 +++----
+ drivers/mmc/host/sdhci-acpi.c | 2
+ drivers/pci/pci-mid.c | 4 -
+ drivers/platform/x86/intel_int0002_vgpio.c | 2
+ drivers/platform/x86/intel_mid_powerbtn.c | 4 -
+ drivers/powercap/intel_rapl.c | 10 +--
+ drivers/thermal/intel_soc_dts_thermal.c | 2
+ tools/power/x86/turbostat/turbostat.c | 46 +++++++++---------
+ 20 files changed, 98 insertions(+), 92 deletions(-)
+
+--- a/arch/x86/events/intel/core.c
++++ b/arch/x86/events/intel/core.c
+@@ -3724,11 +3724,11 @@ __init int intel_pmu_init(void)
+ pr_cont("Nehalem events, ");
+ break;
+
+- case INTEL_FAM6_ATOM_PINEVIEW:
+- case INTEL_FAM6_ATOM_LINCROFT:
+- case INTEL_FAM6_ATOM_PENWELL:
+- case INTEL_FAM6_ATOM_CLOVERVIEW:
+- case INTEL_FAM6_ATOM_CEDARVIEW:
++ case INTEL_FAM6_ATOM_BONNELL:
++ case INTEL_FAM6_ATOM_BONNELL_MID:
++ case INTEL_FAM6_ATOM_SALTWELL:
++ case INTEL_FAM6_ATOM_SALTWELL_MID:
++ case INTEL_FAM6_ATOM_SALTWELL_TABLET:
+ memcpy(hw_cache_event_ids, atom_hw_cache_event_ids,
+ sizeof(hw_cache_event_ids));
+
+@@ -3740,9 +3740,11 @@ __init int intel_pmu_init(void)
+ pr_cont("Atom events, ");
+ break;
+
+- case INTEL_FAM6_ATOM_SILVERMONT1:
+- case INTEL_FAM6_ATOM_SILVERMONT2:
++ case INTEL_FAM6_ATOM_SILVERMONT:
++ case INTEL_FAM6_ATOM_SILVERMONT_X:
++ case INTEL_FAM6_ATOM_SILVERMONT_MID:
+ case INTEL_FAM6_ATOM_AIRMONT:
++ case INTEL_FAM6_ATOM_AIRMONT_MID:
+ memcpy(hw_cache_event_ids, slm_hw_cache_event_ids,
+ sizeof(hw_cache_event_ids));
+ memcpy(hw_cache_extra_regs, slm_hw_cache_extra_regs,
+@@ -3759,7 +3761,7 @@ __init int intel_pmu_init(void)
+ break;
+
+ case INTEL_FAM6_ATOM_GOLDMONT:
+- case INTEL_FAM6_ATOM_DENVERTON:
++ case INTEL_FAM6_ATOM_GOLDMONT_X:
+ memcpy(hw_cache_event_ids, glm_hw_cache_event_ids,
+ sizeof(hw_cache_event_ids));
+ memcpy(hw_cache_extra_regs, glm_hw_cache_extra_regs,
+--- a/arch/x86/events/intel/cstate.c
++++ b/arch/x86/events/intel/cstate.c
+@@ -531,8 +531,8 @@ static const struct x86_cpu_id intel_cst
+
+ X86_CSTATES_MODEL(INTEL_FAM6_HASWELL_ULT, hswult_cstates),
+
+- X86_CSTATES_MODEL(INTEL_FAM6_ATOM_SILVERMONT1, slm_cstates),
+- X86_CSTATES_MODEL(INTEL_FAM6_ATOM_SILVERMONT2, slm_cstates),
++ X86_CSTATES_MODEL(INTEL_FAM6_ATOM_SILVERMONT, slm_cstates),
++ X86_CSTATES_MODEL(INTEL_FAM6_ATOM_SILVERMONT_X, slm_cstates),
+ X86_CSTATES_MODEL(INTEL_FAM6_ATOM_AIRMONT, slm_cstates),
+
+ X86_CSTATES_MODEL(INTEL_FAM6_BROADWELL_CORE, snb_cstates),
+--- a/arch/x86/events/msr.c
++++ b/arch/x86/events/msr.c
+@@ -61,8 +61,8 @@ static bool test_intel(int idx)
+ case INTEL_FAM6_BROADWELL_GT3E:
+ case INTEL_FAM6_BROADWELL_X:
+
+- case INTEL_FAM6_ATOM_SILVERMONT1:
+- case INTEL_FAM6_ATOM_SILVERMONT2:
++ case INTEL_FAM6_ATOM_SILVERMONT:
++ case INTEL_FAM6_ATOM_SILVERMONT_X:
+ case INTEL_FAM6_ATOM_AIRMONT:
+ if (idx == PERF_MSR_SMI)
+ return true;
+--- a/arch/x86/include/asm/intel-family.h
++++ b/arch/x86/include/asm/intel-family.h
+@@ -50,19 +50,23 @@
+
+ /* "Small Core" Processors (Atom) */
+
+-#define INTEL_FAM6_ATOM_PINEVIEW 0x1C
+-#define INTEL_FAM6_ATOM_LINCROFT 0x26
+-#define INTEL_FAM6_ATOM_PENWELL 0x27
+-#define INTEL_FAM6_ATOM_CLOVERVIEW 0x35
+-#define INTEL_FAM6_ATOM_CEDARVIEW 0x36
+-#define INTEL_FAM6_ATOM_SILVERMONT1 0x37 /* BayTrail/BYT / Valleyview */
+-#define INTEL_FAM6_ATOM_SILVERMONT2 0x4D /* Avaton/Rangely */
+-#define INTEL_FAM6_ATOM_AIRMONT 0x4C /* CherryTrail / Braswell */
+-#define INTEL_FAM6_ATOM_MERRIFIELD 0x4A /* Tangier */
+-#define INTEL_FAM6_ATOM_MOOREFIELD 0x5A /* Anniedale */
+-#define INTEL_FAM6_ATOM_GOLDMONT 0x5C
+-#define INTEL_FAM6_ATOM_DENVERTON 0x5F /* Goldmont Microserver */
+-#define INTEL_FAM6_ATOM_GEMINI_LAKE 0x7A
++#define INTEL_FAM6_ATOM_BONNELL 0x1C /* Diamondville, Pineview */
++#define INTEL_FAM6_ATOM_BONNELL_MID 0x26 /* Silverthorne, Lincroft */
++
++#define INTEL_FAM6_ATOM_SALTWELL 0x36 /* Cedarview */
++#define INTEL_FAM6_ATOM_SALTWELL_MID 0x27 /* Penwell */
++#define INTEL_FAM6_ATOM_SALTWELL_TABLET 0x35 /* Cloverview */
++
++#define INTEL_FAM6_ATOM_SILVERMONT 0x37 /* Bay Trail, Valleyview */
++#define INTEL_FAM6_ATOM_SILVERMONT_X 0x4D /* Avaton, Rangely */
++#define INTEL_FAM6_ATOM_SILVERMONT_MID 0x4A /* Merriefield */
++
++#define INTEL_FAM6_ATOM_AIRMONT 0x4C /* Cherry Trail, Braswell */
++#define INTEL_FAM6_ATOM_AIRMONT_MID 0x5A /* Moorefield */
++
++#define INTEL_FAM6_ATOM_GOLDMONT 0x5C /* Apollo Lake */
++#define INTEL_FAM6_ATOM_GOLDMONT_X 0x5F /* Denverton */
++#define INTEL_FAM6_ATOM_GOLDMONT_PLUS 0x7A /* Gemini Lake */
+
+ /* Xeon Phi */
+
+--- a/arch/x86/kernel/cpu/common.c
++++ b/arch/x86/kernel/cpu/common.c
+@@ -899,11 +899,11 @@ static void identify_cpu_without_cpuid(s
+ }
+
+ static const __initconst struct x86_cpu_id cpu_no_speculation[] = {
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_CEDARVIEW, X86_FEATURE_ANY },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_CLOVERVIEW, X86_FEATURE_ANY },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_LINCROFT, X86_FEATURE_ANY },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_PENWELL, X86_FEATURE_ANY },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_PINEVIEW, X86_FEATURE_ANY },
++ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SALTWELL, X86_FEATURE_ANY },
++ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SALTWELL_TABLET, X86_FEATURE_ANY },
++ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_BONNELL_MID, X86_FEATURE_ANY },
++ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SALTWELL_MID, X86_FEATURE_ANY },
++ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_BONNELL, X86_FEATURE_ANY },
+ { X86_VENDOR_CENTAUR, 5 },
+ { X86_VENDOR_INTEL, 5 },
+ { X86_VENDOR_NSC, 5 },
+@@ -918,10 +918,10 @@ static const __initconst struct x86_cpu_
+
+ /* Only list CPUs which speculate but are non susceptible to SSB */
+ static const __initconst struct x86_cpu_id cpu_no_spec_store_bypass[] = {
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT1 },
++ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT },
+ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_AIRMONT },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT2 },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_MERRIFIELD },
++ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT_X },
++ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT_MID },
+ { X86_VENDOR_INTEL, 6, INTEL_FAM6_CORE_YONAH },
+ { X86_VENDOR_INTEL, 6, INTEL_FAM6_XEON_PHI_KNL },
+ { X86_VENDOR_INTEL, 6, INTEL_FAM6_XEON_PHI_KNM },
+@@ -934,14 +934,14 @@ static const __initconst struct x86_cpu_
+
+ static const __initconst struct x86_cpu_id cpu_no_l1tf[] = {
+ /* in addition to cpu_no_speculation */
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT1 },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT2 },
++ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT },
++ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT_X },
+ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_AIRMONT },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_MERRIFIELD },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_MOOREFIELD },
++ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT_MID },
++ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_AIRMONT_MID },
+ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_GOLDMONT },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_DENVERTON },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_GEMINI_LAKE },
++ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_GOLDMONT_X },
++ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_GOLDMONT_PLUS },
+ { X86_VENDOR_INTEL, 6, INTEL_FAM6_XEON_PHI_KNL },
+ { X86_VENDOR_INTEL, 6, INTEL_FAM6_XEON_PHI_KNM },
+ {}
+--- a/arch/x86/kernel/tsc.c
++++ b/arch/x86/kernel/tsc.c
+@@ -620,7 +620,7 @@ unsigned long native_calibrate_tsc(void)
+ case INTEL_FAM6_KABYLAKE_DESKTOP:
+ crystal_khz = 24000; /* 24.0 MHz */
+ break;
+- case INTEL_FAM6_ATOM_DENVERTON:
++ case INTEL_FAM6_ATOM_GOLDMONT_X:
+ crystal_khz = 25000; /* 25.0 MHz */
+ break;
+ case INTEL_FAM6_ATOM_GOLDMONT:
+--- a/arch/x86/platform/atom/punit_atom_debug.c
++++ b/arch/x86/platform/atom/punit_atom_debug.c
+@@ -154,8 +154,8 @@ static void punit_dbgfs_unregister(void)
+ (kernel_ulong_t)&drv_data }
+
+ static const struct x86_cpu_id intel_punit_cpu_ids[] = {
+- ICPU(INTEL_FAM6_ATOM_SILVERMONT1, punit_device_byt),
+- ICPU(INTEL_FAM6_ATOM_MERRIFIELD, punit_device_tng),
++ ICPU(INTEL_FAM6_ATOM_SILVERMONT, punit_device_byt),
++ ICPU(INTEL_FAM6_ATOM_SILVERMONT_MID, punit_device_tng),
+ ICPU(INTEL_FAM6_ATOM_AIRMONT, punit_device_cht),
+ {}
+ };
+--- a/arch/x86/platform/intel-mid/device_libs/platform_bt.c
++++ b/arch/x86/platform/intel-mid/device_libs/platform_bt.c
+@@ -68,7 +68,7 @@ static struct bt_sfi_data tng_bt_sfi_dat
+ { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, (kernel_ulong_t)&ddata }
+
+ static const struct x86_cpu_id bt_sfi_cpu_ids[] = {
+- ICPU(INTEL_FAM6_ATOM_MERRIFIELD, tng_bt_sfi_data),
++ ICPU(INTEL_FAM6_ATOM_SILVERMONT_MID, tng_bt_sfi_data),
+ {}
+ };
+
+--- a/drivers/acpi/acpi_lpss.c
++++ b/drivers/acpi/acpi_lpss.c
+@@ -291,7 +291,7 @@ static const struct lpss_device_desc bsw
+ #define ICPU(model) { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, }
+
+ static const struct x86_cpu_id lpss_cpu_ids[] = {
+- ICPU(INTEL_FAM6_ATOM_SILVERMONT1), /* Valleyview, Bay Trail */
++ ICPU(INTEL_FAM6_ATOM_SILVERMONT), /* Valleyview, Bay Trail */
+ ICPU(INTEL_FAM6_ATOM_AIRMONT), /* Braswell, Cherry Trail */
+ {}
+ };
+--- a/drivers/acpi/x86/utils.c
++++ b/drivers/acpi/x86/utils.c
+@@ -54,7 +54,7 @@ static const struct always_present_id al
+ * Bay / Cherry Trail PWM directly poked by GPU driver in win10,
+ * but Linux uses a separate PWM driver, harmless if not used.
+ */
+- ENTRY("80860F09", "1", ICPU(INTEL_FAM6_ATOM_SILVERMONT1), {}),
++ ENTRY("80860F09", "1", ICPU(INTEL_FAM6_ATOM_SILVERMONT), {}),
+ ENTRY("80862288", "1", ICPU(INTEL_FAM6_ATOM_AIRMONT), {}),
+ /*
+ * The INT0002 device is necessary to clear wakeup interrupt sources
+--- a/drivers/cpufreq/intel_pstate.c
++++ b/drivers/cpufreq/intel_pstate.c
+@@ -2019,7 +2019,7 @@ static const struct pstate_funcs knl_fun
+ static const struct x86_cpu_id intel_pstate_cpu_ids[] = {
+ ICPU(INTEL_FAM6_SANDYBRIDGE, core_funcs),
+ ICPU(INTEL_FAM6_SANDYBRIDGE_X, core_funcs),
+- ICPU(INTEL_FAM6_ATOM_SILVERMONT1, silvermont_funcs),
++ ICPU(INTEL_FAM6_ATOM_SILVERMONT, silvermont_funcs),
+ ICPU(INTEL_FAM6_IVYBRIDGE, core_funcs),
+ ICPU(INTEL_FAM6_HASWELL_CORE, core_funcs),
+ ICPU(INTEL_FAM6_BROADWELL_CORE, core_funcs),
+@@ -2036,7 +2036,7 @@ static const struct x86_cpu_id intel_pst
+ ICPU(INTEL_FAM6_XEON_PHI_KNL, knl_funcs),
+ ICPU(INTEL_FAM6_XEON_PHI_KNM, knl_funcs),
+ ICPU(INTEL_FAM6_ATOM_GOLDMONT, core_funcs),
+- ICPU(INTEL_FAM6_ATOM_GEMINI_LAKE, core_funcs),
++ ICPU(INTEL_FAM6_ATOM_GOLDMONT_PLUS, core_funcs),
+ ICPU(INTEL_FAM6_SKYLAKE_X, core_funcs),
+ {}
+ };
+--- a/drivers/edac/pnd2_edac.c
++++ b/drivers/edac/pnd2_edac.c
+@@ -1541,7 +1541,7 @@ static struct dunit_ops dnv_ops = {
+
+ static const struct x86_cpu_id pnd2_cpuids[] = {
+ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_GOLDMONT, 0, (kernel_ulong_t)&apl_ops },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_DENVERTON, 0, (kernel_ulong_t)&dnv_ops },
++ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_GOLDMONT_X, 0, (kernel_ulong_t)&dnv_ops },
+ { }
+ };
+ MODULE_DEVICE_TABLE(x86cpu, pnd2_cpuids);
+--- a/drivers/idle/intel_idle.c
++++ b/drivers/idle/intel_idle.c
+@@ -1069,14 +1069,14 @@ static const struct x86_cpu_id intel_idl
+ ICPU(INTEL_FAM6_WESTMERE, idle_cpu_nehalem),
+ ICPU(INTEL_FAM6_WESTMERE_EP, idle_cpu_nehalem),
+ ICPU(INTEL_FAM6_NEHALEM_EX, idle_cpu_nehalem),
+- ICPU(INTEL_FAM6_ATOM_PINEVIEW, idle_cpu_atom),
+- ICPU(INTEL_FAM6_ATOM_LINCROFT, idle_cpu_lincroft),
++ ICPU(INTEL_FAM6_ATOM_BONNELL, idle_cpu_atom),
++ ICPU(INTEL_FAM6_ATOM_BONNELL_MID, idle_cpu_lincroft),
+ ICPU(INTEL_FAM6_WESTMERE_EX, idle_cpu_nehalem),
+ ICPU(INTEL_FAM6_SANDYBRIDGE, idle_cpu_snb),
+ ICPU(INTEL_FAM6_SANDYBRIDGE_X, idle_cpu_snb),
+- ICPU(INTEL_FAM6_ATOM_CEDARVIEW, idle_cpu_atom),
+- ICPU(INTEL_FAM6_ATOM_SILVERMONT1, idle_cpu_byt),
+- ICPU(INTEL_FAM6_ATOM_MERRIFIELD, idle_cpu_tangier),
++ ICPU(INTEL_FAM6_ATOM_SALTWELL, idle_cpu_atom),
++ ICPU(INTEL_FAM6_ATOM_SILVERMONT, idle_cpu_byt),
++ ICPU(INTEL_FAM6_ATOM_SILVERMONT_MID, idle_cpu_tangier),
+ ICPU(INTEL_FAM6_ATOM_AIRMONT, idle_cpu_cht),
+ ICPU(INTEL_FAM6_IVYBRIDGE, idle_cpu_ivb),
+ ICPU(INTEL_FAM6_IVYBRIDGE_X, idle_cpu_ivt),
+@@ -1084,7 +1084,7 @@ static const struct x86_cpu_id intel_idl
+ ICPU(INTEL_FAM6_HASWELL_X, idle_cpu_hsw),
+ ICPU(INTEL_FAM6_HASWELL_ULT, idle_cpu_hsw),
+ ICPU(INTEL_FAM6_HASWELL_GT3E, idle_cpu_hsw),
+- ICPU(INTEL_FAM6_ATOM_SILVERMONT2, idle_cpu_avn),
++ ICPU(INTEL_FAM6_ATOM_SILVERMONT_X, idle_cpu_avn),
+ ICPU(INTEL_FAM6_BROADWELL_CORE, idle_cpu_bdw),
+ ICPU(INTEL_FAM6_BROADWELL_GT3E, idle_cpu_bdw),
+ ICPU(INTEL_FAM6_BROADWELL_X, idle_cpu_bdw),
+@@ -1097,8 +1097,8 @@ static const struct x86_cpu_id intel_idl
+ ICPU(INTEL_FAM6_XEON_PHI_KNL, idle_cpu_knl),
+ ICPU(INTEL_FAM6_XEON_PHI_KNM, idle_cpu_knl),
+ ICPU(INTEL_FAM6_ATOM_GOLDMONT, idle_cpu_bxt),
+- ICPU(INTEL_FAM6_ATOM_GEMINI_LAKE, idle_cpu_bxt),
+- ICPU(INTEL_FAM6_ATOM_DENVERTON, idle_cpu_dnv),
++ ICPU(INTEL_FAM6_ATOM_GOLDMONT_PLUS, idle_cpu_bxt),
++ ICPU(INTEL_FAM6_ATOM_GOLDMONT_X, idle_cpu_dnv),
+ {}
+ };
+
+@@ -1310,7 +1310,7 @@ static void intel_idle_state_table_updat
+ ivt_idle_state_table_update();
+ break;
+ case INTEL_FAM6_ATOM_GOLDMONT:
+- case INTEL_FAM6_ATOM_GEMINI_LAKE:
++ case INTEL_FAM6_ATOM_GOLDMONT_PLUS:
+ bxt_idle_state_table_update();
+ break;
+ case INTEL_FAM6_SKYLAKE_DESKTOP:
+--- a/drivers/mmc/host/sdhci-acpi.c
++++ b/drivers/mmc/host/sdhci-acpi.c
+@@ -128,7 +128,7 @@ static const struct sdhci_acpi_chip sdhc
+ static bool sdhci_acpi_byt(void)
+ {
+ static const struct x86_cpu_id byt[] = {
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT1 },
++ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT },
+ {}
+ };
+
+--- a/drivers/pci/pci-mid.c
++++ b/drivers/pci/pci-mid.c
+@@ -71,8 +71,8 @@ static const struct pci_platform_pm_ops
+ * arch/x86/platform/intel-mid/pwr.c.
+ */
+ static const struct x86_cpu_id lpss_cpu_ids[] = {
+- ICPU(INTEL_FAM6_ATOM_PENWELL),
+- ICPU(INTEL_FAM6_ATOM_MERRIFIELD),
++ ICPU(INTEL_FAM6_ATOM_SALTWELL_MID),
++ ICPU(INTEL_FAM6_ATOM_SILVERMONT_MID),
+ {}
+ };
+
+--- a/drivers/platform/x86/intel_int0002_vgpio.c
++++ b/drivers/platform/x86/intel_int0002_vgpio.c
+@@ -60,7 +60,7 @@ static const struct x86_cpu_id int0002_c
+ /*
+ * Limit ourselves to Cherry Trail for now, until testing shows we
+ * need to handle the INT0002 device on Baytrail too.
+- * ICPU(INTEL_FAM6_ATOM_SILVERMONT1), * Valleyview, Bay Trail *
++ * ICPU(INTEL_FAM6_ATOM_SILVERMONT), * Valleyview, Bay Trail *
+ */
+ ICPU(INTEL_FAM6_ATOM_AIRMONT), /* Braswell, Cherry Trail */
+ {}
+--- a/drivers/platform/x86/intel_mid_powerbtn.c
++++ b/drivers/platform/x86/intel_mid_powerbtn.c
+@@ -125,8 +125,8 @@ static struct mid_pb_ddata mrfld_ddata =
+ { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, (kernel_ulong_t)&ddata }
+
+ static const struct x86_cpu_id mid_pb_cpu_ids[] = {
+- ICPU(INTEL_FAM6_ATOM_PENWELL, mfld_ddata),
+- ICPU(INTEL_FAM6_ATOM_MERRIFIELD, mrfld_ddata),
++ ICPU(INTEL_FAM6_ATOM_SALTWELL_MID, mfld_ddata),
++ ICPU(INTEL_FAM6_ATOM_SILVERMONT_MID, mrfld_ddata),
+ {}
+ };
+
+--- a/drivers/powercap/intel_rapl.c
++++ b/drivers/powercap/intel_rapl.c
+@@ -1159,13 +1159,13 @@ static const struct x86_cpu_id rapl_ids[
+ RAPL_CPU(INTEL_FAM6_KABYLAKE_MOBILE, rapl_defaults_core),
+ RAPL_CPU(INTEL_FAM6_KABYLAKE_DESKTOP, rapl_defaults_core),
+
+- RAPL_CPU(INTEL_FAM6_ATOM_SILVERMONT1, rapl_defaults_byt),
++ RAPL_CPU(INTEL_FAM6_ATOM_SILVERMONT, rapl_defaults_byt),
+ RAPL_CPU(INTEL_FAM6_ATOM_AIRMONT, rapl_defaults_cht),
+- RAPL_CPU(INTEL_FAM6_ATOM_MERRIFIELD, rapl_defaults_tng),
+- RAPL_CPU(INTEL_FAM6_ATOM_MOOREFIELD, rapl_defaults_ann),
++ RAPL_CPU(INTEL_FAM6_ATOM_SILVERMONT_MID,rapl_defaults_tng),
++ RAPL_CPU(INTEL_FAM6_ATOM_AIRMONT_MID, rapl_defaults_ann),
+ RAPL_CPU(INTEL_FAM6_ATOM_GOLDMONT, rapl_defaults_core),
+- RAPL_CPU(INTEL_FAM6_ATOM_GEMINI_LAKE, rapl_defaults_core),
+- RAPL_CPU(INTEL_FAM6_ATOM_DENVERTON, rapl_defaults_core),
++ RAPL_CPU(INTEL_FAM6_ATOM_GOLDMONT_PLUS, rapl_defaults_core),
++ RAPL_CPU(INTEL_FAM6_ATOM_GOLDMONT_X, rapl_defaults_core),
+
+ RAPL_CPU(INTEL_FAM6_XEON_PHI_KNL, rapl_defaults_hsw_server),
+ RAPL_CPU(INTEL_FAM6_XEON_PHI_KNM, rapl_defaults_hsw_server),
+--- a/drivers/thermal/intel_soc_dts_thermal.c
++++ b/drivers/thermal/intel_soc_dts_thermal.c
+@@ -43,7 +43,7 @@ static irqreturn_t soc_irq_thread_fn(int
+ }
+
+ static const struct x86_cpu_id soc_thermal_ids[] = {
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT1, 0,
++ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT, 0,
+ BYT_SOC_DTS_APIC_IRQ},
+ {}
+ };
+--- a/tools/power/x86/turbostat/turbostat.c
++++ b/tools/power/x86/turbostat/turbostat.c
+@@ -1839,7 +1839,7 @@ int has_turbo_ratio_group_limits(int fam
+ switch (model) {
+ case INTEL_FAM6_ATOM_GOLDMONT:
+ case INTEL_FAM6_SKYLAKE_X:
+- case INTEL_FAM6_ATOM_DENVERTON:
++ case INTEL_FAM6_ATOM_GOLDMONT_X:
+ return 1;
+ }
+ return 0;
+@@ -2701,9 +2701,9 @@ int probe_nhm_msrs(unsigned int family,
+ pkg_cstate_limits = skx_pkg_cstate_limits;
+ has_misc_feature_control = 1;
+ break;
+- case INTEL_FAM6_ATOM_SILVERMONT1: /* BYT */
++ case INTEL_FAM6_ATOM_SILVERMONT: /* BYT */
+ no_MSR_MISC_PWR_MGMT = 1;
+- case INTEL_FAM6_ATOM_SILVERMONT2: /* AVN */
++ case INTEL_FAM6_ATOM_SILVERMONT_X: /* AVN */
+ pkg_cstate_limits = slv_pkg_cstate_limits;
+ break;
+ case INTEL_FAM6_ATOM_AIRMONT: /* AMT */
+@@ -2715,8 +2715,8 @@ int probe_nhm_msrs(unsigned int family,
+ pkg_cstate_limits = phi_pkg_cstate_limits;
+ break;
+ case INTEL_FAM6_ATOM_GOLDMONT: /* BXT */
+- case INTEL_FAM6_ATOM_GEMINI_LAKE:
+- case INTEL_FAM6_ATOM_DENVERTON: /* DNV */
++ case INTEL_FAM6_ATOM_GOLDMONT_PLUS:
++ case INTEL_FAM6_ATOM_GOLDMONT_X: /* DNV */
+ pkg_cstate_limits = bxt_pkg_cstate_limits;
+ break;
+ default:
+@@ -2745,9 +2745,9 @@ int has_slv_msrs(unsigned int family, un
+ return 0;
+
+ switch (model) {
+- case INTEL_FAM6_ATOM_SILVERMONT1:
+- case INTEL_FAM6_ATOM_MERRIFIELD:
+- case INTEL_FAM6_ATOM_MOOREFIELD:
++ case INTEL_FAM6_ATOM_SILVERMONT:
++ case INTEL_FAM6_ATOM_SILVERMONT_MID:
++ case INTEL_FAM6_ATOM_AIRMONT_MID:
+ return 1;
+ }
+ return 0;
+@@ -2759,7 +2759,7 @@ int is_dnv(unsigned int family, unsigned
+ return 0;
+
+ switch (model) {
+- case INTEL_FAM6_ATOM_DENVERTON:
++ case INTEL_FAM6_ATOM_GOLDMONT_X:
+ return 1;
+ }
+ return 0;
+@@ -3275,8 +3275,8 @@ double get_tdp(unsigned int model)
+ return ((msr >> 0) & RAPL_POWER_GRANULARITY) * rapl_power_units;
+
+ switch (model) {
+- case INTEL_FAM6_ATOM_SILVERMONT1:
+- case INTEL_FAM6_ATOM_SILVERMONT2:
++ case INTEL_FAM6_ATOM_SILVERMONT:
++ case INTEL_FAM6_ATOM_SILVERMONT_X:
+ return 30.0;
+ default:
+ return 135.0;
+@@ -3342,7 +3342,7 @@ void rapl_probe(unsigned int family, uns
+ }
+ break;
+ case INTEL_FAM6_ATOM_GOLDMONT: /* BXT */
+- case INTEL_FAM6_ATOM_GEMINI_LAKE:
++ case INTEL_FAM6_ATOM_GOLDMONT_PLUS:
+ do_rapl = RAPL_PKG | RAPL_PKG_POWER_INFO;
+ if (rapl_joules)
+ BIC_PRESENT(BIC_Pkg_J);
+@@ -3400,8 +3400,8 @@ void rapl_probe(unsigned int family, uns
+ BIC_PRESENT(BIC_RAMWatt);
+ }
+ break;
+- case INTEL_FAM6_ATOM_SILVERMONT1: /* BYT */
+- case INTEL_FAM6_ATOM_SILVERMONT2: /* AVN */
++ case INTEL_FAM6_ATOM_SILVERMONT: /* BYT */
++ case INTEL_FAM6_ATOM_SILVERMONT_X: /* AVN */
+ do_rapl = RAPL_PKG | RAPL_CORES;
+ if (rapl_joules) {
+ BIC_PRESENT(BIC_Pkg_J);
+@@ -3411,7 +3411,7 @@ void rapl_probe(unsigned int family, uns
+ BIC_PRESENT(BIC_CorWatt);
+ }
+ break;
+- case INTEL_FAM6_ATOM_DENVERTON: /* DNV */
++ case INTEL_FAM6_ATOM_GOLDMONT_X: /* DNV */
+ do_rapl = RAPL_PKG | RAPL_DRAM | RAPL_DRAM_POWER_INFO | RAPL_DRAM_PERF_STATUS | RAPL_PKG_PERF_STATUS | RAPL_PKG_POWER_INFO | RAPL_CORES_ENERGY_STATUS;
+ BIC_PRESENT(BIC_PKG__);
+ BIC_PRESENT(BIC_RAM__);
+@@ -3434,7 +3434,7 @@ void rapl_probe(unsigned int family, uns
+ return;
+
+ rapl_power_units = 1.0 / (1 << (msr & 0xF));
+- if (model == INTEL_FAM6_ATOM_SILVERMONT1)
++ if (model == INTEL_FAM6_ATOM_SILVERMONT)
+ rapl_energy_units = 1.0 * (1 << (msr >> 8 & 0x1F)) / 1000000;
+ else
+ rapl_energy_units = 1.0 / (1 << (msr >> 8 & 0x1F));
+@@ -3684,8 +3684,8 @@ int has_snb_msrs(unsigned int family, un
+ case INTEL_FAM6_KABYLAKE_DESKTOP: /* KBL */
+ case INTEL_FAM6_SKYLAKE_X: /* SKX */
+ case INTEL_FAM6_ATOM_GOLDMONT: /* BXT */
+- case INTEL_FAM6_ATOM_GEMINI_LAKE:
+- case INTEL_FAM6_ATOM_DENVERTON: /* DNV */
++ case INTEL_FAM6_ATOM_GOLDMONT_PLUS:
++ case INTEL_FAM6_ATOM_GOLDMONT_X: /* DNV */
+ return 1;
+ }
+ return 0;
+@@ -3716,7 +3716,7 @@ int has_hsw_msrs(unsigned int family, un
+ case INTEL_FAM6_KABYLAKE_MOBILE: /* KBL */
+ case INTEL_FAM6_KABYLAKE_DESKTOP: /* KBL */
+ case INTEL_FAM6_ATOM_GOLDMONT: /* BXT */
+- case INTEL_FAM6_ATOM_GEMINI_LAKE:
++ case INTEL_FAM6_ATOM_GOLDMONT_PLUS:
+ return 1;
+ }
+ return 0;
+@@ -3750,8 +3750,8 @@ int is_slm(unsigned int family, unsigned
+ if (!genuine_intel)
+ return 0;
+ switch (model) {
+- case INTEL_FAM6_ATOM_SILVERMONT1: /* BYT */
+- case INTEL_FAM6_ATOM_SILVERMONT2: /* AVN */
++ case INTEL_FAM6_ATOM_SILVERMONT: /* BYT */
++ case INTEL_FAM6_ATOM_SILVERMONT_X: /* AVN */
+ return 1;
+ }
+ return 0;
+@@ -4106,11 +4106,11 @@ void process_cpuid()
+ crystal_hz = 24000000; /* 24.0 MHz */
+ break;
+ case INTEL_FAM6_SKYLAKE_X: /* SKX */
+- case INTEL_FAM6_ATOM_DENVERTON: /* DNV */
++ case INTEL_FAM6_ATOM_GOLDMONT_X: /* DNV */
+ crystal_hz = 25000000; /* 25.0 MHz */
+ break;
+ case INTEL_FAM6_ATOM_GOLDMONT: /* BXT */
+- case INTEL_FAM6_ATOM_GEMINI_LAKE:
++ case INTEL_FAM6_ATOM_GOLDMONT_PLUS:
+ crystal_hz = 19200000; /* 19.2 MHz */
+ break;
+ default:
diff --git a/patches.arch/x86-kvm-expose-x86_feature_md_clear-to-guests.patch b/patches.arch/x86-kvm-expose-x86_feature_md_clear-to-guests.patch
new file mode 100644
index 0000000000..ef439ddf46
--- /dev/null
+++ b/patches.arch/x86-kvm-expose-x86_feature_md_clear-to-guests.patch
@@ -0,0 +1,45 @@
+From: Andi Kleen <ak@linux.intel.com>
+Date: Fri, 18 Jan 2019 16:50:23 -0800
+Subject: x86/kvm: Expose X86_FEATURE_MD_CLEAR to guests
+Git-commit: 6c4dbbd14730c43f4ed808a9c42ca41625925c22
+Patch-mainline: v5.1-rc1
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+X86_FEATURE_MD_CLEAR is a new CPUID bit which is set when microcode
+provides the mechanism to invoke a flush of various exploitable CPU buffers
+by invoking the VERW instruction.
+
+Hand it through to guests so they can adjust their mitigations.
+
+This also requires corresponding qemu changes, which are available
+separately.
+
+[ tglx: Massaged changelog ]
+
+Signed-off-by: Andi Kleen <ak@linux.intel.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Borislav Petkov <bp@suse.de>
+Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
+Reviewed-by: Jon Masters <jcm@redhat.com>
+Tested-by: Jon Masters <jcm@redhat.com>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ arch/x86/kvm/cpuid.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
+index c07958b59f50..39501e7afdb4 100644
+--- a/arch/x86/kvm/cpuid.c
++++ b/arch/x86/kvm/cpuid.c
+@@ -410,7 +410,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
+ /* cpuid 7.0.edx*/
+ const u32 kvm_cpuid_7_0_edx_x86_features =
+ F(AVX512_4VNNIW) | F(AVX512_4FMAPS) | F(SPEC_CTRL) |
+- F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES) | F(INTEL_STIBP);
++ F(SPEC_CTRL_SSBD) | F(ARCH_CAPABILITIES) | F(INTEL_STIBP) |
++ F(MD_CLEAR);
+
+ /* all calls to cpuid_count() should be made on the same cpu */
+ get_cpu();
+
diff --git a/patches.arch/x86-kvm-vmx-add-mds-protection-when-l1d-flush-is-not-active.patch b/patches.arch/x86-kvm-vmx-add-mds-protection-when-l1d-flush-is-not-active.patch
new file mode 100644
index 0000000000..72dc41269e
--- /dev/null
+++ b/patches.arch/x86-kvm-vmx-add-mds-protection-when-l1d-flush-is-not-active.patch
@@ -0,0 +1,52 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Wed, 27 Feb 2019 12:48:14 +0100
+Subject: x86/kvm/vmx: Add MDS protection when L1D Flush is not active
+Git-commit: 650b68a0622f933444a6d66936abb3103029413b
+Patch-mainline: v5.1-rc1
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+CPUs which are affected by L1TF and MDS mitigate MDS with the L1D Flush on
+VMENTER when updated microcode is installed.
+
+If a CPU is not affected by L1TF or if the L1D Flush is not in use, then
+MDS mitigation needs to be invoked explicitly.
+
+For these cases, follow the host mitigation state and invoke the MDS
+mitigation before VMENTER.
+
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
+Reviewed-by: Borislav Petkov <bp@suse.de>
+Reviewed-by: Jon Masters <jcm@redhat.com>
+Tested-by: Jon Masters <jcm@redhat.com>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ arch/x86/kernel/cpu/bugs.c | 1 +
+ arch/x86/kvm/vmx.c | 3 +++
+ 2 files changed, 4 insertions(+)
+
+--- a/arch/x86/kernel/cpu/bugs.c
++++ b/arch/x86/kernel/cpu/bugs.c
+@@ -62,6 +62,7 @@ DEFINE_STATIC_KEY_FALSE(switch_mm_always
+
+ /* Control MDS CPU buffer clear before returning to user space */
+ DEFINE_STATIC_KEY_FALSE(mds_user_clear);
++EXPORT_SYMBOL_GPL(mds_user_clear);
+
+ void __init check_bugs(void)
+ {
+--- a/arch/x86/kvm/vmx.c
++++ b/arch/x86/kvm/vmx.c
+@@ -9684,8 +9684,11 @@ static void __noclone vmx_vcpu_run(struc
+
+ vmx->__launched = vmx->loaded_vmcs->launched;
+
++ /* L1D Flush includes CPU buffer clear to mitigate MDS */
+ if (static_branch_unlikely(&vmx_l1d_should_flush))
+ vmx_l1d_flush(vcpu);
++ else if (static_branch_unlikely(&mds_user_clear))
++ mds_clear_cpu_buffers();
+
+ asm(
+ /* Store host registers */
diff --git a/patches.arch/x86-msr-index-cleanup-bit-defines.patch b/patches.arch/x86-msr-index-cleanup-bit-defines.patch
new file mode 100644
index 0000000000..4fed2b84e7
--- /dev/null
+++ b/patches.arch/x86-msr-index-cleanup-bit-defines.patch
@@ -0,0 +1,102 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Thu, 21 Feb 2019 12:36:50 +0100
+Subject: x86/msr-index: Cleanup bit defines
+Git-commit: d8eabc37310a92df40d07c5a8afc53cebf996716
+Patch-mainline: v5.1-rc1
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+Greg pointed out that speculation related bit defines are using (1 << N)
+format instead of BIT(N). Aside of that (1 << N) is wrong as it should use
+1UL at least.
+
+Clean it up.
+
+[ Josh Poimboeuf: Fix tools build ]
+
+Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Reviewed-by: Borislav Petkov <bp@suse.de>
+Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
+Reviewed-by: Jon Masters <jcm@redhat.com>
+Tested-by: Jon Masters <jcm@redhat.com>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ arch/x86/include/asm/msr-index.h | 34 ++++++++++++++++++----------------
+ tools/power/x86/turbostat/Makefile | 2 +-
+ 2 files changed, 19 insertions(+), 17 deletions(-)
+
+--- a/arch/x86/include/asm/msr-index.h
++++ b/arch/x86/include/asm/msr-index.h
+@@ -1,6 +1,8 @@
+ #ifndef _ASM_X86_MSR_INDEX_H
+ #define _ASM_X86_MSR_INDEX_H
+
++#include <linux/bits.h>
++
+ /*
+ * CPU model specific register (MSR) numbers.
+ *
+@@ -39,14 +41,14 @@
+ /* Intel MSRs. Some also available on other CPUs */
+
+ #define MSR_IA32_SPEC_CTRL 0x00000048 /* Speculation Control */
+-#define SPEC_CTRL_IBRS (1 << 0) /* Indirect Branch Restricted Speculation */
++#define SPEC_CTRL_IBRS BIT(0) /* Indirect Branch Restricted Speculation */
+ #define SPEC_CTRL_STIBP_SHIFT 1 /* Single Thread Indirect Branch Predictor (STIBP) bit */
+-#define SPEC_CTRL_STIBP (1 << SPEC_CTRL_STIBP_SHIFT) /* STIBP mask */
++#define SPEC_CTRL_STIBP BIT(SPEC_CTRL_STIBP_SHIFT) /* STIBP mask */
+ #define SPEC_CTRL_SSBD_SHIFT 2 /* Speculative Store Bypass Disable bit */
+-#define SPEC_CTRL_SSBD (1 << SPEC_CTRL_SSBD_SHIFT) /* Speculative Store Bypass Disable */
++#define SPEC_CTRL_SSBD BIT(SPEC_CTRL_SSBD_SHIFT) /* Speculative Store Bypass Disable */
+
+ #define MSR_IA32_PRED_CMD 0x00000049 /* Prediction Command */
+-#define PRED_CMD_IBPB (1 << 0) /* Indirect Branch Prediction Barrier */
++#define PRED_CMD_IBPB BIT(0) /* Indirect Branch Prediction Barrier */
+
+ #define MSR_PPIN_CTL 0x0000004e
+ #define MSR_PPIN 0x0000004f
+@@ -68,20 +70,20 @@
+ #define MSR_MTRRcap 0x000000fe
+
+ #define MSR_IA32_ARCH_CAPABILITIES 0x0000010a
+-#define ARCH_CAP_RDCL_NO (1 << 0) /* Not susceptible to Meltdown */
+-#define ARCH_CAP_IBRS_ALL (1 << 1) /* Enhanced IBRS support */
+-#define ARCH_CAP_SKIP_VMENTRY_L1DFLUSH (1 << 3) /* Skip L1D flush on vmentry */
+-#define ARCH_CAP_SSB_NO (1 << 4) /*
+- * Not susceptible to Speculative Store Bypass
+- * attack, so no Speculative Store Bypass
+- * control required.
+- */
++#define ARCH_CAP_RDCL_NO BIT(0) /* Not susceptible to Meltdown */
++#define ARCH_CAP_IBRS_ALL BIT(1) /* Enhanced IBRS support */
++#define ARCH_CAP_SKIP_VMENTRY_L1DFLUSH BIT(3) /* Skip L1D flush on vmentry */
++#define ARCH_CAP_SSB_NO BIT(4) /*
++ * Not susceptible to Speculative Store Bypass
++ * attack, so no Speculative Store Bypass
++ * control required.
++ */
+
+ #define MSR_IA32_FLUSH_CMD 0x0000010b
+-#define L1D_FLUSH (1 << 0) /*
+- * Writeback and invalidate the
+- * L1 data cache.
+- */
++#define L1D_FLUSH BIT(0) /*
++ * Writeback and invalidate the
++ * L1 data cache.
++ */
+
+ #define MSR_IA32_BBL_CR_CTL 0x00000119
+ #define MSR_IA32_BBL_CR_CTL3 0x0000011e
+--- a/tools/power/x86/turbostat/Makefile
++++ b/tools/power/x86/turbostat/Makefile
+@@ -8,7 +8,7 @@ ifeq ("$(origin O)", "command line")
+ endif
+
+ turbostat : turbostat.c
+-CFLAGS += -Wall
++override CFLAGS += -Wall -I../../../include
+ CFLAGS += -DMSRHEADER='"../../../../arch/x86/include/asm/msr-index.h"'
+ CFLAGS += -DINTEL_FAMILY_HEADER='"../../../../arch/x86/include/asm/intel-family.h"'
+
diff --git a/patches.arch/x86-speculation-consolidate-cpu-whitelists.patch b/patches.arch/x86-speculation-consolidate-cpu-whitelists.patch
new file mode 100644
index 0000000000..a8953a02a2
--- /dev/null
+++ b/patches.arch/x86-speculation-consolidate-cpu-whitelists.patch
@@ -0,0 +1,167 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Wed, 27 Feb 2019 10:10:23 +0100
+Subject: x86/speculation: Consolidate CPU whitelists
+Git-commit: 36ad35131adacc29b328b9c8b6277a8bf0d6fd5d
+Patch-mainline: v5.1-rc1
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+The CPU vulnerability whitelists have some overlap and there are more
+whitelists coming along.
+
+Use the driver_data field in the x86_cpu_id struct to denote the
+whitelisted vulnerabilities and combine all whitelists into one.
+
+Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
+Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Reviewed-by: Borislav Petkov <bp@suse.de>
+Reviewed-by: Jon Masters <jcm@redhat.com>
+Tested-by: Jon Masters <jcm@redhat.com>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ arch/x86/kernel/cpu/common.c | 103 ++++++++++++++++++++++---------------------
+ 1 file changed, 55 insertions(+), 48 deletions(-)
+
+--- a/arch/x86/kernel/cpu/common.c
++++ b/arch/x86/kernel/cpu/common.c
+@@ -898,60 +898,68 @@ static void identify_cpu_without_cpuid(s
+ #endif
+ }
+
+-static const __initconst struct x86_cpu_id cpu_no_speculation[] = {
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SALTWELL, X86_FEATURE_ANY },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SALTWELL_TABLET, X86_FEATURE_ANY },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_BONNELL_MID, X86_FEATURE_ANY },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SALTWELL_MID, X86_FEATURE_ANY },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_BONNELL, X86_FEATURE_ANY },
+- { X86_VENDOR_CENTAUR, 5 },
+- { X86_VENDOR_INTEL, 5 },
+- { X86_VENDOR_NSC, 5 },
+- { X86_VENDOR_ANY, 4 },
+- {}
+-};
++#define NO_SPECULATION BIT(0)
++#define NO_MELTDOWN BIT(1)
++#define NO_SSB BIT(2)
++#define NO_L1TF BIT(3)
++
++#define VULNWL(_vendor, _family, _model, _whitelist) \
++ { X86_VENDOR_##_vendor, _family, _model, X86_FEATURE_ANY, _whitelist }
++
++#define VULNWL_INTEL(model, whitelist) \
++ VULNWL(INTEL, 6, INTEL_FAM6_##model, whitelist)
++
++#define VULNWL_AMD(family, whitelist) \
++ VULNWL(AMD, family, X86_MODEL_ANY, whitelist)
++
++static const __initconst struct x86_cpu_id cpu_vuln_whitelist[] = {
++ VULNWL(ANY, 4, X86_MODEL_ANY, NO_SPECULATION),
++ VULNWL(CENTAUR, 5, X86_MODEL_ANY, NO_SPECULATION),
++ VULNWL(INTEL, 5, X86_MODEL_ANY, NO_SPECULATION),
++ VULNWL(NSC, 5, X86_MODEL_ANY, NO_SPECULATION),
++
++ VULNWL_INTEL(ATOM_SALTWELL, NO_SPECULATION),
++ VULNWL_INTEL(ATOM_SALTWELL_TABLET, NO_SPECULATION),
++ VULNWL_INTEL(ATOM_SALTWELL_MID, NO_SPECULATION),
++ VULNWL_INTEL(ATOM_BONNELL, NO_SPECULATION),
++ VULNWL_INTEL(ATOM_BONNELL_MID, NO_SPECULATION),
++
++ VULNWL_INTEL(ATOM_SILVERMONT, NO_SSB | NO_L1TF),
++ VULNWL_INTEL(ATOM_SILVERMONT_X, NO_SSB | NO_L1TF),
++ VULNWL_INTEL(ATOM_SILVERMONT_MID, NO_SSB | NO_L1TF),
++ VULNWL_INTEL(ATOM_AIRMONT, NO_SSB | NO_L1TF),
++ VULNWL_INTEL(XEON_PHI_KNL, NO_SSB | NO_L1TF),
++ VULNWL_INTEL(XEON_PHI_KNM, NO_SSB | NO_L1TF),
++
++ VULNWL_INTEL(CORE_YONAH, NO_SSB),
++
++ VULNWL_INTEL(ATOM_AIRMONT_MID, NO_L1TF),
++ VULNWL_INTEL(ATOM_GOLDMONT, NO_L1TF),
++ VULNWL_INTEL(ATOM_GOLDMONT_X, NO_L1TF),
++ VULNWL_INTEL(ATOM_GOLDMONT_PLUS, NO_L1TF),
++
++ VULNWL_AMD(0x0f, NO_MELTDOWN | NO_SSB | NO_L1TF),
++ VULNWL_AMD(0x10, NO_MELTDOWN | NO_SSB | NO_L1TF),
++ VULNWL_AMD(0x11, NO_MELTDOWN | NO_SSB | NO_L1TF),
++ VULNWL_AMD(0x12, NO_MELTDOWN | NO_SSB | NO_L1TF),
+
+-static const __initconst struct x86_cpu_id cpu_no_meltdown[] = {
+- { X86_VENDOR_AMD },
++ /* FAMILY_ANY must be last, otherwise 0x0f - 0x12 matches won't work */
++ VULNWL_AMD(X86_FAMILY_ANY, NO_MELTDOWN | NO_L1TF),
+ {}
+ };
+
+-/* Only list CPUs which speculate but are non susceptible to SSB */
+-static const __initconst struct x86_cpu_id cpu_no_spec_store_bypass[] = {
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_AIRMONT },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT_X },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT_MID },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_CORE_YONAH },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_XEON_PHI_KNL },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_XEON_PHI_KNM },
+- { X86_VENDOR_AMD, 0x12, },
+- { X86_VENDOR_AMD, 0x11, },
+- { X86_VENDOR_AMD, 0x10, },
+- { X86_VENDOR_AMD, 0xf, },
+- {}
+-};
++static bool __init cpu_matches(unsigned long which)
++{
++ const struct x86_cpu_id *m = x86_match_cpu(cpu_vuln_whitelist);
+
+-static const __initconst struct x86_cpu_id cpu_no_l1tf[] = {
+- /* in addition to cpu_no_speculation */
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT_X },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_AIRMONT },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT_MID },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_AIRMONT_MID },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_GOLDMONT },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_GOLDMONT_X },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_GOLDMONT_PLUS },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_XEON_PHI_KNL },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_XEON_PHI_KNM },
+- {}
+-};
++ return m && !!(m->driver_data & which);
++}
+
+ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
+ {
+ u64 ia32_cap = 0;
+
+- if (x86_match_cpu(cpu_no_speculation))
++ if (cpu_matches(NO_SPECULATION))
+ return;
+
+ setup_force_cpu_bug(X86_BUG_SPECTRE_V1);
+@@ -960,15 +968,14 @@ static void __init cpu_set_bug_bits(stru
+ if (cpu_has(c, X86_FEATURE_ARCH_CAPABILITIES))
+ rdmsrl(MSR_IA32_ARCH_CAPABILITIES, ia32_cap);
+
+- if (!x86_match_cpu(cpu_no_spec_store_bypass) &&
+- !(ia32_cap & ARCH_CAP_SSB_NO) &&
++ if (!cpu_matches(NO_SSB) && !(ia32_cap & ARCH_CAP_SSB_NO) &&
+ !cpu_has(c, X86_FEATURE_AMD_SSB_NO))
+ setup_force_cpu_bug(X86_BUG_SPEC_STORE_BYPASS);
+
+ if (ia32_cap & ARCH_CAP_IBRS_ALL)
+ setup_force_cpu_cap(X86_FEATURE_IBRS_ENHANCED);
+
+- if (x86_match_cpu(cpu_no_meltdown))
++ if (cpu_matches(NO_MELTDOWN))
+ return;
+
+ /* Rogue Data Cache Load? No! */
+@@ -977,7 +984,7 @@ static void __init cpu_set_bug_bits(stru
+
+ setup_force_cpu_bug(X86_BUG_CPU_MELTDOWN);
+
+- if (x86_match_cpu(cpu_no_l1tf))
++ if (cpu_matches(NO_L1TF))
+ return;
+
+ setup_force_cpu_bug(X86_BUG_L1TF);
diff --git a/patches.arch/x86-speculation-mds-add-basic-bug-infrastructure-for-mds.patch b/patches.arch/x86-speculation-mds-add-basic-bug-infrastructure-for-mds.patch
new file mode 100644
index 0000000000..3b673bacec
--- /dev/null
+++ b/patches.arch/x86-speculation-mds-add-basic-bug-infrastructure-for-mds.patch
@@ -0,0 +1,148 @@
+From: Andi Kleen <ak@linux.intel.com>
+Date: Fri, 18 Jan 2019 16:50:16 -0800
+Subject: x86/speculation/mds: Add basic bug infrastructure for MDS
+Git-commit: ed5194c2732c8084af9fd159c146ea92bf137128
+Patch-mainline: v5.1-rc1
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+Microarchitectural Data Sampling (MDS), is a class of side channel attacks
+on internal buffers in Intel CPUs. The variants are:
+
+ - Microarchitectural Store Buffer Data Sampling (MSBDS) (CVE-2018-12126)
+ - Microarchitectural Fill Buffer Data Sampling (MFBDS) (CVE-2018-12130)
+ - Microarchitectural Load Port Data Sampling (MLPDS) (CVE-2018-12127)
+
+MSBDS leaks Store Buffer Entries which can be speculatively forwarded to a
+dependent load (store-to-load forwarding) as an optimization. The forward
+can also happen to a faulting or assisting load operation for a different
+memory address, which can be exploited under certain conditions. Store
+buffers are partitioned between Hyper-Threads so cross thread forwarding is
+not possible. But if a thread enters or exits a sleep state the store
+buffer is repartitioned which can expose data from one thread to the other.
+
+MFBDS leaks Fill Buffer Entries. Fill buffers are used internally to manage
+L1 miss situations and to hold data which is returned or sent in response
+to a memory or I/O operation. Fill buffers can forward data to a load
+operation and also write data to the cache. When the fill buffer is
+deallocated it can retain the stale data of the preceding operations which
+can then be forwarded to a faulting or assisting load operation, which can
+be exploited under certain conditions. Fill buffers are shared between
+Hyper-Threads so cross thread leakage is possible.
+
+MLDPS leaks Load Port Data. Load ports are used to perform load operations
+from memory or I/O. The received data is then forwarded to the register
+file or a subsequent operation. In some implementations the Load Port can
+contain stale data from a previous operation which can be forwarded to
+faulting or assisting loads under certain conditions, which again can be
+exploited eventually. Load ports are shared between Hyper-Threads so cross
+thread leakage is possible.
+
+All variants have the same mitigation for single CPU thread case (SMT off),
+so the kernel can treat them as one MDS issue.
+
+Add the basic infrastructure to detect if the current CPU is affected by
+MDS.
+
+[ tglx: Rewrote changelog ]
+
+Signed-off-by: Andi Kleen <ak@linux.intel.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Borislav Petkov <bp@suse.de>
+Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
+Reviewed-by: Jon Masters <jcm@redhat.com>
+Tested-by: Jon Masters <jcm@redhat.com>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ arch/x86/include/asm/cpufeatures.h | 2 ++
+ arch/x86/include/asm/msr-index.h | 5 +++++
+ arch/x86/kernel/cpu/common.c | 25 ++++++++++++++++---------
+ 3 files changed, 23 insertions(+), 9 deletions(-)
+
+--- a/arch/x86/include/asm/cpufeatures.h
++++ b/arch/x86/include/asm/cpufeatures.h
+@@ -341,6 +341,7 @@
+ #define X86_FEATURE_AVX512_4VNNIW (18*32+ 2) /* AVX-512 Neural Network Instructions */
+ #define X86_FEATURE_AVX512_4FMAPS (18*32+ 3) /* AVX-512 Multiply Accumulation Single precision */
+ #define X86_FEATURE_TSX_FORCE_ABORT (18*32+13) /* "" TSX_FORCE_ABORT */
++#define X86_FEATURE_MD_CLEAR (18*32+10) /* VERW clears CPU buffers */
+ #define X86_FEATURE_PCONFIG (18*32+18) /* Intel PCONFIG */
+ #define X86_FEATURE_SPEC_CTRL (18*32+26) /* "" Speculation Control (IBRS + IBPB) */
+ #define X86_FEATURE_INTEL_STIBP (18*32+27) /* "" Single Thread Indirect Branch Predictors */
+@@ -378,4 +379,5 @@
+ #define X86_BUG_SPECTRE_V2 X86_BUG(16) /* CPU is affected by Spectre variant 2 attack with indirect branches */
+ #define X86_BUG_SPEC_STORE_BYPASS X86_BUG(17) /* CPU is affected by speculative store bypass attack */
+ #define X86_BUG_L1TF X86_BUG(18) /* CPU is affected by L1 Terminal Fault */
++#define X86_BUG_MDS X86_BUG(19) /* CPU is affected by Microarchitectural data sampling */
+ #endif /* _ASM_X86_CPUFEATURES_H */
+--- a/arch/x86/include/asm/msr-index.h
++++ b/arch/x86/include/asm/msr-index.h
+@@ -78,6 +78,11 @@
+ * attack, so no Speculative Store Bypass
+ * control required.
+ */
++#define ARCH_CAP_MDS_NO BIT(5) /*
++ * Not susceptible to
++ * Microarchitectural Data
++ * Sampling (MDS) vulnerabilities.
++ */
+
+ #define MSR_IA32_FLUSH_CMD 0x0000010b
+ #define L1D_FLUSH BIT(0) /*
+--- a/arch/x86/kernel/cpu/common.c
++++ b/arch/x86/kernel/cpu/common.c
+@@ -902,6 +902,7 @@ static void identify_cpu_without_cpuid(s
+ #define NO_MELTDOWN BIT(1)
+ #define NO_SSB BIT(2)
+ #define NO_L1TF BIT(3)
++#define NO_MDS BIT(4)
+
+ #define VULNWL(_vendor, _family, _model, _whitelist) \
+ { X86_VENDOR_##_vendor, _family, _model, X86_FEATURE_ANY, _whitelist }
+@@ -918,6 +919,7 @@ static const __initconst struct x86_cpu_
+ VULNWL(INTEL, 5, X86_MODEL_ANY, NO_SPECULATION),
+ VULNWL(NSC, 5, X86_MODEL_ANY, NO_SPECULATION),
+
++ /* Intel Family 6 */
+ VULNWL_INTEL(ATOM_SALTWELL, NO_SPECULATION),
+ VULNWL_INTEL(ATOM_SALTWELL_TABLET, NO_SPECULATION),
+ VULNWL_INTEL(ATOM_SALTWELL_MID, NO_SPECULATION),
+@@ -934,17 +936,19 @@ static const __initconst struct x86_cpu_
+ VULNWL_INTEL(CORE_YONAH, NO_SSB),
+
+ VULNWL_INTEL(ATOM_AIRMONT_MID, NO_L1TF),
+- VULNWL_INTEL(ATOM_GOLDMONT, NO_L1TF),
+- VULNWL_INTEL(ATOM_GOLDMONT_X, NO_L1TF),
+- VULNWL_INTEL(ATOM_GOLDMONT_PLUS, NO_L1TF),
+-
+- VULNWL_AMD(0x0f, NO_MELTDOWN | NO_SSB | NO_L1TF),
+- VULNWL_AMD(0x10, NO_MELTDOWN | NO_SSB | NO_L1TF),
+- VULNWL_AMD(0x11, NO_MELTDOWN | NO_SSB | NO_L1TF),
+- VULNWL_AMD(0x12, NO_MELTDOWN | NO_SSB | NO_L1TF),
++
++ VULNWL_INTEL(ATOM_GOLDMONT, NO_MDS | NO_L1TF),
++ VULNWL_INTEL(ATOM_GOLDMONT_X, NO_MDS | NO_L1TF),
++ VULNWL_INTEL(ATOM_GOLDMONT_PLUS, NO_MDS | NO_L1TF),
++
++ /* AMD Family 0xf - 0x12 */
++ VULNWL_AMD(0x0f, NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS),
++ VULNWL_AMD(0x10, NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS),
++ VULNWL_AMD(0x11, NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS),
++ VULNWL_AMD(0x12, NO_MELTDOWN | NO_SSB | NO_L1TF | NO_MDS),
+
+ /* FAMILY_ANY must be last, otherwise 0x0f - 0x12 matches won't work */
+- VULNWL_AMD(X86_FAMILY_ANY, NO_MELTDOWN | NO_L1TF),
++ VULNWL_AMD(X86_FAMILY_ANY, NO_MELTDOWN | NO_L1TF | NO_MDS),
+ {}
+ };
+
+@@ -975,6 +979,9 @@ static void __init cpu_set_bug_bits(stru
+ if (ia32_cap & ARCH_CAP_IBRS_ALL)
+ setup_force_cpu_cap(X86_FEATURE_IBRS_ENHANCED);
+
++ if (!cpu_matches(NO_MDS) && !(ia32_cap & ARCH_CAP_MDS_NO))
++ setup_force_cpu_bug(X86_BUG_MDS);
++
+ if (cpu_matches(NO_MELTDOWN))
+ return;
+
diff --git a/patches.arch/x86-speculation-mds-add-bug_msbds_only.patch b/patches.arch/x86-speculation-mds-add-bug_msbds_only.patch
new file mode 100644
index 0000000000..b6ebab3b9e
--- /dev/null
+++ b/patches.arch/x86-speculation-mds-add-bug_msbds_only.patch
@@ -0,0 +1,86 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Fri, 1 Mar 2019 20:21:08 +0100
+Subject: x86/speculation/mds: Add BUG_MSBDS_ONLY
+Git-commit: e261f209c3666e842fd645a1e31f001c3a26def9
+Patch-mainline: v5.1-rc1
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+This bug bit is set on CPUs which are only affected by Microarchitectural
+Store Buffer Data Sampling (MSBDS) and not by any other MDS variant.
+
+This is important because the Store Buffers are partitioned between
+Hyper-Threads so cross thread forwarding is not possible. But if a thread
+enters or exits a sleep state the store buffer is repartitioned which can
+expose data from one thread to the other. This transition can be mitigated.
+
+That means that for CPUs which are only affected by MSBDS SMT can be
+enabled, if the CPU is not affected by other SMT sensitive vulnerabilities,
+e.g. L1TF. The XEON PHI variants fall into that category. Also the
+Silvermont/Airmont ATOMs, but for them it's not really relevant as they do
+not support SMT, but mark them for completeness sake.
+
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
+Reviewed-by: Jon Masters <jcm@redhat.com>
+Tested-by: Jon Masters <jcm@redhat.com>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ arch/x86/include/asm/cpufeatures.h | 1 +
+ arch/x86/kernel/cpu/common.c | 20 ++++++++++++--------
+ 2 files changed, 13 insertions(+), 8 deletions(-)
+
+--- a/arch/x86/include/asm/cpufeatures.h
++++ b/arch/x86/include/asm/cpufeatures.h
+@@ -379,4 +379,5 @@
+ #define X86_BUG_SPEC_STORE_BYPASS X86_BUG(17) /* CPU is affected by speculative store bypass attack */
+ #define X86_BUG_L1TF X86_BUG(18) /* CPU is affected by L1 Terminal Fault */
+ #define X86_BUG_MDS X86_BUG(19) /* CPU is affected by Microarchitectural data sampling */
++#define X86_BUG_MSBDS_ONLY X86_BUG(20) /* CPU is only affected by the MSDBS variant of BUG_MDS */
+ #endif /* _ASM_X86_CPUFEATURES_H */
+--- a/arch/x86/kernel/cpu/common.c
++++ b/arch/x86/kernel/cpu/common.c
+@@ -903,6 +903,7 @@ static void identify_cpu_without_cpuid(s
+ #define NO_SSB BIT(2)
+ #define NO_L1TF BIT(3)
+ #define NO_MDS BIT(4)
++#define MSBDS_ONLY BIT(5)
+
+ #define VULNWL(_vendor, _family, _model, _whitelist) \
+ { X86_VENDOR_##_vendor, _family, _model, X86_FEATURE_ANY, _whitelist }
+@@ -926,16 +927,16 @@ static const __initconst struct x86_cpu_
+ VULNWL_INTEL(ATOM_BONNELL, NO_SPECULATION),
+ VULNWL_INTEL(ATOM_BONNELL_MID, NO_SPECULATION),
+
+- VULNWL_INTEL(ATOM_SILVERMONT, NO_SSB | NO_L1TF),
+- VULNWL_INTEL(ATOM_SILVERMONT_X, NO_SSB | NO_L1TF),
+- VULNWL_INTEL(ATOM_SILVERMONT_MID, NO_SSB | NO_L1TF),
+- VULNWL_INTEL(ATOM_AIRMONT, NO_SSB | NO_L1TF),
+- VULNWL_INTEL(XEON_PHI_KNL, NO_SSB | NO_L1TF),
+- VULNWL_INTEL(XEON_PHI_KNM, NO_SSB | NO_L1TF),
++ VULNWL_INTEL(ATOM_SILVERMONT, NO_SSB | NO_L1TF | MSBDS_ONLY),
++ VULNWL_INTEL(ATOM_SILVERMONT_X, NO_SSB | NO_L1TF | MSBDS_ONLY),
++ VULNWL_INTEL(ATOM_SILVERMONT_MID, NO_SSB | NO_L1TF | MSBDS_ONLY),
++ VULNWL_INTEL(ATOM_AIRMONT, NO_SSB | NO_L1TF | MSBDS_ONLY),
++ VULNWL_INTEL(XEON_PHI_KNL, NO_SSB | NO_L1TF | MSBDS_ONLY),
++ VULNWL_INTEL(XEON_PHI_KNM, NO_SSB | NO_L1TF | MSBDS_ONLY),
+
+ VULNWL_INTEL(CORE_YONAH, NO_SSB),
+
+- VULNWL_INTEL(ATOM_AIRMONT_MID, NO_L1TF),
++ VULNWL_INTEL(ATOM_AIRMONT_MID, NO_L1TF | MSBDS_ONLY),
+
+ VULNWL_INTEL(ATOM_GOLDMONT, NO_MDS | NO_L1TF),
+ VULNWL_INTEL(ATOM_GOLDMONT_X, NO_MDS | NO_L1TF),
+@@ -979,8 +980,11 @@ static void __init cpu_set_bug_bits(stru
+ if (ia32_cap & ARCH_CAP_IBRS_ALL)
+ setup_force_cpu_cap(X86_FEATURE_IBRS_ENHANCED);
+
+- if (!cpu_matches(NO_MDS) && !(ia32_cap & ARCH_CAP_MDS_NO))
++ if (!cpu_matches(NO_MDS) && !(ia32_cap & ARCH_CAP_MDS_NO)) {
+ setup_force_cpu_bug(X86_BUG_MDS);
++ if (cpu_matches(MSBDS_ONLY))
++ setup_force_cpu_bug(X86_BUG_MSBDS_ONLY);
++ }
+
+ if (cpu_matches(NO_MELTDOWN))
+ return;
diff --git a/patches.arch/x86-speculation-mds-add-mds-full-nosmt-cmdline-option.patch b/patches.arch/x86-speculation-mds-add-mds-full-nosmt-cmdline-option.patch
new file mode 100644
index 0000000000..d3303c9f25
--- /dev/null
+++ b/patches.arch/x86-speculation-mds-add-mds-full-nosmt-cmdline-option.patch
@@ -0,0 +1,85 @@
+From: Josh Poimboeuf <jpoimboe@redhat.com>
+Date: Tue, 2 Apr 2019 09:59:33 -0500
+Subject: x86/speculation/mds: Add mds=full,nosmt cmdline option
+Git-repo: tip/tip
+Git-commit: d71eb0ce109a124b0fa714832823b9452f2762cf
+Patch-mainline: Queued in a subsystem tree
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+Add the mds=full,nosmt cmdline option. This is like mds=full, but with
+SMT disabled if the CPU is vulnerable.
+
+Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Tyler Hicks <tyhicks@canonical.com>
+Acked-by: Jiri Kosina <jkosina@suse.cz>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ Documentation/admin-guide/kernel-parameters.txt | 6 ++++--
+ Documentation/x86/mds.rst | 4 ++++
+ arch/x86/kernel/cpu/bugs.c | 10 ++++++++++
+ 3 files changed, 18 insertions(+), 2 deletions(-)
+
+--- a/arch/x86/kernel/cpu/bugs.c
++++ b/arch/x86/kernel/cpu/bugs.c
+@@ -342,6 +342,7 @@ early_param("l1tf", l1tf_cmdline);
+
+ /* Default mitigation for L1TF-affected CPUs */
+ static enum mds_mitigations mds_mitigation __ro_after_init = MDS_MITIGATION_FULL;
++static bool mds_nosmt __ro_after_init = false;
+
+ static const char * const mds_strings[] = {
+ [MDS_MITIGATION_OFF] = "Vulnerable",
+@@ -359,8 +360,13 @@ static void __init mds_select_mitigation
+ if (mds_mitigation == MDS_MITIGATION_FULL) {
+ if (!boot_cpu_has(X86_FEATURE_MD_CLEAR))
+ mds_mitigation = MDS_MITIGATION_VMWERV;
++
+ static_branch_enable(&mds_user_clear);
++
++ if (mds_nosmt && !boot_cpu_has(X86_BUG_MSBDS_ONLY))
++ cpu_smt_disable(false);
+ }
++
+ pr_info("%s\n", mds_strings[mds_mitigation]);
+ }
+
+@@ -376,6 +382,10 @@ static int __init mds_cmdline(char *str)
+ mds_mitigation = MDS_MITIGATION_OFF;
+ else if (!strcmp(str, "full"))
+ mds_mitigation = MDS_MITIGATION_FULL;
++ else if (!strcmp(str, "full,nosmt")) {
++ mds_mitigation = MDS_MITIGATION_FULL;
++ mds_nosmt = true;
++ }
+
+ return 0;
+ }
+--- a/Documentation/admin-guide/kernel-parameters.txt
++++ b/Documentation/admin-guide/kernel-parameters.txt
+@@ -2221,8 +2221,10 @@
+ This parameter controls the MDS mitigation. The
+ options are:
+
+- full - Enable MDS mitigation on vulnerable CPUs
+- off - Unconditionally disable MDS mitigation
++ full - Enable MDS mitigation on vulnerable CPUs
++ full,nosmt - Enable MDS mitigation and disable
++ SMT on vulnerable CPUs
++ off - Unconditionally disable MDS mitigation
+
+ Not specifying this option is equivalent to
+ mds=full.
+--- a/Documentation/x86/mds.rst
++++ b/Documentation/x86/mds.rst
+@@ -119,6 +119,10 @@ Kernel internal mitigation modes
+ scenarios where the host has the updated microcode but the
+ hypervisor does not expose MD_CLEAR in CPUID. It's a best
+ effort approach without guarantee.
++
++ full,nosmt The same as mds=full, with SMT disabled on vulnerable
++ CPUs. This is the complete mitigation.
++
+ ======= ============================================================
+
+ If the CPU is affected and mds=off is not supplied on the kernel command
diff --git a/patches.arch/x86-speculation-mds-add-mds_clear_cpu_buffers.patch b/patches.arch/x86-speculation-mds-add-mds_clear_cpu_buffers.patch
new file mode 100644
index 0000000000..3d563bb801
--- /dev/null
+++ b/patches.arch/x86-speculation-mds-add-mds_clear_cpu_buffers.patch
@@ -0,0 +1,216 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Mon, 18 Feb 2019 23:13:06 +0100
+Subject: x86/speculation/mds: Add mds_clear_cpu_buffers()
+Git-commit: 6a9e529272517755904b7afa639f6db59ddb793e
+Patch-mainline: v5.1-rc1
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+The Microarchitectural Data Sampling (MDS) vulernabilities are mitigated by
+clearing the affected CPU buffers. The mechanism for clearing the buffers
+uses the unused and obsolete VERW instruction in combination with a
+microcode update which triggers a CPU buffer clear when VERW is executed.
+
+Provide a inline function with the assembly magic. The argument of the VERW
+instruction must be a memory operand as documented:
+
+ "MD_CLEAR enumerates that the memory-operand variant of VERW (for
+ example, VERW m16) has been extended to also overwrite buffers affected
+ by MDS. This buffer overwriting functionality is not guaranteed for the
+ register operand variant of VERW."
+
+Documentation also recommends to use a writable data segment selector:
+
+ "The buffer overwriting occurs regardless of the result of the VERW
+ permission check, as well as when the selector is null or causes a
+ descriptor load segment violation. However, for lowest latency we
+ recommend using a selector that indicates a valid writable data
+ segment."
+
+Add x86 specific documentation about MDS and the internal workings of the
+mitigation.
+
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Borislav Petkov <bp@suse.de>
+Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
+Reviewed-by: Jon Masters <jcm@redhat.com>
+Tested-by: Jon Masters <jcm@redhat.com>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ Documentation/index.rst | 1
+ Documentation/x86/conf.py | 10 +++
+ Documentation/x86/index.rst | 8 ++
+ Documentation/x86/mds.rst | 99 +++++++++++++++++++++++++++++++++++
+ arch/x86/include/asm/nospec-branch.h | 25 ++++++++
+ 5 files changed, 143 insertions(+)
+
+--- a/arch/x86/include/asm/nospec-branch.h
++++ b/arch/x86/include/asm/nospec-branch.h
+@@ -318,6 +318,31 @@ DECLARE_STATIC_KEY_FALSE(switch_to_cond_
+ DECLARE_STATIC_KEY_FALSE(switch_mm_cond_ibpb);
+ DECLARE_STATIC_KEY_FALSE(switch_mm_always_ibpb);
+
++#include <asm/segment.h>
++
++/**
++ * mds_clear_cpu_buffers - Mitigation for MDS vulnerability
++ *
++ * This uses the otherwise unused and obsolete VERW instruction in
++ * combination with microcode which triggers a CPU buffer flush when the
++ * instruction is executed.
++ */
++static inline void mds_clear_cpu_buffers(void)
++{
++ static const u16 ds = __KERNEL_DS;
++
++ /*
++ * Has to be the memory-operand variant because only that
++ * guarantees the CPU buffer flush functionality according to
++ * documentation. The register-operand variant does not.
++ * Works with any segment selector, but a valid writable
++ * data segment is the fastest variant.
++ *
++ * "cc" clobber is required because VERW modifies ZF.
++ */
++ asm volatile("verw %[ds]" : : [ds] "m" (ds) : "cc");
++}
++
+ #endif /* __ASSEMBLY__ */
+
+ /*
+--- a/Documentation/index.rst
++++ b/Documentation/index.rst
+@@ -34,6 +34,7 @@ the kernel interface as seen by applicat
+ :maxdepth: 2
+
+ userspace-api/index
++ x86/index
+
+
+ Introduction to kernel development
+--- /dev/null
++++ b/Documentation/x86/conf.py
+@@ -0,0 +1,10 @@
++# -*- coding: utf-8; mode: python -*-
++
++project = "X86 architecture specific documentation"
++
++tags.add("subproject")
++
++latex_documents = [
++ ('index', 'x86.tex', project,
++ 'The kernel development community', 'manual'),
++]
+--- /dev/null
++++ b/Documentation/x86/index.rst
+@@ -0,0 +1,8 @@
++==========================
++x86 architecture specifics
++==========================
++
++.. toctree::
++ :maxdepth: 1
++
++ mds
+--- /dev/null
++++ b/Documentation/x86/mds.rst
+@@ -0,0 +1,99 @@
++Microarchitectural Data Sampling (MDS) mitigation
++=================================================
++
++.. _mds:
++
++Overview
++--------
++
++Microarchitectural Data Sampling (MDS) is a family of side channel attacks
++on internal buffers in Intel CPUs. The variants are:
++
++ - Microarchitectural Store Buffer Data Sampling (MSBDS) (CVE-2018-12126)
++ - Microarchitectural Fill Buffer Data Sampling (MFBDS) (CVE-2018-12130)
++ - Microarchitectural Load Port Data Sampling (MLPDS) (CVE-2018-12127)
++
++MSBDS leaks Store Buffer Entries which can be speculatively forwarded to a
++dependent load (store-to-load forwarding) as an optimization. The forward
++can also happen to a faulting or assisting load operation for a different
++memory address, which can be exploited under certain conditions. Store
++buffers are partitioned between Hyper-Threads so cross thread forwarding is
++not possible. But if a thread enters or exits a sleep state the store
++buffer is repartitioned which can expose data from one thread to the other.
++
++MFBDS leaks Fill Buffer Entries. Fill buffers are used internally to manage
++L1 miss situations and to hold data which is returned or sent in response
++to a memory or I/O operation. Fill buffers can forward data to a load
++operation and also write data to the cache. When the fill buffer is
++deallocated it can retain the stale data of the preceding operations which
++can then be forwarded to a faulting or assisting load operation, which can
++be exploited under certain conditions. Fill buffers are shared between
++Hyper-Threads so cross thread leakage is possible.
++
++MLPDS leaks Load Port Data. Load ports are used to perform load operations
++from memory or I/O. The received data is then forwarded to the register
++file or a subsequent operation. In some implementations the Load Port can
++contain stale data from a previous operation which can be forwarded to
++faulting or assisting loads under certain conditions, which again can be
++exploited eventually. Load ports are shared between Hyper-Threads so cross
++thread leakage is possible.
++
++
++Exposure assumptions
++--------------------
++
++It is assumed that attack code resides in user space or in a guest with one
++exception. The rationale behind this assumption is that the code construct
++needed for exploiting MDS requires:
++
++ - to control the load to trigger a fault or assist
++
++ - to have a disclosure gadget which exposes the speculatively accessed
++ data for consumption through a side channel.
++
++ - to control the pointer through which the disclosure gadget exposes the
++ data
++
++The existence of such a construct in the kernel cannot be excluded with
++100% certainty, but the complexity involved makes it extremly unlikely.
++
++There is one exception, which is untrusted BPF. The functionality of
++untrusted BPF is limited, but it needs to be thoroughly investigated
++whether it can be used to create such a construct.
++
++
++Mitigation strategy
++-------------------
++
++All variants have the same mitigation strategy at least for the single CPU
++thread case (SMT off): Force the CPU to clear the affected buffers.
++
++This is achieved by using the otherwise unused and obsolete VERW
++instruction in combination with a microcode update. The microcode clears
++the affected CPU buffers when the VERW instruction is executed.
++
++For virtualization there are two ways to achieve CPU buffer
++clearing. Either the modified VERW instruction or via the L1D Flush
++command. The latter is issued when L1TF mitigation is enabled so the extra
++VERW can be avoided. If the CPU is not affected by L1TF then VERW needs to
++be issued.
++
++If the VERW instruction with the supplied segment selector argument is
++executed on a CPU without the microcode update there is no side effect
++other than a small number of pointlessly wasted CPU cycles.
++
++This does not protect against cross Hyper-Thread attacks except for MSBDS
++which is only exploitable cross Hyper-thread when one of the Hyper-Threads
++enters a C-state.
++
++The kernel provides a function to invoke the buffer clearing:
++
++ mds_clear_cpu_buffers()
++
++The mitigation is invoked on kernel/userspace, hypervisor/guest and C-state
++(idle) transitions.
++
++According to current knowledge additional mitigations inside the kernel
++itself are not required because the necessary gadgets to expose the leaked
++data cannot be controlled in a way which allows exploitation from malicious
++user space or VM guests.
diff --git a/patches.arch/x86-speculation-mds-add-mitigation-control-for-mds.patch b/patches.arch/x86-speculation-mds-add-mitigation-control-for-mds.patch
new file mode 100644
index 0000000000..0cc8bfbf56
--- /dev/null
+++ b/patches.arch/x86-speculation-mds-add-mitigation-control-for-mds.patch
@@ -0,0 +1,186 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Mon, 18 Feb 2019 22:04:08 +0100
+Subject: x86/speculation/mds: Add mitigation control for MDS
+Git-commit: bc1241700acd82ec69fde98c5763ce51086269f8
+Patch-mainline: v5.1-rc1
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+Now that the mitigations are in place, add a command line parameter to
+control the mitigation, a mitigation selector function and a SMT update
+mechanism.
+
+This is the minimal straight forward initial implementation which just
+provides an always on/off mode. The command line parameter is:
+
+ mds=[full|off]
+
+This is consistent with the existing mitigations for other speculative
+hardware vulnerabilities.
+
+The idle invocation is dynamically updated according to the SMT state of
+the system similar to the dynamic update of the STIBP mitigation. The idle
+mitigation is limited to CPUs which are only affected by MSBDS and not any
+other variant, because the other variants cannot be mitigated on SMT
+enabled systems.
+
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Borislav Petkov <bp@suse.de>
+Reviewed-by: Jon Masters <jcm@redhat.com>
+Tested-by: Jon Masters <jcm@redhat.com>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ Documentation/admin-guide/kernel-parameters.txt | 22 +++++++
+ arch/x86/include/asm/processor.h | 5 +
+ arch/x86/kernel/cpu/bugs.c | 70 ++++++++++++++++++++++++
+ 3 files changed, 97 insertions(+)
+
+--- a/arch/x86/include/asm/processor.h
++++ b/arch/x86/include/asm/processor.h
+@@ -982,4 +982,9 @@ enum l1tf_mitigations {
+
+ extern enum l1tf_mitigations l1tf_mitigation;
+
++enum mds_mitigations {
++ MDS_MITIGATION_OFF,
++ MDS_MITIGATION_FULL,
++};
++
+ #endif /* _ASM_X86_PROCESSOR_H */
+--- a/arch/x86/kernel/cpu/bugs.c
++++ b/arch/x86/kernel/cpu/bugs.c
+@@ -34,6 +34,7 @@
+ static void __init spectre_v2_select_mitigation(void);
+ static void __init ssb_select_mitigation(void);
+ static void __init l1tf_select_mitigation(void);
++static void __init mds_select_mitigation(void);
+
+ /* The base value of the SPEC_CTRL MSR that always has to be preserved. */
+ u64 x86_spec_ctrl_base;
+@@ -105,6 +106,8 @@ void __init check_bugs(void)
+
+ l1tf_select_mitigation();
+
++ mds_select_mitigation();
++
+ #ifdef CONFIG_X86_32
+ /*
+ * Check whether we are able to run this kernel safely on SMP.
+@@ -330,6 +333,50 @@ early_param("l1tf", l1tf_cmdline);
+
+
+ #undef pr_fmt
++#define pr_fmt(fmt) "MDS: " fmt
++
++/* Default mitigation for L1TF-affected CPUs */
++static enum mds_mitigations mds_mitigation __ro_after_init = MDS_MITIGATION_FULL;
++
++static const char * const mds_strings[] = {
++ [MDS_MITIGATION_OFF] = "Vulnerable",
++ [MDS_MITIGATION_FULL] = "Mitigation: Clear CPU buffers"
++};
++
++static void __init mds_select_mitigation(void)
++{
++ if (!boot_cpu_has_bug(X86_BUG_MDS)) {
++ mds_mitigation = MDS_MITIGATION_OFF;
++ return;
++ }
++
++ if (mds_mitigation == MDS_MITIGATION_FULL) {
++ if (boot_cpu_has(X86_FEATURE_MD_CLEAR))
++ static_branch_enable(&mds_user_clear);
++ else
++ mds_mitigation = MDS_MITIGATION_OFF;
++ }
++ pr_info("%s\n", mds_strings[mds_mitigation]);
++}
++
++static int __init mds_cmdline(char *str)
++{
++ if (!boot_cpu_has_bug(X86_BUG_MDS))
++ return 0;
++
++ if (!str)
++ return -EINVAL;
++
++ if (!strcmp(str, "off"))
++ mds_mitigation = MDS_MITIGATION_OFF;
++ else if (!strcmp(str, "full"))
++ mds_mitigation = MDS_MITIGATION_FULL;
++
++ return 0;
++}
++early_param("mds", mds_cmdline);
++
++#undef pr_fmt
+ #define pr_fmt(fmt) "Spectre V2 : " fmt
+
+ static enum spectre_v2_mitigation spectre_v2_enabled __ro_after_init =
+@@ -738,6 +785,26 @@ static void update_indir_branch_cond(voi
+ static_branch_disable(&switch_to_cond_stibp);
+ }
+
++/* Update the static key controlling the MDS CPU buffer clear in idle */
++static void update_mds_branch_idle(void)
++{
++ /*
++ * Enable the idle clearing if SMT is active on CPUs which are
++ * affected only by MSBDS and not any other MDS variant.
++ *
++ * The other variants cannot be mitigated when SMT is enabled, so
++ * clearing the buffers on idle just to prevent the Store Buffer
++ * repartitioning leak would be a window dressing exercise.
++ */
++ if (!boot_cpu_has_bug(X86_BUG_MSBDS_ONLY))
++ return;
++
++ if (sched_smt_active())
++ static_branch_enable(&mds_idle_clear);
++ else
++ static_branch_disable(&mds_idle_clear);
++}
++
+ void arch_smt_update(void)
+ {
+ /* Enhanced IBRS implies STIBP. No update required. */
+@@ -758,6 +825,9 @@ void arch_smt_update(void)
+ break;
+ }
+
++ if (mds_mitigation == MDS_MITIGATION_FULL)
++ update_mds_branch_idle();
++
+ mutex_unlock(&spec_ctrl_mutex);
+ }
+
+--- a/Documentation/admin-guide/kernel-parameters.txt
++++ b/Documentation/admin-guide/kernel-parameters.txt
+@@ -2205,6 +2205,28 @@
+ Format: <first>,<last>
+ Specifies range of consoles to be captured by the MDA.
+
++ mds= [X86,INTEL]
++ Control mitigation for the Micro-architectural Data
++ Sampling (MDS) vulnerability.
++
++ Certain CPUs are vulnerable to an exploit against CPU
++ internal buffers which can forward information to a
++ disclosure gadget under certain conditions.
++
++ In vulnerable processors, the speculatively
++ forwarded data can be used in a cache side channel
++ attack, to access data to which the attacker does
++ not have direct access.
++
++ This parameter controls the MDS mitigation. The
++ options are:
++
++ full - Enable MDS mitigation on vulnerable CPUs
++ off - Unconditionally disable MDS mitigation
++
++ Not specifying this option is equivalent to
++ mds=full.
++
+ mem=nn[KMG] [KNL,BOOT] Force usage of a specific amount of memory
+ Amount of memory to be used when the kernel is not able
+ to see the whole system memory or for test.
diff --git a/patches.arch/x86-speculation-mds-add-mitigation-mode-vmwerv.patch b/patches.arch/x86-speculation-mds-add-mitigation-mode-vmwerv.patch
new file mode 100644
index 0000000000..4f0e1f0f07
--- /dev/null
+++ b/patches.arch/x86-speculation-mds-add-mitigation-mode-vmwerv.patch
@@ -0,0 +1,131 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Wed, 20 Feb 2019 09:40:40 +0100
+Subject: x86/speculation/mds: Add mitigation mode VMWERV
+Git-commit: 22dd8365088b6403630b82423cf906491859b65e
+Patch-mainline: v5.1-rc1
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+In virtualized environments it can happen that the host has the microcode
+update which utilizes the VERW instruction to clear CPU buffers, but the
+hypervisor is not yet updated to expose the X86_FEATURE_MD_CLEAR CPUID bit
+to guests.
+
+Introduce an internal mitigation mode VMWERV which enables the invocation
+of the CPU buffer clearing even if X86_FEATURE_MD_CLEAR is not set. If the
+system has no updated microcode this results in a pointless execution of
+the VERW instruction wasting a few CPU cycles. If the microcode is updated,
+but not exposed to a guest then the CPU buffers will be cleared.
+
+That said: Virtual Machines Will Eventually Receive Vaccine
+
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Borislav Petkov <bp@suse.de>
+Reviewed-by: Jon Masters <jcm@redhat.com>
+Tested-by: Jon Masters <jcm@redhat.com>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ Documentation/x86/mds.rst | 27 +++++++++++++++++++++++++++
+ arch/x86/include/asm/processor.h | 1 +
+ arch/x86/kernel/cpu/bugs.c | 18 ++++++++++++------
+ 3 files changed, 40 insertions(+), 6 deletions(-)
+
+diff --git a/Documentation/x86/mds.rst b/Documentation/x86/mds.rst
+index 87ce8ac9f36e..3d6f943f1afb 100644
+--- a/Documentation/x86/mds.rst
++++ b/Documentation/x86/mds.rst
+@@ -93,11 +93,38 @@ The kernel provides a function to invoke the buffer clearing:
+ The mitigation is invoked on kernel/userspace, hypervisor/guest and C-state
+ (idle) transitions.
+
++As a special quirk to address virtualization scenarios where the host has
++the microcode updated, but the hypervisor does not (yet) expose the
++MD_CLEAR CPUID bit to guests, the kernel issues the VERW instruction in the
++hope that it might actually clear the buffers. The state is reflected
++accordingly.
++
+ According to current knowledge additional mitigations inside the kernel
+ itself are not required because the necessary gadgets to expose the leaked
+ data cannot be controlled in a way which allows exploitation from malicious
+ user space or VM guests.
+
++Kernel internal mitigation modes
++--------------------------------
++
++ ======= ============================================================
++ off Mitigation is disabled. Either the CPU is not affected or
++ mds=off is supplied on the kernel command line
++
++ full Mitigation is eanbled. CPU is affected and MD_CLEAR is
++ advertised in CPUID.
++
++ vmwerv Mitigation is enabled. CPU is affected and MD_CLEAR is not
++ advertised in CPUID. That is mainly for virtualization
++ scenarios where the host has the updated microcode but the
++ hypervisor does not expose MD_CLEAR in CPUID. It's a best
++ effort approach without guarantee.
++ ======= ============================================================
++
++If the CPU is affected and mds=off is not supplied on the kernel command
++line then the kernel selects the appropriate mitigation mode depending on
++the availability of the MD_CLEAR CPUID bit.
++
+ Mitigation points
+ -----------------
+
+diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
+index 1f0295783325..aca1ef8cc79f 100644
+--- a/arch/x86/include/asm/processor.h
++++ b/arch/x86/include/asm/processor.h
+@@ -995,6 +995,7 @@ extern enum l1tf_mitigations l1tf_mitigation;
+ enum mds_mitigations {
+ MDS_MITIGATION_OFF,
+ MDS_MITIGATION_FULL,
++ MDS_MITIGATION_VMWERV,
+ };
+
+ #endif /* _ASM_X86_PROCESSOR_H */
+diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
+index 7ab16a6ed064..95cda38c8785 100644
+--- a/arch/x86/kernel/cpu/bugs.c
++++ b/arch/x86/kernel/cpu/bugs.c
+@@ -224,7 +224,8 @@ static enum mds_mitigations mds_mitigation __ro_after_init = MDS_MITIGATION_FULL
+
+ static const char * const mds_strings[] = {
+ [MDS_MITIGATION_OFF] = "Vulnerable",
+- [MDS_MITIGATION_FULL] = "Mitigation: Clear CPU buffers"
++ [MDS_MITIGATION_FULL] = "Mitigation: Clear CPU buffers",
++ [MDS_MITIGATION_VMWERV] = "Vulnerable: Clear CPU buffers attempted, no microcode",
+ };
+
+ static void __init mds_select_mitigation(void)
+@@ -235,10 +236,9 @@ static void __init mds_select_mitigation(void)
+ }
+
+ if (mds_mitigation == MDS_MITIGATION_FULL) {
+- if (boot_cpu_has(X86_FEATURE_MD_CLEAR))
+- static_branch_enable(&mds_user_clear);
+- else
+- mds_mitigation = MDS_MITIGATION_OFF;
++ if (!boot_cpu_has(X86_FEATURE_MD_CLEAR))
++ mds_mitigation = MDS_MITIGATION_VMWERV;
++ static_branch_enable(&mds_user_clear);
+ }
+ pr_info("%s\n", mds_strings[mds_mitigation]);
+ }
+@@ -705,8 +705,14 @@ void arch_smt_update(void)
+ break;
+ }
+
+- if (mds_mitigation == MDS_MITIGATION_FULL)
++ switch (mds_mitigation) {
++ case MDS_MITIGATION_FULL:
++ case MDS_MITIGATION_VMWERV:
+ update_mds_branch_idle();
++ break;
++ case MDS_MITIGATION_OFF:
++ break;
++ }
+
+ mutex_unlock(&spec_ctrl_mutex);
+ }
+
diff --git a/patches.arch/x86-speculation-mds-add-mitigations-support-for-mds.patch b/patches.arch/x86-speculation-mds-add-mitigations-support-for-mds.patch
new file mode 100644
index 0000000000..4405b7c895
--- /dev/null
+++ b/patches.arch/x86-speculation-mds-add-mitigations-support-for-mds.patch
@@ -0,0 +1,62 @@
+From: Josh Poimboeuf <jpoimboe@redhat.com>
+Date: Wed, 17 Apr 2019 16:39:02 -0500
+Subject: x86/speculation/mds: Add 'mitigations=' support for MDS
+Git-repo: tip/tip
+Git-commit: 5c14068f87d04adc73ba3f41c2a303d3c3d1fa12
+Patch-mainline: Queued in a subsystem tree
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+Add MDS to the new 'mitigations=' cmdline option.
+
+Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ Documentation/admin-guide/kernel-parameters.txt | 2 ++
+ arch/x86/kernel/cpu/bugs.c | 5 +++--
+ 2 files changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
+index 9aa3543a8723..18cad2b0392a 100644
+--- a/Documentation/admin-guide/kernel-parameters.txt
++++ b/Documentation/admin-guide/kernel-parameters.txt
+@@ -2556,6 +2556,7 @@
+ spectre_v2_user=off [X86]
+ spec_store_bypass_disable=off [X86,PPC]
+ l1tf=off [X86]
++ mds=off [X86]
+
+ auto (default)
+ Mitigate all CPU vulnerabilities, but leave SMT
+@@ -2570,6 +2571,7 @@
+ if needed. This is for users who always want to
+ be fully mitigated, even if it means losing SMT.
+ Equivalent to: l1tf=flush,nosmt [X86]
++ mds=full,nosmt [X86]
+
+ mminit_loglevel=
+ [KNL] When CONFIG_DEBUG_MEMORY_INIT is set, this
+diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
+index 3c5c3c3ba734..667c273a66d7 100644
+--- a/arch/x86/kernel/cpu/bugs.c
++++ b/arch/x86/kernel/cpu/bugs.c
+@@ -233,7 +233,7 @@ static const char * const mds_strings[] = {
+
+ static void __init mds_select_mitigation(void)
+ {
+- if (!boot_cpu_has_bug(X86_BUG_MDS)) {
++ if (!boot_cpu_has_bug(X86_BUG_MDS) || cpu_mitigations_off()) {
+ mds_mitigation = MDS_MITIGATION_OFF;
+ return;
+ }
+@@ -244,7 +244,8 @@ static void __init mds_select_mitigation(void)
+
+ static_branch_enable(&mds_user_clear);
+
+- if (mds_nosmt && !boot_cpu_has(X86_BUG_MSBDS_ONLY))
++ if (!boot_cpu_has(X86_BUG_MSBDS_ONLY) &&
++ (mds_nosmt || cpu_mitigations_auto_nosmt()))
+ cpu_smt_disable(false);
+ }
+
+
diff --git a/patches.arch/x86-speculation-mds-add-smt-warning-message.patch b/patches.arch/x86-speculation-mds-add-smt-warning-message.patch
new file mode 100644
index 0000000000..0ba3c2f544
--- /dev/null
+++ b/patches.arch/x86-speculation-mds-add-smt-warning-message.patch
@@ -0,0 +1,50 @@
+From: Josh Poimboeuf <jpoimboe@redhat.com>
+Date: Tue, 2 Apr 2019 10:00:51 -0500
+Subject: x86/speculation/mds: Add SMT warning message
+Git-commit: 39226ef02bfb43248b7db12a4fdccb39d95318e3
+Git-repo: tip/tip
+Patch-mainline: Queued in a subsystem tree
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+MDS is vulnerable with SMT. Make that clear with a one-time printk
+whenever SMT first gets enabled.
+
+Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Tyler Hicks <tyhicks@canonical.com>
+Acked-by: Jiri Kosina <jkosina@suse.cz>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ arch/x86/kernel/cpu/bugs.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+--- a/arch/x86/kernel/cpu/bugs.c
++++ b/arch/x86/kernel/cpu/bugs.c
+@@ -800,6 +800,9 @@ static void update_indir_branch_cond(voi
+ static_branch_disable(&switch_to_cond_stibp);
+ }
+
++#undef pr_fmt
++#define pr_fmt(fmt) fmt
++
+ /* Update the static key controlling the MDS CPU buffer clear in idle */
+ static void update_mds_branch_idle(void)
+ {
+@@ -820,6 +823,8 @@ static void update_mds_branch_idle(void)
+ static_branch_disable(&mds_idle_clear);
+ }
+
++#define MDS_MSG_SMT "MDS CPU bug present and SMT on, data leak possible. See https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/mds.html for more details.\n"
++
+ void arch_smt_update(void)
+ {
+ /* Enhanced IBRS implies STIBP. No update required. */
+@@ -843,6 +848,8 @@ void arch_smt_update(void)
+ switch (mds_mitigation) {
+ case MDS_MITIGATION_FULL:
+ case MDS_MITIGATION_VMWERV:
++ if (sched_smt_active() && !boot_cpu_has(X86_BUG_MSBDS_ONLY))
++ pr_warn_once(MDS_MSG_SMT);
+ update_mds_branch_idle();
+ break;
+ case MDS_MITIGATION_OFF:
diff --git a/patches.arch/x86-speculation-mds-add-sysfs-reporting-for-mds.patch b/patches.arch/x86-speculation-mds-add-sysfs-reporting-for-mds.patch
new file mode 100644
index 0000000000..2a1c7ad669
--- /dev/null
+++ b/patches.arch/x86-speculation-mds-add-sysfs-reporting-for-mds.patch
@@ -0,0 +1,120 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Mon, 18 Feb 2019 22:51:43 +0100
+Subject: x86/speculation/mds: Add sysfs reporting for MDS
+Git-commit: 8a4b06d391b0a42a373808979b5028f5c84d9c6a
+Patch-mainline: v5.1-rc1
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+Add the sysfs reporting file for MDS. It exposes the vulnerability and
+mitigation state similar to the existing files for the other speculative
+hardware vulnerabilities.
+
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Reviewed-by: Borislav Petkov <bp@suse.de>
+Reviewed-by: Jon Masters <jcm@redhat.com>
+Tested-by: Jon Masters <jcm@redhat.com>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ Documentation/ABI/testing/sysfs-devices-system-cpu | 1
+ arch/x86/kernel/cpu/bugs.c | 25 +++++++++++++++++++++
+ drivers/base/cpu.c | 8 ++++++
+ include/linux/cpu.h | 2 +
+ 4 files changed, 36 insertions(+)
+
+--- a/arch/x86/kernel/cpu/bugs.c
++++ b/arch/x86/kernel/cpu/bugs.c
+@@ -1170,6 +1170,22 @@ static ssize_t l1tf_show_state(char *buf
+ }
+ #endif
+
++static ssize_t mds_show_state(char *buf)
++{
++ if (!hypervisor_is_type(X86_HYPER_NATIVE)) {
++ return sprintf(buf, "%s; SMT Host state unknown\n",
++ mds_strings[mds_mitigation]);
++ }
++
++ if (boot_cpu_has(X86_BUG_MSBDS_ONLY)) {
++ return sprintf(buf, "%s; SMT %s\n", mds_strings[mds_mitigation],
++ sched_smt_active() ? "mitigated" : "disabled");
++ }
++
++ return sprintf(buf, "%s; SMT %s\n", mds_strings[mds_mitigation],
++ sched_smt_active() ? "vulnerable" : "disabled");
++}
++
+ static char *stibp_state(void)
+ {
+ if (spectre_v2_enabled == SPECTRE_V2_IBRS_ENHANCED)
+@@ -1236,6 +1252,10 @@ static ssize_t cpu_show_common(struct de
+ return l1tf_show_state(buf);
+ break;
+
++
++ case X86_BUG_MDS:
++ return mds_show_state(buf);
++
+ default:
+ break;
+ }
+@@ -1267,4 +1287,9 @@ ssize_t cpu_show_l1tf(struct device *dev
+ {
+ return cpu_show_common(dev, attr, buf, X86_BUG_L1TF);
+ }
++
++ssize_t cpu_show_mds(struct device *dev, struct device_attribute *attr, char *buf)
++{
++ return cpu_show_common(dev, attr, buf, X86_BUG_MDS);
++}
+ #endif
+--- a/Documentation/ABI/testing/sysfs-devices-system-cpu
++++ b/Documentation/ABI/testing/sysfs-devices-system-cpu
+@@ -380,6 +380,7 @@ What: /sys/devices/system/cpu/vulnerabi
+ /sys/devices/system/cpu/vulnerabilities/spectre_v2
+ /sys/devices/system/cpu/vulnerabilities/spec_store_bypass
+ /sys/devices/system/cpu/vulnerabilities/l1tf
++ /sys/devices/system/cpu/vulnerabilities/mds
+ Date: January 2018
+ Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org>
+ Description: Information about CPU vulnerabilities
+--- a/drivers/base/cpu.c
++++ b/drivers/base/cpu.c
+@@ -533,11 +533,18 @@ ssize_t __weak cpu_show_l1tf(struct devi
+ return sprintf(buf, "Not affected\n");
+ }
+
++ssize_t __weak cpu_show_mds(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ return sprintf(buf, "Not affected\n");
++}
++
+ static DEVICE_ATTR(meltdown, 0444, cpu_show_meltdown, NULL);
+ static DEVICE_ATTR(spectre_v1, 0444, cpu_show_spectre_v1, NULL);
+ static DEVICE_ATTR(spectre_v2, 0444, cpu_show_spectre_v2, NULL);
+ static DEVICE_ATTR(spec_store_bypass, 0444, cpu_show_spec_store_bypass, NULL);
+ static DEVICE_ATTR(l1tf, 0444, cpu_show_l1tf, NULL);
++static DEVICE_ATTR(mds, 0444, cpu_show_mds, NULL);
+
+ static struct attribute *cpu_root_vulnerabilities_attrs[] = {
+ &dev_attr_meltdown.attr,
+@@ -545,6 +552,7 @@ static struct attribute *cpu_root_vulner
+ &dev_attr_spectre_v2.attr,
+ &dev_attr_spec_store_bypass.attr,
+ &dev_attr_l1tf.attr,
++ &dev_attr_mds.attr,
+ NULL
+ };
+
+--- a/include/linux/cpu.h
++++ b/include/linux/cpu.h
+@@ -56,6 +56,8 @@ extern ssize_t cpu_show_spec_store_bypas
+ struct device_attribute *attr, char *buf);
+ extern ssize_t cpu_show_l1tf(struct device *dev,
+ struct device_attribute *attr, char *buf);
++extern ssize_t cpu_show_mds(struct device *dev,
++ struct device_attribute *attr, char *buf);
+
+ extern __printf(4, 5)
+ struct device *cpu_device_create(struct device *parent, void *drvdata,
diff --git a/patches.arch/x86-speculation-mds-clear-cpu-buffers-on-exit-to-user.patch b/patches.arch/x86-speculation-mds-clear-cpu-buffers-on-exit-to-user.patch
new file mode 100644
index 0000000000..8501ae91ae
--- /dev/null
+++ b/patches.arch/x86-speculation-mds-clear-cpu-buffers-on-exit-to-user.patch
@@ -0,0 +1,192 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Mon, 18 Feb 2019 23:42:51 +0100
+Subject: x86/speculation/mds: Clear CPU buffers on exit to user
+Git-commit: 04dcbdb8057827b043b3c71aa397c4c63e67d086
+Patch-mainline: v5.1-rc1
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+Add a static key which controls the invocation of the CPU buffer clear
+mechanism on exit to user space and add the call into
+prepare_exit_to_usermode() and do_nmi() right before actually returning.
+
+Add documentation which kernel to user space transition this covers and
+explain why some corner cases are not mitigated.
+
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Reviewed-by: Borislav Petkov <bp@suse.de>
+Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
+Reviewed-by: Jon Masters <jcm@redhat.com>
+Tested-by: Jon Masters <jcm@redhat.com>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ Documentation/x86/mds.rst | 52 +++++++++++++++++++++++++++++++++++
+ arch/x86/entry/common.c | 3 ++
+ arch/x86/include/asm/nospec-branch.h | 13 ++++++++
+ arch/x86/kernel/cpu/bugs.c | 3 ++
+ arch/x86/kernel/nmi.c | 4 ++
+ arch/x86/kernel/traps.c | 8 +++++
+ 6 files changed, 83 insertions(+)
+
+--- a/arch/x86/entry/common.c
++++ b/arch/x86/entry/common.c
+@@ -30,6 +30,7 @@
+ #include <asm/vdso.h>
+ #include <linux/uaccess.h>
+ #include <asm/cpufeature.h>
++#include <asm/nospec-branch.h>
+
+ #define CREATE_TRACE_POINTS
+ #include <trace/events/syscalls.h>
+@@ -208,6 +209,8 @@ __visible inline void prepare_exit_to_us
+ #endif
+
+ user_enter_irqoff();
++
++ mds_user_clear_cpu_buffers();
+ }
+
+ #define SYSCALL_EXIT_WORK_FLAGS \
+--- a/arch/x86/include/asm/nospec-branch.h
++++ b/arch/x86/include/asm/nospec-branch.h
+@@ -318,6 +318,8 @@ DECLARE_STATIC_KEY_FALSE(switch_to_cond_
+ DECLARE_STATIC_KEY_FALSE(switch_mm_cond_ibpb);
+ DECLARE_STATIC_KEY_FALSE(switch_mm_always_ibpb);
+
++DECLARE_STATIC_KEY_FALSE(mds_user_clear);
++
+ #include <asm/segment.h>
+
+ /**
+@@ -343,6 +345,17 @@ static inline void mds_clear_cpu_buffers
+ asm volatile("verw %[ds]" : : [ds] "m" (ds) : "cc");
+ }
+
++/**
++ * mds_user_clear_cpu_buffers - Mitigation for MDS vulnerability
++ *
++ * Clear CPU buffers if the corresponding static key is enabled
++ */
++static inline void mds_user_clear_cpu_buffers(void)
++{
++ if (static_branch_likely(&mds_user_clear))
++ mds_clear_cpu_buffers();
++}
++
+ #endif /* __ASSEMBLY__ */
+
+ /*
+--- a/arch/x86/kernel/cpu/bugs.c
++++ b/arch/x86/kernel/cpu/bugs.c
+@@ -60,6 +60,9 @@ DEFINE_STATIC_KEY_FALSE(switch_mm_cond_i
+ /* Control unconditional IBPB in switch_mm() */
+ DEFINE_STATIC_KEY_FALSE(switch_mm_always_ibpb);
+
++/* Control MDS CPU buffer clear before returning to user space */
++DEFINE_STATIC_KEY_FALSE(mds_user_clear);
++
+ void __init check_bugs(void)
+ {
+ identify_boot_cpu();
+--- a/arch/x86/kernel/nmi.c
++++ b/arch/x86/kernel/nmi.c
+@@ -34,6 +34,7 @@
+ #include <asm/x86_init.h>
+ #include <asm/reboot.h>
+ #include <asm/cache.h>
++#include <asm/nospec-branch.h>
+
+ #define CREATE_TRACE_POINTS
+ #include <trace/events/nmi.h>
+@@ -533,6 +534,9 @@ nmi_restart:
+ write_cr2(this_cpu_read(nmi_cr2));
+ if (this_cpu_dec_return(nmi_state))
+ goto nmi_restart;
++
++ if (user_mode(regs))
++ mds_user_clear_cpu_buffers();
+ }
+ NOKPROBE_SYMBOL(do_nmi);
+
+--- a/arch/x86/kernel/traps.c
++++ b/arch/x86/kernel/traps.c
+@@ -59,6 +59,7 @@
+ #include <asm/alternative.h>
+ #include <asm/fpu/xstate.h>
+ #include <asm/trace/mpx.h>
++#include <asm/nospec-branch.h>
+ #include <asm/mpx.h>
+ #include <asm/vm86.h>
+
+@@ -393,6 +394,13 @@ dotraplinkage void do_double_fault(struc
+ regs->ip = (unsigned long)general_protection;
+ regs->sp = (unsigned long)&gpregs->orig_ax;
+
++ /*
++ * This situation can be triggered by userspace via
++ * modify_ldt(2) and the return does not take the regular
++ * user space exit, so a CPU buffer clear is required when
++ * MDS mitigation is enabled.
++ */
++ mds_user_clear_cpu_buffers();
+ return;
+ }
+ #endif
+--- a/Documentation/x86/mds.rst
++++ b/Documentation/x86/mds.rst
+@@ -97,3 +97,55 @@ According to current knowledge additiona
+ itself are not required because the necessary gadgets to expose the leaked
+ data cannot be controlled in a way which allows exploitation from malicious
+ user space or VM guests.
++
++Mitigation points
++-----------------
++
++1. Return to user space
++^^^^^^^^^^^^^^^^^^^^^^^
++
++ When transitioning from kernel to user space the CPU buffers are flushed
++ on affected CPUs when the mitigation is not disabled on the kernel
++ command line. The migitation is enabled through the static key
++ mds_user_clear.
++
++ The mitigation is invoked in prepare_exit_to_usermode() which covers
++ most of the kernel to user space transitions. There are a few exceptions
++ which are not invoking prepare_exit_to_usermode() on return to user
++ space. These exceptions use the paranoid exit code.
++
++ - Non Maskable Interrupt (NMI):
++
++ Access to sensible data like keys, credentials in the NMI context is
++ mostly theoretical: The CPU can do prefetching or execute a
++ misspeculated code path and thereby fetching data which might end up
++ leaking through a buffer.
++
++ But for mounting other attacks the kernel stack address of the task is
++ already valuable information. So in full mitigation mode, the NMI is
++ mitigated on the return from do_nmi() to provide almost complete
++ coverage.
++
++ - Double fault (#DF):
++
++ A double fault is usually fatal, but the ESPFIX workaround, which can
++ be triggered from user space through modify_ldt(2) is a recoverable
++ double fault. #DF uses the paranoid exit path, so explicit mitigation
++ in the double fault handler is required.
++
++ - Machine Check Exception (#MC):
++
++ Another corner case is a #MC which hits between the CPU buffer clear
++ invocation and the actual return to user. As this still is in kernel
++ space it takes the paranoid exit path which does not clear the CPU
++ buffers. So the #MC handler repopulates the buffers to some
++ extent. Machine checks are not reliably controllable and the window is
++ extremly small so mitigation would just tick a checkbox that this
++ theoretical corner case is covered. To keep the amount of special
++ cases small, ignore #MC.
++
++ - Debug Exception (#DB):
++
++ This takes the paranoid exit path only when the INT1 breakpoint is in
++ kernel space. #DB on a user space address takes the regular exit path,
++ so no extra mitigation required.
diff --git a/patches.arch/x86-speculation-mds-conditionally-clear-cpu-buffers-on-idle-entry.patch b/patches.arch/x86-speculation-mds-conditionally-clear-cpu-buffers-on-idle-entry.patch
new file mode 100644
index 0000000000..e55065d925
--- /dev/null
+++ b/patches.arch/x86-speculation-mds-conditionally-clear-cpu-buffers-on-idle-entry.patch
@@ -0,0 +1,224 @@
+From: Thomas Gleixner <tglx@linutronix.de>
+Date: Mon, 18 Feb 2019 23:04:01 +0100
+Subject: x86/speculation/mds: Conditionally clear CPU buffers on idle entry
+Git-commit: 07f07f55a29cb705e221eda7894dd67ab81ef343
+Patch-mainline: v5.1-rc1
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+Add a static key which controls the invocation of the CPU buffer clear
+mechanism on idle entry. This is independent of other MDS mitigations
+because the idle entry invocation to mitigate the potential leakage due to
+store buffer repartitioning is only necessary on SMT systems.
+
+Add the actual invocations to the different halt/mwait variants which
+covers all usage sites. mwaitx is not patched as it's not available on
+Intel CPUs.
+
+The buffer clear is only invoked before entering the C-State to prevent
+that stale data from the idling CPU is spilled to the Hyper-Thread sibling
+after the Store buffer got repartitioned and all entries are available to
+the non idle sibling.
+
+When coming out of idle the store buffer is partitioned again so each
+sibling has half of it available. Now CPU which returned from idle could be
+speculatively exposed to contents of the sibling, but the buffers are
+flushed either on exit to user space or on VMENTER.
+
+When later on conditional buffer clearing is implemented on top of this,
+then there is no action required either because before returning to user
+space the context switch will set the condition flag which causes a flush
+on the return to user path.
+
+Note, that the buffer clearing on idle is only sensible on CPUs which are
+solely affected by MSBDS and not any other variant of MDS because the other
+MDS variants cannot be mitigated when SMT is enabled, so the buffer
+clearing on idle would be a window dressing exercise.
+
+This intentionally does not handle the case in the acpi/processor_idle
+driver which uses the legacy IO port interface for C-State transitions for
+two reasons:
+
+ - The acpi/processor_idle driver was replaced by the intel_idle driver
+ almost a decade ago. Anything Nehalem upwards supports it and defaults
+ to that new driver.
+
+ - The legacy IO port interface is likely to be used on older and therefore
+ unaffected CPUs or on systems which do not receive microcode updates
+ anymore, so there is no point in adding that.
+
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Borislav Petkov <bp@suse.de>
+Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
+Reviewed-by: Jon Masters <jcm@redhat.com>
+Tested-by: Jon Masters <jcm@redhat.com>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ Documentation/x86/mds.rst | 42 ++++++++++++++++++++++++++++++++++++
+ arch/x86/include/asm/irqflags.h | 4 ++++
+ arch/x86/include/asm/mwait.h | 7 ++++++
+ arch/x86/include/asm/nospec-branch.h | 12 +++++++++++
+ arch/x86/kernel/cpu/bugs.c | 3 +++
+ 5 files changed, 68 insertions(+)
+
+diff --git a/Documentation/x86/mds.rst b/Documentation/x86/mds.rst
+index 54d935bf283b..87ce8ac9f36e 100644
+--- a/Documentation/x86/mds.rst
++++ b/Documentation/x86/mds.rst
+@@ -149,3 +149,45 @@ Mitigation points
+ This takes the paranoid exit path only when the INT1 breakpoint is in
+ kernel space. #DB on a user space address takes the regular exit path,
+ so no extra mitigation required.
++
++
++2. C-State transition
++^^^^^^^^^^^^^^^^^^^^^
++
++ When a CPU goes idle and enters a C-State the CPU buffers need to be
++ cleared on affected CPUs when SMT is active. This addresses the
++ repartitioning of the store buffer when one of the Hyper-Threads enters
++ a C-State.
++
++ When SMT is inactive, i.e. either the CPU does not support it or all
++ sibling threads are offline CPU buffer clearing is not required.
++
++ The idle clearing is enabled on CPUs which are only affected by MSBDS
++ and not by any other MDS variant. The other MDS variants cannot be
++ protected against cross Hyper-Thread attacks because the Fill Buffer and
++ the Load Ports are shared. So on CPUs affected by other variants, the
++ idle clearing would be a window dressing exercise and is therefore not
++ activated.
++
++ The invocation is controlled by the static key mds_idle_clear which is
++ switched depending on the chosen mitigation mode and the SMT state of
++ the system.
++
++ The buffer clear is only invoked before entering the C-State to prevent
++ that stale data from the idling CPU from spilling to the Hyper-Thread
++ sibling after the store buffer got repartitioned and all entries are
++ available to the non idle sibling.
++
++ When coming out of idle the store buffer is partitioned again so each
++ sibling has half of it available. The back from idle CPU could be then
++ speculatively exposed to contents of the sibling. The buffers are
++ flushed either on exit to user space or on VMENTER so malicious code
++ in user space or the guest cannot speculatively access them.
++
++ The mitigation is hooked into all variants of halt()/mwait(), but does
++ not cover the legacy ACPI IO-Port mechanism because the ACPI idle driver
++ has been superseded by the intel_idle driver around 2010 and is
++ preferred on all affected CPUs which are expected to gain the MD_CLEAR
++ functionality in microcode. Aside of that the IO-Port mechanism is a
++ legacy interface which is only used on older systems which are either
++ not affected or do not receive microcode updates anymore.
+diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
+index 058e40fed167..8a0e56e1dcc9 100644
+--- a/arch/x86/include/asm/irqflags.h
++++ b/arch/x86/include/asm/irqflags.h
+@@ -6,6 +6,8 @@
+
+ #ifndef __ASSEMBLY__
+
++#include <asm/nospec-branch.h>
++
+ /* Provide __cpuidle; we can't safely include <linux/cpu.h> */
+ #define __cpuidle __attribute__((__section__(".cpuidle.text")))
+
+@@ -54,11 +56,13 @@ static inline void native_irq_enable(void)
+
+ static inline __cpuidle void native_safe_halt(void)
+ {
++ mds_idle_clear_cpu_buffers();
+ asm volatile("sti; hlt": : :"memory");
+ }
+
+ static inline __cpuidle void native_halt(void)
+ {
++ mds_idle_clear_cpu_buffers();
+ asm volatile("hlt": : :"memory");
+ }
+
+diff --git a/arch/x86/include/asm/mwait.h b/arch/x86/include/asm/mwait.h
+index 39a2fb29378a..eb0f80ce8524 100644
+--- a/arch/x86/include/asm/mwait.h
++++ b/arch/x86/include/asm/mwait.h
+@@ -6,6 +6,7 @@
+ #include <linux/sched/idle.h>
+
+ #include <asm/cpufeature.h>
++#include <asm/nospec-branch.h>
+
+ #define MWAIT_SUBSTATE_MASK 0xf
+ #define MWAIT_CSTATE_MASK 0xf
+@@ -40,6 +41,8 @@ static inline void __monitorx(const void *eax, unsigned long ecx,
+
+ static inline void __mwait(unsigned long eax, unsigned long ecx)
+ {
++ mds_idle_clear_cpu_buffers();
++
+ /* "mwait %eax, %ecx;" */
+ asm volatile(".byte 0x0f, 0x01, 0xc9;"
+ :: "a" (eax), "c" (ecx));
+@@ -74,6 +77,8 @@ static inline void __mwait(unsigned long eax, unsigned long ecx)
+ static inline void __mwaitx(unsigned long eax, unsigned long ebx,
+ unsigned long ecx)
+ {
++ /* No MDS buffer clear as this is AMD/HYGON only */
++
+ /* "mwaitx %eax, %ebx, %ecx;" */
+ asm volatile(".byte 0x0f, 0x01, 0xfb;"
+ :: "a" (eax), "b" (ebx), "c" (ecx));
+@@ -81,6 +86,8 @@ static inline void __mwaitx(unsigned long eax, unsigned long ebx,
+
+ static inline void __sti_mwait(unsigned long eax, unsigned long ecx)
+ {
++ mds_idle_clear_cpu_buffers();
++
+ trace_hardirqs_on();
+ /* "mwait %eax, %ecx;" */
+ asm volatile("sti; .byte 0x0f, 0x01, 0xc9;"
+diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
+index 65b747286d96..4e970390110f 100644
+--- a/arch/x86/include/asm/nospec-branch.h
++++ b/arch/x86/include/asm/nospec-branch.h
+@@ -319,6 +319,7 @@ DECLARE_STATIC_KEY_FALSE(switch_mm_cond_ibpb);
+ DECLARE_STATIC_KEY_FALSE(switch_mm_always_ibpb);
+
+ DECLARE_STATIC_KEY_FALSE(mds_user_clear);
++DECLARE_STATIC_KEY_FALSE(mds_idle_clear);
+
+ #include <asm/segment.h>
+
+@@ -356,6 +357,17 @@ static inline void mds_user_clear_cpu_buffers(void)
+ mds_clear_cpu_buffers();
+ }
+
++/**
++ * mds_idle_clear_cpu_buffers - Mitigation for MDS vulnerability
++ *
++ * Clear CPU buffers if the corresponding static key is enabled
++ */
++static inline void mds_idle_clear_cpu_buffers(void)
++{
++ if (static_branch_likely(&mds_idle_clear))
++ mds_clear_cpu_buffers();
++}
++
+ #endif /* __ASSEMBLY__ */
+
+ /*
+diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
+index 29ed8e8dfee2..916995167301 100644
+--- a/arch/x86/kernel/cpu/bugs.c
++++ b/arch/x86/kernel/cpu/bugs.c
+@@ -66,6 +66,9 @@ DEFINE_STATIC_KEY_FALSE(switch_mm_always_ibpb);
+ /* Control MDS CPU buffer clear before returning to user space */
+ DEFINE_STATIC_KEY_FALSE(mds_user_clear);
+ EXPORT_SYMBOL_GPL(mds_user_clear);
++/* Control MDS CPU buffer clear before idling (halt, mwait) */
++DEFINE_STATIC_KEY_FALSE(mds_idle_clear);
++EXPORT_SYMBOL_GPL(mds_idle_clear);
+
+ void __init check_bugs(void)
+ {
+
diff --git a/patches.arch/x86-speculation-mds-print-smt-vulnerable-on-msbds-with-mitigations-off.patch b/patches.arch/x86-speculation-mds-print-smt-vulnerable-on-msbds-with-mitigations-off.patch
new file mode 100644
index 0000000000..c9762dddd2
--- /dev/null
+++ b/patches.arch/x86-speculation-mds-print-smt-vulnerable-on-msbds-with-mitigations-off.patch
@@ -0,0 +1,49 @@
+From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
+Date: Fri, 12 Apr 2019 17:50:58 -0400
+Subject: x86/speculation/mds: Print SMT vulnerable on MSBDS with mitigations off
+Git-repo: tip/tip
+Git-commit: e2c3c94788b08891dcf3dbe608f9880523ecd71b
+Patch-mainline: Queued in a subsystem tree
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+This code is only for CPUs which are affected by MSBDS, but are *not*
+affected by the other two MDS issues.
+
+For such CPUs, enabling the mds_idle_clear mitigation is enough to
+mitigate SMT.
+
+However if user boots with 'mds=off' and still has SMT enabled, we should
+not report that SMT is mitigated:
+
+$cat /sys//devices/system/cpu/vulnerabilities/mds
+Vulnerable; SMT mitigated
+
+But rather:
+Vulnerable; SMT vulnerable
+
+Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Tyler Hicks <tyhicks@canonical.com>
+Reviewed-by: Josh Poimboeuf <jpoimboe@redhat.com>
+Link: https://lkml.kernel.org/r/20190412215118.294906495@localhost.localdomain
+
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ arch/x86/kernel/cpu/bugs.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
+index 0642505dda69..6b8a55c7cebc 100644
+--- a/arch/x86/kernel/cpu/bugs.c
++++ b/arch/x86/kernel/cpu/bugs.c
+@@ -1204,7 +1204,8 @@ static ssize_t mds_show_state(char *buf)
+
+ if (boot_cpu_has(X86_BUG_MSBDS_ONLY)) {
+ return sprintf(buf, "%s; SMT %s\n", mds_strings[mds_mitigation],
+- sched_smt_active() ? "mitigated" : "disabled");
++ (mds_mitigation == MDS_MITIGATION_OFF ? "vulnerable" :
++ sched_smt_active() ? "mitigated" : "disabled"));
+ }
+
+ return sprintf(buf, "%s; SMT %s\n", mds_strings[mds_mitigation],
+
diff --git a/patches.arch/x86-speculation-move-arch_smt_update-call-to-after-mitigation-decisions.patch b/patches.arch/x86-speculation-move-arch_smt_update-call-to-after-mitigation-decisions.patch
new file mode 100644
index 0000000000..cfcda3d0e4
--- /dev/null
+++ b/patches.arch/x86-speculation-move-arch_smt_update-call-to-after-mitigation-decisions.patch
@@ -0,0 +1,45 @@
+From: Josh Poimboeuf <jpoimboe@redhat.com>
+Date: Tue, 2 Apr 2019 10:00:14 -0500
+Subject: x86/speculation: Move arch_smt_update() call to after mitigation decisions
+Git-repo: tip/tip
+Git-commit: 7c3658b20194a5b3209a143f63bc9c643c6a3ae2
+Patch-mainline: Queued in a subsystem tree
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+arch_smt_update() now has a dependency on both Spectre v2 and MDS
+mitigations. Move its initial call to after all the mitigation decisions
+have been made.
+
+Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Reviewed-by: Tyler Hicks <tyhicks@canonical.com>
+Acked-by: Jiri Kosina <jkosina@suse.cz>
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ arch/x86/kernel/cpu/bugs.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
+index 9f252082a83b..3f934ffef8cf 100644
+--- a/arch/x86/kernel/cpu/bugs.c
++++ b/arch/x86/kernel/cpu/bugs.c
+@@ -111,6 +111,8 @@ void __init check_bugs(void)
+
+ mds_select_mitigation();
+
++ arch_smt_update();
++
+ #ifdef CONFIG_X86_32
+ /*
+ * Check whether we are able to run this kernel safely on SMP.
+@@ -638,9 +640,6 @@ static void __init spectre_v2_select_mitigation(void)
+
+ /* Set up IBPB and STIBP depending on the general spectre V2 command */
+ spectre_v2_user_select_mitigation(cmd);
+-
+- /* Enable STIBP if appropriate */
+- arch_smt_update();
+ }
+
+ static void update_stibp_msr(void * __unused)
+
diff --git a/patches.arch/x86-speculation-simplify-the-cpu-bug-detection-logic.patch b/patches.arch/x86-speculation-simplify-the-cpu-bug-detection-logic.patch
new file mode 100644
index 0000000000..2ca003db81
--- /dev/null
+++ b/patches.arch/x86-speculation-simplify-the-cpu-bug-detection-logic.patch
@@ -0,0 +1,84 @@
+From: Dominik Brodowski <linux@dominikbrodowski.net>
+Date: Tue, 22 May 2018 11:05:39 +0200
+Subject: x86/speculation: Simplify the CPU bug detection logic
+Git-commit: 8ecc4979b1bd9c94168e6fc92960033b7a951336
+Patch-mainline: v4.17-rc7
+References: bsc#1111331, CVE-2018-12126, CVE-2018-12127, CVE-2018-12130
+
+Only CPUs which speculate can speculate. Therefore, it seems prudent
+to test for cpu_no_speculation first and only then determine whether
+a specific speculating CPU is susceptible to store bypass speculation.
+This is underlined by all CPUs currently listed in cpu_no_speculation
+were present in cpu_no_spec_store_bypass as well.
+
+Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
+Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
+Cc: bp@suse.de
+Cc: konrad.wilk@oracle.com
+Link: https://lkml.kernel.org/r/20180522090539.GA24668@light.dominikbrodowski.net
+
+Acked-by: Borislav Petkov <bp@suse.de>
+---
+ arch/x86/kernel/cpu/common.c | 22 +++++++---------------
+ 1 file changed, 7 insertions(+), 15 deletions(-)
+
+diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
+index 78decc3e3067..38276f58d3bf 100644
+--- a/arch/x86/kernel/cpu/common.c
++++ b/arch/x86/kernel/cpu/common.c
+@@ -942,12 +942,8 @@ static const __initconst struct x86_cpu_id cpu_no_meltdown[] = {
+ {}
+ };
+
++/* Only list CPUs which speculate but are non susceptible to SSB */
+ static const __initconst struct x86_cpu_id cpu_no_spec_store_bypass[] = {
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_PINEVIEW },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_LINCROFT },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_PENWELL },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_CLOVERVIEW },
+- { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_CEDARVIEW },
+ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT1 },
+ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_AIRMONT },
+ { X86_VENDOR_INTEL, 6, INTEL_FAM6_ATOM_SILVERMONT2 },
+@@ -955,14 +951,10 @@ static const __initconst struct x86_cpu_id cpu_no_spec_store_bypass[] = {
+ { X86_VENDOR_INTEL, 6, INTEL_FAM6_CORE_YONAH },
+ { X86_VENDOR_INTEL, 6, INTEL_FAM6_XEON_PHI_KNL },
+ { X86_VENDOR_INTEL, 6, INTEL_FAM6_XEON_PHI_KNM },
+- { X86_VENDOR_CENTAUR, 5, },
+- { X86_VENDOR_INTEL, 5, },
+- { X86_VENDOR_NSC, 5, },
+ { X86_VENDOR_AMD, 0x12, },
+ { X86_VENDOR_AMD, 0x11, },
+ { X86_VENDOR_AMD, 0x10, },
+ { X86_VENDOR_AMD, 0xf, },
+- { X86_VENDOR_ANY, 4, },
+ {}
+ };
+
+@@ -970,6 +962,12 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
+ {
+ u64 ia32_cap = 0;
+
++ if (x86_match_cpu(cpu_no_speculation))
++ return;
++
++ setup_force_cpu_bug(X86_BUG_SPECTRE_V1);
++ setup_force_cpu_bug(X86_BUG_SPECTRE_V2);
++
+ if (cpu_has(c, X86_FEATURE_ARCH_CAPABILITIES))
+ rdmsrl(MSR_IA32_ARCH_CAPABILITIES, ia32_cap);
+
+@@ -977,12 +975,6 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
+ !(ia32_cap & ARCH_CAP_SSB_NO))
+ setup_force_cpu_bug(X86_BUG_SPEC_STORE_BYPASS);
+
+- if (x86_match_cpu(cpu_no_speculation))
+- return;
+-
+- setup_force_cpu_bug(X86_BUG_SPECTRE_V1);
+- setup_force_cpu_bug(X86_BUG_SPECTRE_V2);
+-
+ if (x86_match_cpu(cpu_no_meltdown))
+ return;
+
+
diff --git a/patches.arch/x86-speculation-support-enhanced-ibrs-on-future-cpus.patch b/patches.arch/x86-speculation-support-enhanced-ibrs-on-future-cpus.patch
index e0333fec19..6a78531142 100644
--- a/patches.arch/x86-speculation-support-enhanced-ibrs-on-future-cpus.patch
+++ b/patches.arch/x86-speculation-support-enhanced-ibrs-on-future-cpus.patch
@@ -95,7 +95,7 @@ Acked-by: Borislav Petkov <bp@suse.de>
};
#undef pr_fmt
-@@ -347,6 +348,13 @@ static void __init spectre_v2_select_mit
+@@ -348,6 +349,13 @@ static void __init spectre_v2_select_mit
case SPECTRE_V2_CMD_FORCE:
case SPECTRE_V2_CMD_AUTO:
@@ -109,7 +109,7 @@ Acked-by: Borislav Petkov <bp@suse.de>
if (IS_ENABLED(CONFIG_RETPOLINE))
goto retpoline_auto;
break;
-@@ -384,6 +392,7 @@ retpoline_auto:
+@@ -385,6 +393,7 @@ retpoline_auto:
setup_force_cpu_cap(X86_FEATURE_RETPOLINE);
}
@@ -117,7 +117,7 @@ Acked-by: Borislav Petkov <bp@suse.de>
spectre_v2_enabled = mode;
pr_info("%s\n", spectre_v2_strings[mode]);
-@@ -406,9 +415,16 @@ retpoline_auto:
+@@ -407,9 +416,16 @@ retpoline_auto:
/*
* Retpoline means the kernel is safe because it has no indirect
@@ -138,9 +138,9 @@ Acked-by: Borislav Petkov <bp@suse.de>
}
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
-@@ -957,6 +957,9 @@ static void __init cpu_set_bug_bits(stru
- setup_force_cpu_bug(X86_BUG_SPECTRE_V1);
- setup_force_cpu_bug(X86_BUG_SPECTRE_V2);
+@@ -956,6 +956,9 @@ static void __init cpu_set_bug_bits(stru
+ !cpu_has(c, X86_FEATURE_AMD_SSB_NO))
+ setup_force_cpu_bug(X86_BUG_SPEC_STORE_BYPASS);
+ if (ia32_cap & ARCH_CAP_IBRS_ALL)
+ setup_force_cpu_cap(X86_FEATURE_IBRS_ENHANCED);
diff --git a/patches.drivers/ALSA-core-Don-t-refer-to-snd_cards-array-directly.patch b/patches.drivers/ALSA-core-Don-t-refer-to-snd_cards-array-directly.patch
new file mode 100644
index 0000000000..46a76ed964
--- /dev/null
+++ b/patches.drivers/ALSA-core-Don-t-refer-to-snd_cards-array-directly.patch
@@ -0,0 +1,181 @@
+From f4fa968950aef7efb98a0899bb0132405e2edaf1 Mon Sep 17 00:00:00 2001
+From: Takashi Iwai <tiwai@suse.de>
+Date: Tue, 16 Apr 2019 18:18:47 +0200
+Subject: [PATCH] ALSA: core: Don't refer to snd_cards array directly
+Git-commit: f4fa968950aef7efb98a0899bb0132405e2edaf1
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+The snd_cards[] array holds the card pointers that have been currently
+registered, and it's exported for the external modules that may need
+to refer a card object. But accessing to this array can be racy
+against the driver probe or removal, as the card registration or free
+may happen concurrently.
+
+This patch gets rid of the direct access to snd_cards[] array and
+provides a helper function to give the card object from the index
+number with a refcount management. Then the caller can access to the
+given card object safely, and releases it via snd_card_unref().
+
+While we're at it, add a proper comment to snd_card_unref() and make
+it an inlined function for type-safety, too.
+
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ include/sound/core.h | 16 ++++++++++++++--
+ sound/core/init.c | 23 +++++++++++++++++++++--
+ sound/core/oss/mixer_oss.c | 16 ++++++++++++----
+ sound/core/sound.c | 5 ++++-
+ sound/last.c | 10 +++++++---
+ 5 files changed, 58 insertions(+), 12 deletions(-)
+
+--- a/include/sound/core.h
++++ b/include/sound/core.h
+@@ -241,7 +241,6 @@ int copy_from_user_toio(volatile void __
+
+ /* init.c */
+
+-extern struct snd_card *snd_cards[SNDRV_CARDS];
+ int snd_card_locked(int card);
+ #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE)
+ #define SND_MIXER_OSS_NOTIFY_REGISTER 0
+@@ -265,7 +264,20 @@ int snd_card_add_dev_attr(struct snd_car
+ int snd_component_add(struct snd_card *card, const char *component);
+ int snd_card_file_add(struct snd_card *card, struct file *file);
+ int snd_card_file_remove(struct snd_card *card, struct file *file);
+-#define snd_card_unref(card) put_device(&(card)->card_dev)
++
++struct snd_card *snd_card_ref(int card);
++
++/**
++ * snd_card_unref - Unreference the card object
++ * @card: the card object to unreference
++ *
++ * Call this function for the card object that was obtained via snd_card_ref()
++ * or snd_lookup_minor_data().
++ */
++static inline void snd_card_unref(struct snd_card *card)
++{
++ put_device(&card->card_dev);
++}
+
+ #define snd_card_set_dev(card, devptr) ((card)->dev = (devptr))
+
+--- a/sound/core/init.c
++++ b/sound/core/init.c
+@@ -49,8 +49,7 @@ static const struct file_operations snd_
+
+ /* locked for registering/using */
+ static DECLARE_BITMAP(snd_cards_lock, SNDRV_CARDS);
+-struct snd_card *snd_cards[SNDRV_CARDS];
+-EXPORT_SYMBOL(snd_cards);
++static struct snd_card *snd_cards[SNDRV_CARDS];
+
+ static DEFINE_MUTEX(snd_card_mutex);
+
+@@ -294,6 +293,26 @@ int snd_card_new(struct device *parent,
+ }
+ EXPORT_SYMBOL(snd_card_new);
+
++/**
++ * snd_card_ref - Get the card object from the index
++ * @idx: the card index
++ *
++ * Returns a card object corresponding to the given index or NULL if not found.
++ * Release the object via snd_card_unref().
++ */
++struct snd_card *snd_card_ref(int idx)
++{
++ struct snd_card *card;
++
++ mutex_lock(&snd_card_mutex);
++ card = snd_cards[idx];
++ if (card)
++ get_device(&card->card_dev);
++ mutex_unlock(&snd_card_mutex);
++ return card;
++}
++EXPORT_SYMBOL_GPL(snd_card_ref);
++
+ /* return non-zero if a card is already locked */
+ int snd_card_locked(int card)
+ {
+--- a/sound/core/oss/mixer_oss.c
++++ b/sound/core/oss/mixer_oss.c
+@@ -1402,24 +1402,32 @@ static int snd_mixer_oss_notify_handler(
+
+ static int __init alsa_mixer_oss_init(void)
+ {
++ struct snd_card *card;
+ int idx;
+
+ snd_mixer_oss_notify_callback = snd_mixer_oss_notify_handler;
+ for (idx = 0; idx < SNDRV_CARDS; idx++) {
+- if (snd_cards[idx])
+- snd_mixer_oss_notify_handler(snd_cards[idx], SND_MIXER_OSS_NOTIFY_REGISTER);
++ card = snd_card_ref(idx);
++ if (card) {
++ snd_mixer_oss_notify_handler(card, SND_MIXER_OSS_NOTIFY_REGISTER);
++ snd_card_unref(card);
++ }
+ }
+ return 0;
+ }
+
+ static void __exit alsa_mixer_oss_exit(void)
+ {
++ struct snd_card *card;
+ int idx;
+
+ snd_mixer_oss_notify_callback = NULL;
+ for (idx = 0; idx < SNDRV_CARDS; idx++) {
+- if (snd_cards[idx])
+- snd_mixer_oss_notify_handler(snd_cards[idx], SND_MIXER_OSS_NOTIFY_FREE);
++ card = snd_card_ref(idx);
++ if (card) {
++ snd_mixer_oss_notify_handler(card, SND_MIXER_OSS_NOTIFY_FREE);
++ snd_card_unref(card);
++ }
+ }
+ }
+
+--- a/sound/core/sound.c
++++ b/sound/core/sound.c
+@@ -136,8 +136,11 @@ static struct snd_minor *autoload_device
+ if (dev == SNDRV_MINOR_CONTROL) {
+ /* /dev/aloadC? */
+ int card = SNDRV_MINOR_CARD(minor);
+- if (snd_cards[card] == NULL)
++ struct snd_card *ref = snd_card_ref(card);
++ if (!ref)
+ snd_request_card(card);
++ else
++ snd_card_unref(ref);
+ } else if (dev == SNDRV_MINOR_GLOBAL) {
+ /* /dev/aloadSEQ */
+ snd_request_other(minor);
+--- a/sound/last.c
++++ b/sound/last.c
+@@ -24,14 +24,18 @@
+
+ static int __init alsa_sound_last_init(void)
+ {
++ struct snd_card *card;
+ int idx, ok = 0;
+
+ printk(KERN_INFO "ALSA device list:\n");
+- for (idx = 0; idx < SNDRV_CARDS; idx++)
+- if (snd_cards[idx] != NULL) {
+- printk(KERN_INFO " #%i: %s\n", idx, snd_cards[idx]->longname);
++ for (idx = 0; idx < SNDRV_CARDS; idx++) {
++ card = snd_card_ref(idx);
++ if (card) {
++ printk(KERN_INFO " #%i: %s\n", idx, card->longname);
++ snd_card_unref(card);
+ ok++;
+ }
++ }
+ if (ok == 0)
+ printk(KERN_INFO " No soundcards found.\n");
+ return 0;
diff --git a/patches.drivers/ALSA-emu10k1-Drop-superfluous-id-uniquification-beha.patch b/patches.drivers/ALSA-emu10k1-Drop-superfluous-id-uniquification-beha.patch
new file mode 100644
index 0000000000..506e41c6fc
--- /dev/null
+++ b/patches.drivers/ALSA-emu10k1-Drop-superfluous-id-uniquification-beha.patch
@@ -0,0 +1,50 @@
+From c989954938761a2939a21fcbc768af182de6be58 Mon Sep 17 00:00:00 2001
+From: Takashi Iwai <tiwai@suse.de>
+Date: Tue, 16 Apr 2019 18:01:46 +0200
+Subject: [PATCH] ALSA: emu10k1: Drop superfluous id-uniquification behavior
+Git-commit: c989954938761a2939a21fcbc768af182de6be58
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+The emu10k1 driver tries to create a unique id string by itself when
+it's copied from the card list, but it's rather superfluous, as the
+same thing will be done in ALSA core side at the card registration.
+Let's drop the code. This allows us removing snd_cards export.
+
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ sound/pci/emu10k1/emu10k1_main.c | 16 +---------------
+ 1 file changed, 1 insertion(+), 15 deletions(-)
+
+diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
+index 61f85ff91cd9..0419c75bdf5a 100644
+--- a/sound/pci/emu10k1/emu10k1_main.c
++++ b/sound/pci/emu10k1/emu10k1_main.c
+@@ -1882,22 +1882,8 @@ int snd_emu10k1_create(struct snd_card *card,
+ c->name, pci->vendor, pci->device,
+ emu->serial);
+
+- if (!*card->id && c->id) {
+- int i, n = 0;
++ if (!*card->id && c->id)
+ strlcpy(card->id, c->id, sizeof(card->id));
+- for (;;) {
+- for (i = 0; i < snd_ecards_limit; i++) {
+- if (snd_cards[i] && !strcmp(snd_cards[i]->id, card->id))
+- break;
+- }
+- if (i >= snd_ecards_limit)
+- break;
+- n++;
+- if (n >= SNDRV_CARDS)
+- break;
+- snprintf(card->id, sizeof(card->id), "%s_%d", c->id, n);
+- }
+- }
+
+ is_audigy = emu->audigy = c->emu10k2_chip;
+
+--
+2.16.4
+
diff --git a/patches.drivers/ALSA-seq-Correct-unlock-sequence-at-snd_seq_client_i.patch b/patches.drivers/ALSA-seq-Correct-unlock-sequence-at-snd_seq_client_i.patch
new file mode 100644
index 0000000000..308af2814c
--- /dev/null
+++ b/patches.drivers/ALSA-seq-Correct-unlock-sequence-at-snd_seq_client_i.patch
@@ -0,0 +1,50 @@
+From b5fd12d6c0fc64c2c2b5ae095e63824083d27151 Mon Sep 17 00:00:00 2001
+From: Takashi Iwai <tiwai@suse.de>
+Date: Mon, 15 Apr 2019 09:03:01 +0200
+Subject: [PATCH] ALSA: seq: Correct unlock sequence at snd_seq_client_ioctl_unlock()
+Git-commit: b5fd12d6c0fc64c2c2b5ae095e63824083d27151
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+The doubly unlock sequence at snd_seq_client_ioctl_unlock() is tricky.
+I took a direct unref call since I thought it would avoid
+misunderstanding, but rather this seems more confusing. Let's use
+snd_seq_client_unlock() consistently even if they look strange to be
+called twice, and add more comments for avoiding reader's confusion.
+
+Fixes: 6b580f523172 ("ALSA: seq: Protect racy pool manipulation from OSS sequencer")
+Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ sound/core/seq/seq_clientmgr.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
+index 3acd80e718f2..c0227a672442 100644
+--- a/sound/core/seq/seq_clientmgr.c
++++ b/sound/core/seq/seq_clientmgr.c
+@@ -191,6 +191,7 @@ bool snd_seq_client_ioctl_lock(int clientid)
+ if (!client)
+ return false;
+ mutex_lock(&client->ioctl_mutex);
++ /* The client isn't unrefed here; see snd_seq_client_ioctl_unlock() */
+ return true;
+ }
+ EXPORT_SYMBOL_GPL(snd_seq_client_ioctl_lock);
+@@ -204,7 +205,11 @@ void snd_seq_client_ioctl_unlock(int clientid)
+ if (WARN_ON(!client))
+ return;
+ mutex_unlock(&client->ioctl_mutex);
+- snd_use_lock_free(&client->use_lock);
++ /* The doubly unrefs below are intentional; the first one releases the
++ * leftover from snd_seq_client_ioctl_lock() above, and the second one
++ * is for releasing snd_seq_client_use_ptr() in this function
++ */
++ snd_seq_client_unlock(client);
+ snd_seq_client_unlock(client);
+ }
+ EXPORT_SYMBOL_GPL(snd_seq_client_ioctl_unlock);
+--
+2.16.4
+
diff --git a/patches.drivers/ALSA-seq-Protect-racy-pool-manipulation-from-OSS-seq.patch b/patches.drivers/ALSA-seq-Protect-racy-pool-manipulation-from-OSS-seq.patch
new file mode 100644
index 0000000000..2c9eaf349b
--- /dev/null
+++ b/patches.drivers/ALSA-seq-Protect-racy-pool-manipulation-from-OSS-seq.patch
@@ -0,0 +1,132 @@
+From 6b580f523172f2c738b661069a57c23c74a75f88 Mon Sep 17 00:00:00 2001
+From: Takashi Iwai <tiwai@suse.de>
+Date: Fri, 12 Apr 2019 12:44:39 +0200
+Subject: [PATCH] ALSA: seq: Protect racy pool manipulation from OSS sequencer
+Git-commit: 6b580f523172f2c738b661069a57c23c74a75f88
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+OSS sequencer emulation still allows to queue and issue the events
+that manipulate the client pool concurrently in a racy way. This
+patch serializes the access like the normal sequencer write / ioctl
+via taking the client ioctl_mutex. Since the access to the sequencer
+client is done indirectly via a client id number, a new helper to
+take/release the mutex is introduced.
+
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ sound/core/seq/oss/seq_oss_device.h | 10 ++++++++--
+ sound/core/seq/seq_clientmgr.c | 40 ++++++++++++++++++++++++++++++++++---
+ sound/core/seq/seq_clientmgr.h | 4 ++++
+ 3 files changed, 49 insertions(+), 5 deletions(-)
+
+diff --git a/sound/core/seq/oss/seq_oss_device.h b/sound/core/seq/oss/seq_oss_device.h
+index 2d0e9eaf13aa..77eb1fe1155c 100644
+--- a/sound/core/seq/oss/seq_oss_device.h
++++ b/sound/core/seq/oss/seq_oss_device.h
+@@ -30,6 +30,7 @@
+ #include <sound/rawmidi.h>
+ #include <sound/seq_kernel.h>
+ #include <sound/info.h>
++#include "../seq_clientmgr.h"
+
+ /* max. applications */
+ #define SNDRV_SEQ_OSS_MAX_CLIENTS 16
+@@ -150,11 +151,16 @@ snd_seq_oss_dispatch(struct seq_oss_devinfo *dp, struct snd_seq_event *ev, int a
+ return snd_seq_kernel_client_dispatch(dp->cseq, ev, atomic, hop);
+ }
+
+-/* ioctl */
++/* ioctl for writeq */
+ static inline int
+ snd_seq_oss_control(struct seq_oss_devinfo *dp, unsigned int type, void *arg)
+ {
+- return snd_seq_kernel_client_ctl(dp->cseq, type, arg);
++ int err;
++
++ snd_seq_client_ioctl_lock(dp->cseq);
++ err = snd_seq_kernel_client_ctl(dp->cseq, type, arg);
++ snd_seq_client_ioctl_unlock(dp->cseq);
++ return err;
+ }
+
+ /* fill the addresses in header */
+diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
+index 0af5b1440b33..a5c9d59eb5b8 100644
+--- a/sound/core/seq/seq_clientmgr.c
++++ b/sound/core/seq/seq_clientmgr.c
+@@ -179,6 +179,36 @@ struct snd_seq_client *snd_seq_client_use_ptr(int clientid)
+ return client;
+ }
+
++/* Take refcount and perform ioctl_mutex lock on the given client;
++ * used only for OSS sequencer
++ * Unlock via snd_seq_client_ioctl_unlock() below
++ */
++bool snd_seq_client_ioctl_lock(int clientid)
++{
++ struct snd_seq_client *client;
++
++ client = snd_seq_client_use_ptr(clientid);
++ if (!client)
++ return false;
++ mutex_lock(&client->ioctl_mutex);
++ return true;
++}
++EXPORT_SYMBOL_GPL(snd_seq_client_ioctl_lock);
++
++/* Unlock and unref the given client; for OSS sequencer use only */
++void snd_seq_client_ioctl_unlock(int clientid)
++{
++ struct snd_seq_client *client;
++
++ client = snd_seq_client_use_ptr(clientid);
++ if (WARN_ON(!client))
++ return;
++ mutex_unlock(&client->ioctl_mutex);
++ snd_use_lock_free(&client->use_lock);
++ snd_seq_client_unlock(client);
++}
++EXPORT_SYMBOL_GPL(snd_seq_client_ioctl_unlock);
++
+ static void usage_alloc(struct snd_seq_usage *res, int num)
+ {
+ res->cur += num;
+@@ -2247,11 +2277,15 @@ int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev,
+ if (cptr == NULL)
+ return -EINVAL;
+
+- if (! cptr->accept_output)
++ if (!cptr->accept_output) {
+ result = -EPERM;
+- else /* send it */
++ } else { /* send it */
++ mutex_lock(&cptr->ioctl_mutex);
+ result = snd_seq_client_enqueue_event(cptr, ev, file, blocking,
+- false, 0, NULL);
++ false, 0,
++ &cptr->ioctl_mutex);
++ mutex_unlock(&cptr->ioctl_mutex);
++ }
+
+ snd_seq_client_unlock(cptr);
+ return result;
+diff --git a/sound/core/seq/seq_clientmgr.h b/sound/core/seq/seq_clientmgr.h
+index 66ad3d547916..28a51dcc0190 100644
+--- a/sound/core/seq/seq_clientmgr.h
++++ b/sound/core/seq/seq_clientmgr.h
+@@ -97,6 +97,10 @@ int snd_seq_kernel_client_write_poll(int clientid, struct file *file, poll_table
+ int snd_seq_client_notify_subscription(int client, int port,
+ struct snd_seq_port_subscribe *info, int evtype);
+
++/* only for OSS sequencer */
++bool snd_seq_client_ioctl_lock(int clientid);
++void snd_seq_client_ioctl_unlock(int clientid);
++
+ extern int seq_client_load[15];
+
+ #endif
+--
+2.16.4
+
diff --git a/patches.drivers/ALSA-seq-Simplify-snd_seq_kernel_client_enqueue-help.patch b/patches.drivers/ALSA-seq-Simplify-snd_seq_kernel_client_enqueue-help.patch
new file mode 100644
index 0000000000..3d3c8e5cb0
--- /dev/null
+++ b/patches.drivers/ALSA-seq-Simplify-snd_seq_kernel_client_enqueue-help.patch
@@ -0,0 +1,143 @@
+From 6740ea6776e97274627e3c261469d1c4ba0a0cb5 Mon Sep 17 00:00:00 2001
+From: Takashi Iwai <tiwai@suse.de>
+Date: Fri, 12 Apr 2019 12:10:14 +0200
+Subject: [PATCH] ALSA: seq: Simplify snd_seq_kernel_client_enqueue() helper
+Git-commit: 6740ea6776e97274627e3c261469d1c4ba0a0cb5
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+We have two helpers for queuing a sequencer event from the kernel
+client, and both are used only from OSS sequencer layer without any
+hop and atomic set. Let's simplify and unify two helpers into one.
+
+No functional change, just a call pattern change.
+
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ include/sound/seq_kernel.h | 3 +-
+ sound/core/seq/oss/seq_oss_rw.c | 11 +++-------
+ sound/core/seq/oss/seq_oss_writeq.c | 2 -
+ sound/core/seq/seq_clientmgr.c | 39 ++++++------------------------------
+ sound/core/seq/seq_clientmgr.h | 4 ---
+ 5 files changed, 14 insertions(+), 45 deletions(-)
+
+--- a/include/sound/seq_kernel.h
++++ b/include/sound/seq_kernel.h
+@@ -73,7 +73,8 @@ __printf(3, 4)
+ int snd_seq_create_kernel_client(struct snd_card *card, int client_index,
+ const char *name_fmt, ...);
+ int snd_seq_delete_kernel_client(int client);
+-int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, int atomic, int hop);
++int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev,
++ struct file *file, bool blocking);
+ int snd_seq_kernel_client_dispatch(int client, struct snd_seq_event *ev, int atomic, int hop);
+ int snd_seq_kernel_client_ctl(int client, unsigned int cmd, void *arg);
+
+--- a/sound/core/seq/oss/seq_oss_rw.c
++++ b/sound/core/seq/oss/seq_oss_rw.c
+@@ -180,14 +180,11 @@ insert_queue(struct seq_oss_devinfo *dp,
+ return 0; /* invalid event - no need to insert queue */
+
+ event.time.tick = snd_seq_oss_timer_cur_tick(dp->timer);
+- if (dp->timer->realtime || !dp->timer->running) {
++ if (dp->timer->realtime || !dp->timer->running)
+ snd_seq_oss_dispatch(dp, &event, 0, 0);
+- } else {
+- if (is_nonblock_mode(dp->file_mode))
+- rc = snd_seq_kernel_client_enqueue(dp->cseq, &event, 0, 0);
+- else
+- rc = snd_seq_kernel_client_enqueue_blocking(dp->cseq, &event, opt, 0, 0);
+- }
++ else
++ rc = snd_seq_kernel_client_enqueue(dp->cseq, &event, opt,
++ !is_nonblock_mode(dp->file_mode));
+ return rc;
+ }
+
+--- a/sound/core/seq/oss/seq_oss_writeq.c
++++ b/sound/core/seq/oss/seq_oss_writeq.c
+@@ -116,7 +116,7 @@ snd_seq_oss_writeq_sync(struct seq_oss_w
+ rec->t.code = SEQ_SYNCTIMER;
+ rec->t.time = time;
+ q->sync_event_put = 1;
+- snd_seq_kernel_client_enqueue_blocking(dp->cseq, &ev, NULL, 0, 0);
++ snd_seq_kernel_client_enqueue(dp->cseq, &ev, NULL, true);
+ }
+
+ wait_event_interruptible_timeout(q->sync_sleep, ! q->sync_event_put, HZ);
+--- a/sound/core/seq/seq_clientmgr.c
++++ b/sound/core/seq/seq_clientmgr.c
+@@ -2225,12 +2225,13 @@ int snd_seq_delete_kernel_client(int cli
+
+ EXPORT_SYMBOL(snd_seq_delete_kernel_client);
+
+-/* skeleton to enqueue event, called from snd_seq_kernel_client_enqueue
+- * and snd_seq_kernel_client_enqueue_blocking
++/*
++ * exported, called by kernel clients to enqueue events (w/o blocking)
++ *
++ * RETURN VALUE: zero if succeed, negative if error
+ */
+-static int kernel_client_enqueue(int client, struct snd_seq_event *ev,
+- struct file *file, int blocking,
+- int atomic, int hop)
++int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev,
++ struct file *file, bool blocking)
+ {
+ struct snd_seq_client *cptr;
+ int result;
+@@ -2257,39 +2258,13 @@ static int kernel_client_enqueue(int cli
+ result = -EPERM;
+ else /* send it */
+ result = snd_seq_client_enqueue_event(cptr, ev, file, blocking,
+- atomic, hop, NULL);
++ false, 0, NULL);
+
+ snd_seq_client_unlock(cptr);
+ return result;
+ }
+-
+-/*
+- * exported, called by kernel clients to enqueue events (w/o blocking)
+- *
+- * RETURN VALUE: zero if succeed, negative if error
+- */
+-int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event * ev,
+- int atomic, int hop)
+-{
+- return kernel_client_enqueue(client, ev, NULL, 0, atomic, hop);
+-}
+-
+ EXPORT_SYMBOL(snd_seq_kernel_client_enqueue);
+
+-/*
+- * exported, called by kernel clients to enqueue events (with blocking)
+- *
+- * RETURN VALUE: zero if succeed, negative if error
+- */
+-int snd_seq_kernel_client_enqueue_blocking(int client, struct snd_seq_event * ev,
+- struct file *file,
+- int atomic, int hop)
+-{
+- return kernel_client_enqueue(client, ev, file, 1, atomic, hop);
+-}
+-
+-EXPORT_SYMBOL(snd_seq_kernel_client_enqueue_blocking);
+-
+ /*
+ * exported, called by kernel clients to dispatch events directly to other
+ * clients, bypassing the queues. Event time-stamp will be updated.
+--- a/sound/core/seq/seq_clientmgr.h
++++ b/sound/core/seq/seq_clientmgr.h
+@@ -93,10 +93,6 @@ struct snd_seq_client *snd_seq_client_us
+ /* dispatch event to client(s) */
+ int snd_seq_dispatch_event(struct snd_seq_event_cell *cell, int atomic, int hop);
+
+-/* exported to other modules */
+-int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, int atomic, int hop);
+-int snd_seq_kernel_client_enqueue_blocking(int client, struct snd_seq_event * ev,
+- struct file *file, int atomic, int hop);
+ int snd_seq_kernel_client_write_poll(int clientid, struct file *file, poll_table *wait);
+ int snd_seq_client_notify_subscription(int client, int port,
+ struct snd_seq_port_subscribe *info, int evtype);
diff --git a/patches.drivers/ASoC-Intel-avoid-Oops-if-DMA-setup-fails.patch b/patches.drivers/ASoC-Intel-avoid-Oops-if-DMA-setup-fails.patch
new file mode 100644
index 0000000000..c16be9fb1c
--- /dev/null
+++ b/patches.drivers/ASoC-Intel-avoid-Oops-if-DMA-setup-fails.patch
@@ -0,0 +1,66 @@
+From 0efa3334d65b7f421ba12382dfa58f6ff5bf83c4 Mon Sep 17 00:00:00 2001
+From: Ross Zwisler <zwisler@chromium.org>
+Date: Mon, 29 Apr 2019 12:25:17 -0600
+Subject: [PATCH] ASoC: Intel: avoid Oops if DMA setup fails
+Git-commit: 0efa3334d65b7f421ba12382dfa58f6ff5bf83c4
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+Currently in sst_dsp_new() if we get an error return from sst_dma_new()
+we just print an error message and then still complete the function
+successfully. This means that we are trying to run without sst->dma
+properly set up, which will result in NULL pointer dereference when
+sst->dma is later used. This was happening for me in
+Sst_dsp_dma_get_channel():
+
+ struct sst_dma *dma = dsp->dma;
+ ...
+ dma->ch = dma_request_channel(mask, dma_chan_filter, dsp);
+
+This resulted in:
+
+ BUG: unable to handle kernel NULL pointer dereference at 0000000000000018
+ IP: sst_dsp_dma_get_channel+0x4f/0x125 [snd_soc_sst_firmware]
+
+Fix this by adding proper error handling for the case where we fail to
+set up DMA.
+
+This change only affects Haswell and Broadwell systems. Baytrail
+systems explicilty opt-out of DMA via sst->pdata->resindex_dma_base
+being set to -1.
+
+Signed-off-by: Ross Zwisler <zwisler@google.com>
+Cc: stable@vger.kernel.org
+Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ sound/soc/intel/common/sst-firmware.c | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/sound/soc/intel/common/sst-firmware.c b/sound/soc/intel/common/sst-firmware.c
+index 1e067504b604..f830e59f93ea 100644
+--- a/sound/soc/intel/common/sst-firmware.c
++++ b/sound/soc/intel/common/sst-firmware.c
+@@ -1251,11 +1251,15 @@ struct sst_dsp *sst_dsp_new(struct device *dev,
+ goto irq_err;
+
+ err = sst_dma_new(sst);
+- if (err)
+- dev_warn(dev, "sst_dma_new failed %d\n", err);
++ if (err) {
++ dev_err(dev, "sst_dma_new failed %d\n", err);
++ goto dma_err;
++ }
+
+ return sst;
+
++dma_err:
++ free_irq(sst->irq, sst);
+ irq_err:
+ if (sst->ops->free)
+ sst->ops->free(sst);
+--
+2.16.4
+
diff --git a/patches.drivers/ASoC-cs4270-Set-auto-increment-bit-for-register-writ.patch b/patches.drivers/ASoC-cs4270-Set-auto-increment-bit-for-register-writ.patch
new file mode 100644
index 0000000000..ce8a28c0b2
--- /dev/null
+++ b/patches.drivers/ASoC-cs4270-Set-auto-increment-bit-for-register-writ.patch
@@ -0,0 +1,39 @@
+From f0f2338a9cfaf71db895fa989ea7234e8a9b471d Mon Sep 17 00:00:00 2001
+From: Daniel Mack <daniel@zonque.org>
+Date: Wed, 20 Mar 2019 22:41:56 +0100
+Subject: [PATCH] ASoC: cs4270: Set auto-increment bit for register writes
+Git-commit: f0f2338a9cfaf71db895fa989ea7234e8a9b471d
+Patch-mainline: v5.1-rc5
+References: bsc#1051510
+
+The CS4270 does not by default increment the register address on
+consecutive writes. During normal operation it doesn't matter as all
+register accesses are done individually. At resume time after suspend,
+however, the regcache code gathers the biggest possible block of
+registers to sync and sends them one on one go.
+
+To fix this, set the INCR bit in all cases.
+
+Signed-off-by: Daniel Mack <daniel@zonque.org>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ sound/soc/codecs/cs4270.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
+index 33d74f163bd7..793a14d58667 100644
+--- a/sound/soc/codecs/cs4270.c
++++ b/sound/soc/codecs/cs4270.c
+@@ -642,6 +642,7 @@ static const struct regmap_config cs4270_regmap = {
+ .reg_defaults = cs4270_reg_defaults,
+ .num_reg_defaults = ARRAY_SIZE(cs4270_reg_defaults),
+ .cache_type = REGCACHE_RBTREE,
++ .write_flag_mask = CS4270_I2C_INCR,
+
+ .readable_reg = cs4270_reg_is_readable,
+ .volatile_reg = cs4270_reg_is_volatile,
+--
+2.16.4
+
diff --git a/patches.drivers/ASoC-fix-valid-stream-condition.patch b/patches.drivers/ASoC-fix-valid-stream-condition.patch
new file mode 100644
index 0000000000..9894d2938c
--- /dev/null
+++ b/patches.drivers/ASoC-fix-valid-stream-condition.patch
@@ -0,0 +1,40 @@
+From 6a7c59c6d9f3b280e81d7a04bbe4e55e90152dce Mon Sep 17 00:00:00 2001
+From: Jerome Brunet <jbrunet@baylibre.com>
+Date: Mon, 29 Apr 2019 11:47:49 +0200
+Subject: [PATCH] ASoC: fix valid stream condition
+Git-commit: 6a7c59c6d9f3b280e81d7a04bbe4e55e90152dce
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+A stream may specify a rate range using 'rate_min' and 'rate_max', so a
+stream may be valid and not specify any rates. However, as stream cannot
+be valid and not have any channel. Let's use this condition instead to
+determine if a stream is valid or not.
+
+Fixes: cde79035c6cf ("ASoC: Handle multiple codecs with split playback / capture")
+Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ sound/soc/soc-pcm.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
+index d21247546f7f..57088bd69e5d 100644
+--- a/sound/soc/soc-pcm.c
++++ b/sound/soc/soc-pcm.c
+@@ -43,8 +43,8 @@ static bool snd_soc_dai_stream_valid(struct snd_soc_dai *dai, int stream)
+ else
+ codec_stream = &dai->driver->capture;
+
+- /* If the codec specifies any rate at all, it supports the stream. */
+- return codec_stream->rates;
++ /* If the codec specifies any channels at all, it supports the stream */
++ return codec_stream->channels_min;
+ }
+
+ /**
+--
+2.16.4
+
diff --git a/patches.drivers/ASoC-hdmi-codec-fix-S-PDIF-DAI.patch b/patches.drivers/ASoC-hdmi-codec-fix-S-PDIF-DAI.patch
new file mode 100644
index 0000000000..8980b2d8bb
--- /dev/null
+++ b/patches.drivers/ASoC-hdmi-codec-fix-S-PDIF-DAI.patch
@@ -0,0 +1,175 @@
+From 2e95f984aae4cf0608d0ba2189c756f2bd50b44a Mon Sep 17 00:00:00 2001
+From: Russell King <rmk+kernel@armlinux.org.uk>
+Date: Thu, 28 Feb 2019 15:30:34 +0000
+Subject: [PATCH] ASoC: hdmi-codec: fix S/PDIF DAI
+Git-commit: 2e95f984aae4cf0608d0ba2189c756f2bd50b44a
+Patch-mainline: v5.1-rc5
+References: bsc#1051510
+
+When using the S/PDIF DAI, there is no requirement to call
+snd_soc_dai_set_fmt() as there is no DAI format definition that defines
+S/PDIF. In any case, S/PDIF does not have separate clocks, this is
+embedded into the data stream.
+
+Consequently, when attempting to use TDA998x in S/PDIF mode, the attempt
+to configure TDA998x via the hw_params callback fails as the
+hdmi_codec_daifmt is left initialised to zero.
+
+Since the S/PDIF DAI will only be used by S/PDIF, prepare the
+hdmi_codec_daifmt structure for this format.
+
+Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
+Reviewed-by: Jyri Sarha <jsarha@ti.com>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ sound/soc/codecs/hdmi-codec.c | 122 +++++++++++++++++++++---------------------
+ 1 file changed, 61 insertions(+), 61 deletions(-)
+
+--- a/sound/soc/codecs/hdmi-codec.c
++++ b/sound/soc/codecs/hdmi-codec.c
+@@ -549,73 +549,71 @@ static int hdmi_codec_set_fmt(struct snd
+ {
+ struct hdmi_codec_priv *hcp = snd_soc_dai_get_drvdata(dai);
+ struct hdmi_codec_daifmt cf = { 0 };
+- int ret = 0;
+
+ dev_dbg(dai->dev, "%s()\n", __func__);
+
+- if (dai->id == DAI_ID_SPDIF) {
+- cf.fmt = HDMI_SPDIF;
+- } else {
+- switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+- case SND_SOC_DAIFMT_CBM_CFM:
+- cf.bit_clk_master = 1;
+- cf.frame_clk_master = 1;
+- break;
+- case SND_SOC_DAIFMT_CBS_CFM:
+- cf.frame_clk_master = 1;
+- break;
+- case SND_SOC_DAIFMT_CBM_CFS:
+- cf.bit_clk_master = 1;
+- break;
+- case SND_SOC_DAIFMT_CBS_CFS:
+- break;
+- default:
+- return -EINVAL;
+- }
+-
+- switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
+- case SND_SOC_DAIFMT_NB_NF:
+- break;
+- case SND_SOC_DAIFMT_NB_IF:
+- cf.frame_clk_inv = 1;
+- break;
+- case SND_SOC_DAIFMT_IB_NF:
+- cf.bit_clk_inv = 1;
+- break;
+- case SND_SOC_DAIFMT_IB_IF:
+- cf.frame_clk_inv = 1;
+- cf.bit_clk_inv = 1;
+- break;
+- }
+-
+- switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+- case SND_SOC_DAIFMT_I2S:
+- cf.fmt = HDMI_I2S;
+- break;
+- case SND_SOC_DAIFMT_DSP_A:
+- cf.fmt = HDMI_DSP_A;
+- break;
+- case SND_SOC_DAIFMT_DSP_B:
+- cf.fmt = HDMI_DSP_B;
+- break;
+- case SND_SOC_DAIFMT_RIGHT_J:
+- cf.fmt = HDMI_RIGHT_J;
+- break;
+- case SND_SOC_DAIFMT_LEFT_J:
+- cf.fmt = HDMI_LEFT_J;
+- break;
+- case SND_SOC_DAIFMT_AC97:
+- cf.fmt = HDMI_AC97;
+- break;
+- default:
+- dev_err(dai->dev, "Invalid DAI interface format\n");
+- return -EINVAL;
+- }
++ if (dai->id == DAI_ID_SPDIF)
++ return 0;
++
++ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
++ case SND_SOC_DAIFMT_CBM_CFM:
++ cf.bit_clk_master = 1;
++ cf.frame_clk_master = 1;
++ break;
++ case SND_SOC_DAIFMT_CBS_CFM:
++ cf.frame_clk_master = 1;
++ break;
++ case SND_SOC_DAIFMT_CBM_CFS:
++ cf.bit_clk_master = 1;
++ break;
++ case SND_SOC_DAIFMT_CBS_CFS:
++ break;
++ default:
++ return -EINVAL;
++ }
++
++ switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
++ case SND_SOC_DAIFMT_NB_NF:
++ break;
++ case SND_SOC_DAIFMT_NB_IF:
++ cf.frame_clk_inv = 1;
++ break;
++ case SND_SOC_DAIFMT_IB_NF:
++ cf.bit_clk_inv = 1;
++ break;
++ case SND_SOC_DAIFMT_IB_IF:
++ cf.frame_clk_inv = 1;
++ cf.bit_clk_inv = 1;
++ break;
++ }
++
++ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
++ case SND_SOC_DAIFMT_I2S:
++ cf.fmt = HDMI_I2S;
++ break;
++ case SND_SOC_DAIFMT_DSP_A:
++ cf.fmt = HDMI_DSP_A;
++ break;
++ case SND_SOC_DAIFMT_DSP_B:
++ cf.fmt = HDMI_DSP_B;
++ break;
++ case SND_SOC_DAIFMT_RIGHT_J:
++ cf.fmt = HDMI_RIGHT_J;
++ break;
++ case SND_SOC_DAIFMT_LEFT_J:
++ cf.fmt = HDMI_LEFT_J;
++ break;
++ case SND_SOC_DAIFMT_AC97:
++ cf.fmt = HDMI_AC97;
++ break;
++ default:
++ dev_err(dai->dev, "Invalid DAI interface format\n");
++ return -EINVAL;
+ }
+
+ hcp->daifmt[dai->id] = cf;
+
+- return ret;
++ return 0;
+ }
+
+ static int hdmi_codec_digital_mute(struct snd_soc_dai *dai, int mute)
+@@ -771,8 +769,10 @@ static int hdmi_codec_probe(struct platf
+ i++;
+ }
+
+- if (hcd->spdif)
++ if (hcd->spdif) {
+ hcp->daidrv[i] = hdmi_spdif_dai;
++ hcp->daifmt[DAI_ID_SPDIF].fmt = HDMI_SPDIF;
++ }
+
+ ret = snd_soc_register_codec(dev, &hdmi_codec, hcp->daidrv,
+ dai_count);
diff --git a/patches.drivers/ASoC-nau8810-fix-the-issue-of-widget-with-prefixed-n.patch b/patches.drivers/ASoC-nau8810-fix-the-issue-of-widget-with-prefixed-n.patch
new file mode 100644
index 0000000000..a990c633ed
--- /dev/null
+++ b/patches.drivers/ASoC-nau8810-fix-the-issue-of-widget-with-prefixed-n.patch
@@ -0,0 +1,39 @@
+From 54d1cf78b0f4ba348a7c7fb8b7d0708d71b6cc8a Mon Sep 17 00:00:00 2001
+From: John Hsu <KCHSU0@nuvoton.com>
+Date: Wed, 13 Mar 2019 16:23:44 +0800
+Subject: [PATCH] ASoC: nau8810: fix the issue of widget with prefixed name
+Git-commit: 54d1cf78b0f4ba348a7c7fb8b7d0708d71b6cc8a
+Patch-mainline: v5.1-rc5
+References: bsc#1051510
+
+The driver changes the stream name of DAC and ADC to avoid the issue of
+widget with prefixed name. When the machine adds prefixed name for codec,
+the stream name of DAI may not find the widgets.
+
+Signed-off-by: John Hsu <KCHSU0@nuvoton.com>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ sound/soc/codecs/nau8810.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c
+index bfd74b86c9d2..645aa0794123 100644
+--- a/sound/soc/codecs/nau8810.c
++++ b/sound/soc/codecs/nau8810.c
+@@ -411,9 +411,9 @@ static const struct snd_soc_dapm_widget nau8810_dapm_widgets[] = {
+ SND_SOC_DAPM_MIXER("Mono Mixer", NAU8810_REG_POWER3,
+ NAU8810_MOUTMX_EN_SFT, 0, &nau8810_mono_mixer_controls[0],
+ ARRAY_SIZE(nau8810_mono_mixer_controls)),
+- SND_SOC_DAPM_DAC("DAC", "HiFi Playback", NAU8810_REG_POWER3,
++ SND_SOC_DAPM_DAC("DAC", "Playback", NAU8810_REG_POWER3,
+ NAU8810_DAC_EN_SFT, 0),
+- SND_SOC_DAPM_ADC("ADC", "HiFi Capture", NAU8810_REG_POWER2,
++ SND_SOC_DAPM_ADC("ADC", "Capture", NAU8810_REG_POWER2,
+ NAU8810_ADC_EN_SFT, 0),
+ SND_SOC_DAPM_PGA("SpkN Out", NAU8810_REG_POWER3,
+ NAU8810_NSPK_EN_SFT, 0, NULL, 0),
+--
+2.16.4
+
diff --git a/patches.drivers/ASoC-nau8824-fix-the-issue-of-the-widget-with-prefix.patch b/patches.drivers/ASoC-nau8824-fix-the-issue-of-the-widget-with-prefix.patch
new file mode 100644
index 0000000000..cdcf1c8efa
--- /dev/null
+++ b/patches.drivers/ASoC-nau8824-fix-the-issue-of-the-widget-with-prefix.patch
@@ -0,0 +1,110 @@
+From 844a4a362dbec166b44d6b9b3dd45b08cb273703 Mon Sep 17 00:00:00 2001
+From: John Hsu <KCHSU0@nuvoton.com>
+Date: Mon, 11 Mar 2019 09:36:45 +0800
+Subject: [PATCH] ASoC: nau8824: fix the issue of the widget with prefix name
+Git-commit: 844a4a362dbec166b44d6b9b3dd45b08cb273703
+Patch-mainline: v5.1-rc5
+References: bsc#1051510
+
+The driver has two issues when machine add prefix name for codec.
+(1)The stream name of DAI can't find the AIF widgets.
+(2)The drivr can enable/disalbe the MICBIAS and SAR widgets.
+
+The patch will fix these issues caused by prefixed name added.
+
+Signed-off-by: John Hsu <KCHSU0@nuvoton.com>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ sound/soc/codecs/nau8824.c | 46 ++++++++++++++++++++++++++++++++++++++--------
+ 1 file changed, 38 insertions(+), 8 deletions(-)
+
+diff --git a/sound/soc/codecs/nau8824.c b/sound/soc/codecs/nau8824.c
+index 87ed3dc496dc..5ab05e75edea 100644
+--- a/sound/soc/codecs/nau8824.c
++++ b/sound/soc/codecs/nau8824.c
+@@ -681,8 +681,8 @@ static const struct snd_soc_dapm_widget nau8824_dapm_widgets[] = {
+ SND_SOC_DAPM_ADC("ADCR", NULL, NAU8824_REG_ANALOG_ADC_2,
+ NAU8824_ADCR_EN_SFT, 0),
+
+- SND_SOC_DAPM_AIF_OUT("AIFTX", "HiFi Capture", 0, SND_SOC_NOPM, 0, 0),
+- SND_SOC_DAPM_AIF_IN("AIFRX", "HiFi Playback", 0, SND_SOC_NOPM, 0, 0),
++ SND_SOC_DAPM_AIF_OUT("AIFTX", "Capture", 0, SND_SOC_NOPM, 0, 0),
++ SND_SOC_DAPM_AIF_IN("AIFRX", "Playback", 0, SND_SOC_NOPM, 0, 0),
+
+ SND_SOC_DAPM_DAC("DACL", NULL, NAU8824_REG_RDAC,
+ NAU8824_DACL_EN_SFT, 0),
+@@ -831,6 +831,36 @@ static void nau8824_int_status_clear_all(struct regmap *regmap)
+ }
+ }
+
++static void nau8824_dapm_disable_pin(struct nau8824 *nau8824, const char *pin)
++{
++ struct snd_soc_dapm_context *dapm = nau8824->dapm;
++ const char *prefix = dapm->component->name_prefix;
++ char prefixed_pin[80];
++
++ if (prefix) {
++ snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
++ prefix, pin);
++ snd_soc_dapm_disable_pin(dapm, prefixed_pin);
++ } else {
++ snd_soc_dapm_disable_pin(dapm, pin);
++ }
++}
++
++static void nau8824_dapm_enable_pin(struct nau8824 *nau8824, const char *pin)
++{
++ struct snd_soc_dapm_context *dapm = nau8824->dapm;
++ const char *prefix = dapm->component->name_prefix;
++ char prefixed_pin[80];
++
++ if (prefix) {
++ snprintf(prefixed_pin, sizeof(prefixed_pin), "%s %s",
++ prefix, pin);
++ snd_soc_dapm_force_enable_pin(dapm, prefixed_pin);
++ } else {
++ snd_soc_dapm_force_enable_pin(dapm, pin);
++ }
++}
++
+ static void nau8824_eject_jack(struct nau8824 *nau8824)
+ {
+ struct snd_soc_dapm_context *dapm = nau8824->dapm;
+@@ -839,8 +869,8 @@ static void nau8824_eject_jack(struct nau8824 *nau8824)
+ /* Clear all interruption status */
+ nau8824_int_status_clear_all(regmap);
+
+- snd_soc_dapm_disable_pin(dapm, "SAR");
+- snd_soc_dapm_disable_pin(dapm, "MICBIAS");
++ nau8824_dapm_disable_pin(nau8824, "SAR");
++ nau8824_dapm_disable_pin(nau8824, "MICBIAS");
+ snd_soc_dapm_sync(dapm);
+
+ /* Enable the insertion interruption, disable the ejection
+@@ -870,8 +900,8 @@ static void nau8824_jdet_work(struct work_struct *work)
+ struct regmap *regmap = nau8824->regmap;
+ int adc_value, event = 0, event_mask = 0;
+
+- snd_soc_dapm_force_enable_pin(dapm, "MICBIAS");
+- snd_soc_dapm_force_enable_pin(dapm, "SAR");
++ nau8824_dapm_enable_pin(nau8824, "MICBIAS");
++ nau8824_dapm_enable_pin(nau8824, "SAR");
+ snd_soc_dapm_sync(dapm);
+
+ msleep(100);
+@@ -882,8 +912,8 @@ static void nau8824_jdet_work(struct work_struct *work)
+ if (adc_value < HEADSET_SARADC_THD) {
+ event |= SND_JACK_HEADPHONE;
+
+- snd_soc_dapm_disable_pin(dapm, "SAR");
+- snd_soc_dapm_disable_pin(dapm, "MICBIAS");
++ nau8824_dapm_disable_pin(nau8824, "SAR");
++ nau8824_dapm_disable_pin(nau8824, "MICBIAS");
+ snd_soc_dapm_sync(dapm);
+ } else {
+ event |= SND_JACK_HEADSET;
+--
+2.16.4
+
diff --git a/patches.drivers/ASoC-samsung-odroid-Fix-clock-configuration-for-4410.patch b/patches.drivers/ASoC-samsung-odroid-Fix-clock-configuration-for-4410.patch
new file mode 100644
index 0000000000..4689137bd0
--- /dev/null
+++ b/patches.drivers/ASoC-samsung-odroid-Fix-clock-configuration-for-4410.patch
@@ -0,0 +1,49 @@
+From 2b13bee3884926cba22061efa75bd315e871de24 Mon Sep 17 00:00:00 2001
+From: Sylwester Nawrocki <s.nawrocki@samsung.com>
+Date: Tue, 12 Mar 2019 18:40:06 +0100
+Subject: [PATCH] ASoC: samsung: odroid: Fix clock configuration for 44100 sample rate
+Git-commit: 2b13bee3884926cba22061efa75bd315e871de24
+Patch-mainline: v5.1-rc5
+References: bsc#1051510
+
+After commit fbeec965b8d1c ("ASoC: samsung: odroid: Fix 32000 sample rate
+handling") the audio root clock frequency is configured improperly for
+44100 sample rate. Due to clock rate rounding it's 20070401 Hz instead
+of 22579000 Hz. This results in a too low value of the PSR clock divider
+in the CPU DAI driver and too fast actual sample rate for fs=44100. E.g.
+1 kHz tone has actual 1780 Hz frequency (1 kHz * 20070401/22579000 * 2).
+
+Fix this by increasing the correction passed to clk_set_rate() to take
+into account inaccuracy of the EPLL frequency properly.
+
+Fixes: fbeec965b8d1c ("ASoC: samsung: odroid: Fix 32000 sample rate handling")
+Reported-by: JaeChul Lee <jcsing.lee@samsung.com>
+Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ sound/soc/samsung/odroid.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c
+index 694512f980fd..1dc54c4206f0 100644
+--- a/sound/soc/samsung/odroid.c
++++ b/sound/soc/samsung/odroid.c
+@@ -91,11 +91,11 @@ static int odroid_card_be_hw_params(struct snd_pcm_substream *substream,
+ return ret;
+
+ /*
+- * We add 1 to the rclk_freq value in order to avoid too low clock
++ * We add 2 to the rclk_freq value in order to avoid too low clock
+ * frequency values due to the EPLL output frequency not being exact
+ * multiple of the audio sampling rate.
+ */
+- rclk_freq = params_rate(params) * rfs + 1;
++ rclk_freq = params_rate(params) * rfs + 2;
+
+ ret = clk_set_rate(priv->sclk_i2s, rclk_freq);
+ if (ret < 0)
+--
+2.16.4
+
diff --git a/patches.drivers/ASoC-soc-pcm-fix-a-codec-fixup-issue-in-TDM-case.patch b/patches.drivers/ASoC-soc-pcm-fix-a-codec-fixup-issue-in-TDM-case.patch
new file mode 100644
index 0000000000..091c8a4aae
--- /dev/null
+++ b/patches.drivers/ASoC-soc-pcm-fix-a-codec-fixup-issue-in-TDM-case.patch
@@ -0,0 +1,64 @@
+From 570f18b6a8d1f0e60e8caf30e66161b6438dcc91 Mon Sep 17 00:00:00 2001
+From: Rander Wang <rander.wang@linux.intel.com>
+Date: Fri, 8 Mar 2019 16:38:57 +0800
+Subject: [PATCH] ASoC:soc-pcm:fix a codec fixup issue in TDM case
+Git-commit: 570f18b6a8d1f0e60e8caf30e66161b6438dcc91
+Patch-mainline: v5.1-rc5
+References: bsc#1051510
+
+On HDaudio platforms, if playback is started when capture is working,
+there is no audible output.
+
+This can be root-caused to the use of the rx|tx_mask to store an HDaudio
+stream tag.
+
+If capture is stared before playback, rx_mask would be non-zero on HDaudio
+platform, then the channel number of playback, which is in the same codec
+dai with the capture, would be changed by soc_pcm_codec_params_fixup based
+on the tx_mask at first, then overwritten by this function based on rx_mask
+at last.
+
+According to the author of tx|rx_mask, tx_mask is for playback and rx_mask
+is for capture. And stream direction is checked at all other references of
+tx|rx_mask in ASoC, so here should be an error. This patch checks stream
+direction for tx|rx_mask for fixup function.
+
+This issue would affect not only HDaudio+ASoC, but also I2S codecs if the
+channel number based on rx_mask is not equal to the one for tx_mask. It could
+be rarely reproduecd because most drivers in kernel set the same channel number
+to tx|rx_mask or rx_mask is zero.
+
+Tested on all platforms using stream_tag & HDaudio and intel I2S platforms.
+
+Signed-off-by: Rander Wang <rander.wang@linux.intel.com>
+Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ sound/soc/soc-pcm.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c
+index a5b40e82dea4..e70555a4ea06 100644
+--- a/sound/soc/soc-pcm.c
++++ b/sound/soc/soc-pcm.c
+@@ -954,10 +954,13 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
+ codec_params = *params;
+
+ /* fixup params based on TDM slot masks */
+- if (codec_dai->tx_mask)
++ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
++ codec_dai->tx_mask)
+ soc_pcm_codec_params_fixup(&codec_params,
+ codec_dai->tx_mask);
+- if (codec_dai->rx_mask)
++
++ if (substream->stream == SNDRV_PCM_STREAM_CAPTURE &&
++ codec_dai->rx_mask)
+ soc_pcm_codec_params_fixup(&codec_params,
+ codec_dai->rx_mask);
+
+--
+2.16.4
+
diff --git a/patches.drivers/ASoC-tlv320aic32x4-Fix-Common-Pins.patch b/patches.drivers/ASoC-tlv320aic32x4-Fix-Common-Pins.patch
new file mode 100644
index 0000000000..0d36cb72b5
--- /dev/null
+++ b/patches.drivers/ASoC-tlv320aic32x4-Fix-Common-Pins.patch
@@ -0,0 +1,35 @@
+From c63adb28f6d913310430f14c69f0a2ea55eed0cc Mon Sep 17 00:00:00 2001
+From: Annaliese McDermond <nh6z@nh6z.net>
+Date: Sat, 30 Mar 2019 09:02:02 -0700
+Subject: [PATCH] ASoC: tlv320aic32x4: Fix Common Pins
+Git-commit: c63adb28f6d913310430f14c69f0a2ea55eed0cc
+Patch-mainline: v5.1-rc5
+References: bsc#1051510
+
+The common pins were mistakenly not added to the DAPM graph.
+Adding these pins will allow valid graphs to be created.
+
+Signed-off-by: Annaliese McDermond <nh6z@nh6z.net>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ sound/soc/codecs/tlv320aic32x4.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c
+index 96f1526cb258..5520044929f4 100644
+--- a/sound/soc/codecs/tlv320aic32x4.c
++++ b/sound/soc/codecs/tlv320aic32x4.c
+@@ -490,6 +490,8 @@ static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = {
+ SND_SOC_DAPM_INPUT("IN2_R"),
+ SND_SOC_DAPM_INPUT("IN3_L"),
+ SND_SOC_DAPM_INPUT("IN3_R"),
++ SND_SOC_DAPM_INPUT("CM_L"),
++ SND_SOC_DAPM_INPUT("CM_R"),
+ };
+
+ static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = {
+--
+2.16.4
+
diff --git a/patches.drivers/ASoC-wm_adsp-Add-locking-to-wm_adsp2_bus_error.patch b/patches.drivers/ASoC-wm_adsp-Add-locking-to-wm_adsp2_bus_error.patch
new file mode 100644
index 0000000000..d1a65f1134
--- /dev/null
+++ b/patches.drivers/ASoC-wm_adsp-Add-locking-to-wm_adsp2_bus_error.patch
@@ -0,0 +1,69 @@
+From a2225a6d155fcb247fe4c6d87f7c91807462966d Mon Sep 17 00:00:00 2001
+From: Charles Keepax <ckeepax@opensource.cirrus.com>
+Date: Tue, 19 Mar 2019 11:52:06 +0000
+Subject: [PATCH] ASoC: wm_adsp: Add locking to wm_adsp2_bus_error
+Git-commit: a2225a6d155fcb247fe4c6d87f7c91807462966d
+Patch-mainline: v5.1-rc5
+References: bsc#1051510
+
+Best to lock across handling the bus error to ensure the DSP doesn't
+change power state as we are reading the status registers.
+
+Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ sound/soc/codecs/wm_adsp.c | 11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
+index b3348a213c18..c19a8a041d4d 100644
+--- a/sound/soc/codecs/wm_adsp.c
++++ b/sound/soc/codecs/wm_adsp.c
+@@ -3922,11 +3922,13 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)
+ struct regmap *regmap = dsp->regmap;
+ int ret = 0;
+
++ mutex_lock(&dsp->pwr_lock);
++
+ ret = regmap_read(regmap, dsp->base + ADSP2_LOCK_REGION_CTRL, &val);
+ if (ret) {
+ adsp_err(dsp,
+ "Failed to read Region Lock Ctrl register: %d\n", ret);
+- return IRQ_HANDLED;
++ goto error;
+ }
+
+ if (val & ADSP2_WDT_TIMEOUT_STS_MASK) {
+@@ -3945,7 +3947,7 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)
+ adsp_err(dsp,
+ "Failed to read Bus Err Addr register: %d\n",
+ ret);
+- return IRQ_HANDLED;
++ goto error;
+ }
+
+ adsp_err(dsp, "bus error address = 0x%x\n",
+@@ -3958,7 +3960,7 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)
+ adsp_err(dsp,
+ "Failed to read Pmem Xmem Err Addr register: %d\n",
+ ret);
+- return IRQ_HANDLED;
++ goto error;
+ }
+
+ adsp_err(dsp, "xmem error address = 0x%x\n",
+@@ -3971,6 +3973,9 @@ irqreturn_t wm_adsp2_bus_error(struct wm_adsp *dsp)
+ regmap_update_bits(regmap, dsp->base + ADSP2_LOCK_REGION_CTRL,
+ ADSP2_CTRL_ERR_EINT, ADSP2_CTRL_ERR_EINT);
+
++error:
++ mutex_unlock(&dsp->pwr_lock);
++
+ return IRQ_HANDLED;
+ }
+ EXPORT_SYMBOL_GPL(wm_adsp2_bus_error);
+--
+2.16.4
+
diff --git a/patches.drivers/Bluetooth-Align-minimum-encryption-key-size-for-LE-a.patch b/patches.drivers/Bluetooth-Align-minimum-encryption-key-size-for-LE-a.patch
new file mode 100644
index 0000000000..9d6139897f
--- /dev/null
+++ b/patches.drivers/Bluetooth-Align-minimum-encryption-key-size-for-LE-a.patch
@@ -0,0 +1,58 @@
+From d5bb334a8e171b262e48f378bd2096c0ea458265 Mon Sep 17 00:00:00 2001
+From: Marcel Holtmann <marcel@holtmann.org>
+Date: Wed, 24 Apr 2019 22:19:17 +0200
+Subject: [PATCH] Bluetooth: Align minimum encryption key size for LE and BR/EDR connections
+Git-commit: d5bb334a8e171b262e48f378bd2096c0ea458265
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+The minimum encryption key size for LE connections is 56 bits and to
+align LE with BR/EDR, enforce 56 bits of minimum encryption key size for
+BR/EDR connections as well.
+
+Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
+Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
+Cc: stable@vger.kernel.org
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ include/net/bluetooth/hci_core.h | 3 +++
+ net/bluetooth/hci_conn.c | 8 ++++++++
+ 2 files changed, 11 insertions(+)
+
+diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
+index 094e61e07030..05b1b96f4d9e 100644
+--- a/include/net/bluetooth/hci_core.h
++++ b/include/net/bluetooth/hci_core.h
+@@ -190,6 +190,9 @@ struct adv_info {
+
+ #define HCI_MAX_SHORT_NAME_LENGTH 10
+
++/* Min encryption key size to match with SMP */
++#define HCI_MIN_ENC_KEY_SIZE 7
++
+ /* Default LE RPA expiry time, 15 minutes */
+ #define HCI_DEFAULT_RPA_TIMEOUT (15 * 60)
+
+diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
+index bd4978ce8c45..3cf0764d5793 100644
+--- a/net/bluetooth/hci_conn.c
++++ b/net/bluetooth/hci_conn.c
+@@ -1276,6 +1276,14 @@ int hci_conn_check_link_mode(struct hci_conn *conn)
+ !test_bit(HCI_CONN_ENCRYPT, &conn->flags))
+ return 0;
+
++ /* The minimum encryption key size needs to be enforced by the
++ * host stack before establishing any L2CAP connections. The
++ * specification in theory allows a minimum of 1, but to align
++ * BR/EDR and LE transports, a minimum of 7 is chosen.
++ */
++ if (conn->enc_key_size < HCI_MIN_ENC_KEY_SIZE)
++ return 0;
++
+ return 1;
+ }
+
+--
+2.16.4
+
diff --git a/patches.drivers/Bluetooth-hidp-fix-buffer-overflow.patch b/patches.drivers/Bluetooth-hidp-fix-buffer-overflow.patch
new file mode 100644
index 0000000000..62087c0f46
--- /dev/null
+++ b/patches.drivers/Bluetooth-hidp-fix-buffer-overflow.patch
@@ -0,0 +1,38 @@
+From a1616a5ac99ede5d605047a9012481ce7ff18b16 Mon Sep 17 00:00:00 2001
+From: Young Xiao <YangX92@hotmail.com>
+Date: Fri, 12 Apr 2019 15:24:30 +0800
+Subject: [PATCH] Bluetooth: hidp: fix buffer overflow
+Git-commit: a1616a5ac99ede5d605047a9012481ce7ff18b16
+Patch-mainline: v5.2-rc1
+References: bsc#1051510, CVE-2019-11884, bsc#1134848
+
+Struct ca is copied from userspace. It is not checked whether the "name"
+field is NULL terminated, which allows local users to obtain potentially
+sensitive information from kernel stack memory, via a HIDPCONNADD command.
+
+This vulnerability is similar to CVE-2011-1079.
+
+Signed-off-by: Young Xiao <YangX92@hotmail.com>
+Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
+Cc: stable@vger.kernel.org
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ net/bluetooth/hidp/sock.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c
+index 9f85a1943be9..2151913892ce 100644
+--- a/net/bluetooth/hidp/sock.c
++++ b/net/bluetooth/hidp/sock.c
+@@ -75,6 +75,7 @@ static int do_hidp_sock_ioctl(struct socket *sock, unsigned int cmd, void __user
+ sockfd_put(csock);
+ return err;
+ }
++ ca.name[sizeof(ca.name)-1] = 0;
+
+ err = hidp_connection_add(&ca, csock, isock);
+ if (!err && copy_to_user(argp, &ca, sizeof(ca)))
+--
+2.16.4
+
diff --git a/patches.drivers/Revert-tty-pty-Fix-race-condition-between-release_on.patch b/patches.drivers/Revert-tty-pty-Fix-race-condition-between-release_on.patch
new file mode 100644
index 0000000000..675eb7ea9f
--- /dev/null
+++ b/patches.drivers/Revert-tty-pty-Fix-race-condition-between-release_on.patch
@@ -0,0 +1,69 @@
+From 0eae4686a128d87503863a261e84887750c8bc68 Mon Sep 17 00:00:00 2001
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Date: Fri, 29 Mar 2019 15:47:40 +0100
+Subject: [PATCH] Revert "tty: pty: Fix race condition between release_one_tty and pty_write"
+Git-commit: 0eae4686a128d87503863a261e84887750c8bc68
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+This reverts commit b9ca5f8560af244489b4a1bc1ae88b341f24bc95 as 0-day
+shows it has a circular locking dependency.
+
+Fixes: b9ca5f8560af ("tty: pty: Fix race condition between release_one_tty and pty_write")
+Reported-by: kernel test robot <lkp@intel.com>
+Cc: Sahara <keun-o.park@darkmatter.ae>
+Cc: stable <stable@vger.kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/tty/pty.c | 7 -------
+ drivers/tty/tty_io.c | 3 ---
+ 2 files changed, 10 deletions(-)
+
+diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
+index ef72031ab5b9..00099a8439d2 100644
+--- a/drivers/tty/pty.c
++++ b/drivers/tty/pty.c
+@@ -116,12 +116,6 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
+ if (tty->stopped)
+ return 0;
+
+- mutex_lock(&tty_mutex);
+- if (to->magic != TTY_MAGIC) {
+- mutex_unlock(&tty_mutex);
+- return -EIO;
+- }
+-
+ if (c > 0) {
+ spin_lock_irqsave(&to->port->lock, flags);
+ /* Stuff the data into the input queue of the other end */
+@@ -131,7 +125,6 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c)
+ tty_flip_buffer_push(to->port);
+ spin_unlock_irqrestore(&to->port->lock, flags);
+ }
+- mutex_unlock(&tty_mutex);
+ return c;
+ }
+
+diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
+index c27777f3b8c4..5fa250157025 100644
+--- a/drivers/tty/tty_io.c
++++ b/drivers/tty/tty_io.c
+@@ -1448,13 +1448,10 @@ static void release_one_tty(struct work_struct *work)
+ struct tty_driver *driver = tty->driver;
+ struct module *owner = driver->owner;
+
+- mutex_lock(&tty_mutex);
+ if (tty->ops->cleanup)
+ tty->ops->cleanup(tty);
+
+ tty->magic = 0;
+- mutex_unlock(&tty_mutex);
+-
+ tty_driver_kref_put(driver);
+ module_put(owner);
+
+--
+2.16.4
+
diff --git a/patches.drivers/clk-rockchip-Fix-video-codec-clocks-on-rk3288.patch b/patches.drivers/clk-rockchip-Fix-video-codec-clocks-on-rk3288.patch
new file mode 100644
index 0000000000..8d127b34a4
--- /dev/null
+++ b/patches.drivers/clk-rockchip-Fix-video-codec-clocks-on-rk3288.patch
@@ -0,0 +1,85 @@
+From 00c0cd9e59d265b393553e9afa54fee8b10e8158 Mon Sep 17 00:00:00 2001
+From: Douglas Anderson <dianders@chromium.org>
+Date: Thu, 11 Apr 2019 06:55:55 -0700
+Subject: [PATCH] clk: rockchip: Fix video codec clocks on rk3288
+Git-commit: 00c0cd9e59d265b393553e9afa54fee8b10e8158
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+It appears that there is a typo in the rk3288 TRM. For
+GRF_SOC_CON0[7] it says that 0 means "vepu" and 1 means "vdpu". It's
+the other way around.
+
+How do I know? Here's my evidence:
+
+1. Prior to commit 4d3e84f99628 ("clk: rockchip: describe aclk_vcodec
+ using the new muxgrf type on rk3288") we always pretended that we
+ were using "aclk_vdpu" and the comment in the code said that this
+ matched the default setting in the system. In fact the default
+ setting is 0 according to the TRM and according to reading memory
+ at bootup. In addition rk3288-based Chromebooks ran like this and
+ the video codecs worked.
+2. With the existing clock code if you boot up and try to enable the
+ new VIDEO_ROCKCHIP_VPU as a module (and without "clk_ignore_unused"
+ on the command line), you get errors like "failed to get ack on
+ domain 'pd_video', val=0x80208". After flipping vepu/vdpu things
+ init OK.
+3. If I export and add both the vepu and vdpu to the list of clocks
+ for RK3288_PD_VIDEO I can get past the power domain errors, but now
+ I freeze when the vpu_mmu gets initted.
+4. If I just mark the "vdpu" as IGNORE_UNUSED then everything boots up
+ and probes OK showing that somehow the "vdpu" was important to keep
+ enabled. This is because we were actually using it as a parent.
+5. After this change I can hack "aclk_vcodec_pre" to parent from
+ "aclk_vepu" using assigned-clocks and the video codec still probes
+ OK.
+6. Rockchip has said so on the mailing list [1].
+
+...so let's fix it.
+
+Let's also add CLK_SET_RATE_PARENT to "aclk_vcodec_pre" as suggested
+by Jonas Karlman. Prior to the same commit you could do
+clk_set_rate() on "aclk_vcodec" and it would change "aclk_vdpu".
+That's because "aclk_vcodec" was a simple gate clock (always gets
+CLK_SET_RATE_PARENT) and its direct parent was "aclk_vdpu". After
+that commit "aclk_vcodec_pre" gets in the way so we need to add
+CLK_SET_RATE_PARENT to it too.
+
+[1] https://lkml.kernel.org/r/1d17b015-9e17-34b9-baf8-c285dc1957aa@rock-chips.com
+
+Fixes: 4d3e84f99628 ("clk: rockchip: describe aclk_vcodec using the new muxgrf type on rk3288")
+Suggested-by: Jonas Karlman <jonas@kwiboo.se>
+Suggested-by: Randy Li <ayaka@soulik.info>
+Signed-off-by: Douglas Anderson <dianders@chromium.org>
+Signed-off-by: Heiko Stuebner <heiko@sntech.de>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/clk/rockchip/clk-rk3288.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/clk/rockchip/clk-rk3288.c b/drivers/clk/rockchip/clk-rk3288.c
+index f47d514cba36..94cbcb0aa49f 100644
+--- a/drivers/clk/rockchip/clk-rk3288.c
++++ b/drivers/clk/rockchip/clk-rk3288.c
+@@ -219,7 +219,7 @@ PNAME(mux_hsadcout_p) = { "hsadc_src", "ext_hsadc" };
+ PNAME(mux_edp_24m_p) = { "ext_edp_24m", "xin24m" };
+ PNAME(mux_tspout_p) = { "cpll", "gpll", "npll", "xin27m" };
+
+-PNAME(mux_aclk_vcodec_pre_p) = { "aclk_vepu", "aclk_vdpu" };
++PNAME(mux_aclk_vcodec_pre_p) = { "aclk_vdpu", "aclk_vepu" };
+ PNAME(mux_usbphy480m_p) = { "sclk_otgphy1_480m", "sclk_otgphy2_480m",
+ "sclk_otgphy0_480m" };
+ PNAME(mux_hsicphy480m_p) = { "cpll", "gpll", "usbphy480m_src" };
+@@ -420,7 +420,7 @@ static struct rockchip_clk_branch rk3288_clk_branches[] __initdata = {
+ COMPOSITE(0, "aclk_vdpu", mux_pll_src_cpll_gpll_usb480m_p, 0,
+ RK3288_CLKSEL_CON(32), 14, 2, MFLAGS, 8, 5, DFLAGS,
+ RK3288_CLKGATE_CON(3), 11, GFLAGS),
+- MUXGRF(0, "aclk_vcodec_pre", mux_aclk_vcodec_pre_p, 0,
++ MUXGRF(0, "aclk_vcodec_pre", mux_aclk_vcodec_pre_p, CLK_SET_RATE_PARENT,
+ RK3288_GRF_SOC_CON(0), 7, 1, MFLAGS),
+ GATE(ACLK_VCODEC, "aclk_vcodec", "aclk_vcodec_pre", 0,
+ RK3288_CLKGATE_CON(9), 0, GFLAGS),
+--
+2.16.4
+
diff --git a/patches.drivers/clk-rockchip-fix-wrong-clock-definitions-for-rk3328.patch b/patches.drivers/clk-rockchip-fix-wrong-clock-definitions-for-rk3328.patch
new file mode 100644
index 0000000000..42552ae89c
--- /dev/null
+++ b/patches.drivers/clk-rockchip-fix-wrong-clock-definitions-for-rk3328.patch
@@ -0,0 +1,92 @@
+From fb903392131a324a243c7731389277db1cd9f8df Mon Sep 17 00:00:00 2001
+From: Jonas Karlman <jonas@kwiboo.se>
+Date: Sun, 10 Mar 2019 12:00:45 +0000
+Subject: [PATCH] clk: rockchip: fix wrong clock definitions for rk3328
+Git-commit: fb903392131a324a243c7731389277db1cd9f8df
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+This patch fixes definition of several clock gate and select register
+that is wrong for rk3328 referring to the TRM and vendor kernel.
+Also use correct number of softrst registers.
+
+Fix clock definition for:
+- clk_crypto
+- aclk_h265
+- pclk_h265
+- aclk_h264
+- hclk_h264
+- aclk_axisram
+- aclk_gmac
+- aclk_usb3otg
+
+Fixes: fe3511ad8a1c ("clk: rockchip: add clock controller for rk3328")
+Cc: stable@vger.kernel.org
+Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
+Tested-by: Peter Geis <pgwipeout@gmail.com>
+Signed-off-by: Heiko Stuebner <heiko@sntech.de>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/clk/rockchip/clk-rk3328.c | 18 +++++++++---------
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+--- a/drivers/clk/rockchip/clk-rk3328.c
++++ b/drivers/clk/rockchip/clk-rk3328.c
+@@ -458,7 +458,7 @@ static struct rockchip_clk_branch rk3328
+ RK3328_CLKSEL_CON(35), 15, 1, MFLAGS, 8, 7, DFLAGS,
+ RK3328_CLKGATE_CON(2), 12, GFLAGS),
+ COMPOSITE(SCLK_CRYPTO, "clk_crypto", mux_2plls_p, 0,
+- RK3328_CLKSEL_CON(20), 7, 1, MFLAGS, 0, 7, DFLAGS,
++ RK3328_CLKSEL_CON(20), 7, 1, MFLAGS, 0, 5, DFLAGS,
+ RK3328_CLKGATE_CON(2), 4, GFLAGS),
+ COMPOSITE_NOMUX(SCLK_TSADC, "clk_tsadc", "clk_24m", 0,
+ RK3328_CLKSEL_CON(22), 0, 10, DFLAGS,
+@@ -550,15 +550,15 @@ static struct rockchip_clk_branch rk3328
+ GATE(0, "hclk_rkvenc_niu", "hclk_rkvenc", CLK_IGNORE_UNUSED,
+ RK3328_CLKGATE_CON(25), 1, GFLAGS),
+ GATE(ACLK_H265, "aclk_h265", "aclk_rkvenc", 0,
+- RK3328_CLKGATE_CON(25), 0, GFLAGS),
++ RK3328_CLKGATE_CON(25), 2, GFLAGS),
+ GATE(PCLK_H265, "pclk_h265", "hclk_rkvenc", 0,
+- RK3328_CLKGATE_CON(25), 1, GFLAGS),
++ RK3328_CLKGATE_CON(25), 3, GFLAGS),
+ GATE(ACLK_H264, "aclk_h264", "aclk_rkvenc", 0,
+- RK3328_CLKGATE_CON(25), 0, GFLAGS),
++ RK3328_CLKGATE_CON(25), 4, GFLAGS),
+ GATE(HCLK_H264, "hclk_h264", "hclk_rkvenc", 0,
+- RK3328_CLKGATE_CON(25), 1, GFLAGS),
++ RK3328_CLKGATE_CON(25), 5, GFLAGS),
+ GATE(ACLK_AXISRAM, "aclk_axisram", "aclk_rkvenc", CLK_IGNORE_UNUSED,
+- RK3328_CLKGATE_CON(25), 0, GFLAGS),
++ RK3328_CLKGATE_CON(25), 6, GFLAGS),
+
+ COMPOSITE(SCLK_VENC_CORE, "sclk_venc_core", mux_4plls_p, 0,
+ RK3328_CLKSEL_CON(51), 14, 2, MFLAGS, 8, 5, DFLAGS,
+@@ -663,7 +663,7 @@ static struct rockchip_clk_branch rk3328
+
+ /* PD_GMAC */
+ COMPOSITE(ACLK_GMAC, "aclk_gmac", mux_2plls_hdmiphy_p, 0,
+- RK3328_CLKSEL_CON(35), 6, 2, MFLAGS, 0, 5, DFLAGS,
++ RK3328_CLKSEL_CON(25), 6, 2, MFLAGS, 0, 5, DFLAGS,
+ RK3328_CLKGATE_CON(3), 2, GFLAGS),
+ COMPOSITE_NOMUX(PCLK_GMAC, "pclk_gmac", "aclk_gmac", 0,
+ RK3328_CLKSEL_CON(25), 8, 3, DFLAGS,
+@@ -733,7 +733,7 @@ static struct rockchip_clk_branch rk3328
+
+ /* PD_PERI */
+ GATE(0, "aclk_peri_noc", "aclk_peri", CLK_IGNORE_UNUSED, RK3328_CLKGATE_CON(19), 11, GFLAGS),
+- GATE(ACLK_USB3OTG, "aclk_usb3otg", "aclk_peri", 0, RK3328_CLKGATE_CON(19), 4, GFLAGS),
++ GATE(ACLK_USB3OTG, "aclk_usb3otg", "aclk_peri", 0, RK3328_CLKGATE_CON(19), 14, GFLAGS),
+
+ GATE(HCLK_SDMMC, "hclk_sdmmc", "hclk_peri", 0, RK3328_CLKGATE_CON(19), 0, GFLAGS),
+ GATE(HCLK_SDIO, "hclk_sdio", "hclk_peri", 0, RK3328_CLKGATE_CON(19), 1, GFLAGS),
+@@ -894,7 +894,7 @@ static void __init rk3328_clk_init(struc
+ &rk3328_cpuclk_data, rk3328_cpuclk_rates,
+ ARRAY_SIZE(rk3328_cpuclk_rates));
+
+- rockchip_register_softrst(np, 11, reg_base + RK3328_SOFTRST_CON(0),
++ rockchip_register_softrst(np, 12, reg_base + RK3328_SOFTRST_CON(0),
+ ROCKCHIP_SOFTRST_HIWORD_MASK);
+
+ rockchip_register_restart_notifier(ctx, RK3328_GLB_SRST_FST, NULL);
diff --git a/patches.drivers/dmaengine-axi-dmac-Don-t-check-the-number-of-frames-.patch b/patches.drivers/dmaengine-axi-dmac-Don-t-check-the-number-of-frames-.patch
new file mode 100644
index 0000000000..647bf4914e
--- /dev/null
+++ b/patches.drivers/dmaengine-axi-dmac-Don-t-check-the-number-of-frames-.patch
@@ -0,0 +1,45 @@
+From 648865a79d8ee3d1aa64aab5eb2a9d12eeed14f9 Mon Sep 17 00:00:00 2001
+From: Alexandru Ardelean <alexandru.ardelean@analog.com>
+Date: Tue, 26 Mar 2019 16:05:20 +0200
+Subject: [PATCH] dmaengine: axi-dmac: Don't check the number of frames for alignment
+Git-commit: 648865a79d8ee3d1aa64aab5eb2a9d12eeed14f9
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+In 2D transfers (for the AXI DMAC), the number of frames (numf) represents
+Y_LENGTH, and the length of a frame is X_LENGTH. 2D transfers are useful
+for video transfers where screen resolutions ( X * Y ) are typically
+aligned for X, but not for Y.
+
+There is no requirement for Y_LENGTH to be aligned to the bus-width (or
+anything), and this is also true for AXI DMAC.
+
+Checking the Y_LENGTH for alignment causes false errors when initiating DMA
+transfers. This change fixes this by checking only that the Y_LENGTH is
+non-zero.
+
+Fixes: 0e3b67b348b8 ("dmaengine: Add support for the Analog Devices AXI-DMAC DMA controller")
+Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/dma/dma-axi-dmac.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c
+index eecb367b4f3e..cdbef59a9542 100644
+--- a/drivers/dma/dma-axi-dmac.c
++++ b/drivers/dma/dma-axi-dmac.c
+@@ -526,7 +526,7 @@ static struct dma_async_tx_descriptor *axi_dmac_prep_interleaved(
+
+ if (chan->hw_2d) {
+ if (!axi_dmac_check_len(chan, xt->sgl[0].size) ||
+- !axi_dmac_check_len(chan, xt->numf))
++ xt->numf == 0)
+ return NULL;
+ if (xt->sgl[0].size + dst_icg > chan->max_length ||
+ xt->sgl[0].size + src_icg > chan->max_length)
+--
+2.16.4
+
diff --git a/patches.drivers/dmaengine-tegra210-dma-free-dma-controller-in-remove.patch b/patches.drivers/dmaengine-tegra210-dma-free-dma-controller-in-remove.patch
new file mode 100644
index 0000000000..ebb023a581
--- /dev/null
+++ b/patches.drivers/dmaengine-tegra210-dma-free-dma-controller-in-remove.patch
@@ -0,0 +1,90 @@
+From f030e419501cb95e961e9ed35c493b5d46a04eca Mon Sep 17 00:00:00 2001
+From: Sameer Pujar <spujar@nvidia.com>
+Date: Thu, 2 May 2019 18:25:16 +0530
+Subject: [PATCH] dmaengine: tegra210-dma: free dma controller in remove()
+Git-commit: f030e419501cb95e961e9ed35c493b5d46a04eca
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+Following kernel panic is seen during DMA driver unload->load sequence
+==========================================================================
+Unable to handle kernel paging request at virtual address ffffff8001198880
+Internal error: Oops: 86000007 [#1] PREEMPT SMP
+Cpu: 0 PID: 5907 Comm: HwBinder:4123_1 Tainted: G C 4.9.128-tegra-g065839f
+Hardware name: galen (DT)
+Task: ffffffc3590d1a80 task.stack: ffffffc3d0678000
+PC is at 0xffffff8001198880
+LR is at of_dma_request_slave_channel+0xd8/0x1f8
+pc : [<ffffff8001198880>] lr : [<ffffff8008746f30>] pstate: 60400045
+sp : ffffffc3d067b710
+X29: ffffffc3d067b710 x28: 000000000000002f
+X27: ffffff800949e000 x26: ffffff800949e750
+X25: ffffff800949e000 x24: ffffffbefe817d84
+X23: ffffff8009f77cb0 x22: 0000000000000028
+X21: ffffffc3ffda49c8 x20: 0000000000000029
+X19: 0000000000000001 x18: ffffffffffffffff
+X17: 0000000000000000 x16: ffffff80082b66a0
+X15: ffffff8009e78250 x14: 000000000000000a
+X13: 0000000000000038 x12: 0101010101010101
+X11: 0000000000000030 x10: 0101010101010101
+x9 : fffffffffffffffc x8 : 7f7f7f7f7f7f7f7f
+x7 : 62ff726b6b64622c x6 : 0000000000008064
+x5 : 6400000000000000 x4 : ffffffbefe817c44
+x3 : ffffffc3ffda3e08 x2 : ffffff8001198880
+x1 : ffffffc3d48323c0 x0 : ffffffc3d067b788
+
+Process HwBinder:4123_1 (pid: 5907, stack limit = 0xffffffc3d0678028)
+Call trace:
+[<ffffff8001198880>] 0xffffff8001198880
+[<ffffff80087459f8>] dma_request_chan+0x50/0x1f0
+[<ffffff8008745bc0>] dma_request_slave_channel+0x28/0x40
+[<ffffff8001552c44>] tegra_alt_pcm_open+0x114/0x170
+[<ffffff8008d65fa4>] soc_pcm_open+0x10c/0x878
+[<ffffff8008d18618>] snd_pcm_open_substream+0xc0/0x170
+[<ffffff8008d1878c>] snd_pcm_open+0xc4/0x240
+[<ffffff8008d189e0>] snd_pcm_playback_open+0x58/0x80
+[<ffffff8008cfc6d4>] snd_open+0xb4/0x178
+[<ffffff8008250628>] chrdev_open+0xb8/0x1d0
+[<ffffff8008246fdc>] do_dentry_open+0x214/0x318
+[<ffffff80082485d0>] vfs_open+0x58/0x88
+[<ffffff800825bce0>] do_last+0x450/0xde0
+[<ffffff800825c718>] path_openat+0xa8/0x368
+[<ffffff800825dd84>] do_filp_open+0x8c/0x110
+[<ffffff8008248a74>] do_sys_open+0x164/0x220
+[<ffffff80082b66dc>] compat_SyS_openat+0x3c/0x50
+[<ffffff8008083040>] el0_svc_naked+0x34/0x38
+
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---[ end trace 67e6d544e65b5145 ]---
+Kernel panic - not syncing: Fatal exception
+==========================================================================
+
+In device probe(), of_dma_controller_register() registers DMA controller.
+But when driver is removed, this is not freed. During driver reload this
+results in data abort and kernel panic. Add of_dma_controller_free() in
+driver remove path to fix the issue.
+
+Fixes: f46b195799b5 ("dmaengine: tegra-adma: Add support for Tegra210 ADMA")
+Signed-off-by: Sameer Pujar <spujar@nvidia.com>
+Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
+Signed-off-by: Vinod Koul <vkoul@kernel.org>
+---
+ drivers/dma/tegra210-adma.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c
+index f26c458d584e..953669d35479 100644
+--- a/drivers/dma/tegra210-adma.c
++++ b/drivers/dma/tegra210-adma.c
+@@ -888,6 +888,7 @@ static int tegra_adma_remove(struct platform_device *pdev)
+ struct tegra_adma *tdma = platform_get_drvdata(pdev);
+ int i;
+
++ of_dma_controller_free(pdev->dev.of_node);
+ dma_async_device_unregister(&tdma->dma_dev);
+
+ for (i = 0; i < tdma->nr_channels; ++i)
+--
+2.16.4
+
diff --git a/patches.drivers/dwc2-gadget-Fix-completed-transfer-size-calculation-.patch b/patches.drivers/dwc2-gadget-Fix-completed-transfer-size-calculation-.patch
new file mode 100644
index 0000000000..1103708253
--- /dev/null
+++ b/patches.drivers/dwc2-gadget-Fix-completed-transfer-size-calculation-.patch
@@ -0,0 +1,39 @@
+From 5acb4b970184d189d901192d075997c933b82260 Mon Sep 17 00:00:00 2001
+From: Minas Harutyunyan <minas.harutyunyan@synopsys.com>
+Date: Fri, 22 Feb 2019 15:49:19 +0400
+Subject: [PATCH] dwc2: gadget: Fix completed transfer size calculation in DDMA
+Git-commit: 5acb4b970184d189d901192d075997c933b82260
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+Fix calculation of transfer size on completion in function
+dwc2_gadget_get_xfersize_ddma().
+
+Added increment of descriptor pointer to move to next descriptor in
+the loop.
+
+Fixes: aa3e8bc81311 ("usb: dwc2: gadget: DDMA transfer start and complete")
+
+Signed-off-by: Minas Harutyunyan <hminas@synopsys.com>
+Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/usb/dwc2/gadget.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
+index a17e444e467b..16ffd9fd9361 100644
+--- a/drivers/usb/dwc2/gadget.c
++++ b/drivers/usb/dwc2/gadget.c
+@@ -2325,6 +2325,7 @@ static unsigned int dwc2_gadget_get_xfersize_ddma(struct dwc2_hsotg_ep *hs_ep)
+ if (status & DEV_DMA_STS_MASK)
+ dev_err(hsotg->dev, "descriptor %d closed with %x\n",
+ i, status & DEV_DMA_STS_MASK);
++ desc++;
+ }
+
+ return bytes_rem;
+--
+2.16.4
+
diff --git a/patches.drivers/intel_th-pci-Add-Comet-Lake-support.patch b/patches.drivers/intel_th-pci-Add-Comet-Lake-support.patch
new file mode 100644
index 0000000000..6fe6f153d8
--- /dev/null
+++ b/patches.drivers/intel_th-pci-Add-Comet-Lake-support.patch
@@ -0,0 +1,38 @@
+From e60e9a4b231a20a199d7a61caadc48693c30d695 Mon Sep 17 00:00:00 2001
+From: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Date: Wed, 17 Apr 2019 10:35:36 +0300
+Subject: [PATCH] intel_th: pci: Add Comet Lake support
+Git-commit: e60e9a4b231a20a199d7a61caadc48693c30d695
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+This adds support for Intel TH on Comet Lake.
+
+Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
+Cc: stable <stable@vger.kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/hwtracing/intel_th/pci.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/drivers/hwtracing/intel_th/pci.c b/drivers/hwtracing/intel_th/pci.c
+index 1cf6290d6435..70f2cb90adc5 100644
+--- a/drivers/hwtracing/intel_th/pci.c
++++ b/drivers/hwtracing/intel_th/pci.c
+@@ -165,6 +165,11 @@ static const struct pci_device_id intel_th_pci_id_table[] = {
+ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x34a6),
+ .driver_data = (kernel_ulong_t)&intel_th_2x,
+ },
++ {
++ /* Comet Lake */
++ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x02a6),
++ .driver_data = (kernel_ulong_t)&intel_th_2x,
++ },
+ { 0 },
+ };
+
+--
+2.16.4
+
diff --git a/patches.drivers/iommu-vt-d-don-t-request-page-request-irq-under-dmar_global_lock b/patches.drivers/iommu-vt-d-don-t-request-page-request-irq-under-dmar_global_lock
new file mode 100644
index 0000000000..02ec82e57c
--- /dev/null
+++ b/patches.drivers/iommu-vt-d-don-t-request-page-request-irq-under-dmar_global_lock
@@ -0,0 +1,101 @@
+From: Lu Baolu <baolu.lu@linux.intel.com>
+Date: Fri, 19 Apr 2019 14:43:29 +0800
+Subject: iommu/vt-d: Don't request page request irq under dmar_global_lock
+Git-commit: a7755c3cfa5df755e39447b08c28203e011fb98c
+References: bsc#1135006
+Patch-mainline: v5.2-rc1
+
+Requesting page reqest irq under dmar_global_lock could cause
+potential lock race condition (caught by lockdep).
+
+[ 4.100055] ======================================================
+[ 4.100063] WARNING: possible circular locking dependency detected
+[ 4.100072] 5.1.0-rc4+ #2169 Not tainted
+[ 4.100078] ------------------------------------------------------
+[ 4.100086] swapper/0/1 is trying to acquire lock:
+[ 4.100094] 000000007dcbe3c3 (dmar_lock){+.+.}, at: dmar_alloc_hwirq+0x35/0x140
+[ 4.100112] but task is already holding lock:
+[ 4.100120] 0000000060bbe946 (dmar_global_lock){++++}, at: intel_iommu_init+0x191/0x1438
+[ 4.100136] which lock already depends on the new lock.
+[ 4.100146] the existing dependency chain (in reverse order) is:
+[ 4.100155]
+ -> #2 (dmar_global_lock){++++}:
+[ 4.100169] down_read+0x44/0xa0
+[ 4.100178] intel_irq_remapping_alloc+0xb2/0x7b0
+[ 4.100186] mp_irqdomain_alloc+0x9e/0x2e0
+[ 4.100195] __irq_domain_alloc_irqs+0x131/0x330
+[ 4.100203] alloc_isa_irq_from_domain.isra.4+0x9a/0xd0
+[ 4.100212] mp_map_pin_to_irq+0x244/0x310
+[ 4.100221] setup_IO_APIC+0x757/0x7ed
+[ 4.100229] x86_late_time_init+0x17/0x1c
+[ 4.100238] start_kernel+0x425/0x4e3
+[ 4.100247] secondary_startup_64+0xa4/0xb0
+[ 4.100254]
+ -> #1 (irq_domain_mutex){+.+.}:
+[ 4.100265] __mutex_lock+0x7f/0x9d0
+[ 4.100273] __irq_domain_add+0x195/0x2b0
+[ 4.100280] irq_domain_create_hierarchy+0x3d/0x40
+[ 4.100289] msi_create_irq_domain+0x32/0x110
+[ 4.100297] dmar_alloc_hwirq+0x111/0x140
+[ 4.100305] dmar_set_interrupt.part.14+0x1a/0x70
+[ 4.100314] enable_drhd_fault_handling+0x2c/0x6c
+[ 4.100323] apic_bsp_setup+0x75/0x7a
+[ 4.100330] x86_late_time_init+0x17/0x1c
+[ 4.100338] start_kernel+0x425/0x4e3
+[ 4.100346] secondary_startup_64+0xa4/0xb0
+[ 4.100352]
+ -> #0 (dmar_lock){+.+.}:
+[ 4.100364] lock_acquire+0xb4/0x1c0
+[ 4.100372] __mutex_lock+0x7f/0x9d0
+[ 4.100379] dmar_alloc_hwirq+0x35/0x140
+[ 4.100389] intel_svm_enable_prq+0x61/0x180
+[ 4.100397] intel_iommu_init+0x1128/0x1438
+[ 4.100406] pci_iommu_init+0x16/0x3f
+[ 4.100414] do_one_initcall+0x5d/0x2be
+[ 4.100422] kernel_init_freeable+0x1f0/0x27c
+[ 4.100431] kernel_init+0xa/0x110
+[ 4.100438] ret_from_fork+0x3a/0x50
+[ 4.100444]
+ other info that might help us debug this:
+
+[ 4.100454] Chain exists of:
+ dmar_lock --> irq_domain_mutex --> dmar_global_lock
+[ 4.100469] Possible unsafe locking scenario:
+
+[ 4.100476] CPU0 CPU1
+[ 4.100483] ---- ----
+[ 4.100488] lock(dmar_global_lock);
+[ 4.100495] lock(irq_domain_mutex);
+[ 4.100503] lock(dmar_global_lock);
+[ 4.100512] lock(dmar_lock);
+[ 4.100518]
+ *** DEADLOCK ***
+
+Cc: Ashok Raj <ashok.raj@intel.com>
+Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
+Cc: Kevin Tian <kevin.tian@intel.com>
+Reported-by: Dave Jiang <dave.jiang@intel.com>
+Fixes: a222a7f0bb6c9 ("iommu/vt-d: Implement page request handling")
+Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
+Signed-off-by: Joerg Roedel <jroedel@suse.de>
+---
+ drivers/iommu/intel-iommu.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/drivers/iommu/intel-iommu.c
++++ b/drivers/iommu/intel-iommu.c
+@@ -3435,7 +3435,13 @@ domains_done:
+
+ #ifdef CONFIG_INTEL_IOMMU_SVM
+ if (pasid_enabled(iommu) && ecap_prs(iommu->ecap)) {
++ /*
++ * Call dmar_alloc_hwirq() with dmar_global_lock held,
++ * could cause possible lock race condition.
++ */
++ up_write(&dmar_global_lock);
+ ret = intel_svm_enable_prq(iommu);
++ down_write(&dmar_global_lock);
+ if (ret)
+ goto free_iommu;
+ }
+
diff --git a/patches.drivers/iommu-vt-d-make-kernel-parameter-igfx_off-work-with-viommu b/patches.drivers/iommu-vt-d-make-kernel-parameter-igfx_off-work-with-viommu
new file mode 100644
index 0000000000..4ede87ac04
--- /dev/null
+++ b/patches.drivers/iommu-vt-d-make-kernel-parameter-igfx_off-work-with-viommu
@@ -0,0 +1,42 @@
+From: Lu Baolu <baolu.lu@linux.intel.com>
+Date: Thu, 2 May 2019 09:34:26 +0800
+Subject: iommu/vt-d: Make kernel parameter igfx_off work with vIOMMU
+Git-commit: 5daab58043ee2bca861068e2595564828f3bc663
+References: bsc#1135007
+Patch-mainline: v5.2-rc1
+
+The kernel parameter igfx_off is used by users to disable
+DMA remapping for the Intel integrated graphic device. It
+was designed for bare metal cases where a dedicated IOMMU
+is used for graphic. This doesn't apply to virtual IOMMU
+case where an include-all IOMMU is used. This makes the
+kernel parameter work with virtual IOMMU as well.
+
+Cc: Ashok Raj <ashok.raj@intel.com>
+Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
+Suggested-by: Kevin Tian <kevin.tian@intel.com>
+Fixes: c0771df8d5297 ("intel-iommu: Export a flag indicating that the IOMMU is used for iGFX.")
+Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
+Tested-by: Zhenyu Wang <zhenyuw@linux.intel.com>
+Signed-off-by: Joerg Roedel <jroedel@suse.de>
+---
+ drivers/iommu/intel-iommu.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/drivers/iommu/intel-iommu.c
++++ b/drivers/iommu/intel-iommu.c
+@@ -3351,9 +3351,12 @@ static int __init init_dmars(void)
+ iommu_identity_mapping |= IDENTMAP_ALL;
+
+ #ifdef CONFIG_INTEL_IOMMU_BROKEN_GFX_WA
+- iommu_identity_mapping |= IDENTMAP_GFX;
++ dmar_map_gfx = 0;
+ #endif
+
++ if (!dmar_map_gfx)
++ iommu_identity_mapping |= IDENTMAP_GFX;
++
+ check_tylersburg_isoch();
+
+ if (iommu_identity_mapping) {
+
diff --git a/patches.drivers/iommu-vt-d-set-intel_iommu_gfx_mapped-correctly b/patches.drivers/iommu-vt-d-set-intel_iommu_gfx_mapped-correctly
new file mode 100644
index 0000000000..f84fdbca56
--- /dev/null
+++ b/patches.drivers/iommu-vt-d-set-intel_iommu_gfx_mapped-correctly
@@ -0,0 +1,49 @@
+From: Lu Baolu <baolu.lu@linux.intel.com>
+Date: Thu, 2 May 2019 09:34:25 +0800
+Subject: iommu/vt-d: Set intel_iommu_gfx_mapped correctly
+Git-commit: cf1ec4539a50bdfe688caad4615ca47646884316
+References: bsc#1135008
+Patch-mainline: v5.2-rc1
+
+The intel_iommu_gfx_mapped flag is exported by the Intel
+IOMMU driver to indicate whether an IOMMU is used for the
+graphic device. In a virtualized IOMMU environment (e.g.
+QEMU), an include-all IOMMU is used for graphic device.
+This flag is found to be clear even the IOMMU is used.
+
+Cc: Ashok Raj <ashok.raj@intel.com>
+Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
+Cc: Kevin Tian <kevin.tian@intel.com>
+Reported-by: Zhenyu Wang <zhenyuw@linux.intel.com>
+Fixes: c0771df8d5297 ("intel-iommu: Export a flag indicating that the IOMMU is used for iGFX.")
+Suggested-by: Kevin Tian <kevin.tian@intel.com>
+Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
+Signed-off-by: Joerg Roedel <jroedel@suse.de>
+---
+ drivers/iommu/intel-iommu.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+--- a/drivers/iommu/intel-iommu.c
++++ b/drivers/iommu/intel-iommu.c
+@@ -4131,9 +4131,7 @@ static void __init init_no_remapping_dev
+
+ /* This IOMMU has *only* gfx devices. Either bypass it or
+ set the gfx_mapped flag, as appropriate */
+- if (dmar_map_gfx) {
+- intel_iommu_gfx_mapped = 1;
+- } else {
++ if (!dmar_map_gfx) {
+ drhd->ignored = 1;
+ for_each_active_dev_scope(drhd->devices,
+ drhd->devices_cnt, i, dev)
+@@ -4933,6 +4931,9 @@ int __init intel_iommu_init(void)
+ goto out_free_reserved_range;
+ }
+
++ if (dmar_map_gfx)
++ intel_iommu_gfx_mapped = 1;
++
+ init_no_remapping_devices();
+
+ ret = init_dmars();
+
diff --git a/patches.drivers/media-cx18-update-pos-correctly-in-cx18_read_pos.patch b/patches.drivers/media-cx18-update-pos-correctly-in-cx18_read_pos.patch
new file mode 100644
index 0000000000..fd62d631a3
--- /dev/null
+++ b/patches.drivers/media-cx18-update-pos-correctly-in-cx18_read_pos.patch
@@ -0,0 +1,37 @@
+From 7afb0df554292dca7568446f619965fb8153085d Mon Sep 17 00:00:00 2001
+From: Dan Carpenter <dan.carpenter@oracle.com>
+Date: Fri, 22 Feb 2019 01:37:02 -0500
+Subject: [PATCH] media: cx18: update *pos correctly in cx18_read_pos()
+Git-commit: 7afb0df554292dca7568446f619965fb8153085d
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+We should be updating *pos. The current code is a no-op.
+
+Fixes: 1c1e45d17b66 ("V4L/DVB (7786): cx18: new driver for the Conexant CX23418 MPEG encoder chip")
+
+Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/media/pci/cx18/cx18-fileops.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/media/pci/cx18/cx18-fileops.c b/drivers/media/pci/cx18/cx18-fileops.c
+index f778965a2eb8..59e78fb17575 100644
+--- a/drivers/media/pci/cx18/cx18-fileops.c
++++ b/drivers/media/pci/cx18/cx18-fileops.c
+@@ -484,7 +484,7 @@ static ssize_t cx18_read_pos(struct cx18_stream *s, char __user *ubuf,
+
+ CX18_DEBUG_HI_FILE("read %zd from %s, got %zd\n", count, s->name, rc);
+ if (rc > 0)
+- pos += rc;
++ *pos += rc;
+ return rc;
+ }
+
+--
+2.16.4
+
diff --git a/patches.drivers/media-cx23885-check-allocation-return.patch b/patches.drivers/media-cx23885-check-allocation-return.patch
new file mode 100644
index 0000000000..5dffa95e6c
--- /dev/null
+++ b/patches.drivers/media-cx23885-check-allocation-return.patch
@@ -0,0 +1,43 @@
+From a3d7f22ef34ec4206b50ee121384d5c8bebd5591 Mon Sep 17 00:00:00 2001
+From: Nicholas Mc Guire <hofrat@osadl.org>
+Date: Sat, 19 Jan 2019 22:52:23 -0500
+Subject: [PATCH] media: cx23885: check allocation return
+Git-commit: a3d7f22ef34ec4206b50ee121384d5c8bebd5591
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+Checking of kmalloc() seems to have been committed - as
+cx23885_dvb_register() is checking for != 0 return, returning
+-ENOMEM should be fine here. While at it address the coccicheck
+suggestion to move to kmemdup rather than using kmalloc+memcpy.
+
+Fixes: 46b21bbaa8a8 ("[media] Add support for DViCO FusionHDTV DVB-T Dual Express2")
+
+Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
+Signed-off-by: Sean Young <sean@mess.org>
+Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/media/pci/cx23885/cx23885-dvb.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
+index 0d0929c54f93..e2e63f05645e 100644
+--- a/drivers/media/pci/cx23885/cx23885-dvb.c
++++ b/drivers/media/pci/cx23885/cx23885-dvb.c
+@@ -1474,8 +1474,9 @@ static int dvb_register(struct cx23885_tsport *port)
+ if (fe0->dvb.frontend != NULL) {
+ struct i2c_adapter *tun_i2c;
+
+- fe0->dvb.frontend->sec_priv = kmalloc(sizeof(dib7000p_ops), GFP_KERNEL);
+- memcpy(fe0->dvb.frontend->sec_priv, &dib7000p_ops, sizeof(dib7000p_ops));
++ fe0->dvb.frontend->sec_priv = kmemdup(&dib7000p_ops, sizeof(dib7000p_ops), GFP_KERNEL);
++ if (!fe0->dvb.frontend->sec_priv)
++ return -ENOMEM;
+ tun_i2c = dib7000p_ops.get_i2c_master(fe0->dvb.frontend, DIBX000_I2C_INTERFACE_TUNER, 1);
+ if (!dvb_attach(dib0070_attach, fe0->dvb.frontend, tun_i2c, &dib7070p_dib0070_config))
+ return -ENODEV;
+--
+2.16.4
+
diff --git a/patches.drivers/media-davinci-isif-avoid-uninitialized-variable-use.patch b/patches.drivers/media-davinci-isif-avoid-uninitialized-variable-use.patch
new file mode 100644
index 0000000000..b11b752246
--- /dev/null
+++ b/patches.drivers/media-davinci-isif-avoid-uninitialized-variable-use.patch
@@ -0,0 +1,78 @@
+From 0e633f97162c1c74c68e2eb20bbd9259dce87cd9 Mon Sep 17 00:00:00 2001
+From: Arnd Bergmann <arnd@arndb.de>
+Date: Fri, 22 Mar 2019 10:34:22 -0400
+Subject: [PATCH] media: davinci-isif: avoid uninitialized variable use
+Git-commit: 0e633f97162c1c74c68e2eb20bbd9259dce87cd9
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+clang warns about a possible variable use that gcc never
+complained about:
+
+drivers/media/platform/davinci/isif.c:982:32: error: variable 'frame_size' is uninitialized when used here
+ [-Werror,-Wuninitialized]
+ dm365_vpss_set_pg_frame_size(frame_size);
+ ^~~~~~~~~~
+drivers/media/platform/davinci/isif.c:887:2: note: variable 'frame_size' is declared here
+ struct vpss_pg_frame_size frame_size;
+ ^
+1 error generated.
+
+There is no initialization for this variable at all, and there
+has never been one in the mainline kernel, so we really should
+not put that stack data into an mmio register.
+
+On the other hand, I suspect that gcc checks the condition
+more closely and notices that the global
+isif_cfg.bayer.config_params.test_pat_gen flag is initialized
+to zero and never written to from any code path, so anything
+depending on it can be eliminated.
+
+To shut up the clang warning, just remove the dead code manually,
+it has probably never been used because any attempt to do so
+would have resulted in undefined behavior.
+
+Fixes: 63e3ab142fa3 ("V4L/DVB: V4L - vpfe capture - source for ISIF driver on DM365")
+
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
+Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/media/platform/davinci/isif.c | 9 ---------
+ 1 file changed, 9 deletions(-)
+
+diff --git a/drivers/media/platform/davinci/isif.c b/drivers/media/platform/davinci/isif.c
+index 47cecd10eb9f..2dee9af6d413 100644
+--- a/drivers/media/platform/davinci/isif.c
++++ b/drivers/media/platform/davinci/isif.c
+@@ -884,9 +884,7 @@ static int isif_set_hw_if_params(struct vpfe_hw_if_param *params)
+ static int isif_config_ycbcr(void)
+ {
+ struct isif_ycbcr_config *params = &isif_cfg.ycbcr;
+- struct vpss_pg_frame_size frame_size;
+ u32 modeset = 0, ccdcfg = 0;
+- struct vpss_sync_pol sync;
+
+ dev_dbg(isif_cfg.dev, "\nStarting isif_config_ycbcr...");
+
+@@ -974,13 +972,6 @@ static int isif_config_ycbcr(void)
+ /* two fields are interleaved in memory */
+ regw(0x00000249, SDOFST);
+
+- /* Setup test pattern if enabled */
+- if (isif_cfg.bayer.config_params.test_pat_gen) {
+- sync.ccdpg_hdpol = params->hd_pol;
+- sync.ccdpg_vdpol = params->vd_pol;
+- dm365_vpss_set_sync_pol(sync);
+- dm365_vpss_set_pg_frame_size(frame_size);
+- }
+ return 0;
+ }
+
+--
+2.16.4
+
diff --git a/patches.drivers/media-ivtv-update-pos-correctly-in-ivtv_read_pos.patch b/patches.drivers/media-ivtv-update-pos-correctly-in-ivtv_read_pos.patch
new file mode 100644
index 0000000000..fcdf04ad5c
--- /dev/null
+++ b/patches.drivers/media-ivtv-update-pos-correctly-in-ivtv_read_pos.patch
@@ -0,0 +1,37 @@
+From f8e579f3ca0973daef263f513da5edff520a6c0d Mon Sep 17 00:00:00 2001
+From: Dan Carpenter <dan.carpenter@oracle.com>
+Date: Fri, 22 Feb 2019 01:36:41 -0500
+Subject: [PATCH] media: ivtv: update *pos correctly in ivtv_read_pos()
+Git-commit: f8e579f3ca0973daef263f513da5edff520a6c0d
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+We had intended to update *pos, but the current code is a no-op.
+
+Fixes: 1a0adaf37c30 ("V4L/DVB (5345): ivtv driver for Conexant cx23416/cx23415 MPEG encoder/decoder")
+
+Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/media/pci/ivtv/ivtv-fileops.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/media/pci/ivtv/ivtv-fileops.c b/drivers/media/pci/ivtv/ivtv-fileops.c
+index 6196daae4b3e..043ac0ae9ed0 100644
+--- a/drivers/media/pci/ivtv/ivtv-fileops.c
++++ b/drivers/media/pci/ivtv/ivtv-fileops.c
+@@ -420,7 +420,7 @@ static ssize_t ivtv_read_pos(struct ivtv_stream *s, char __user *ubuf, size_t co
+
+ IVTV_DEBUG_HI_FILE("read %zd from %s, got %zd\n", count, s->name, rc);
+ if (rc > 0)
+- pos += rc;
++ *pos += rc;
+ return rc;
+ }
+
+--
+2.16.4
+
diff --git a/patches.drivers/media-ov2659-fix-unbalanced-mutex_lock-unlock.patch b/patches.drivers/media-ov2659-fix-unbalanced-mutex_lock-unlock.patch
new file mode 100644
index 0000000000..5c64655395
--- /dev/null
+++ b/patches.drivers/media-ov2659-fix-unbalanced-mutex_lock-unlock.patch
@@ -0,0 +1,39 @@
+From 384538bda10913e5c94ec5b5d34bd3075931bcf4 Mon Sep 17 00:00:00 2001
+From: Akinobu Mita <akinobu.mita@gmail.com>
+Date: Sat, 30 Mar 2019 10:01:32 -0400
+Subject: [PATCH] media: ov2659: fix unbalanced mutex_lock/unlock
+Git-commit: 384538bda10913e5c94ec5b5d34bd3075931bcf4
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+Avoid returning with mutex locked.
+
+Fixes: fa8cb6444c32 ("[media] ov2659: Don't depend on subdev API")
+
+Cc: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
+Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
+Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>
+Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/media/i2c/ov2659.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
+index a1e9a980a445..5ed2413eac8a 100644
+--- a/drivers/media/i2c/ov2659.c
++++ b/drivers/media/i2c/ov2659.c
+@@ -1132,7 +1132,7 @@ static int ov2659_set_fmt(struct v4l2_subdev *sd,
+ mf = v4l2_subdev_get_try_format(sd, cfg, fmt->pad);
+ *mf = fmt->format;
+ #else
+- return -ENOTTY;
++ ret = -ENOTTY;
+ #endif
+ } else {
+ s64 val;
+--
+2.16.4
+
diff --git a/patches.drivers/media-serial_ir-Fix-use-after-free-in-serial_ir_init.patch b/patches.drivers/media-serial_ir-Fix-use-after-free-in-serial_ir_init.patch
new file mode 100644
index 0000000000..538bbec145
--- /dev/null
+++ b/patches.drivers/media-serial_ir-Fix-use-after-free-in-serial_ir_init.patch
@@ -0,0 +1,141 @@
+From 56cd26b618855c9af48c8301aa6754ced8dd0beb Mon Sep 17 00:00:00 2001
+From: YueHaibing <yuehaibing@huawei.com>
+Date: Tue, 5 Mar 2019 00:40:26 -0500
+Subject: [PATCH] media: serial_ir: Fix use-after-free in serial_ir_init_module
+Git-commit: 56cd26b618855c9af48c8301aa6754ced8dd0beb
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+Syzkaller report this:
+
+Bug: KASAN: use-after-free in sysfs_remove_file_ns+0x5f/0x70 fs/sysfs/file.c:468
+Read of size 8 at addr ffff8881dc7ae030 by task syz-executor.0/6249
+
+Cpu: 1 PID: 6249 Comm: syz-executor.0 Not tainted 5.0.0-rc8+ #3
+Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
+Call Trace:
+ __dump_stack lib/dump_stack.c:77 [inline]
+ dump_stack+0xfa/0x1ce lib/dump_stack.c:113
+ print_address_description+0x65/0x270 mm/kasan/report.c:187
+ kasan_report+0x149/0x18d mm/kasan/report.c:317
+ ? 0xffffffffc1728000
+ sysfs_remove_file_ns+0x5f/0x70 fs/sysfs/file.c:468
+ sysfs_remove_file include/linux/sysfs.h:519 [inline]
+ driver_remove_file+0x40/0x50 drivers/base/driver.c:122
+ remove_bind_files drivers/base/bus.c:585 [inline]
+ bus_remove_driver+0x186/0x220 drivers/base/bus.c:725
+ driver_unregister+0x6c/0xa0 drivers/base/driver.c:197
+ serial_ir_init_module+0x169/0x1000 [serial_ir]
+ do_one_initcall+0xfa/0x5ca init/main.c:887
+ do_init_module+0x204/0x5f6 kernel/module.c:3460
+ load_module+0x66b2/0x8570 kernel/module.c:3808
+ __do_sys_finit_module+0x238/0x2a0 kernel/module.c:3902
+ do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290
+ entry_SYSCALL_64_after_hwframe+0x49/0xbe
+Rip: 0033:0x462e99
+Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
+Rsp: 002b:00007f9450132c58 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
+Rax: ffffffffffffffda RBX: 000000000073bf00 RCX: 0000000000462e99
+Rdx: 0000000000000000 RSI: 0000000020000100 RDI: 0000000000000003
+Rbp: 00007f9450132c70 R08: 0000000000000000 R09: 0000000000000000
+R10: 0000000000000000 R11: 0000000000000246 R12: 00007f94501336bc
+R13: 00000000004bcefa R14: 00000000006f6fb0 R15: 0000000000000004
+
+Allocated by task 6249:
+ set_track mm/kasan/common.c:85 [inline]
+ __kasan_kmalloc.constprop.3+0xa0/0xd0 mm/kasan/common.c:495
+ kmalloc include/linux/slab.h:545 [inline]
+ kzalloc include/linux/slab.h:740 [inline]
+ bus_add_driver+0xc0/0x610 drivers/base/bus.c:651
+ driver_register+0x1bb/0x3f0 drivers/base/driver.c:170
+ serial_ir_init_module+0xe8/0x1000 [serial_ir]
+ do_one_initcall+0xfa/0x5ca init/main.c:887
+ do_init_module+0x204/0x5f6 kernel/module.c:3460
+ load_module+0x66b2/0x8570 kernel/module.c:3808
+ __do_sys_finit_module+0x238/0x2a0 kernel/module.c:3902
+ do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290
+ entry_SYSCALL_64_after_hwframe+0x49/0xbe
+
+Freed by task 6249:
+ set_track mm/kasan/common.c:85 [inline]
+ __kasan_slab_free+0x130/0x180 mm/kasan/common.c:457
+ slab_free_hook mm/slub.c:1430 [inline]
+ slab_free_freelist_hook mm/slub.c:1457 [inline]
+ slab_free mm/slub.c:3005 [inline]
+ kfree+0xe1/0x270 mm/slub.c:3957
+ kobject_cleanup lib/kobject.c:662 [inline]
+ kobject_release lib/kobject.c:691 [inline]
+ kref_put include/linux/kref.h:67 [inline]
+ kobject_put+0x146/0x240 lib/kobject.c:708
+ bus_remove_driver+0x10e/0x220 drivers/base/bus.c:732
+ driver_unregister+0x6c/0xa0 drivers/base/driver.c:197
+ serial_ir_init_module+0x14c/0x1000 [serial_ir]
+ do_one_initcall+0xfa/0x5ca init/main.c:887
+ do_init_module+0x204/0x5f6 kernel/module.c:3460
+ load_module+0x66b2/0x8570 kernel/module.c:3808
+ __do_sys_finit_module+0x238/0x2a0 kernel/module.c:3902
+ do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290
+ entry_SYSCALL_64_after_hwframe+0x49/0xbe
+
+The buggy address belongs to the object at ffff8881dc7ae000
+ which belongs to the cache kmalloc-256 of size 256
+The buggy address is located 48 bytes inside of
+ 256-byte region [ffff8881dc7ae000, ffff8881dc7ae100)
+The buggy address belongs to the page:
+page:ffffea000771eb80 count:1 mapcount:0 mapping:ffff8881f6c02e00 index:0x0
+Flags: 0x2fffc0000000200(slab)
+Raw: 02fffc0000000200 ffffea0007d14800 0000000400000002 ffff8881f6c02e00
+Raw: 0000000000000000 00000000800c000c 00000001ffffffff 0000000000000000
+page dumped because: kasan: bad access detected
+
+Memory state around the buggy address:
+ ffff8881dc7adf00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+ ffff8881dc7adf80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+>ffff8881dc7ae000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8881dc7ae080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8881dc7ae100: fc fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00
+
+There are already cleanup handlings in serial_ir_init error path,
+no need to call serial_ir_exit do it again in serial_ir_init_module,
+otherwise will trigger a use-after-free issue.
+
+Fixes: fa5dc29c1fcc ("[media] lirc_serial: move out of staging and rename to serial_ir")
+
+Reported-by: Hulk Robot <hulkci@huawei.com>
+Signed-off-by: YueHaibing <yuehaibing@huawei.com>
+Signed-off-by: Sean Young <sean@mess.org>
+Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/media/rc/serial_ir.c | 9 +--------
+ 1 file changed, 1 insertion(+), 8 deletions(-)
+
+diff --git a/drivers/media/rc/serial_ir.c b/drivers/media/rc/serial_ir.c
+index ffe2c672d105..3998ba29beb6 100644
+--- a/drivers/media/rc/serial_ir.c
++++ b/drivers/media/rc/serial_ir.c
+@@ -773,8 +773,6 @@ static void serial_ir_exit(void)
+
+ static int __init serial_ir_init_module(void)
+ {
+- int result;
+-
+ switch (type) {
+ case IR_HOMEBREW:
+ case IR_IRDEO:
+@@ -802,12 +800,7 @@ static int __init serial_ir_init_module(void)
+ if (sense != -1)
+ sense = !!sense;
+
+- result = serial_ir_init();
+- if (!result)
+- return 0;
+-
+- serial_ir_exit();
+- return result;
++ return serial_ir_init();
+ }
+
+ static void __exit serial_ir_exit_module(void)
+--
+2.16.4
+
diff --git a/patches.drivers/media-tw5864-Fix-possible-NULL-pointer-dereference-i.patch b/patches.drivers/media-tw5864-Fix-possible-NULL-pointer-dereference-i.patch
new file mode 100644
index 0000000000..903cea3e5a
--- /dev/null
+++ b/patches.drivers/media-tw5864-Fix-possible-NULL-pointer-dereference-i.patch
@@ -0,0 +1,46 @@
+From 2e7682ebfc750177a4944eeb56e97a3f05734528 Mon Sep 17 00:00:00 2001
+From: YueHaibing <yuehaibing@huawei.com>
+Date: Thu, 14 Mar 2019 22:01:24 -0400
+Subject: [PATCH] media: tw5864: Fix possible NULL pointer dereference in tw5864_handle_frame
+Git-commit: 2e7682ebfc750177a4944eeb56e97a3f05734528
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+'vb' null check should be done before dereferencing it in
+tw5864_handle_frame, otherwise a NULL pointer dereference
+may occur.
+
+Fixes: 34d1324edd31 ("[media] pci: Add tw5864 driver")
+
+Signed-off-by: YueHaibing <yuehaibing@huawei.com>
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/media/pci/tw5864/tw5864-video.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/media/pci/tw5864/tw5864-video.c b/drivers/media/pci/tw5864/tw5864-video.c
+index 5a1f3aa4101a..434d313a3c15 100644
+--- a/drivers/media/pci/tw5864/tw5864-video.c
++++ b/drivers/media/pci/tw5864/tw5864-video.c
+@@ -1395,13 +1395,13 @@ static void tw5864_handle_frame(struct tw5864_h264_frame *frame)
+ input->vb = NULL;
+ spin_unlock_irqrestore(&input->slock, flags);
+
+- v4l2_buf = to_vb2_v4l2_buffer(&vb->vb.vb2_buf);
+-
+ if (!vb) { /* Gone because of disabling */
+ dev_dbg(&dev->pci->dev, "vb is empty, dropping frame\n");
+ return;
+ }
+
++ v4l2_buf = to_vb2_v4l2_buffer(&vb->vb.vb2_buf);
++
+ /*
+ * Check for space.
+ * Mind the overhead of startcode emulation prevention.
+--
+2.16.4
+
diff --git a/patches.drivers/media-vivid-use-vfree-instead-of-kfree-for-dev-bitma.patch b/patches.drivers/media-vivid-use-vfree-instead-of-kfree-for-dev-bitma.patch
new file mode 100644
index 0000000000..7dbf7f646c
--- /dev/null
+++ b/patches.drivers/media-vivid-use-vfree-instead-of-kfree-for-dev-bitma.patch
@@ -0,0 +1,41 @@
+From dad7e270ba712ba1c99cd2d91018af6044447a06 Mon Sep 17 00:00:00 2001
+From: Alexander Potapenko <glider@google.com>
+Date: Thu, 4 Apr 2019 10:56:46 -0400
+Subject: [PATCH] media: vivid: use vfree() instead of kfree() for dev->bitmap_cap
+Git-commit: dad7e270ba712ba1c99cd2d91018af6044447a06
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+syzkaller reported crashes on kfree() called from
+vivid_vid_cap_s_selection(). This looks like a simple typo, as
+dev->bitmap_cap is allocated with vzalloc() throughout the file.
+
+Fixes: ef834f7836ec0 ("[media] vivid: add the video capture and output
+parts")
+
+Signed-off-by: Alexander Potapenko <glider@google.com>
+Reported-by: Syzbot <syzbot+6c0effb5877f6b0344e2@syzkaller.appspotmail.com>
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/media/platform/vivid/vivid-vid-cap.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/media/platform/vivid/vivid-vid-cap.c b/drivers/media/platform/vivid/vivid-vid-cap.c
+index 52eeda624d7e..530ac8decb25 100644
+--- a/drivers/media/platform/vivid/vivid-vid-cap.c
++++ b/drivers/media/platform/vivid/vivid-vid-cap.c
+@@ -1007,7 +1007,7 @@ int vivid_vid_cap_s_selection(struct file *file, void *fh, struct v4l2_selection
+ v4l2_rect_map_inside(&s->r, &dev->fmt_cap_rect);
+ if (dev->bitmap_cap && (compose->width != s->r.width ||
+ compose->height != s->r.height)) {
+- kfree(dev->bitmap_cap);
++ vfree(dev->bitmap_cap);
+ dev->bitmap_cap = NULL;
+ }
+ *compose = s->r;
+--
+2.16.4
+
diff --git a/patches.drivers/media-wl128x-Fix-an-error-code-in-fm_download_firmwa.patch b/patches.drivers/media-wl128x-Fix-an-error-code-in-fm_download_firmwa.patch
new file mode 100644
index 0000000000..08ab610d26
--- /dev/null
+++ b/patches.drivers/media-wl128x-Fix-an-error-code-in-fm_download_firmwa.patch
@@ -0,0 +1,40 @@
+From ef4bb63dc1f7213c08e13f6943c69cd27f69e4a3 Mon Sep 17 00:00:00 2001
+From: Dan Carpenter <dan.carpenter@oracle.com>
+Date: Wed, 6 Mar 2019 02:27:43 -0500
+Subject: [PATCH] media: wl128x: Fix an error code in fm_download_firmware()
+Git-commit: ef4bb63dc1f7213c08e13f6943c69cd27f69e4a3
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+We forgot to set "ret" on this error path.
+
+Fixes: e8454ff7b9a4 ("[media] drivers:media:radio: wl128x: FM Driver Common sources")
+
+Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/media/radio/wl128x/fmdrv_common.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
+index 3c8987af3772..1614809f7d35 100644
+--- a/drivers/media/radio/wl128x/fmdrv_common.c
++++ b/drivers/media/radio/wl128x/fmdrv_common.c
+@@ -1268,8 +1268,9 @@ static int fm_download_firmware(struct fmdev *fmdev, const u8 *fw_name)
+
+ switch (action->type) {
+ case ACTION_SEND_COMMAND: /* Send */
+- if (fmc_send_cmd(fmdev, 0, 0, action->data,
+- action->size, NULL, NULL))
++ ret = fmc_send_cmd(fmdev, 0, 0, action->data,
++ action->size, NULL, NULL);
++ if (ret)
+ goto rel_fw;
+
+ cmd_cnt++;
+--
+2.16.4
+
diff --git a/patches.drivers/media-wl128x-prevent-two-potential-buffer-overflows.patch b/patches.drivers/media-wl128x-prevent-two-potential-buffer-overflows.patch
new file mode 100644
index 0000000000..238ca550b4
--- /dev/null
+++ b/patches.drivers/media-wl128x-prevent-two-potential-buffer-overflows.patch
@@ -0,0 +1,64 @@
+From 9c2ccc324b3a6cbc865ab8b3e1a09e93d3c8ade9 Mon Sep 17 00:00:00 2001
+From: Dan Carpenter <dan.carpenter@oracle.com>
+Date: Tue, 26 Mar 2019 01:12:07 -0400
+Subject: [PATCH] media: wl128x: prevent two potential buffer overflows
+Git-commit: 9c2ccc324b3a6cbc865ab8b3e1a09e93d3c8ade9
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+Smatch marks skb->data as untrusted so it warns that "evt_hdr->dlen"
+can copy up to 255 bytes and we only have room for two bytes. Even
+if this comes from the firmware and we trust it, the new policy
+generally is just to fix it as kernel hardenning.
+
+I can't test this code so I tried to be very conservative. I considered
+not allowing "evt_hdr->dlen == 1" because it doesn't initialize the
+whole variable but in the end I decided to allow it and manually
+initialized "asic_id" and "asic_ver" to zero.
+
+Fixes: e8454ff7b9a4 ("[media] drivers:media:radio: wl128x: FM Driver Common sources")
+
+Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/media/radio/wl128x/fmdrv_common.c | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/media/radio/wl128x/fmdrv_common.c b/drivers/media/radio/wl128x/fmdrv_common.c
+index 1614809f7d35..a1fcb80a2191 100644
+--- a/drivers/media/radio/wl128x/fmdrv_common.c
++++ b/drivers/media/radio/wl128x/fmdrv_common.c
+@@ -489,7 +489,8 @@ int fmc_send_cmd(struct fmdev *fmdev, u8 fm_op, u16 type, void *payload,
+ return -EIO;
+ }
+ /* Send response data to caller */
+- if (response != NULL && response_len != NULL && evt_hdr->dlen) {
++ if (response != NULL && response_len != NULL && evt_hdr->dlen &&
++ evt_hdr->dlen <= payload_len) {
+ /* Skip header info and copy only response data */
+ skb_pull(skb, sizeof(struct fm_event_msg_hdr));
+ memcpy(response, skb->data, evt_hdr->dlen);
+@@ -583,6 +584,8 @@ static void fm_irq_handle_flag_getcmd_resp(struct fmdev *fmdev)
+ return;
+
+ fm_evt_hdr = (void *)skb->data;
++ if (fm_evt_hdr->dlen > sizeof(fmdev->irq_info.flag))
++ return;
+
+ /* Skip header info and copy only response data */
+ skb_pull(skb, sizeof(struct fm_event_msg_hdr));
+@@ -1309,7 +1312,7 @@ static int load_default_rx_configuration(struct fmdev *fmdev)
+ static int fm_power_up(struct fmdev *fmdev, u8 mode)
+ {
+ u16 payload;
+- __be16 asic_id, asic_ver;
++ __be16 asic_id = 0, asic_ver = 0;
+ int resp_len, ret;
+ u8 fw_name[50];
+
+--
+2.16.4
+
diff --git a/patches.drivers/mtd-docg3-Fix-passing-zero-to-PTR_ERR-warning-in-doc.patch b/patches.drivers/mtd-docg3-Fix-passing-zero-to-PTR_ERR-warning-in-doc.patch
new file mode 100644
index 0000000000..1d78c24e1c
--- /dev/null
+++ b/patches.drivers/mtd-docg3-Fix-passing-zero-to-PTR_ERR-warning-in-doc.patch
@@ -0,0 +1,38 @@
+From 32937a82f36c7bbe08db4052de94bc7ade4e3c51 Mon Sep 17 00:00:00 2001
+From: YueHaibing <yuehaibing@huawei.com>
+Date: Wed, 23 Jan 2019 14:58:27 +0800
+Subject: [PATCH] mtd: docg3: Fix passing zero to 'PTR_ERR' warning in doc_probe_device
+Git-commit: 32937a82f36c7bbe08db4052de94bc7ade4e3c51
+Patch-mainline: v5.1-rc1
+References: bsc#1051510
+
+Fix a static code checker warning:
+drivers/mtd/devices/docg3.c:1875
+ doc_probe_device() warn: passing zero to 'ERR_PTR'
+
+Fixes: ae9d4934b2d7 ("mtd: docg3: add multiple floor support")
+Signed-off-by: YueHaibing <yuehaibing@huawei.com>
+Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
+Signed-off-by: Boris Brezillon <bbrezillon@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/mtd/devices/docg3.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
+index 4c94fc096696..60ddc38a5431 100644
+--- a/drivers/mtd/devices/docg3.c
++++ b/drivers/mtd/devices/docg3.c
+@@ -1872,7 +1872,7 @@ doc_probe_device(struct docg3_cascade *cascade, int floor, struct device *dev)
+ nomem2:
+ kfree(docg3);
+ nomem1:
+- return ERR_PTR(ret);
++ return ret ? ERR_PTR(ret) : NULL;
+ }
+
+ /**
+--
+2.16.4
+
diff --git a/patches.drivers/mtd-docg3-fix-a-possible-memory-leak-of-mtd-name.patch b/patches.drivers/mtd-docg3-fix-a-possible-memory-leak-of-mtd-name.patch
new file mode 100644
index 0000000000..cc6078d719
--- /dev/null
+++ b/patches.drivers/mtd-docg3-fix-a-possible-memory-leak-of-mtd-name.patch
@@ -0,0 +1,46 @@
+From b0dd77a796423ad3c609b6708260adca85a0798f Mon Sep 17 00:00:00 2001
+From: YueHaibing <yuehaibing@huawei.com>
+Date: Fri, 25 Jan 2019 10:12:42 +0800
+Subject: [PATCH] mtd: docg3: fix a possible memory leak of mtd->name
+Git-commit: b0dd77a796423ad3c609b6708260adca85a0798f
+Patch-mainline: v5.1-rc1
+References: bsc#1051510
+
+In case DOC_CHIPID_G3, mtd->name is not freed in err handling path,
+which is alloced by kasprintf(). Fix this by using devm_kasprintf().
+
+Fixes: ae9d4934b2d7 ("mtd: docg3: add multiple floor support")
+Signed-off-by: YueHaibing <yuehaibing@huawei.com>
+Signed-off-by: Boris Brezillon <bbrezillon@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/mtd/devices/docg3.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
+index 60ddc38a5431..7754803e3463 100644
+--- a/drivers/mtd/devices/docg3.c
++++ b/drivers/mtd/devices/docg3.c
+@@ -1767,8 +1767,8 @@ static int __init doc_set_driver_info(int chip_id, struct mtd_info *mtd)
+
+ switch (chip_id) {
+ case DOC_CHIPID_G3:
+- mtd->name = kasprintf(GFP_KERNEL, "docg3.%d",
+- docg3->device_id);
++ mtd->name = devm_kasprintf(docg3->dev, GFP_KERNEL, "docg3.%d",
++ docg3->device_id);
+ if (!mtd->name)
+ return -ENOMEM;
+ docg3->max_block = 2047;
+@@ -1886,7 +1886,6 @@ static void doc_release_device(struct mtd_info *mtd)
+ mtd_device_unregister(mtd);
+ kfree(docg3->bbt);
+ kfree(docg3);
+- kfree(mtd->name);
+ kfree(mtd);
+ }
+
+--
+2.16.4
+
diff --git a/patches.drivers/mtd-nand-omap-Fix-comment-in-platform-data-using-wro.patch b/patches.drivers/mtd-nand-omap-Fix-comment-in-platform-data-using-wro.patch
new file mode 100644
index 0000000000..8caac6e39d
--- /dev/null
+++ b/patches.drivers/mtd-nand-omap-Fix-comment-in-platform-data-using-wro.patch
@@ -0,0 +1,34 @@
+From e90a619fb7e1acb5e18f1ab618c6d10b08f0fc70 Mon Sep 17 00:00:00 2001
+From: Miquel Raynal <miquel.raynal@bootlin.com>
+Date: Thu, 7 Feb 2019 15:28:24 +0100
+Subject: [PATCH] mtd: nand: omap: Fix comment in platform data using wrong Kconfig symbol
+Git-commit: e90a619fb7e1acb5e18f1ab618c6d10b08f0fc70
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+The symbol that is being used in the #if/#endif block is not the one
+which is mentioned at the bottom.
+
+Fixes: 93af53b8633c ("nand: omap2: Remove horrible ifdefs to fix module probe")
+Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ include/linux/platform_data/elm.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/linux/platform_data/elm.h b/include/linux/platform_data/elm.h
+index b8686c00f15f..fef4b081b736 100644
+--- a/include/linux/platform_data/elm.h
++++ b/include/linux/platform_data/elm.h
+@@ -60,6 +60,6 @@ static inline int elm_config(struct device *dev, enum bch_ecc bch_type,
+ {
+ return -ENOSYS;
+ }
+-#endif /* CONFIG_MTD_NAND_ECC_BCH */
++#endif /* CONFIG_MTD_NAND_OMAP_BCH */
+
+ #endif /* __ELM_H */
+--
+2.16.4
+
diff --git a/patches.drivers/mtd-part-fix-incorrect-format-specifier-for-an-unsig.patch b/patches.drivers/mtd-part-fix-incorrect-format-specifier-for-an-unsig.patch
new file mode 100644
index 0000000000..053b532d9a
--- /dev/null
+++ b/patches.drivers/mtd-part-fix-incorrect-format-specifier-for-an-unsig.patch
@@ -0,0 +1,40 @@
+From 3008ba87093852f3756c5d33f584602e5e2a4aa4 Mon Sep 17 00:00:00 2001
+From: Colin Ian King <colin.king@canonical.com>
+Date: Thu, 31 Jan 2019 14:08:20 +0000
+Subject: [PATCH] mtd: part: fix incorrect format specifier for an unsigned long long
+Git-commit: 3008ba87093852f3756c5d33f584602e5e2a4aa4
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+An unsigned long long is being formatted with %lld instead of the unsigned
+version %llu. Fix this.
+
+Clean up cppcheck warning:
+%lld in format string (no. 1) requires 'long long' but the argument type
+is 'unsigned long long'.
+
+Fixes: a62c24d75529 ("mtd: part: Add sysfs variable for offset of partition")
+Signed-off-by: Colin Ian King <colin.king@canonical.com>
+Signed-off-by: Richard Weinberger <richard@nod.at>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/mtd/mtdpart.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
+index 37f174ccbcec..dfa241ad018b 100644
+--- a/drivers/mtd/mtdpart.c
++++ b/drivers/mtd/mtdpart.c
+@@ -572,7 +572,7 @@ static ssize_t mtd_partition_offset_show(struct device *dev,
+ {
+ struct mtd_info *mtd = dev_get_drvdata(dev);
+ struct mtd_part *part = mtd_to_part(mtd);
+- return snprintf(buf, PAGE_SIZE, "%lld\n", part->offset);
++ return snprintf(buf, PAGE_SIZE, "%llu\n", part->offset);
+ }
+
+ static DEVICE_ATTR(offset, S_IRUGO, mtd_partition_offset_show, NULL);
+--
+2.16.4
+
diff --git a/patches.drivers/net-ibmvnic-Update-MAC-address-settings-after-adapte.patch b/patches.drivers/net-ibmvnic-Update-MAC-address-settings-after-adapte.patch
new file mode 100644
index 0000000000..f91883fe2c
--- /dev/null
+++ b/patches.drivers/net-ibmvnic-Update-MAC-address-settings-after-adapte.patch
@@ -0,0 +1,160 @@
+From 62740e97881c78b45a117a358a866fb32975def6 Mon Sep 17 00:00:00 2001
+From: Thomas Falcon <tlfalcon@linux.ibm.com>
+Date: Thu, 9 May 2019 23:13:43 -0500
+Subject: [PATCH] net/ibmvnic: Update MAC address settings after adapter reset
+
+References: bsc#1134760
+Patch-mainline: v5.2-rc1
+Git-commit: 62740e97881c78b45a117a358a866fb32975def6
+
+It was discovered in testing that the underlying hardware MAC
+address will revert to initial settings following a device reset,
+but the driver fails to resend the current OS MAC settings. This
+oversight can result in dropped packets should the scenario occur.
+Fix this by informing hardware of current MAC address settings
+following any adapter initialization or resets.
+
+Signed-off-by: Thomas Falcon <tlfalcon@linux.ibm.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Acked-by: Michal Suchanek <msuchanek@suse.de>
+---
+ drivers/net/ethernet/ibm/ibmvnic.c | 53 ++++++++++++++++--------------
+ drivers/net/ethernet/ibm/ibmvnic.h | 2 --
+ 2 files changed, 28 insertions(+), 27 deletions(-)
+
+diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
+index b398d6c94dbd..2be3bcd0192f 100644
+--- a/drivers/net/ethernet/ibm/ibmvnic.c
++++ b/drivers/net/ethernet/ibm/ibmvnic.c
+@@ -118,7 +118,7 @@ static int init_sub_crq_irqs(struct ibmvnic_adapter *adapter);
+ static int ibmvnic_init(struct ibmvnic_adapter *);
+ static int ibmvnic_reset_init(struct ibmvnic_adapter *);
+ static void release_crq_queue(struct ibmvnic_adapter *);
+-static int __ibmvnic_set_mac(struct net_device *netdev, struct sockaddr *p);
++static int __ibmvnic_set_mac(struct net_device *, u8 *);
+ static int init_crq_queue(struct ibmvnic_adapter *adapter);
+ static int send_query_phys_parms(struct ibmvnic_adapter *adapter);
+
+@@ -849,11 +849,7 @@ static int ibmvnic_login(struct net_device *netdev)
+ }
+ } while (retry);
+
+- /* handle pending MAC address changes after successful login */
+- if (adapter->mac_change_pending) {
+- __ibmvnic_set_mac(netdev, &adapter->desired.mac);
+- adapter->mac_change_pending = false;
+- }
++ __ibmvnic_set_mac(netdev, adapter->mac_addr);
+
+ return 0;
+ }
+@@ -1686,28 +1682,40 @@ static void ibmvnic_set_multi(struct net_device *netdev)
+ }
+ }
+
+-static int __ibmvnic_set_mac(struct net_device *netdev, struct sockaddr *p)
++static int __ibmvnic_set_mac(struct net_device *netdev, u8 *dev_addr)
+ {
+ struct ibmvnic_adapter *adapter = netdev_priv(netdev);
+- struct sockaddr *addr = p;
+ union ibmvnic_crq crq;
+ int rc;
+
+- if (!is_valid_ether_addr(addr->sa_data))
+- return -EADDRNOTAVAIL;
++ if (!is_valid_ether_addr(dev_addr)) {
++ rc = -EADDRNOTAVAIL;
++ goto err;
++ }
+
+ memset(&crq, 0, sizeof(crq));
+ crq.change_mac_addr.first = IBMVNIC_CRQ_CMD;
+ crq.change_mac_addr.cmd = CHANGE_MAC_ADDR;
+- ether_addr_copy(&crq.change_mac_addr.mac_addr[0], addr->sa_data);
++ ether_addr_copy(&crq.change_mac_addr.mac_addr[0], dev_addr);
+
+ init_completion(&adapter->fw_done);
+ rc = ibmvnic_send_crq(adapter, &crq);
+- if (rc)
+- return rc;
++ if (rc) {
++ rc = -EIO;
++ goto err;
++ }
++
+ wait_for_completion(&adapter->fw_done);
+ /* netdev->dev_addr is changed in handle_change_mac_rsp function */
+- return adapter->fw_done_rc ? -EIO : 0;
++ if (adapter->fw_done_rc) {
++ rc = -EIO;
++ goto err;
++ }
++
++ return 0;
++err:
++ ether_addr_copy(adapter->mac_addr, netdev->dev_addr);
++ return rc;
+ }
+
+ static int ibmvnic_set_mac(struct net_device *netdev, void *p)
+@@ -1716,13 +1724,10 @@ static int ibmvnic_set_mac(struct net_device *netdev, void *p)
+ struct sockaddr *addr = p;
+ int rc;
+
+- if (adapter->state == VNIC_PROBED) {
+- memcpy(&adapter->desired.mac, addr, sizeof(struct sockaddr));
+- adapter->mac_change_pending = true;
+- return 0;
+- }
+-
+- rc = __ibmvnic_set_mac(netdev, addr);
++ rc = 0;
++ ether_addr_copy(adapter->mac_addr, addr->sa_data);
++ if (adapter->state != VNIC_PROBED)
++ rc = __ibmvnic_set_mac(netdev, addr->sa_data);
+
+ return rc;
+ }
+@@ -3937,8 +3942,8 @@ static int handle_change_mac_rsp(union ibmvnic_crq *crq,
+ dev_err(dev, "Error %ld in CHANGE_MAC_ADDR_RSP\n", rc);
+ goto out;
+ }
+- memcpy(netdev->dev_addr, &crq->change_mac_addr_rsp.mac_addr[0],
+- ETH_ALEN);
++ ether_addr_copy(netdev->dev_addr,
++ &crq->change_mac_addr_rsp.mac_addr[0]);
+ out:
+ complete(&adapter->fw_done);
+ return rc;
+@@ -4852,8 +4857,6 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
+ init_completion(&adapter->init_done);
+ adapter->resetting = false;
+
+- adapter->mac_change_pending = false;
+-
+ do {
+ rc = init_crq_queue(adapter);
+ if (rc) {
+diff --git a/drivers/net/ethernet/ibm/ibmvnic.h b/drivers/net/ethernet/ibm/ibmvnic.h
+index cffdac372a33..dcf2eb6d9290 100644
+--- a/drivers/net/ethernet/ibm/ibmvnic.h
++++ b/drivers/net/ethernet/ibm/ibmvnic.h
+@@ -969,7 +969,6 @@ struct ibmvnic_tunables {
+ u64 rx_entries;
+ u64 tx_entries;
+ u64 mtu;
+- struct sockaddr mac;
+ };
+
+ struct ibmvnic_adapter {
+@@ -1091,7 +1090,6 @@ struct ibmvnic_adapter {
+ bool resetting;
+ bool napi_enabled, from_passive_init;
+
+- bool mac_change_pending;
+ bool failover_pending;
+ bool force_reset_recovery;
+
+--
+2.20.1
+
diff --git a/patches.drivers/net-ibmvnic-Update-carrier-state-after-link-state-ch.patch b/patches.drivers/net-ibmvnic-Update-carrier-state-after-link-state-ch.patch
new file mode 100644
index 0000000000..5acb3e95be
--- /dev/null
+++ b/patches.drivers/net-ibmvnic-Update-carrier-state-after-link-state-ch.patch
@@ -0,0 +1,66 @@
+From 0655f9943df2f2d71f406fd77b51d05548134fc2 Mon Sep 17 00:00:00 2001
+From: Thomas Falcon <tlfalcon@linux.ibm.com>
+Date: Thu, 9 May 2019 23:13:44 -0500
+Subject: [PATCH] net/ibmvnic: Update carrier state after link state change
+
+References: bsc#1135100
+Patch-mainline: v5.2-rc1
+Git-commit: 0655f9943df2f2d71f406fd77b51d05548134fc2
+
+Only set the device carrier state to on after receiving an up link
+state indication from the underlying adapter. Likewise, if a down
+link indication is receieved, update the carrier state accordingly.
+This fix ensures that accurate carrier state is reported by the driver
+following a link state update by the underlying adapter.
+
+Signed-off-by: Thomas Falcon <tlfalcon@linux.ibm.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Acked-by: Michal Suchanek <msuchanek@suse.de>
+---
+ drivers/net/ethernet/ibm/ibmvnic.c | 9 ++++-----
+ 1 file changed, 4 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
+index 2be3bcd0192f..3dcd9c3d8781 100644
+--- a/drivers/net/ethernet/ibm/ibmvnic.c
++++ b/drivers/net/ethernet/ibm/ibmvnic.c
+@@ -1111,7 +1111,6 @@ static int ibmvnic_open(struct net_device *netdev)
+ }
+
+ rc = __ibmvnic_open(netdev);
+- netif_carrier_on(netdev);
+
+ return rc;
+ }
+@@ -1864,8 +1863,6 @@ static int do_reset(struct ibmvnic_adapter *adapter,
+ adapter->reset_reason != VNIC_RESET_CHANGE_PARAM)
+ call_netdevice_notifiers(NETDEV_NOTIFY_PEERS, netdev);
+
+- netif_carrier_on(netdev);
+-
+ return 0;
+ }
+
+@@ -1935,8 +1932,6 @@ static int do_hard_reset(struct ibmvnic_adapter *adapter,
+ return 0;
+ }
+
+- netif_carrier_on(netdev);
+-
+ return 0;
+ }
+
+@@ -4480,6 +4475,10 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq,
+ crq->link_state_indication.phys_link_state;
+ adapter->logical_link_state =
+ crq->link_state_indication.logical_link_state;
++ if (adapter->phys_link_state && adapter->logical_link_state)
++ netif_carrier_on(netdev);
++ else
++ netif_carrier_off(netdev);
+ break;
+ case CHANGE_MAC_ADDR_RSP:
+ netdev_dbg(netdev, "Got MAC address change Response\n");
+--
+2.20.1
+
diff --git a/patches.drivers/omapfb-add-missing-of_node_put-after-of_device_is_av.patch b/patches.drivers/omapfb-add-missing-of_node_put-after-of_device_is_av.patch
new file mode 100644
index 0000000000..40a103d589
--- /dev/null
+++ b/patches.drivers/omapfb-add-missing-of_node_put-after-of_device_is_av.patch
@@ -0,0 +1,64 @@
+From 787a79230a0f9984e59549b9baa4daf274973a0d Mon Sep 17 00:00:00 2001
+From: Julia Lawall <Julia.Lawall@lip6.fr>
+Date: Mon, 1 Apr 2019 17:46:56 +0200
+Subject: [PATCH] omapfb: add missing of_node_put after of_device_is_available
+Git-commit: 787a79230a0f9984e59549b9baa4daf274973a0d
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+Add an of_node_put when a tested device node is not available.
+
+The semantic patch that fixes this problem is as follows
+(http://coccinelle.lip6.fr):
+
+// <smpl>
+@@
+identifier f;
+local idexpression e;
+expression x;
+@@
+
+e = f(...);
+... when != of_node_put(e)
+ when != x = e
+ when != e = x
+ when any
+if (<+...of_device_is_available(e)...+>) {
+ ... when != of_node_put(e)
+(
+ return e;
+|
++ of_node_put(e);
+ return ...;
+)
+}
+// </smpl>
+
+Fixes: f76ee892a99e6 ("omapfb: copy omapdss & displays for omapfb")
+Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
+Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c b/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c
+index 136d30484d02..cb6acbac9c47 100644
+--- a/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c
++++ b/drivers/video/fbdev/omap2/omapfb/dss/omapdss-boot-init.c
+@@ -193,8 +193,10 @@ static int __init omapdss_boot_init(void)
+
+ dss = of_find_matching_node(NULL, omapdss_of_match);
+
+- if (dss == NULL || !of_device_is_available(dss))
++ if (dss == NULL || !of_device_is_available(dss)) {
++ of_node_put(dss);
+ return 0;
++ }
+
+ omapdss_walk_device(dss, true);
+
+--
+2.16.4
+
diff --git a/patches.drivers/phy-sun4i-usb-Make-sure-to-disable-PHY0-passby-for-p.patch b/patches.drivers/phy-sun4i-usb-Make-sure-to-disable-PHY0-passby-for-p.patch
new file mode 100644
index 0000000000..84e3a9aa93
--- /dev/null
+++ b/patches.drivers/phy-sun4i-usb-Make-sure-to-disable-PHY0-passby-for-p.patch
@@ -0,0 +1,50 @@
+From e6f32efb1b128344a2c7df9875bc1a1abaa1d395 Mon Sep 17 00:00:00 2001
+From: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
+Date: Thu, 14 Mar 2019 14:05:18 +0100
+Subject: [PATCH] phy: sun4i-usb: Make sure to disable PHY0 passby for peripheral mode
+Git-commit: e6f32efb1b128344a2c7df9875bc1a1abaa1d395
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+On platforms where the MUSB and HCI controllers share PHY0, PHY passby
+is required when using the HCI controller with the PHY, but it must be
+disabled when the MUSB controller is used instead.
+
+Without this, PHY0 passby is always enabled, which results in broken
+peripheral mode on such platforms (e.g. H3/H5).
+
+Fixes: ba4bdc9e1dc0 ("PHY: sunxi: Add driver for sunxi usb phy")
+
+Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
+Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/phy/allwinner/phy-sun4i-usb.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
+index 5163097b43df..7b23920e0068 100644
+--- a/drivers/phy/allwinner/phy-sun4i-usb.c
++++ b/drivers/phy/allwinner/phy-sun4i-usb.c
+@@ -551,6 +551,7 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)
+ struct sun4i_usb_phy_data *data =
+ container_of(work, struct sun4i_usb_phy_data, detect.work);
+ struct phy *phy0 = data->phys[0].phy;
++ struct sun4i_usb_phy *phy = phy_get_drvdata(phy0);
+ bool force_session_end, id_notify = false, vbus_notify = false;
+ int id_det, vbus_det;
+
+@@ -607,6 +608,9 @@ static void sun4i_usb_phy0_id_vbus_det_scan(struct work_struct *work)
+ mutex_unlock(&phy0->mutex);
+ }
+
++ /* Enable PHY0 passby for host mode only. */
++ sun4i_usb_phy_passby(phy, !id_det);
++
+ /* Re-route PHY0 if necessary */
+ if (data->cfg->phy0_dual_route)
+ sun4i_usb_phy0_reroute(data, id_det);
+--
+2.16.4
+
diff --git a/patches.drivers/platform-x86-alienware-wmi-printing-the-wrong-error-.patch b/patches.drivers/platform-x86-alienware-wmi-printing-the-wrong-error-.patch
new file mode 100644
index 0000000000..e0e651a6f1
--- /dev/null
+++ b/patches.drivers/platform-x86-alienware-wmi-printing-the-wrong-error-.patch
@@ -0,0 +1,38 @@
+From 6d1f8b3d75419a8659ac916a1e9543bb3513a882 Mon Sep 17 00:00:00 2001
+From: Dan Carpenter <dan.carpenter@oracle.com>
+Date: Wed, 24 Apr 2019 12:44:18 +0300
+Subject: [PATCH] platform/x86: alienware-wmi: printing the wrong error code
+Git-commit: 6d1f8b3d75419a8659ac916a1e9543bb3513a882
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+The "out_data" variable is uninitialized at the point. Originally, this
+used to print "status" instead and that seems like the correct thing to
+print.
+
+Fixes: bc2ef884320b ("alienware-wmi: For WMAX HDMI method, introduce a way to query HDMI cable status")
+Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
+Reviewed-by: Mario Limonciello <mario.limonciello@dell.com>
+Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/platform/x86/alienware-wmi.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c
+index c0d1555735cd..83fd7677af24 100644
+--- a/drivers/platform/x86/alienware-wmi.c
++++ b/drivers/platform/x86/alienware-wmi.c
+@@ -587,7 +587,7 @@ static ssize_t show_hdmi_source(struct device *dev,
+ return scnprintf(buf, PAGE_SIZE,
+ "input [gpu] unknown\n");
+ }
+- pr_err("alienware-wmi: unknown HDMI source status: %d\n", out_data);
++ pr_err("alienware-wmi: unknown HDMI source status: %u\n", status);
+ return scnprintf(buf, PAGE_SIZE, "input gpu [unknown]\n");
+ }
+
+--
+2.16.4
+
diff --git a/patches.drivers/platform-x86-dell-rbtn-Add-missing-include.patch b/patches.drivers/platform-x86-dell-rbtn-Add-missing-include.patch
new file mode 100644
index 0000000000..de90109446
--- /dev/null
+++ b/patches.drivers/platform-x86-dell-rbtn-Add-missing-include.patch
@@ -0,0 +1,45 @@
+From e28f296ea155da36f710eb1f1173d8780fbac49d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Valdis=20Kl=20=C4=93=20tnieks?= <valdis.kletnieks@vt.edu>
+Date: Tue, 12 Mar 2019 07:26:06 -0400
+Subject: [PATCH] platform/x86: dell-rbtn: Add missing #include
+Git-commit: e28f296ea155da36f710eb1f1173d8780fbac49d
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+Building with W=1 complains:
+ CC [M] drivers/platform/x86/dell-rbtn.o
+drivers/platform/x86/dell-rbtn.c:345:5: warning: no previous prototype for 'dell_rbtn_notifier_register' [-Wmissing-prototypes]
+ 345 | int dell_rbtn_notifier_register(struct notifier_block *nb)
+ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
+drivers/platform/x86/dell-rbtn.c:371:5: warning: no previous prototype for 'dell_rbtn_notifier_unregister' [-Wmissing-prototypes]
+ 371 | int dell_rbtn_notifier_unregister(struct notifier_block *nb)
+ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The real problem is a missing include. Add it to keep dell-rbtn.c and .h in sync.
+
+Fixes: b05ffc95f9ed ("dell-rbtn: Export notifier for other kernel modules")
+Signed-off-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
+[andy: massaged commit message, added Fixes tag]
+Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/platform/x86/dell-rbtn.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/platform/x86/dell-rbtn.c b/drivers/platform/x86/dell-rbtn.c
+index f3afe778001e..56535d7222dd 100644
+--- a/drivers/platform/x86/dell-rbtn.c
++++ b/drivers/platform/x86/dell-rbtn.c
+@@ -18,6 +18,8 @@
+ #include <linux/rfkill.h>
+ #include <linux/input.h>
+
++#include "dell-rbtn.h"
++
+ enum rbtn_type {
+ RBTN_UNKNOWN,
+ RBTN_TOGGLE,
+--
+2.16.4
+
diff --git a/patches.drivers/platform-x86-intel_pmc_ipc-adding-error-handling.patch b/patches.drivers/platform-x86-intel_pmc_ipc-adding-error-handling.patch
new file mode 100644
index 0000000000..16ef664c18
--- /dev/null
+++ b/patches.drivers/platform-x86-intel_pmc_ipc-adding-error-handling.patch
@@ -0,0 +1,49 @@
+From e61985d0550df8c2078310202aaad9b41049c36c Mon Sep 17 00:00:00 2001
+From: Junxiao Chang <junxiao.chang@intel.com>
+Date: Mon, 8 Apr 2019 17:40:22 +0800
+Subject: [PATCH] platform/x86: intel_pmc_ipc: adding error handling
+Git-commit: e61985d0550df8c2078310202aaad9b41049c36c
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+If punit or telemetry device initialization fails, pmc driver should
+unregister and return failure.
+
+This change is to fix a kernel panic when removing kernel module
+intel_pmc_ipc.
+
+Fixes: 48c1917088ba ("platform:x86: Add Intel telemetry platform device")
+Signed-off-by: Junxiao Chang <junxiao.chang@intel.com>
+Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/platform/x86/intel_pmc_ipc.c | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/platform/x86/intel_pmc_ipc.c b/drivers/platform/x86/intel_pmc_ipc.c
+index 7964ba22ef8d..d37cbd1cf58c 100644
+--- a/drivers/platform/x86/intel_pmc_ipc.c
++++ b/drivers/platform/x86/intel_pmc_ipc.c
+@@ -771,13 +771,17 @@ static int ipc_create_pmc_devices(void)
+ if (ret) {
+ dev_err(ipcdev.dev, "Failed to add punit platform device\n");
+ platform_device_unregister(ipcdev.tco_dev);
++ return ret;
+ }
+
+ if (!ipcdev.telem_res_inval) {
+ ret = ipc_create_telemetry_device();
+- if (ret)
++ if (ret) {
+ dev_warn(ipcdev.dev,
+ "Failed to add telemetry platform device\n");
++ platform_device_unregister(ipcdev.punit_dev);
++ platform_device_unregister(ipcdev.tco_dev);
++ }
+ }
+
+ return ret;
+--
+2.16.4
+
diff --git a/patches.drivers/platform-x86-intel_punit_ipc-Revert-Fix-resource-ior.patch b/patches.drivers/platform-x86-intel_punit_ipc-Revert-Fix-resource-ior.patch
new file mode 100644
index 0000000000..b650374073
--- /dev/null
+++ b/patches.drivers/platform-x86-intel_punit_ipc-Revert-Fix-resource-ior.patch
@@ -0,0 +1,61 @@
+From 0e5e80043b0db4c292aaf0ea86415da6193f861a Mon Sep 17 00:00:00 2001
+From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Date: Tue, 9 Apr 2019 14:25:15 +0300
+Subject: [PATCH] platform/x86: intel_punit_ipc: Revert "Fix resource ioremap warning"
+Git-commit: 0e5e80043b0db4c292aaf0ea86415da6193f861a
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+Since we have a proper fix for intel_pmc_ipc driver for resource management,
+get rid of unneeded commit in the intel_punit_ipc driver.
+
+This reverts commit 6cc8cbbc8868033f279b63e98b26b75eaa0006ab.
+
+Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/platform/x86/intel_punit_ipc.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/platform/x86/intel_punit_ipc.c b/drivers/platform/x86/intel_punit_ipc.c
+index 79671927f4ef..ab7ae1950867 100644
+--- a/drivers/platform/x86/intel_punit_ipc.c
++++ b/drivers/platform/x86/intel_punit_ipc.c
+@@ -252,28 +252,28 @@ static int intel_punit_get_bars(struct platform_device *pdev)
+ * - GTDRIVER_IPC BASE_IFACE
+ */
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+- if (res && resource_size(res) > 1) {
++ if (res) {
+ addr = devm_ioremap_resource(&pdev->dev, res);
+ if (!IS_ERR(addr))
+ punit_ipcdev->base[ISPDRIVER_IPC][BASE_DATA] = addr;
+ }
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
+- if (res && resource_size(res) > 1) {
++ if (res) {
+ addr = devm_ioremap_resource(&pdev->dev, res);
+ if (!IS_ERR(addr))
+ punit_ipcdev->base[ISPDRIVER_IPC][BASE_IFACE] = addr;
+ }
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 4);
+- if (res && resource_size(res) > 1) {
++ if (res) {
+ addr = devm_ioremap_resource(&pdev->dev, res);
+ if (!IS_ERR(addr))
+ punit_ipcdev->base[GTDRIVER_IPC][BASE_DATA] = addr;
+ }
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 5);
+- if (res && resource_size(res) > 1) {
++ if (res) {
+ addr = devm_ioremap_resource(&pdev->dev, res);
+ if (!IS_ERR(addr))
+ punit_ipcdev->base[GTDRIVER_IPC][BASE_IFACE] = addr;
+--
+2.16.4
+
diff --git a/patches.drivers/platform-x86-sony-laptop-Fix-unintentional-fall-thro.patch b/patches.drivers/platform-x86-sony-laptop-Fix-unintentional-fall-thro.patch
new file mode 100644
index 0000000000..b8e921de15
--- /dev/null
+++ b/patches.drivers/platform-x86-sony-laptop-Fix-unintentional-fall-thro.patch
@@ -0,0 +1,57 @@
+From 1cbd7a64959d33e7a2a1fa2bf36a62b350a9fcbd Mon Sep 17 00:00:00 2001
+From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
+Date: Wed, 24 Apr 2019 13:09:34 -0500
+Subject: [PATCH] platform/x86: sony-laptop: Fix unintentional fall-through
+Git-commit: 1cbd7a64959d33e7a2a1fa2bf36a62b350a9fcbd
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+It seems that the default case should return AE_CTRL_TERMINATE, instead
+of falling through to case ACPI_RESOURCE_TYPE_END_TAG and returning AE_OK;
+otherwise the line of code at the end of the function is unreachable and
+makes no sense:
+
+return AE_CTRL_TERMINATE;
+
+This fix is based on the following thread of discussion:
+
+https://lore.kernel.org/patchwork/patch/959782/
+
+Fixes: 33a04454527e ("sony-laptop: Add SNY6001 device handling (sonypi reimplementation)")
+Cc: stable@vger.kernel.org
+Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
+Reviewed-by: Kees Cook <keescook@chromium.org>
+Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/platform/x86/sony-laptop.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
+index 4bfbfa3f78e6..2058445fc456 100644
+--- a/drivers/platform/x86/sony-laptop.c
++++ b/drivers/platform/x86/sony-laptop.c
+@@ -4424,14 +4424,16 @@ sony_pic_read_possible_resource(struct acpi_resource *resource, void *context)
+ }
+ return AE_OK;
+ }
++
++ case ACPI_RESOURCE_TYPE_END_TAG:
++ return AE_OK;
++
+ default:
+ dprintk("Resource %d isn't an IRQ nor an IO port\n",
+ resource->type);
++ return AE_CTRL_TERMINATE;
+
+- case ACPI_RESOURCE_TYPE_END_TAG:
+- return AE_OK;
+ }
+- return AE_CTRL_TERMINATE;
+ }
+
+ static int sony_pic_possible_resources(struct acpi_device *device)
+--
+2.16.4
+
diff --git a/patches.drivers/pwm-Fix-deadlock-warning-when-removing-PWM-device.patch b/patches.drivers/pwm-Fix-deadlock-warning-when-removing-PWM-device.patch
new file mode 100644
index 0000000000..3ef35ff60f
--- /dev/null
+++ b/patches.drivers/pwm-Fix-deadlock-warning-when-removing-PWM-device.patch
@@ -0,0 +1,277 @@
+From 347ab9480313737c0f1aaa08e8f2e1a791235535 Mon Sep 17 00:00:00 2001
+From: Phong Hoang <phong.hoang.wz@renesas.com>
+Date: Tue, 19 Mar 2019 19:40:08 +0900
+Subject: [PATCH] pwm: Fix deadlock warning when removing PWM device
+Mime-version: 1.0
+Content-type: text/plain; charset=UTF-8
+Content-transfer-encoding: 8bit
+Git-commit: 347ab9480313737c0f1aaa08e8f2e1a791235535
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+This patch fixes deadlock warning if removing PWM device
+when CONFIG_PROVE_LOCKING is enabled.
+
+This issue can be reproceduced by the following steps on
+the R-Car H3 Salvator-X board if the backlight is disabled:
+
+ # cd /sys/class/pwm/pwmchip0
+ # echo 0 > export
+ # ls
+ device export npwm power pwm0 subsystem uevent unexport
+ # cd device/driver
+ # ls
+ bind e6e31000.pwm uevent unbind
+ # echo e6e31000.pwm > unbind
+
+[ 87.659974] ======================================================
+[ 87.666149] WARNING: possible circular locking dependency detected
+[ 87.672327] 5.0.0 #7 Not tainted
+[ 87.675549] ------------------------------------------------------
+[ 87.681723] bash/2986 is trying to acquire lock:
+[ 87.686337] 000000005ea0e178 (kn->count#58){++++}, at: kernfs_remove_by_name_ns+0x50/0xa0
+[ 87.694528]
+[ 87.694528] but task is already holding lock:
+[ 87.700353] 000000006313b17c (pwm_lock){+.+.}, at: pwmchip_remove+0x28/0x13c
+[ 87.707405]
+[ 87.707405] which lock already depends on the new lock.
+[ 87.707405]
+[ 87.715574]
+[ 87.715574] the existing dependency chain (in reverse order) is:
+[ 87.723048]
+[ 87.723048] -> #1 (pwm_lock){+.+.}:
+[ 87.728017] __mutex_lock+0x70/0x7e4
+[ 87.732108] mutex_lock_nested+0x1c/0x24
+[ 87.736547] pwm_request_from_chip.part.6+0x34/0x74
+[ 87.741940] pwm_request_from_chip+0x20/0x40
+[ 87.746725] export_store+0x6c/0x1f4
+[ 87.750820] dev_attr_store+0x18/0x28
+[ 87.754998] sysfs_kf_write+0x54/0x64
+[ 87.759175] kernfs_fop_write+0xe4/0x1e8
+[ 87.763615] __vfs_write+0x40/0x184
+[ 87.767619] vfs_write+0xa8/0x19c
+[ 87.771448] ksys_write+0x58/0xbc
+[ 87.775278] __arm64_sys_write+0x18/0x20
+[ 87.779721] el0_svc_common+0xd0/0x124
+[ 87.783986] el0_svc_compat_handler+0x1c/0x24
+[ 87.788858] el0_svc_compat+0x8/0x18
+[ 87.792947]
+[ 87.792947] -> #0 (kn->count#58){++++}:
+[ 87.798260] lock_acquire+0xc4/0x22c
+[ 87.802353] __kernfs_remove+0x258/0x2c4
+[ 87.806790] kernfs_remove_by_name_ns+0x50/0xa0
+[ 87.811836] remove_files.isra.1+0x38/0x78
+[ 87.816447] sysfs_remove_group+0x48/0x98
+[ 87.820971] sysfs_remove_groups+0x34/0x4c
+[ 87.825583] device_remove_attrs+0x6c/0x7c
+[ 87.830197] device_del+0x11c/0x33c
+[ 87.834201] device_unregister+0x14/0x2c
+[ 87.838638] pwmchip_sysfs_unexport+0x40/0x4c
+[ 87.843509] pwmchip_remove+0xf4/0x13c
+[ 87.847773] rcar_pwm_remove+0x28/0x34
+[ 87.852039] platform_drv_remove+0x24/0x64
+[ 87.856651] device_release_driver_internal+0x18c/0x21c
+[ 87.862391] device_release_driver+0x14/0x1c
+[ 87.867175] unbind_store+0xe0/0x124
+[ 87.871265] drv_attr_store+0x20/0x30
+[ 87.875442] sysfs_kf_write+0x54/0x64
+[ 87.879618] kernfs_fop_write+0xe4/0x1e8
+[ 87.884055] __vfs_write+0x40/0x184
+[ 87.888057] vfs_write+0xa8/0x19c
+[ 87.891887] ksys_write+0x58/0xbc
+[ 87.895716] __arm64_sys_write+0x18/0x20
+[ 87.900154] el0_svc_common+0xd0/0x124
+[ 87.904417] el0_svc_compat_handler+0x1c/0x24
+[ 87.909289] el0_svc_compat+0x8/0x18
+[ 87.913378]
+[ 87.913378] other info that might help us debug this:
+[ 87.913378]
+[ 87.921374] Possible unsafe locking scenario:
+[ 87.921374]
+[ 87.927286] CPU0 CPU1
+[ 87.931808] ---- ----
+[ 87.936331] lock(pwm_lock);
+[ 87.939293] lock(kn->count#58);
+[ 87.945120] lock(pwm_lock);
+[ 87.950599] lock(kn->count#58);
+[ 87.953908]
+[ 87.953908] *** DEADLOCK ***
+[ 87.953908]
+[ 87.959821] 4 locks held by bash/2986:
+[ 87.963563] #0: 00000000ace7bc30 (sb_writers#6){.+.+}, at: vfs_write+0x188/0x19c
+[ 87.971044] #1: 00000000287991b2 (&of->mutex){+.+.}, at: kernfs_fop_write+0xb4/0x1e8
+[ 87.978872] #2: 00000000f739d016 (&dev->mutex){....}, at: device_release_driver_internal+0x40/0x21c
+[ 87.988001] #3: 000000006313b17c (pwm_lock){+.+.}, at: pwmchip_remove+0x28/0x13c
+[ 87.995481]
+[ 87.995481] stack backtrace:
+[ 87.999836] CPU: 0 PID: 2986 Comm: bash Not tainted 5.0.0 #7
+[ 88.005489] Hardware name: Renesas Salvator-X board based on r8a7795 ES1.x (DT)
+[ 88.012791] Call trace:
+[ 88.015235] dump_backtrace+0x0/0x190
+[ 88.018891] show_stack+0x14/0x1c
+[ 88.022204] dump_stack+0xb0/0xec
+[ 88.025514] print_circular_bug.isra.32+0x1d0/0x2e0
+[ 88.030385] __lock_acquire+0x1318/0x1864
+[ 88.034388] lock_acquire+0xc4/0x22c
+[ 88.037958] __kernfs_remove+0x258/0x2c4
+[ 88.041874] kernfs_remove_by_name_ns+0x50/0xa0
+[ 88.046398] remove_files.isra.1+0x38/0x78
+[ 88.050487] sysfs_remove_group+0x48/0x98
+[ 88.054490] sysfs_remove_groups+0x34/0x4c
+[ 88.058580] device_remove_attrs+0x6c/0x7c
+[ 88.062671] device_del+0x11c/0x33c
+[ 88.066154] device_unregister+0x14/0x2c
+[ 88.070070] pwmchip_sysfs_unexport+0x40/0x4c
+[ 88.074421] pwmchip_remove+0xf4/0x13c
+[ 88.078163] rcar_pwm_remove+0x28/0x34
+[ 88.081906] platform_drv_remove+0x24/0x64
+[ 88.085996] device_release_driver_internal+0x18c/0x21c
+[ 88.091215] device_release_driver+0x14/0x1c
+[ 88.095478] unbind_store+0xe0/0x124
+[ 88.099048] drv_attr_store+0x20/0x30
+[ 88.102704] sysfs_kf_write+0x54/0x64
+[ 88.106359] kernfs_fop_write+0xe4/0x1e8
+[ 88.110275] __vfs_write+0x40/0x184
+[ 88.113757] vfs_write+0xa8/0x19c
+[ 88.117065] ksys_write+0x58/0xbc
+[ 88.120374] __arm64_sys_write+0x18/0x20
+[ 88.124291] el0_svc_common+0xd0/0x124
+[ 88.128034] el0_svc_compat_handler+0x1c/0x24
+[ 88.132384] el0_svc_compat+0x8/0x18
+
+The sysfs unexport in pwmchip_remove() is completely asymmetric
+to what we do in pwmchip_add_with_polarity() and commit 0733424c9ba9
+("pwm: Unexport children before chip removal") is a strong indication
+that this was wrong to begin with. We should just move
+pwmchip_sysfs_unexport() where it belongs, which is right after
+pwmchip_sysfs_unexport_children(). In that case, we do not need
+separate functions anymore either.
+
+We also really want to remove sysfs irrespective of whether or not
+the chip will be removed as a result of pwmchip_remove(). We can only
+assume that the driver will be gone after that, so we shouldn't leave
+any dangling sysfs files around.
+
+This warning disappears if we move pwmchip_sysfs_unexport() to
+the top of pwmchip_remove(), pwmchip_sysfs_unexport_children().
+That way it is also outside of the pwm_lock section, which indeed
+doesn't seem to be needed.
+
+Moving the pwmchip_sysfs_export() call outside of that section also
+seems fine and it'd be perfectly symmetric with pwmchip_remove() again.
+
+So, this patch fixes them.
+
+Signed-off-by: Phong Hoang <phong.hoang.wz@renesas.com>
+[shimoda: revise the commit log and code]
+Fixes: 76abbdde2d95 ("pwm: Add sysfs interface")
+Fixes: 0733424c9ba9 ("pwm: Unexport children before chip removal")
+Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
+Tested-by: Hoan Nguyen An <na-hoan@jinso.co.jp>
+Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
+Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
+Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/pwm/core.c | 10 +++++-----
+ drivers/pwm/sysfs.c | 14 +-------------
+ include/linux/pwm.h | 5 -----
+ 3 files changed, 6 insertions(+), 23 deletions(-)
+
+diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
+index 3149204567f3..8c9200a0df5e 100644
+--- a/drivers/pwm/core.c
++++ b/drivers/pwm/core.c
+@@ -311,10 +311,12 @@ int pwmchip_add_with_polarity(struct pwm_chip *chip,
+ if (IS_ENABLED(CONFIG_OF))
+ of_pwmchip_add(chip);
+
+- pwmchip_sysfs_export(chip);
+-
+ out:
+ mutex_unlock(&pwm_lock);
++
++ if (!ret)
++ pwmchip_sysfs_export(chip);
++
+ return ret;
+ }
+ EXPORT_SYMBOL_GPL(pwmchip_add_with_polarity);
+@@ -348,7 +350,7 @@ int pwmchip_remove(struct pwm_chip *chip)
+ unsigned int i;
+ int ret = 0;
+
+- pwmchip_sysfs_unexport_children(chip);
++ pwmchip_sysfs_unexport(chip);
+
+ mutex_lock(&pwm_lock);
+
+@@ -368,8 +370,6 @@ int pwmchip_remove(struct pwm_chip *chip)
+
+ free_pwms(chip);
+
+- pwmchip_sysfs_unexport(chip);
+-
+ out:
+ mutex_unlock(&pwm_lock);
+ return ret;
+diff --git a/drivers/pwm/sysfs.c b/drivers/pwm/sysfs.c
+index ceb233dd6048..13d9bd54dfce 100644
+--- a/drivers/pwm/sysfs.c
++++ b/drivers/pwm/sysfs.c
+@@ -409,19 +409,6 @@ void pwmchip_sysfs_export(struct pwm_chip *chip)
+ }
+
+ void pwmchip_sysfs_unexport(struct pwm_chip *chip)
+-{
+- struct device *parent;
+-
+- parent = class_find_device(&pwm_class, NULL, chip,
+- pwmchip_sysfs_match);
+- if (parent) {
+- /* for class_find_device() */
+- put_device(parent);
+- device_unregister(parent);
+- }
+-}
+-
+-void pwmchip_sysfs_unexport_children(struct pwm_chip *chip)
+ {
+ struct device *parent;
+ unsigned int i;
+@@ -439,6 +426,7 @@ void pwmchip_sysfs_unexport_children(struct pwm_chip *chip)
+ }
+
+ put_device(parent);
++ device_unregister(parent);
+ }
+
+ static int __init pwm_sysfs_init(void)
+diff --git a/include/linux/pwm.h b/include/linux/pwm.h
+index b628abfffacc..eaa5c6e3fc9f 100644
+--- a/include/linux/pwm.h
++++ b/include/linux/pwm.h
+@@ -596,7 +596,6 @@ static inline void pwm_remove_table(struct pwm_lookup *table, size_t num)
+ #ifdef CONFIG_PWM_SYSFS
+ void pwmchip_sysfs_export(struct pwm_chip *chip);
+ void pwmchip_sysfs_unexport(struct pwm_chip *chip);
+-void pwmchip_sysfs_unexport_children(struct pwm_chip *chip);
+ #else
+ static inline void pwmchip_sysfs_export(struct pwm_chip *chip)
+ {
+@@ -605,10 +604,6 @@ static inline void pwmchip_sysfs_export(struct pwm_chip *chip)
+ static inline void pwmchip_sysfs_unexport(struct pwm_chip *chip)
+ {
+ }
+-
+-static inline void pwmchip_sysfs_unexport_children(struct pwm_chip *chip)
+-{
+-}
+ #endif /* CONFIG_PWM_SYSFS */
+
+ #endif /* __LINUX_PWM_H */
+--
+2.16.4
+
diff --git a/patches.drivers/pwm-meson-Consider-128-a-valid-pre-divider.patch b/patches.drivers/pwm-meson-Consider-128-a-valid-pre-divider.patch
new file mode 100644
index 0000000000..ea93de3c0f
--- /dev/null
+++ b/patches.drivers/pwm-meson-Consider-128-a-valid-pre-divider.patch
@@ -0,0 +1,54 @@
+From 51496e4446875726d50a5617a6e0e0dabbc2e6da Mon Sep 17 00:00:00 2001
+From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
+Date: Mon, 1 Apr 2019 20:18:16 +0200
+Subject: [PATCH] pwm: meson: Consider 128 a valid pre-divider
+Mime-version: 1.0
+Content-type: text/plain; charset=UTF-8
+Content-transfer-encoding: 8bit
+Git-commit: 51496e4446875726d50a5617a6e0e0dabbc2e6da
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+The pre-divider allows configuring longer PWM periods compared to using
+the input clock directly. The pre-divider is 7 bit wide, meaning it's
+maximum value is 128 (the register value is off-by-one: 0x7f or 127).
+
+Change the loop to also allow for the maximum possible value to be
+considered valid.
+
+Fixes: 211ed630753d2f ("pwm: Add support for Meson PWM Controller")
+Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
+Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
+Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/pwm/pwm-meson.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
+index c1ed641b3e26..aaae48ab484e 100644
+--- a/drivers/pwm/pwm-meson.c
++++ b/drivers/pwm/pwm-meson.c
+@@ -184,7 +184,7 @@ static int meson_pwm_calc(struct meson_pwm *meson,
+ do_div(fin_ps, fin_freq);
+
+ /* Calc pre_div with the period */
+- for (pre_div = 0; pre_div < MISC_CLK_DIV_MASK; pre_div++) {
++ for (pre_div = 0; pre_div <= MISC_CLK_DIV_MASK; pre_div++) {
+ cnt = DIV_ROUND_CLOSEST_ULL((u64)period * 1000,
+ fin_ps * (pre_div + 1));
+ dev_dbg(meson->chip.dev, "fin_ps=%llu pre_div=%u cnt=%u\n",
+@@ -193,7 +193,7 @@ static int meson_pwm_calc(struct meson_pwm *meson,
+ break;
+ }
+
+- if (pre_div == MISC_CLK_DIV_MASK) {
++ if (pre_div > MISC_CLK_DIV_MASK) {
+ dev_err(meson->chip.dev, "unable to get period pre_div\n");
+ return -EINVAL;
+ }
+--
+2.16.4
+
diff --git a/patches.drivers/pwm-meson-Don-t-disable-PWM-when-setting-duty-repeat.patch b/patches.drivers/pwm-meson-Don-t-disable-PWM-when-setting-duty-repeat.patch
new file mode 100644
index 0000000000..f69c349142
--- /dev/null
+++ b/patches.drivers/pwm-meson-Don-t-disable-PWM-when-setting-duty-repeat.patch
@@ -0,0 +1,44 @@
+From a279345807e1e0ae79567a52cfdd9d30c9174a3c Mon Sep 17 00:00:00 2001
+From: Bichao Zheng <bichao.zheng@amlogic.com>
+Date: Mon, 1 Apr 2019 20:18:17 +0200
+Subject: [PATCH] pwm: meson: Don't disable PWM when setting duty repeatedly
+Git-commit: a279345807e1e0ae79567a52cfdd9d30c9174a3c
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+There is an abnormally low about 20ms,when setting duty repeatedly.
+Because setting the duty will disable PWM and then enable. Delete
+this operation now.
+
+Fixes: 211ed630753d2f ("pwm: Add support for Meson PWM Controller")
+Signed-off-by: Bichao Zheng <bichao.zheng@amlogic.com>
+[ Dropped code instead of hiding it behind a comment ]
+
+Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
+Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
+Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/pwm/pwm-meson.c | 5 -----
+ 1 file changed, 5 deletions(-)
+
+diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
+index aaae48ab484e..2ab3d216b35a 100644
+--- a/drivers/pwm/pwm-meson.c
++++ b/drivers/pwm/pwm-meson.c
+@@ -314,11 +314,6 @@ static int meson_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
+ if (state->period != channel->state.period ||
+ state->duty_cycle != channel->state.duty_cycle ||
+ state->polarity != channel->state.polarity) {
+- if (channel->state.enabled) {
+- meson_pwm_disable(meson, pwm->hwpwm);
+- channel->state.enabled = false;
+- }
+-
+ if (state->polarity != channel->state.polarity) {
+ if (state->polarity == PWM_POLARITY_NORMAL)
+ meson->inverter_mask |= BIT(pwm->hwpwm);
+--
+2.16.4
+
diff --git a/patches.drivers/pwm-meson-Use-the-spin-lock-only-to-protect-register.patch b/patches.drivers/pwm-meson-Use-the-spin-lock-only-to-protect-register.patch
new file mode 100644
index 0000000000..742eba0206
--- /dev/null
+++ b/patches.drivers/pwm-meson-Use-the-spin-lock-only-to-protect-register.patch
@@ -0,0 +1,144 @@
+From f173747fffdf037c791405ab4f1ec0eb392fc48e Mon Sep 17 00:00:00 2001
+From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
+Date: Mon, 1 Apr 2019 19:57:48 +0200
+Subject: [PATCH] pwm: meson: Use the spin-lock only to protect register modifications
+Mime-version: 1.0
+Content-type: text/plain; charset=UTF-8
+Content-transfer-encoding: 8bit
+Git-commit: f173747fffdf037c791405ab4f1ec0eb392fc48e
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+Holding the spin-lock for all of the code in meson_pwm_apply() can
+result in a "BUG: scheduling while atomic". This can happen because
+clk_get_rate() (which is called from meson_pwm_calc()) may sleep.
+Only hold the spin-lock when modifying registers to solve this.
+
+The reason why we need a spin-lock in the driver is because the
+REG_MISC_AB register is shared between the two channels provided by one
+PWM controller. The only functions where REG_MISC_AB is modified are
+meson_pwm_enable() and meson_pwm_disable() so the register reads/writes
+in there need to be protected by the spin-lock.
+
+The original code also used the spin-lock to protect the values in
+struct meson_pwm_channel. This could be necessary if two consumers can
+use the same PWM channel. However, PWM core doesn't allow this so we
+don't need to protect the values in struct meson_pwm_channel with a
+lock.
+
+Fixes: 211ed630753d2f ("pwm: Add support for Meson PWM Controller")
+Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
+Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
+Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
+Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/pwm/pwm-meson.c | 25 +++++++++++++++++--------
+ 1 file changed, 17 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/pwm/pwm-meson.c b/drivers/pwm/pwm-meson.c
+index 2ab3d216b35a..e247ab632530 100644
+--- a/drivers/pwm/pwm-meson.c
++++ b/drivers/pwm/pwm-meson.c
+@@ -111,6 +111,10 @@ struct meson_pwm {
+ const struct meson_pwm_data *data;
+ void __iomem *base;
+ u8 inverter_mask;
++ /*
++ * Protects register (write) access to the REG_MISC_AB register
++ * that is shared between the two PWMs.
++ */
+ spinlock_t lock;
+ };
+
+@@ -235,6 +239,7 @@ static void meson_pwm_enable(struct meson_pwm *meson,
+ {
+ u32 value, clk_shift, clk_enable, enable;
+ unsigned int offset;
++ unsigned long flags;
+
+ switch (id) {
+ case 0:
+@@ -255,6 +260,8 @@ static void meson_pwm_enable(struct meson_pwm *meson,
+ return;
+ }
+
++ spin_lock_irqsave(&meson->lock, flags);
++
+ value = readl(meson->base + REG_MISC_AB);
+ value &= ~(MISC_CLK_DIV_MASK << clk_shift);
+ value |= channel->pre_div << clk_shift;
+@@ -267,11 +274,14 @@ static void meson_pwm_enable(struct meson_pwm *meson,
+ value = readl(meson->base + REG_MISC_AB);
+ value |= enable;
+ writel(value, meson->base + REG_MISC_AB);
++
++ spin_unlock_irqrestore(&meson->lock, flags);
+ }
+
+ static void meson_pwm_disable(struct meson_pwm *meson, unsigned int id)
+ {
+ u32 value, enable;
++ unsigned long flags;
+
+ switch (id) {
+ case 0:
+@@ -286,9 +296,13 @@ static void meson_pwm_disable(struct meson_pwm *meson, unsigned int id)
+ return;
+ }
+
++ spin_lock_irqsave(&meson->lock, flags);
++
+ value = readl(meson->base + REG_MISC_AB);
+ value &= ~enable;
+ writel(value, meson->base + REG_MISC_AB);
++
++ spin_unlock_irqrestore(&meson->lock, flags);
+ }
+
+ static int meson_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
+@@ -296,19 +310,16 @@ static int meson_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
+ {
+ struct meson_pwm_channel *channel = pwm_get_chip_data(pwm);
+ struct meson_pwm *meson = to_meson_pwm(chip);
+- unsigned long flags;
+ int err = 0;
+
+ if (!state)
+ return -EINVAL;
+
+- spin_lock_irqsave(&meson->lock, flags);
+-
+ if (!state->enabled) {
+ meson_pwm_disable(meson, pwm->hwpwm);
+ channel->state.enabled = false;
+
+- goto unlock;
++ return 0;
+ }
+
+ if (state->period != channel->state.period ||
+@@ -324,7 +335,7 @@ static int meson_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
+ err = meson_pwm_calc(meson, channel, pwm->hwpwm,
+ state->duty_cycle, state->period);
+ if (err < 0)
+- goto unlock;
++ return err;
+
+ channel->state.polarity = state->polarity;
+ channel->state.period = state->period;
+@@ -336,9 +347,7 @@ static int meson_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
+ channel->state.enabled = true;
+ }
+
+-unlock:
+- spin_unlock_irqrestore(&meson->lock, flags);
+- return err;
++ return 0;
+ }
+
+ static void meson_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
+--
+2.16.4
+
diff --git a/patches.drivers/pwm-tiehrpwm-Update-shadow-register-for-disabling-PW.patch b/patches.drivers/pwm-tiehrpwm-Update-shadow-register-for-disabling-PW.patch
new file mode 100644
index 0000000000..df57e12413
--- /dev/null
+++ b/patches.drivers/pwm-tiehrpwm-Update-shadow-register-for-disabling-PW.patch
@@ -0,0 +1,48 @@
+From b00ef53053191d3025c15e8041699f8c9d132daf Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Christoph=20Vogtl=C3=A4nder?= <c.vogtlaender@sigma-surface-science.com>
+Date: Tue, 12 Mar 2019 14:38:46 +0530
+Subject: [PATCH] pwm: tiehrpwm: Update shadow register for disabling PWMs
+Mime-version: 1.0
+Content-type: text/plain; charset=UTF-8
+Content-transfer-encoding: 8bit
+Git-commit: b00ef53053191d3025c15e8041699f8c9d132daf
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+It must be made sure that immediate mode is not already set, when
+modifying shadow register value in ehrpwm_pwm_disable(). Otherwise
+modifications to the action-qualifier continuous S/W force
+register(AQSFRC) will be done in the active register.
+This may happen when both channels are being disabled. In this case,
+only the first channel state will be recorded as disabled in the shadow
+register. Later, when enabling the first channel again, the second
+channel would be enabled as well. Setting RLDCSF to zero, first, ensures
+that the shadow register is updated as desired.
+
+Fixes: 38dabd91ff0b ("pwm: tiehrpwm: Fix disabling of output of PWMs")
+Signed-off-by: Christoph Vogtländer <c.vogtlaender@sigma-surface-science.com>
+[vigneshr@ti.com: Improve commit message]
+Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
+Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/pwm/pwm-tiehrpwm.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/pwm/pwm-tiehrpwm.c b/drivers/pwm/pwm-tiehrpwm.c
+index f7b8a86fa5c5..ad4a40c0f27c 100644
+--- a/drivers/pwm/pwm-tiehrpwm.c
++++ b/drivers/pwm/pwm-tiehrpwm.c
+@@ -382,6 +382,8 @@ static void ehrpwm_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
+ }
+
+ /* Update shadow register first before modifying active register */
++ ehrpwm_modify(pc->mmio_base, AQSFRC, AQSFRC_RLDCSF_MASK,
++ AQSFRC_RLDCSF_ZRO);
+ ehrpwm_modify(pc->mmio_base, AQCSFRC, aqcsfrc_mask, aqcsfrc_val);
+ /*
+ * Changes to immediate action on Action Qualifier. This puts
+--
+2.16.4
+
diff --git a/patches.drivers/sc16is7xx-missing-unregister-delete-driver-on-error-.patch b/patches.drivers/sc16is7xx-missing-unregister-delete-driver-on-error-.patch
new file mode 100644
index 0000000000..491ea3ab55
--- /dev/null
+++ b/patches.drivers/sc16is7xx-missing-unregister-delete-driver-on-error-.patch
@@ -0,0 +1,56 @@
+From ac0cdb3d990108df795b676cd0d0e65ac34b2273 Mon Sep 17 00:00:00 2001
+From: Mao Wenan <maowenan@huawei.com>
+Date: Fri, 8 Mar 2019 22:08:31 +0800
+Subject: [PATCH] sc16is7xx: missing unregister/delete driver on error in sc16is7xx_init()
+Git-commit: ac0cdb3d990108df795b676cd0d0e65ac34b2273
+Patch-mainline: v5.1-rc3
+References: bsc#1051510
+
+Add the missing uart_unregister_driver() and i2c_del_driver() before return
+from sc16is7xx_init() in the error handling case.
+
+Signed-off-by: Mao Wenan <maowenan@huawei.com>
+Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/tty/serial/sc16is7xx.c | 12 ++++++++++--
+ 1 file changed, 10 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
+index 635178cf3eed..09a183dfc526 100644
+--- a/drivers/tty/serial/sc16is7xx.c
++++ b/drivers/tty/serial/sc16is7xx.c
+@@ -1507,7 +1507,7 @@ static int __init sc16is7xx_init(void)
+ ret = i2c_add_driver(&sc16is7xx_i2c_uart_driver);
+ if (ret < 0) {
+ pr_err("failed to init sc16is7xx i2c --> %d\n", ret);
+- return ret;
++ goto err_i2c;
+ }
+ #endif
+
+@@ -1515,10 +1515,18 @@ static int __init sc16is7xx_init(void)
+ ret = spi_register_driver(&sc16is7xx_spi_uart_driver);
+ if (ret < 0) {
+ pr_err("failed to init sc16is7xx spi --> %d\n", ret);
+- return ret;
++ goto err_spi;
+ }
+ #endif
+ return ret;
++
++err_spi:
++#ifdef CONFIG_SERIAL_SC16IS7XX_I2C
++ i2c_del_driver(&sc16is7xx_i2c_uart_driver);
++#endif
++err_i2c:
++ uart_unregister_driver(&sc16is7xx_uart);
++ return ret;
+ }
+ module_init(sc16is7xx_init);
+
+--
+2.16.4
+
diff --git a/patches.drivers/sc16is7xx-move-label-err_spi-to-correct-section.patch b/patches.drivers/sc16is7xx-move-label-err_spi-to-correct-section.patch
new file mode 100644
index 0000000000..da56092523
--- /dev/null
+++ b/patches.drivers/sc16is7xx-move-label-err_spi-to-correct-section.patch
@@ -0,0 +1,49 @@
+From e00164a0f000de893944981f41a568c981aca658 Mon Sep 17 00:00:00 2001
+From: Guoqing Jiang <gqjiang@suse.com>
+Date: Tue, 9 Apr 2019 16:16:38 +0800
+Subject: [PATCH] sc16is7xx: move label 'err_spi' to correct section
+Mime-version: 1.0
+Content-type: text/plain; charset=UTF-8
+Content-transfer-encoding: 8bit
+Git-commit: e00164a0f000de893944981f41a568c981aca658
+Patch-mainline: v5.1-rc6
+References: bsc#1051510
+
+err_spi is used when SERIAL_SC16IS7XX_SPI is enabled, so make
+the label only available under SERIAL_SC16IS7XX_SPI option.
+Otherwise, the below warning appears.
+
+drivers/tty/serial/sc16is7xx.c:1523:1: warning: label ‘err_spi’ defined but not used [-Wunused-label]
+ err_spi:
+ ^~~~~~~
+
+Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
+Fixes: ac0cdb3d9901 ("sc16is7xx: missing unregister/delete driver on error in sc16is7xx_init()")
+Signed-off-by: Arnd Bergmann <arnd@arndb.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/tty/serial/sc16is7xx.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
+index 09a183dfc526..22381a8c72e4 100644
+--- a/drivers/tty/serial/sc16is7xx.c
++++ b/drivers/tty/serial/sc16is7xx.c
+@@ -1520,10 +1520,12 @@ static int __init sc16is7xx_init(void)
+ #endif
+ return ret;
+
++#ifdef CONFIG_SERIAL_SC16IS7XX_SPI
+ err_spi:
+ #ifdef CONFIG_SERIAL_SC16IS7XX_I2C
+ i2c_del_driver(&sc16is7xx_i2c_uart_driver);
+ #endif
++#endif
+ err_i2c:
+ uart_unregister_driver(&sc16is7xx_uart);
+ return ret;
+--
+2.16.4
+
diff --git a/patches.drivers/sc16is7xx-put-err_spi-and-err_i2c-into-correct-ifdef.patch b/patches.drivers/sc16is7xx-put-err_spi-and-err_i2c-into-correct-ifdef.patch
new file mode 100644
index 0000000000..9106802a4e
--- /dev/null
+++ b/patches.drivers/sc16is7xx-put-err_spi-and-err_i2c-into-correct-ifdef.patch
@@ -0,0 +1,45 @@
+From c53051128bb0e8754e13345d782ca69e5e1ce36d Mon Sep 17 00:00:00 2001
+From: Guoqing Jiang <gqjiang@suse.com>
+Date: Thu, 18 Apr 2019 10:01:55 +0800
+Subject: [PATCH] sc16is7xx: put err_spi and err_i2c into correct #ifdef
+Git-commit: c53051128bb0e8754e13345d782ca69e5e1ce36d
+Patch-mainline: v5.1-rc6
+References: bsc#1051510
+
+err_spi is only called within SERIAL_SC16IS7XX_SPI
+while err_i2c is called inside SERIAL_SC16IS7XX_I2C.
+So we need to put err_spi and err_i2c into each #ifdef
+accordingly.
+
+This change fixes ("sc16is7xx: move label 'err_spi'
+to correct section").
+
+Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/tty/serial/sc16is7xx.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
+index 22381a8c72e4..a31db15cd7c0 100644
+--- a/drivers/tty/serial/sc16is7xx.c
++++ b/drivers/tty/serial/sc16is7xx.c
+@@ -1522,11 +1522,11 @@ static int __init sc16is7xx_init(void)
+
+ #ifdef CONFIG_SERIAL_SC16IS7XX_SPI
+ err_spi:
++#endif
+ #ifdef CONFIG_SERIAL_SC16IS7XX_I2C
+ i2c_del_driver(&sc16is7xx_i2c_uart_driver);
+-#endif
+-#endif
+ err_i2c:
++#endif
+ uart_unregister_driver(&sc16is7xx_uart);
+ return ret;
+ }
+--
+2.16.4
+
diff --git a/patches.drivers/spi-a3700-Clear-DATA_OUT-when-performing-a-read.patch b/patches.drivers/spi-a3700-Clear-DATA_OUT-when-performing-a-read.patch
new file mode 100644
index 0000000000..32776f6247
--- /dev/null
+++ b/patches.drivers/spi-a3700-Clear-DATA_OUT-when-performing-a-read.patch
@@ -0,0 +1,38 @@
+From 44a5f423e70374e5b42cecd85e78f2d79334e0f2 Mon Sep 17 00:00:00 2001
+From: Maxime Chevallier <maxime.chevallier@smile.fr>
+Date: Wed, 17 Jan 2018 17:15:25 +0100
+Subject: [PATCH] spi: a3700: Clear DATA_OUT when performing a read
+Git-commit: 44a5f423e70374e5b42cecd85e78f2d79334e0f2
+Patch-mainline: v4.16-rc1
+References: bsc#1051510
+
+When performing a read using FIFO mode, the spi controller shifts out
+the last 2 bytes that were written in a previous transfer on MOSI.
+
+This undocumented behaviour can cause devices to misinterpret the
+transfer, so we explicitly clear the WFIFO before each read.
+
+This behaviour was noticed on EspressoBin.
+
+Signed-off-by: Maxime Chevallier <maxime.chevallier@smile.fr>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/spi/spi-armada-3700.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+--- a/drivers/spi/spi-armada-3700.c
++++ b/drivers/spi/spi-armada-3700.c
+@@ -668,6 +668,11 @@ static int a3700_spi_transfer_one(struct
+ a3700_spi_pin_mode_set(a3700_spi, nbits, xfer->rx_buf ? true : false);
+
+ if (xfer->rx_buf) {
++ /* Clear WFIFO, since it's last 2 bytes are shifted out during
++ * a read operation
++ */
++ spireg_write(a3700_spi, A3700_SPI_DATA_OUT_REG, 0);
++
+ /* Set read data length */
+ spireg_write(a3700_spi, A3700_SPI_IF_DIN_CNT_REG,
+ a3700_spi->buf_len);
diff --git a/patches.drivers/ssb-Fix-possible-NULL-pointer-dereference-in-ssb_hos.patch b/patches.drivers/ssb-Fix-possible-NULL-pointer-dereference-in-ssb_hos.patch
new file mode 100644
index 0000000000..209ffbc911
--- /dev/null
+++ b/patches.drivers/ssb-Fix-possible-NULL-pointer-dereference-in-ssb_hos.patch
@@ -0,0 +1,99 @@
+From b2c01aab9646ed8ffb7c549afe55d5349c482425 Mon Sep 17 00:00:00 2001
+From: YueHaibing <yuehaibing@huawei.com>
+Date: Wed, 6 Mar 2019 19:56:58 +0800
+Subject: [PATCH] ssb: Fix possible NULL pointer dereference in ssb_host_pcmcia_exit
+Git-commit: b2c01aab9646ed8ffb7c549afe55d5349c482425
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+Syzkaller report this:
+
+Kasan: GPF could be caused by NULL-ptr deref or user memory access
+general protection fault: 0000 [#1] SMP KASAN PTI
+Cpu: 0 PID: 4492 Comm: syz-executor.0 Not tainted 5.0.0-rc7+ #45
+Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
+Rip: 0010:sysfs_remove_file_ns+0x27/0x70 fs/sysfs/file.c:468
+Code: 00 00 00 41 54 55 48 89 fd 53 49 89 d4 48 89 f3 e8 ee 76 9c ff 48 8d 7d 30 48 b8 00 00 00 00 00 fc ff df 48 89 fa 48 c1 ea 03 <80> 3c 02 00 75 2d 48 89 da 48 b8 00 00 00 00 00 fc ff df 48 8b 6d
+Rsp: 0018:ffff8881e9d9fc00 EFLAGS: 00010206
+Rax: dffffc0000000000 RBX: ffffffff900367e0 RCX: ffffffff81a95952
+Rdx: 0000000000000006 RSI: ffffc90001405000 RDI: 0000000000000030
+Rbp: 0000000000000000 R08: fffffbfff1fa22ed R09: fffffbfff1fa22ed
+R10: 0000000000000001 R11: fffffbfff1fa22ec R12: 0000000000000000
+R13: ffffffffc1abdac0 R14: 1ffff1103d3b3f8b R15: 0000000000000000
+Fs: 00007fe409dc1700(0000) GS:ffff8881f1200000(0000) knlGS:0000000000000000
+Cs: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
+Cr2: 0000001b2d721000 CR3: 00000001e98b6005 CR4: 00000000007606f0
+Dr0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
+Dr3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
+Pkru: 55555554
+Call Trace:
+ sysfs_remove_file include/linux/sysfs.h:519 [inline]
+ driver_remove_file+0x40/0x50 drivers/base/driver.c:122
+ pcmcia_remove_newid_file drivers/pcmcia/ds.c:163 [inline]
+ pcmcia_unregister_driver+0x7d/0x2b0 drivers/pcmcia/ds.c:209
+ ssb_modexit+0xa/0x1b [ssb]
+ __do_sys_delete_module kernel/module.c:1018 [inline]
+ __se_sys_delete_module kernel/module.c:961 [inline]
+ __x64_sys_delete_module+0x3dc/0x5e0 kernel/module.c:961
+ do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290
+ entry_SYSCALL_64_after_hwframe+0x49/0xbe
+Rip: 0033:0x462e99
+Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
+Rsp: 002b:00007fe409dc0c58 EFLAGS: 00000246 ORIG_RAX: 00000000000000b0
+Rax: ffffffffffffffda RBX: 000000000073bf00 RCX: 0000000000462e99
+Rdx: 0000000000000000 RSI: 0000000000000000 RDI: 00000000200000c0
+Rbp: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000
+R10: 0000000000000000 R11: 0000000000000246 R12: 00007fe409dc16bc
+R13: 00000000004bccaa R14: 00000000006f6bc8 R15: 00000000ffffffff
+Modules linked in: ssb(-) 3c59x nvme_core macvlan tap pata_hpt3x3 rt2x00pci null_blk tsc40 pm_notifier_error_inject notifier_error_inject mdio cdc_wdm nf_reject_ipv4 ath9k_common ath9k_hw ath pppox ppp_generic slhc ehci_platform wl12xx wlcore tps6507x_ts ioc4 nf_synproxy_core ide_gd_mod ax25 can_dev iwlwifi can_raw atm tm2_touchkey can_gw can sundance adp5588_keys rt2800mmio rt2800lib rt2x00mmio rt2x00lib eeprom_93cx6 pn533 lru_cache elants_i2c ip_set nfnetlink gameport tipc hampshire nhc_ipv6 nhc_hop nhc_udp nhc_fragment nhc_routing nhc_mobility nhc_dest 6lowpan silead brcmutil nfc mt76_usb mt76 mac80211 iptable_security iptable_raw iptable_mangle iptable_nat nf_nat_ipv4 nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 iptable_filter bpfilter ip6_vti ip_gre sit hsr veth vxcan batman_adv cfg80211 rfkill chnl_net caif nlmon vcan bridge stp llc ip6_gre ip6_tunnel tunnel6 tun joydev mousedev serio_raw ide_pci_generic piix floppy ide_core sch_fq_codel ip_tables x_tables ipv6
+ [last unloaded: 3c59x]
+Dumping ftrace buffer:
+ (ftrace buffer empty)
+
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---[ end trace 3913cbf8011e1c05 ]---
+
+In ssb_modinit, it does not fail SSB init when ssb_host_pcmcia_init failed,
+however in ssb_modexit, ssb_host_pcmcia_exit calls pcmcia_unregister_driver
+unconditionally, which may tigger a NULL pointer dereference issue as above.
+
+Reported-by: Hulk Robot <hulkci@huawei.com>
+Fixes: 399500da18f7 ("ssb: pick PCMCIA host code support from b43 driver")
+Signed-off-by: YueHaibing <yuehaibing@huawei.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/ssb/bridge_pcmcia_80211.c | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/ssb/bridge_pcmcia_80211.c b/drivers/ssb/bridge_pcmcia_80211.c
+index f51f150307df..ffa379efff83 100644
+--- a/drivers/ssb/bridge_pcmcia_80211.c
++++ b/drivers/ssb/bridge_pcmcia_80211.c
+@@ -113,16 +113,21 @@ static struct pcmcia_driver ssb_host_pcmcia_driver = {
+ .resume = ssb_host_pcmcia_resume,
+ };
+
++static int pcmcia_init_failed;
++
+ /*
+ * These are not module init/exit functions!
+ * The module_pcmcia_driver() helper cannot be used here.
+ */
+ int ssb_host_pcmcia_init(void)
+ {
+- return pcmcia_register_driver(&ssb_host_pcmcia_driver);
++ pcmcia_init_failed = pcmcia_register_driver(&ssb_host_pcmcia_driver);
++
++ return pcmcia_init_failed;
+ }
+
+ void ssb_host_pcmcia_exit(void)
+ {
+- pcmcia_unregister_driver(&ssb_host_pcmcia_driver);
++ if (!pcmcia_init_failed)
++ pcmcia_unregister_driver(&ssb_host_pcmcia_driver);
+ }
+--
+2.16.4
+
diff --git a/patches.drivers/usb-storage-Set-virt_boundary_mask-to-avoid-SG-overf.patch b/patches.drivers/usb-storage-Set-virt_boundary_mask-to-avoid-SG-overf.patch
new file mode 100644
index 0000000000..095d58d072
--- /dev/null
+++ b/patches.drivers/usb-storage-Set-virt_boundary_mask-to-avoid-SG-overf.patch
@@ -0,0 +1,92 @@
+From 747668dbc061b3e62bc1982767a3a1f9815fcf0e Mon Sep 17 00:00:00 2001
+From: Alan Stern <stern@rowland.harvard.edu>
+Date: Mon, 15 Apr 2019 13:19:25 -0400
+Subject: [PATCH] usb-storage: Set virt_boundary_mask to avoid SG overflows
+Git-commit: 747668dbc061b3e62bc1982767a3a1f9815fcf0e
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+The USB subsystem has always had an unusual requirement for its
+scatter-gather transfers: Each element in the scatterlist (except the
+last one) must have a length divisible by the bulk maxpacket size.
+This is a particular issue for USB mass storage, which uses SG lists
+created by the block layer rather than setting up its own.
+
+So far we have scraped by okay because most devices have a logical
+block size of 512 bytes or larger, and the bulk maxpacket sizes for
+USB 2 and below are all <= 512. However, USB 3 has a bulk maxpacket
+size of 1024. Since the xhci-hcd driver includes native SG support,
+this hasn't mattered much. But now people are trying to use USB-3
+mass storage devices with USBIP, and the vhci-hcd driver currently
+does not have full SG support.
+
+The result is an overflow error, when the driver attempts to implement
+an SG transfer of 63 512-byte blocks as a single
+3584-byte (7 blocks) transfer followed by seven 4096-byte (8 blocks)
+transfers. The device instead sends 31 1024-byte packets followed by
+a 512-byte packet, and this overruns the first SG buffer.
+
+Ideally this would be fixed by adding better SG support to vhci-hcd.
+But for now it appears we can work around the problem by
+asking the block layer to respect the maxpacket limitation, through
+the use of the virt_boundary_mask.
+
+Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
+Reported-by: Seth Bollinger <Seth.Bollinger@digi.com>
+Tested-by: Seth Bollinger <Seth.Bollinger@digi.com>
+Cc: Ming Lei <tom.leiming@gmail.com>
+Cc: stable <stable@vger.kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/usb/storage/scsiglue.c | 26 ++++++++++++--------------
+ 1 file changed, 12 insertions(+), 14 deletions(-)
+
+diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
+index a73ea495d5a7..59190d88fa9f 100644
+--- a/drivers/usb/storage/scsiglue.c
++++ b/drivers/usb/storage/scsiglue.c
+@@ -65,6 +65,7 @@ static const char* host_info(struct Scsi_Host *host)
+ static int slave_alloc (struct scsi_device *sdev)
+ {
+ struct us_data *us = host_to_us(sdev->host);
++ int maxp;
+
+ /*
+ * Set the INQUIRY transfer length to 36. We don't use any of
+@@ -74,20 +75,17 @@ static int slave_alloc (struct scsi_device *sdev)
+ sdev->inquiry_len = 36;
+
+ /*
+- * USB has unusual DMA-alignment requirements: Although the
+- * starting address of each scatter-gather element doesn't matter,
+- * the length of each element except the last must be divisible
+- * by the Bulk maxpacket value. There's currently no way to
+- * express this by block-layer constraints, so we'll cop out
+- * and simply require addresses to be aligned at 512-byte
+- * boundaries. This is okay since most block I/O involves
+- * hardware sectors that are multiples of 512 bytes in length,
+- * and since host controllers up through USB 2.0 have maxpacket
+- * values no larger than 512.
+- *
+- * But it doesn't suffice for Wireless USB, where Bulk maxpacket
+- * values can be as large as 2048. To make that work properly
+- * will require changes to the block layer.
++ * USB has unusual scatter-gather requirements: the length of each
++ * scatterlist element except the last must be divisible by the
++ * Bulk maxpacket value. Fortunately this value is always a
++ * power of 2. Inform the block layer about this requirement.
++ */
++ maxp = usb_maxpacket(us->pusb_dev, us->recv_bulk_pipe, 0);
++ blk_queue_virt_boundary(sdev->request_queue, maxp - 1);
++
++ /*
++ * Some host controllers may have alignment requirements.
++ * We'll play it safe by requiring 512-byte alignment always.
+ */
+ blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1));
+
+--
+2.16.4
+
diff --git a/patches.drm/0004-drm-i915-gvt-Fix-incorrect-mask-of-mmio-0x22028-in-g.patch b/patches.drm/0004-drm-i915-gvt-Fix-incorrect-mask-of-mmio-0x22028-in-g.patch
new file mode 100644
index 0000000000..63913ed9a6
--- /dev/null
+++ b/patches.drm/0004-drm-i915-gvt-Fix-incorrect-mask-of-mmio-0x22028-in-g.patch
@@ -0,0 +1,39 @@
+From 2bfc4975083ace0e5777116514c3a75e59b3dbcd Mon Sep 17 00:00:00 2001
+From: Colin Xu <colin.xu@intel.com>
+Date: Mon, 1 Apr 2019 14:13:53 +0800
+Subject: drm/i915/gvt: Fix incorrect mask of mmio 0x22028 in gen8/9 mmio list
+Git-commit: 2bfc4975083ace0e5777116514c3a75e59b3dbcd
+Patch-mainline: v5.2-rc1
+References: bnc#1113722
+
+According to GFX PRM on 01.org, bit 31:16 of mmio 0x22028 should be masks.
+
+Fixes: 178657139307 ("drm/i915/gvt: vGPU context switch")
+Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com>
+Signed-off-by: Colin Xu <colin.xu@intel.com>
+Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
+Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
+---
+ drivers/gpu/drm/i915/gvt/mmio_context.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/gpu/drm/i915/gvt/mmio_context.c
++++ b/drivers/gpu/drm/i915/gvt/mmio_context.c
+@@ -79,7 +79,7 @@ static struct engine_mmio gen8_engine_mm
+ {BCS, RING_MI_MODE(BLT_RING_BASE), 0xffff, false}, /* 0x2209c */
+ {BCS, RING_INSTPM(BLT_RING_BASE), 0xffff, false}, /* 0x220c0 */
+ {BCS, RING_HWSTAM(BLT_RING_BASE), 0x0, false}, /* 0x22098 */
+- {BCS, RING_EXCC(BLT_RING_BASE), 0x0, false}, /* 0x22028 */
++ {BCS, RING_EXCC(BLT_RING_BASE), 0xffff, false}, /* 0x22028 */
+ {RCS, INVALID_MMIO_REG, 0, false } /* Terminated */
+ };
+
+@@ -130,7 +130,7 @@ static struct engine_mmio gen9_engine_mm
+ {BCS, RING_MI_MODE(BLT_RING_BASE), 0xffff, false}, /* 0x2209c */
+ {BCS, RING_INSTPM(BLT_RING_BASE), 0xffff, false}, /* 0x220c0 */
+ {BCS, RING_HWSTAM(BLT_RING_BASE), 0x0, false}, /* 0x22098 */
+- {BCS, RING_EXCC(BLT_RING_BASE), 0x0, false}, /* 0x22028 */
++ {BCS, RING_EXCC(BLT_RING_BASE), 0xffff, false}, /* 0x22028 */
+
+ {VCS2, RING_EXCC(GEN8_BSD2_RING_BASE), 0xffff, false}, /* 0x1c028 */
+
diff --git a/patches.drm/0005-drm-meson-add-size-and-alignment-requirements-for-du.patch b/patches.drm/0005-drm-meson-add-size-and-alignment-requirements-for-du.patch
new file mode 100644
index 0000000000..65e89c9db0
--- /dev/null
+++ b/patches.drm/0005-drm-meson-add-size-and-alignment-requirements-for-du.patch
@@ -0,0 +1,53 @@
+From 852ce7285c99e3f7b56e76511e1b33c645a2b648 Mon Sep 17 00:00:00 2001
+From: Neil Armstrong <narmstrong@baylibre.com>
+Date: Mon, 8 Apr 2019 11:01:37 +0200
+Subject: drm/meson: add size and alignment requirements for dumb buffers
+Git-commit: 852ce7285c99e3f7b56e76511e1b33c645a2b648
+Patch-mainline: v5.2-rc1
+References: bnc#1113722
+
+The Amlogic SoCs Canvas buffers stride must be aligned on 64bytes
+and overall size should be aligned on PAGE width.
+
+Adds a custom dumb_create op to adds these requirements.
+
+Fixes: bbbe775ec5b5 ("drm: Add support for Amlogic Meson Graphic Controller")
+Suggested-by: Sky Zhou <sky.zhou@amlogic.com>
+Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
+Reviewed-by: Sky Zhou <sky.zhou@amlogic.com>
+Link: https://patchwork.freedesktop.org/patch/msgid/20190408090137.2402-1-narmstrong@baylibre.com
+Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
+---
+ drivers/gpu/drm/meson/meson_drv.c | 14 +++++++++++++-
+ 1 file changed, 13 insertions(+), 1 deletion(-)
+
+--- a/drivers/gpu/drm/meson/meson_drv.c
++++ b/drivers/gpu/drm/meson/meson_drv.c
+@@ -93,6 +93,18 @@ static irqreturn_t meson_irq(int irq, vo
+ return IRQ_HANDLED;
+ }
+
++static int meson_dumb_create(struct drm_file *file, struct drm_device *dev,
++ struct drm_mode_create_dumb *args)
++{
++ /*
++ * We need 64bytes aligned stride, and PAGE aligned size
++ */
++ args->pitch = ALIGN(DIV_ROUND_UP(args->width * args->bpp, 8), SZ_64);
++ args->size = PAGE_ALIGN(args->pitch * args->height);
++
++ return drm_gem_cma_dumb_create_internal(file, dev, args);
++}
++
+ DEFINE_DRM_GEM_CMA_FOPS(fops);
+
+ static struct drm_driver meson_driver = {
+@@ -115,7 +127,7 @@ static struct drm_driver meson_driver =
+ .gem_prime_mmap = drm_gem_cma_prime_mmap,
+
+ /* GEM Ops */
+- .dumb_create = drm_gem_cma_dumb_create,
++ .dumb_create = meson_dumb_create,
+ .dumb_destroy = drm_gem_dumb_destroy,
+ .dumb_map_offset = drm_gem_cma_dumb_map_offset,
+ .gem_free_object_unlocked = drm_gem_cma_free_object,
diff --git a/patches.drm/drm-fb-helper-dpms_legacy-Only-set-on-connectors-in-.patch b/patches.drm/drm-fb-helper-dpms_legacy-Only-set-on-connectors-in-.patch
new file mode 100644
index 0000000000..85fc07e12d
--- /dev/null
+++ b/patches.drm/drm-fb-helper-dpms_legacy-Only-set-on-connectors-in-.patch
@@ -0,0 +1,57 @@
+From 65a102f68005891d7f39354cfd79099908df6d51 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= <noralf@tronnes.org>
+Date: Tue, 26 Mar 2019 18:55:32 +0100
+Subject: [PATCH] drm/fb-helper: dpms_legacy(): Only set on connectors in use
+Mime-version: 1.0
+Content-type: text/plain; charset=UTF-8
+Content-transfer-encoding: 8bit
+Git-commit: 65a102f68005891d7f39354cfd79099908df6d51
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+For each enabled crtc the functions sets dpms on all registered connectors.
+Limit this to only doing it once and on the connectors actually in use.
+
+Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
+Fixes: 023eb571a1d0 ("drm: correctly update connector DPMS status in drm_fb_helper")
+Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
+Link: https://patchwork.freedesktop.org/patch/msgid/20190326175546.18126-3-noralf@tronnes.org
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/gpu/drm/drm_fb_helper.c | 11 +++++------
+ 1 file changed, 5 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
+index a6d88f8b7a52..0d8384e30e16 100644
+--- a/drivers/gpu/drm/drm_fb_helper.c
++++ b/drivers/gpu/drm/drm_fb_helper.c
+@@ -639,20 +639,19 @@ static struct sysrq_key_op sysrq_drm_fb_helper_restore_op = { };
+ static void dpms_legacy(struct drm_fb_helper *fb_helper, int dpms_mode)
+ {
+ struct drm_device *dev = fb_helper->dev;
+- struct drm_crtc *crtc;
+ struct drm_connector *connector;
++ struct drm_mode_set *modeset;
+ int i, j;
+
+ drm_modeset_lock_all(dev);
+ for (i = 0; i < fb_helper->crtc_count; i++) {
+- crtc = fb_helper->crtc_info[i].mode_set.crtc;
++ modeset = &fb_helper->crtc_info[i].mode_set;
+
+- if (!crtc->enabled)
++ if (!modeset->crtc->enabled)
+ continue;
+
+- /* Walk the connectors & encoders on this fb turning them on/off */
+- drm_fb_helper_for_each_connector(fb_helper, j) {
+- connector = fb_helper->connector_info[j]->connector;
++ for (j = 0; j < modeset->num_connectors; j++) {
++ connector = modeset->connectors[j];
+ connector->funcs->dpms(connector, dpms_mode);
+ drm_object_property_set_value(&connector->base,
+ dev->mode_config.dpms_property, dpms_mode);
+--
+2.16.4
+
diff --git a/patches.drm/drm-i915-Fix-I915_EXEC_RING_MASK.patch b/patches.drm/drm-i915-Fix-I915_EXEC_RING_MASK.patch
new file mode 100644
index 0000000000..5ce2396909
--- /dev/null
+++ b/patches.drm/drm-i915-Fix-I915_EXEC_RING_MASK.patch
@@ -0,0 +1,42 @@
+From d90c06d57027203f73021bb7ddb30b800d65c636 Mon Sep 17 00:00:00 2001
+From: Chris Wilson <chris@chris-wilson.co.uk>
+Date: Fri, 1 Mar 2019 14:03:47 +0000
+Subject: [PATCH] drm/i915: Fix I915_EXEC_RING_MASK
+Git-commit: d90c06d57027203f73021bb7ddb30b800d65c636
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+This was supposed to be a mask of all known rings, but it is being used
+by execbuffer to filter out invalid rings, and so is instead mapping high
+unused values onto valid rings. Instead of a mask of all known rings,
+we need it to be the mask of all possible rings.
+
+Fixes: 549f7365820a ("drm/i915: Enable SandyBridge blitter ring")
+Fixes: de1add360522 ("drm/i915: Decouple execbuf uAPI from internal implementation")
+Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
+Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
+Cc: <stable@vger.kernel.org> # v4.6+
+Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
+Link: https://patchwork.freedesktop.org/patch/msgid/20190301140404.26690-21-chris@chris-wilson.co.uk
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ include/uapi/drm/i915_drm.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
+index b10eea3f6d24..1a60642c1d61 100644
+--- a/include/uapi/drm/i915_drm.h
++++ b/include/uapi/drm/i915_drm.h
+@@ -979,7 +979,7 @@ struct drm_i915_gem_execbuffer2 {
+ * struct drm_i915_gem_exec_fence *fences.
+ */
+ __u64 cliprects_ptr;
+-#define I915_EXEC_RING_MASK (7<<0)
++#define I915_EXEC_RING_MASK (0x3f)
+ #define I915_EXEC_DEFAULT (0<<0)
+ #define I915_EXEC_RENDER (1<<0)
+ #define I915_EXEC_BSD (2<<0)
+--
+2.16.4
+
diff --git a/patches.drm/drm-mediatek-fix-possible-object-reference-leak.patch b/patches.drm/drm-mediatek-fix-possible-object-reference-leak.patch
new file mode 100644
index 0000000000..5cdf570357
--- /dev/null
+++ b/patches.drm/drm-mediatek-fix-possible-object-reference-leak.patch
@@ -0,0 +1,48 @@
+From 2ae2c3316fb77dcf64275d011596b60104c45426 Mon Sep 17 00:00:00 2001
+From: Wen Yang <wen.yang99@zte.com.cn>
+Date: Thu, 4 Apr 2019 00:04:09 +0800
+Subject: [PATCH] drm/mediatek: fix possible object reference leak
+Git-commit: 2ae2c3316fb77dcf64275d011596b60104c45426
+Patch-mainline: v5.1-rc5
+References: bsc#1051510
+
+The call to of_parse_phandle returns a node pointer with refcount
+incremented thus it must be explicitly decremented after the last
+usage.
+
+Detected by coccinelle with the following warnings:
+drivers/gpu/drm/mediatek/mtk_hdmi.c:1521:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1509, but without a corresponding object release within this function.
+drivers/gpu/drm/mediatek/mtk_hdmi.c:1524:1-7: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 1509, but without a corresponding object release within this function.
+
+Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
+Cc: CK Hu <ck.hu@mediatek.com>
+Cc: Philipp Zabel <p.zabel@pengutronix.de>
+Cc: David Airlie <airlied@linux.ie>
+Cc: Daniel Vetter <daniel@ffwll.ch>
+Cc: Matthias Brugger <matthias.bgg@gmail.com>
+Cc: dri-devel@lists.freedesktop.org
+Cc: linux-arm-kernel@lists.infradead.org
+Cc: linux-mediatek@lists.infradead.org
+Cc: linux-kernel@vger.kernel.org
+Signed-off-by: CK Hu <ck.hu@mediatek.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/gpu/drm/mediatek/mtk_hdmi.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c
+index 543a25e5765e..e04e6c293d39 100644
+--- a/drivers/gpu/drm/mediatek/mtk_hdmi.c
++++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c
+@@ -1515,6 +1515,7 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
+ of_node_put(remote);
+
+ hdmi->ddc_adpt = of_find_i2c_adapter_by_node(i2c_np);
++ of_node_put(i2c_np);
+ if (!hdmi->ddc_adpt) {
+ dev_err(dev, "Failed to get ddc i2c adapter by node\n");
+ return -EINVAL;
+--
+2.16.4
+
diff --git a/patches.drm/drm-rockchip-shutdown-drm-subsystem-on-shutdown.patch b/patches.drm/drm-rockchip-shutdown-drm-subsystem-on-shutdown.patch
new file mode 100644
index 0000000000..bb379c2f0e
--- /dev/null
+++ b/patches.drm/drm-rockchip-shutdown-drm-subsystem-on-shutdown.patch
@@ -0,0 +1,74 @@
+From b8f9d7f37b6af829c34c49d1a4f73ce6ed58e403 Mon Sep 17 00:00:00 2001
+From: Vicente Bergas <vicencb@gmail.com>
+Date: Tue, 2 Apr 2019 13:37:53 +0200
+Subject: [PATCH] drm/rockchip: shutdown drm subsystem on shutdown
+Git-commit: b8f9d7f37b6af829c34c49d1a4f73ce6ed58e403
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+As explained by Robin Murphy:
+> the IOMMU shutdown disables paging, so if the VOP is still
+> scanning out then that will result in whatever IOVAs it was using now going
+> straight out onto the bus as physical addresses.
+
+We had a more radical approach before in commit
+7f3ef5dedb14 ("drm/rockchip: Allow driver to be shutdown on reboot/kexec")
+but that resulted in new warnings and oopses on shutdown on rk3399
+chromeos devices.
+
+So second try is resurrecting Vicentes shutdown change which should
+achieve the same result but in a less drastic way.
+
+Fixes: 63238173b2fa ("Revert "drm/rockchip: Allow driver to be shutdown on reboot/kexec"")
+Cc: Jeffy Chen <jeffy.chen@rock-chips.com>
+Cc: Robin Murphy <robin.murphy@arm.com>
+Cc: Marc Zyngier <marc.zyngier@arm.com>
+Cc: Brian Norris <briannorris@chromium.org>
+Cc: Doug Anderson <dianders@chromium.org>
+Cc: stable@vger.kernel.org
+Suggested-by: JeffyChen <jeffy.chen@rock-chips.com>
+Suggested-by: Robin Murphy <robin.murphy@arm.com>
+Signed-off-by: Vicente Bergas <vicencb@gmail.com>
+[adapted commit message to explain the history]
+
+Signed-off-by: Heiko Stuebner <heiko@sntech.de>
+Tested-by: Brian Norris <briannorris@chromium.org>
+Tested-by: Douglas Anderson <dianders@chromium.org>
+Acked-by: Marc Zyngier <marc.zyngier@arm.com>
+Link: https://patchwork.freedesktop.org/patch/msgid/20190402113753.10118-1-heiko@sntech.de
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+index 8d7a634c12c2..cb938d3cd3c2 100644
+--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
++++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+@@ -448,6 +448,14 @@ static int rockchip_drm_platform_remove(struct platform_device *pdev)
+ return 0;
+ }
+
++static void rockchip_drm_platform_shutdown(struct platform_device *pdev)
++{
++ struct drm_device *drm = platform_get_drvdata(pdev);
++
++ if (drm)
++ drm_atomic_helper_shutdown(drm);
++}
++
+ static const struct of_device_id rockchip_drm_dt_ids[] = {
+ { .compatible = "rockchip,display-subsystem", },
+ { /* sentinel */ },
+@@ -457,6 +465,7 @@ MODULE_DEVICE_TABLE(of, rockchip_drm_dt_ids);
+ static struct platform_driver rockchip_drm_platform_driver = {
+ .probe = rockchip_drm_platform_probe,
+ .remove = rockchip_drm_platform_remove,
++ .shutdown = rockchip_drm_platform_shutdown,
+ .driver = {
+ .name = "rockchip-drm",
+ .of_match_table = rockchip_drm_dt_ids,
+--
+2.16.4
+
diff --git a/patches.fixes/0001-btrfs-qgroup-Move-reserved-data-accounting-from-btrf.patch b/patches.fixes/0001-btrfs-qgroup-Move-reserved-data-accounting-from-btrf.patch
index a1afb3c4ac..ca0ac6e584 100644
--- a/patches.fixes/0001-btrfs-qgroup-Move-reserved-data-accounting-from-btrf.patch
+++ b/patches.fixes/0001-btrfs-qgroup-Move-reserved-data-accounting-from-btrf.patch
@@ -102,24 +102,25 @@ Fixes: f64d5ca86821 ("btrfs: delayed_ref: Add new function to record reserved sp
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
---
- fs/btrfs/delayed-ref.c | 12 ++++--------
+ fs/btrfs/delayed-ref.c | 14 ++++----------
fs/btrfs/delayed-ref.h | 11 -----------
fs/btrfs/extent-tree.c | 3 ---
fs/btrfs/qgroup.c | 19 +++++++++++++++----
fs/btrfs/qgroup.h | 18 +++++++++++-------
include/trace/events/btrfs.h | 29 -----------------------------
- 6 files changed, 30 insertions(+), 62 deletions(-)
+ 6 files changed, 30 insertions(+), 64 deletions(-)
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
-@@ -618,14 +618,12 @@ add_delayed_ref_head(struct btrfs_fs_inf
- INIT_LIST_HEAD(&head_ref->ref_add_list);
+@@ -590,15 +590,13 @@ static void init_delayed_ref_head(struct
+ RB_CLEAR_NODE(&head_ref->href_node);
head_ref->processing = 0;
head_ref->total_ref_mod = count_mod;
- head_ref->qgroup_reserved = 0;
- head_ref->qgroup_ref_root = 0;
+ spin_lock_init(&head_ref->lock);
+ mutex_init(&head_ref->mutex);
- /* Record qgroup extent info if provided */
if (qrecord) {
if (ref_root && reserved) {
- head_ref->qgroup_ref_root = ref_root;
@@ -129,16 +130,18 @@ Signed-off-by: David Sterba <dsterba@suse.com>
}
qrecord->bytenr = bytenr;
-@@ -647,8 +645,6 @@ add_delayed_ref_head(struct btrfs_fs_inf
+@@ -641,10 +639,6 @@ add_delayed_ref_head(struct btrfs_fs_inf
existing = htree_insert(&delayed_refs->href_root,
&head_ref->href_node);
if (existing) {
-- WARN_ON(ref_root && reserved && existing->qgroup_ref_root
+- WARN_ON(qrecord && head_ref->qgroup_ref_root
+- && head_ref->qgroup_reserved
+- && existing->qgroup_ref_root
- && existing->qgroup_reserved);
- update_existing_head_ref(delayed_refs, &existing->node, ref,
+ update_existing_head_ref(delayed_refs, existing, head_ref,
old_ref_mod);
/*
-@@ -815,7 +811,7 @@ int btrfs_add_delayed_tree_ref(struct bt
+@@ -764,7 +758,7 @@ int btrfs_add_delayed_tree_ref(struct bt
if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) &&
is_fstree(ref_root)) {
@@ -147,7 +150,7 @@ Signed-off-by: David Sterba <dsterba@suse.com>
if (!record)
goto free_head_ref;
}
-@@ -878,7 +874,7 @@ int btrfs_add_delayed_data_ref(struct bt
+@@ -848,7 +842,7 @@ int btrfs_add_delayed_data_ref(struct bt
if (test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) &&
is_fstree(ref_root)) {
@@ -158,8 +161,8 @@ Signed-off-by: David Sterba <dsterba@suse.com>
kmem_cache_free(btrfs_delayed_ref_head_cachep,
--- a/fs/btrfs/delayed-ref.h
+++ b/fs/btrfs/delayed-ref.h
-@@ -116,17 +116,6 @@ struct btrfs_delayed_ref_head {
- int total_ref_mod;
+@@ -115,17 +115,6 @@ struct btrfs_delayed_ref_head {
+ int ref_mod;
/*
- * For qgroup reserved space freeing.
@@ -178,16 +181,16 @@ Signed-off-by: David Sterba <dsterba@suse.com>
* until the delayed ref is processed. must_insert_reserved is
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
-@@ -2465,9 +2465,6 @@ static int run_one_delayed_ref(struct bt
- }
+@@ -2563,9 +2563,6 @@ static int cleanup_ref_head(struct btrfs
}
-
-- /* Also free its reserved qgroup space */
-- btrfs_qgroup_free_delayed_ref(fs_info, head->qgroup_ref_root,
-- head->qgroup_reserved);
- return ret;
}
+- /* Also free its reserved qgroup space */
+- btrfs_qgroup_free_delayed_ref(fs_info, head->qgroup_ref_root,
+- head->qgroup_reserved);
+ btrfs_delayed_ref_unlock(head);
+ btrfs_put_delayed_ref_head(head);
+ return 0;
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -1488,12 +1488,18 @@ int btrfs_qgroup_trace_extent_nolock(str
@@ -269,7 +272,7 @@ Signed-off-by: David Sterba <dsterba@suse.com>
int btrfs_verify_qgroup_counts(struct btrfs_fs_info *fs_info, u64 qgroupid,
--- a/include/trace/events/btrfs.h
+++ b/include/trace/events/btrfs.h
-@@ -1516,35 +1516,6 @@ DEFINE_EVENT(btrfs__qgroup_rsv_data, btr
+@@ -1513,35 +1513,6 @@ DEFINE_EVENT(btrfs__qgroup_rsv_data, btr
TP_ARGS(inode, start, len, reserved, op)
);
diff --git a/patches.fixes/0001-btrfs-reloc-Fix-NULL-pointer-dereference-due-to-expa.patch b/patches.fixes/0001-btrfs-reloc-Fix-NULL-pointer-dereference-due-to-expa.patch
index 4dae97abe4..4d5eb8d080 100644
--- a/patches.fixes/0001-btrfs-reloc-Fix-NULL-pointer-dereference-due-to-expa.patch
+++ b/patches.fixes/0001-btrfs-reloc-Fix-NULL-pointer-dereference-due-to-expa.patch
@@ -1,8 +1,9 @@
From e8fd2e459649ab5105cc627018dd25ea395719de Mon Sep 17 00:00:00 2001
From: Qu Wenruo <wqu@suse.com>
Date: Mon, 18 Mar 2019 10:37:22 +0800
-Patch-mainline: Submitted, for v5.1
-References: bsc#1129497
+Patch-mainline: v5.2-rc1
+Git-commit: 10995c0491204c861948c9850939a7f4e90760a4
+References: bsc#1129497 bsc#1134651
Subject: [PATCH] btrfs: reloc: Fix NULL pointer dereference due to expanded
reloc_root lifespan
diff --git a/patches.fixes/0001-dt-bindings-net-Fix-a-typo-in-the-phy-mode-list-for-.patch b/patches.fixes/0001-dt-bindings-net-Fix-a-typo-in-the-phy-mode-list-for-.patch
new file mode 100644
index 0000000000..af7026daec
--- /dev/null
+++ b/patches.fixes/0001-dt-bindings-net-Fix-a-typo-in-the-phy-mode-list-for-.patch
@@ -0,0 +1,37 @@
+From 822dd046d7e22a8d01728200a003da230e4c6f7f Mon Sep 17 00:00:00 2001
+From: Maxime Chevallier <maxime.chevallier@bootlin.com>
+Date: Tue, 7 May 2019 17:35:55 +0200
+Subject: [PATCH] dt-bindings: net: Fix a typo in the phy-mode list for
+ ethernet bindings
+Git-commit: 822dd046d7e22a8d01728200a003da230e4c6f7f
+Patch-mainline: v5.1
+References: bsc#1129770
+
+The phy_mode "2000base-x" is actually supposed to be "1000base-x", even
+though the commit title of the original patch says otherwise.
+
+Fixes: 55601a880690 ("net: phy: Add 2000base-x, 2500base-x and rxaui modes")
+Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
+Reviewed-by: Andrew Lunn <andrew@lunn.ch>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Reviewed-by: Fabian Baumanis <fabian.baumanis@suse.com>
+---
+ Documentation/devicetree/bindings/net/ethernet.txt | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Documentation/devicetree/bindings/net/ethernet.txt b/Documentation/devicetree/bindings/net/ethernet.txt
+index a68621580584..d45b5b56fa39 100644
+--- a/Documentation/devicetree/bindings/net/ethernet.txt
++++ b/Documentation/devicetree/bindings/net/ethernet.txt
+@@ -36,7 +36,7 @@ Documentation/devicetree/bindings/phy/phy-bindings.txt.
+ * "smii"
+ * "xgmii"
+ * "trgmii"
+- * "2000base-x",
++ * "1000base-x",
+ * "2500base-x",
+ * "rxaui"
+ * "xaui"
+--
+2.16.4
+
diff --git a/patches.fixes/0001-media-pvrusb2-Prevent-a-buffer-overflow.patch b/patches.fixes/0001-media-pvrusb2-Prevent-a-buffer-overflow.patch
new file mode 100644
index 0000000000..408b10e725
--- /dev/null
+++ b/patches.fixes/0001-media-pvrusb2-Prevent-a-buffer-overflow.patch
@@ -0,0 +1,61 @@
+From c1ced46c7b49ad7bc064e68d966e0ad303f917fb Mon Sep 17 00:00:00 2001
+From: Dan Carpenter <dan.carpenter@oracle.com>
+Date: Mon, 8 Apr 2019 05:52:38 -0400
+Subject: [PATCH] media: pvrusb2: Prevent a buffer overflow
+Git-commit: c1ced46c7b49ad7bc064e68d966e0ad303f917fb
+Patch-mainline: v5.1
+References: bsc#1129770
+
+The ctrl_check_input() function is called from pvr2_ctrl_range_check().
+It's supposed to validate user supplied input and return true or false
+depending on whether the input is valid or not. The problem is that
+negative shifts or shifts greater than 31 are undefined in C. In
+practice with GCC they result in shift wrapping so this function returns
+true for some inputs which are not valid and this could result in a
+buffer overflow:
+
+ drivers/media/usb/pvrusb2/pvrusb2-ctrl.c:205 pvr2_ctrl_get_valname()
+ warn: uncapped user index 'names[val]'
+
+The cptr->hdw->input_allowed_mask mask is configured in pvr2_hdw_create()
+and the highest valid bit is BIT(4).
+
+Fixes: 7fb20fa38caa ("V4L/DVB (7299): pvrusb2: Improve logic which handles input choice availability")
+
+Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
+Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
+Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
+Signed-off-by: Oliver Neukum <oneukum@suse.com>
+---
+ drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 2 ++
+ drivers/media/usb/pvrusb2/pvrusb2-hdw.h | 1 +
+ 2 files changed, 3 insertions(+)
+
+diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+index 51112b7988e4..816c85786c2a 100644
+--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
++++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
+@@ -666,6 +666,8 @@ static int ctrl_get_input(struct pvr2_ctrl *cptr,int *vp)
+
+ static int ctrl_check_input(struct pvr2_ctrl *cptr,int v)
+ {
++ if (v < 0 || v > PVR2_CVAL_INPUT_MAX)
++ return 0;
+ return ((1 << v) & cptr->hdw->input_allowed_mask) != 0;
+ }
+
+diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.h b/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
+index 25648add77e5..bd2b7a67b732 100644
+--- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
++++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.h
+@@ -50,6 +50,7 @@
+ #define PVR2_CVAL_INPUT_COMPOSITE 2
+ #define PVR2_CVAL_INPUT_SVIDEO 3
+ #define PVR2_CVAL_INPUT_RADIO 4
++#define PVR2_CVAL_INPUT_MAX PVR2_CVAL_INPUT_RADIO
+
+ enum pvr2_config {
+ pvr2_config_empty, /* No configuration */
+--
+2.16.4
+
diff --git a/patches.fixes/0001-mtd-spi-nor-intel-spi-Avoid-crossing-4K-address-boun.patch b/patches.fixes/0001-mtd-spi-nor-intel-spi-Avoid-crossing-4K-address-boun.patch
new file mode 100644
index 0000000000..14339e2271
--- /dev/null
+++ b/patches.fixes/0001-mtd-spi-nor-intel-spi-Avoid-crossing-4K-address-boun.patch
@@ -0,0 +1,73 @@
+From 2b75ebeea6f4937d4d05ec4982c471cef9a29b7f Mon Sep 17 00:00:00 2001
+From: Alexander Sverdlin <alexander.sverdlin@nokia.com>
+Date: Tue, 19 Mar 2019 17:18:07 +0000
+Subject: [PATCH] mtd: spi-nor: intel-spi: Avoid crossing 4K address boundary
+ on read/write
+Git-commit: 2b75ebeea6f4937d4d05ec4982c471cef9a29b7f
+Patch-mainline: v5.1
+References: bsc#1129770
+
+It was observed that reads crossing 4K address boundary are failing.
+
+This limitation is mentioned in Intel documents:
+
+Intel(R) 9 Series Chipset Family Platform Controller Hub (PCH) Datasheet:
+
+"5.26.3 Flash Access
+Program Register Access:
+* Program Register Accesses are not allowed to cross a 4 KB boundary..."
+
+Enhanced Serial Peripheral Interface (eSPI)
+Interface Base Specification (for Client and Server Platforms):
+
+"5.1.4 Address
+For other memory transactions, the address may start or end at any byte
+boundary. However, the address and payload length combination must not
+cross the naturally aligned address boundary of the corresponding Maximum
+Payload Size. It must not cross a 4 KB address boundary."
+
+Avoid this by splitting an operation crossing the boundary into two
+operations.
+
+Fixes: 8afda8b26d01 ("spi-nor: Add support for Intel SPI serial flash controller")
+Cc: stable@vger.kernel.org
+Reported-by: Romain Porte <romain.porte@nokia.com>
+Tested-by: Pascal Fabreges <pascal.fabreges@nokia.com>
+Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
+Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>
+Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
+Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Signed-off-by: Oliver Neukum <oneukum@suse.com>
+---
+ drivers/mtd/spi-nor/intel-spi.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/drivers/mtd/spi-nor/intel-spi.c b/drivers/mtd/spi-nor/intel-spi.c
+index af0a22019516..d60cbf23d9aa 100644
+--- a/drivers/mtd/spi-nor/intel-spi.c
++++ b/drivers/mtd/spi-nor/intel-spi.c
+@@ -632,6 +632,10 @@ static ssize_t intel_spi_read(struct spi_nor *nor, loff_t from, size_t len,
+ while (len > 0) {
+ block_size = min_t(size_t, len, INTEL_SPI_FIFO_SZ);
+
++ /* Read cannot cross 4K boundary */
++ block_size = min_t(loff_t, from + block_size,
++ round_up(from + 1, SZ_4K)) - from;
++
+ writel(from, ispi->base + FADDR);
+
+ val = readl(ispi->base + HSFSTS_CTL);
+@@ -685,6 +689,10 @@ static ssize_t intel_spi_write(struct spi_nor *nor, loff_t to, size_t len,
+ while (len > 0) {
+ block_size = min_t(size_t, len, INTEL_SPI_FIFO_SZ);
+
++ /* Write cannot cross 4K boundary */
++ block_size = min_t(loff_t, to + block_size,
++ round_up(to + 1, SZ_4K)) - to;
++
+ writel(to, ispi->base + FADDR);
+
+ val = readl(ispi->base + HSFSTS_CTL);
+--
+2.16.4
+
diff --git a/patches.fixes/Revert-ide-unexport-DISK_EVENT_MEDIA_CHANGE-for-ide-.patch b/patches.fixes/Revert-ide-unexport-DISK_EVENT_MEDIA_CHANGE-for-ide-.patch
new file mode 100644
index 0000000000..df616f4224
--- /dev/null
+++ b/patches.fixes/Revert-ide-unexport-DISK_EVENT_MEDIA_CHANGE-for-ide-.patch
@@ -0,0 +1,71 @@
+From 3e6cbb165a21e50cace5cffb17d61f249a2203ce Mon Sep 17 00:00:00 2001
+From: Martin Wilck <mwilck@suse.com>
+Date: Thu, 17 Jan 2019 22:46:56 +0100
+Subject: [PATCH 2/4] Revert "ide: unexport DISK_EVENT_MEDIA_CHANGE for ide-gd
+ and ide-cd"
+Git-commit: 3c12c8e94ca04d668ad0cded7857fea2637834b3
+Patch-mainline: v5.2-rc1
+References: bsc#1110946
+
+This reverts commit 7eec77a1816a7042591a6cbdb4820e9e7ebffe0e.
+
+Instead of leaving disk->events completely empty, we now export the supported
+events again, and tell the block layer not to forward events to user space by
+not setting DISK_EVENT_FLAG_UEVENT. This allows the block layer to distinguish
+between devices that for which events should be handled in kernel only, and
+devices which don't support any meda change events at all.
+
+Cc: Borislav Petkov <bp@alien8.de>
+Signed-off-by: Martin Wilck <mwilck@suse.com>
+---
+ drivers/ide/ide-cd.c | 1 +
+ drivers/ide/ide-cd_ioctl.c | 5 +++--
+ drivers/ide/ide-gd.c | 6 ++++--
+ 3 files changed, 8 insertions(+), 4 deletions(-)
+
+--- a/drivers/ide/ide-cd.c
++++ b/drivers/ide/ide-cd.c
+@@ -1796,6 +1796,7 @@ static int ide_cd_probe(ide_drive_t *dri
+ ide_cd_read_toc(drive, &sense);
+ g->fops = &idecd_ops;
+ g->flags |= GENHD_FL_REMOVABLE | GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE;
++ g->events = DISK_EVENT_MEDIA_CHANGE;
+ device_add_disk(&drive->gendev, g);
+ return 0;
+
+--- a/drivers/ide/ide-cd_ioctl.c
++++ b/drivers/ide/ide-cd_ioctl.c
+@@ -81,8 +81,9 @@ int ide_cdrom_drive_status(struct cdrom_
+
+ /*
+ * ide-cd always generates media changed event if media is missing, which
+- * makes it impossible to use for proper event reporting, so disk->events
+- * is cleared to 0 and the following function is used only to trigger
++ * makes it impossible to use for proper event reporting, so
++ * DISK_EVENT_FLAG_UEVENT is cleared in disk->events
++ * and the following function is used only to trigger
+ * revalidation and never propagated to userland.
+ */
+ unsigned int ide_cdrom_check_events_real(struct cdrom_device_info *cdi,
+--- a/drivers/ide/ide-gd.c
++++ b/drivers/ide/ide-gd.c
+@@ -299,8 +299,9 @@ static unsigned int ide_gd_check_events(
+ /*
+ * The following is used to force revalidation on the first open on
+ * removeable devices, and never gets reported to userland as
+- * genhd->events is 0. This is intended as removeable ide disk
+- * can't really detect MEDIA_CHANGE events.
++ * DISK_EVENT_FLAG_UEVENT isn't set in genhd->events.
++ * This is intended as removeable ide disk can't really detect
++ * MEDIA_CHANGE events.
+ */
+ ret = drive->dev_flags & IDE_DFLAG_MEDIA_CHANGED;
+ drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED;
+@@ -416,6 +417,7 @@ static int ide_gd_probe(ide_drive_t *dri
+ if (drive->dev_flags & IDE_DFLAG_REMOVABLE)
+ g->flags = GENHD_FL_REMOVABLE;
+ g->fops = &ide_gd_ops;
++ g->events = DISK_EVENT_MEDIA_CHANGE;
+ device_add_disk(&drive->gendev, g);
+ return 0;
+
diff --git a/patches.fixes/kernel-sysctl.c-add-missing-range-check-in-do_proc_d.patch b/patches.fixes/kernel-sysctl.c-add-missing-range-check-in-do_proc_d.patch
new file mode 100644
index 0000000000..83779f34ed
--- /dev/null
+++ b/patches.fixes/kernel-sysctl.c-add-missing-range-check-in-do_proc_d.patch
@@ -0,0 +1,56 @@
+From 8cf7630b29701d364f8df4a50e4f1f5e752b2778 Mon Sep 17 00:00:00 2001
+From: Zev Weiss <zev@bewilderbeest.net>
+Date: Mon, 11 Mar 2019 23:28:02 -0700
+Subject: [PATCH] kernel/sysctl.c: add missing range check in do_proc_dointvec_minmax_conv
+Git-commit: 8cf7630b29701d364f8df4a50e4f1f5e752b2778
+Patch-mainline: v5.1-rc1
+References: bsc#1051510
+
+This bug has apparently existed since the introduction of this function
+in the pre-git era (4500e91754d3 in Thomas Gleixner's history.git,
+"[net]: Add proc_dointvec_userhz_jiffies, use it for proper handling of
+neighbour sysctls.").
+
+As a minimal fix we can simply duplicate the corresponding check in
+do_proc_dointvec_conv().
+
+Link: http://lkml.kernel.org/r/20190207123426.9202-3-zev@bewilderbeest.net
+Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
+Cc: Brendan Higgins <brendanhiggins@google.com>
+Cc: Iurii Zaikin <yzaikin@google.com>
+Cc: Kees Cook <keescook@chromium.org>
+Cc: Luis Chamberlain <mcgrof@kernel.org>
+Cc: <stable@vger.kernel.org> [2.6.2+]
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ kernel/sysctl.c | 11 ++++++++++-
+ 1 file changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/kernel/sysctl.c b/kernel/sysctl.c
+index 7bb3988425ee..0854197e0e67 100644
+--- a/kernel/sysctl.c
++++ b/kernel/sysctl.c
+@@ -2645,7 +2645,16 @@ static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
+ {
+ struct do_proc_dointvec_minmax_conv_param *param = data;
+ if (write) {
+- int val = *negp ? -*lvalp : *lvalp;
++ int val;
++ if (*negp) {
++ if (*lvalp > (unsigned long) INT_MAX + 1)
++ return -EINVAL;
++ val = -*lvalp;
++ } else {
++ if (*lvalp > (unsigned long) INT_MAX)
++ return -EINVAL;
++ val = *lvalp;
++ }
+ if ((param->min && *param->min > val) ||
+ (param->max && *param->max < val))
+ return -EINVAL;
+--
+2.16.4
+
diff --git a/patches.fixes/kernel-sysctl.c-fix-out-of-bounds-access-when-settin.patch b/patches.fixes/kernel-sysctl.c-fix-out-of-bounds-access-when-settin.patch
new file mode 100644
index 0000000000..2060de230a
--- /dev/null
+++ b/patches.fixes/kernel-sysctl.c-fix-out-of-bounds-access-when-settin.patch
@@ -0,0 +1,93 @@
+From 9002b21465fa4d829edfc94a5a441005cffaa972 Mon Sep 17 00:00:00 2001
+From: Will Deacon <will.deacon@arm.com>
+Date: Fri, 5 Apr 2019 18:39:38 -0700
+Subject: [PATCH] kernel/sysctl.c: fix out-of-bounds access when setting file-max
+Git-commit: 9002b21465fa4d829edfc94a5a441005cffaa972
+Patch-mainline: v5.1-rc4
+References: bsc#1051510
+
+Commit 32a5ad9c2285 ("sysctl: handle overflow for file-max") hooked up
+min/max values for the file-max sysctl parameter via the .extra1 and
+.extra2 fields in the corresponding struct ctl_table entry.
+
+Unfortunately, the minimum value points at the global 'zero' variable,
+which is an int. This results in a KASAN splat when accessed as a long
+by proc_doulongvec_minmax on 64-bit architectures:
+
+ | BUG: KASAN: global-out-of-bounds in __do_proc_doulongvec_minmax+0x5d8/0x6a0
+ | Read of size 8 at addr ffff2000133d1c20 by task systemd/1
+ |
+ | CPU: 0 PID: 1 Comm: systemd Not tainted 5.1.0-rc3-00012-g40b114779944 #2
+ | Hardware name: linux,dummy-virt (DT)
+ | Call trace:
+ | dump_backtrace+0x0/0x228
+ | show_stack+0x14/0x20
+ | dump_stack+0xe8/0x124
+ | print_address_description+0x60/0x258
+ | kasan_report+0x140/0x1a0
+ | __asan_report_load8_noabort+0x18/0x20
+ | __do_proc_doulongvec_minmax+0x5d8/0x6a0
+ | proc_doulongvec_minmax+0x4c/0x78
+ | proc_sys_call_handler.isra.19+0x144/0x1d8
+ | proc_sys_write+0x34/0x58
+ | __vfs_write+0x54/0xe8
+ | vfs_write+0x124/0x3c0
+ | ksys_write+0xbc/0x168
+ | __arm64_sys_write+0x68/0x98
+ | el0_svc_common+0x100/0x258
+ | el0_svc_handler+0x48/0xc0
+ | el0_svc+0x8/0xc
+ |
+ | The buggy address belongs to the variable:
+ | zero+0x0/0x40
+ |
+ | Memory state around the buggy address:
+ | ffff2000133d1b00: 00 00 00 00 00 00 00 00 fa fa fa fa 04 fa fa fa
+ | ffff2000133d1b80: fa fa fa fa 04 fa fa fa fa fa fa fa 04 fa fa fa
+ | >ffff2000133d1c00: fa fa fa fa 04 fa fa fa fa fa fa fa 00 00 00 00
+ | ^
+ | ffff2000133d1c80: fa fa fa fa 00 fa fa fa fa fa fa fa 00 00 00 00
+ | ffff2000133d1d00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+
+Fix the splat by introducing a unsigned long 'zero_ul' and using that
+instead.
+
+Link: http://lkml.kernel.org/r/20190403153409.17307-1-will.deacon@arm.com
+Fixes: 32a5ad9c2285 ("sysctl: handle overflow for file-max")
+Signed-off-by: Will Deacon <will.deacon@arm.com>
+Acked-by: Christian Brauner <christian@brauner.io>
+Cc: Kees Cook <keescook@chromium.org>
+Cc: Alexey Dobriyan <adobriyan@gmail.com>
+Cc: Matteo Croce <mcroce@redhat.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ kernel/sysctl.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/kernel/sysctl.c b/kernel/sysctl.c
+index e5da394d1ca3..c9ec050bcf46 100644
+--- a/kernel/sysctl.c
++++ b/kernel/sysctl.c
+@@ -128,6 +128,7 @@ static int zero;
+ static int __maybe_unused one = 1;
+ static int __maybe_unused two = 2;
+ static int __maybe_unused four = 4;
++static unsigned long zero_ul;
+ static unsigned long one_ul = 1;
+ static unsigned long long_max = LONG_MAX;
+ static int one_hundred = 100;
+@@ -1750,7 +1751,7 @@ static struct ctl_table fs_table[] = {
+ .maxlen = sizeof(files_stat.max_files),
+ .mode = 0644,
+ .proc_handler = proc_doulongvec_minmax,
+- .extra1 = &zero,
++ .extra1 = &zero_ul,
+ .extra2 = &long_max,
+ },
+ {
+--
+2.16.4
+
diff --git a/patches.fixes/linux-kernel.h-Use-parentheses-around-argument-in-u6.patch b/patches.fixes/linux-kernel.h-Use-parentheses-around-argument-in-u6.patch
new file mode 100644
index 0000000000..bfbac90a9e
--- /dev/null
+++ b/patches.fixes/linux-kernel.h-Use-parentheses-around-argument-in-u6.patch
@@ -0,0 +1,72 @@
+From a0fe2c6479aab5723239b315ef1b552673f434a3 Mon Sep 17 00:00:00 2001
+From: Jann Horn <jannh@google.com>
+Date: Fri, 29 Mar 2019 22:46:49 +0100
+Subject: [PATCH] linux/kernel.h: Use parentheses around argument in u64_to_user_ptr()
+Git-commit: a0fe2c6479aab5723239b315ef1b552673f434a3
+Patch-mainline: v5.1-rc5
+References: bsc#1051510
+
+Use parentheses around uses of the argument in u64_to_user_ptr() to
+ensure that the cast doesn't apply to part of the argument.
+
+There are existing uses of the macro of the form
+
+ u64_to_user_ptr(A + B)
+
+which expands to
+
+ (void __user *)(uintptr_t)A + B
+
+(the cast applies to the first operand of the addition, the addition
+is a pointer addition). This happens to still work as intended, the
+semantic difference doesn't cause a difference in behavior.
+
+But I want to use u64_to_user_ptr() with a ternary operator in the
+argument, like so:
+
+ u64_to_user_ptr(A ? B : C)
+
+This currently doesn't work as intended.
+
+Signed-off-by: Jann Horn <jannh@google.com>
+Signed-off-by: Borislav Petkov <bp@suse.de>
+Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
+Cc: Andrei Vagin <avagin@openvz.org>
+Cc: Andrew Morton <akpm@linux-foundation.org>
+Cc: Dan Carpenter <dan.carpenter@oracle.com>
+Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Cc: "H. Peter Anvin" <hpa@zytor.com>
+Cc: Ingo Molnar <mingo@kernel.org>
+Cc: Jani Nikula <jani.nikula@intel.com>
+Cc: Kees Cook <keescook@chromium.org>
+Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
+Cc: NeilBrown <neilb@suse.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Qiaowei Ren <qiaowei.ren@intel.com>
+Cc: Thomas Gleixner <tglx@linutronix.de>
+Cc: x86-ml <x86@kernel.org>
+Link: https://lkml.kernel.org/r/20190329214652.258477-1-jannh@google.com
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ include/linux/kernel.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/include/linux/kernel.h b/include/linux/kernel.h
+index 34a5036debd3..2d14e21c16c0 100644
+--- a/include/linux/kernel.h
++++ b/include/linux/kernel.h
+@@ -47,8 +47,8 @@
+
+ #define u64_to_user_ptr(x) ( \
+ { \
+- typecheck(u64, x); \
+- (void __user *)(uintptr_t)x; \
++ typecheck(u64, (x)); \
++ (void __user *)(uintptr_t)(x); \
+ } \
+ )
+
+--
+2.16.4
+
diff --git a/patches.fixes/net-rds-force-to-destroy-connection-if-t_sock-is-NUL.patch b/patches.fixes/net-rds-force-to-destroy-connection-if-t_sock-is-NUL.patch
new file mode 100644
index 0000000000..bb5d3efa51
--- /dev/null
+++ b/patches.fixes/net-rds-force-to-destroy-connection-if-t_sock-is-NUL.patch
@@ -0,0 +1,143 @@
+From: Mao Wenan <maowenan@huawei.com>
+Date: Thu, 28 Mar 2019 17:10:56 +0800
+Subject: net: rds: force to destroy connection if t_sock is NULL in rds_tcp_kill_sock().
+Patch-mainline: v5.1-rc4
+Git-commit: cb66ddd156203daefb8d71158036b27b0e2caf63
+References: CVE-2019-11815 bsc#1134537
+
+When it is to cleanup net namespace, rds_tcp_exit_net() will call
+rds_tcp_kill_sock(), if t_sock is NULL, it will not call
+rds_conn_destroy(), rds_conn_path_destroy() and rds_tcp_conn_free() to free
+connection, and the worker cp_conn_w is not stopped, afterwards the net is freed in
+net_drop_ns(); While cp_conn_w rds_connect_worker() will call rds_tcp_conn_path_connect()
+and reference 'net' which has already been freed.
+
+In rds_tcp_conn_path_connect(), rds_tcp_set_callbacks() will set t_sock = sock before
+sock->ops->connect, but if connect() is failed, it will call
+rds_tcp_restore_callbacks() and set t_sock = NULL, if connect is always
+failed, rds_connect_worker() will try to reconnect all the time, so
+rds_tcp_kill_sock() will never to cancel worker cp_conn_w and free the
+connections.
+
+Therefore, the condition !tc->t_sock is not needed if it is going to do
+cleanup_net->rds_tcp_exit_net->rds_tcp_kill_sock, because tc->t_sock is always
+NULL, and there is on other path to cancel cp_conn_w and free
+connection. So this patch is to fix this.
+
+rds_tcp_kill_sock():
+...
+if (net != c_net || !tc->t_sock)
+...
+Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
+
+==================================================================
+BUG: KASAN: use-after-free in inet_create+0xbcc/0xd28
+net/ipv4/af_inet.c:340
+Read of size 4 at addr ffff8003496a4684 by task kworker/u8:4/3721
+
+CPU: 3 PID: 3721 Comm: kworker/u8:4 Not tainted 5.1.0 #11
+Hardware name: linux,dummy-virt (DT)
+Workqueue: krdsd rds_connect_worker
+Call trace:
+ dump_backtrace+0x0/0x3c0 arch/arm64/kernel/time.c:53
+ show_stack+0x28/0x38 arch/arm64/kernel/traps.c:152
+ __dump_stack lib/dump_stack.c:77 [inline]
+ dump_stack+0x120/0x188 lib/dump_stack.c:113
+ print_address_description+0x68/0x278 mm/kasan/report.c:253
+ kasan_report_error mm/kasan/report.c:351 [inline]
+ kasan_report+0x21c/0x348 mm/kasan/report.c:409
+ __asan_report_load4_noabort+0x30/0x40 mm/kasan/report.c:429
+ inet_create+0xbcc/0xd28 net/ipv4/af_inet.c:340
+ __sock_create+0x4f8/0x770 net/socket.c:1276
+ sock_create_kern+0x50/0x68 net/socket.c:1322
+ rds_tcp_conn_path_connect+0x2b4/0x690 net/rds/tcp_connect.c:114
+ rds_connect_worker+0x108/0x1d0 net/rds/threads.c:175
+ process_one_work+0x6e8/0x1700 kernel/workqueue.c:2153
+ worker_thread+0x3b0/0xdd0 kernel/workqueue.c:2296
+ kthread+0x2f0/0x378 kernel/kthread.c:255
+ ret_from_fork+0x10/0x18 arch/arm64/kernel/entry.S:1117
+
+Allocated by task 687:
+ save_stack mm/kasan/kasan.c:448 [inline]
+ set_track mm/kasan/kasan.c:460 [inline]
+ kasan_kmalloc+0xd4/0x180 mm/kasan/kasan.c:553
+ kasan_slab_alloc+0x14/0x20 mm/kasan/kasan.c:490
+ slab_post_alloc_hook mm/slab.h:444 [inline]
+ slab_alloc_node mm/slub.c:2705 [inline]
+ slab_alloc mm/slub.c:2713 [inline]
+ kmem_cache_alloc+0x14c/0x388 mm/slub.c:2718
+ kmem_cache_zalloc include/linux/slab.h:697 [inline]
+ net_alloc net/core/net_namespace.c:384 [inline]
+ copy_net_ns+0xc4/0x2d0 net/core/net_namespace.c:424
+ create_new_namespaces+0x300/0x658 kernel/nsproxy.c:107
+ unshare_nsproxy_namespaces+0xa0/0x198 kernel/nsproxy.c:206
+ ksys_unshare+0x340/0x628 kernel/fork.c:2577
+ __do_sys_unshare kernel/fork.c:2645 [inline]
+ __se_sys_unshare kernel/fork.c:2643 [inline]
+ __arm64_sys_unshare+0x38/0x58 kernel/fork.c:2643
+ __invoke_syscall arch/arm64/kernel/syscall.c:35 [inline]
+ invoke_syscall arch/arm64/kernel/syscall.c:47 [inline]
+ el0_svc_common+0x168/0x390 arch/arm64/kernel/syscall.c:83
+ el0_svc_handler+0x60/0xd0 arch/arm64/kernel/syscall.c:129
+ el0_svc+0x8/0xc arch/arm64/kernel/entry.S:960
+
+Freed by task 264:
+ save_stack mm/kasan/kasan.c:448 [inline]
+ set_track mm/kasan/kasan.c:460 [inline]
+ __kasan_slab_free+0x114/0x220 mm/kasan/kasan.c:521
+ kasan_slab_free+0x10/0x18 mm/kasan/kasan.c:528
+ slab_free_hook mm/slub.c:1370 [inline]
+ slab_free_freelist_hook mm/slub.c:1397 [inline]
+ slab_free mm/slub.c:2952 [inline]
+ kmem_cache_free+0xb8/0x3a8 mm/slub.c:2968
+ net_free net/core/net_namespace.c:400 [inline]
+ net_drop_ns.part.6+0x78/0x90 net/core/net_namespace.c:407
+ net_drop_ns net/core/net_namespace.c:406 [inline]
+ cleanup_net+0x53c/0x6d8 net/core/net_namespace.c:569
+ process_one_work+0x6e8/0x1700 kernel/workqueue.c:2153
+ worker_thread+0x3b0/0xdd0 kernel/workqueue.c:2296
+ kthread+0x2f0/0x378 kernel/kthread.c:255
+ ret_from_fork+0x10/0x18 arch/arm64/kernel/entry.S:1117
+
+The buggy address belongs to the object at ffff8003496a3f80
+ which belongs to the cache net_namespace of size 7872
+The buggy address is located 1796 bytes inside of
+ 7872-byte region [ffff8003496a3f80, ffff8003496a5e40)
+The buggy address belongs to the page:
+page:ffff7e000d25a800 count:1 mapcount:0 mapping:ffff80036ce4b000
+index:0x0 compound_mapcount: 0
+flags: 0xffffe0000008100(slab|head)
+raw: 0ffffe0000008100 dead000000000100 dead000000000200 ffff80036ce4b000
+raw: 0000000000000000 0000000080040004 00000001ffffffff 0000000000000000
+page dumped because: kasan: bad access detected
+
+Memory state around the buggy address:
+ ffff8003496a4580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
+ ffff8003496a4600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
+>ffff8003496a4680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
+ ^
+ ffff8003496a4700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
+ ffff8003496a4780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
+==================================================================
+
+Fixes: 467fa15356ac("RDS-TCP: Support multiple RDS-TCP listen endpoints, one per netns.")
+Reported-by: Hulk Robot <hulkci@huawei.com>
+Signed-off-by: Mao Wenan <maowenan@huawei.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Acked-by: Michal Kubecek <mkubecek@suse.cz>
+
+---
+ net/rds/tcp.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/net/rds/tcp.c
++++ b/net/rds/tcp.c
+@@ -509,7 +509,7 @@ static void rds_tcp_kill_sock(struct net *net)
+ list_for_each_entry_safe(tc, _tc, &rds_tcp_conn_list, t_tcp_node) {
+ struct net *c_net = read_pnet(&tc->t_cpath->cp_conn->c_net);
+
+- if (net != c_net || !tc->t_sock)
++ if (net != c_net)
+ continue;
+ if (!list_has_conn(&tmp_list, tc->t_cpath->cp_conn)) {
+ list_move_tail(&tc->t_tcp_node, &tmp_list);
diff --git a/patches.fixes/nvme-multipath-avoid-crash-on-invalid-subsystem-cntl.patch b/patches.fixes/nvme-multipath-avoid-crash-on-invalid-subsystem-cntl.patch
index 84190b3834..f066dbf5a6 100644
--- a/patches.fixes/nvme-multipath-avoid-crash-on-invalid-subsystem-cntl.patch
+++ b/patches.fixes/nvme-multipath-avoid-crash-on-invalid-subsystem-cntl.patch
@@ -1,8 +1,10 @@
+From 8a03b27ea61c2ab9de16a8a195822ef05e799748 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
-Date: Fri May 3 15:37:35 2019 +0200
+Date: Fri, 3 May 2019 15:37:35 +0200
Subject: [PATCH] nvme-multipath: avoid crash on invalid subsystem cntlid
enumeration
-Git-commit: e2296434d80e1717695f0dff9f04fb9b7ee0fed0
+
+Git-commit: 8a03b27ea61c2ab9de16a8a195822ef05e799748
Patch-Mainline: queued in subsystem maintainer repository
Git-repo: git://git.infradead.org/nvme.git
References: bsc#1129273
@@ -20,7 +22,7 @@ Signed-off-by: Christoph Hellwig <hch@lst.de>
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
-index f0716f6ce41f..2551264ef2b5 100644
+index 5c9429d41120..499acf07d61a 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -31,7 +31,7 @@ void nvme_set_disk_name(char *disk_name, struct nvme_ns *ns,
@@ -33,5 +35,5 @@ index f0716f6ce41f..2551264ef2b5 100644
} else {
sprintf(disk_name, "nvme%dn%d", ctrl->subsys->instance,
--
-2.16.4
+2.20.1
diff --git a/patches.fixes/proc-kcore-don-t-bounds-check-against-address-0.patch b/patches.fixes/proc-kcore-don-t-bounds-check-against-address-0.patch
new file mode 100644
index 0000000000..d3de7d9dc5
--- /dev/null
+++ b/patches.fixes/proc-kcore-don-t-bounds-check-against-address-0.patch
@@ -0,0 +1,82 @@
+From 3955333df9a50e8783d115613a397ae55d905080 Mon Sep 17 00:00:00 2001
+From: Laura Abbott <labbott@redhat.com>
+Date: Fri, 11 May 2018 16:01:57 -0700
+Subject: [PATCH] proc/kcore: don't bounds check against address 0
+Git-commit: 3955333df9a50e8783d115613a397ae55d905080
+Patch-mainline: v4.17-rc5
+References: bsc#1051510
+
+The existing kcore code checks for bad addresses against __va(0) with
+the assumption that this is the lowest address on the system. This may
+not hold true on some systems (e.g. arm64) and produce overflows and
+crashes. Switch to using other functions to validate the address range.
+
+It's currently only seen on arm64 and it's not clear if anyone wants to
+use that particular combination on a stable release. So this is not
+urgent for stable.
+
+Link: http://lkml.kernel.org/r/20180501201143.15121-1-labbott@redhat.com
+Signed-off-by: Laura Abbott <labbott@redhat.com>
+Tested-by: Dave Anderson <anderson@redhat.com>
+Cc: Kees Cook <keescook@chromium.org>
+Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
+Cc: Ingo Molnar <mingo@kernel.org>
+Cc: Andi Kleen <andi@firstfloor.org>
+Cc: Alexey Dobriyan <adobriyan@gmail.com>a
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ fs/proc/kcore.c | 23 ++++++++++++++++-------
+ 1 file changed, 16 insertions(+), 7 deletions(-)
+
+diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
+index d1e82761de81..e64ecb9f2720 100644
+--- a/fs/proc/kcore.c
++++ b/fs/proc/kcore.c
+@@ -209,25 +209,34 @@ kclist_add_private(unsigned long pfn, unsigned long nr_pages, void *arg)
+ {
+ struct list_head *head = (struct list_head *)arg;
+ struct kcore_list *ent;
++ struct page *p;
++
++ if (!pfn_valid(pfn))
++ return 1;
++
++ p = pfn_to_page(pfn);
++ if (!memmap_valid_within(pfn, p, page_zone(p)))
++ return 1;
+
+ ent = kmalloc(sizeof(*ent), GFP_KERNEL);
+ if (!ent)
+ return -ENOMEM;
+- ent->addr = (unsigned long)__va((pfn << PAGE_SHIFT));
++ ent->addr = (unsigned long)page_to_virt(p);
+ ent->size = nr_pages << PAGE_SHIFT;
+
+- /* Sanity check: Can happen in 32bit arch...maybe */
+- if (ent->addr < (unsigned long) __va(0))
++ if (!virt_addr_valid(ent->addr))
+ goto free_out;
+
+ /* cut not-mapped area. ....from ppc-32 code. */
+ if (ULONG_MAX - ent->addr < ent->size)
+ ent->size = ULONG_MAX - ent->addr;
+
+- /* cut when vmalloc() area is higher than direct-map area */
+- if (VMALLOC_START > (unsigned long)__va(0)) {
+- if (ent->addr > VMALLOC_START)
+- goto free_out;
++ /*
++ * We've already checked virt_addr_valid so we know this address
++ * is a valid pointer, therefore we can check against it to determine
++ * if we need to trim
++ */
++ if (VMALLOC_START > ent->addr) {
+ if (VMALLOC_START - ent->addr < ent->size)
+ ent->size = VMALLOC_START - ent->addr;
+ }
+--
+2.16.4
+
diff --git a/patches.fixes/proc-revalidate-kernel-thread-inodes-to-root-root.patch b/patches.fixes/proc-revalidate-kernel-thread-inodes-to-root-root.patch
new file mode 100644
index 0000000000..a90c5ee9c1
--- /dev/null
+++ b/patches.fixes/proc-revalidate-kernel-thread-inodes-to-root-root.patch
@@ -0,0 +1,51 @@
+From 2e0ad552f5f8cd0fda02bc45fcd2b89821c62fd1 Mon Sep 17 00:00:00 2001
+From: Alexey Dobriyan <adobriyan@gmail.com>
+Date: Fri, 20 Apr 2018 14:56:03 -0700
+Subject: [PATCH] proc: revalidate kernel thread inodes to root:root
+Git-commit: 2e0ad552f5f8cd0fda02bc45fcd2b89821c62fd1
+Patch-mainline: v4.17-rc2
+References: bsc#1051510
+
+task_dump_owner() has the following code:
+
+ mm = task->mm;
+ if (mm) {
+ if (get_dumpable(mm) != SUID_DUMP_USER) {
+ uid = ...
+ }
+ }
+
+Check for ->mm is buggy -- kernel thread might be borrowing mm
+and inode will go to some random uid:gid pair.
+
+Link: http://lkml.kernel.org/r/20180412220109.GA20978@avx2
+Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
+Cc: "Eric W. Biederman" <ebiederm@xmission.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ fs/proc/base.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/fs/proc/base.c b/fs/proc/base.c
+index eafa39a3a88c..1b2ede6abcdf 100644
+--- a/fs/proc/base.c
++++ b/fs/proc/base.c
+@@ -1693,6 +1693,12 @@ void task_dump_owner(struct task_struct *task, umode_t mode,
+ kuid_t uid;
+ kgid_t gid;
+
++ if (unlikely(task->flags & PF_KTHREAD)) {
++ *ruid = GLOBAL_ROOT_UID;
++ *rgid = GLOBAL_ROOT_GID;
++ return;
++ }
++
+ /* Default to the tasks effective ownership */
+ rcu_read_lock();
+ cred = __task_cred(task);
+--
+2.16.4
+
diff --git a/patches.fixes/proc-sysctl-fix-return-error-for-proc_doulongvec_min.patch b/patches.fixes/proc-sysctl-fix-return-error-for-proc_doulongvec_min.patch
new file mode 100644
index 0000000000..45ab1411ed
--- /dev/null
+++ b/patches.fixes/proc-sysctl-fix-return-error-for-proc_doulongvec_min.patch
@@ -0,0 +1,106 @@
+From 09be178400829dddc1189b50a7888495dd26aa84 Mon Sep 17 00:00:00 2001
+From: Cheng Lin <cheng.lin130@zte.com.cn>
+Date: Thu, 3 Jan 2019 15:26:13 -0800
+Subject: [PATCH] proc/sysctl: fix return error for proc_doulongvec_minmax()
+Git-commit: 09be178400829dddc1189b50a7888495dd26aa84
+Patch-mainline: v5.0-rc1
+References: bsc#1051510
+
+If the number of input parameters is less than the total parameters, an
+EINVAL error will be returned.
+
+For example, we use proc_doulongvec_minmax to pass up to two parameters
+with kern_table:
+
+{
+ .procname = "monitor_signals",
+ .data = &monitor_sigs,
+ .maxlen = 2*sizeof(unsigned long),
+ .mode = 0644,
+ .proc_handler = proc_doulongvec_minmax,
+},
+
+Reproduce:
+
+When passing two parameters, it's work normal. But passing only one
+parameter, an error "Invalid argument"(EINVAL) is returned.
+
+ [root@cl150 ~]# echo 1 2 > /proc/sys/kernel/monitor_signals
+ [root@cl150 ~]# cat /proc/sys/kernel/monitor_signals
+ 1 2
+ [root@cl150 ~]# echo 3 > /proc/sys/kernel/monitor_signals
+ -bash: echo: write error: Invalid argument
+ [root@cl150 ~]# echo $?
+ 1
+ [root@cl150 ~]# cat /proc/sys/kernel/monitor_signals
+ 3 2
+ [root@cl150 ~]#
+
+The following is the result after apply this patch. No error is
+returned when the number of input parameters is less than the total
+parameters.
+
+ [root@cl150 ~]# echo 1 2 > /proc/sys/kernel/monitor_signals
+ [root@cl150 ~]# cat /proc/sys/kernel/monitor_signals
+ 1 2
+ [root@cl150 ~]# echo 3 > /proc/sys/kernel/monitor_signals
+ [root@cl150 ~]# echo $?
+ 0
+ [root@cl150 ~]# cat /proc/sys/kernel/monitor_signals
+ 3 2
+ [root@cl150 ~]#
+
+There are three processing functions dealing with digital parameters,
+__do_proc_dointvec/__do_proc_douintvec/__do_proc_doulongvec_minmax.
+
+This patch deals with __do_proc_doulongvec_minmax, just as
+__do_proc_dointvec does, adding a check for parameters 'left'. In
+__do_proc_douintvec, its code implementation explicitly does not support
+multiple inputs.
+
+static int __do_proc_douintvec(...){
+ ...
+ /*
+ * Arrays are not supported, keep this simple. *Do not* add
+ * support for them.
+ */
+ if (vleft != 1) {
+ *lenp = 0;
+ return -EINVAL;
+ }
+ ...
+}
+
+So, just __do_proc_doulongvec_minmax has the problem. And most use of
+proc_doulongvec_minmax/proc_doulongvec_ms_jiffies_minmax just have one
+parameter.
+
+Link: http://lkml.kernel.org/r/1544081775-15720-1-git-send-email-cheng.lin130@zte.com.cn
+Signed-off-by: Cheng Lin <cheng.lin130@zte.com.cn>
+Acked-by: Luis Chamberlain <mcgrof@kernel.org>
+Reviewed-by: Kees Cook <keescook@chromium.org>
+Cc: Alexey Dobriyan <adobriyan@gmail.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ kernel/sysctl.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/kernel/sysctl.c b/kernel/sysctl.c
+index 1825f712e73b..7f6c1a3b3485 100644
+--- a/kernel/sysctl.c
++++ b/kernel/sysctl.c
+@@ -2787,6 +2787,8 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
+ bool neg;
+
+ left -= proc_skip_spaces(&p);
++ if (!left)
++ break;
+
+ err = proc_get_long(&p, &left, &val, &neg,
+ proc_wspace_sep,
+--
+2.16.4
+
diff --git a/patches.fixes/vfio-mdev-Avoid-release-parent-reference-during-erro.patch b/patches.fixes/vfio-mdev-Avoid-release-parent-reference-during-erro.patch
new file mode 100644
index 0000000000..f66cb88c0a
--- /dev/null
+++ b/patches.fixes/vfio-mdev-Avoid-release-parent-reference-during-erro.patch
@@ -0,0 +1,40 @@
+From 60e7f2c3fe9919cee9534b422865eed49f4efb15 Mon Sep 17 00:00:00 2001
+From: Parav Pandit <parav@mellanox.com>
+Date: Tue, 30 Apr 2019 17:49:28 -0500
+Subject: [PATCH] vfio/mdev: Avoid release parent reference during error path
+Git-commit: 60e7f2c3fe9919cee9534b422865eed49f4efb15
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+During mdev parent registration in mdev_register_device(),
+if parent device is duplicate, it releases the reference of existing
+parent device.
+This is incorrect. Existing parent device should not be touched.
+
+Fixes: 7b96953bc640 ("vfio: Mediated device Core driver")
+Reviewed-by: Cornelia Huck <cohuck@redhat.com>
+Reviewed-by: Kirti Wankhede <kwankhede@nvidia.com>
+Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
+Signed-off-by: Parav Pandit <parav@mellanox.com>
+Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/vfio/mdev/mdev_core.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
+index b96fedc77ee5..1299d2e72ce2 100644
+--- a/drivers/vfio/mdev/mdev_core.c
++++ b/drivers/vfio/mdev/mdev_core.c
+@@ -181,6 +181,7 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops)
+ /* Check for duplicate */
+ parent = __find_parent_device(dev);
+ if (parent) {
++ parent = NULL;
+ ret = -EEXIST;
+ goto add_dev_err;
+ }
+--
+2.16.4
+
diff --git a/patches.fixes/vfio-mdev-Fix-aborting-mdev-child-device-removal-if-.patch b/patches.fixes/vfio-mdev-Fix-aborting-mdev-child-device-removal-if-.patch
new file mode 100644
index 0000000000..10f8724bda
--- /dev/null
+++ b/patches.fixes/vfio-mdev-Fix-aborting-mdev-child-device-removal-if-.patch
@@ -0,0 +1,77 @@
+From 6093e348a5e2475c5bb2e571346460f939998670 Mon Sep 17 00:00:00 2001
+From: Parav Pandit <parav@mellanox.com>
+Date: Tue, 30 Apr 2019 17:49:33 -0500
+Subject: [PATCH] vfio/mdev: Fix aborting mdev child device removal if one fails
+Git-commit: 6093e348a5e2475c5bb2e571346460f939998670
+Patch-mainline: v5.2-rc1
+References: bsc#1051510
+
+device_for_each_child() stops executing callback function for remaining
+child devices, if callback hits an error.
+Each child mdev device is independent of each other.
+While unregistering parent device, mdev core must remove all child mdev
+devices.
+Therefore, mdev_device_remove_cb() always returns success so that
+device_for_each_child doesn't abort if one child removal hits error.
+
+While at it, improve remove and unregister functions for below simplicity.
+
+There isn't need to pass forced flag pointer during mdev parent
+removal which invokes mdev_device_remove(). So simplify the flow.
+
+mdev_device_remove() is called from two paths.
+1. mdev_unregister_driver()
+ mdev_device_remove_cb()
+ mdev_device_remove()
+2. remove_store()
+ mdev_device_remove()
+
+Fixes: 7b96953bc640 ("vfio: Mediated device Core driver")
+Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
+Signed-off-by: Parav Pandit <parav@mellanox.com>
+Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/vfio/mdev/mdev_core.c | 10 ++++------
+ 1 file changed, 4 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
+index 836d31985f14..1a317e409355 100644
+--- a/drivers/vfio/mdev/mdev_core.c
++++ b/drivers/vfio/mdev/mdev_core.c
+@@ -149,10 +149,10 @@ static int mdev_device_remove_ops(struct mdev_device *mdev, bool force_remove)
+
+ static int mdev_device_remove_cb(struct device *dev, void *data)
+ {
+- if (!dev_is_mdev(dev))
+- return 0;
++ if (dev_is_mdev(dev))
++ mdev_device_remove(dev, true);
+
+- return mdev_device_remove(dev, data ? *(bool *)data : true);
++ return 0;
+ }
+
+ /*
+@@ -240,7 +240,6 @@ EXPORT_SYMBOL(mdev_register_device);
+ void mdev_unregister_device(struct device *dev)
+ {
+ struct mdev_parent *parent;
+- bool force_remove = true;
+
+ mutex_lock(&parent_list_lock);
+ parent = __find_parent_device(dev);
+@@ -254,8 +253,7 @@ void mdev_unregister_device(struct device *dev)
+ list_del(&parent->next);
+ class_compat_remove_link(mdev_bus_compat_class, dev, NULL);
+
+- device_for_each_child(dev, (void *)&force_remove,
+- mdev_device_remove_cb);
++ device_for_each_child(dev, NULL, mdev_device_remove_cb);
+
+ parent_remove_sysfs_files(parent);
+
+--
+2.16.4
+
diff --git a/patches.fixes/vfio-pci-use-correct-format-characters.patch b/patches.fixes/vfio-pci-use-correct-format-characters.patch
new file mode 100644
index 0000000000..5cb3f7ce88
--- /dev/null
+++ b/patches.fixes/vfio-pci-use-correct-format-characters.patch
@@ -0,0 +1,83 @@
+From 426b046b748d1f47e096e05bdcc6fb4172791307 Mon Sep 17 00:00:00 2001
+From: Louis Taylor <louis@kragniz.eu>
+Date: Wed, 3 Apr 2019 12:36:20 -0600
+Subject: [PATCH] vfio/pci: use correct format characters
+Git-commit: 426b046b748d1f47e096e05bdcc6fb4172791307
+Patch-mainline: v5.1-rc4
+References: bsc#1051510
+
+When compiling with -Wformat, clang emits the following warnings:
+
+drivers/vfio/pci/vfio_pci.c:1601:5: warning: format specifies type
+ 'unsigned short' but the argument has type 'unsigned int' [-Wformat]
+ vendor, device, subvendor, subdevice,
+ ^~~~~~
+
+drivers/vfio/pci/vfio_pci.c:1601:13: warning: format specifies type
+ 'unsigned short' but the argument has type 'unsigned int' [-Wformat]
+ vendor, device, subvendor, subdevice,
+ ^~~~~~
+
+drivers/vfio/pci/vfio_pci.c:1601:21: warning: format specifies type
+ 'unsigned short' but the argument has type 'unsigned int' [-Wformat]
+ vendor, device, subvendor, subdevice,
+ ^~~~~~~~~
+
+drivers/vfio/pci/vfio_pci.c:1601:32: warning: format specifies type
+ 'unsigned short' but the argument has type 'unsigned int' [-Wformat]
+ vendor, device, subvendor, subdevice,
+ ^~~~~~~~~
+
+drivers/vfio/pci/vfio_pci.c:1605:5: warning: format specifies type
+ 'unsigned short' but the argument has type 'unsigned int' [-Wformat]
+ vendor, device, subvendor, subdevice,
+ ^~~~~~
+
+drivers/vfio/pci/vfio_pci.c:1605:13: warning: format specifies type
+ 'unsigned short' but the argument has type 'unsigned int' [-Wformat]
+ vendor, device, subvendor, subdevice,
+ ^~~~~~
+
+drivers/vfio/pci/vfio_pci.c:1605:21: warning: format specifies type
+ 'unsigned short' but the argument has type 'unsigned int' [-Wformat]
+ vendor, device, subvendor, subdevice,
+ ^~~~~~~~~
+
+drivers/vfio/pci/vfio_pci.c:1605:32: warning: format specifies type
+ 'unsigned short' but the argument has type 'unsigned int' [-Wformat]
+ vendor, device, subvendor, subdevice,
+ ^~~~~~~~~
+The types of these arguments are unconditionally defined, so this patch
+updates the format character to the correct ones for unsigned ints.
+
+Link: https://github.com/ClangBuiltLinux/linux/issues/378
+Signed-off-by: Louis Taylor <louis@kragniz.eu>
+Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/vfio/pci/vfio_pci.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
+index a25659b5a5d1..3fa20e95a6bb 100644
+--- a/drivers/vfio/pci/vfio_pci.c
++++ b/drivers/vfio/pci/vfio_pci.c
+@@ -1661,11 +1661,11 @@ static void __init vfio_pci_fill_ids(void)
+ rc = pci_add_dynid(&vfio_pci_driver, vendor, device,
+ subvendor, subdevice, class, class_mask, 0);
+ if (rc)
+- pr_warn("failed to add dynamic id [%04hx:%04hx[%04hx:%04hx]] class %#08x/%08x (%d)\n",
++ pr_warn("failed to add dynamic id [%04x:%04x[%04x:%04x]] class %#08x/%08x (%d)\n",
+ vendor, device, subvendor, subdevice,
+ class, class_mask, rc);
+ else
+- pr_info("add [%04hx:%04hx[%04hx:%04hx]] class %#08x/%08x\n",
++ pr_info("add [%04x:%04x[%04x:%04x]] class %#08x/%08x\n",
+ vendor, device, subvendor, subdevice,
+ class, class_mask);
+ }
+--
+2.16.4
+
diff --git a/patches.fixes/vfio_pci-Enable-memory-accesses-before-calling-pci_m.patch b/patches.fixes/vfio_pci-Enable-memory-accesses-before-calling-pci_m.patch
new file mode 100644
index 0000000000..f02cf91a42
--- /dev/null
+++ b/patches.fixes/vfio_pci-Enable-memory-accesses-before-calling-pci_m.patch
@@ -0,0 +1,69 @@
+From 0cfd027be1d6def4a462cdc180c055143af24069 Mon Sep 17 00:00:00 2001
+From: Eric Auger <eric.auger@redhat.com>
+Date: Fri, 15 Feb 2019 17:16:06 +0100
+Subject: [PATCH] vfio_pci: Enable memory accesses before calling pci_map_rom
+Git-commit: 0cfd027be1d6def4a462cdc180c055143af24069
+Patch-mainline: v5.1-rc1
+References: bsc#1051510
+
+pci_map_rom/pci_get_rom_size() performs memory access in the ROM.
+In case the Memory Space accesses were disabled, readw() is likely
+to trigger a synchronous external abort on some platforms.
+
+In case memory accesses were disabled, re-enable them before the
+call and disable them back again just after.
+
+Fixes: 89e1f7d4c66d ("vfio: Add PCI device driver")
+Signed-off-by: Eric Auger <eric.auger@redhat.com>
+Suggested-by: Alex Williamson <alex.williamson@redhat.com>
+Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/vfio/pci/vfio_pci.c | 19 ++++++++++++++-----
+ 1 file changed, 14 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
+index 84b593b9fb1f..a25659b5a5d1 100644
+--- a/drivers/vfio/pci/vfio_pci.c
++++ b/drivers/vfio/pci/vfio_pci.c
+@@ -759,6 +759,7 @@ static long vfio_pci_ioctl(void *device_data,
+ {
+ void __iomem *io;
+ size_t size;
++ u16 orig_cmd;
+
+ info.offset = VFIO_PCI_INDEX_TO_OFFSET(info.index);
+ info.flags = 0;
+@@ -774,15 +775,23 @@ static long vfio_pci_ioctl(void *device_data,
+ break;
+ }
+
+- /* Is it really there? */
++ /*
++ * Is it really there? Enable memory decode for
++ * implicit access in pci_map_rom().
++ */
++ pci_read_config_word(pdev, PCI_COMMAND, &orig_cmd);
++ pci_write_config_word(pdev, PCI_COMMAND,
++ orig_cmd | PCI_COMMAND_MEMORY);
++
+ io = pci_map_rom(pdev, &size);
+- if (!io || !size) {
++ if (io) {
++ info.flags = VFIO_REGION_INFO_FLAG_READ;
++ pci_unmap_rom(pdev, io);
++ } else {
+ info.size = 0;
+- break;
+ }
+- pci_unmap_rom(pdev, io);
+
+- info.flags = VFIO_REGION_INFO_FLAG_READ;
++ pci_write_config_word(pdev, PCI_COMMAND, orig_cmd);
+ break;
+ }
+ case VFIO_PCI_VGA_REGION_INDEX:
+--
+2.16.4
+
diff --git a/patches.fixes/vhost-vsock-fix-reset-orphans-race-with-close-timeou.patch b/patches.fixes/vhost-vsock-fix-reset-orphans-race-with-close-timeou.patch
new file mode 100644
index 0000000000..d2044723dd
--- /dev/null
+++ b/patches.fixes/vhost-vsock-fix-reset-orphans-race-with-close-timeou.patch
@@ -0,0 +1,65 @@
+From c38f57da428b033f2721b611d84b1f40bde674a8 Mon Sep 17 00:00:00 2001
+From: Stefan Hajnoczi <stefanha@redhat.com>
+Date: Thu, 6 Dec 2018 19:14:34 +0000
+Subject: [PATCH] vhost/vsock: fix reset orphans race with close timeout
+Git-commit: c38f57da428b033f2721b611d84b1f40bde674a8
+Patch-mainline: v4.20-rc6
+References: bsc#1051510
+
+If a local process has closed a connected socket and hasn't received a
+RST packet yet, then the socket remains in the table until a timeout
+expires.
+
+When a vhost_vsock instance is released with the timeout still pending,
+the socket is never freed because vhost_vsock has already set the
+SOCK_DONE flag.
+
+Check if the close timer is pending and let it close the socket. This
+prevents the race which can leak sockets.
+
+Reported-by: Maximilian Riemensberger <riemensberger@cadami.net>
+Cc: Graham Whaley <graham.whaley@gmail.com>
+Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/vhost/vsock.c | 22 +++++++++++++++-------
+ 1 file changed, 15 insertions(+), 7 deletions(-)
+
+diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c
+index 34bc3ab40c6d..731e2ea2aeca 100644
+--- a/drivers/vhost/vsock.c
++++ b/drivers/vhost/vsock.c
+@@ -563,13 +563,21 @@ static void vhost_vsock_reset_orphans(struct sock *sk)
+ * executing.
+ */
+
+- if (!vhost_vsock_get(vsk->remote_addr.svm_cid)) {
+- sock_set_flag(sk, SOCK_DONE);
+- vsk->peer_shutdown = SHUTDOWN_MASK;
+- sk->sk_state = SS_UNCONNECTED;
+- sk->sk_err = ECONNRESET;
+- sk->sk_error_report(sk);
+- }
++ /* If the peer is still valid, no need to reset connection */
++ if (vhost_vsock_get(vsk->remote_addr.svm_cid))
++ return;
++
++ /* If the close timeout is pending, let it expire. This avoids races
++ * with the timeout callback.
++ */
++ if (vsk->close_work_scheduled)
++ return;
++
++ sock_set_flag(sk, SOCK_DONE);
++ vsk->peer_shutdown = SHUTDOWN_MASK;
++ sk->sk_state = SS_UNCONNECTED;
++ sk->sk_err = ECONNRESET;
++ sk->sk_error_report(sk);
+ }
+
+ static int vhost_vsock_dev_release(struct inode *inode, struct file *file)
+--
+2.16.4
+
diff --git a/patches.fixes/virtio-Honour-may_reduce_num-in-vring_create_virtque.patch b/patches.fixes/virtio-Honour-may_reduce_num-in-vring_create_virtque.patch
new file mode 100644
index 0000000000..66063e9369
--- /dev/null
+++ b/patches.fixes/virtio-Honour-may_reduce_num-in-vring_create_virtque.patch
@@ -0,0 +1,66 @@
+From cf94db21905333e610e479688add629397a4b384 Mon Sep 17 00:00:00 2001
+From: Cornelia Huck <cohuck@redhat.com>
+Date: Mon, 8 Apr 2019 14:33:22 +0200
+Subject: [PATCH] virtio: Honour 'may_reduce_num' in vring_create_virtqueue
+Git-commit: cf94db21905333e610e479688add629397a4b384
+Patch-mainline: v5.1-rc5
+References: bsc#1051510
+
+vring_create_virtqueue() allows the caller to specify via the
+may_reduce_num parameter whether the vring code is allowed to
+allocate a smaller ring than specified.
+
+However, the split ring allocation code tries to allocate a
+smaller ring on allocation failure regardless of what the
+caller specified. This may cause trouble for e.g. virtio-pci
+in legacy mode, which does not support ring resizing. (The
+packed ring code does not resize in any case.)
+
+Let's fix this by bailing out immediately in the split ring code
+if the requested size cannot be allocated and may_reduce_num has
+not been specified.
+
+While at it, fix a typo in the usage instructions.
+
+Fixes: 2a2d1382fe9d ("virtio: Add improved queue allocation API")
+Cc: stable@vger.kernel.org # v4.6+
+Signed-off-by: Cornelia Huck <cohuck@redhat.com>
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
+Reviewed-by: Jens Freimann <jfreimann@redhat.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/virtio/virtio_ring.c | 2 ++
+ include/linux/virtio_ring.h | 2 +-
+ 2 files changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
+index 18846afb39da..5df92c308286 100644
+--- a/drivers/virtio/virtio_ring.c
++++ b/drivers/virtio/virtio_ring.c
+@@ -882,6 +882,8 @@ static struct virtqueue *vring_create_virtqueue_split(
+ GFP_KERNEL|__GFP_NOWARN|__GFP_ZERO);
+ if (queue)
+ break;
++ if (!may_reduce_num)
++ return NULL;
+ }
+
+ if (!num)
+diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
+index fab02133a919..3dc70adfe5f5 100644
+--- a/include/linux/virtio_ring.h
++++ b/include/linux/virtio_ring.h
+@@ -63,7 +63,7 @@ struct virtqueue;
+ /*
+ * Creates a virtqueue and allocates the descriptor ring. If
+ * may_reduce_num is set, then this may allocate a smaller ring than
+- * expected. The caller should query virtqueue_get_ring_size to learn
++ * expected. The caller should query virtqueue_get_vring_size to learn
+ * the actual size of the ring.
+ */
+ struct virtqueue *vring_create_virtqueue(unsigned int index,
+--
+2.16.4
+
diff --git a/patches.fixes/virtio-blk-limit-number-of-hw-queues-by-nr_cpu_ids.patch b/patches.fixes/virtio-blk-limit-number-of-hw-queues-by-nr_cpu_ids.patch
new file mode 100644
index 0000000000..0cce08e17f
--- /dev/null
+++ b/patches.fixes/virtio-blk-limit-number-of-hw-queues-by-nr_cpu_ids.patch
@@ -0,0 +1,46 @@
+From bf348f9b78d413e75bb079462751a1d86b6de36c Mon Sep 17 00:00:00 2001
+From: Dongli Zhang <dongli.zhang@oracle.com>
+Date: Wed, 27 Mar 2019 18:36:34 +0800
+Subject: [PATCH] virtio-blk: limit number of hw queues by nr_cpu_ids
+Git-commit: bf348f9b78d413e75bb079462751a1d86b6de36c
+Patch-mainline: v5.1-rc5
+References: bsc#1051510
+
+When tag_set->nr_maps is 1, the block layer limits the number of hw queues
+by nr_cpu_ids. No matter how many hw queues are used by virtio-blk, as it
+has (tag_set->nr_maps == 1), it can use at most nr_cpu_ids hw queues.
+
+In addition, specifically for pci scenario, when the 'num-queues' specified
+by qemu is more than maxcpus, virtio-blk would not be able to allocate more
+than maxcpus vectors in order to have a vector for each queue. As a result,
+it falls back into MSI-X with one vector for config and one shared for
+queues.
+
+Considering above reasons, this patch limits the number of hw queues used
+by virtio-blk by nr_cpu_ids.
+
+Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
+Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/block/virtio_blk.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
+index 4bc083b7c9b5..2a7ca4a1e6f7 100644
+--- a/drivers/block/virtio_blk.c
++++ b/drivers/block/virtio_blk.c
+@@ -513,6 +513,8 @@ static int init_vq(struct virtio_blk *vblk)
+ if (err)
+ num_vqs = 1;
+
++ num_vqs = min_t(unsigned int, nr_cpu_ids, num_vqs);
++
+ vblk->vqs = kmalloc_array(num_vqs, sizeof(*vblk->vqs), GFP_KERNEL);
+ if (!vblk->vqs)
+ return -ENOMEM;
+--
+2.16.4
+
diff --git a/patches.fixes/virtio_pci-fix-a-NULL-pointer-reference-in-vp_del_vq.patch b/patches.fixes/virtio_pci-fix-a-NULL-pointer-reference-in-vp_del_vq.patch
new file mode 100644
index 0000000000..ce22aa40e9
--- /dev/null
+++ b/patches.fixes/virtio_pci-fix-a-NULL-pointer-reference-in-vp_del_vq.patch
@@ -0,0 +1,70 @@
+From 6a8aae68c87349dbbcd46eac380bc43cdb98a13b Mon Sep 17 00:00:00 2001
+From: Longpeng <longpeng2@huawei.com>
+Date: Sat, 9 Mar 2019 15:17:40 +0800
+Subject: [PATCH] virtio_pci: fix a NULL pointer reference in vp_del_vqs
+Git-commit: 6a8aae68c87349dbbcd46eac380bc43cdb98a13b
+Patch-mainline: v5.1-rc5
+References: bsc#1051510
+
+If the msix_affinity_masks is alloced failed, then we'll
+try to free some resources in vp_free_vectors() that may
+access it directly.
+
+We met the following stack in our production:
+[ 29.296767] BUG: unable to handle kernel NULL pointer dereference at (null)
+[ 29.311151] IP: [<ffffffffc04fe35a>] vp_free_vectors+0x6a/0x150 [virtio_pci]
+[ 29.324787] PGD 0
+[ 29.333224] Oops: 0000 [#1] SMP
+[...]
+[ 29.425175] RIP: 0010:[<ffffffffc04fe35a>] [<ffffffffc04fe35a>] vp_free_vectors+0x6a/0x150 [virtio_pci]
+[ 29.441405] RSP: 0018:ffff9a55c2dcfa10 EFLAGS: 00010206
+[ 29.453491] RAX: 0000000000000000 RBX: ffff9a55c322c400 RCX: 0000000000000000
+[ 29.467488] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff9a55c322c400
+[ 29.481461] RBP: ffff9a55c2dcfa20 R08: 0000000000000000 R09: ffffc1b6806ff020
+[ 29.495427] R10: 0000000000000e95 R11: 0000000000aaaaaa R12: 0000000000000000
+[ 29.509414] R13: 0000000000010000 R14: ffff9a55bd2d9e98 R15: ffff9a55c322c400
+[ 29.523407] FS: 00007fdcba69f8c0(0000) GS:ffff9a55c2840000(0000) knlGS:0000000000000000
+[ 29.538472] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
+[ 29.551621] CR2: 0000000000000000 CR3: 000000003ce52000 CR4: 00000000003607a0
+[ 29.565886] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
+[ 29.580055] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
+[ 29.594122] Call Trace:
+[ 29.603446] [<ffffffffc04fe8a2>] vp_request_msix_vectors+0xe2/0x260 [virtio_pci]
+[ 29.618017] [<ffffffffc04fedc5>] vp_try_to_find_vqs+0x95/0x3b0 [virtio_pci]
+[ 29.632152] [<ffffffffc04ff117>] vp_find_vqs+0x37/0xb0 [virtio_pci]
+[ 29.645582] [<ffffffffc057bf63>] init_vq+0x153/0x260 [virtio_blk]
+[ 29.658831] [<ffffffffc057c1e8>] virtblk_probe+0xe8/0x87f [virtio_blk]
+[...]
+
+Cc: Gonglei <arei.gonglei@huawei.com>
+Signed-off-by: Longpeng <longpeng2@huawei.com>
+Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
+Reviewed-by: Gonglei <arei.gonglei@huawei.com>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/virtio/virtio_pci_common.c | 8 +++++---
+ 1 file changed, 5 insertions(+), 3 deletions(-)
+
+diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
+index d0584c040c60..7a0398bb84f7 100644
+--- a/drivers/virtio/virtio_pci_common.c
++++ b/drivers/virtio/virtio_pci_common.c
+@@ -255,9 +255,11 @@ void vp_del_vqs(struct virtio_device *vdev)
+ for (i = 0; i < vp_dev->msix_used_vectors; ++i)
+ free_irq(pci_irq_vector(vp_dev->pci_dev, i), vp_dev);
+
+- for (i = 0; i < vp_dev->msix_vectors; i++)
+- if (vp_dev->msix_affinity_masks[i])
+- free_cpumask_var(vp_dev->msix_affinity_masks[i]);
++ if (vp_dev->msix_affinity_masks) {
++ for (i = 0; i < vp_dev->msix_vectors; i++)
++ if (vp_dev->msix_affinity_masks[i])
++ free_cpumask_var(vp_dev->msix_affinity_masks[i]);
++ }
+
+ if (vp_dev->msix_enabled) {
+ /* Disable the vector used for configuration */
+--
+2.16.4
+
diff --git a/patches.fixes/vsock-virtio-fix-kernel-panic-after-device-hot-unplu.patch b/patches.fixes/vsock-virtio-fix-kernel-panic-after-device-hot-unplu.patch
new file mode 100644
index 0000000000..b6fe226c01
--- /dev/null
+++ b/patches.fixes/vsock-virtio-fix-kernel-panic-after-device-hot-unplu.patch
@@ -0,0 +1,103 @@
+From 22b5c0b63f32568e130fa2df4ba23efce3eb495b Mon Sep 17 00:00:00 2001
+From: Stefano Garzarella <sgarzare@redhat.com>
+Date: Fri, 1 Feb 2019 12:42:06 +0100
+Subject: [PATCH] vsock/virtio: fix kernel panic after device hot-unplug
+Git-commit: 22b5c0b63f32568e130fa2df4ba23efce3eb495b
+Patch-mainline: v5.0-rc6
+References: bsc#1051510
+
+virtio_vsock_remove() invokes the vsock_core_exit() also if there
+are opened sockets for the AF_VSOCK protocol family. In this way
+the vsock "transport" pointer is set to NULL, triggering the
+kernel panic at the first socket activity.
+
+This patch move the vsock_core_init()/vsock_core_exit() in the
+virtio_vsock respectively in module_init and module_exit functions,
+that cannot be invoked until there are open sockets.
+
+Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1609699
+Reported-by: Yan Fu <yafu@redhat.com>
+Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
+Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ net/vmw_vsock/virtio_transport.c | 26 ++++++++++++++++++--------
+ 1 file changed, 18 insertions(+), 8 deletions(-)
+
+diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
+index 5d3cce9e8744..9dae54698737 100644
+--- a/net/vmw_vsock/virtio_transport.c
++++ b/net/vmw_vsock/virtio_transport.c
+@@ -75,6 +75,9 @@ static u32 virtio_transport_get_local_cid(void)
+ {
+ struct virtio_vsock *vsock = virtio_vsock_get();
+
++ if (!vsock)
++ return VMADDR_CID_ANY;
++
+ return vsock->guest_cid;
+ }
+
+@@ -584,10 +587,6 @@ static int virtio_vsock_probe(struct virtio_device *vdev)
+
+ virtio_vsock_update_guest_cid(vsock);
+
+- ret = vsock_core_init(&virtio_transport.transport);
+- if (ret < 0)
+- goto out_vqs;
+-
+ vsock->rx_buf_nr = 0;
+ vsock->rx_buf_max_nr = 0;
+ atomic_set(&vsock->queued_replies, 0);
+@@ -618,8 +617,6 @@ static int virtio_vsock_probe(struct virtio_device *vdev)
+ mutex_unlock(&the_virtio_vsock_mutex);
+ return 0;
+
+-out_vqs:
+- vsock->vdev->config->del_vqs(vsock->vdev);
+ out:
+ kfree(vsock);
+ mutex_unlock(&the_virtio_vsock_mutex);
+@@ -669,7 +666,6 @@ static void virtio_vsock_remove(struct virtio_device *vdev)
+
+ mutex_lock(&the_virtio_vsock_mutex);
+ the_virtio_vsock = NULL;
+- vsock_core_exit();
+ mutex_unlock(&the_virtio_vsock_mutex);
+
+ vdev->config->del_vqs(vdev);
+@@ -702,14 +698,28 @@ static int __init virtio_vsock_init(void)
+ virtio_vsock_workqueue = alloc_workqueue("virtio_vsock", 0, 0);
+ if (!virtio_vsock_workqueue)
+ return -ENOMEM;
++
+ ret = register_virtio_driver(&virtio_vsock_driver);
+ if (ret)
+- destroy_workqueue(virtio_vsock_workqueue);
++ goto out_wq;
++
++ ret = vsock_core_init(&virtio_transport.transport);
++ if (ret)
++ goto out_vdr;
++
++ return 0;
++
++out_vdr:
++ unregister_virtio_driver(&virtio_vsock_driver);
++out_wq:
++ destroy_workqueue(virtio_vsock_workqueue);
+ return ret;
++
+ }
+
+ static void __exit virtio_vsock_exit(void)
+ {
++ vsock_core_exit();
+ unregister_virtio_driver(&virtio_vsock_driver);
+ destroy_workqueue(virtio_vsock_workqueue);
+ }
+--
+2.16.4
+
diff --git a/patches.fixes/vsock-virtio-fix-kernel-panic-from-virtio_transport_.patch b/patches.fixes/vsock-virtio-fix-kernel-panic-from-virtio_transport_.patch
new file mode 100644
index 0000000000..c7fa6c3fb5
--- /dev/null
+++ b/patches.fixes/vsock-virtio-fix-kernel-panic-from-virtio_transport_.patch
@@ -0,0 +1,109 @@
+From 4c404ce23358d5d8fbdeb7a6021a9b33d3c3c167 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Adalbert=20Laz=C4=83r?= <alazar@bitdefender.com>
+Date: Wed, 6 Mar 2019 12:13:53 +0200
+Subject: [PATCH] vsock/virtio: fix kernel panic from virtio_transport_reset_no_sock
+Mime-version: 1.0
+Content-type: text/plain; charset=UTF-8
+Content-transfer-encoding: 8bit
+Git-commit: 4c404ce23358d5d8fbdeb7a6021a9b33d3c3c167
+Patch-mainline: v5.1-rc1
+References: bsc#1051510
+
+Previous to commit 22b5c0b63f32 ("vsock/virtio: fix kernel panic
+after device hot-unplug"), vsock_core_init() was called from
+virtio_vsock_probe(). Now, virtio_transport_reset_no_sock() can be called
+before vsock_core_init() has the chance to run.
+
+[Wed Feb 27 14:17:09 2019] BUG: unable to handle kernel NULL pointer dereference at 0000000000000110
+[Wed Feb 27 14:17:09 2019] #PF error: [normal kernel read fault]
+[Wed Feb 27 14:17:09 2019] PGD 0 P4D 0
+[Wed Feb 27 14:17:09 2019] Oops: 0000 [#1] SMP PTI
+[Wed Feb 27 14:17:09 2019] CPU: 3 PID: 59 Comm: kworker/3:1 Not tainted 5.0.0-rc7-390-generic-hvi #390
+[Wed Feb 27 14:17:09 2019] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
+[Wed Feb 27 14:17:09 2019] Workqueue: virtio_vsock virtio_transport_rx_work [vmw_vsock_virtio_transport]
+[Wed Feb 27 14:17:09 2019] RIP: 0010:virtio_transport_reset_no_sock+0x8c/0xc0 [vmw_vsock_virtio_transport_common]
+[Wed Feb 27 14:17:09 2019] Code: 35 8b 4f 14 48 8b 57 08 31 f6 44 8b 4f 10 44 8b 07 48 8d 7d c8 e8 84 f8 ff ff 48 85 c0 48 89 c3 74 2a e8 f7 31 03 00 48 89 df <48> 8b 80 10 01 00 00 e8 68 fb 69 ed 48 8b 75 f0 65 48 33 34 25 28
+[Wed Feb 27 14:17:09 2019] RSP: 0018:ffffb42701ab7d40 EFLAGS: 00010282
+[Wed Feb 27 14:17:09 2019] RAX: 0000000000000000 RBX: ffff9d79637ee080 RCX: 0000000000000003
+[Wed Feb 27 14:17:09 2019] RDX: 0000000000000001 RSI: 0000000000000002 RDI: ffff9d79637ee080
+[Wed Feb 27 14:17:09 2019] RBP: ffffb42701ab7d78 R08: ffff9d796fae70e0 R09: ffff9d796f403500
+[Wed Feb 27 14:17:09 2019] R10: ffffb42701ab7d90 R11: 0000000000000000 R12: ffff9d7969d09240
+[Wed Feb 27 14:17:09 2019] R13: ffff9d79624e6840 R14: ffff9d7969d09318 R15: ffff9d796d48ff80
+[Wed Feb 27 14:17:09 2019] FS: 0000000000000000(0000) GS:ffff9d796fac0000(0000) knlGS:0000000000000000
+[Wed Feb 27 14:17:09 2019] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
+[Wed Feb 27 14:17:09 2019] CR2: 0000000000000110 CR3: 0000000427f22000 CR4: 00000000000006e0
+[Wed Feb 27 14:17:09 2019] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
+[Wed Feb 27 14:17:09 2019] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
+[Wed Feb 27 14:17:09 2019] Call Trace:
+[Wed Feb 27 14:17:09 2019] virtio_transport_recv_pkt+0x63/0x820 [vmw_vsock_virtio_transport_common]
+[Wed Feb 27 14:17:09 2019] ? kfree+0x17e/0x190
+[Wed Feb 27 14:17:09 2019] ? detach_buf_split+0x145/0x160
+[Wed Feb 27 14:17:09 2019] ? __switch_to_asm+0x40/0x70
+[Wed Feb 27 14:17:09 2019] virtio_transport_rx_work+0xa0/0x106 [vmw_vsock_virtio_transport]
+[Wed Feb 27 14:17:09 2019] NET: Registered protocol family 40
+[Wed Feb 27 14:17:09 2019] process_one_work+0x167/0x410
+[Wed Feb 27 14:17:09 2019] worker_thread+0x4d/0x460
+[Wed Feb 27 14:17:09 2019] kthread+0x105/0x140
+[Wed Feb 27 14:17:09 2019] ? rescuer_thread+0x360/0x360
+[Wed Feb 27 14:17:09 2019] ? kthread_destroy_worker+0x50/0x50
+[Wed Feb 27 14:17:09 2019] ret_from_fork+0x35/0x40
+[Wed Feb 27 14:17:09 2019] Modules linked in: vmw_vsock_virtio_transport vmw_vsock_virtio_transport_common input_leds vsock serio_raw i2c_piix4 mac_hid qemu_fw_cfg autofs4 cirrus ttm drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops virtio_net psmouse drm net_failover pata_acpi virtio_blk failover floppy
+
+Fixes: 22b5c0b63f32 ("vsock/virtio: fix kernel panic after device hot-unplug")
+Reported-by: Alexandru Herghelegiu <aherghelegiu@bitdefender.com>
+Signed-off-by: Adalbert Lazăr <alazar@bitdefender.com>
+Co-developed-by: Stefan Hajnoczi <stefanha@redhat.com>
+Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
+Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ net/vmw_vsock/virtio_transport_common.c | 22 +++++++++++++++-------
+ 1 file changed, 15 insertions(+), 7 deletions(-)
+
+diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
+index 3ae3a33da70b..602715fc9a75 100644
+--- a/net/vmw_vsock/virtio_transport_common.c
++++ b/net/vmw_vsock/virtio_transport_common.c
+@@ -662,6 +662,8 @@ static int virtio_transport_reset(struct vsock_sock *vsk,
+ */
+ static int virtio_transport_reset_no_sock(struct virtio_vsock_pkt *pkt)
+ {
++ const struct virtio_transport *t;
++ struct virtio_vsock_pkt *reply;
+ struct virtio_vsock_pkt_info info = {
+ .op = VIRTIO_VSOCK_OP_RST,
+ .type = le16_to_cpu(pkt->hdr.type),
+@@ -672,15 +674,21 @@ static int virtio_transport_reset_no_sock(struct virtio_vsock_pkt *pkt)
+ if (le16_to_cpu(pkt->hdr.op) == VIRTIO_VSOCK_OP_RST)
+ return 0;
+
+- pkt = virtio_transport_alloc_pkt(&info, 0,
+- le64_to_cpu(pkt->hdr.dst_cid),
+- le32_to_cpu(pkt->hdr.dst_port),
+- le64_to_cpu(pkt->hdr.src_cid),
+- le32_to_cpu(pkt->hdr.src_port));
+- if (!pkt)
++ reply = virtio_transport_alloc_pkt(&info, 0,
++ le64_to_cpu(pkt->hdr.dst_cid),
++ le32_to_cpu(pkt->hdr.dst_port),
++ le64_to_cpu(pkt->hdr.src_cid),
++ le32_to_cpu(pkt->hdr.src_port));
++ if (!reply)
+ return -ENOMEM;
+
+- return virtio_transport_get_ops()->send_pkt(pkt);
++ t = virtio_transport_get_ops();
++ if (!t) {
++ virtio_transport_free_pkt(reply);
++ return -ENOTCONN;
++ }
++
++ return t->send_pkt(reply);
+ }
+
+ static void virtio_transport_wait_close(struct sock *sk, long timeout)
+--
+2.16.4
+
diff --git a/patches.fixes/vsock-virtio-reset-connected-sockets-on-device-remov.patch b/patches.fixes/vsock-virtio-reset-connected-sockets-on-device-remov.patch
new file mode 100644
index 0000000000..13a23d699f
--- /dev/null
+++ b/patches.fixes/vsock-virtio-reset-connected-sockets-on-device-remov.patch
@@ -0,0 +1,37 @@
+From 85965487abc540368393a15491e6e7fcd230039d Mon Sep 17 00:00:00 2001
+From: Stefano Garzarella <sgarzare@redhat.com>
+Date: Fri, 1 Feb 2019 12:42:07 +0100
+Subject: [PATCH] vsock/virtio: reset connected sockets on device removal
+Git-commit: 85965487abc540368393a15491e6e7fcd230039d
+Patch-mainline: v5.0-rc6
+References: bsc#1051510
+
+When the virtio transport device disappear, we should reset all
+connected sockets in order to inform the users.
+
+Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
+Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ net/vmw_vsock/virtio_transport.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
+index 9dae54698737..15eb5d3d4750 100644
+--- a/net/vmw_vsock/virtio_transport.c
++++ b/net/vmw_vsock/virtio_transport.c
+@@ -634,6 +634,9 @@ static void virtio_vsock_remove(struct virtio_device *vdev)
+ flush_work(&vsock->event_work);
+ flush_work(&vsock->send_pkt_work);
+
++ /* Reset all connected sockets when the device disappear */
++ vsock_for_each_connected_socket(virtio_vsock_reset_sock);
++
+ vdev->config->reset(vdev);
+
+ mutex_lock(&vsock->rx_lock);
+--
+2.16.4
+
diff --git a/patches.kabi/Re-export-snd_cards-for-kABI.patch b/patches.kabi/Re-export-snd_cards-for-kABI.patch
new file mode 100644
index 0000000000..0fd3b42980
--- /dev/null
+++ b/patches.kabi/Re-export-snd_cards-for-kABI.patch
@@ -0,0 +1,26 @@
+From: Takashi Iwai <tiwai@suse.de>
+Subject: Re-export snd_cards for kABI compatibility
+Patch-mainline: Never, kABI compatibility
+References: bsc#1051510
+
+Re-export snd_cards object only for kABI compatibility with SLE15.
+It's not declared in the header.
+
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ sound/core/init.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/sound/core/init.c
++++ b/sound/core/init.c
+@@ -49,7 +49,8 @@ static const struct file_operations snd_
+
+ /* locked for registering/using */
+ static DECLARE_BITMAP(snd_cards_lock, SNDRV_CARDS);
+-static struct snd_card *snd_cards[SNDRV_CARDS];
++struct snd_card *snd_cards[SNDRV_CARDS];
++EXPORT_SYMBOL(snd_cards); /* XXX exported only for SLE15 kABI compatibility */
+
+ static DEFINE_MUTEX(snd_card_mutex);
+
diff --git a/patches.kabi/snd_seq_kernel_client_enqueue-kabi-compat.patch b/patches.kabi/snd_seq_kernel_client_enqueue-kabi-compat.patch
new file mode 100644
index 0000000000..22d8af8e48
--- /dev/null
+++ b/patches.kabi/snd_seq_kernel_client_enqueue-kabi-compat.patch
@@ -0,0 +1,50 @@
+From: Takashi Iwai <tiwai@suse.de>
+Subject: kABI workaround for snd_seq_kernel_client_enqueue() API changes
+Patch-mainline: Never, ugly kABI workaround
+References: bsc#1051510
+
+The snd_seq_kernel_client_enqueue() API function was changed to take
+fewer arguments. Rename it and provide the old API functions to keep
+the kABI compatibility with SLE15.
+
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ include/sound/seq_kernel.h | 2 ++
+ sound/core/seq/seq_clientmgr.c | 17 +++++++++++++++++
+ 2 files changed, 19 insertions(+)
+
+--- a/include/sound/seq_kernel.h
++++ b/include/sound/seq_kernel.h
+@@ -73,6 +73,8 @@ __printf(3, 4)
+ int snd_seq_create_kernel_client(struct snd_card *card, int client_index,
+ const char *name_fmt, ...);
+ int snd_seq_delete_kernel_client(int client);
++/* XXX kABI compatibility for SLE15 XXX */
++#define snd_seq_kernel_client_enqueue __snd_seq_kernel_client_enqueue
+ int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev,
+ struct file *file, bool blocking);
+ int snd_seq_kernel_client_dispatch(int client, struct snd_seq_event *ev, int atomic, int hop);
+--- a/sound/core/seq/seq_clientmgr.c
++++ b/sound/core/seq/seq_clientmgr.c
+@@ -2557,3 +2557,20 @@ void __exit snd_sequencer_device_done(vo
+ snd_unregister_device(&seq_dev);
+ put_device(&seq_dev);
+ }
++
++/* XXX kABI compatibility for SLE15 XXX */
++#undef snd_seq_kernel_client_enqueue
++int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev,
++ int atomic, int hop)
++{
++ return __snd_seq_kernel_client_enqueue(client, ev, NULL, false);
++}
++EXPORT_SYMBOL(snd_seq_kernel_client_enqueue);
++
++int snd_seq_kernel_client_enqueue_blocking(int client, struct snd_seq_event *ev,
++ struct file *file, int atomic,
++ int hop)
++{
++ return __snd_seq_kernel_client_enqueue(client, ev, file, true);
++}
++EXPORT_SYMBOL(snd_seq_kernel_client_enqueue_blocking);
diff --git a/patches.suse/0001-btrfs-Factor-out-common-delayed-refs-init-code.patch b/patches.suse/0001-btrfs-Factor-out-common-delayed-refs-init-code.patch
new file mode 100644
index 0000000000..7683027899
--- /dev/null
+++ b/patches.suse/0001-btrfs-Factor-out-common-delayed-refs-init-code.patch
@@ -0,0 +1,85 @@
+From cb49a87b2a4edb469e4d295eca4b1d106f64083e Mon Sep 17 00:00:00 2001
+From: Nikolay Borisov <nborisov@suse.com>
+Date: Tue, 24 Apr 2018 17:18:17 +0300
+Git-commit: cb49a87b2a4edb469e4d295eca4b1d106f64083e
+Patch-mainline: v4.18
+References: bsc#1134813
+Subject: [PATCH 1/8] btrfs: Factor out common delayed refs init code
+
+THe majority of the init code for struct btrfs_delayed_ref_node is
+duplicated in add_delayed_data_ref and add_delayed_tree_ref. Factor out
+the common bits in init_delayed_ref_common. This function is going to be
+used in future patches to clean that up. No functional changes.
+
+Signed-off-by: Nikolay Borisov <nborisov@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/delayed-ref.c | 51 ++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 51 insertions(+)
+
+diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
+index 4fb041e14742..a0dc255792c7 100644
+--- a/fs/btrfs/delayed-ref.c
++++ b/fs/btrfs/delayed-ref.c
+@@ -644,6 +644,57 @@ add_delayed_ref_head(struct btrfs_trans_handle *trans,
+ return head_ref;
+ }
+
++/*
++ * init_delayed_ref_common - Initialize the structure which represents a
++ * modification to a an extent.
++ *
++ * @fs_info: Internal to the mounted filesystem mount structure.
++ *
++ * @ref: The structure which is going to be initialized.
++ *
++ * @bytenr: The logical address of the extent for which a modification is
++ * going to be recorded.
++ *
++ * @num_bytes: Size of the extent whose modification is being recorded.
++ *
++ * @ref_root: The id of the root where this modification has originated, this
++ * can be either one of the well-known metadata trees or the
++ * subvolume id which references this extent.
++ *
++ * @action: Can be one of BTRFS_ADD_DELAYED_REF/BTRFS_DROP_DELAYED_REF or
++ * BTRFS_ADD_DELAYED_EXTENT
++ *
++ * @ref_type: Holds the type of the extent which is being recorded, can be
++ * one of BTRFS_SHARED_BLOCK_REF_KEY/BTRFS_TREE_BLOCK_REF_KEY
++ * when recording a metadata extent or BTRFS_SHARED_DATA_REF_KEY/
++ * BTRFS_EXTENT_DATA_REF_KEY when recording data extent
++ */
++static void init_delayed_ref_common(struct btrfs_fs_info *fs_info,
++ struct btrfs_delayed_ref_node *ref,
++ u64 bytenr, u64 num_bytes, u64 ref_root,
++ int action, u8 ref_type)
++{
++ u64 seq = 0;
++
++ if (action == BTRFS_ADD_DELAYED_EXTENT)
++ action = BTRFS_ADD_DELAYED_REF;
++
++ if (is_fstree(ref_root))
++ seq = atomic64_read(&fs_info->tree_mod_seq);
++
++ refcount_set(&ref->refs, 1);
++ ref->bytenr = bytenr;
++ ref->num_bytes = num_bytes;
++ ref->ref_mod = 1;
++ ref->action = action;
++ ref->is_head = 0;
++ ref->in_tree = 1;
++ ref->seq = seq;
++ ref->type = ref_type;
++ RB_CLEAR_NODE(&ref->ref_node);
++ INIT_LIST_HEAD(&ref->add_list);
++}
++
+ /*
+ * helper to insert a delayed tree ref into the rbtree.
+ */
+--
+2.21.0
+
diff --git a/patches.suse/0001-btrfs-add-a-helper-to-return-a-head-ref.patch b/patches.suse/0001-btrfs-add-a-helper-to-return-a-head-ref.patch
new file mode 100644
index 0000000000..90af0de646
--- /dev/null
+++ b/patches.suse/0001-btrfs-add-a-helper-to-return-a-head-ref.patch
@@ -0,0 +1,86 @@
+From 2eadaa22c17ac3c546850f70d9d20fa19459dbce Mon Sep 17 00:00:00 2001
+From: Josef Bacik <josef@toxicpanda.com>
+Date: Fri, 29 Sep 2017 15:43:52 -0400
+Git-commit: 2eadaa22c17ac3c546850f70d9d20fa19459dbce
+Patch-mainline: 4.15
+References: bsc#1134813
+Subject: [PATCH 1/7] btrfs: add a helper to return a head ref
+
+Simplify the error handling in __btrfs_run_delayed_refs by breaking out
+the code used to return a head back to the delayed_refs tree for
+processing into a helper function.
+
+Signed-off-by: Josef Bacik <jbacik@fb.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/extent-tree.c | 29 ++++++++++++++---------------
+ 1 file changed, 14 insertions(+), 15 deletions(-)
+
+diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
+index 52d246994341..3e4a6a4b0505 100644
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -2575,6 +2575,16 @@ select_delayed_ref(struct btrfs_delayed_ref_head *head)
+ return ref;
+ }
+
++static void unselect_delayed_ref_head(struct btrfs_delayed_ref_root *delayed_refs,
++ struct btrfs_delayed_ref_head *head)
++{
++ spin_lock(&delayed_refs->lock);
++ head->processing = 0;
++ delayed_refs->num_heads_ready++;
++ spin_unlock(&delayed_refs->lock);
++ btrfs_delayed_ref_unlock(head);
++}
++
+ /*
+ * Returns 0 on success or if called with an already aborted transaction.
+ * Returns -ENOMEM or -EIO on failure and will abort the transaction.
+@@ -2648,11 +2658,7 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
+ if (ref && ref->seq &&
+ btrfs_check_delayed_seq(fs_info, delayed_refs, ref->seq)) {
+ spin_unlock(&locked_ref->lock);
+- spin_lock(&delayed_refs->lock);
+- locked_ref->processing = 0;
+- delayed_refs->num_heads_ready++;
+- spin_unlock(&delayed_refs->lock);
+- btrfs_delayed_ref_unlock(locked_ref);
++ unselect_delayed_ref_head(delayed_refs, locked_ref);
+ locked_ref = NULL;
+ cond_resched();
+ count++;
+@@ -2698,14 +2704,11 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
+ */
+ if (must_insert_reserved)
+ locked_ref->must_insert_reserved = 1;
+- spin_lock(&delayed_refs->lock);
+- locked_ref->processing = 0;
+- delayed_refs->num_heads_ready++;
+- spin_unlock(&delayed_refs->lock);
++ unselect_delayed_ref_head(delayed_refs,
++ locked_ref);
+ btrfs_debug(fs_info,
+ "run_delayed_extent_op returned %d",
+ ret);
+- btrfs_delayed_ref_unlock(locked_ref);
+ return ret;
+ }
+ continue;
+@@ -2763,11 +2766,7 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
+
+ btrfs_free_delayed_extent_op(extent_op);
+ if (ret) {
+- spin_lock(&delayed_refs->lock);
+- locked_ref->processing = 0;
+- delayed_refs->num_heads_ready++;
+- spin_unlock(&delayed_refs->lock);
+- btrfs_delayed_ref_unlock(locked_ref);
++ unselect_delayed_ref_head(delayed_refs, locked_ref);
+ btrfs_put_delayed_ref(ref);
+ btrfs_debug(fs_info, "run_one_delayed_ref returned %d",
+ ret);
+--
+2.21.0
+
diff --git a/patches.suse/0001-btrfs-delayed-ref-Introduce-better-documented-delaye.patch b/patches.suse/0001-btrfs-delayed-ref-Introduce-better-documented-delaye.patch
new file mode 100644
index 0000000000..8ef20a6718
--- /dev/null
+++ b/patches.suse/0001-btrfs-delayed-ref-Introduce-better-documented-delaye.patch
@@ -0,0 +1,187 @@
+From b28b1f0ce44c1b9ebc1c43e3eba18c1f1f5d9cec Mon Sep 17 00:00:00 2001
+From: Qu Wenruo <wqu@suse.com>
+Git-commit: b28b1f0ce44c1b9ebc1c43e3eba18c1f1f5d9cec
+References: bsc#1063638 bsc#1128052 bsc#1108838
+Patch-mainline: v5.2-rc1
+Date: Thu, 4 Apr 2019 14:45:29 +0800
+Subject: [PATCH 1/9] btrfs: delayed-ref: Introduce better documented delayed
+ ref structures
+
+Current delayed ref interface has several problems:
+
+- Longer and longer parameter lists
+ bytenr
+ num_bytes
+ parent
+ ---------- so far so good
+ ref_root
+ owner
+ offset
+ ---------- I don't feel good now
+
+- Different interpretation of the same parameter
+
+ Above @owner for data ref is inode number (u64),
+ while for tree ref, it's level (int).
+
+ They are even in different size range.
+ For level we only need 0 ~ 8, while for ino it's
+ BTRFS_FIRST_FREE_OBJECTID ~ BTRFS_LAST_FREE_OBJECTID.
+
+ And @offset doesn't even make sense for tree ref.
+
+ Such parameter reuse may look clever as an hidden union, but it
+ destroys code readability.
+
+To solve both problems, we introduce a new structure, btrfs_ref to solve
+them:
+
+- Structure instead of long parameter list
+ This makes later expansion easier, and is better documented.
+
+- Use btrfs_ref::type to distinguish data and tree ref
+
+- Use proper union to store data/tree ref specific structures.
+
+- Use separate functions to fill data/tree ref data, with a common generic
+ function to fill common bytenr/num_bytes members.
+
+All parameters will find its place in btrfs_ref, and an extra member,
+@real_root, inspired by ref-verify code, is newly introduced for later
+qgroup code, to record which tree is triggered by this extent modification.
+
+This patch doesn't touch any code, but provides the basis for further
+refactoring.
+
+Signed-off-by: Qu Wenruo <wqu@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/delayed-ref.h | 109 +++++++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 109 insertions(+)
+
+--- a/fs/btrfs/delayed-ref.h
++++ b/fs/btrfs/delayed-ref.h
+@@ -189,6 +189,83 @@ struct btrfs_delayed_ref_root {
+ u64 qgroup_to_skip;
+ };
+
++enum btrfs_ref_type {
++ BTRFS_REF_NOT_SET,
++ BTRFS_REF_DATA,
++ BTRFS_REF_METADATA,
++ BTRFS_REF_LAST,
++};
++
++struct btrfs_data_ref {
++ /* For EXTENT_DATA_REF */
++
++ /* Root which refers to this data extent */
++ u64 ref_root;
++
++ /* Inode which refers to this data extent */
++ u64 ino;
++
++ /*
++ * file_offset - extent_offset
++ *
++ * file_offset is the key.offset of the EXTENT_DATA key.
++ * extent_offset is btrfs_file_extent_offset() of the EXTENT_DATA data.
++ */
++ u64 offset;
++};
++
++struct btrfs_tree_ref {
++ /*
++ * Level of this tree block
++ *
++ * Shared for skinny (TREE_BLOCK_REF) and normal tree ref.
++ */
++ int level;
++
++ /*
++ * Root which refers to this tree block.
++ *
++ * For TREE_BLOCK_REF (skinny metadata, either inline or keyed)
++ */
++ u64 root;
++
++ /* For non-skinny metadata, no special member needed */
++};
++
++struct btrfs_ref {
++ enum btrfs_ref_type type;
++ int action;
++
++ /*
++ * Whether this extent should go through qgroup record.
++ *
++ * Normally false, but for certain cases like delayed subtree scan,
++ * setting this flag can hugely reduce qgroup overhead.
++ */
++ bool skip_qgroup;
++
++ /*
++ * Optional. For which root is this modification.
++ * Mostly used for qgroup optimization.
++ *
++ * When unset, data/tree ref init code will populate it.
++ * In certain cases, we're modifying reference for a different root.
++ * E.g. COW fs tree blocks for balance.
++ * In that case, tree_ref::root will be fs tree, but we're doing this
++ * for reloc tree, then we should set @real_root to reloc tree.
++ */
++ u64 real_root;
++ u64 bytenr;
++ u64 len;
++
++ /* Bytenr of the parent tree block */
++ u64 parent;
++ union {
++ struct btrfs_data_ref data_ref;
++ struct btrfs_tree_ref tree_ref;
++ };
++};
++
+ extern struct kmem_cache *btrfs_delayed_ref_head_cachep;
+ extern struct kmem_cache *btrfs_delayed_tree_ref_cachep;
+ extern struct kmem_cache *btrfs_delayed_data_ref_cachep;
+@@ -197,6 +274,38 @@ extern struct kmem_cache *btrfs_delayed_
+ int btrfs_delayed_ref_init(void);
+ void btrfs_delayed_ref_exit(void);
+
++static inline void btrfs_init_generic_ref(struct btrfs_ref *generic_ref,
++ int action, u64 bytenr, u64 len, u64 parent)
++{
++ generic_ref->action = action;
++ generic_ref->bytenr = bytenr;
++ generic_ref->len = len;
++ generic_ref->parent = parent;
++}
++
++static inline void btrfs_init_tree_ref(struct btrfs_ref *generic_ref,
++ int level, u64 root)
++{
++ /* If @real_root not set, use @root as fallback */
++ if (!generic_ref->real_root)
++ generic_ref->real_root = root;
++ generic_ref->tree_ref.level = level;
++ generic_ref->tree_ref.root = root;
++ generic_ref->type = BTRFS_REF_METADATA;
++}
++
++static inline void btrfs_init_data_ref(struct btrfs_ref *generic_ref,
++ u64 ref_root, u64 ino, u64 offset)
++{
++ /* If @real_root not set, use @root as fallback */
++ if (!generic_ref->real_root)
++ generic_ref->real_root = ref_root;
++ generic_ref->data_ref.ref_root = ref_root;
++ generic_ref->data_ref.ino = ino;
++ generic_ref->data_ref.offset = offset;
++ generic_ref->type = BTRFS_REF_DATA;
++}
++
+ static inline struct btrfs_delayed_extent_op *
+ btrfs_alloc_delayed_extent_op(void)
+ {
diff --git a/patches.suse/0001-btrfs-track-refs-in-a-rb_tree-instead-of-a-list.patch b/patches.suse/0001-btrfs-track-refs-in-a-rb_tree-instead-of-a-list.patch
new file mode 100644
index 0000000000..ff33d5ddc5
--- /dev/null
+++ b/patches.suse/0001-btrfs-track-refs-in-a-rb_tree-instead-of-a-list.patch
@@ -0,0 +1,404 @@
+From 0e0adbcfdc908684317c99a9bf5e13383f03b7ec Mon Sep 17 00:00:00 2001
+From: Josef Bacik <josef@toxicpanda.com>
+Git-commit: 0e0adbcfdc908684317c99a9bf5e13383f03b7ec
+Patch-mainline: v4.15
+References: bsc#1134813
+Date: Thu, 19 Oct 2017 14:16:00 -0400
+Subject: [PATCH] btrfs: track refs in a rb_tree instead of a list
+
+If we get a significant amount of delayed refs for a single block (think
+modifying multiple snapshots) we can end up spending an ungodly amount
+of time looping through all of the entries trying to see if they can be
+merged. This is because we only add them to a list, so we have O(2n)
+for every ref head. This doesn't make any sense as we likely have refs
+for different roots, and so they cannot be merged. Tracking in a tree
+will allow us to break as soon as we hit an entry that doesn't match,
+making our worst case O(n).
+
+With this we can also merge entries more easily. Before we had to hope
+that matching refs were on the ends of our list, but with the tree we
+can search down to exact matches and merge them at insert time.
+
+Signed-off-by: Josef Bacik <jbacik@fb.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/backref.c | 5 +-
+ fs/btrfs/delayed-ref.c | 108 +++++++++++++++++++++--------------------
+ fs/btrfs/delayed-ref.h | 5 +-
+ fs/btrfs/disk-io.c | 10 ++--
+ fs/btrfs/extent-tree.c | 21 +++++---
+ 5 files changed, 82 insertions(+), 67 deletions(-)
+
+diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
+index 523d2dba7745..7d0dc100a09a 100644
+--- a/fs/btrfs/backref.c
++++ b/fs/btrfs/backref.c
+@@ -773,6 +773,7 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
+ struct btrfs_key key;
+ struct btrfs_key tmp_op_key;
+ struct btrfs_key *op_key = NULL;
++ struct rb_node *n;
+ int count;
+ int ret = 0;
+
+@@ -782,7 +783,9 @@ static int add_delayed_refs(const struct btrfs_fs_info *fs_info,
+ }
+
+ spin_lock(&head->lock);
+- list_for_each_entry(node, &head->ref_list, list) {
++ for (n = rb_first(&head->ref_tree); n; n = rb_next(n)) {
++ node = rb_entry(n, struct btrfs_delayed_ref_node,
++ ref_node);
+ if (node->seq > seq)
+ continue;
+
+diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
+index 8c7d7db01f7a..83be8f9fd906 100644
+--- a/fs/btrfs/delayed-ref.c
++++ b/fs/btrfs/delayed-ref.c
+@@ -143,6 +143,34 @@ static struct btrfs_delayed_ref_head *htree_insert(struct rb_root *root,
+ return NULL;
+ }
+
++static struct btrfs_delayed_ref_node* tree_insert(struct rb_root *root,
++ struct btrfs_delayed_ref_node *ins)
++{
++ struct rb_node **p = &root->rb_node;
++ struct rb_node *node = &ins->ref_node;
++ struct rb_node *parent_node = NULL;
++ struct btrfs_delayed_ref_node *entry;
++
++ while (*p) {
++ int comp;
++
++ parent_node = *p;
++ entry = rb_entry(parent_node, struct btrfs_delayed_ref_node,
++ ref_node);
++ comp = comp_refs(ins, entry, true);
++ if (comp < 0)
++ p = &(*p)->rb_left;
++ else if (comp > 0)
++ p = &(*p)->rb_right;
++ else
++ return entry;
++ }
++
++ rb_link_node(node, parent_node, p);
++ rb_insert_color(node, root);
++ return NULL;
++}
++
+ /*
+ * find an head entry based on bytenr. This returns the delayed ref
+ * head if it was able to find one, or NULL if nothing was in that spot.
+@@ -212,7 +240,8 @@ static inline void drop_delayed_ref(struct btrfs_trans_handle *trans,
+ struct btrfs_delayed_ref_node *ref)
+ {
+ assert_spin_locked(&head->lock);
+- list_del(&ref->list);
++ rb_erase(&ref->ref_node, &head->ref_tree);
++ RB_CLEAR_NODE(&ref->ref_node);
+ if (!list_empty(&ref->add_list))
+ list_del(&ref->add_list);
+ ref->in_tree = 0;
+@@ -229,24 +258,18 @@ static bool merge_ref(struct btrfs_trans_handle *trans,
+ u64 seq)
+ {
+ struct btrfs_delayed_ref_node *next;
++ struct rb_node *node = rb_next(&ref->ref_node);
+ bool done = false;
+
+- next = list_first_entry(&head->ref_list, struct btrfs_delayed_ref_node,
+- list);
+- while (!done && &next->list != &head->ref_list) {
++ while (!done && node) {
+ int mod;
+- struct btrfs_delayed_ref_node *next2;
+-
+- next2 = list_next_entry(next, list);
+-
+- if (next == ref)
+- goto next;
+
++ next = rb_entry(node, struct btrfs_delayed_ref_node, ref_node);
++ node = rb_next(node);
+ if (seq && next->seq >= seq)
+- goto next;
+-
++ break;
+ if (comp_refs(ref, next, false))
+- goto next;
++ break;
+
+ if (ref->action == next->action) {
+ mod = next->ref_mod;
+@@ -270,8 +293,6 @@ static bool merge_ref(struct btrfs_trans_handle *trans,
+ WARN_ON(ref->type == BTRFS_TREE_BLOCK_REF_KEY ||
+ ref->type == BTRFS_SHARED_BLOCK_REF_KEY);
+ }
+-next:
+- next = next2;
+ }
+
+ return done;
+@@ -283,11 +304,12 @@ void btrfs_merge_delayed_refs(struct btrfs_trans_handle *trans,
+ struct btrfs_delayed_ref_head *head)
+ {
+ struct btrfs_delayed_ref_node *ref;
++ struct rb_node *node;
+ u64 seq = 0;
+
+ assert_spin_locked(&head->lock);
+
+- if (list_empty(&head->ref_list))
++ if (RB_EMPTY_ROOT(&head->ref_tree))
+ return;
+
+ /* We don't have too many refs to merge for data. */
+@@ -304,22 +326,13 @@ void btrfs_merge_delayed_refs(struct btrfs_trans_handle *trans,
+ }
+ spin_unlock(&fs_info->tree_mod_seq_lock);
+
+- ref = list_first_entry(&head->ref_list, struct btrfs_delayed_ref_node,
+- list);
+- while (&ref->list != &head->ref_list) {
++again:
++ for (node = rb_first(&head->ref_tree); node; node = rb_next(node)) {
++ ref = rb_entry(node, struct btrfs_delayed_ref_node, ref_node);
+ if (seq && ref->seq >= seq)
+- goto next;
+-
+- if (merge_ref(trans, delayed_refs, head, ref, seq)) {
+- if (list_empty(&head->ref_list))
+- break;
+- ref = list_first_entry(&head->ref_list,
+- struct btrfs_delayed_ref_node,
+- list);
+ continue;
+- }
+-next:
+- ref = list_next_entry(ref, list);
++ if (merge_ref(trans, delayed_refs, head, ref, seq))
++ goto again;
+ }
+ }
+
+@@ -402,25 +415,19 @@ btrfs_select_ref_head(struct btrfs_trans_handle *trans)
+ * Return 0 for insert.
+ * Return >0 for merge.
+ */
+-static int
+-add_delayed_ref_tail_merge(struct btrfs_trans_handle *trans,
+- struct btrfs_delayed_ref_root *root,
+- struct btrfs_delayed_ref_head *href,
+- struct btrfs_delayed_ref_node *ref)
++static int insert_delayed_ref(struct btrfs_trans_handle *trans,
++ struct btrfs_delayed_ref_root *root,
++ struct btrfs_delayed_ref_head *href,
++ struct btrfs_delayed_ref_node *ref)
+ {
+ struct btrfs_delayed_ref_node *exist;
+ int mod;
+ int ret = 0;
+
+ spin_lock(&href->lock);
+- /* Check whether we can merge the tail node with ref */
+- if (list_empty(&href->ref_list))
+- goto add_tail;
+- exist = list_entry(href->ref_list.prev, struct btrfs_delayed_ref_node,
+- list);
+- /* No need to compare bytenr nor is_head */
+- if (comp_refs(exist, ref, true))
+- goto add_tail;
++ exist = tree_insert(&href->ref_tree, ref);
++ if (!exist)
++ goto inserted;
+
+ /* Now we are sure we can merge */
+ ret = 1;
+@@ -451,9 +458,7 @@ add_delayed_ref_tail_merge(struct btrfs_trans_handle *trans,
+ drop_delayed_ref(trans, root, href, exist);
+ spin_unlock(&href->lock);
+ return ret;
+-
+-add_tail:
+- list_add_tail(&ref->list, &href->ref_list);
++inserted:
+ if (ref->action == BTRFS_ADD_DELAYED_REF)
+ list_add_tail(&ref->add_list, &href->ref_add_list);
+ atomic_inc(&root->num_entries);
+@@ -593,7 +598,7 @@ add_delayed_ref_head(struct btrfs_fs_info *fs_info,
+ head_ref->ref_mod = count_mod;
+ head_ref->must_insert_reserved = must_insert_reserved;
+ head_ref->is_data = is_data;
+- INIT_LIST_HEAD(&head_ref->ref_list);
++ head_ref->ref_tree = RB_ROOT;
+ INIT_LIST_HEAD(&head_ref->ref_add_list);
+ RB_CLEAR_NODE(&head_ref->href_node);
+ head_ref->processing = 0;
+@@ -685,7 +690,7 @@ add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
+ ref->is_head = 0;
+ ref->in_tree = 1;
+ ref->seq = seq;
+- INIT_LIST_HEAD(&ref->list);
++ RB_CLEAR_NODE(&ref->ref_node);
+ INIT_LIST_HEAD(&ref->add_list);
+
+ full_ref = btrfs_delayed_node_to_tree_ref(ref);
+@@ -699,7 +704,7 @@ add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
+
+ trace_add_delayed_tree_ref(fs_info, ref, full_ref, action);
+
+- ret = add_delayed_ref_tail_merge(trans, delayed_refs, head_ref, ref);
++ ret = insert_delayed_ref(trans, delayed_refs, head_ref, ref);
+
+ /*
+ * XXX: memory should be freed at the same level allocated.
+@@ -742,7 +747,7 @@ add_delayed_data_ref(struct btrfs_fs_info *fs_info,
+ ref->is_head = 0;
+ ref->in_tree = 1;
+ ref->seq = seq;
+- INIT_LIST_HEAD(&ref->list);
++ RB_CLEAR_NODE(&ref->ref_node);
+ INIT_LIST_HEAD(&ref->add_list);
+
+ full_ref = btrfs_delayed_node_to_data_ref(ref);
+@@ -758,8 +763,7 @@ add_delayed_data_ref(struct btrfs_fs_info *fs_info,
+
+ trace_add_delayed_data_ref(fs_info, ref, full_ref, action);
+
+- ret = add_delayed_ref_tail_merge(trans, delayed_refs, head_ref, ref);
+-
++ ret = insert_delayed_ref(trans, delayed_refs, head_ref, ref);
+ if (ret > 0)
+ kmem_cache_free(btrfs_delayed_data_ref_cachep, full_ref);
+ }
+diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h
+index 1ce11858d727..a43af432f859 100644
+--- a/fs/btrfs/delayed-ref.h
++++ b/fs/btrfs/delayed-ref.h
+@@ -27,8 +27,7 @@
+ #define BTRFS_UPDATE_DELAYED_HEAD 4 /* not changing ref count on head ref */
+
+ struct btrfs_delayed_ref_node {
+- /*data/tree ref use list, stored in ref_head->ref_list. */
+- struct list_head list;
++ struct rb_node ref_node;
+ /*
+ * If action is BTRFS_ADD_DELAYED_REF, also link this node to
+ * ref_head->ref_add_list, then we do not need to iterate the
+@@ -92,7 +91,7 @@ struct btrfs_delayed_ref_head {
+ struct mutex mutex;
+
+ spinlock_t lock;
+- struct list_head ref_list;
++ struct rb_root ref_tree;
+ /* accumulate add BTRFS_ADD_DELAYED_REF nodes to this ref_add_list. */
+ struct list_head ref_add_list;
+
+diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
+index d1f396f72979..efce9a2fa9be 100644
+--- a/fs/btrfs/disk-io.c
++++ b/fs/btrfs/disk-io.c
+@@ -4113,7 +4113,7 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
+
+ while ((node = rb_first(&delayed_refs->href_root)) != NULL) {
+ struct btrfs_delayed_ref_head *head;
+- struct btrfs_delayed_ref_node *tmp;
++ struct rb_node *n;
+ bool pin_bytes = false;
+
+ head = rb_entry(node, struct btrfs_delayed_ref_head,
+@@ -4129,10 +4129,12 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
+ continue;
+ }
+ spin_lock(&head->lock);
+- list_for_each_entry_safe_reverse(ref, tmp, &head->ref_list,
+- list) {
++ while ((n = rb_first(&head->ref_tree)) != NULL) {
++ ref = rb_entry(n, struct btrfs_delayed_ref_node,
++ ref_node);
+ ref->in_tree = 0;
+- list_del(&ref->list);
++ rb_erase(&ref->ref_node, &head->ref_tree);
++ RB_CLEAR_NODE(&ref->ref_node);
+ if (!list_empty(&ref->add_list))
+ list_del(&ref->add_list);
+ atomic_dec(&delayed_refs->num_entries);
+diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
+index fc9720e28005..673ac4e01dd0 100644
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -2519,7 +2519,7 @@ select_delayed_ref(struct btrfs_delayed_ref_head *head)
+ {
+ struct btrfs_delayed_ref_node *ref;
+
+- if (list_empty(&head->ref_list))
++ if (RB_EMPTY_ROOT(&head->ref_tree))
+ return NULL;
+
+ /*
+@@ -2532,8 +2532,8 @@ select_delayed_ref(struct btrfs_delayed_ref_head *head)
+ return list_first_entry(&head->ref_add_list,
+ struct btrfs_delayed_ref_node, add_list);
+
+- ref = list_first_entry(&head->ref_list, struct btrfs_delayed_ref_node,
+- list);
++ ref = rb_entry(rb_first(&head->ref_tree),
++ struct btrfs_delayed_ref_node, ref_node);
+ ASSERT(list_empty(&ref->add_list));
+ return ref;
+ }
+@@ -2593,7 +2593,7 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans,
+ spin_unlock(&head->lock);
+ spin_lock(&delayed_refs->lock);
+ spin_lock(&head->lock);
+- if (!list_empty(&head->ref_list) || head->extent_op) {
++ if (!RB_EMPTY_ROOT(&head->ref_tree) || head->extent_op) {
+ spin_unlock(&head->lock);
+ spin_unlock(&delayed_refs->lock);
+ return 1;
+@@ -2740,7 +2740,8 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
+
+ actual_count++;
+ ref->in_tree = 0;
+- list_del(&ref->list);
++ rb_erase(&ref->ref_node, &locked_ref->ref_tree);
++ RB_CLEAR_NODE(&ref->ref_node);
+ if (!list_empty(&ref->add_list))
+ list_del(&ref->add_list);
+ /*
+@@ -3138,6 +3139,7 @@ static noinline int check_delayed_ref(struct btrfs_root *root,
+ struct btrfs_delayed_data_ref *data_ref;
+ struct btrfs_delayed_ref_root *delayed_refs;
+ struct btrfs_transaction *cur_trans;
++ struct rb_node *node;
+ int ret = 0;
+
+ cur_trans = root->fs_info->running_transaction;
+@@ -3170,7 +3172,12 @@ static noinline int check_delayed_ref(struct btrfs_root *root,
+ spin_unlock(&delayed_refs->lock);
+
+ spin_lock(&head->lock);
+- list_for_each_entry(ref, &head->ref_list, list) {
++ /*
++ * XXX: We should replace this with a proper search function in the
++ * future.
++ */
++ for (node = rb_first(&head->ref_tree); node; node = rb_next(node)) {
++ ref = rb_entry(node, struct btrfs_delayed_ref_node, ref_node);
+ /* If it's a shared ref we know a cross reference exists */
+ if (ref->type != BTRFS_EXTENT_DATA_REF_KEY) {
+ ret = 1;
+@@ -7141,7 +7148,7 @@ static noinline int check_ref_cleanup(struct btrfs_trans_handle *trans,
+ goto out_delayed_unlock;
+
+ spin_lock(&head->lock);
+- if (!list_empty(&head->ref_list))
++ if (!RB_EMPTY_ROOT(&head->ref_tree))
+ goto out;
+
+ if (head->extent_op) {
+--
+2.21.0
+
diff --git a/patches.suse/0001-drm-ttm-Remove-warning-about-inconsistent-mapping-in.patch b/patches.suse/0001-drm-ttm-Remove-warning-about-inconsistent-mapping-in.patch
new file mode 100644
index 0000000000..06f8d5fb5f
--- /dev/null
+++ b/patches.suse/0001-drm-ttm-Remove-warning-about-inconsistent-mapping-in.patch
@@ -0,0 +1,33 @@
+From d719a1ff8391101ba5cb0998943dfb3f77d47e7f Mon Sep 17 00:00:00 2001
+From: Thomas Zimmermann <tzimmermann@suse.de>
+Date: Tue, 14 May 2019 12:37:31 +0200
+Subject: drm/ttm: Remove warning about inconsistent mapping information
+Patch-mainline: Never, local cleanup
+References: bnc#1131488
+
+Fixing the issue of bnc1131488 requires changing a significant amount
+of the fbdev emulation. As the problem is rather cosmetical, we drop
+the warning for now.
+
+Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
+Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
+---
+ drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
+index 622dab6c4347..90a56c6724b5 100644
+--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
++++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
+@@ -284,8 +284,6 @@ static void ttm_bo_vm_open(struct vm_area_struct *vma)
+ struct ttm_buffer_object *bo =
+ (struct ttm_buffer_object *)vma->vm_private_data;
+
+- WARN_ON(bo->bdev->dev_mapping != vma->vm_file->f_mapping);
+-
+ (void)ttm_bo_reference(bo);
+ }
+
+--
+2.21.0
+
diff --git a/patches.suse/0002-btrfs-Use-init_delayed_ref_common-in-add_delayed_tre.patch b/patches.suse/0002-btrfs-Use-init_delayed_ref_common-in-add_delayed_tre.patch
new file mode 100644
index 0000000000..c03208f122
--- /dev/null
+++ b/patches.suse/0002-btrfs-Use-init_delayed_ref_common-in-add_delayed_tre.patch
@@ -0,0 +1,75 @@
+From 646f4dd76fb3ac0d1e8677890522d4c044ee2f06 Mon Sep 17 00:00:00 2001
+From: Nikolay Borisov <nborisov@suse.com>
+Date: Tue, 24 Apr 2018 17:18:18 +0300
+Git-commit: 646f4dd76fb3ac0d1e8677890522d4c044ee2f06
+Patch-mainline: v4.18
+References: bsc#1134813
+Subject: [PATCH 2/8] btrfs: Use init_delayed_ref_common in
+ add_delayed_tree_ref
+
+Use the newly introduced common helper. No functional changes.
+
+Signed-off-by: Nikolay Borisov <nborisov@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/delayed-ref.c | 35 +++++++++++------------------------
+ 1 file changed, 11 insertions(+), 24 deletions(-)
+
+diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
+index a0dc255792c7..1c27d3322198 100644
+--- a/fs/btrfs/delayed-ref.c
++++ b/fs/btrfs/delayed-ref.c
+@@ -708,38 +708,25 @@ add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
+ {
+ struct btrfs_delayed_tree_ref *full_ref;
+ struct btrfs_delayed_ref_root *delayed_refs;
+- u64 seq = 0;
++ u8 ref_type;
+ int ret;
+
+- if (action == BTRFS_ADD_DELAYED_EXTENT)
+- action = BTRFS_ADD_DELAYED_REF;
+-
+- if (is_fstree(ref_root))
+- seq = atomic64_read(&fs_info->tree_mod_seq);
+ delayed_refs = &trans->transaction->delayed_refs;
+-
+- /* first set the basic ref node struct up */
+- refcount_set(&ref->refs, 1);
+- ref->bytenr = bytenr;
+- ref->num_bytes = num_bytes;
+- ref->ref_mod = 1;
+- ref->action = action;
+- ref->is_head = 0;
+- ref->in_tree = 1;
+- ref->seq = seq;
+- RB_CLEAR_NODE(&ref->ref_node);
+- INIT_LIST_HEAD(&ref->add_list);
+-
+ full_ref = btrfs_delayed_node_to_tree_ref(ref);
+- full_ref->parent = parent;
+- full_ref->root = ref_root;
+ if (parent)
+- ref->type = BTRFS_SHARED_BLOCK_REF_KEY;
++ ref_type = BTRFS_SHARED_BLOCK_REF_KEY;
+ else
+- ref->type = BTRFS_TREE_BLOCK_REF_KEY;
++ ref_type = BTRFS_TREE_BLOCK_REF_KEY;
++
++ init_delayed_ref_common(fs_info, ref, bytenr, num_bytes, ref_root,
++ action, ref_type);
++ full_ref->root = ref_root;
++ full_ref->parent = parent;
+ full_ref->level = level;
+
+- trace_add_delayed_tree_ref(fs_info, ref, full_ref, action);
++ trace_add_delayed_tree_ref(fs_info, ref, full_ref,
++ action == BTRFS_ADD_DELAYED_EXTENT ?
++ BTRFS_ADD_DELAYED_REF : action);
+
+ ret = insert_delayed_ref(trans, delayed_refs, head_ref, ref);
+
+--
+2.21.0
+
diff --git a/patches.suse/0002-btrfs-extent-tree-Open-code-process_func-in-__btrfs_.patch b/patches.suse/0002-btrfs-extent-tree-Open-code-process_func-in-__btrfs_.patch
new file mode 100644
index 0000000000..b57a910b3b
--- /dev/null
+++ b/patches.suse/0002-btrfs-extent-tree-Open-code-process_func-in-__btrfs_.patch
@@ -0,0 +1,83 @@
+From dd28b6a5aad306c417477db700ed0848c923a31c Mon Sep 17 00:00:00 2001
+From: Qu Wenruo <wqu@suse.com>
+Date: Thu, 4 Apr 2019 14:45:30 +0800
+Git-commit: dd28b6a5aad306c417477db700ed0848c923a31c
+References: bsc#1063638 bsc#1128052 bsc#1108838
+Patch-mainline: v5.2-rc1
+Subject: [PATCH 2/9] btrfs: extent-tree: Open-code process_func in
+ __btrfs_mod_ref
+
+The process_func function pointer is local to __btrfs_mod_ref() and
+points to either btrfs_inc_extent_ref() or btrfs_free_extent().
+
+Open code it to make later delayed ref refactor easier, so we can
+refactor btrfs_inc_extent_ref() and btrfs_free_extent() in different
+patches.
+
+Reviewed-by: Nikolay Borisov <nborisov@suse.com>
+Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
+Signed-off-by: Qu Wenruo <wqu@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/extent-tree.c | 30 ++++++++++++++++--------------
+ 1 file changed, 16 insertions(+), 14 deletions(-)
+
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -3275,10 +3275,6 @@ static int __btrfs_mod_ref(struct btrfs_
+ int i;
+ int level;
+ int ret = 0;
+- int (*process_func)(struct btrfs_trans_handle *,
+- struct btrfs_fs_info *,
+- u64, u64, u64, u64, u64, u64);
+-
+
+ if (btrfs_is_testing(fs_info))
+ return 0;
+@@ -3290,11 +3286,6 @@ static int __btrfs_mod_ref(struct btrfs_
+ if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state) && level == 0)
+ return 0;
+
+- if (inc)
+- process_func = btrfs_inc_extent_ref;
+- else
+- process_func = btrfs_free_extent;
+-
+ if (full_backref)
+ parent = buf->start;
+ else
+@@ -3316,16 +3307,27 @@ static int __btrfs_mod_ref(struct btrfs_
+
+ num_bytes = btrfs_file_extent_disk_num_bytes(buf, fi);
+ key.offset -= btrfs_file_extent_offset(buf, fi);
+- ret = process_func(trans, fs_info, bytenr, num_bytes,
+- parent, ref_root, key.objectid,
+- key.offset);
++ if (inc)
++ ret = btrfs_inc_extent_ref(trans, fs_info, bytenr,
++ num_bytes, parent, ref_root,
++ key.objectid, key.offset);
++ else
++ ret = btrfs_free_extent(trans, fs_info, bytenr,
++ num_bytes, parent, ref_root,
++ key.objectid, key.offset);
+ if (ret)
+ goto fail;
+ } else {
+ bytenr = btrfs_node_blockptr(buf, i);
+ num_bytes = fs_info->nodesize;
+- ret = process_func(trans, fs_info, bytenr, num_bytes,
+- parent, ref_root, level - 1, 0);
++ if (inc)
++ ret = btrfs_inc_extent_ref(trans, fs_info, bytenr,
++ num_bytes, parent, ref_root,
++ level - 1, 0);
++ else
++ ret = btrfs_free_extent(trans, fs_info, bytenr,
++ num_bytes, parent, ref_root,
++ level - 1, 0);
+ if (ret)
+ goto fail;
+ }
diff --git a/patches.suse/0002-btrfs-move-extent_op-cleanup-to-a-helper.patch b/patches.suse/0002-btrfs-move-extent_op-cleanup-to-a-helper.patch
new file mode 100644
index 0000000000..7595f806b4
--- /dev/null
+++ b/patches.suse/0002-btrfs-move-extent_op-cleanup-to-a-helper.patch
@@ -0,0 +1,130 @@
+From b00e62507ec6a9b63d9b3019795584e694085b65 Mon Sep 17 00:00:00 2001
+From: Josef Bacik <josef@toxicpanda.com>
+Date: Fri, 29 Sep 2017 15:43:53 -0400
+Git-commit: b00e62507ec6a9b63d9b3019795584e694085b65
+Patch-mainline: 4.15
+References: bsc#1134813
+Subject: [PATCH 2/7] btrfs: move extent_op cleanup to a helper
+
+Move the extent_op cleanup for an empty head ref to a helper function to
+help simplify __btrfs_run_delayed_refs.
+
+Signed-off-by: Josef Bacik <jbacik@fb.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/extent-tree.c | 77 ++++++++++++++++++++++--------------------
+ 1 file changed, 40 insertions(+), 37 deletions(-)
+
+diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
+index 3e4a6a4b0505..e5ed90f20805 100644
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -2585,6 +2585,26 @@ static void unselect_delayed_ref_head(struct btrfs_delayed_ref_root *delayed_ref
+ btrfs_delayed_ref_unlock(head);
+ }
+
++static int cleanup_extent_op(struct btrfs_trans_handle *trans,
++ struct btrfs_fs_info *fs_info,
++ struct btrfs_delayed_ref_head *head)
++{
++ struct btrfs_delayed_extent_op *extent_op = head->extent_op;
++ int ret;
++
++ if (!extent_op)
++ return 0;
++ head->extent_op = NULL;
++ if (head->must_insert_reserved) {
++ btrfs_free_delayed_extent_op(extent_op);
++ return 0;
++ }
++ spin_unlock(&head->lock);
++ ret = run_delayed_extent_op(trans, fs_info, &head->node, extent_op);
++ btrfs_free_delayed_extent_op(extent_op);
++ return ret ? ret : 1;
++}
++
+ /*
+ * Returns 0 on success or if called with an already aborted transaction.
+ * Returns -ENOMEM or -EIO on failure and will abort the transaction.
+@@ -2665,16 +2685,6 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
+ continue;
+ }
+
+- /*
+- * record the must insert reserved flag before we
+- * drop the spin lock.
+- */
+- must_insert_reserved = locked_ref->must_insert_reserved;
+- locked_ref->must_insert_reserved = 0;
+-
+- extent_op = locked_ref->extent_op;
+- locked_ref->extent_op = NULL;
+-
+ if (!ref) {
+
+
+@@ -2684,33 +2694,17 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
+ */
+ ref = &locked_ref->node;
+
+- if (extent_op && must_insert_reserved) {
+- btrfs_free_delayed_extent_op(extent_op);
+- extent_op = NULL;
+- }
+-
+- if (extent_op) {
+- spin_unlock(&locked_ref->lock);
+- ret = run_delayed_extent_op(trans, fs_info,
+- ref, extent_op);
+- btrfs_free_delayed_extent_op(extent_op);
+-
+- if (ret) {
+- /*
+- * Need to reset must_insert_reserved if
+- * there was an error so the abort stuff
+- * can cleanup the reserved space
+- * properly.
+- */
+- if (must_insert_reserved)
+- locked_ref->must_insert_reserved = 1;
+- unselect_delayed_ref_head(delayed_refs,
+- locked_ref);
+- btrfs_debug(fs_info,
+- "run_delayed_extent_op returned %d",
+- ret);
+- return ret;
+- }
++ ret = cleanup_extent_op(trans, fs_info, locked_ref);
++ if (ret < 0) {
++ unselect_delayed_ref_head(delayed_refs,
++ locked_ref);
++ btrfs_debug(fs_info,
++ "run_delayed_extent_op returned %d",
++ ret);
++ return ret;
++ } else if (ret > 0) {
++ /* We dropped our lock, we need to loop. */
++ ret = 0;
+ continue;
+ }
+
+@@ -2759,6 +2753,15 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
+ WARN_ON(1);
+ }
+ }
++ /*
++ * Record the must-insert_reserved flag before we drop the spin
++ * lock.
++ */
++ must_insert_reserved = locked_ref->must_insert_reserved;
++ locked_ref->must_insert_reserved = 0;
++
++ extent_op = locked_ref->extent_op;
++ locked_ref->extent_op = NULL;
+ spin_unlock(&locked_ref->lock);
+
+ ret = run_one_delayed_ref(trans, fs_info, ref, extent_op,
+--
+2.21.0
+
diff --git a/patches.suse/0003-btrfs-Use-init_delayed_ref_common-in-add_delayed_dat.patch b/patches.suse/0003-btrfs-Use-init_delayed_ref_common-in-add_delayed_dat.patch
new file mode 100644
index 0000000000..8396e83151
--- /dev/null
+++ b/patches.suse/0003-btrfs-Use-init_delayed_ref_common-in-add_delayed_dat.patch
@@ -0,0 +1,73 @@
+From c812c8a857a00acae78341d5d4702eb8d7d02661 Mon Sep 17 00:00:00 2001
+From: Nikolay Borisov <nborisov@suse.com>
+Date: Tue, 24 Apr 2018 17:18:19 +0300
+Git-commit: c812c8a857a00acae78341d5d4702eb8d7d02661
+Patch-mainline: v4.18
+References: bsc#1134813
+Subject: [PATCH 3/8] btrfs: Use init_delayed_ref_common in
+ add_delayed_data_ref
+
+Use the newly introduced helper and remove the duplicate code. No
+functional changes.
+
+Signed-off-by: Nikolay Borisov <nborisov@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/delayed-ref.c | 33 ++++++++++-----------------------
+ 1 file changed, 10 insertions(+), 23 deletions(-)
+
+--- a/fs/btrfs/delayed-ref.c
++++ b/fs/btrfs/delayed-ref.c
+@@ -768,41 +768,28 @@ add_delayed_data_ref(struct btrfs_fs_inf
+ {
+ struct btrfs_delayed_data_ref *full_ref;
+ struct btrfs_delayed_ref_root *delayed_refs;
+- u64 seq = 0;
++ u8 ref_type;
+ int ret;
+
+- if (action == BTRFS_ADD_DELAYED_EXTENT)
+- action = BTRFS_ADD_DELAYED_REF;
+-
+ delayed_refs = &trans->transaction->delayed_refs;
+
+- if (is_fstree(ref_root))
+- seq = atomic64_read(&fs_info->tree_mod_seq);
+-
+- /* first set the basic ref node struct up */
+- refcount_set(&ref->refs, 1);
+- ref->bytenr = bytenr;
+- ref->num_bytes = num_bytes;
+- ref->ref_mod = 1;
+- ref->action = action;
+- ref->is_head = 0;
+- ref->in_tree = 1;
+- ref->seq = seq;
+- RB_CLEAR_NODE(&ref->ref_node);
+- INIT_LIST_HEAD(&ref->add_list);
+
+ full_ref = btrfs_delayed_node_to_data_ref(ref);
+- full_ref->parent = parent;
+- full_ref->root = ref_root;
+ if (parent)
+- ref->type = BTRFS_SHARED_DATA_REF_KEY;
++ ref_type = BTRFS_SHARED_DATA_REF_KEY;
+ else
+- ref->type = BTRFS_EXTENT_DATA_REF_KEY;
++ ref_type = BTRFS_EXTENT_DATA_REF_KEY;
+
++ init_delayed_ref_common(fs_info, ref, bytenr, num_bytes,
++ ref_root, action, ref_type);
++ full_ref->root = ref_root;
++ full_ref->parent = parent;
+ full_ref->objectid = owner;
+ full_ref->offset = offset;
+
+- trace_add_delayed_data_ref(fs_info, ref, full_ref, action);
++ trace_add_delayed_data_ref(fs_info, ref, full_ref,
++ action == BTRFS_ADD_DELAYED_EXTENT ?
++ BTRFS_ADD_DELAYED_REF : action);
+
+ ret = insert_delayed_ref(trans, delayed_refs, head_ref, ref);
+ if (ret > 0)
diff --git a/patches.suse/0003-btrfs-breakout-empty-head-cleanup-to-a-helper.patch b/patches.suse/0003-btrfs-breakout-empty-head-cleanup-to-a-helper.patch
new file mode 100644
index 0000000000..006adddba8
--- /dev/null
+++ b/patches.suse/0003-btrfs-breakout-empty-head-cleanup-to-a-helper.patch
@@ -0,0 +1,124 @@
+From 194ab0bc21cc99c5b804040aa785e0bdcc214656 Mon Sep 17 00:00:00 2001
+From: Josef Bacik <josef@toxicpanda.com>
+Date: Fri, 29 Sep 2017 15:43:54 -0400
+Git-commit: 194ab0bc21cc99c5b804040aa785e0bdcc214656
+Patch-mainline: 4.15
+References: bsc#1134813
+Subject: [PATCH 3/7] btrfs: breakout empty head cleanup to a helper
+
+Move this code out to a helper function to further simplivy
+__btrfs_run_delayed_refs.
+
+Signed-off-by: Josef Bacik <jbacik@fb.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/extent-tree.c | 79 ++++++++++++++++++++++++------------------
+ 1 file changed, 45 insertions(+), 34 deletions(-)
+
+diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
+index e5ed90f20805..5e61e9287b0e 100644
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -2605,6 +2605,43 @@ static int cleanup_extent_op(struct btrfs_trans_handle *trans,
+ return ret ? ret : 1;
+ }
+
++static int cleanup_ref_head(struct btrfs_trans_handle *trans,
++ struct btrfs_fs_info *fs_info,
++ struct btrfs_delayed_ref_head *head)
++{
++ struct btrfs_delayed_ref_root *delayed_refs;
++ int ret;
++
++ delayed_refs = &trans->transaction->delayed_refs;
++
++ ret = cleanup_extent_op(trans, fs_info, head);
++ if (ret < 0) {
++ unselect_delayed_ref_head(delayed_refs, head);
++ btrfs_debug(fs_info, "run_delayed_extent_op returned %d", ret);
++ return ret;
++ } else if (ret) {
++ return ret;
++ }
++
++ /*
++ * Need to drop our head ref lock and re-acquire the delayed ref lock
++ * and then re-check to make sure nobody got added.
++ */
++ spin_unlock(&head->lock);
++ spin_lock(&delayed_refs->lock);
++ spin_lock(&head->lock);
++ if (!list_empty(&head->ref_list) || head->extent_op) {
++ spin_unlock(&head->lock);
++ spin_unlock(&delayed_refs->lock);
++ return 1;
++ }
++ head->node.in_tree = 0;
++ delayed_refs->num_heads--;
++ rb_erase(&head->href_node, &delayed_refs->href_root);
++ spin_unlock(&delayed_refs->lock);
++ return 0;
++}
++
+ /*
+ * Returns 0 on success or if called with an already aborted transaction.
+ * Returns -ENOMEM or -EIO on failure and will abort the transaction.
+@@ -2686,47 +2723,21 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
+ }
+
+ if (!ref) {
+-
+-
+- /* All delayed refs have been processed, Go ahead
+- * and send the head node to run_one_delayed_ref,
+- * so that any accounting fixes can happen
+- */
+- ref = &locked_ref->node;
+-
+- ret = cleanup_extent_op(trans, fs_info, locked_ref);
+- if (ret < 0) {
+- unselect_delayed_ref_head(delayed_refs,
+- locked_ref);
+- btrfs_debug(fs_info,
+- "run_delayed_extent_op returned %d",
+- ret);
+- return ret;
+- } else if (ret > 0) {
++ ret = cleanup_ref_head(trans, fs_info, locked_ref);
++ if (ret > 0 ) {
+ /* We dropped our lock, we need to loop. */
+ ret = 0;
+ continue;
++ } else if (ret) {
++ return ret;
+ }
+
+ /*
+- * Need to drop our head ref lock and re-acquire the
+- * delayed ref lock and then re-check to make sure
+- * nobody got added.
++ * All delayed refs have been processed, Go ahead and
++ * send the head node to run_one_delayed_ref, so that
++ * any accounting fixes can happen
+ */
+- spin_unlock(&locked_ref->lock);
+- spin_lock(&delayed_refs->lock);
+- spin_lock(&locked_ref->lock);
+- if (!list_empty(&locked_ref->ref_list) ||
+- locked_ref->extent_op) {
+- spin_unlock(&locked_ref->lock);
+- spin_unlock(&delayed_refs->lock);
+- continue;
+- }
+- ref->in_tree = 0;
+- delayed_refs->num_heads--;
+- rb_erase(&locked_ref->href_node,
+- &delayed_refs->href_root);
+- spin_unlock(&delayed_refs->lock);
++ ref = &locked_ref->node;
+ } else {
+ actual_count++;
+ ref->in_tree = 0;
+--
+2.21.0
+
diff --git a/patches.suse/0003-x86-idle-Control-Indirect-Branch-Speculation-in-idle.patch b/patches.suse/0003-x86-idle-Control-Indirect-Branch-Speculation-in-idle.patch
index bc9f09616d..14fc7dac62 100644
--- a/patches.suse/0003-x86-idle-Control-Indirect-Branch-Speculation-in-idle.patch
+++ b/patches.suse/0003-x86-idle-Control-Indirect-Branch-Speculation-in-idle.patch
@@ -20,21 +20,13 @@ Originally-by: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
- arch/x86/include/asm/mwait.h | 14 ++++++++++++++
+ arch/x86/include/asm/mwait.h | 13 +++++++++++++
arch/x86/kernel/process.c | 14 ++++++++++++++
- 2 files changed, 28 insertions(+)
+ 2 files changed, 27 insertions(+)
--- a/arch/x86/include/asm/mwait.h
+++ b/arch/x86/include/asm/mwait.h
-@@ -5,6 +5,7 @@
- #include <linux/sched/idle.h>
-
- #include <asm/cpufeature.h>
-+#include <asm/nospec-branch.h>
-
- #define MWAIT_SUBSTATE_MASK 0xf
- #define MWAIT_CSTATE_MASK 0xf
-@@ -105,7 +106,20 @@ static inline void mwait_idle_with_hints
+@@ -112,7 +112,20 @@ static inline void mwait_idle_with_hints
mb();
}
@@ -57,7 +49,7 @@ Signed-off-by: Jiri Slaby <jslaby@suse.cz>
}
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
-@@ -465,6 +465,20 @@ static __cpuidle void mwait_idle(void)
+@@ -674,6 +674,20 @@ static __cpuidle void mwait_idle(void)
mb(); /* quirk */
}
diff --git a/patches.suse/0004-btrfs-Open-code-add_delayed_tree_ref.patch b/patches.suse/0004-btrfs-Open-code-add_delayed_tree_ref.patch
new file mode 100644
index 0000000000..b154cc6d0a
--- /dev/null
+++ b/patches.suse/0004-btrfs-Open-code-add_delayed_tree_ref.patch
@@ -0,0 +1,128 @@
+From 70d640004ab5c2597084f6463dd39b36f4f026f8 Mon Sep 17 00:00:00 2001
+From: Nikolay Borisov <nborisov@suse.com>
+Date: Tue, 24 Apr 2018 17:18:20 +0300
+Git-commit: 70d640004ab5c2597084f6463dd39b36f4f026f8
+Patch-mainline: v4.18
+References: bsc#1134813
+Subject: [PATCH 4/8] btrfs: Open-code add_delayed_tree_ref
+
+Now that the initialization part and the critical section code have been
+split it's a lot easier to open code add_delayed_tree_ref. Do so in the
+following manner:
+
+1. The comming init code is put immediately after memory-to-be-initialized
+ is allocated, followed by the ref-specific member initialization.
+
+2. The only piece of code that remains in the critical section is
+ insert_delayed_ref call.
+
+3. Tracing and memory freeing code is put outside of the critical
+ section as well.
+
+The only real change here is an overall shorter critical section when
+dealing with delayed tree refs. From functional point of view - the code
+is unchanged.
+
+Signed-off-by: Nikolay Borisov <nborisov@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/delayed-ref.c | 65 +++++++++++++++----------------------------------
+ 1 file changed, 20 insertions(+), 45 deletions(-)
+
+--- a/fs/btrfs/delayed-ref.c
++++ b/fs/btrfs/delayed-ref.c
+@@ -713,49 +713,6 @@ static void init_delayed_ref_common(stru
+ }
+
+ /*
+- * helper to insert a delayed tree ref into the rbtree.
+- */
+-static noinline void
+-add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
+- struct btrfs_trans_handle *trans,
+- struct btrfs_delayed_ref_head *head_ref,
+- struct btrfs_delayed_ref_node *ref, u64 bytenr,
+- u64 num_bytes, u64 parent, u64 ref_root, int level,
+- int action)
+-{
+- struct btrfs_delayed_tree_ref *full_ref;
+- struct btrfs_delayed_ref_root *delayed_refs;
+- u8 ref_type;
+- int ret;
+-
+- delayed_refs = &trans->transaction->delayed_refs;
+- full_ref = btrfs_delayed_node_to_tree_ref(ref);
+- if (parent)
+- ref_type = BTRFS_SHARED_BLOCK_REF_KEY;
+- else
+- ref_type = BTRFS_TREE_BLOCK_REF_KEY;
+-
+- init_delayed_ref_common(fs_info, ref, bytenr, num_bytes, ref_root,
+- action, ref_type);
+- full_ref->root = ref_root;
+- full_ref->parent = parent;
+- full_ref->level = level;
+-
+- trace_add_delayed_tree_ref(fs_info, ref, full_ref,
+- action == BTRFS_ADD_DELAYED_EXTENT ?
+- BTRFS_ADD_DELAYED_REF : action);
+-
+- ret = insert_delayed_ref(trans, delayed_refs, head_ref, ref);
+-
+- /*
+- * XXX: memory should be freed at the same level allocated.
+- * But bad practice is anywhere... Follow it now. Need cleanup.
+- */
+- if (ret > 0)
+- kmem_cache_free(btrfs_delayed_tree_ref_cachep, full_ref);
+-}
+-
+-/*
+ * helper to insert a delayed data ref into the rbtree.
+ */
+ static noinline void
+@@ -814,12 +771,24 @@ int btrfs_add_delayed_tree_ref(struct bt
+ struct btrfs_qgroup_extent_record *record = NULL;
+ int qrecord_inserted;
+ int is_system = (ref_root == BTRFS_CHUNK_TREE_OBJECTID);
++ int ret;
++ u8 ref_type;
+
+ BUG_ON(extent_op && extent_op->is_data);
+ ref = kmem_cache_alloc(btrfs_delayed_tree_ref_cachep, GFP_NOFS);
+ if (!ref)
+ return -ENOMEM;
+
++ if (parent)
++ ref_type = BTRFS_SHARED_BLOCK_REF_KEY;
++ else
++ ref_type = BTRFS_TREE_BLOCK_REF_KEY;
++ init_delayed_ref_common(fs_info, &ref->node, bytenr, num_bytes,
++ ref_root, action, ref_type);
++ ref->root = ref_root;
++ ref->parent = parent;
++ ref->level = level;
++
+ head_ref = kmem_cache_alloc(btrfs_delayed_ref_head_cachep, GFP_NOFS);
+ if (!head_ref)
+ goto free_ref;
+@@ -845,10 +814,16 @@ int btrfs_add_delayed_tree_ref(struct bt
+ is_system, &qrecord_inserted,
+ old_ref_mod, new_ref_mod);
+
+- add_delayed_tree_ref(fs_info, trans, head_ref, &ref->node, bytenr,
+- num_bytes, parent, ref_root, level, action);
++
++ ret = insert_delayed_ref(trans, delayed_refs, head_ref, &ref->node);
+ spin_unlock(&delayed_refs->lock);
+
++ trace_add_delayed_tree_ref(fs_info, &ref->node, ref,
++ action == BTRFS_ADD_DELAYED_EXTENT ?
++ BTRFS_ADD_DELAYED_REF : action);
++ if (ret > 0)
++ kmem_cache_free(btrfs_delayed_tree_ref_cachep, ref);
++
+ if (qrecord_inserted)
+ return btrfs_qgroup_trace_extent_post(fs_info, record);
+ return 0;
diff --git a/patches.suse/0004-btrfs-move-ref_mod-modification-into-the-if-ref-logi.patch b/patches.suse/0004-btrfs-move-ref_mod-modification-into-the-if-ref-logi.patch
new file mode 100644
index 0000000000..6ec779dbd3
--- /dev/null
+++ b/patches.suse/0004-btrfs-move-ref_mod-modification-into-the-if-ref-logi.patch
@@ -0,0 +1,46 @@
+From 1ce7a5ec44c8b148c4600e25c696a135319734db Mon Sep 17 00:00:00 2001
+From: Josef Bacik <josef@toxicpanda.com>
+Date: Fri, 29 Sep 2017 15:43:55 -0400
+Git-commit: 1ce7a5ec44c8b148c4600e25c696a135319734db
+Patch-mainline: 4.15
+References: bsc#1134813
+Subject: [PATCH 4/7] btrfs: move ref_mod modification into the if (ref) logic
+
+We only use this logic if our ref isn't a ref_head, so move it up into
+the if (ref) case since we know that this is a normal ref and not a
+delayed ref head.
+
+Signed-off-by: Josef Bacik <jbacik@fb.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/extent-tree.c | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
+index 5e61e9287b0e..0dcbbeacaadc 100644
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -2744,10 +2744,6 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
+ list_del(&ref->list);
+ if (!list_empty(&ref->add_list))
+ list_del(&ref->add_list);
+- }
+- atomic_dec(&delayed_refs->num_entries);
+-
+- if (!btrfs_delayed_ref_is_head(ref)) {
+ /*
+ * when we play the delayed ref, also correct the
+ * ref_mod on head
+@@ -2764,6 +2760,8 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
+ WARN_ON(1);
+ }
+ }
++ atomic_dec(&delayed_refs->num_entries);
++
+ /*
+ * Record the must-insert_reserved flag before we drop the spin
+ * lock.
+--
+2.21.0
+
diff --git a/patches.suse/0005-btrfs-Open-code-add_delayed_data_ref.patch b/patches.suse/0005-btrfs-Open-code-add_delayed_data_ref.patch
new file mode 100644
index 0000000000..4bb5260040
--- /dev/null
+++ b/patches.suse/0005-btrfs-Open-code-add_delayed_data_ref.patch
@@ -0,0 +1,125 @@
+From cd7f9699b113434467434580ebb8d9b328152fb8 Mon Sep 17 00:00:00 2001
+From: Nikolay Borisov <nborisov@suse.com>
+Date: Tue, 24 Apr 2018 17:18:21 +0300
+Git-commit: cd7f9699b113434467434580ebb8d9b328152fb8
+Patch-mainline: v4.18
+References: bsc#1134813
+Subject: [PATCH 5/8] btrfs: Open-code add_delayed_data_ref
+
+Now that the initialization part and the critical section code have been
+split it's a lot easier to open code add_delayed_data_ref. Do so in the
+following manner:
+
+1. The common init function is put immediately after memory-to-be-initialized
+ is allocated, followed by the specific data ref initialization.
+
+2. The only piece of code that remains in the critical section is
+ insert_delayed_ref call.
+
+3. Tracing and memory freeing code is moved outside of the critical
+ section.
+
+No functional changes, just an overall shorter critical section.
+
+Signed-off-by: Nikolay Borisov <nborisov@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/delayed-ref.c | 65 +++++++++++++++----------------------------------
+ 1 file changed, 21 insertions(+), 44 deletions(-)
+
+--- a/fs/btrfs/delayed-ref.c
++++ b/fs/btrfs/delayed-ref.c
+@@ -713,47 +713,6 @@ static void init_delayed_ref_common(stru
+ }
+
+ /*
+- * helper to insert a delayed data ref into the rbtree.
+- */
+-static noinline void
+-add_delayed_data_ref(struct btrfs_fs_info *fs_info,
+- struct btrfs_trans_handle *trans,
+- struct btrfs_delayed_ref_head *head_ref,
+- struct btrfs_delayed_ref_node *ref, u64 bytenr,
+- u64 num_bytes, u64 parent, u64 ref_root, u64 owner,
+- u64 offset, int action)
+-{
+- struct btrfs_delayed_data_ref *full_ref;
+- struct btrfs_delayed_ref_root *delayed_refs;
+- u8 ref_type;
+- int ret;
+-
+- delayed_refs = &trans->transaction->delayed_refs;
+-
+-
+- full_ref = btrfs_delayed_node_to_data_ref(ref);
+- if (parent)
+- ref_type = BTRFS_SHARED_DATA_REF_KEY;
+- else
+- ref_type = BTRFS_EXTENT_DATA_REF_KEY;
+-
+- init_delayed_ref_common(fs_info, ref, bytenr, num_bytes,
+- ref_root, action, ref_type);
+- full_ref->root = ref_root;
+- full_ref->parent = parent;
+- full_ref->objectid = owner;
+- full_ref->offset = offset;
+-
+- trace_add_delayed_data_ref(fs_info, ref, full_ref,
+- action == BTRFS_ADD_DELAYED_EXTENT ?
+- BTRFS_ADD_DELAYED_REF : action);
+-
+- ret = insert_delayed_ref(trans, delayed_refs, head_ref, ref);
+- if (ret > 0)
+- kmem_cache_free(btrfs_delayed_data_ref_cachep, full_ref);
+-}
+-
+-/*
+ * add a delayed tree ref. This does all of the accounting required
+ * to make sure the delayed ref is eventually processed before this
+ * transaction commits.
+@@ -851,11 +810,25 @@ int btrfs_add_delayed_data_ref(struct bt
+ struct btrfs_delayed_ref_root *delayed_refs;
+ struct btrfs_qgroup_extent_record *record = NULL;
+ int qrecord_inserted;
++ int ret;
++ u8 ref_type;
+
+ ref = kmem_cache_alloc(btrfs_delayed_data_ref_cachep, GFP_NOFS);
+ if (!ref)
+ return -ENOMEM;
+
++ if (parent)
++ ref_type = BTRFS_SHARED_DATA_REF_KEY;
++ else
++ ref_type = BTRFS_EXTENT_DATA_REF_KEY;
++ init_delayed_ref_common(fs_info, &ref->node, bytenr, num_bytes,
++ ref_root, action, ref_type);
++ ref->root = ref_root;
++ ref->parent = parent;
++ ref->objectid = owner;
++ ref->offset = offset;
++
++
+ head_ref = kmem_cache_alloc(btrfs_delayed_ref_head_cachep, GFP_NOFS);
+ if (!head_ref) {
+ kmem_cache_free(btrfs_delayed_data_ref_cachep, ref);
+@@ -887,11 +860,15 @@ int btrfs_add_delayed_data_ref(struct bt
+ action, 1, 0, &qrecord_inserted,
+ old_ref_mod, new_ref_mod);
+
+- add_delayed_data_ref(fs_info, trans, head_ref, &ref->node, bytenr,
+- num_bytes, parent, ref_root, owner, offset,
+- action);
++ ret = insert_delayed_ref(trans, delayed_refs, head_ref, &ref->node);
+ spin_unlock(&delayed_refs->lock);
+
++ trace_add_delayed_data_ref(trans->fs_info, &ref->node, ref,
++ action == BTRFS_ADD_DELAYED_EXTENT ?
++ BTRFS_ADD_DELAYED_REF : action);
++ if (ret > 0)
++ kmem_cache_free(btrfs_delayed_data_ref_cachep, ref);
++
+ if (qrecord_inserted)
+ return btrfs_qgroup_trace_extent_post(fs_info, record);
+ return 0;
diff --git a/patches.suse/0005-btrfs-move-all-ref-head-cleanup-to-the-helper-functi.patch b/patches.suse/0005-btrfs-move-all-ref-head-cleanup-to-the-helper-functi.patch
new file mode 100644
index 0000000000..6be92b2214
--- /dev/null
+++ b/patches.suse/0005-btrfs-move-all-ref-head-cleanup-to-the-helper-functi.patch
@@ -0,0 +1,211 @@
+From c1103f7a5d7a544dfdaca6102de68792909dc834 Mon Sep 17 00:00:00 2001
+From: Josef Bacik <josef@toxicpanda.com>
+Date: Fri, 29 Sep 2017 15:43:56 -0400
+Git-commit: c1103f7a5d7a544dfdaca6102de68792909dc834
+Patch-mainline: 4.15
+References: bsc#1134813
+Subject: [PATCH 5/7] btrfs: move all ref head cleanup to the helper function
+
+We do a couple different cleanup operations on the ref head. We adjust
+counters, we'll free any reserved space if we didn't end up using the
+ref, and we clear the pending csum bytes. Move all these disparate
+things into cleanup_ref_head and clean up the logic in
+__btrfs_run_delayed_refs so that it handles the !ref case a lot cleaner,
+as well as making run_one_delayed_ref() only deal with real refs and not
+the ref head.
+
+Signed-off-by: Josef Bacik <jbacik@fb.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/extent-tree.c | 145 ++++++++++++++++++-----------------------
+ 1 file changed, 64 insertions(+), 81 deletions(-)
+
+diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
+index 0dcbbeacaadc..628ae71094f2 100644
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -2500,44 +2500,6 @@ static int run_one_delayed_ref(struct btrfs_trans_handle *trans,
+ return 0;
+ }
+
+- if (btrfs_delayed_ref_is_head(node)) {
+- struct btrfs_delayed_ref_head *head;
+- /*
+- * we've hit the end of the chain and we were supposed
+- * to insert this extent into the tree. But, it got
+- * deleted before we ever needed to insert it, so all
+- * we have to do is clean up the accounting
+- */
+- BUG_ON(extent_op);
+- head = btrfs_delayed_node_to_head(node);
+- trace_run_delayed_ref_head(fs_info, node, head, node->action);
+-
+- if (head->total_ref_mod < 0) {
+- struct btrfs_block_group_cache *cache;
+-
+- cache = btrfs_lookup_block_group(fs_info, node->bytenr);
+- ASSERT(cache);
+- percpu_counter_add(&cache->space_info->total_bytes_pinned,
+- -node->num_bytes);
+- btrfs_put_block_group(cache);
+- }
+-
+- if (insert_reserved) {
+- btrfs_pin_extent(fs_info, node->bytenr,
+- node->num_bytes, 1);
+- if (head->is_data) {
+- ret = btrfs_del_csums(trans, fs_info,
+- node->bytenr,
+- node->num_bytes);
+- }
+- }
+-
+- /* Also free its reserved qgroup space */
+- btrfs_qgroup_free_delayed_ref(fs_info, head->qgroup_ref_root,
+- head->qgroup_reserved);
+- return ret;
+- }
+-
+ if (node->type == BTRFS_TREE_BLOCK_REF_KEY ||
+ node->type == BTRFS_SHARED_BLOCK_REF_KEY)
+ ret = run_delayed_tree_ref(trans, fs_info, node, extent_op,
+@@ -2639,6 +2601,43 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans,
+ delayed_refs->num_heads--;
+ rb_erase(&head->href_node, &delayed_refs->href_root);
+ spin_unlock(&delayed_refs->lock);
++ spin_unlock(&head->lock);
++ atomic_dec(&delayed_refs->num_entries);
++
++ trace_run_delayed_ref_head(fs_info, &head->node, head,
++ head->node.action);
++
++ if (head->total_ref_mod < 0) {
++ struct btrfs_block_group_cache *cache;
++
++ cache = btrfs_lookup_block_group(fs_info, head->node.bytenr);
++ ASSERT(cache);
++ percpu_counter_add(&cache->space_info->total_bytes_pinned,
++ -head->node.num_bytes);
++ btrfs_put_block_group(cache);
++
++ if (head->is_data) {
++ spin_lock(&delayed_refs->lock);
++ delayed_refs->pending_csums -= head->node.num_bytes;
++ spin_unlock(&delayed_refs->lock);
++ }
++ }
++
++ if (head->must_insert_reserved) {
++ btrfs_pin_extent(fs_info, head->node.bytenr,
++ head->node.num_bytes, 1);
++ if (head->is_data) {
++ ret = btrfs_del_csums(trans, fs_info,
++ head->node.bytenr,
++ head->node.num_bytes);
++ }
++ }
++
++ /* Also free its reserved qgroup space */
++ btrfs_qgroup_free_delayed_ref(fs_info, head->qgroup_ref_root,
++ head->qgroup_reserved);
++ btrfs_delayed_ref_unlock(head);
++ btrfs_put_delayed_ref(&head->node);
+ return 0;
+ }
+
+@@ -2722,6 +2721,10 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
+ continue;
+ }
+
++ /*
++ * We're done processing refs in this ref_head, clean everything
++ * up and move on to the next ref_head.
++ */
+ if (!ref) {
+ ret = cleanup_ref_head(trans, fs_info, locked_ref);
+ if (ret > 0 ) {
+@@ -2731,34 +2734,30 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
+ } else if (ret) {
+ return ret;
+ }
++ locked_ref = NULL;
++ count++;
++ continue;
++ }
+
+- /*
+- * All delayed refs have been processed, Go ahead and
+- * send the head node to run_one_delayed_ref, so that
+- * any accounting fixes can happen
+- */
+- ref = &locked_ref->node;
+- } else {
+- actual_count++;
+- ref->in_tree = 0;
+- list_del(&ref->list);
+- if (!list_empty(&ref->add_list))
+- list_del(&ref->add_list);
+- /*
+- * when we play the delayed ref, also correct the
+- * ref_mod on head
+- */
+- switch (ref->action) {
+- case BTRFS_ADD_DELAYED_REF:
+- case BTRFS_ADD_DELAYED_EXTENT:
+- locked_ref->node.ref_mod -= ref->ref_mod;
+- break;
+- case BTRFS_DROP_DELAYED_REF:
+- locked_ref->node.ref_mod += ref->ref_mod;
+- break;
+- default:
+- WARN_ON(1);
+- }
++ actual_count++;
++ ref->in_tree = 0;
++ list_del(&ref->list);
++ if (!list_empty(&ref->add_list))
++ list_del(&ref->add_list);
++ /*
++ * When we play the delayed ref, also correct the ref_mod on
++ * head
++ */
++ switch (ref->action) {
++ case BTRFS_ADD_DELAYED_REF:
++ case BTRFS_ADD_DELAYED_EXTENT:
++ locked_ref->node.ref_mod -= ref->ref_mod;
++ break;
++ case BTRFS_DROP_DELAYED_REF:
++ locked_ref->node.ref_mod += ref->ref_mod;
++ break;
++ default:
++ WARN_ON(1);
+ }
+ atomic_dec(&delayed_refs->num_entries);
+
+@@ -2785,22 +2784,6 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
+ return ret;
+ }
+
+- /*
+- * If this node is a head, that means all the refs in this head
+- * have been dealt with, and we will pick the next head to deal
+- * with, so we must unlock the head and drop it from the cluster
+- * list before we release it.
+- */
+- if (btrfs_delayed_ref_is_head(ref)) {
+- if (locked_ref->is_data &&
+- locked_ref->total_ref_mod < 0) {
+- spin_lock(&delayed_refs->lock);
+- delayed_refs->pending_csums -= ref->num_bytes;
+- spin_unlock(&delayed_refs->lock);
+- }
+- btrfs_delayed_ref_unlock(locked_ref);
+- locked_ref = NULL;
+- }
+ btrfs_put_delayed_ref(ref);
+ count++;
+ cond_resched();
+--
+2.21.0
+
diff --git a/patches.suse/0006-btrfs-Introduce-init_delayed_ref_head.patch b/patches.suse/0006-btrfs-Introduce-init_delayed_ref_head.patch
new file mode 100644
index 0000000000..1593956fc0
--- /dev/null
+++ b/patches.suse/0006-btrfs-Introduce-init_delayed_ref_head.patch
@@ -0,0 +1,102 @@
+From a2e569b3f2b138f2c25b4598cf4b18af8af39abd Mon Sep 17 00:00:00 2001
+From: Nikolay Borisov <nborisov@suse.com>
+Date: Tue, 24 Apr 2018 17:18:22 +0300
+Git-commit: a2e569b3f2b138f2c25b4598cf4b18af8af39abd
+Patch-mainline: v4.18
+References: bsc#1134813
+Subject: [PATCH 6/8] btrfs: Introduce init_delayed_ref_head
+
+add_delayed_ref_head implements the logic to both initialize a head_ref
+structure as well as perform the necessary operations to add it to the
+delayed ref machinery. This has resulted in a very cumebrsome interface
+with loads of parameters and code, which at first glance, looks very
+unwieldy. Begin untangling it by first extracting the initialization
+only code in its own function. It's more or less verbatim copy of the
+first part of add_delayed_ref_head.
+
+Signed-off-by: Nikolay Borisov <nborisov@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/delayed-ref.c | 65 ++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 65 insertions(+)
+
+diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
+index 3fa8ea5cbbc6..227094efd050 100644
+--- a/fs/btrfs/delayed-ref.c
++++ b/fs/btrfs/delayed-ref.c
+@@ -526,6 +526,71 @@ update_existing_head_ref(struct btrfs_delayed_ref_root *delayed_refs,
+ spin_unlock(&existing->lock);
+ }
+
++static void init_delayed_ref_head(struct btrfs_delayed_ref_head *head_ref,
++ struct btrfs_qgroup_extent_record *qrecord,
++ u64 bytenr, u64 num_bytes, u64 ref_root,
++ u64 reserved, int action, bool is_data,
++ bool is_system)
++{
++ int count_mod = 1;
++ int must_insert_reserved = 0;
++
++ /* If reserved is provided, it must be a data extent. */
++ BUG_ON(!is_data && reserved);
++
++ /*
++ * The head node stores the sum of all the mods, so dropping a ref
++ * should drop the sum in the head node by one.
++ */
++ if (action == BTRFS_UPDATE_DELAYED_HEAD)
++ count_mod = 0;
++ else if (action == BTRFS_DROP_DELAYED_REF)
++ count_mod = -1;
++
++ /*
++ * BTRFS_ADD_DELAYED_EXTENT means that we need to update the reserved
++ * accounting when the extent is finally added, or if a later
++ * modification deletes the delayed ref without ever inserting the
++ * extent into the extent allocation tree. ref->must_insert_reserved
++ * is the flag used to record that accounting mods are required.
++ *
++ * Once we record must_insert_reserved, switch the action to
++ * BTRFS_ADD_DELAYED_REF because other special casing is not required.
++ */
++ if (action == BTRFS_ADD_DELAYED_EXTENT)
++ must_insert_reserved = 1;
++ else
++ must_insert_reserved = 0;
++
++ refcount_set(&head_ref->refs, 1);
++ head_ref->bytenr = bytenr;
++ head_ref->num_bytes = num_bytes;
++ head_ref->ref_mod = count_mod;
++ head_ref->must_insert_reserved = must_insert_reserved;
++ head_ref->is_data = is_data;
++ head_ref->is_system = is_system;
++ head_ref->ref_tree = RB_ROOT;
++ INIT_LIST_HEAD(&head_ref->ref_add_list);
++ RB_CLEAR_NODE(&head_ref->href_node);
++ head_ref->processing = 0;
++ head_ref->total_ref_mod = count_mod;
++ head_ref->qgroup_reserved = 0;
++ head_ref->qgroup_ref_root = 0;
++ spin_lock_init(&head_ref->lock);
++ mutex_init(&head_ref->mutex);
++
++ if (qrecord) {
++ if (ref_root && reserved) {
++ head_ref->qgroup_ref_root = ref_root;
++ head_ref->qgroup_reserved = reserved;
++ }
++
++ qrecord->bytenr = bytenr;
++ qrecord->num_bytes = num_bytes;
++ qrecord->old_roots = NULL;
++ }
++}
++
+ /*
+ * helper function to actually insert a head node into the rbtree.
+ * this does all the dirty work in terms of maintaining the correct
+--
+2.21.0
+
diff --git a/patches.suse/0006-btrfs-remove-delayed_ref_node-from-ref_head.patch b/patches.suse/0006-btrfs-remove-delayed_ref_node-from-ref_head.patch
new file mode 100644
index 0000000000..72ff11a51c
--- /dev/null
+++ b/patches.suse/0006-btrfs-remove-delayed_ref_node-from-ref_head.patch
@@ -0,0 +1,780 @@
+From d278850eff3053ef166cf64c16f798dfe36278a2 Mon Sep 17 00:00:00 2001
+From: Josef Bacik <josef@toxicpanda.com>
+Date: Fri, 29 Sep 2017 15:43:57 -0400
+Git-commit: d278850eff3053ef166cf64c16f798dfe36278a2
+Patch-mainline: 4.15
+References: bsc#1134813
+Subject: [PATCH 6/7] btrfs: remove delayed_ref_node from ref_head
+
+This is just excessive information in the ref_head, and makes the code
+complicated. It is a relic from when we had the heads and the refs in
+the same tree, which is no longer the case. With this removal I've
+cleaned up a bunch of the cruft around this old assumption as well.
+
+Signed-off-by: Josef Bacik <jbacik@fb.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/backref.c | 4 +-
+ fs/btrfs/delayed-ref.c | 126 +++++++++++++++--------------------
+ fs/btrfs/delayed-ref.h | 49 +++++---------
+ fs/btrfs/disk-io.c | 12 ++--
+ fs/btrfs/extent-tree.c | 90 ++++++++++---------------
+ include/trace/events/btrfs.h | 13 ++--
+ 6 files changed, 119 insertions(+), 175 deletions(-)
+
+diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
+index b517ef1477ea..33cba1abf8b6 100644
+--- a/fs/btrfs/backref.c
++++ b/fs/btrfs/backref.c
+@@ -1178,7 +1178,7 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
+ head = btrfs_find_delayed_ref_head(delayed_refs, bytenr);
+ if (head) {
+ if (!mutex_trylock(&head->mutex)) {
+- refcount_inc(&head->node.refs);
++ refcount_inc(&head->refs);
+ spin_unlock(&delayed_refs->lock);
+
+ btrfs_release_path(path);
+@@ -1189,7 +1189,7 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
+ */
+ mutex_lock(&head->mutex);
+ mutex_unlock(&head->mutex);
+- btrfs_put_delayed_ref(&head->node);
++ btrfs_put_delayed_ref_head(head);
+ goto again;
+ }
+ spin_unlock(&delayed_refs->lock);
+diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
+index 93ffa898df6d..b9b41c838da4 100644
+--- a/fs/btrfs/delayed-ref.c
++++ b/fs/btrfs/delayed-ref.c
+@@ -96,15 +96,15 @@ static struct btrfs_delayed_ref_head *htree_insert(struct rb_root *root,
+ u64 bytenr;
+
+ ins = rb_entry(node, struct btrfs_delayed_ref_head, href_node);
+- bytenr = ins->node.bytenr;
++ bytenr = ins->bytenr;
+ while (*p) {
+ parent_node = *p;
+ entry = rb_entry(parent_node, struct btrfs_delayed_ref_head,
+ href_node);
+
+- if (bytenr < entry->node.bytenr)
++ if (bytenr < entry->bytenr)
+ p = &(*p)->rb_left;
+- else if (bytenr > entry->node.bytenr)
++ else if (bytenr > entry->bytenr)
+ p = &(*p)->rb_right;
+ else
+ return entry;
+@@ -133,15 +133,15 @@ find_ref_head(struct rb_root *root, u64 bytenr,
+ while (n) {
+ entry = rb_entry(n, struct btrfs_delayed_ref_head, href_node);
+
+- if (bytenr < entry->node.bytenr)
++ if (bytenr < entry->bytenr)
+ n = n->rb_left;
+- else if (bytenr > entry->node.bytenr)
++ else if (bytenr > entry->bytenr)
+ n = n->rb_right;
+ else
+ return entry;
+ }
+ if (entry && return_bigger) {
+- if (bytenr > entry->node.bytenr) {
++ if (bytenr > entry->bytenr) {
+ n = rb_next(&entry->href_node);
+ if (!n)
+ n = rb_first(root);
+@@ -164,17 +164,17 @@ int btrfs_delayed_ref_lock(struct btrfs_trans_handle *trans,
+ if (mutex_trylock(&head->mutex))
+ return 0;
+
+- refcount_inc(&head->node.refs);
++ refcount_inc(&head->refs);
+ spin_unlock(&delayed_refs->lock);
+
+ mutex_lock(&head->mutex);
+ spin_lock(&delayed_refs->lock);
+- if (!head->node.in_tree) {
++ if (RB_EMPTY_NODE(&head->href_node)) {
+ mutex_unlock(&head->mutex);
+- btrfs_put_delayed_ref(&head->node);
++ btrfs_put_delayed_ref_head(head);
+ return -EAGAIN;
+ }
+- btrfs_put_delayed_ref(&head->node);
++ btrfs_put_delayed_ref_head(head);
+ return 0;
+ }
+
+@@ -183,15 +183,10 @@ static inline void drop_delayed_ref(struct btrfs_trans_handle *trans,
+ struct btrfs_delayed_ref_head *head,
+ struct btrfs_delayed_ref_node *ref)
+ {
+- if (btrfs_delayed_ref_is_head(ref)) {
+- head = btrfs_delayed_node_to_head(ref);
+- rb_erase(&head->href_node, &delayed_refs->href_root);
+- } else {
+- assert_spin_locked(&head->lock);
+- list_del(&ref->list);
+- if (!list_empty(&ref->add_list))
+- list_del(&ref->add_list);
+- }
++ assert_spin_locked(&head->lock);
++ list_del(&ref->list);
++ if (!list_empty(&ref->add_list))
++ list_del(&ref->add_list);
+ ref->in_tree = 0;
+ btrfs_put_delayed_ref(ref);
+ atomic_dec(&delayed_refs->num_entries);
+@@ -380,8 +375,8 @@ btrfs_select_ref_head(struct btrfs_trans_handle *trans)
+ head->processing = 1;
+ WARN_ON(delayed_refs->num_heads_ready == 0);
+ delayed_refs->num_heads_ready--;
+- delayed_refs->run_delayed_start = head->node.bytenr +
+- head->node.num_bytes;
++ delayed_refs->run_delayed_start = head->bytenr +
++ head->num_bytes;
+ return head;
+ }
+
+@@ -469,20 +464,16 @@ add_delayed_ref_tail_merge(struct btrfs_trans_handle *trans,
+ */
+ static noinline void
+ update_existing_head_ref(struct btrfs_delayed_ref_root *delayed_refs,
+- struct btrfs_delayed_ref_node *existing,
+- struct btrfs_delayed_ref_node *update,
++ struct btrfs_delayed_ref_head *existing,
++ struct btrfs_delayed_ref_head *update,
+ int *old_ref_mod_ret)
+ {
+- struct btrfs_delayed_ref_head *existing_ref;
+- struct btrfs_delayed_ref_head *ref;
+ int old_ref_mod;
+
+- existing_ref = btrfs_delayed_node_to_head(existing);
+- ref = btrfs_delayed_node_to_head(update);
+- BUG_ON(existing_ref->is_data != ref->is_data);
++ BUG_ON(existing->is_data != update->is_data);
+
+- spin_lock(&existing_ref->lock);
+- if (ref->must_insert_reserved) {
++ spin_lock(&existing->lock);
++ if (update->must_insert_reserved) {
+ /* if the extent was freed and then
+ * reallocated before the delayed ref
+ * entries were processed, we can end up
+@@ -490,7 +481,7 @@ update_existing_head_ref(struct btrfs_delayed_ref_root *delayed_refs,
+ * the must_insert_reserved flag set.
+ * Set it again here
+ */
+- existing_ref->must_insert_reserved = ref->must_insert_reserved;
++ existing->must_insert_reserved = update->must_insert_reserved;
+
+ /*
+ * update the num_bytes so we make sure the accounting
+@@ -500,22 +491,22 @@ update_existing_head_ref(struct btrfs_delayed_ref_root *delayed_refs,
+
+ }
+
+- if (ref->extent_op) {
+- if (!existing_ref->extent_op) {
+- existing_ref->extent_op = ref->extent_op;
++ if (update->extent_op) {
++ if (!existing->extent_op) {
++ existing->extent_op = update->extent_op;
+ } else {
+- if (ref->extent_op->update_key) {
+- memcpy(&existing_ref->extent_op->key,
+- &ref->extent_op->key,
+- sizeof(ref->extent_op->key));
+- existing_ref->extent_op->update_key = true;
++ if (update->extent_op->update_key) {
++ memcpy(&existing->extent_op->key,
++ &update->extent_op->key,
++ sizeof(update->extent_op->key));
++ existing->extent_op->update_key = true;
+ }
+- if (ref->extent_op->update_flags) {
+- existing_ref->extent_op->flags_to_set |=
+- ref->extent_op->flags_to_set;
+- existing_ref->extent_op->update_flags = true;
++ if (update->extent_op->update_flags) {
++ existing->extent_op->flags_to_set |=
++ update->extent_op->flags_to_set;
++ existing->extent_op->update_flags = true;
+ }
+- btrfs_free_delayed_extent_op(ref->extent_op);
++ btrfs_free_delayed_extent_op(update->extent_op);
+ }
+ }
+ /*
+@@ -523,23 +514,23 @@ update_existing_head_ref(struct btrfs_delayed_ref_root *delayed_refs,
+ * only need the lock for this case cause we could be processing it
+ * currently, for refs we just added we know we're a-ok.
+ */
+- old_ref_mod = existing_ref->total_ref_mod;
++ old_ref_mod = existing->total_ref_mod;
+ if (old_ref_mod_ret)
+ *old_ref_mod_ret = old_ref_mod;
+ existing->ref_mod += update->ref_mod;
+- existing_ref->total_ref_mod += update->ref_mod;
++ existing->total_ref_mod += update->ref_mod;
+
+ /*
+ * If we are going to from a positive ref mod to a negative or vice
+ * versa we need to make sure to adjust pending_csums accordingly.
+ */
+- if (existing_ref->is_data) {
+- if (existing_ref->total_ref_mod >= 0 && old_ref_mod < 0)
++ if (existing->is_data) {
++ if (existing->total_ref_mod >= 0 && old_ref_mod < 0)
+ delayed_refs->pending_csums -= existing->num_bytes;
+- if (existing_ref->total_ref_mod < 0 && old_ref_mod >= 0)
++ if (existing->total_ref_mod < 0 && old_ref_mod >= 0)
+ delayed_refs->pending_csums += existing->num_bytes;
+ }
+- spin_unlock(&existing_ref->lock);
++ spin_unlock(&existing->lock);
+ }
+
+ /*
+@@ -550,14 +541,13 @@ update_existing_head_ref(struct btrfs_delayed_ref_root *delayed_refs,
+ static noinline struct btrfs_delayed_ref_head *
+ add_delayed_ref_head(struct btrfs_fs_info *fs_info,
+ struct btrfs_trans_handle *trans,
+- struct btrfs_delayed_ref_node *ref,
++ struct btrfs_delayed_ref_head *head_ref,
+ struct btrfs_qgroup_extent_record *qrecord,
+ u64 bytenr, u64 num_bytes, u64 ref_root, u64 reserved,
+ int action, int is_data, int *qrecord_inserted_ret,
+ int *old_ref_mod, int *new_ref_mod)
+ {
+ struct btrfs_delayed_ref_head *existing;
+- struct btrfs_delayed_ref_head *head_ref = NULL;
+ struct btrfs_delayed_ref_root *delayed_refs;
+ int count_mod = 1;
+ int must_insert_reserved = 0;
+@@ -593,26 +583,21 @@ add_delayed_ref_head(struct btrfs_fs_info *fs_info,
+
+ delayed_refs = &trans->transaction->delayed_refs;
+
+- /* first set the basic ref node struct up */
+- refcount_set(&ref->refs, 1);
+- ref->bytenr = bytenr;
+- ref->num_bytes = num_bytes;
+- ref->ref_mod = count_mod;
+- ref->type = 0;
+- ref->action = 0;
+- ref->is_head = 1;
+- ref->in_tree = 1;
+- ref->seq = 0;
+-
+- head_ref = btrfs_delayed_node_to_head(ref);
++ refcount_set(&head_ref->refs, 1);
++ head_ref->bytenr = bytenr;
++ head_ref->num_bytes = num_bytes;
++ head_ref->ref_mod = count_mod;
+ head_ref->must_insert_reserved = must_insert_reserved;
+ head_ref->is_data = is_data;
+ INIT_LIST_HEAD(&head_ref->ref_list);
+ INIT_LIST_HEAD(&head_ref->ref_add_list);
++ RB_CLEAR_NODE(&head_ref->href_node);
+ head_ref->processing = 0;
+ head_ref->total_ref_mod = count_mod;
+ head_ref->qgroup_reserved = 0;
+ head_ref->qgroup_ref_root = 0;
++ spin_lock_init(&head_ref->lock);
++ mutex_init(&head_ref->mutex);
+
+ /* Record qgroup extent info if provided */
+ if (qrecord) {
+@@ -632,17 +617,14 @@ add_delayed_ref_head(struct btrfs_fs_info *fs_info,
+ qrecord_inserted = 1;
+ }
+
+- spin_lock_init(&head_ref->lock);
+- mutex_init(&head_ref->mutex);
+-
+- trace_add_delayed_ref_head(fs_info, ref, head_ref, action);
++ trace_add_delayed_ref_head(fs_info, head_ref, action);
+
+ existing = htree_insert(&delayed_refs->href_root,
+ &head_ref->href_node);
+ if (existing) {
+ WARN_ON(ref_root && reserved && existing->qgroup_ref_root
+ && existing->qgroup_reserved);
+- update_existing_head_ref(delayed_refs, &existing->node, ref,
++ update_existing_head_ref(delayed_refs, existing, head_ref,
+ old_ref_mod);
+ /*
+ * we've updated the existing ref, free the newly
+@@ -821,7 +803,7 @@ int btrfs_add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
+ * insert both the head node and the new ref without dropping
+ * the spin lock
+ */
+- head_ref = add_delayed_ref_head(fs_info, trans, &head_ref->node, record,
++ head_ref = add_delayed_ref_head(fs_info, trans, head_ref, record,
+ bytenr, num_bytes, 0, 0, action, 0,
+ &qrecord_inserted, old_ref_mod,
+ new_ref_mod);
+@@ -888,7 +870,7 @@ int btrfs_add_delayed_data_ref(struct btrfs_fs_info *fs_info,
+ * insert both the head node and the new ref without dropping
+ * the spin lock
+ */
+- head_ref = add_delayed_ref_head(fs_info, trans, &head_ref->node, record,
++ head_ref = add_delayed_ref_head(fs_info, trans, head_ref, record,
+ bytenr, num_bytes, ref_root, reserved,
+ action, 1, &qrecord_inserted,
+ old_ref_mod, new_ref_mod);
+@@ -920,7 +902,7 @@ int btrfs_add_delayed_extent_op(struct btrfs_fs_info *fs_info,
+ delayed_refs = &trans->transaction->delayed_refs;
+ spin_lock(&delayed_refs->lock);
+
+- add_delayed_ref_head(fs_info, trans, &head_ref->node, NULL, bytenr,
++ add_delayed_ref_head(fs_info, trans, head_ref, NULL, bytenr,
+ num_bytes, 0, 0, BTRFS_UPDATE_DELAYED_HEAD,
+ extent_op->is_data, NULL, NULL, NULL);
+
+diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h
+index ce88e4ac5276..1ce11858d727 100644
+--- a/fs/btrfs/delayed-ref.h
++++ b/fs/btrfs/delayed-ref.h
+@@ -26,15 +26,6 @@
+ #define BTRFS_ADD_DELAYED_EXTENT 3 /* record a full extent allocation */
+ #define BTRFS_UPDATE_DELAYED_HEAD 4 /* not changing ref count on head ref */
+
+-/*
+- * XXX: Qu: I really hate the design that ref_head and tree/data ref shares the
+- * same ref_node structure.
+- * Ref_head is in a higher logic level than tree/data ref, and duplicated
+- * bytenr/num_bytes in ref_node is really a waste or memory, they should be
+- * referred from ref_head.
+- * This gets more disgusting after we use list to store tree/data ref in
+- * ref_head. Must clean this mess up later.
+- */
+ struct btrfs_delayed_ref_node {
+ /*data/tree ref use list, stored in ref_head->ref_list. */
+ struct list_head list;
+@@ -91,8 +82,9 @@ struct btrfs_delayed_extent_op {
+ * reference count modifications we've queued up.
+ */
+ struct btrfs_delayed_ref_head {
+- struct btrfs_delayed_ref_node node;
+-
++ u64 bytenr;
++ u64 num_bytes;
++ refcount_t refs;
+ /*
+ * the mutex is held while running the refs, and it is also
+ * held when checking the sum of reference modifications.
+@@ -115,6 +107,14 @@ struct btrfs_delayed_ref_head {
+ */
+ int total_ref_mod;
+
++ /*
++ * This is the current outstanding mod references for this bytenr. This
++ * is used with lookup_extent_info to get an accurate reference count
++ * for a bytenr, so it is adjusted as delayed refs are run so that any
++ * on disk reference count + ref_mod is accurate.
++ */
++ int ref_mod;
++
+ /*
+ * For qgroup reserved space freeing.
+ *
+@@ -234,15 +234,18 @@ static inline void btrfs_put_delayed_ref(struct btrfs_delayed_ref_node *ref)
+ case BTRFS_SHARED_DATA_REF_KEY:
+ kmem_cache_free(btrfs_delayed_data_ref_cachep, ref);
+ break;
+- case 0:
+- kmem_cache_free(btrfs_delayed_ref_head_cachep, ref);
+- break;
+ default:
+ BUG();
+ }
+ }
+ }
+
++static inline void btrfs_put_delayed_ref_head(struct btrfs_delayed_ref_head *head)
++{
++ if (refcount_dec_and_test(&head->refs))
++ kmem_cache_free(btrfs_delayed_ref_head_cachep, head);
++}
++
+ int btrfs_add_delayed_tree_ref(struct btrfs_fs_info *fs_info,
+ struct btrfs_trans_handle *trans,
+ u64 bytenr, u64 num_bytes, u64 parent,
+@@ -282,36 +285,18 @@ int btrfs_check_delayed_seq(struct btrfs_fs_info *fs_info,
+ struct btrfs_delayed_ref_root *delayed_refs,
+ u64 seq);
+
+-/*
+- * a node might live in a head or a regular ref, this lets you
+- * test for the proper type to use.
+- */
+-static int btrfs_delayed_ref_is_head(struct btrfs_delayed_ref_node *node)
+-{
+- return node->is_head;
+-}
+-
+ /*
+ * helper functions to cast a node into its container
+ */
+ static inline struct btrfs_delayed_tree_ref *
+ btrfs_delayed_node_to_tree_ref(struct btrfs_delayed_ref_node *node)
+ {
+- WARN_ON(btrfs_delayed_ref_is_head(node));
+ return container_of(node, struct btrfs_delayed_tree_ref, node);
+ }
+
+ static inline struct btrfs_delayed_data_ref *
+ btrfs_delayed_node_to_data_ref(struct btrfs_delayed_ref_node *node)
+ {
+- WARN_ON(btrfs_delayed_ref_is_head(node));
+ return container_of(node, struct btrfs_delayed_data_ref, node);
+ }
+-
+-static inline struct btrfs_delayed_ref_head *
+-btrfs_delayed_node_to_head(struct btrfs_delayed_ref_node *node)
+-{
+- WARN_ON(!btrfs_delayed_ref_is_head(node));
+- return container_of(node, struct btrfs_delayed_ref_head, node);
+-}
+ #endif
+diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
+index f971d5680e6f..69ce738c00d0 100644
+--- a/fs/btrfs/disk-io.c
++++ b/fs/btrfs/disk-io.c
+@@ -4121,12 +4121,12 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
+ head = rb_entry(node, struct btrfs_delayed_ref_head,
+ href_node);
+ if (!mutex_trylock(&head->mutex)) {
+- refcount_inc(&head->node.refs);
++ refcount_inc(&head->refs);
+ spin_unlock(&delayed_refs->lock);
+
+ mutex_lock(&head->mutex);
+ mutex_unlock(&head->mutex);
+- btrfs_put_delayed_ref(&head->node);
++ btrfs_put_delayed_ref_head(head);
+ spin_lock(&delayed_refs->lock);
+ continue;
+ }
+@@ -4147,16 +4147,16 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
+ if (head->processing == 0)
+ delayed_refs->num_heads_ready--;
+ atomic_dec(&delayed_refs->num_entries);
+- head->node.in_tree = 0;
+ rb_erase(&head->href_node, &delayed_refs->href_root);
++ RB_CLEAR_NODE(&head->href_node);
+ spin_unlock(&head->lock);
+ spin_unlock(&delayed_refs->lock);
+ mutex_unlock(&head->mutex);
+
+ if (pin_bytes)
+- btrfs_pin_extent(fs_info, head->node.bytenr,
+- head->node.num_bytes, 1);
+- btrfs_put_delayed_ref(&head->node);
++ btrfs_pin_extent(fs_info, head->bytenr,
++ head->num_bytes, 1);
++ btrfs_put_delayed_ref_head(head);
+ cond_resched();
+ spin_lock(&delayed_refs->lock);
+ }
+diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
+index 628ae71094f2..423d89145bac 100644
+--- a/fs/btrfs/extent-tree.c
++++ b/fs/btrfs/extent-tree.c
+@@ -912,7 +912,7 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
+ head = btrfs_find_delayed_ref_head(delayed_refs, bytenr);
+ if (head) {
+ if (!mutex_trylock(&head->mutex)) {
+- refcount_inc(&head->node.refs);
++ refcount_inc(&head->refs);
+ spin_unlock(&delayed_refs->lock);
+
+ btrfs_release_path(path);
+@@ -923,7 +923,7 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
+ */
+ mutex_lock(&head->mutex);
+ mutex_unlock(&head->mutex);
+- btrfs_put_delayed_ref(&head->node);
++ btrfs_put_delayed_ref_head(head);
+ goto search_again;
+ }
+ spin_lock(&head->lock);
+@@ -932,7 +932,7 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
+ else
+ BUG_ON(num_refs == 0);
+
+- num_refs += head->node.ref_mod;
++ num_refs += head->ref_mod;
+ spin_unlock(&head->lock);
+ mutex_unlock(&head->mutex);
+ }
+@@ -2337,7 +2337,7 @@ static void __run_delayed_extent_op(struct btrfs_delayed_extent_op *extent_op,
+
+ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
+ struct btrfs_fs_info *fs_info,
+- struct btrfs_delayed_ref_node *node,
++ struct btrfs_delayed_ref_head *head,
+ struct btrfs_delayed_extent_op *extent_op)
+ {
+ struct btrfs_key key;
+@@ -2359,14 +2359,14 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
+ if (!path)
+ return -ENOMEM;
+
+- key.objectid = node->bytenr;
++ key.objectid = head->bytenr;
+
+ if (metadata) {
+ key.type = BTRFS_METADATA_ITEM_KEY;
+ key.offset = extent_op->level;
+ } else {
+ key.type = BTRFS_EXTENT_ITEM_KEY;
+- key.offset = node->num_bytes;
++ key.offset = head->num_bytes;
+ }
+
+ again:
+@@ -2383,17 +2383,17 @@ static int run_delayed_extent_op(struct btrfs_trans_handle *trans,
+ path->slots[0]--;
+ btrfs_item_key_to_cpu(path->nodes[0], &key,
+ path->slots[0]);
+- if (key.objectid == node->bytenr &&
++ if (key.objectid == head->bytenr &&
+ key.type == BTRFS_EXTENT_ITEM_KEY &&
+- key.offset == node->num_bytes)
++ key.offset == head->num_bytes)
+ ret = 0;
+ }
+ if (ret > 0) {
+ btrfs_release_path(path);
+ metadata = 0;
+
+- key.objectid = node->bytenr;
+- key.offset = node->num_bytes;
++ key.objectid = head->bytenr;
++ key.offset = head->num_bytes;
+ key.type = BTRFS_EXTENT_ITEM_KEY;
+ goto again;
+ }
+@@ -2562,7 +2562,7 @@ static int cleanup_extent_op(struct btrfs_trans_handle *trans,
+ return 0;
+ }
+ spin_unlock(&head->lock);
+- ret = run_delayed_extent_op(trans, fs_info, &head->node, extent_op);
++ ret = run_delayed_extent_op(trans, fs_info, head, extent_op);
+ btrfs_free_delayed_extent_op(extent_op);
+ return ret ? ret : 1;
+ }
+@@ -2597,39 +2597,37 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans,
+ spin_unlock(&delayed_refs->lock);
+ return 1;
+ }
+- head->node.in_tree = 0;
+ delayed_refs->num_heads--;
+ rb_erase(&head->href_node, &delayed_refs->href_root);
++ RB_CLEAR_NODE(&head->href_node);
+ spin_unlock(&delayed_refs->lock);
+ spin_unlock(&head->lock);
+ atomic_dec(&delayed_refs->num_entries);
+
+- trace_run_delayed_ref_head(fs_info, &head->node, head,
+- head->node.action);
++ trace_run_delayed_ref_head(fs_info, head, 0);
+
+ if (head->total_ref_mod < 0) {
+ struct btrfs_block_group_cache *cache;
+
+- cache = btrfs_lookup_block_group(fs_info, head->node.bytenr);
++ cache = btrfs_lookup_block_group(fs_info, head->bytenr);
+ ASSERT(cache);
+ percpu_counter_add(&cache->space_info->total_bytes_pinned,
+- -head->node.num_bytes);
++ -head->num_bytes);
+ btrfs_put_block_group(cache);
+
+ if (head->is_data) {
+ spin_lock(&delayed_refs->lock);
+- delayed_refs->pending_csums -= head->node.num_bytes;
++ delayed_refs->pending_csums -= head->num_bytes;
+ spin_unlock(&delayed_refs->lock);
+ }
+ }
+
+ if (head->must_insert_reserved) {
+- btrfs_pin_extent(fs_info, head->node.bytenr,
+- head->node.num_bytes, 1);
++ btrfs_pin_extent(fs_info, head->bytenr,
++ head->num_bytes, 1);
+ if (head->is_data) {
+- ret = btrfs_del_csums(trans, fs_info,
+- head->node.bytenr,
+- head->node.num_bytes);
++ ret = btrfs_del_csums(trans, fs_info, head->bytenr,
++ head->num_bytes);
+ }
+ }
+
+@@ -2637,7 +2635,7 @@ static int cleanup_ref_head(struct btrfs_trans_handle *trans,
+ btrfs_qgroup_free_delayed_ref(fs_info, head->qgroup_ref_root,
+ head->qgroup_reserved);
+ btrfs_delayed_ref_unlock(head);
+- btrfs_put_delayed_ref(&head->node);
++ btrfs_put_delayed_ref_head(head);
+ return 0;
+ }
+
+@@ -2751,10 +2749,10 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
+ switch (ref->action) {
+ case BTRFS_ADD_DELAYED_REF:
+ case BTRFS_ADD_DELAYED_EXTENT:
+- locked_ref->node.ref_mod -= ref->ref_mod;
++ locked_ref->ref_mod -= ref->ref_mod;
+ break;
+ case BTRFS_DROP_DELAYED_REF:
+- locked_ref->node.ref_mod += ref->ref_mod;
++ locked_ref->ref_mod += ref->ref_mod;
+ break;
+ default:
+ WARN_ON(1);
+@@ -3087,33 +3085,16 @@ int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
+ spin_unlock(&delayed_refs->lock);
+ goto out;
+ }
++ head = rb_entry(node, struct btrfs_delayed_ref_head,
++ href_node);
++ refcount_inc(&head->refs);
++ spin_unlock(&delayed_refs->lock);
+
+- while (node) {
+- head = rb_entry(node, struct btrfs_delayed_ref_head,
+- href_node);
+- if (btrfs_delayed_ref_is_head(&head->node)) {
+- struct btrfs_delayed_ref_node *ref;
+-
+- ref = &head->node;
+- refcount_inc(&ref->refs);
+-
+- spin_unlock(&delayed_refs->lock);
+- /*
+- * Mutex was contended, block until it's
+- * released and try again
+- */
+- mutex_lock(&head->mutex);
+- mutex_unlock(&head->mutex);
++ /* Mutex was contended, block until it's released and retry. */
++ mutex_lock(&head->mutex);
++ mutex_unlock(&head->mutex);
+
+- btrfs_put_delayed_ref(ref);
+- cond_resched();
+- goto again;
+- } else {
+- WARN_ON(1);
+- }
+- node = rb_next(node);
+- }
+- spin_unlock(&delayed_refs->lock);
++ btrfs_put_delayed_ref_head(head);
+ cond_resched();
+ goto again;
+ }
+@@ -3171,7 +3152,7 @@ static noinline int check_delayed_ref(struct btrfs_root *root,
+ }
+
+ if (!mutex_trylock(&head->mutex)) {
+- refcount_inc(&head->node.refs);
++ refcount_inc(&head->refs);
+ spin_unlock(&delayed_refs->lock);
+
+ btrfs_release_path(path);
+@@ -3182,7 +3163,7 @@ static noinline int check_delayed_ref(struct btrfs_root *root,
+ */
+ mutex_lock(&head->mutex);
+ mutex_unlock(&head->mutex);
+- btrfs_put_delayed_ref(&head->node);
++ btrfs_put_delayed_ref_head(head);
+ return -EAGAIN;
+ }
+ spin_unlock(&delayed_refs->lock);
+@@ -7235,9 +7216,8 @@ static noinline int check_ref_cleanup(struct btrfs_trans_handle *trans,
+ * at this point we have a head with no other entries. Go
+ * ahead and process it.
+ */
+- head->node.in_tree = 0;
+ rb_erase(&head->href_node, &delayed_refs->href_root);
+-
++ RB_CLEAR_NODE(&head->href_node);
+ atomic_dec(&delayed_refs->num_entries);
+
+ /*
+@@ -7256,7 +7236,7 @@ static noinline int check_ref_cleanup(struct btrfs_trans_handle *trans,
+ ret = 1;
+
+ mutex_unlock(&head->mutex);
+- btrfs_put_delayed_ref(&head->node);
++ btrfs_put_delayed_ref_head(head);
+ return ret;
+ out:
+ spin_unlock(&head->lock);
+diff --git a/include/trace/events/btrfs.h b/include/trace/events/btrfs.h
+index 77437f545c63..bfe2f23b578c 100644
+--- a/include/trace/events/btrfs.h
++++ b/include/trace/events/btrfs.h
+@@ -798,11 +798,10 @@ DEFINE_EVENT(btrfs_delayed_data_ref, run_delayed_data_ref,
+ DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
+
+ TP_PROTO(const struct btrfs_fs_info *fs_info,
+- const struct btrfs_delayed_ref_node *ref,
+ const struct btrfs_delayed_ref_head *head_ref,
+ int action),
+
+- TP_ARGS(fs_info, ref, head_ref, action),
++ TP_ARGS(fs_info, head_ref, action),
+
+ TP_STRUCT__entry_btrfs(
+ __field( u64, bytenr )
+@@ -812,8 +811,8 @@ DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
+ ),
+
+ TP_fast_assign_btrfs(fs_info,
+- __entry->bytenr = ref->bytenr;
+- __entry->num_bytes = ref->num_bytes;
++ __entry->bytenr = head_ref->bytenr;
++ __entry->num_bytes = head_ref->num_bytes;
+ __entry->action = action;
+ __entry->is_data = head_ref->is_data;
+ ),
+@@ -828,21 +827,19 @@ DECLARE_EVENT_CLASS(btrfs_delayed_ref_head,
+ DEFINE_EVENT(btrfs_delayed_ref_head, add_delayed_ref_head,
+
+ TP_PROTO(const struct btrfs_fs_info *fs_info,
+- const struct btrfs_delayed_ref_node *ref,
+ const struct btrfs_delayed_ref_head *head_ref,
+ int action),
+
+- TP_ARGS(fs_info, ref, head_ref, action)
++ TP_ARGS(fs_info, head_ref, action)
+ );
+
+ DEFINE_EVENT(btrfs_delayed_ref_head, run_delayed_ref_head,
+
+ TP_PROTO(const struct btrfs_fs_info *fs_info,
+- const struct btrfs_delayed_ref_node *ref,
+ const struct btrfs_delayed_ref_head *head_ref,
+ int action),
+
+- TP_ARGS(fs_info, ref, head_ref, action)
++ TP_ARGS(fs_info, head_ref, action)
+ );
+
+ #define show_chunk_type(type) \
+--
+2.21.0
+
diff --git a/patches.suse/0007-btrfs-Use-init_delayed_ref_head-in-add_delayed_ref_h.patch b/patches.suse/0007-btrfs-Use-init_delayed_ref_head-in-add_delayed_ref_h.patch
new file mode 100644
index 0000000000..d41cf73dd5
--- /dev/null
+++ b/patches.suse/0007-btrfs-Use-init_delayed_ref_head-in-add_delayed_ref_h.patch
@@ -0,0 +1,102 @@
+From eb86ec73b968b2895ffede893b33bf49bbc9bf5c Mon Sep 17 00:00:00 2001
+From: Nikolay Borisov <nborisov@suse.com>
+Date: Tue, 24 Apr 2018 17:18:23 +0300
+Git-commit: eb86ec73b968b2895ffede893b33bf49bbc9bf5c
+Patch-mainline: v4.18
+References: bsc#1134813
+Subject: [PATCH 7/8] btrfs: Use init_delayed_ref_head in add_delayed_ref_head
+
+Use the newly introduced function when initialising the head_ref in
+add_delayed_ref_head. No functional changes.
+
+Signed-off-by: Nikolay Borisov <nborisov@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/delayed-ref.c | 61 +++----------------------------------------------
+ 1 file changed, 4 insertions(+), 57 deletions(-)
+
+--- a/fs/btrfs/delayed-ref.c
++++ b/fs/btrfs/delayed-ref.c
+@@ -625,69 +625,16 @@ add_delayed_ref_head(struct btrfs_fs_inf
+ {
+ struct btrfs_delayed_ref_head *existing;
+ struct btrfs_delayed_ref_root *delayed_refs;
+- int count_mod = 1;
+- int must_insert_reserved = 0;
+ int qrecord_inserted = 0;
+
+- /* If reserved is provided, it must be a data extent. */
+- BUG_ON(!is_data && reserved);
+-
+- /*
+- * the head node stores the sum of all the mods, so dropping a ref
+- * should drop the sum in the head node by one.
+- */
+- if (action == BTRFS_UPDATE_DELAYED_HEAD)
+- count_mod = 0;
+- else if (action == BTRFS_DROP_DELAYED_REF)
+- count_mod = -1;
+-
+- /*
+- * BTRFS_ADD_DELAYED_EXTENT means that we need to update
+- * the reserved accounting when the extent is finally added, or
+- * if a later modification deletes the delayed ref without ever
+- * inserting the extent into the extent allocation tree.
+- * ref->must_insert_reserved is the flag used to record
+- * that accounting mods are required.
+- *
+- * Once we record must_insert_reserved, switch the action to
+- * BTRFS_ADD_DELAYED_REF because other special casing is not required.
+- */
+- if (action == BTRFS_ADD_DELAYED_EXTENT)
+- must_insert_reserved = 1;
+- else
+- must_insert_reserved = 0;
+-
+ delayed_refs = &trans->transaction->delayed_refs;
+
+- refcount_set(&head_ref->refs, 1);
+- head_ref->bytenr = bytenr;
+- head_ref->num_bytes = num_bytes;
+- head_ref->ref_mod = count_mod;
+- head_ref->must_insert_reserved = must_insert_reserved;
+- head_ref->is_data = is_data;
+- head_ref->is_system = is_system;
+- head_ref->ref_tree = RB_ROOT;
+- INIT_LIST_HEAD(&head_ref->ref_add_list);
+- RB_CLEAR_NODE(&head_ref->href_node);
+- head_ref->processing = 0;
+- head_ref->total_ref_mod = count_mod;
+- head_ref->qgroup_reserved = 0;
+- head_ref->qgroup_ref_root = 0;
+- spin_lock_init(&head_ref->lock);
+- mutex_init(&head_ref->mutex);
++ init_delayed_ref_head(head_ref, qrecord, bytenr, num_bytes, ref_root,
++ reserved, action, is_data, is_system);
+
+ /* Record qgroup extent info if provided */
+ if (qrecord) {
+- if (ref_root && reserved) {
+- head_ref->qgroup_ref_root = ref_root;
+- head_ref->qgroup_reserved = reserved;
+- }
+-
+- qrecord->bytenr = bytenr;
+- qrecord->num_bytes = num_bytes;
+- qrecord->old_roots = NULL;
+-
+- if(btrfs_qgroup_trace_extent_nolock(fs_info,
++ if (btrfs_qgroup_trace_extent_nolock(fs_info,
+ delayed_refs, qrecord))
+ kfree(qrecord);
+ else
+@@ -712,7 +659,7 @@ add_delayed_ref_head(struct btrfs_fs_inf
+ } else {
+ if (old_ref_mod)
+ *old_ref_mod = 0;
+- if (is_data && count_mod < 0)
++ if (is_data && head_ref->ref_mod < 0)
+ delayed_refs->pending_csums += num_bytes;
+ delayed_refs->num_heads++;
+ delayed_refs->num_heads_ready++;
diff --git a/patches.suse/0008-btrfs-split-delayed-ref-head-initialization-and-addi.patch b/patches.suse/0008-btrfs-split-delayed-ref-head-initialization-and-addi.patch
new file mode 100644
index 0000000000..7620fc154c
--- /dev/null
+++ b/patches.suse/0008-btrfs-split-delayed-ref-head-initialization-and-addi.patch
@@ -0,0 +1,159 @@
+From 2335efafa63f0c675ebb4f8908fff9e972fb8a58 Mon Sep 17 00:00:00 2001
+From: Nikolay Borisov <nborisov@suse.com>
+Date: Tue, 24 Apr 2018 17:18:24 +0300
+Git-commit: 2335efafa63f0c675ebb4f8908fff9e972fb8a58
+Patch-mainline: v4.18
+References: bsc#1134813
+Subject: [PATCH 8/8] btrfs: split delayed ref head initialization and addition
+
+add_delayed_ref_head really performed 2 independent operations -
+initialisting the ref head and adding it to a list. Now that the init
+part is in a separate function let's complete the separation between
+both operations. This results in a lot simpler interface for
+add_delayed_ref_head since the function now deals solely with either
+adding the newly initialised delayed ref head or merging it into an
+existing delayed ref head. This results in vastly simplified function
+signature since 5 arguments are dropped. The only other thing worth
+mentioning is that due to this split the WARN_ON catching reinit of
+existing. In this patch the condition is extended such that:
+
+ qrecord && head_ref->qgroup_ref_root && head_ref->qgroup_reserved
+
+is added. This is done because the two qgroup_* prefixed member are
+set only if both ref_root and reserved are passed. So functionally
+it's equivalent to the old WARN_ON and allows to remove the two args
+from add_delayed_ref_head.
+
+Signed-off-by: Nikolay Borisov <nborisov@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+---
+ fs/btrfs/delayed-ref.c | 42 ++++++++++++++++++++----------------------
+ 1 file changed, 20 insertions(+), 22 deletions(-)
+
+--- a/fs/btrfs/delayed-ref.c
++++ b/fs/btrfs/delayed-ref.c
+@@ -617,9 +617,7 @@ add_delayed_ref_head(struct btrfs_fs_inf
+ struct btrfs_trans_handle *trans,
+ struct btrfs_delayed_ref_head *head_ref,
+ struct btrfs_qgroup_extent_record *qrecord,
+- u64 bytenr, u64 num_bytes, u64 ref_root, u64 reserved,
+- int action, int is_data, int is_system,
+- int *qrecord_inserted_ret,
++ int action, int *qrecord_inserted_ret,
+ int *old_ref_mod, int *new_ref_mod)
+
+ {
+@@ -629,9 +627,6 @@ add_delayed_ref_head(struct btrfs_fs_inf
+
+ delayed_refs = &trans->transaction->delayed_refs;
+
+- init_delayed_ref_head(head_ref, qrecord, bytenr, num_bytes, ref_root,
+- reserved, action, is_data, is_system);
+-
+ /* Record qgroup extent info if provided */
+ if (qrecord) {
+ if (btrfs_qgroup_trace_extent_nolock(fs_info,
+@@ -646,7 +641,9 @@ add_delayed_ref_head(struct btrfs_fs_inf
+ existing = htree_insert(&delayed_refs->href_root,
+ &head_ref->href_node);
+ if (existing) {
+- WARN_ON(ref_root && reserved && existing->qgroup_ref_root
++ WARN_ON(qrecord && head_ref->qgroup_ref_root
++ && head_ref->qgroup_reserved
++ && existing->qgroup_ref_root
+ && existing->qgroup_reserved);
+ update_existing_head_ref(delayed_refs, existing, head_ref,
+ old_ref_mod);
+@@ -659,8 +656,8 @@ add_delayed_ref_head(struct btrfs_fs_inf
+ } else {
+ if (old_ref_mod)
+ *old_ref_mod = 0;
+- if (is_data && head_ref->ref_mod < 0)
+- delayed_refs->pending_csums += num_bytes;
++ if (head_ref->is_data && head_ref->ref_mod < 0)
++ delayed_refs->pending_csums += head_ref->num_bytes;
+ delayed_refs->num_heads++;
+ delayed_refs->num_heads_ready++;
+ atomic_inc(&delayed_refs->num_entries);
+@@ -670,6 +667,7 @@ add_delayed_ref_head(struct btrfs_fs_inf
+ *qrecord_inserted_ret = qrecord_inserted;
+ if (new_ref_mod)
+ *new_ref_mod = head_ref->total_ref_mod;
++
+ return head_ref;
+ }
+
+@@ -741,7 +739,7 @@ int btrfs_add_delayed_tree_ref(struct bt
+ struct btrfs_delayed_ref_root *delayed_refs;
+ struct btrfs_qgroup_extent_record *record = NULL;
+ int qrecord_inserted;
+- int is_system = (ref_root == BTRFS_CHUNK_TREE_OBJECTID);
++ bool is_system = (ref_root == BTRFS_CHUNK_TREE_OBJECTID);
+ int ret;
+ u8 ref_type;
+
+@@ -771,6 +769,8 @@ int btrfs_add_delayed_tree_ref(struct bt
+ goto free_head_ref;
+ }
+
++ init_delayed_ref_head(head_ref, record, bytenr, num_bytes,
++ ref_root, 0, action, false, is_system);
+ head_ref->extent_op = extent_op;
+
+ delayed_refs = &trans->transaction->delayed_refs;
+@@ -781,8 +781,7 @@ int btrfs_add_delayed_tree_ref(struct bt
+ * the spin lock
+ */
+ head_ref = add_delayed_ref_head(fs_info, trans, head_ref, record,
+- bytenr, num_bytes, 0, 0, action, 0,
+- is_system, &qrecord_inserted,
++ action, &qrecord_inserted,
+ old_ref_mod, new_ref_mod);
+
+
+@@ -858,6 +857,8 @@ int btrfs_add_delayed_data_ref(struct bt
+ }
+ }
+
++ init_delayed_ref_head(head_ref, record, bytenr, num_bytes, ref_root,
++ reserved, action, true, false);
+ head_ref->extent_op = NULL;
+
+ delayed_refs = &trans->transaction->delayed_refs;
+@@ -868,8 +869,7 @@ int btrfs_add_delayed_data_ref(struct bt
+ * the spin lock
+ */
+ head_ref = add_delayed_ref_head(fs_info, trans, head_ref, record,
+- bytenr, num_bytes, ref_root, reserved,
+- action, 1, 0, &qrecord_inserted,
++ action, &qrecord_inserted,
+ old_ref_mod, new_ref_mod);
+
+ ret = insert_delayed_ref(trans, delayed_refs, head_ref, &ref->node);
+@@ -898,19 +898,17 @@ int btrfs_add_delayed_extent_op(struct b
+ if (!head_ref)
+ return -ENOMEM;
+
++ init_delayed_ref_head(head_ref, NULL, bytenr, num_bytes, 0, 0,
++ BTRFS_UPDATE_DELAYED_HEAD, extent_op->is_data,
++ false);
+ head_ref->extent_op = extent_op;
+
+ delayed_refs = &trans->transaction->delayed_refs;
+ spin_lock(&delayed_refs->lock);
+
+- /*
+- * extent_ops just modify the flags of an extent and they don't result
+- * in ref count changes, hence it's safe to pass false/0 for is_system
+- * argument
+- */
+- add_delayed_ref_head(fs_info, trans, head_ref, NULL, bytenr,
+- num_bytes, 0, 0, BTRFS_UPDATE_DELAYED_HEAD,
+- extent_op->is_data, 0, NULL, NULL, NULL);
++ add_delayed_ref_head(fs_info, trans, head_ref, NULL,
++ BTRFS_UPDATE_DELAYED_HEAD,
++ NULL, NULL, NULL);
+
+ spin_unlock(&delayed_refs->lock);
+ return 0;
diff --git a/patches.suse/Revert-block-unexport-DISK_EVENT_MEDIA_CHANGE-for.patch b/patches.suse/Revert-block-unexport-DISK_EVENT_MEDIA_CHANGE-for.patch
new file mode 100644
index 0000000000..a90104f24b
--- /dev/null
+++ b/patches.suse/Revert-block-unexport-DISK_EVENT_MEDIA_CHANGE-for.patch
@@ -0,0 +1,145 @@
+From 9ec1f4444e4f969bd5729ac031a3e5735d6664df Mon Sep 17 00:00:00 2001
+From: Martin Wilck <mwilck@suse.com>
+Date: Thu, 17 Jan 2019 23:05:00 +0100
+Subject: [PATCH v2 3/4] Revert "block: unexport DISK_EVENT_MEDIA_CHANGE for
+ legacy/fringe drivers"
+Patch-mainline: v5.2-rc1
+Git-commit: 773008f6fe0544aa28140ced0504cefba17381aa
+References: bsc#1110946, bsc#1119843
+
+This reverts commit 9fd097b14918875bd6f125ed699d7bbbba5893ee.
+
+Instead of leaving disk->events completely empty, we now export the supported
+events again, and tell the block layer not to forward events to user space by
+not setting DISK_EVENT_FLAG_UEVENT. This allows the block layer to distinguish
+between devices that for which events should be handled in kernel only, and
+devices which don't support any meda change events at all.
+
+Cc: Jiri Kosina <jikos@kernel.org>
+Cc: Tim Waugh <tim@cyberelk.net>
+Cc: Michal Simek <michal.simek@xilinx.com>
+Signed-off-by: Martin Wilck <mwilck@suse.com>
+---
+ drivers/block/DAC960.c | 1 +
+ drivers/block/amiflop.c | 1 +
+ drivers/block/ataflop.c | 1 +
+ drivers/block/floppy.c | 1 +
+ drivers/block/paride/pcd.c | 1 +
+ drivers/block/paride/pd.c | 1 +
+ drivers/block/paride/pf.c | 1 +
+ drivers/block/swim.c | 1 +
+ drivers/block/swim3.c | 1 +
+ drivers/block/xsysace.c | 1 +
+ drivers/cdrom/gdrom.c | 1 +
+ 11 files changed, 11 insertions(+)
+
+--- a/drivers/block/DAC960.c
++++ b/drivers/block/DAC960.c
+@@ -2548,6 +2548,7 @@ static bool DAC960_RegisterBlockDevice(D
+ disk->major = MajorNumber;
+ disk->first_minor = n << DAC960_MaxPartitionsBits;
+ disk->fops = &DAC960_BlockDeviceOperations;
++ disk->events = DISK_EVENT_MEDIA_CHANGE;
+ }
+ /*
+ Indicate the Block Device Registration completed successfully,
+--- a/drivers/block/amiflop.c
++++ b/drivers/block/amiflop.c
+@@ -1735,6 +1735,7 @@ static int __init fd_probe_drives(void)
+ disk->major = FLOPPY_MAJOR;
+ disk->first_minor = drive;
+ disk->fops = &floppy_fops;
++ disk->events = DISK_EVENT_MEDIA_CHANGE;
+ sprintf(disk->disk_name, "fd%d", drive);
+ disk->private_data = &unit[drive];
+ set_capacity(disk, 880*2);
+--- a/drivers/block/ataflop.c
++++ b/drivers/block/ataflop.c
+@@ -1970,6 +1970,7 @@ static int __init atari_floppy_init (voi
+ unit[i].disk->first_minor = i;
+ sprintf(unit[i].disk->disk_name, "fd%d", i);
+ unit[i].disk->fops = &floppy_fops;
++ unit[i].disk->events = DISK_EVENT_MEDIA_CHANGE;
+ unit[i].disk->private_data = &unit[i];
+ set_capacity(unit[i].disk, MAX_DISK_SIZE * 2);
+ add_disk(unit[i].disk);
+--- a/drivers/block/floppy.c
++++ b/drivers/block/floppy.c
+@@ -4212,6 +4212,7 @@ static int __init do_floppy_init(void)
+ disks[drive]->major = FLOPPY_MAJOR;
+ disks[drive]->first_minor = TOMINOR(drive);
+ disks[drive]->fops = &floppy_fops;
++ disks[drive]->events = DISK_EVENT_MEDIA_CHANGE;
+ sprintf(disks[drive]->disk_name, "fd%d", drive);
+
+ setup_timer(&motor_off_timer[drive], motor_off_callback, drive);
+--- a/drivers/block/paride/pcd.c
++++ b/drivers/block/paride/pcd.c
+@@ -329,6 +329,7 @@ static void pcd_init_units(void)
+ strcpy(disk->disk_name, cd->name); /* umm... */
+ disk->fops = &pcd_bdops;
+ disk->flags = GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE;
++ disk->events = DISK_EVENT_MEDIA_CHANGE;
+ }
+ }
+
+--- a/drivers/block/paride/pd.c
++++ b/drivers/block/paride/pd.c
+@@ -854,6 +854,7 @@ static void pd_probe_drive(struct pd_uni
+ p->fops = &pd_fops;
+ p->major = major;
+ p->first_minor = (disk - pd) << PD_BITS;
++ p->events = DISK_EVENT_MEDIA_CHANGE;
+ disk->gd = p;
+ p->private_data = disk;
+ p->queue = blk_init_queue(do_pd_request, &pd_lock);
+--- a/drivers/block/paride/pf.c
++++ b/drivers/block/paride/pf.c
+@@ -304,6 +304,7 @@ static void __init pf_init_units(void)
+ disk->first_minor = unit;
+ strcpy(disk->disk_name, pf->name);
+ disk->fops = &pf_fops;
++ disk->events = DISK_EVENT_MEDIA_CHANGE;
+ if (!(*drives[unit])[D_PRT])
+ pf_drive_count++;
+ }
+--- a/drivers/block/swim.c
++++ b/drivers/block/swim.c
+@@ -875,6 +875,7 @@ static int swim_floppy_init(struct swim_
+ swd->unit[drive].disk->first_minor = drive;
+ sprintf(swd->unit[drive].disk->disk_name, "fd%d", drive);
+ swd->unit[drive].disk->fops = &floppy_fops;
++ swd->unit[drive].disk->events = DISK_EVENT_MEDIA_CHANGE;
+ swd->unit[drive].disk->private_data = &swd->unit[drive];
+ set_capacity(swd->unit[drive].disk, 2880);
+ add_disk(swd->unit[drive].disk);
+--- a/drivers/block/swim3.c
++++ b/drivers/block/swim3.c
+@@ -1242,6 +1242,7 @@ static int swim3_attach(struct macio_dev
+ disk->first_minor = index;
+ disk->fops = &floppy_fops;
+ disk->private_data = &floppy_states[index];
++ disk->events = DISK_EVENT_MEDIA_CHANGE;
+ disk->flags |= GENHD_FL_REMOVABLE;
+ sprintf(disk->disk_name, "fd%d", index);
+ set_capacity(disk, 2880);
+--- a/drivers/block/xsysace.c
++++ b/drivers/block/xsysace.c
+@@ -1005,6 +1005,7 @@ static int ace_setup(struct ace_device *
+ ace->gd->major = ace_major;
+ ace->gd->first_minor = ace->id * ACE_NUM_MINORS;
+ ace->gd->fops = &ace_fops;
++ ace->gd->events = DISK_EVENT_MEDIA_CHANGE;
+ ace->gd->queue = ace->queue;
+ ace->gd->private_data = ace;
+ snprintf(ace->gd->disk_name, 32, "xs%c", ace->id + 'a');
+--- a/drivers/cdrom/gdrom.c
++++ b/drivers/cdrom/gdrom.c
+@@ -807,6 +807,7 @@ static int probe_gdrom(struct platform_d
+ goto probe_fail_cdrom_register;
+ }
+ gd.disk->fops = &gdrom_bdops;
++ gd.disk->events = DISK_EVENT_MEDIA_CHANGE;
+ /* latch on to the interrupt */
+ err = gdrom_set_interrupt_handlers();
+ if (err)
diff --git a/patches.suse/block-check_events-don-t-bother-with-events-if-un.patch b/patches.suse/block-check_events-don-t-bother-with-events-if-un.patch
new file mode 100644
index 0000000000..02c7958d5b
--- /dev/null
+++ b/patches.suse/block-check_events-don-t-bother-with-events-if-un.patch
@@ -0,0 +1,99 @@
+From e8bac0005b99f71190d276e06b30b6a4fae83532 Mon Sep 17 00:00:00 2001
+From: Martin Wilck <mwilck@suse.com>
+Date: Fri, 18 Jan 2019 00:00:07 +0100
+Subject: [PATCH v2 4/4] block: check_events: don't bother with events if
+ unsupported
+Patch-mainline: v5.2-rc1
+Git-commit: cdf3e3deb747d5e193dee617ed37c83060eb576f
+References: bsc#1110946, bsc#1119843
+
+Drivers now report to the block layer if they support media change
+events. If this is not the case, there's no need to allocate
+the event structure, and all event handling code can effectively
+be skipped. This simplifies code flow in particular for
+non-removable sd devices.
+
+This effectively reverts commit 75e3f3ee3c64 ("block: always allocate
+genhd->ev if check_events is implemented").
+
+The sysfs files for the events are kept in place even if no events
+are supported, as user space may rely on them being present. The only
+difference is that an error code is now returned if the user tries
+to set poll_msecs.
+
+Signed-off-by: Martin Wilck <mwilck@suse.com>
+---
+ block/genhd.c | 28 +++++++++++++++++-----------
+ 1 file changed, 17 insertions(+), 11 deletions(-)
+
+--- a/block/genhd.c
++++ b/block/genhd.c
+@@ -1855,6 +1855,9 @@ static ssize_t disk_events_poll_msecs_sh
+ {
+ struct gendisk *disk = dev_to_disk(dev);
+
++ if (!disk->ev)
++ return sprintf(buf, "-1\n");
++
+ return sprintf(buf, "%ld\n", disk->ev->poll_msecs);
+ }
+
+@@ -1871,6 +1874,9 @@ static ssize_t disk_events_poll_msecs_st
+ if (intv < 0 && intv != -1)
+ return -EINVAL;
+
++ if (!disk->ev)
++ return -ENODEV;
++
+ disk_block_events(disk);
+ disk->ev->poll_msecs = intv;
+ __disk_unblock_events(disk, true);
+@@ -1935,7 +1941,8 @@ static void disk_alloc_events(struct gen
+ {
+ struct disk_events *ev;
+
+- if (!disk->fops->check_events)
++ if (!disk->fops->check_events ||
++ !(disk->events & DISK_EVENT_TYPES_MASK))
+ return;
+
+ ev = kzalloc(sizeof(*ev), GFP_KERNEL);
+@@ -1957,14 +1964,14 @@ static void disk_alloc_events(struct gen
+
+ static void disk_add_events(struct gendisk *disk)
+ {
+- if (!disk->ev)
+- return;
+-
+ /* FIXME: error handling */
+ if (sysfs_create_files(&disk_to_dev(disk)->kobj, disk_events_attrs) < 0)
+ pr_warn("%s: failed to create sysfs files for events\n",
+ disk->disk_name);
+
++ if (!disk->ev)
++ return;
++
+ mutex_lock(&disk_events_mutex);
+ list_add_tail(&disk->ev->node, &disk_events);
+ mutex_unlock(&disk_events_mutex);
+@@ -1978,14 +1985,13 @@ static void disk_add_events(struct gendi
+
+ static void disk_del_events(struct gendisk *disk)
+ {
+- if (!disk->ev)
+- return;
+-
+- disk_block_events(disk);
++ if (disk->ev) {
++ disk_block_events(disk);
+
+- mutex_lock(&disk_events_mutex);
+- list_del_init(&disk->ev->node);
+- mutex_unlock(&disk_events_mutex);
++ mutex_lock(&disk_events_mutex);
++ list_del_init(&disk->ev->node);
++ mutex_unlock(&disk_events_mutex);
++ }
+
+ sysfs_remove_files(&disk_to_dev(disk)->kobj, disk_events_attrs);
+ }
diff --git a/patches.suse/block-disk_events-introduce-event-flags.patch b/patches.suse/block-disk_events-introduce-event-flags.patch
new file mode 100644
index 0000000000..3e192ee090
--- /dev/null
+++ b/patches.suse/block-disk_events-introduce-event-flags.patch
@@ -0,0 +1,133 @@
+From 360a9cc1e5ae8d281c2dcf3cb41fb5e40999f01d Mon Sep 17 00:00:00 2001
+From: Martin Wilck <mwilck@suse.com>
+Date: Thu, 17 Jan 2019 22:30:48 +0100
+Subject: [PATCH v2 1/4] block: disk_events: introduce event flags
+Git-commit: c92e2f04b35938da23eb9a7f7101cbdd5ac7cdc4
+Patch-mainline: v5.2-rc1
+References: bsc#1110946, bsc#1119843
+
+Currently, an empty disk->events field tells the block layer not to forward
+media change events to user space. This was done in commit 7c88a168da80 ("block:
+don't propagate unlisted DISK_EVENTs to userland") in order to avoid events
+from "fringe" drivers to be forwarded to user space. By doing so, the block
+layer lost the information which events were supported by a particular
+block device, and most importantly, whether or not a given device supports
+media change events at all.
+
+Prepare for not interpreting the "events" field this way in the future any
+more. This is done by adding two flag bits that can be set to have the
+device treated like one that has the "events" field set to a non-zero value
+before. This applies only to the sd and sr drivers, which are changed to
+set the new flags.
+
+The new flags are DISK_EVENT_FLAG_POLL to enforce polling of the device for
+synchronous events, and DISK_EVENT_FLAG_UEVENT to tell the blocklayer to
+generate udev events from kernel events. They can easily be fit in the int
+reserved for event bits.
+
+This patch doesn't change behavior.
+
+Signed-off-by: Martin Wilck <mwilck@suse.com>
+---
+ block/genhd.c | 22 ++++++++++++++++------
+ drivers/scsi/sd.c | 3 ++-
+ drivers/scsi/sr.c | 3 ++-
+ include/linux/genhd.h | 7 +++++++
+ 4 files changed, 27 insertions(+), 8 deletions(-)
+
+--- a/block/genhd.c
++++ b/block/genhd.c
+@@ -1577,7 +1577,8 @@ static unsigned long disk_events_poll_ji
+ */
+ if (ev->poll_msecs >= 0)
+ intv_msecs = ev->poll_msecs;
+- else if (disk->events & ~disk->async_events)
++ else if (disk->events & DISK_EVENT_FLAG_POLL
++ && disk->events & ~disk->async_events)
+ intv_msecs = disk_events_dfl_poll_msecs;
+
+ return msecs_to_jiffies(intv_msecs);
+@@ -1787,11 +1788,13 @@ static void disk_check_events(struct dis
+
+ /*
+ * Tell userland about new events. Only the events listed in
+- * @disk->events are reported. Unlisted events are processed the
+- * same internally but never get reported to userland.
++ * @disk->events are reported, and only if DISK_EVENT_FLAG_UEVENT
++ * is set. Otherwise, events are processed internally but never
++ * get reported to userland.
+ */
+ for (i = 0; i < ARRAY_SIZE(disk_uevents); i++)
+- if (events & disk->events & (1 << i))
++ if (events & disk->events & (1 << i) &&
++ disk->events & DISK_EVENT_FLAG_UEVENT)
+ envp[nr_events++] = disk_uevents[i];
+
+ if (nr_events)
+@@ -1828,7 +1831,10 @@ static ssize_t disk_events_show(struct d
+ {
+ struct gendisk *disk = dev_to_disk(dev);
+
+- return __disk_events_show(disk->events, buf);
++ if (!(disk->events & DISK_EVENT_FLAG_UEVENT))
++ return 0;
++
++ return __disk_events_show(disk->events & DISK_EVENT_TYPES_MASK, buf);
+ }
+
+ static ssize_t disk_events_async_show(struct device *dev,
+@@ -1836,7 +1842,11 @@ static ssize_t disk_events_async_show(st
+ {
+ struct gendisk *disk = dev_to_disk(dev);
+
+- return __disk_events_show(disk->async_events, buf);
++ if (!(disk->events & DISK_EVENT_FLAG_UEVENT))
++ return 0;
++
++ return __disk_events_show(disk->async_events & DISK_EVENT_TYPES_MASK,
++ buf);
+ }
+
+ static ssize_t disk_events_poll_msecs_show(struct device *dev,
+--- a/drivers/scsi/sd.c
++++ b/drivers/scsi/sd.c
+@@ -3296,7 +3296,8 @@ static void sd_probe_async(void *data, a
+ gd->flags = GENHD_FL_EXT_DEVT;
+ if (sdp->removable) {
+ gd->flags |= GENHD_FL_REMOVABLE;
+- gd->events |= DISK_EVENT_MEDIA_CHANGE;
++ gd->events |= DISK_EVENT_MEDIA_CHANGE |
++ DISK_EVENT_FLAG_POLL | DISK_EVENT_FLAG_UEVENT;
+ }
+
+ blk_pm_runtime_init(sdp->request_queue, dev);
+--- a/drivers/scsi/sr.c
++++ b/drivers/scsi/sr.c
+@@ -702,7 +702,8 @@ static int sr_probe(struct device *dev)
+ sprintf(disk->disk_name, "sr%d", minor);
+ disk->fops = &sr_bdops;
+ disk->flags = GENHD_FL_CD | GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE;
+- disk->events = DISK_EVENT_MEDIA_CHANGE | DISK_EVENT_EJECT_REQUEST;
++ disk->events = DISK_EVENT_MEDIA_CHANGE | DISK_EVENT_EJECT_REQUEST
++ | DISK_EVENT_FLAG_POLL | DISK_EVENT_FLAG_UEVENT;
+
+ blk_queue_rq_timeout(sdev->request_queue, SR_TIMEOUT);
+
+--- a/include/linux/genhd.h
++++ b/include/linux/genhd.h
+@@ -145,8 +145,15 @@ struct hd_struct {
+ enum {
+ DISK_EVENT_MEDIA_CHANGE = 1 << 0, /* media changed */
+ DISK_EVENT_EJECT_REQUEST = 1 << 1, /* eject requested */
++ /* Poll even if events_poll_msecs is unset */
++ DISK_EVENT_FLAG_POLL = 1 << 16,
++ /* Forward events to udev */
++ DISK_EVENT_FLAG_UEVENT = 1 << 17,
+ };
+
++#define DISK_EVENT_TYPES_MASK \
++ (DISK_EVENT_MEDIA_CHANGE | DISK_EVENT_EJECT_REQUEST)
++
+ struct disk_part_tbl {
+ struct rcu_head rcu_head;
+ int len;
diff --git a/patches.suse/btrfs-Take-trans-lock-before-access-running-trans-in.patch b/patches.suse/btrfs-Take-trans-lock-before-access-running-trans-in.patch
index 9161f4d80f..d676081c42 100644
--- a/patches.suse/btrfs-Take-trans-lock-before-access-running-trans-in.patch
+++ b/patches.suse/btrfs-Take-trans-lock-before-access-running-trans-in.patch
@@ -27,15 +27,13 @@ Signed-off-by: ethanwu <ethanwu@synology.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Acked-by: Nikolay Borisov <nborisov@suse.com>
---
- fs/btrfs/extent-tree.c | 7 +++++++
+ fs/btrfs/extent-tree.c | 7 +++++++
1 file changed, 7 insertions(+)
-diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
-index 903c919fd249..d55fa1104b9e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
-@@ -3098,7 +3098,11 @@ static noinline int check_delayed_ref(struct btrfs_root *root,
- struct btrfs_transaction *cur_trans;
+@@ -3073,7 +3073,11 @@ static noinline int check_delayed_ref(st
+ struct rb_node *node;
int ret = 0;
+ spin_lock(&root->fs_info->trans_lock);
@@ -46,7 +44,7 @@ index 903c919fd249..d55fa1104b9e 100644
if (!cur_trans)
return 0;
-@@ -3107,6 +3111,7 @@ static noinline int check_delayed_ref(struct btrfs_root *root,
+@@ -3082,6 +3086,7 @@ static noinline int check_delayed_ref(st
head = btrfs_find_delayed_ref_head(delayed_refs, bytenr);
if (!head) {
spin_unlock(&delayed_refs->lock);
@@ -54,15 +52,15 @@ index 903c919fd249..d55fa1104b9e 100644
return 0;
}
-@@ -3123,6 +3128,7 @@ static noinline int check_delayed_ref(struct btrfs_root *root,
+@@ -3098,6 +3103,7 @@ static noinline int check_delayed_ref(st
mutex_lock(&head->mutex);
mutex_unlock(&head->mutex);
- btrfs_put_delayed_ref(&head->node);
+ btrfs_put_delayed_ref_head(head);
+ btrfs_put_transaction(cur_trans);
return -EAGAIN;
}
spin_unlock(&delayed_refs->lock);
-@@ -3150,6 +3156,7 @@ static noinline int check_delayed_ref(struct btrfs_root *root,
+@@ -3130,6 +3136,7 @@ static noinline int check_delayed_ref(st
}
spin_unlock(&head->lock);
mutex_unlock(&head->mutex);
@@ -70,6 +68,3 @@ index 903c919fd249..d55fa1104b9e 100644
return ret;
}
---
-2.7.4
-
diff --git a/patches.suse/btrfs-fix-race-condition-between-delayed-refs-and-blockgroup-removal.patch b/patches.suse/btrfs-fix-race-condition-between-delayed-refs-and-blockgroup-removal.patch
index 03df183e98..f7f380eaa6 100644
--- a/patches.suse/btrfs-fix-race-condition-between-delayed-refs-and-blockgroup-removal.patch
+++ b/patches.suse/btrfs-fix-race-condition-between-delayed-refs-and-blockgroup-removal.patch
@@ -50,13 +50,13 @@ Signed-off-by: David Sterba <dsterba@suse.com>
---
fs/btrfs/delayed-ref.c | 19 ++++++++++++++-----
fs/btrfs/delayed-ref.h | 1 +
- fs/btrfs/extent-tree.c | 16 +++++++++++-----
- 3 files changed, 26 insertions(+), 10 deletions(-)
+ fs/btrfs/extent-tree.c | 19 ++++++++++++-------
+ 3 files changed, 27 insertions(+), 12 deletions(-)
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -553,8 +553,10 @@ add_delayed_ref_head(struct btrfs_fs_inf
- struct btrfs_delayed_ref_node *ref,
+ struct btrfs_delayed_ref_head *head_ref,
struct btrfs_qgroup_extent_record *qrecord,
u64 bytenr, u64 num_bytes, u64 ref_root, u64 reserved,
- int action, int is_data, int *qrecord_inserted_ret,
@@ -66,16 +66,16 @@ Signed-off-by: David Sterba <dsterba@suse.com>
+
{
struct btrfs_delayed_ref_head *existing;
- struct btrfs_delayed_ref_head *head_ref = NULL;
-@@ -607,6 +609,7 @@ add_delayed_ref_head(struct btrfs_fs_inf
- head_ref = btrfs_delayed_node_to_head(ref);
+ struct btrfs_delayed_ref_root *delayed_refs;
+@@ -598,6 +600,7 @@ add_delayed_ref_head(struct btrfs_fs_inf
+ head_ref->ref_mod = count_mod;
head_ref->must_insert_reserved = must_insert_reserved;
head_ref->is_data = is_data;
+ head_ref->is_system = is_system;
- INIT_LIST_HEAD(&head_ref->ref_list);
+ head_ref->ref_tree = RB_ROOT;
INIT_LIST_HEAD(&head_ref->ref_add_list);
- head_ref->processing = 0;
-@@ -795,6 +798,7 @@ int btrfs_add_delayed_tree_ref(struct bt
+ RB_CLEAR_NODE(&head_ref->href_node);
+@@ -785,6 +788,7 @@ int btrfs_add_delayed_tree_ref(struct bt
struct btrfs_delayed_ref_root *delayed_refs;
struct btrfs_qgroup_extent_record *record = NULL;
int qrecord_inserted;
@@ -83,9 +83,9 @@ Signed-off-by: David Sterba <dsterba@suse.com>
BUG_ON(extent_op && extent_op->is_data);
ref = kmem_cache_alloc(btrfs_delayed_tree_ref_cachep, GFP_NOFS);
-@@ -823,8 +827,8 @@ int btrfs_add_delayed_tree_ref(struct bt
+@@ -813,8 +817,8 @@ int btrfs_add_delayed_tree_ref(struct bt
*/
- head_ref = add_delayed_ref_head(fs_info, trans, &head_ref->node, record,
+ head_ref = add_delayed_ref_head(fs_info, trans, head_ref, record,
bytenr, num_bytes, 0, 0, action, 0,
- &qrecord_inserted, old_ref_mod,
- new_ref_mod);
@@ -94,16 +94,16 @@ Signed-off-by: David Sterba <dsterba@suse.com>
add_delayed_tree_ref(fs_info, trans, head_ref, &ref->node, bytenr,
num_bytes, parent, ref_root, level, action);
-@@ -890,7 +894,7 @@ int btrfs_add_delayed_data_ref(struct bt
+@@ -880,7 +884,7 @@ int btrfs_add_delayed_data_ref(struct bt
*/
- head_ref = add_delayed_ref_head(fs_info, trans, &head_ref->node, record,
+ head_ref = add_delayed_ref_head(fs_info, trans, head_ref, record,
bytenr, num_bytes, ref_root, reserved,
- action, 1, &qrecord_inserted,
+ action, 1, 0, &qrecord_inserted,
old_ref_mod, new_ref_mod);
add_delayed_data_ref(fs_info, trans, head_ref, &ref->node, bytenr,
-@@ -920,9 +924,14 @@ int btrfs_add_delayed_extent_op(struct b
+@@ -910,9 +914,14 @@ int btrfs_add_delayed_extent_op(struct b
delayed_refs = &trans->transaction->delayed_refs;
spin_lock(&delayed_refs->lock);
@@ -112,16 +112,16 @@ Signed-off-by: David Sterba <dsterba@suse.com>
+ * in ref count changes, hence it's safe to pass false/0 for is_system
+ * argument
+ */
- add_delayed_ref_head(fs_info, trans, &head_ref->node, NULL, bytenr,
+ add_delayed_ref_head(fs_info, trans, head_ref, NULL, bytenr,
num_bytes, 0, 0, BTRFS_UPDATE_DELAYED_HEAD,
- extent_op->is_data, NULL, NULL, NULL);
-+ extent_op->is_data, 0, NULL, NULL, NULL);
++ extent_op->is_data, 0, NULL, NULL, NULL);
spin_unlock(&delayed_refs->lock);
return 0;
--- a/fs/btrfs/delayed-ref.h
+++ b/fs/btrfs/delayed-ref.h
-@@ -140,6 +140,7 @@ struct btrfs_delayed_ref_head {
+@@ -139,6 +139,7 @@ struct btrfs_delayed_ref_head {
*/
unsigned int must_insert_reserved:1;
unsigned int is_data:1;
@@ -131,28 +131,30 @@ Signed-off-by: David Sterba <dsterba@suse.com>
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
-@@ -2439,13 +2439,19 @@ static int run_one_delayed_ref(struct bt
- trace_run_delayed_ref_head(fs_info, node, head, node->action);
-
- if (head->total_ref_mod < 0) {
-- struct btrfs_block_group_cache *cache;
-+ struct btrfs_space_info *space_info;
-+ u64 flags;
+@@ -2534,14 +2534,19 @@ static int cleanup_ref_head(struct btrfs
+ trace_run_delayed_ref_head(fs_info, head, 0);
-- cache = btrfs_lookup_block_group(fs_info, node->bytenr);
-- ASSERT(cache);
-- percpu_counter_add(&cache->space_info->total_bytes_pinned,
-+ if (head->is_data)
-+ flags = BTRFS_BLOCK_GROUP_DATA;
-+ else if (head->is_system)
-+ flags = BTRFS_BLOCK_GROUP_SYSTEM;
-+ else
-+ flags = BTRFS_BLOCK_GROUP_METADATA;
-+ space_info = __find_space_info(fs_info, flags);
-+ ASSERT(space_info);
-+ percpu_counter_add(&space_info->total_bytes_pinned,
- -node->num_bytes);
-- btrfs_put_block_group(cache);
- }
+ if (head->total_ref_mod < 0) {
+- struct btrfs_block_group_cache *cache;
+-
+- cache = btrfs_lookup_block_group(fs_info, head->bytenr);
+- ASSERT(cache);
+- percpu_counter_add(&cache->space_info->total_bytes_pinned,
+- -head->num_bytes);
+- btrfs_put_block_group(cache);
++ struct btrfs_space_info *space_info;
++ u64 flags;
- if (insert_reserved) {
++ if (head->is_data)
++ flags = BTRFS_BLOCK_GROUP_DATA;
++ else if (head->is_system)
++ flags = BTRFS_BLOCK_GROUP_SYSTEM;
++ else
++ flags = BTRFS_BLOCK_GROUP_METADATA;
++ space_info = __find_space_info(fs_info, flags);
++ ASSERT(space_info);
++ percpu_counter_add(&space_info->total_bytes_pinned,
++ -head->num_bytes);
+ if (head->is_data) {
+ spin_lock(&delayed_refs->lock);
+ delayed_refs->pending_csums -= head->num_bytes;
diff --git a/patches.suse/lpfc-validate-command-in-lpfc_sli4_scmd_to_wqidx_dis.patch b/patches.suse/lpfc-validate-command-in-lpfc_sli4_scmd_to_wqidx_dis.patch
new file mode 100644
index 0000000000..ed07c65ac5
--- /dev/null
+++ b/patches.suse/lpfc-validate-command-in-lpfc_sli4_scmd_to_wqidx_dis.patch
@@ -0,0 +1,32 @@
+From: Hannes Reinecke <hare@suse.de>
+Date: Tue, 14 May 2019 12:36:46 +0200
+Subject: [PATCH] lpfc: validate command in lpfc_sli4_scmd_to_wqidx_distr()
+References: bsc#1129138
+Patch-Mainline: never, SLE15 specific
+
+According to Broadcom we need to validate the command to avoid
+crashes with blk-mq.
+
+Suggested-by: Justin Tee <justin.tee@broadcom.com>
+Signed-off-by: Hannes Reinecke <hare@suse.com>
+---
+ drivers/scsi/lpfc/lpfc_scsi.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
+index 100a4a5a5b99..d1aab85f5102 100644
+--- a/drivers/scsi/lpfc/lpfc_scsi.c
++++ b/drivers/scsi/lpfc/lpfc_scsi.c
+@@ -3932,7 +3932,8 @@ int lpfc_sli4_scmd_to_wqidx_distr(struct lpfc_hba *phba,
+ uint32_t tag;
+ uint16_t hwq;
+
+- if (cmnd && shost_use_blk_mq(cmnd->device->host)) {
++ if (cmnd && shost_use_blk_mq(cmnd->device->host) &&
++ cmnd->request && cmnd->request->q) {
+ tag = blk_mq_unique_tag(cmnd->request);
+ hwq = blk_mq_unique_tag_to_hwq(tag);
+
+--
+2.16.4
+
diff --git a/patches.suse/revert-btrfs-qgroup-move-half-of-the-qgroup-accounting-time-out-of-commit-trans.patch b/patches.suse/revert-btrfs-qgroup-move-half-of-the-qgroup-accounting-time-out-of-commit-trans.patch
index d6291a06ae..1ff8b31a3b 100644
--- a/patches.suse/revert-btrfs-qgroup-move-half-of-the-qgroup-accounting-time-out-of-commit-trans.patch
+++ b/patches.suse/revert-btrfs-qgroup-move-half-of-the-qgroup-accounting-time-out-of-commit-trans.patch
@@ -40,39 +40,38 @@ deadlocks when resolving references.
Acked-by: Jeff Mahoney <jeffm@suse.com>
---
---
- fs/btrfs/delayed-ref.c | 20 +++-----------------
+ fs/btrfs/delayed-ref.c | 22 ++++------------------
fs/btrfs/qgroup.c | 30 +++---------------------------
fs/btrfs/qgroup.h | 33 +++------------------------------
- 3 files changed, 9 insertions(+), 74 deletions(-)
+ 3 files changed, 10 insertions(+), 75 deletions(-)
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
-@@ -558,7 +558,6 @@ add_delayed_ref_head(struct btrfs_fs_inf
+@@ -615,13 +615,11 @@ add_delayed_ref_head(struct btrfs_fs_inf
+ struct btrfs_trans_handle *trans,
+ struct btrfs_delayed_ref_head *head_ref,
struct btrfs_qgroup_extent_record *qrecord,
- u64 bytenr, u64 num_bytes, u64 ref_root, u64 reserved,
- int action, int is_data, int is_system,
-- int *qrecord_inserted_ret,
- int *old_ref_mod, int *new_ref_mod)
+- int action, int *qrecord_inserted_ret,
+- int *old_ref_mod, int *new_ref_mod)
++ int action, int *old_ref_mod, int *new_ref_mod)
{
-@@ -567,7 +566,6 @@ add_delayed_ref_head(struct btrfs_fs_inf
+ struct btrfs_delayed_ref_head *existing;
struct btrfs_delayed_ref_root *delayed_refs;
- int count_mod = 1;
- int must_insert_reserved = 0;
- int qrecord_inserted = 0;
- /* If reserved is provided, it must be a data extent. */
- BUG_ON(!is_data && reserved);
-@@ -635,8 +633,6 @@ add_delayed_ref_head(struct btrfs_fs_inf
- if(btrfs_qgroup_trace_extent_nolock(fs_info,
+ delayed_refs = &trans->transaction->delayed_refs;
+
+@@ -630,8 +628,6 @@ add_delayed_ref_head(struct btrfs_fs_inf
+ if (btrfs_qgroup_trace_extent_nolock(fs_info,
delayed_refs, qrecord))
kfree(qrecord);
- else
- qrecord_inserted = 1;
}
- spin_lock_init(&head_ref->lock);
-@@ -667,8 +663,6 @@ add_delayed_ref_head(struct btrfs_fs_inf
+ trace_add_delayed_ref_head(fs_info, head_ref, action);
+@@ -657,8 +653,6 @@ add_delayed_ref_head(struct btrfs_fs_inf
atomic_inc(&delayed_refs->num_entries);
trans->delayed_ref_updates++;
}
@@ -80,70 +79,73 @@ Acked-by: Jeff Mahoney <jeffm@suse.com>
- *qrecord_inserted_ret = qrecord_inserted;
if (new_ref_mod)
*new_ref_mod = head_ref->total_ref_mod;
- return head_ref;
-@@ -801,7 +795,6 @@ int btrfs_add_delayed_tree_ref(struct bt
+
+@@ -732,7 +726,6 @@ int btrfs_add_delayed_tree_ref(struct bt
struct btrfs_delayed_ref_head *head_ref;
struct btrfs_delayed_ref_root *delayed_refs;
struct btrfs_qgroup_extent_record *record = NULL;
- int qrecord_inserted;
- int is_system = (ref_root == BTRFS_CHUNK_TREE_OBJECTID);
-
- BUG_ON(extent_op && extent_op->is_data);
-@@ -831,15 +824,12 @@ int btrfs_add_delayed_tree_ref(struct bt
+ bool is_system = (ref_root == BTRFS_CHUNK_TREE_OBJECTID);
+ int ret;
+ u8 ref_type;
+@@ -775,8 +768,7 @@ int btrfs_add_delayed_tree_ref(struct bt
+ * the spin lock
*/
- head_ref = add_delayed_ref_head(fs_info, trans, &head_ref->node, record,
- bytenr, num_bytes, 0, 0, action, 0,
-- is_system, &qrecord_inserted,
+ head_ref = add_delayed_ref_head(fs_info, trans, head_ref, record,
+- action, &qrecord_inserted,
- old_ref_mod, new_ref_mod);
-+ is_system, old_ref_mod, new_ref_mod);
++ action, old_ref_mod, new_ref_mod);
- add_delayed_tree_ref(fs_info, trans, head_ref, &ref->node, bytenr,
- num_bytes, parent, ref_root, level, action);
- spin_unlock(&delayed_refs->lock);
+
+ ret = insert_delayed_ref(trans, delayed_refs, head_ref, &ref->node);
+@@ -788,8 +780,6 @@ int btrfs_add_delayed_tree_ref(struct bt
+ if (ret > 0)
+ kmem_cache_free(btrfs_delayed_tree_ref_cachep, ref);
- if (qrecord_inserted)
- return btrfs_qgroup_trace_extent_post(fs_info, record);
return 0;
free_head_ref:
-@@ -864,7 +854,6 @@ int btrfs_add_delayed_data_ref(struct bt
+@@ -814,7 +804,6 @@ int btrfs_add_delayed_data_ref(struct bt
struct btrfs_delayed_ref_head *head_ref;
struct btrfs_delayed_ref_root *delayed_refs;
struct btrfs_qgroup_extent_record *record = NULL;
- int qrecord_inserted;
+ int ret;
+ u8 ref_type;
- ref = kmem_cache_alloc(btrfs_delayed_data_ref_cachep, GFP_NOFS);
- if (!ref)
-@@ -898,16 +887,13 @@ int btrfs_add_delayed_data_ref(struct bt
+@@ -863,8 +852,7 @@ int btrfs_add_delayed_data_ref(struct bt
+ * the spin lock
*/
- head_ref = add_delayed_ref_head(fs_info, trans, &head_ref->node, record,
- bytenr, num_bytes, ref_root, reserved,
-- action, 1, 0, &qrecord_inserted,
+ head_ref = add_delayed_ref_head(fs_info, trans, head_ref, record,
+- action, &qrecord_inserted,
- old_ref_mod, new_ref_mod);
-+ action, 1, 0, old_ref_mod, new_ref_mod);
++ action, old_ref_mod, new_ref_mod);
- add_delayed_data_ref(fs_info, trans, head_ref, &ref->node, bytenr,
- num_bytes, parent, ref_root, owner, offset,
- action);
+ ret = insert_delayed_ref(trans, delayed_refs, head_ref, &ref->node);
spin_unlock(&delayed_refs->lock);
+@@ -875,8 +863,6 @@ int btrfs_add_delayed_data_ref(struct bt
+ if (ret > 0)
+ kmem_cache_free(btrfs_delayed_data_ref_cachep, ref);
- if (qrecord_inserted)
- return btrfs_qgroup_trace_extent_post(fs_info, record);
return 0;
}
-@@ -935,7 +921,7 @@ int btrfs_add_delayed_extent_op(struct b
- */
- add_delayed_ref_head(fs_info, trans, &head_ref->node, NULL, bytenr,
- num_bytes, 0, 0, BTRFS_UPDATE_DELAYED_HEAD,
-- extent_op->is_data, 0, NULL, NULL, NULL);
-+ extent_op->is_data, 0, NULL, NULL);
+@@ -902,7 +888,7 @@ int btrfs_add_delayed_extent_op(struct b
+
+ add_delayed_ref_head(fs_info, trans, head_ref, NULL,
+ BTRFS_UPDATE_DELAYED_HEAD,
+- NULL, NULL, NULL);
++ NULL, NULL);
spin_unlock(&delayed_refs->lock);
return 0;
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
-@@ -1501,28 +1501,6 @@ int btrfs_qgroup_trace_extent_nolock(str
+@@ -1507,28 +1507,6 @@ int btrfs_qgroup_trace_extent_nolock(str
return 0;
}
@@ -172,7 +174,7 @@ Acked-by: Jeff Mahoney <jeffm@suse.com>
int btrfs_qgroup_trace_extent(struct btrfs_trans_handle *trans,
struct btrfs_fs_info *fs_info, u64 bytenr, u64 num_bytes,
gfp_t gfp_flag)
-@@ -1548,11 +1526,9 @@ int btrfs_qgroup_trace_extent(struct btr
+@@ -1554,11 +1532,9 @@ int btrfs_qgroup_trace_extent(struct btr
spin_lock(&delayed_refs->lock);
ret = btrfs_qgroup_trace_extent_nolock(fs_info, delayed_refs, record);
spin_unlock(&delayed_refs->lock);
@@ -186,7 +188,7 @@ Acked-by: Jeff Mahoney <jeffm@suse.com>
}
int btrfs_qgroup_trace_leaf_items(struct btrfs_trans_handle *trans,
-@@ -2097,7 +2073,7 @@ int btrfs_qgroup_account_extents(struct
+@@ -2457,7 +2433,7 @@ int btrfs_qgroup_account_extents(struct
* Old roots should be searched when inserting qgroup
* extent record
*/
@@ -197,7 +199,7 @@ Acked-by: Jeff Mahoney <jeffm@suse.com>
record->bytenr, 0,
--- a/fs/btrfs/qgroup.h
+++ b/fs/btrfs/qgroup.h
-@@ -179,10 +179,9 @@ struct btrfs_delayed_extent_op;
+@@ -270,10 +270,9 @@ struct btrfs_delayed_extent_op;
/*
* Inform qgroup to trace one dirty extent, its info is recorded in @record.
@@ -210,7 +212,7 @@ Acked-by: Jeff Mahoney <jeffm@suse.com>
*
* Return 0 for success insert
* Return >0 for existing record, caller can free @record safely.
-@@ -194,37 +193,11 @@ int btrfs_qgroup_trace_extent_nolock(
+@@ -285,37 +284,11 @@ int btrfs_qgroup_trace_extent_nolock(
struct btrfs_qgroup_extent_record *record);
/*
diff --git a/series.conf b/series.conf
index 8e3d0143e7..ad19ebdd4b 100644
--- a/series.conf
+++ b/series.conf
@@ -8296,6 +8296,12 @@
patches.suse/0008-btrfs-tree-checker-Enhance-output-for-check_csum_ite.patch
patches.suse/0009-btrfs-tree-checker-Enhance-output-for-check_extent_d.patch
patches.suse/0010-btrfs-tree-checker-use-zu-format-string-for-size_t.patch
+ patches.suse/0001-btrfs-add-a-helper-to-return-a-head-ref.patch
+ patches.suse/0002-btrfs-move-extent_op-cleanup-to-a-helper.patch
+ patches.suse/0003-btrfs-breakout-empty-head-cleanup-to-a-helper.patch
+ patches.suse/0004-btrfs-move-ref_mod-modification-into-the-if-ref-logi.patch
+ patches.suse/0005-btrfs-move-all-ref-head-cleanup-to-the-helper-functi.patch
+ patches.suse/0006-btrfs-remove-delayed_ref_node-from-ref_head.patch
patches.suse/0020-btrfs-remove-type-argument-from-comp_tree_refs.patch
patches.suse/0016-btrfs-cleanup-extent-locking-sequence.patch
patches.suse/0017-Btrfs-rework-outstanding_extents.patch
@@ -8303,6 +8309,7 @@
patches.suse/0019-btrfs-make-the-delalloc-block-rsv-per-inode.patch
patches.suse/0021-btrfs-switch-args-for-comp_-_refs.patch
patches.suse/0022-btrfs-add-a-comp_refs-helper.patch
+ patches.suse/0001-btrfs-track-refs-in-a-rb_tree-instead-of-a-list.patch
patches.suse/btrfs-move-btrfs_truncate_block-out-of-trans-handle.patch
patches.suse/btrfs-Fix-bug-for-misused-dev_t-when-lookup-in-dev-s.patch
patches.fixes/jfs-remove-increment-of-i_version-counter.patch
@@ -11656,6 +11663,7 @@
patches.drivers/mmc-sdhci-xenon-wait-5ms-after-set-1.8V-signal-enabl
patches.drivers/sdhci-Advertise-2.0v-supply-on-SDIO-host-controller
patches.drivers/spi-imx-do-not-access-registers-while-clocks-disable
+ patches.drivers/spi-a3700-Clear-DATA_OUT-when-performing-a-read.patch
patches.drivers/spi-sun6i-disable-unprepare-clocks-on-remove
patches.drivers/EDAC-octeon-Fix-an-uninitialized-variable-warning
patches.drivers/EDAC-mv64x60-Fix-an-error-handling-path
@@ -15736,6 +15744,7 @@
patches.drivers/mmc-sdhci-pci-Only-do-AMD-tuning-for-HS200
patches.suse/fork-unconditionally-clear-stack-on-fork.patch
patches.fixes/autofs-mount-point-create-should-honour-passed-in-mo.patch
+ patches.fixes/proc-revalidate-kernel-thread-inodes-to-root-root.patch
patches.fixes/0001-kexec_file-do-not-add-extra-alignment-to-efi-memmap.patch
patches.fixes/mm-filemap.c-fix-NULL-pointer-in-page_cache_tree_ins.patch
patches.drivers/0014-arm64-kasan-avoid-pfn_to_nid-before-page-array-is-in.patch
@@ -16093,6 +16102,7 @@
patches.suse/net-sched-actions-fix-refcnt-leak-in-skbmod.patch
patches.drivers/0001-init-fix-false-positives-in-W-X-checking.patch
patches.fixes/0001-mm-sections-are-not-offlined-during-memory-hotremove.patch
+ patches.fixes/proc-kcore-don-t-bounds-check-against-address-0.patch
patches.fixes/0001-mm-oom-fix-concurrent-munlock-and-oom-reaper-unmap-v.patch
patches.drivers/nvme-fix-use-after-free-in-nvme_free_ns_head.patch
patches.fixes/nvme-Fix-sync-controller-reset-return.patch
@@ -16352,6 +16362,7 @@
patches.suse/msft-hv-1696-KVM-x86-fix-UD-address-of-failed-Hyper-V-hypercalls.patch
patches.fixes/sched-tracing-Fix-trace_sched_pi_setprio-for-deboost.patch
patches.arch/47-kvm-vmx-expose-ssbd-properly-to-guests.patch
+ patches.arch/x86-speculation-simplify-the-cpu-bug-detection-logic.patch
patches.fixes/tracing-Fix-crash-when-freeing-instances-with-event-.patch
patches.suse/0001-tracing-Make-the-snapshot-trigger-work-with-instance.patch
patches.fixes/afs-Fix-directory-permissions-check.patch
@@ -16432,6 +16443,14 @@
patches.drivers/hwmon-asus_atk0110-Replace-deprecated-device-registe
patches.drivers/spi-bcm63xx-hspi-Enable-the-clock-before-calling-clk
patches.drivers/spi-pxa2xx-check-clk_prepare_enable-return-value
+ patches.suse/0001-btrfs-Factor-out-common-delayed-refs-init-code.patch
+ patches.suse/0002-btrfs-Use-init_delayed_ref_common-in-add_delayed_tre.patch
+ patches.suse/0003-btrfs-Use-init_delayed_ref_common-in-add_delayed_dat.patch
+ patches.suse/0004-btrfs-Open-code-add_delayed_tree_ref.patch
+ patches.suse/0005-btrfs-Open-code-add_delayed_data_ref.patch
+ patches.suse/0006-btrfs-Introduce-init_delayed_ref_head.patch
+ patches.suse/0007-btrfs-Use-init_delayed_ref_head-in-add_delayed_ref_h.patch
+ patches.suse/0008-btrfs-split-delayed-ref-head-initialization-and-addi.patch
patches.suse/0001-btrfs-qgroup-Search-commit-root-for-rescan-to-avoid-.patch
patches.suse/0002-btrfs-qgroup-Finish-rescan-when-hit-the-last-leaf-of.patch
patches.suse/btrfs-update-stale-comments-referencing-vmtruncate.patch
@@ -18005,6 +18024,7 @@
patches.suse/sched-numa-Update-the-scan-period-without-holding-the-numa_group-lock.patch
patches.suse/sched-numa-Use-group_weights-to-identify-if-migration-degrades-locality.patch
patches.suse/sched-numa-Move-task_numa_placement-closer-to-numa_migrate_preferred.patch
+ patches.arch/locking-atomics-asm-generic-move-some-macros-from-linux-bitops-h-to-a-new-linux-bits-h-file.patch
patches.arch/perf-x86-intel-lbr-fix-incomplete-lbr-call-stack
patches.fixes/kprobes-make-list-and-blacklist-root-user-read-only.patch
patches.arch/kprobes-x86-fix-p-uses-in-error-messages
@@ -19473,6 +19493,7 @@
patches.fixes/s390-sles12sp4-pkey-move-pckmo-subfunction-available-checks-away-from-module-init.patch
patches.suse/rcu-Make-need_resched-respond-to-urgent-RCU-QS-needs.patch
patches.fixes/kprobes-Return-error-if-we-fail-to-reuse-kprobe-inst.patch
+ patches.arch/x86-cpu-sanitize-fam6_atom-naming.patch
patches.suse/sched-numa-remove-unused-code-from-update_numa_stats.patch
patches.suse/sched-numa-remove-unused-nr_running-field.patch
patches.arch/x86-corruption-check-fix-panic-in-memory_corruption_check-when-boot-option-without-value-is-provided
@@ -20316,6 +20337,7 @@
patches.drivers/i2c-scmi-Fix-probe-error-on-devices-with-an-empty-SM.patch
patches.fixes/nvme-validate-controller-state-before-rescheduling-k.patch
patches.drivers/Revert-PCI-ASPM-Do-not-initialize-link-state-when-as.patch
+ patches.fixes/vhost-vsock-fix-reset-orphans-race-with-close-timeou.patch
patches.fixes/virtio-s390-avoid-race-on-vcdev-config
patches.fixes/virtio-s390-fix-race-in-ccw_io_helper
patches.drivers/vhost-vsock-fix-use-after-free-in-network-stack-call.patch
@@ -20526,6 +20548,7 @@
patches.arch/kvm-nvmx-set-vm-instruction-error-for-vmptrld-of-unbacked-page
patches.arch/kvm-nvmx-free-the-vmread-vmwrite-bitmaps-if-alloc_kvm_area-fails
patches.arch/kvm-vmx-set-ia32_tsc_aux-for-legacy-mode-guests
+ patches.arch/kvm-x86-report-stibp-on-get_supported_cpuid.patch
patches.fixes/arm-arm64-KVM-vgic-Force-VM-halt-when-changing-the-a.patch
patches.arch/KVM-PPC-Book3S-HV-Fix-race-between-kvm_unmap_hva_ran.patch
patches.fixes/KVM-PPC-Book3S-PR-Set-hflag-to-indicate-that-POWER9-.patch
@@ -20806,6 +20829,7 @@
patches.suse/ipv6-Consider-sk_bound_dev_if-when-binding-a-socket-to.patch
patches.drivers/ALSA-hda-realtek-Enable-the-headset-mic-auto-detecti.patch
patches.drivers/ALSA-hda-tegra-clear-pending-irq-handlers.patch
+ patches.fixes/proc-sysctl-fix-return-error-for-proc_doulongvec_min.patch
patches.fixes/ARM-8808-1-kexec-offline-panic_smp_self_stop-CPU.patch
patches.fixes/ceph-don-t-update-importing-cap-s-mseq-when-handing-cap-export.patch
patches.fixes/xfs-xfs_buf-drop-useless-LIST_HEAD.patch
@@ -21070,6 +21094,8 @@
patches.fixes/dccp-fool-proof-ccid_hc_-rt-x_parse_options.patch
patches.fixes/bpf-fix-lockdep-false-positive-in-percpu_freelist.patch
patches.fixes/bpf-Fix-syscall-s-stackmap-lookup-potential-deadlock.patch
+ patches.fixes/vsock-virtio-fix-kernel-panic-after-device-hot-unplu.patch
+ patches.fixes/vsock-virtio-reset-connected-sockets-on-device-remov.patch
patches.suse/net-systemport-Fix-WoL-with-password-after-deep-slee.patch
patches.suse/net-dp83640-expire-old-TX-skb.patch
patches.suse/0001-s390-qeth-fix-use-after-free-in-error-path.patch
@@ -21217,6 +21243,9 @@
patches.fixes/fix-cgroup_do_mount-handling-of-failure-exits.patch
patches.fixes/copy_mount_string-Limit-string-length-to-PATH_MAX.patch
patches.fixes/exec-Fix-mem-leak-in-kernel_read_file.patch
+ patches.fixes/vfio_pci-Enable-memory-accesses-before-calling-pci_m.patch
+ patches.drivers/mtd-docg3-Fix-passing-zero-to-PTR_ERR-warning-in-doc.patch
+ patches.drivers/mtd-docg3-fix-a-possible-memory-leak-of-mtd-name.patch
patches.drivers/mmc-sdhci-esdhc-imx-fix-HS400-timing-issue.patch
patches.drivers/mmc-sdhci-brcmstb-handle-mmc_of_parse-errors-during-.patch
patches.drivers/mmc-omap-fix-the-maximum-timeout-setting.patch
@@ -21503,6 +21532,7 @@
patches.suse/net-hsr-fix-possible-crash-in-add_timer.patch
patches.suse/route-set-the-deleted-fnhe-fnhe_daddr-to-0-in-ip_del.patch
patches.fixes/0001-vxlan-Fix-GRO-cells-race-condition-between-receive-a.patch
+ patches.fixes/vsock-virtio-fix-kernel-panic-from-virtio_transport_.patch
patches.fixes/0001-tcp-handle-inet_csk_reqsk_queue_add-failures.patch
patches.fixes/bpf-fix-replace_map_fd_with_map_ptr-s-ldimm64-second.patch
patches.suse/rxrpc-Fix-client-call-queueing-waiting-for-channel.patch
@@ -21526,6 +21556,7 @@
patches.fixes/perf-x86-intel-generalize-dynamic-constraint-creation.patch
patches.arch/x86-add-tsx-force-abort-cpuid-msr
patches.fixes/perf-x86-intel-implement-support-for-tsx-force-abort.patch
+ patches.fixes/kernel-sysctl.c-add-missing-range-check-in-do_proc_d.patch
patches.fixes/fsdevpts-always-delete-dcache-dentry-s-in-dput.patch
patches.fixes/splice-dont-merge-into-linked-buffers.patch
patches.fixes/NFS-Fix-I-O-request-leakages.patch
@@ -21715,6 +21746,7 @@
patches.drivers/USB-serial-option-add-Olicard-600.patch
patches.drivers/serial-max310x-Fix-to-avoid-potential-NULL-pointer-d.patch
patches.drivers/tty-atmel_serial-fix-a-potential-NULL-pointer-derefe.patch
+ patches.drivers/sc16is7xx-missing-unregister-delete-driver-on-error-.patch
patches.drivers/serial-ar933x_uart-Fix-build-failure-with-disabled-c.patch
patches.drivers/serial-sh-sci-Fix-setting-SCSCR_TIE-while-transferri.patch
patches.drivers/Disable-kgdboc-failed-by-echo-space-to-sys-module-kg.patch
@@ -21741,6 +21773,7 @@
patches.drivers/fm10k-Fix-a-potential-NULL-pointer-dereference.patch
patches.drivers/qmi_wwan-add-Olicard-600.patch
patches.fixes/openvswitch-fix-flow-actions-reallocation.patch
+ patches.fixes/net-rds-force-to-destroy-connection-if-t_sock-is-NUL.patch
patches.fixes/bpf-fix-use-after-free-in-bpf_evict_inode.patch
patches.suse/kcm-switch-order-of-device-registration-to-fix-a-cra.patch
patches.fixes/0001-ipv6-Fix-dangling-pointer-when-ipv6-fragment.patch
@@ -21748,27 +21781,42 @@
patches.drivers/ibmvnic-Fix-completion-structure-initialization.patch
patches.drm/drm-i915-gvt-do-not-deliver-a-workload-if-its-creati.patch
patches.drm/0002-drm-i915-gvt-do-not-let-pin-count-of-shadow-mm-go-ne.patch
+ patches.fixes/vfio-pci-use-correct-format-characters.patch
patches.drivers/vfio-type1-limit-dma-mappings-per-container
patches.fixes/dm-disable-DISCARD-if-the-underlying-storage-no-long.patch
patches.fixes/mm-huge_memory.c-fix-modifying-of-page-protection-by-insert_pfn_pmd.patch
+ patches.fixes/kernel-sysctl.c-fix-out-of-bounds-access-when-settin.patch
patches.fixes/0001-xen-Prevent-buffer-overflow-in-privcmd-ioctl.patch
patches.drivers/tpm-Fix-the-type-of-the-return-value-in-calc_tpm2_ev.patch
patches.drivers/NFC-nci-Add-some-bounds-checking-in-nci_hci_cmd_rece.patch
patches.drivers/Bluetooth-btusb-request-wake-pin-with-NOAUTOEN.patch
+ patches.fixes/virtio_pci-fix-a-NULL-pointer-reference-in-vp_del_vq.patch
+ patches.fixes/virtio-Honour-may_reduce_num-in-vring_create_virtque.patch
patches.drm/0001-drm-udl-add-a-release-method-and-delay-modeset-teard.patch
patches.drm/0003-drm-mediatek-Fix-an-error-code-in-mtk_hdmi_dt_parse_.patch
+ patches.drm/drm-mediatek-fix-possible-object-reference-leak.patch
patches.drm/drm-i915-gvt-Annotate-iomem-usage.patch
patches.drivers/ALSA-hda-realtek-Add-quirk-for-Tuxedo-XC-1509.patch
patches.drivers/ALSA-seq-Fix-OOB-reads-from-strlcpy.patch
patches.drivers/ALSA-hda-Add-two-more-machines-to-the-power_save_bla.patch
+ patches.drivers/ASoC-hdmi-codec-fix-S-PDIF-DAI.patch
+ patches.drivers/ASoC-soc-pcm-fix-a-codec-fixup-issue-in-TDM-case.patch
+ patches.drivers/ASoC-nau8824-fix-the-issue-of-the-widget-with-prefix.patch
+ patches.drivers/ASoC-nau8810-fix-the-issue-of-widget-with-prefixed-n.patch
+ patches.drivers/ASoC-samsung-odroid-Fix-clock-configuration-for-4410.patch
+ patches.drivers/ASoC-wm_adsp-Add-locking-to-wm_adsp2_bus_error.patch
+ patches.drivers/ASoC-cs4270-Set-auto-increment-bit-for-register-writ.patch
patches.drivers/ASoC-fsl_esai-fix-channel-swap-issue-when-stream-sta.patch
+ patches.drivers/ASoC-tlv320aic32x4-Fix-Common-Pins.patch
patches.drivers/ASoC-stm32-fix-sai-driver-name-initialisation.patch
patches.drivers/iommu-amd-set-exclusion-range-correctly
+ patches.fixes/linux-kernel.h-Use-parentheses-around-argument-in-u6.patch
patches.arch/powerpc-vdso32-fix-CLOCK_MONOTONIC-on-PPC64.patch
patches.drivers/PCI-Add-function-1-DMA-alias-quirk-for-Marvell-9170-.patch
patches.fixes/0001-PCI-pciehp-Ignore-Link-State-Changes-after-powering-.patch
patches.fixes/clk-x86-Add-system-specific-quirk-to-mark-clocks-as-.patch
patches.drivers/platform-x86-pmc_atom-Drop-__initconst-on-dmi-table.patch
+ patches.fixes/virtio-blk-limit-number-of-hw-queues-by-nr_cpu_ids.patch
patches.arch/svm-avic-fix-invalidate-logical-apic-id-entry
patches.arch/kvm-x86-svm-make-sure-nmi-is-injected-after-nmi_singlestep
patches.arch/kvm-x86-don-t-clear-efer-during-smm-transitions-for-32-bit-vcpu
@@ -21795,6 +21843,8 @@
patches.drivers/staging-comedi-vmk80xx-Fix-possible-double-free-of-u.patch
patches.drivers/staging-comedi-ni_usb6501-Fix-use-of-uninitialized-m.patch
patches.drivers/staging-comedi-ni_usb6501-Fix-possible-double-free-o.patch
+ patches.drivers/sc16is7xx-move-label-err_spi-to-correct-section.patch
+ patches.drivers/sc16is7xx-put-err_spi-and-err_i2c-into-correct-ifdef.patch
patches.fixes/device_cgroup-fix-RCU-imbalance-in-error-case.patch
patches.arch/x86-speculation-prevent-deadlock-on-ssb_state-lock.patch
patches.drivers/ALSA-hda-Initialize-power_state-field-properly.patch
@@ -21853,31 +21903,63 @@
patches.drivers/spi-bcm2835aux-warn-in-dmesg-that-native-cs-is-not-r.patch
patches.drivers/spi-bcm2835aux-setup-gpio-cs-to-output-and-correct-l.patch
patches.fixes/0001-btrfs-Don-t-panic-when-we-can-t-find-a-root-key.patch
+ patches.fixes/0001-btrfs-reloc-Fix-NULL-pointer-dereference-due-to-expa.patch
+ patches.suse/0001-btrfs-delayed-ref-Introduce-better-documented-delaye.patch
+ patches.suse/0002-btrfs-extent-tree-Open-code-process_func-in-__btrfs_.patch
patches.drivers/mmc-core-fix-possible-use-after-free-of-host.patch
+ patches.drivers/phy-sun4i-usb-Make-sure-to-disable-PHY0-passby-for-p.patch
patches.drivers/stm-class-Fix-channel-free-in-stm-output-free-path.patch
+ patches.drivers/intel_th-pci-Add-Comet-Lake-support.patch
patches.drivers/intel_th-msu-Fix-single-mode-with-IOMMU.patch
patches.drivers/ALSA-line6-Avoid-polluting-led_-namespace.patch
patches.drivers/leds-avoid-races-with-workqueue.patch
patches.fixes/md-batch-flush-requests.patch
+ patches.suse/block-disk_events-introduce-event-flags.patch
+ patches.fixes/Revert-ide-unexport-DISK_EVENT_MEDIA_CHANGE-for-ide-.patch
+ patches.suse/Revert-block-unexport-DISK_EVENT_MEDIA_CHANGE-for.patch
+ patches.suse/block-check_events-don-t-bother-with-events-if-un.patch
patches.fixes/audit-fix-a-memleak-caused-by-auditing-load-module.patch
patches.drivers/ibmvnic-Report-actual-backing-device-speed-and-duple.patch
patches.fixes/openvswitch-add-seqadj-extension-when-NAT-is-used.patch
patches.drivers/b43-shut-up-clang-Wuninitialized-variable-warning.patch
patches.drivers/mwifiex-Fix-mem-leak-in-mwifiex_tm_cmd.patch
+ patches.drivers/Bluetooth-hidp-fix-buffer-overflow.patch
+ patches.drivers/Bluetooth-Align-minimum-encryption-key-size-for-LE-a.patch
+ patches.drivers/ssb-Fix-possible-NULL-pointer-dereference-in-ssb_hos.patch
patches.drivers/mwifiex-prevent-an-array-overflow.patch
patches.drivers/at76c50x-usb-Don-t-register-led_trigger-if-usb_regis.patch
patches.drivers/mwl8k-Fix-rate_idx-underflow.patch
patches.drivers/rtlwifi-rtl8723ae-Fix-missing-break-in-switch-statem.patch
patches.drivers/brcm80211-potential-NULL-dereference-in-brcmf_cfg802.patch
+ patches.fixes/0001-dt-bindings-net-Fix-a-typo-in-the-phy-mode-list-for-.patch
+ patches.drivers/usb-storage-Set-virt_boundary_mask-to-avoid-SG-overf.patch
patches.drivers/USB-cdc-acm-fix-unthrottle-races.patch
patches.fixes/0001-UAS-fix-alignment-of-scatter-gather-segments.patch
patches.drivers/USB-serial-fix-unthrottle-races.patch
patches.drivers/USB-serial-f81232-fix-interrupt-worker-not-stop.patch
+ patches.drivers/dwc2-gadget-Fix-completed-transfer-size-calculation-.patch
patches.drivers/usb-dwc3-Fix-default-lpm_nyet_threshold-value.patch
patches.drivers/tty-vt.c-Fix-TIOCL_BLANKSCREEN-console-blanking-if-b.patch
patches.drivers/tty-pty-Fix-race-condition-between-release_one_tty-a.patch
+ patches.drivers/Revert-tty-pty-Fix-race-condition-between-release_on.patch
patches.drivers/ipmi-ssif-compare-block-number-correctly-for-multi-p.patch
+ patches.drivers/media-ivtv-update-pos-correctly-in-ivtv_read_pos.patch
+ patches.drivers/media-cx18-update-pos-correctly-in-cx18_read_pos.patch
+ patches.drivers/media-wl128x-Fix-an-error-code-in-fm_download_firmwa.patch
+ patches.drivers/media-cx23885-check-allocation-return.patch
+ patches.drivers/media-serial_ir-Fix-use-after-free-in-serial_ir_init.patch
+ patches.drivers/media-davinci-isif-avoid-uninitialized-variable-use.patch
+ patches.drivers/media-tw5864-Fix-possible-NULL-pointer-dereference-i.patch
+ patches.drivers/media-wl128x-prevent-two-potential-buffer-overflows.patch
+ patches.drivers/media-ov2659-fix-unbalanced-mutex_lock-unlock.patch
+ patches.drivers/media-vivid-use-vfree-instead-of-kfree-for-dev-bitma.patch
+ patches.fixes/0001-media-pvrusb2-Prevent-a-buffer-overflow.patch
patches.fixes/scripts-override-locale-from-environment-when-runnin.patch
+ patches.drm/drm-i915-Fix-I915_EXEC_RING_MASK.patch
+ patches.drm/drm-fb-helper-dpms_legacy-Only-set-on-connectors-in-.patch
+ patches.drm/0004-drm-i915-gvt-Fix-incorrect-mask-of-mmio-0x22028-in-g.patch
+ patches.drm/0005-drm-meson-add-size-and-alignment-requirements-for-du.patch
+ patches.drm/drm-rockchip-shutdown-drm-subsystem-on-shutdown.patch
patches.drivers/ALSA-timer-Unify-timer-callback-process-code.patch
patches.drivers/ALSA-timer-Make-sure-to-clear-pending-ack-list.patch
patches.drivers/ALSA-timer-Check-ack_list-emptiness-instead-of-bit-f.patch
@@ -21891,19 +21973,51 @@
patches.drivers/ALSA-timer-Coding-style-fixes.patch
patches.drivers/Revert-ALSA-seq-Protect-in-kernel-ioctl-calls-with-m.patch
patches.drivers/ALSA-seq-Cover-unsubscribe_port-in-list_mutex.patch
+ patches.drivers/ALSA-seq-Simplify-snd_seq_kernel_client_enqueue-help.patch
+ patches.drivers/ALSA-seq-Protect-racy-pool-manipulation-from-OSS-seq.patch
+ patches.drivers/ALSA-seq-Correct-unlock-sequence-at-snd_seq_client_i.patch
+ patches.drivers/ALSA-emu10k1-Drop-superfluous-id-uniquification-beha.patch
+ patches.drivers/ALSA-core-Don-t-refer-to-snd_cards-array-directly.patch
patches.drivers/ALSA-usb-audio-Handle-the-error-from-snd_usb_mixer_a.patch
patches.drivers/ALSA-hda-realtek-EAPD-turn-on-later.patch
patches.drivers/ALSA-usb-audio-Fix-a-memory-leak-bug.patch
patches.drivers/ALSA-usx2y-fix-a-double-free-bug.patch
patches.drivers/ALSA-hda-Register-irq-handler-after-the-chip-initial.patch
+ patches.drivers/ASoC-fix-valid-stream-condition.patch
patches.drivers/ASoC-fsl_esai-Fix-missing-break-in-switch-statement.patch
+ patches.drivers/ASoC-Intel-avoid-Oops-if-DMA-setup-fails.patch
patches.drivers/ALSA-hda-hdmi-Read-the-pin-sense-from-register-when-.patch
patches.drivers/ALSA-hda-hdmi-Consider-eld_valid-when-reporting-jack.patch
patches.drivers/ALSA-hdea-realtek-Headset-fixup-for-System76-Gazelle.patch
patches.drivers/ASoC-RT5677-SPI-Disable-16Bit-SPI-Transfers.patch
patches.drivers/ASoC-max98090-Fix-restore-of-DAPM-Muxes.patch
+ patches.drivers/dmaengine-axi-dmac-Don-t-check-the-number-of-frames-.patch
+ patches.drivers/dmaengine-tegra210-dma-free-dma-controller-in-remove.patch
+ patches.drivers/clk-rockchip-fix-wrong-clock-definitions-for-rk3328.patch
+ patches.drivers/clk-rockchip-Fix-video-codec-clocks-on-rk3288.patch
patches.arch/powerpc-pseries-Track-LMB-nid-instead-of-using-devic.patch
patches.arch/powerpc-tm-Avoid-machine-crash-on-rt_sigreturn.patch
+ patches.drivers/pwm-Fix-deadlock-warning-when-removing-PWM-device.patch
+ patches.drivers/pwm-tiehrpwm-Update-shadow-register-for-disabling-PW.patch
+ patches.drivers/pwm-meson-Consider-128-a-valid-pre-divider.patch
+ patches.drivers/pwm-meson-Don-t-disable-PWM-when-setting-duty-repeat.patch
+ patches.drivers/pwm-meson-Use-the-spin-lock-only-to-protect-register.patch
+ patches.drivers/omapfb-add-missing-of_node_put-after-of_device_is_av.patch
+ patches.drivers/platform-x86-dell-rbtn-Add-missing-include.patch
+ patches.drivers/platform-x86-intel_pmc_ipc-adding-error-handling.patch
+ patches.drivers/platform-x86-intel_punit_ipc-Revert-Fix-resource-ior.patch
+ patches.drivers/platform-x86-alienware-wmi-printing-the-wrong-error-.patch
+ patches.drivers/platform-x86-sony-laptop-Fix-unintentional-fall-thro.patch
+ patches.fixes/vfio-mdev-Avoid-release-parent-reference-during-erro.patch
+ patches.fixes/vfio-mdev-Fix-aborting-mdev-child-device-removal-if-.patch
+ patches.drivers/mtd-nand-omap-Fix-comment-in-platform-data-using-wro.patch
+ patches.fixes/0001-mtd-spi-nor-intel-spi-Avoid-crossing-4K-address-boun.patch
+ patches.drivers/mtd-part-fix-incorrect-format-specifier-for-an-unsig.patch
+ patches.drivers/iommu-vt-d-don-t-request-page-request-irq-under-dmar_global_lock
+ patches.drivers/iommu-vt-d-set-intel_iommu_gfx_mapped-correctly
+ patches.drivers/iommu-vt-d-make-kernel-parameter-igfx_off-work-with-viommu
+ patches.drivers/net-ibmvnic-Update-MAC-address-settings-after-adapte.patch
+ patches.drivers/net-ibmvnic-Update-carrier-state-after-link-state-ch.patch
# davem/net-next
patches.suse/msft-hv-1766-hv_netvsc-fix-vf-serial-matching-with-pci-slot-info.patch
@@ -21930,6 +22044,8 @@
patches.fixes/ch-fixup-refcounting-imbalance-for-SCSI-devices.patch
patches.suse/scsi-libsas-allocate-sense-buffer-for-bsg-queue.patch
patches.fixes/qla2xxx-always-allocate-qla_tgt_wq.patch
+ patches.suse/lpfc-validate-command-in-lpfc_sli4_scmd_to_wqidx_dis.patch
+ patches.suse/0001-drm-ttm-Remove-warning-about-inconsistent-mapping-in.patch
########################################################
# end of sorted patches
@@ -21938,6 +22054,25 @@
# git://git.infradead.org/nvme.git nvme-5.2
patches.fixes/nvme-multipath-split-bios-with-the-ns_head-bio_set-b.patch
+ # MDS
+ patches.arch/x86-msr-index-cleanup-bit-defines.patch
+ patches.arch/x86-speculation-consolidate-cpu-whitelists.patch
+ patches.arch/x86-speculation-mds-add-basic-bug-infrastructure-for-mds.patch
+ patches.arch/x86-speculation-mds-add-bug_msbds_only.patch
+ patches.arch/x86-kvm-expose-x86_feature_md_clear-to-guests.patch
+ patches.arch/x86-speculation-mds-add-mds_clear_cpu_buffers.patch
+ patches.arch/x86-speculation-mds-clear-cpu-buffers-on-exit-to-user.patch
+ patches.arch/x86-kvm-vmx-add-mds-protection-when-l1d-flush-is-not-active.patch
+ patches.arch/x86-speculation-mds-conditionally-clear-cpu-buffers-on-idle-entry.patch
+ patches.arch/x86-speculation-mds-add-mitigation-control-for-mds.patch
+ patches.arch/x86-speculation-mds-add-sysfs-reporting-for-mds.patch
+ patches.arch/x86-speculation-mds-add-mitigation-mode-vmwerv.patch
+ patches.arch/x86-speculation-mds-add-mds-full-nosmt-cmdline-option.patch
+ patches.arch/x86-speculation-move-arch_smt_update-call-to-after-mitigation-decisions.patch
+ patches.arch/x86-speculation-mds-add-smt-warning-message.patch
+ patches.arch/x86-speculation-mds-print-smt-vulnerable-on-msbds-with-mitigations-off.patch
+ patches.arch/x86-speculation-mds-add-mitigations-support-for-mds.patch
+
########################################################
#
# packaging-specific patches (tweaks for autobuild,
@@ -22211,7 +22346,6 @@
patches.suse/btrfs-qgroups-fix-rescan-worker-running-races.patch
patches.suse/btrfs-suspend-qgroups-during-relocation-recovery.patch
patches.suse/0001-btrfs-qgroup-Make-qgroup-async-transaction-commit-mo.patch
- patches.fixes/0001-btrfs-reloc-Fix-NULL-pointer-dereference-due-to-expa.patch
patches.suse/reiserfs-mark-read-write-mode-unsupported.patch
patches.suse/reiserfs-add-check-to-detect-corrupted-directory-entry.patch
@@ -22671,6 +22805,8 @@
patches.kabi/KVM-Fix-kABI-for-AMD-SMAP-Errata-workaround.patch
patches.kabi/usb_interface-reveive-pm_usage_cnt-for-kabi.patch
+ patches.kabi/snd_seq_kernel_client_enqueue-kabi-compat.patch
+ patches.kabi/Re-export-snd_cards-for-kABI.patch
########################################################
# You'd better have a good reason for adding a patch