--- /dev/null
+From a6d8654d885d7d79a3fb82da64eaa489ca332a82 Mon Sep 17 00:00:00 2001
+From: Filipe Manana <fdmanana@suse.com>
+Date: Tue, 8 Jan 2019 11:44:41 +0000
+Subject: Btrfs: fix deadlock when using free space tree due to block group creation
+
+From: Filipe Manana <fdmanana@suse.com>
+
+commit a6d8654d885d7d79a3fb82da64eaa489ca332a82 upstream.
+
+When modifying the free space tree we can end up COWing one of its extent
+buffers which in turn might result in allocating a new chunk, which in
+turn can result in flushing (finish creation) of pending block groups. If
+that happens we can deadlock because creating a pending block group needs
+to update the free space tree, and if any of the updates tries to modify
+the same extent buffer that we are COWing, we end up in a deadlock since
+we try to write lock twice the same extent buffer.
+
+So fix this by skipping pending block group creation if we are COWing an
+extent buffer from the free space tree. This is a case missed by commit
+5ce555578e091 ("Btrfs: fix deadlock when writing out free space caches").
+
+Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202173
+Fixes: 5ce555578e091 ("Btrfs: fix deadlock when writing out free space caches")
+CC: stable@vger.kernel.org # 4.18+
+Signed-off-by: Filipe Manana <fdmanana@suse.com>
+Reviewed-by: David Sterba <dsterba@suse.com>
+Signed-off-by: David Sterba <dsterba@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/btrfs/ctree.c | 16 +++++++++-------
+ 1 file changed, 9 insertions(+), 7 deletions(-)
+
+--- a/fs/btrfs/ctree.c
++++ b/fs/btrfs/ctree.c
+@@ -1051,19 +1051,21 @@ static noinline int __btrfs_cow_block(st
+ parent_start = parent->start;
+
+ /*
+- * If we are COWing a node/leaf from the extent, chunk or device trees,
+- * make sure that we do not finish block group creation of pending block
+- * groups. We do this to avoid a deadlock.
++ * If we are COWing a node/leaf from the extent, chunk, device or free
++ * space trees, make sure that we do not finish block group creation of
++ * pending block groups. We do this to avoid a deadlock.
+ * COWing can result in allocation of a new chunk, and flushing pending
+ * block groups (btrfs_create_pending_block_groups()) can be triggered
+ * when finishing allocation of a new chunk. Creation of a pending block
+- * group modifies the extent, chunk and device trees, therefore we could
+- * deadlock with ourselves since we are holding a lock on an extent
+- * buffer that btrfs_create_pending_block_groups() may try to COW later.
++ * group modifies the extent, chunk, device and free space trees,
++ * therefore we could deadlock with ourselves since we are holding a
++ * lock on an extent buffer that btrfs_create_pending_block_groups() may
++ * try to COW later.
+ */
+ if (root == fs_info->extent_root ||
+ root == fs_info->chunk_root ||
+- root == fs_info->dev_root)
++ root == fs_info->dev_root ||
++ root == fs_info->free_space_root)
+ trans->can_flush_pending_bgs = false;
+
+ cow = btrfs_alloc_tree_block(trans, root, parent_start,
--- /dev/null
+From 0e141d1c65c1dd31c914eb2e11651adcc1a15912 Mon Sep 17 00:00:00 2001
+From: Quentin Perret <quentin.perret@arm.com>
+Date: Wed, 9 Jan 2019 10:42:36 +0000
+Subject: cpufreq: scmi: Fix frequency invariance in slow path
+
+From: Quentin Perret <quentin.perret@arm.com>
+
+commit 0e141d1c65c1dd31c914eb2e11651adcc1a15912 upstream.
+
+The scmi-cpufreq driver calls the arch_set_freq_scale() callback on
+frequency changes to provide scale-invariant load-tracking signals to
+the scheduler. However, in the slow path, it does so while specifying
+the current and max frequencies in different units, hence resulting in a
+broken freq_scale factor.
+
+Fix this by passing all frequencies in KHz, as stored in the CPUFreq
+frequency table.
+
+Fixes: 99d6bdf33877 (cpufreq: add support for CPU DVFS based on SCMI message protocol)
+Signed-off-by: Quentin Perret <quentin.perret@arm.com>
+Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
+Acked-by: Sudeep Holla <sudeep.holla@arm.com>
+Cc: 4.17+ <stable@vger.kernel.org> # v4.17+
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/cpufreq/scmi-cpufreq.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/cpufreq/scmi-cpufreq.c
++++ b/drivers/cpufreq/scmi-cpufreq.c
+@@ -52,9 +52,9 @@ scmi_cpufreq_set_target(struct cpufreq_p
+ int ret;
+ struct scmi_data *priv = policy->driver_data;
+ struct scmi_perf_ops *perf_ops = handle->perf_ops;
+- u64 freq = policy->freq_table[index].frequency * 1000;
++ u64 freq = policy->freq_table[index].frequency;
+
+- ret = perf_ops->freq_set(handle, priv->domain_id, freq, false);
++ ret = perf_ops->freq_set(handle, priv->domain_id, freq * 1000, false);
+ if (!ret)
+ arch_set_freq_scale(policy->related_cpus, freq,
+ policy->cpuinfo.max_freq);
--- /dev/null
+btrfs-fix-deadlock-when-using-free-space-tree-due-to-block-group-creation.patch
+staging-rtl8188eu-fix-module-loading-from-tasklet-for-ccmp-encryption.patch
+staging-rtl8188eu-fix-module-loading-from-tasklet-for-wep-encryption.patch
+cpufreq-scmi-fix-frequency-invariance-in-slow-path.patch
+x86-modpost-replace-last-remnants-of-retpoline-with-config_retpoline.patch
--- /dev/null
+From 84cad97a717f5749a0236abd5ce68da582ea074f Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Wed, 2 Jan 2019 20:12:46 -0600
+Subject: staging: rtl8188eu: Fix module loading from tasklet for CCMP encryption
+
+From: Larry Finger <Larry.Finger@lwfinger.net>
+
+commit 84cad97a717f5749a0236abd5ce68da582ea074f upstream.
+
+Commit 6bd082af7e36 ("staging:r8188eu: use lib80211 CCMP decrypt")
+causes scheduling while atomic bugs followed by a hard freeze whenever
+the driver tries to connect to a CCMP-encrypted network. Experimentation
+showed that the freezes were eliminated when module lib80211 was
+preloaded, which can be forced by calling lib80211_get_crypto_ops()
+directly rather than indirectly through try_then_request_module().
+With this change, no BUG messages are logged.
+
+Fixes: 6bd082af7e36 ("staging:r8188eu: use lib80211 CCMP decrypt")
+Cc: Stable <stable@vger.kernel.org> # v4.17+
+Reported-and-tested-by: Michael Straube <straube.linux@gmail.com>
+Cc: Ivan Safonov <insafonov@gmail.com>
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/staging/rtl8188eu/core/rtw_security.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/staging/rtl8188eu/core/rtw_security.c
++++ b/drivers/staging/rtl8188eu/core/rtw_security.c
+@@ -1292,7 +1292,7 @@ u32 rtw_aes_decrypt(struct adapter *pada
+ struct sk_buff *skb = ((struct recv_frame *)precvframe)->pkt;
+ void *crypto_private = NULL;
+ u8 *key, *pframe = skb->data;
+- struct lib80211_crypto_ops *crypto_ops = try_then_request_module(lib80211_get_crypto_ops("CCMP"), "lib80211_crypt_ccmp");
++ struct lib80211_crypto_ops *crypto_ops = lib80211_get_crypto_ops("CCMP");
+ struct security_priv *psecuritypriv = &padapter->securitypriv;
+ char iv[8], icv[8];
+
--- /dev/null
+From 7775665aadc48a562051834a73519129bf717d73 Mon Sep 17 00:00:00 2001
+From: Larry Finger <Larry.Finger@lwfinger.net>
+Date: Wed, 2 Jan 2019 20:12:47 -0600
+Subject: staging: rtl8188eu: Fix module loading from tasklet for WEP encryption
+
+From: Larry Finger <Larry.Finger@lwfinger.net>
+
+commit 7775665aadc48a562051834a73519129bf717d73 upstream.
+
+Commit 2b2ea09e74a5 ("staging:r8188eu: Use lib80211 to decrypt WEP-frames")
+causes scheduling while atomic bugs followed by a hard freeze whenever
+the driver tries to connect to a WEP-encrypted network. Experimentation
+showed that the freezes were eliminated when module lib80211 was
+preloaded, which can be forced by calling lib80211_get_crypto_ops()
+directly rather than indirectly through try_then_request_module().
+With this change, no BUG messages are logged.
+
+Fixes: 2b2ea09e74a5 ("staging:r8188eu: Use lib80211 to decrypt WEP-frames")
+Cc: Stable <stable@vger.kernel.org> # v4.17+
+Cc: Michael Straube <straube.linux@gmail.com>
+Cc: Ivan Safonov <insafonov@gmail.com>
+Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/staging/rtl8188eu/core/rtw_security.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/staging/rtl8188eu/core/rtw_security.c
++++ b/drivers/staging/rtl8188eu/core/rtw_security.c
+@@ -154,7 +154,7 @@ void rtw_wep_encrypt(struct adapter *pad
+
+ pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset;
+
+- crypto_ops = try_then_request_module(lib80211_get_crypto_ops("WEP"), "lib80211_crypt_wep");
++ crypto_ops = lib80211_get_crypto_ops("WEP");
+
+ if (!crypto_ops)
+ return;
+@@ -210,7 +210,7 @@ int rtw_wep_decrypt(struct adapter *pad
+ void *crypto_private = NULL;
+ int status = _SUCCESS;
+ const int keyindex = prxattrib->key_index;
+- struct lib80211_crypto_ops *crypto_ops = try_then_request_module(lib80211_get_crypto_ops("WEP"), "lib80211_crypt_wep");
++ struct lib80211_crypto_ops *crypto_ops = lib80211_get_crypto_ops("WEP");
+ char iv[4], icv[4];
+
+ if (!crypto_ops) {
--- /dev/null
+From e4f358916d528d479c3c12bd2fd03f2d5a576380 Mon Sep 17 00:00:00 2001
+From: WANG Chao <chao.wang@ucloud.cn>
+Date: Tue, 11 Dec 2018 00:37:25 +0800
+Subject: x86, modpost: Replace last remnants of RETPOLINE with CONFIG_RETPOLINE
+
+From: WANG Chao <chao.wang@ucloud.cn>
+
+commit e4f358916d528d479c3c12bd2fd03f2d5a576380 upstream.
+
+Commit
+
+ 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support")
+
+replaced the RETPOLINE define with CONFIG_RETPOLINE checks. Remove the
+remaining pieces.
+
+ [ bp: Massage commit message. ]
+
+Fixes: 4cd24de3a098 ("x86/retpoline: Make CONFIG_RETPOLINE depend on compiler support")
+Signed-off-by: WANG Chao <chao.wang@ucloud.cn>
+Signed-off-by: Borislav Petkov <bp@suse.de>
+Reviewed-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
+Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>
+Cc: "H. Peter Anvin" <hpa@zytor.com>
+Cc: Andi Kleen <ak@linux.intel.com>
+Cc: Andrew Morton <akpm@linux-foundation.org>
+Cc: Andy Lutomirski <luto@kernel.org>
+Cc: Arnd Bergmann <arnd@arndb.de>
+Cc: Daniel Borkmann <daniel@iogearbox.net>
+Cc: David Woodhouse <dwmw@amazon.co.uk>
+Cc: Geert Uytterhoeven <geert@linux-m68k.org>
+Cc: Jessica Yu <jeyu@kernel.org>
+Cc: Jiri Kosina <jkosina@suse.cz>
+Cc: Kees Cook <keescook@chromium.org>
+Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
+Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
+Cc: Michal Marek <michal.lkml@markovi.net>
+Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
+Cc: Peter Zijlstra <peterz@infradead.org>
+Cc: Tim Chen <tim.c.chen@linux.intel.com>
+Cc: Vasily Gorbik <gor@linux.ibm.com>
+Cc: linux-kbuild@vger.kernel.org
+Cc: srinivas.eeda@oracle.com
+Cc: stable <stable@vger.kernel.org>
+Cc: x86-ml <x86@kernel.org>
+Link: https://lkml.kernel.org/r/20181210163725.95977-1-chao.wang@ucloud.cn
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/x86/kernel/cpu/bugs.c | 2 +-
+ include/linux/compiler-gcc.h | 2 +-
+ include/linux/module.h | 2 +-
+ scripts/mod/modpost.c | 2 +-
+ 4 files changed, 4 insertions(+), 4 deletions(-)
+
+--- a/arch/x86/kernel/cpu/bugs.c
++++ b/arch/x86/kernel/cpu/bugs.c
+@@ -213,7 +213,7 @@ static enum spectre_v2_mitigation spectr
+ static enum spectre_v2_user_mitigation spectre_v2_user __ro_after_init =
+ SPECTRE_V2_USER_NONE;
+
+-#ifdef RETPOLINE
++#ifdef CONFIG_RETPOLINE
+ static bool spectre_v2_bad_module;
+
+ bool retpoline_module_ok(bool has_retpoline)
+--- a/include/linux/compiler-gcc.h
++++ b/include/linux/compiler-gcc.h
+@@ -75,7 +75,7 @@
+ #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
+ #endif
+
+-#ifdef RETPOLINE
++#ifdef CONFIG_RETPOLINE
+ #define __noretpoline __attribute__((indirect_branch("keep")))
+ #endif
+
+--- a/include/linux/module.h
++++ b/include/linux/module.h
+@@ -818,7 +818,7 @@ static inline void module_bug_finalize(c
+ static inline void module_bug_cleanup(struct module *mod) {}
+ #endif /* CONFIG_GENERIC_BUG */
+
+-#ifdef RETPOLINE
++#ifdef CONFIG_RETPOLINE
+ extern bool retpoline_module_ok(bool has_retpoline);
+ #else
+ static inline bool retpoline_module_ok(bool has_retpoline)
+--- a/scripts/mod/modpost.c
++++ b/scripts/mod/modpost.c
+@@ -2157,7 +2157,7 @@ static void add_intree_flag(struct buffe
+ /* Cannot check for assembler */
+ static void add_retpoline(struct buffer *b)
+ {
+- buf_printf(b, "\n#ifdef RETPOLINE\n");
++ buf_printf(b, "\n#ifdef CONFIG_RETPOLINE\n");
+ buf_printf(b, "MODULE_INFO(retpoline, \"Y\");\n");
+ buf_printf(b, "#endif\n");
+ }