History

i2c: i801: Allow ACPI AML access I/O ports not reserved for SMBus

Commit 7ae81952cda ("i2c: i801: Allow ACPI SystemIO OpRegion to conflict with PCI BAR") made it possible for AML code to access SMBus I/O ports by installing custom SystemIO OpRegion handler and blocking i80i driver access upon first AML read/write to this OpRegion. However, while ThinkPad T560 does have SystemIO OpRegion declared under the SMBus device, it does not access any of the SMBus registers: Device (SMBU) { ... OperationRegion (SMBP, PCI_Config, 0x50, 0x04) Field (SMBP, DWordAcc, NoLock, Preserve) { , 5, TCOB, 11, Offset (0x04) } Name (TCBV, 0x00) Method (TCBS, 0, NotSerialized) { If ((TCBV == 0x00)) { TCBV = (\_SB.PCI0.SMBU.TCOB << 0x05) } Return (TCBV) /* \_SB_.PCI0.SMBU.TCBV */ } OperationRegion (TCBA, SystemIO, TCBS (), 0x10) Field (TCBA, ByteAcc, NoLock, Preserve) { Offset (0x04), , 9, CPSC, 1 } } Problem with the current approach is that it blocks all I/O port access and because this system has touchpad connected to the SMBus controller after first AML access (happens during suspend/resume cycle) the touchpad fails to work anymore. Fix this so that we allow ACPI AML I/O port access if it does not touch the region reserved for the SMBus.

Mika Westerberg committed 8 years ago

Commit 7fd6d981 parent 5b394b21 file · +8 −1Browse files

Unified · Split

drivers/i2c/busses/i2c-i801.c+8−1
@@ -1415,6 +1415,13 @@ static void i801_add_tco(struct i801_priv *priv) · 1414 unmodified lines
14151415 }
14161416
14171417 #ifdef CONFIG_ACPI
1418+static bool i801_acpi_is_smbus_ioport(const struct i801_priv *priv,
1419+ acpi_physical_address address)
1420+{
1421+ return address >= priv->smba &&
1422+ address <= pci_resource_end(priv->pci_dev, SMBBAR);
1423+}
1424+
14181425 static acpi_status
14191426 i801_acpi_io_handler(u32 function, acpi_physical_address address, u32 bits,
14201427 u64 *value, void *handler_context, void *region_context)
@@ -1430,7 +1437,7 @@ i801_acpi_io_handler(u32 function, acpi_physical_address address, u32 bits, · 9 unmodified lines
14301437 */
14311438 mutex_lock(&priv->acpi_lock);
14321439
1433− if (!priv->acpi_reserved) {
1440+ if (!priv->acpi_reserved && i801_acpi_is_smbus_ioport(priv, address)) {
14341441 priv->acpi_reserved = true;
14351442
14361443 dev_warn(&pdev->dev, "BIOS is accessing SMBus registers\n");