mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-24 09:13:20 -05:00
ACPI / PMIC: xpower: Block P-Unit I2C access during read-modify-write
intel_xpower_pmic_update_power() does a read-modify-write of the output control register. The i2c-designware code blocks the P-Unit I2C access during the read and write by taking the P-Unit's PMIC bus semaphore. But between the read and the write that semaphore is released and the P-Unit could make changes to the register which we then end up overwriting. This commit makes intel_xpower_pmic_update_power() take the semaphore itself so that it is held over the entire read-modify-write, avoiding this race. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
e09db3d241
commit
3c670dba86
1 changed files with 15 additions and 6 deletions
|
@ -8,8 +8,9 @@
|
||||||
#include <linux/acpi.h>
|
#include <linux/acpi.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
#include <linux/mfd/axp20x.h>
|
#include <linux/mfd/axp20x.h>
|
||||||
#include <linux/platform_device.h>
|
|
||||||
#include <linux/regmap.h>
|
#include <linux/regmap.h>
|
||||||
|
#include <linux/platform_device.h>
|
||||||
|
#include <asm/iosf_mbi.h>
|
||||||
#include "intel_pmic.h"
|
#include "intel_pmic.h"
|
||||||
|
|
||||||
#define XPOWER_GPADC_LOW 0x5b
|
#define XPOWER_GPADC_LOW 0x5b
|
||||||
|
@ -172,15 +173,21 @@ static int intel_xpower_pmic_get_power(struct regmap *regmap, int reg,
|
||||||
static int intel_xpower_pmic_update_power(struct regmap *regmap, int reg,
|
static int intel_xpower_pmic_update_power(struct regmap *regmap, int reg,
|
||||||
int bit, bool on)
|
int bit, bool on)
|
||||||
{
|
{
|
||||||
int data;
|
int data, ret;
|
||||||
|
|
||||||
/* GPIO1 LDO regulator needs special handling */
|
/* GPIO1 LDO regulator needs special handling */
|
||||||
if (reg == XPOWER_GPI1_CTRL)
|
if (reg == XPOWER_GPI1_CTRL)
|
||||||
return regmap_update_bits(regmap, reg, GPI1_LDO_MASK,
|
return regmap_update_bits(regmap, reg, GPI1_LDO_MASK,
|
||||||
on ? GPI1_LDO_ON : GPI1_LDO_OFF);
|
on ? GPI1_LDO_ON : GPI1_LDO_OFF);
|
||||||
|
|
||||||
if (regmap_read(regmap, reg, &data))
|
ret = iosf_mbi_block_punit_i2c_access();
|
||||||
return -EIO;
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
if (regmap_read(regmap, reg, &data)) {
|
||||||
|
ret = -EIO;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (on)
|
if (on)
|
||||||
data |= BIT(bit);
|
data |= BIT(bit);
|
||||||
|
@ -188,9 +195,11 @@ static int intel_xpower_pmic_update_power(struct regmap *regmap, int reg,
|
||||||
data &= ~BIT(bit);
|
data &= ~BIT(bit);
|
||||||
|
|
||||||
if (regmap_write(regmap, reg, data))
|
if (regmap_write(regmap, reg, data))
|
||||||
return -EIO;
|
ret = -EIO;
|
||||||
|
out:
|
||||||
|
iosf_mbi_unblock_punit_i2c_access();
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue