Skip to content

Commit 014441d

Browse files
committed
Merge tag 'i2c-for-7.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fix from Wolfram Sang: "A revert for the i801 driver restoring old locking behaviour" * tag 'i2c-for-7.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: i2c: i801: Revert "i2c: i801: replace acpi_lock with I2C bus lock"
2 parents c23719a + cfc69c2 commit 014441d

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

drivers/i2c/busses/i2c-i801.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,10 @@ struct i801_priv {
310310

311311
/*
312312
* If set to true the host controller registers are reserved for
313-
* ACPI AML use.
313+
* ACPI AML use. Needs extra protection by acpi_lock.
314314
*/
315315
bool acpi_reserved;
316+
struct mutex acpi_lock;
316317
};
317318

318319
#define FEATURE_SMBUS_PEC BIT(0)
@@ -894,8 +895,11 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,
894895
int hwpec, ret;
895896
struct i801_priv *priv = i2c_get_adapdata(adap);
896897

897-
if (priv->acpi_reserved)
898+
mutex_lock(&priv->acpi_lock);
899+
if (priv->acpi_reserved) {
900+
mutex_unlock(&priv->acpi_lock);
898901
return -EBUSY;
902+
}
899903

900904
pm_runtime_get_sync(&priv->pci_dev->dev);
901905

@@ -935,6 +939,7 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr,
935939
iowrite8(SMBHSTSTS_INUSE_STS | STATUS_FLAGS, SMBHSTSTS(priv));
936940

937941
pm_runtime_put_autosuspend(&priv->pci_dev->dev);
942+
mutex_unlock(&priv->acpi_lock);
938943
return ret;
939944
}
940945

@@ -1465,7 +1470,7 @@ i801_acpi_io_handler(u32 function, acpi_physical_address address, u32 bits,
14651470
* further access from the driver itself. This device is now owned
14661471
* by the system firmware.
14671472
*/
1468-
i2c_lock_bus(&priv->adapter, I2C_LOCK_SEGMENT);
1473+
mutex_lock(&priv->acpi_lock);
14691474

14701475
if (!priv->acpi_reserved && i801_acpi_is_smbus_ioport(priv, address)) {
14711476
priv->acpi_reserved = true;
@@ -1485,7 +1490,7 @@ i801_acpi_io_handler(u32 function, acpi_physical_address address, u32 bits,
14851490
else
14861491
status = acpi_os_write_port(address, (u32)*value, bits);
14871492

1488-
i2c_unlock_bus(&priv->adapter, I2C_LOCK_SEGMENT);
1493+
mutex_unlock(&priv->acpi_lock);
14891494

14901495
return status;
14911496
}
@@ -1545,6 +1550,7 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
15451550
priv->adapter.dev.parent = &dev->dev;
15461551
acpi_use_parent_companion(&priv->adapter.dev);
15471552
priv->adapter.retries = 3;
1553+
mutex_init(&priv->acpi_lock);
15481554

15491555
priv->pci_dev = dev;
15501556
priv->features = id->driver_data;

0 commit comments

Comments
 (0)