--- /dev/null
+From 12864ff8545f6b8144fdf1bb89b5663357f29ec4 Mon Sep 17 00:00:00 2001
+From: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
+Date: Thu, 26 Jul 2018 10:58:20 +0200
+Subject: ACPI / LPSS: Avoid PM quirks on suspend and resume from hibernation
+
+From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+
+commit 12864ff8545f6b8144fdf1bb89b5663357f29ec4 upstream.
+
+Commit a09c59130688 (ACPI / LPSS: Avoid PM quirks on suspend and
+resume from S3) modified the ACPI driver for Intel SoCs (LPSS) to
+avoid applying PM quirks on suspend and resume from S3 to address
+system-wide suspend and resume problems on some systems, but it is
+reported that the same issue also affects hibernation, so extend
+the approach used by that commit to cover hibernation as well.
+
+Fixes: a09c59130688 (ACPI / LPSS: Avoid PM quirks on suspend and resume from S3)
+Link: https://bugs.launchpad.net/bugs/1774950
+Reported-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
+Cc: 4.15+ <stable@vger.kernel.org> # 4.15+
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/acpi/acpi_lpss.c | 26 +++++++++++++++++---------
+ 1 file changed, 17 insertions(+), 9 deletions(-)
+
+--- a/drivers/acpi/acpi_lpss.c
++++ b/drivers/acpi/acpi_lpss.c
+@@ -879,6 +879,7 @@ static void acpi_lpss_dismiss(struct dev
+ #define LPSS_GPIODEF0_DMA_LLP BIT(13)
+
+ static DEFINE_MUTEX(lpss_iosf_mutex);
++static bool lpss_iosf_d3_entered;
+
+ static void lpss_iosf_enter_d3_state(void)
+ {
+@@ -921,6 +922,9 @@ static void lpss_iosf_enter_d3_state(voi
+
+ iosf_mbi_modify(LPSS_IOSF_UNIT_LPIOEP, MBI_CR_WRITE,
+ LPSS_IOSF_GPIODEF0, value1, mask1);
++
++ lpss_iosf_d3_entered = true;
++
+ exit:
+ mutex_unlock(&lpss_iosf_mutex);
+ }
+@@ -935,6 +939,11 @@ static void lpss_iosf_exit_d3_state(void
+
+ mutex_lock(&lpss_iosf_mutex);
+
++ if (!lpss_iosf_d3_entered)
++ goto exit;
++
++ lpss_iosf_d3_entered = false;
++
+ iosf_mbi_modify(LPSS_IOSF_UNIT_LPIOEP, MBI_CR_WRITE,
+ LPSS_IOSF_GPIODEF0, value1, mask1);
+
+@@ -944,13 +953,13 @@ static void lpss_iosf_exit_d3_state(void
+ iosf_mbi_modify(LPSS_IOSF_UNIT_LPIO1, MBI_CFG_WRITE,
+ LPSS_IOSF_PMCSR, value2, mask2);
+
++exit:
+ mutex_unlock(&lpss_iosf_mutex);
+ }
+
+-static int acpi_lpss_suspend(struct device *dev, bool runtime)
++static int acpi_lpss_suspend(struct device *dev, bool wakeup)
+ {
+ struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
+- bool wakeup = runtime || device_may_wakeup(dev);
+ int ret;
+
+ if (pdata->dev_desc->flags & LPSS_SAVE_CTX)
+@@ -963,14 +972,14 @@ static int acpi_lpss_suspend(struct devi
+ * wrong status for devices being about to be powered off. See
+ * lpss_iosf_enter_d3_state() for further information.
+ */
+- if ((runtime || !pm_suspend_via_firmware()) &&
++ if (acpi_target_system_state() == ACPI_STATE_S0 &&
+ lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available())
+ lpss_iosf_enter_d3_state();
+
+ return ret;
+ }
+
+-static int acpi_lpss_resume(struct device *dev, bool runtime)
++static int acpi_lpss_resume(struct device *dev)
+ {
+ struct lpss_private_data *pdata = acpi_driver_data(ACPI_COMPANION(dev));
+ int ret;
+@@ -979,8 +988,7 @@ static int acpi_lpss_resume(struct devic
+ * This call is kept first to be in symmetry with
+ * acpi_lpss_runtime_suspend() one.
+ */
+- if ((runtime || !pm_resume_via_firmware()) &&
+- lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available())
++ if (lpss_quirks & LPSS_QUIRK_ALWAYS_POWER_ON && iosf_mbi_available())
+ lpss_iosf_exit_d3_state();
+
+ ret = acpi_dev_resume(dev);
+@@ -1004,12 +1012,12 @@ static int acpi_lpss_suspend_late(struct
+ return 0;
+
+ ret = pm_generic_suspend_late(dev);
+- return ret ? ret : acpi_lpss_suspend(dev, false);
++ return ret ? ret : acpi_lpss_suspend(dev, device_may_wakeup(dev));
+ }
+
+ static int acpi_lpss_resume_early(struct device *dev)
+ {
+- int ret = acpi_lpss_resume(dev, false);
++ int ret = acpi_lpss_resume(dev);
+
+ return ret ? ret : pm_generic_resume_early(dev);
+ }
+@@ -1024,7 +1032,7 @@ static int acpi_lpss_runtime_suspend(str
+
+ static int acpi_lpss_runtime_resume(struct device *dev)
+ {
+- int ret = acpi_lpss_resume(dev, true);
++ int ret = acpi_lpss_resume(dev);
+
+ return ret ? ret : pm_generic_runtime_resume(dev);
+ }
--- /dev/null
+From 460a53106ac39b74625d1104d9a113e0f3716c18 Mon Sep 17 00:00:00 2001
+From: Erik Schmauss <erik.schmauss@intel.com>
+Date: Sat, 28 Jul 2018 14:05:19 -0700
+Subject: ACPICA: AML Parser: ignore control method status in module-level code
+
+From: Erik Schmauss <erik.schmauss@intel.com>
+
+commit 460a53106ac39b74625d1104d9a113e0f3716c18 upstream.
+
+Previous change in the AML parser code blindly set all non-successful
+dispatcher statuses to AE_OK. That approach is incorrect, though,
+because successful control method invocations from module-level
+return AE_CTRL_TRANSFER. Overwriting AE_OK to this status causes the
+AML parser to think that there was no return value from the control
+method invocation.
+
+Fixes: 92c0f4af386 (ACPICA: AML Parser: ignore dispatcher error status during table load)
+Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
+Tested-by: Linus Torvalds <torvalds@linux-foundation.org>
+Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name>
+Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
+Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/acpi/acpica/psloop.c | 19 ++++++++++++-------
+ 1 file changed, 12 insertions(+), 7 deletions(-)
+
+--- a/drivers/acpi/acpica/psloop.c
++++ b/drivers/acpi/acpica/psloop.c
+@@ -709,15 +709,20 @@ acpi_status acpi_ps_parse_loop(struct ac
+ } else
+ if ((walk_state->
+ parse_flags & ACPI_PARSE_MODULE_LEVEL)
++ && status != AE_CTRL_TRANSFER
+ && ACPI_FAILURE(status)) {
+ /*
+- * ACPI_PARSE_MODULE_LEVEL means that we are loading a table by
+- * executing it as a control method. However, if we encounter
+- * an error while loading the table, we need to keep trying to
+- * load the table rather than aborting the table load. Set the
+- * status to AE_OK to proceed with the table load. If we get a
+- * failure at this point, it means that the dispatcher got an
+- * error while processing Op (most likely an AML operand error.
++ * ACPI_PARSE_MODULE_LEVEL flag means that we are currently
++ * loading a table by executing it as a control method.
++ * However, if we encounter an error while loading the table,
++ * we need to keep trying to load the table rather than
++ * aborting the table load (setting the status to AE_OK
++ * continues the table load). If we get a failure at this
++ * point, it means that the dispatcher got an error while
++ * processing Op (most likely an AML operand error) or a
++ * control method was called from module level and the
++ * dispatcher returned AE_CTRL_TRANSFER. In the latter case,
++ * leave the status alone, there's nothing wrong with it.
+ */
+ status = AE_OK;
+ }