--- /dev/null
+From 01b8cedfd0422326caae308641dcadaa85e0ca72 Mon Sep 17 00:00:00 2001
+From: Satish Babu Patakokila <sbpata@codeaurora.org>
+Date: Fri, 16 Jun 2017 17:33:40 -0700
+Subject: ASoC: compress: Derive substream from stream based on direction
+
+From: Satish Babu Patakokila <sbpata@codeaurora.org>
+
+commit 01b8cedfd0422326caae308641dcadaa85e0ca72 upstream.
+
+Currently compress driver hardcodes direction as playback to get
+substream from the stream. This results in getting the incorrect
+substream for compressed capture usecase.
+To fix this, remove the hardcoding and derive substream based on
+the stream direction.
+
+Signed-off-by: Satish Babu Patakokila <sbpata@codeaurora.org>
+Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org>
+Acked-By: Vinod Koul <vinod.koul@intel.com>
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ sound/soc/soc-compress.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+--- a/sound/soc/soc-compress.c
++++ b/sound/soc/soc-compress.c
+@@ -68,7 +68,8 @@ out:
+ static int soc_compr_open_fe(struct snd_compr_stream *cstream)
+ {
+ struct snd_soc_pcm_runtime *fe = cstream->private_data;
+- struct snd_pcm_substream *fe_substream = fe->pcm->streams[0].substream;
++ struct snd_pcm_substream *fe_substream =
++ fe->pcm->streams[cstream->direction].substream;
+ struct snd_soc_platform *platform = fe->platform;
+ struct snd_soc_dpcm *dpcm;
+ struct snd_soc_dapm_widget_list *list;
+@@ -412,7 +413,8 @@ static int soc_compr_set_params_fe(struc
+ struct snd_compr_params *params)
+ {
+ struct snd_soc_pcm_runtime *fe = cstream->private_data;
+- struct snd_pcm_substream *fe_substream = fe->pcm->streams[0].substream;
++ struct snd_pcm_substream *fe_substream =
++ fe->pcm->streams[cstream->direction].substream;
+ struct snd_soc_platform *platform = fe->platform;
+ int ret = 0, stream;
+
--- /dev/null
+From 138d351eefb727ab9e41a3dc5f112ceb4f6e59f2 Mon Sep 17 00:00:00 2001
+From: Nicholas Bellinger <nab@linux-iscsi.org>
+Date: Fri, 7 Jul 2017 14:45:49 -0700
+Subject: iscsi-target: Add login_keys_workaround attribute for non RFC initiators
+
+From: Nicholas Bellinger <nab@linux-iscsi.org>
+
+commit 138d351eefb727ab9e41a3dc5f112ceb4f6e59f2 upstream.
+
+This patch re-introduces part of a long standing login workaround that
+was recently dropped by:
+
+ commit 1c99de981f30b3e7868b8d20ce5479fa1c0fea46
+ Author: Nicholas Bellinger <nab@linux-iscsi.org>
+ Date: Sun Apr 2 13:36:44 2017 -0700
+
+ iscsi-target: Drop work-around for legacy GlobalSAN initiator
+
+Namely, the workaround for FirstBurstLength ended up being required by
+Mellanox Flexboot PXE boot ROMs as reported by Robert.
+
+So this patch re-adds the work-around for FirstBurstLength within
+iscsi_check_proposer_for_optional_reply(), and makes the key optional
+to respond when the initiator does not propose, nor respond to it.
+
+Also as requested by Arun, this patch introduces a new TPG attribute
+named 'login_keys_workaround' that controls the use of both the
+FirstBurstLength workaround, as well as the two other existing
+workarounds for gPXE iSCSI boot client.
+
+By default, the workaround is enabled with login_keys_workaround=1,
+since Mellanox FlexBoot requires it, and Arun has verified the Qlogic
+MSFT initiator already proposes FirstBurstLength, so it's uneffected
+by this re-adding this part of the original work-around.
+
+Reported-by: Robert LeBlanc <robert@leblancnet.us>
+Cc: Robert LeBlanc <robert@leblancnet.us>
+Reviewed-by: Arun Easi <arun.easi@cavium.com>
+Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/target/iscsi/iscsi_target_configfs.c | 2 +
+ drivers/target/iscsi/iscsi_target_nego.c | 6 ++-
+ drivers/target/iscsi/iscsi_target_parameters.c | 41 +++++++++++++++++--------
+ drivers/target/iscsi/iscsi_target_parameters.h | 2 -
+ drivers/target/iscsi/iscsi_target_tpg.c | 19 +++++++++++
+ drivers/target/iscsi/iscsi_target_tpg.h | 1
+ include/target/iscsi/iscsi_target_core.h | 9 +++++
+ 7 files changed, 64 insertions(+), 16 deletions(-)
+
+--- a/drivers/target/iscsi/iscsi_target_configfs.c
++++ b/drivers/target/iscsi/iscsi_target_configfs.c
+@@ -868,6 +868,7 @@ DEF_TPG_ATTRIB(default_erl);
+ DEF_TPG_ATTRIB(t10_pi);
+ DEF_TPG_ATTRIB(fabric_prot_type);
+ DEF_TPG_ATTRIB(tpg_enabled_sendtargets);
++DEF_TPG_ATTRIB(login_keys_workaround);
+
+ static struct configfs_attribute *lio_target_tpg_attrib_attrs[] = {
+ &iscsi_tpg_attrib_attr_authentication,
+@@ -883,6 +884,7 @@ static struct configfs_attribute *lio_ta
+ &iscsi_tpg_attrib_attr_t10_pi,
+ &iscsi_tpg_attrib_attr_fabric_prot_type,
+ &iscsi_tpg_attrib_attr_tpg_enabled_sendtargets,
++ &iscsi_tpg_attrib_attr_login_keys_workaround,
+ NULL,
+ };
+
+--- a/drivers/target/iscsi/iscsi_target_nego.c
++++ b/drivers/target/iscsi/iscsi_target_nego.c
+@@ -818,7 +818,8 @@ static int iscsi_target_handle_csg_zero(
+ SENDER_TARGET,
+ login->rsp_buf,
+ &login->rsp_length,
+- conn->param_list);
++ conn->param_list,
++ conn->tpg->tpg_attrib.login_keys_workaround);
+ if (ret < 0)
+ return -1;
+
+@@ -888,7 +889,8 @@ static int iscsi_target_handle_csg_one(s
+ SENDER_TARGET,
+ login->rsp_buf,
+ &login->rsp_length,
+- conn->param_list);
++ conn->param_list,
++ conn->tpg->tpg_attrib.login_keys_workaround);
+ if (ret < 0) {
+ iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_INITIATOR_ERR,
+ ISCSI_LOGIN_STATUS_INIT_ERR);
+--- a/drivers/target/iscsi/iscsi_target_parameters.c
++++ b/drivers/target/iscsi/iscsi_target_parameters.c
+@@ -764,7 +764,8 @@ static int iscsi_check_for_auth_key(char
+ return 0;
+ }
+
+-static void iscsi_check_proposer_for_optional_reply(struct iscsi_param *param)
++static void iscsi_check_proposer_for_optional_reply(struct iscsi_param *param,
++ bool keys_workaround)
+ {
+ if (IS_TYPE_BOOL_AND(param)) {
+ if (!strcmp(param->value, NO))
+@@ -772,19 +773,31 @@ static void iscsi_check_proposer_for_opt
+ } else if (IS_TYPE_BOOL_OR(param)) {
+ if (!strcmp(param->value, YES))
+ SET_PSTATE_REPLY_OPTIONAL(param);
+- /*
+- * Required for gPXE iSCSI boot client
+- */
+- if (!strcmp(param->name, IMMEDIATEDATA))
+- SET_PSTATE_REPLY_OPTIONAL(param);
++
++ if (keys_workaround) {
++ /*
++ * Required for gPXE iSCSI boot client
++ */
++ if (!strcmp(param->name, IMMEDIATEDATA))
++ SET_PSTATE_REPLY_OPTIONAL(param);
++ }
+ } else if (IS_TYPE_NUMBER(param)) {
+ if (!strcmp(param->name, MAXRECVDATASEGMENTLENGTH))
+ SET_PSTATE_REPLY_OPTIONAL(param);
+- /*
+- * Required for gPXE iSCSI boot client
+- */
+- if (!strcmp(param->name, MAXCONNECTIONS))
+- SET_PSTATE_REPLY_OPTIONAL(param);
++
++ if (keys_workaround) {
++ /*
++ * Required for Mellanox Flexboot PXE boot ROM
++ */
++ if (!strcmp(param->name, FIRSTBURSTLENGTH))
++ SET_PSTATE_REPLY_OPTIONAL(param);
++
++ /*
++ * Required for gPXE iSCSI boot client
++ */
++ if (!strcmp(param->name, MAXCONNECTIONS))
++ SET_PSTATE_REPLY_OPTIONAL(param);
++ }
+ } else if (IS_PHASE_DECLARATIVE(param))
+ SET_PSTATE_REPLY_OPTIONAL(param);
+ }
+@@ -1421,7 +1434,8 @@ int iscsi_encode_text_output(
+ u8 sender,
+ char *textbuf,
+ u32 *length,
+- struct iscsi_param_list *param_list)
++ struct iscsi_param_list *param_list,
++ bool keys_workaround)
+ {
+ char *output_buf = NULL;
+ struct iscsi_extra_response *er;
+@@ -1457,7 +1471,8 @@ int iscsi_encode_text_output(
+ *length += 1;
+ output_buf = textbuf + *length;
+ SET_PSTATE_PROPOSER(param);
+- iscsi_check_proposer_for_optional_reply(param);
++ iscsi_check_proposer_for_optional_reply(param,
++ keys_workaround);
+ pr_debug("Sending key: %s=%s\n",
+ param->name, param->value);
+ }
+--- a/drivers/target/iscsi/iscsi_target_parameters.h
++++ b/drivers/target/iscsi/iscsi_target_parameters.h
+@@ -40,7 +40,7 @@ extern int iscsi_extract_key_value(char
+ extern int iscsi_update_param_value(struct iscsi_param *, char *);
+ extern int iscsi_decode_text_input(u8, u8, char *, u32, struct iscsi_conn *);
+ extern int iscsi_encode_text_output(u8, u8, char *, u32 *,
+- struct iscsi_param_list *);
++ struct iscsi_param_list *, bool);
+ extern int iscsi_check_negotiated_keys(struct iscsi_param_list *);
+ extern void iscsi_set_connection_parameters(struct iscsi_conn_ops *,
+ struct iscsi_param_list *);
+--- a/drivers/target/iscsi/iscsi_target_tpg.c
++++ b/drivers/target/iscsi/iscsi_target_tpg.c
+@@ -227,6 +227,7 @@ static void iscsit_set_default_tpg_attri
+ a->t10_pi = TA_DEFAULT_T10_PI;
+ a->fabric_prot_type = TA_DEFAULT_FABRIC_PROT_TYPE;
+ a->tpg_enabled_sendtargets = TA_DEFAULT_TPG_ENABLED_SENDTARGETS;
++ a->login_keys_workaround = TA_DEFAULT_LOGIN_KEYS_WORKAROUND;
+ }
+
+ int iscsit_tpg_add_portal_group(struct iscsi_tiqn *tiqn, struct iscsi_portal_group *tpg)
+@@ -899,3 +900,21 @@ int iscsit_ta_tpg_enabled_sendtargets(
+
+ return 0;
+ }
++
++int iscsit_ta_login_keys_workaround(
++ struct iscsi_portal_group *tpg,
++ u32 flag)
++{
++ struct iscsi_tpg_attrib *a = &tpg->tpg_attrib;
++
++ if ((flag != 0) && (flag != 1)) {
++ pr_err("Illegal value %d\n", flag);
++ return -EINVAL;
++ }
++
++ a->login_keys_workaround = flag;
++ pr_debug("iSCSI_TPG[%hu] - TPG enabled bit for login keys workaround: %s ",
++ tpg->tpgt, (a->login_keys_workaround) ? "ON" : "OFF");
++
++ return 0;
++}
+--- a/drivers/target/iscsi/iscsi_target_tpg.h
++++ b/drivers/target/iscsi/iscsi_target_tpg.h
+@@ -39,5 +39,6 @@ extern int iscsit_ta_default_erl(struct
+ extern int iscsit_ta_t10_pi(struct iscsi_portal_group *, u32);
+ extern int iscsit_ta_fabric_prot_type(struct iscsi_portal_group *, u32);
+ extern int iscsit_ta_tpg_enabled_sendtargets(struct iscsi_portal_group *, u32);
++extern int iscsit_ta_login_keys_workaround(struct iscsi_portal_group *, u32);
+
+ #endif /* ISCSI_TARGET_TPG_H */
+--- a/include/target/iscsi/iscsi_target_core.h
++++ b/include/target/iscsi/iscsi_target_core.h
+@@ -64,6 +64,14 @@
+ #define TA_DEFAULT_FABRIC_PROT_TYPE 0
+ /* TPG status needs to be enabled to return sendtargets discovery endpoint info */
+ #define TA_DEFAULT_TPG_ENABLED_SENDTARGETS 1
++/*
++ * Used to control the sending of keys with optional to respond state bit,
++ * as a workaround for non RFC compliant initiators,that do not propose,
++ * nor respond to specific keys required for login to complete.
++ *
++ * See iscsi_check_proposer_for_optional_reply() for more details.
++ */
++#define TA_DEFAULT_LOGIN_KEYS_WORKAROUND 1
+
+ #define ISCSI_IOV_DATA_BUFFER 5
+
+@@ -765,6 +773,7 @@ struct iscsi_tpg_attrib {
+ u8 t10_pi;
+ u32 fabric_prot_type;
+ u32 tpg_enabled_sendtargets;
++ u32 login_keys_workaround;
+ struct iscsi_portal_group *tpg;
+ };
+
--- /dev/null
+From c6e83cac3eda5f7dd32ee1453df2f7abb5c6cd46 Mon Sep 17 00:00:00 2001
+From: Krzysztof Kozlowski <krzk@kernel.org>
+Date: Wed, 28 Jun 2017 16:56:18 +0200
+Subject: PM / Domains: Fix unsafe iteration over modified list of device links
+
+From: Krzysztof Kozlowski <krzk@kernel.org>
+
+commit c6e83cac3eda5f7dd32ee1453df2f7abb5c6cd46 upstream.
+
+pm_genpd_remove_subdomain() iterates over domain's master_links list and
+removes matching element thus it has to use safe version of list
+iteration.
+
+Fixes: f721889ff65a ("PM / Domains: Support for generic I/O PM domains (v8)")
+Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
+Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/base/power/domain.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/base/power/domain.c
++++ b/drivers/base/power/domain.c
+@@ -1373,7 +1373,7 @@ EXPORT_SYMBOL_GPL(pm_genpd_add_subdomain
+ int pm_genpd_remove_subdomain(struct generic_pm_domain *genpd,
+ struct generic_pm_domain *subdomain)
+ {
+- struct gpd_link *link;
++ struct gpd_link *l, *link;
+ int ret = -EINVAL;
+
+ if (IS_ERR_OR_NULL(genpd) || IS_ERR_OR_NULL(subdomain))
+@@ -1388,7 +1388,7 @@ int pm_genpd_remove_subdomain(struct gen
+ goto out;
+ }
+
+- list_for_each_entry(link, &genpd->master_links, master_node) {
++ list_for_each_entry_safe(link, l, &genpd->master_links, master_node) {
+ if (link->slave != subdomain)
+ continue;
+
--- /dev/null
+From b556b15dc04e9b9b98790f04c21acf5e24f994b2 Mon Sep 17 00:00:00 2001
+From: Krzysztof Kozlowski <krzk@kernel.org>
+Date: Wed, 28 Jun 2017 16:56:19 +0200
+Subject: PM / Domains: Fix unsafe iteration over modified list of domain providers
+
+From: Krzysztof Kozlowski <krzk@kernel.org>
+
+commit b556b15dc04e9b9b98790f04c21acf5e24f994b2 upstream.
+
+of_genpd_del_provider() iterates over list of domain provides and
+removes matching element thus it has to use safe version of list
+iteration.
+
+Fixes: aa42240ab254 (PM / Domains: Add generic OF-based PM domain look-up)
+Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
+Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/base/power/domain.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/base/power/domain.c
++++ b/drivers/base/power/domain.c
+@@ -1642,10 +1642,10 @@ EXPORT_SYMBOL_GPL(__of_genpd_add_provide
+ */
+ void of_genpd_del_provider(struct device_node *np)
+ {
+- struct of_genpd_provider *cp;
++ struct of_genpd_provider *cp, *tmp;
+
+ mutex_lock(&of_genpd_mutex);
+- list_for_each_entry(cp, &of_genpd_providers, link) {
++ list_for_each_entry_safe(cp, tmp, &of_genpd_providers, link) {
+ if (cp->node == np) {
+ list_del(&cp->link);
+ of_node_put(cp->node);
--- /dev/null
+From 01e6a61aceb82e13bec29502a8eb70d9574f97ad Mon Sep 17 00:00:00 2001
+From: Michael Ellerman <mpe@ellerman.id.au>
+Date: Tue, 11 Jul 2017 22:10:54 +1000
+Subject: powerpc/64: Fix atomic64_inc_not_zero() to return an int
+
+From: Michael Ellerman <mpe@ellerman.id.au>
+
+commit 01e6a61aceb82e13bec29502a8eb70d9574f97ad upstream.
+
+Although it's not documented anywhere, there is an expectation that
+atomic64_inc_not_zero() returns a result which fits in an int. This is
+the behaviour implemented on all arches except powerpc.
+
+This has caused at least one bug in practice, in the percpu-refcount
+code, where the long result from our atomic64_inc_not_zero() was
+truncated to an int leading to lost references and stuck systems. That
+was worked around in that code in commit 966d2b04e070 ("percpu-refcount:
+fix reference leak during percpu-atomic transition").
+
+To the best of my grepping abilities there are no other callers
+in-tree which truncate the value, but we should fix it anyway. Because
+the breakage is subtle and potentially very harmful I'm also tagging
+it for stable.
+
+Code generation is largely unaffected because in most cases the
+callers are just using the result for a test anyway. In particular the
+case of fget() that was mentioned in commit a6cf7ed5119f
+("powerpc/atomic: Implement atomic*_inc_not_zero") generates exactly
+the same code.
+
+Fixes: a6cf7ed5119f ("powerpc/atomic: Implement atomic*_inc_not_zero")
+Noticed-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/powerpc/include/asm/atomic.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/arch/powerpc/include/asm/atomic.h
++++ b/arch/powerpc/include/asm/atomic.h
+@@ -460,7 +460,7 @@ static __inline__ int atomic64_add_unles
+ * Atomically increments @v by 1, so long as @v is non-zero.
+ * Returns non-zero if @v was non-zero, and zero otherwise.
+ */
+-static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
++static __inline__ int atomic64_inc_not_zero(atomic64_t *v)
+ {
+ long t1, t2;
+
+@@ -479,7 +479,7 @@ static __inline__ long atomic64_inc_not_
+ : "r" (&v->counter)
+ : "cc", "xer", "memory");
+
+- return t1;
++ return t1 != 0;
+ }
+
+ #endif /* __powerpc64__ */
--- /dev/null
+From 2400fd822f467cb4c886c879d8ad99feac9cf319 Mon Sep 17 00:00:00 2001
+From: Oliver O'Halloran <oohall@gmail.com>
+Date: Thu, 6 Jul 2017 18:46:43 +1000
+Subject: powerpc/asm: Mark cr0 as clobbered in mftb()
+
+From: Oliver O'Halloran <oohall@gmail.com>
+
+commit 2400fd822f467cb4c886c879d8ad99feac9cf319 upstream.
+
+The workaround for the CELL timebase bug does not correctly mark cr0 as
+being clobbered. This means GCC doesn't know that the asm block changes cr0 and
+might leave the result of an unrelated comparison in cr0 across the block, which
+we then trash, leading to basically random behaviour.
+
+Fixes: 859deea949c3 ("[POWERPC] Cell timebase bug workaround")
+Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
+[mpe: Tweak change log and flag for stable]
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/powerpc/include/asm/reg.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/powerpc/include/asm/reg.h
++++ b/arch/powerpc/include/asm/reg.h
+@@ -1236,7 +1236,7 @@ static inline unsigned long mfvtb (void)
+ " .llong 0\n" \
+ ".previous" \
+ : "=r" (rval) \
+- : "i" (CPU_FTR_CELL_TB_BUG), "i" (SPRN_TBRL)); \
++ : "i" (CPU_FTR_CELL_TB_BUG), "i" (SPRN_TBRL) : "cr0"); \
+ rval;})
+ #else
+ #define mftb() ({unsigned long rval; \
--- /dev/null
+From 87c4b83e0fe234a1f0eed131ab6fa232036860d5 Mon Sep 17 00:00:00 2001
+From: Anton Blanchard <anton@samba.org>
+Date: Thu, 15 Jun 2017 09:46:38 +1000
+Subject: powerpc: Fix emulation of mcrf in emulate_step()
+
+From: Anton Blanchard <anton@samba.org>
+
+commit 87c4b83e0fe234a1f0eed131ab6fa232036860d5 upstream.
+
+The mcrf emulation code was using the CR field number directly as the shift
+value, without taking into account that CR fields are numbered from 0-7 starting
+at the high bits. That meant it was looking at the CR fields in the reverse
+order.
+
+Fixes: cf87c3f6b647 ("powerpc: Emulate icbi, mcrf and conditional-trap instructions")
+Signed-off-by: Anton Blanchard <anton@samba.org>
+Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/powerpc/lib/sstep.c | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+--- a/arch/powerpc/lib/sstep.c
++++ b/arch/powerpc/lib/sstep.c
+@@ -687,8 +687,10 @@ int __kprobes analyse_instr(struct instr
+ case 19:
+ switch ((instr >> 1) & 0x3ff) {
+ case 0: /* mcrf */
+- rd = (instr >> 21) & 0x1c;
+- ra = (instr >> 16) & 0x1c;
++ rd = 7 - ((instr >> 23) & 0x7);
++ ra = 7 - ((instr >> 18) & 0x7);
++ rd *= 4;
++ ra *= 4;
+ val = (regs->ccr >> ra) & 0xf;
+ regs->ccr = (regs->ccr & ~(0xfUL << rd)) | (val << rd);
+ goto instr_done;
--- /dev/null
+From 64e756c55aa46fc18fd53e8f3598b73b528d8637 Mon Sep 17 00:00:00 2001
+From: Anton Blanchard <anton@samba.org>
+Date: Thu, 15 Jun 2017 09:46:39 +1000
+Subject: powerpc: Fix emulation of mfocrf in emulate_step()
+
+From: Anton Blanchard <anton@samba.org>
+
+commit 64e756c55aa46fc18fd53e8f3598b73b528d8637 upstream.
+
+From POWER4 onwards, mfocrf() only places the specified CR field into
+the destination GPR, and the rest of it is set to 0. The PowerPC AS
+from version 3.0 now requires this behaviour.
+
+The emulation code currently puts the entire CR into the destination GPR.
+Fix it.
+
+Fixes: 6888199f7fe5 ("[POWERPC] Emulate more instructions in software")
+Signed-off-by: Anton Blanchard <anton@samba.org>
+Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/powerpc/lib/sstep.c | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+--- a/arch/powerpc/lib/sstep.c
++++ b/arch/powerpc/lib/sstep.c
+@@ -969,6 +969,19 @@ int __kprobes analyse_instr(struct instr
+ #endif
+
+ case 19: /* mfcr */
++ if ((instr >> 20) & 1) {
++ imm = 0xf0000000UL;
++ for (sh = 0; sh < 8; ++sh) {
++ if (instr & (0x80000 >> sh)) {
++ regs->gpr[rd] = regs->ccr & imm;
++ break;
++ }
++ imm >>= 4;
++ }
++
++ goto instr_done;
++ }
++
+ regs->gpr[rd] = regs->ccr;
+ regs->gpr[rd] &= 0xffffffffUL;
+ goto instr_done;
--- /dev/null
+From 62e62ffd95539b9220894a7900a619e0f3ef4756 Mon Sep 17 00:00:00 2001
+From: Maurizio Lombardi <mlombard@redhat.com>
+Date: Tue, 27 Jun 2017 11:53:27 +0200
+Subject: scsi: ses: do not add a device to an enclosure if enclosure_add_links() fails.
+
+From: Maurizio Lombardi <mlombard@redhat.com>
+
+commit 62e62ffd95539b9220894a7900a619e0f3ef4756 upstream.
+
+The enclosure_add_device() function should fail if it can't create the
+relevant sysfs links.
+
+Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
+Tested-by: Douglas Miller <dougmill@linux.vnet.ibm.com>
+Acked-by: James Bottomley <jejb@linux.vnet.ibm.com>
+Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/misc/enclosure.c | 14 ++++++++++----
+ 1 file changed, 10 insertions(+), 4 deletions(-)
+
+--- a/drivers/misc/enclosure.c
++++ b/drivers/misc/enclosure.c
+@@ -375,6 +375,7 @@ int enclosure_add_device(struct enclosur
+ struct device *dev)
+ {
+ struct enclosure_component *cdev;
++ int err;
+
+ if (!edev || component >= edev->components)
+ return -EINVAL;
+@@ -384,12 +385,17 @@ int enclosure_add_device(struct enclosur
+ if (cdev->dev == dev)
+ return -EEXIST;
+
+- if (cdev->dev)
++ if (cdev->dev) {
+ enclosure_remove_links(cdev);
+-
+- put_device(cdev->dev);
++ put_device(cdev->dev);
++ }
+ cdev->dev = get_device(dev);
+- return enclosure_add_links(cdev);
++ err = enclosure_add_links(cdev);
++ if (err) {
++ put_device(cdev->dev);
++ cdev->dev = NULL;
++ }
++ return err;
+ }
+ EXPORT_SYMBOL_GPL(enclosure_add_device);
+
perf-intel-pt-clear-fup-flag-on-error.patch
bluetooth-use-constant-time-memory-comparison-for-secret-values.patch
wlcore-fix-64k-page-support.patch
+asoc-compress-derive-substream-from-stream-based-on-direction.patch
+pm-domains-fix-unsafe-iteration-over-modified-list-of-device-links.patch
+pm-domains-fix-unsafe-iteration-over-modified-list-of-domain-providers.patch
+scsi-ses-do-not-add-a-device-to-an-enclosure-if-enclosure_add_links-fails.patch
+iscsi-target-add-login_keys_workaround-attribute-for-non-rfc-initiators.patch
+powerpc-64-fix-atomic64_inc_not_zero-to-return-an-int.patch
+powerpc-fix-emulation-of-mcrf-in-emulate_step.patch
+powerpc-fix-emulation-of-mfocrf-in-emulate_step.patch
+powerpc-asm-mark-cr0-as-clobbered-in-mftb.patch