public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] ACPI / LPSS: Always disable I2C host controllers
@ 2015-02-18 11:50 Mika Westerberg
  2015-02-18 11:50 ` [PATCH 2/2] ACPI / LPSS: Deassert resets for SPI host controllers on Braswell Mika Westerberg
  2015-02-18 12:54 ` [PATCH 1/2] ACPI / LPSS: Always disable I2C host controllers Mika Westerberg
  0 siblings, 2 replies; 6+ messages in thread
From: Mika Westerberg @ 2015-02-18 11:50 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Len Brown, linux-acpi, linux-kernel, Mika Westerberg, Yang A Fang,
	Yu Chen

On Baytrail and Braswell the BIOS might leave the I2C host controllers
enabled, probably because it uses them for its on purposes. This is fine in
normal cases because the I2C driver will disable the hardware when it is
probed anyway.

However, in case of suspend to disk it is different story. If the driver
happens to be compiled as module the boot kernel never loads the driver
thus leaving host controllers enabled upon loading the hibernation image.

The I2C host controller interrupt mask register has default value of 0x8ff,
in other words it has most of the interrupts unmasked. When combined with
the fact that the host controller is enabled, the driver immediately starts
getting interrupts even before its resume hook is called (once IO-APIC is
resumed). Since the driver is not prepared for this it will crash the
kernel due to NULL pointer derefence because dev->msgs is NULL.

Unfortunately we were not able to get full backtrace to from the console
which could be reproduced here.

In order to fix this even when the driver is compiled as module, we disable
the I2C host controllers in byt_i2c_setup() before devices are created.

Reported-by: Yu Chen <yu.c.chen@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/acpi/acpi_lpss.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index e75737fd7eef..64ccc3bb0826 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -105,6 +105,8 @@ static void lpss_uart_setup(struct lpss_private_data *pdata)
 	}
 }
 
+#define LPSS_I2C_ENABLE			0x6c
+
 static void byt_i2c_setup(struct lpss_private_data *pdata)
 {
 	unsigned int offset;
@@ -117,6 +119,8 @@ static void byt_i2c_setup(struct lpss_private_data *pdata)
 
 	if (readl(pdata->mmio_base + pdata->dev_desc->prv_offset))
 		pdata->fixed_clk_rate = 133000000;
+
+	writel(0, pdata->mmio_base + LPSS_I2C_ENABLE);
 }
 
 static struct lpss_device_desc lpt_dev_desc = {
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-02-18 16:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-18 11:50 [PATCH 1/2] ACPI / LPSS: Always disable I2C host controllers Mika Westerberg
2015-02-18 11:50 ` [PATCH 2/2] ACPI / LPSS: Deassert resets for SPI host controllers on Braswell Mika Westerberg
2015-02-18 16:25   ` Rafael J. Wysocki
2015-02-18 16:13     ` Mika Westerberg
2015-02-18 12:54 ` [PATCH 1/2] ACPI / LPSS: Always disable I2C host controllers Mika Westerberg
2015-02-18 16:24   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox