i2c: designware-baytrail: Fix race when resetting the semaphore
authorHans de Goede <hdegoede@redhat.com>
Fri, 10 Feb 2017 10:27:57 +0000 (11:27 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 2 Mar 2017 14:46:34 +0000 (15:46 +0100)
Use iosf_mbi_modify instead of iosf_mbi_read + iosf_mbi_write so that
we keep the iosf_mbi_lock locked during the read-modify-write done to
reset the semaphore.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Acked-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20170210102802.20898-8-hdegoede@redhat.com
drivers/i2c/busses/i2c-designware-baytrail.c

index 650a700f215e572fccc804139a370adfc9bab9f2..8df529c04f8e4181437073b961d8a4a61c92ccd4 100644 (file)
@@ -47,15 +47,8 @@ static int get_sem(struct dw_i2c_dev *dev, u32 *sem)
 
 static void reset_semaphore(struct dw_i2c_dev *dev)
 {
-       u32 data;
-
-       if (iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, PUNIT_SEMAPHORE, &data)) {
-               dev_err(dev->dev, "iosf failed to reset punit semaphore during read\n");
-               return;
-       }
-
-       data &= ~PUNIT_SEMAPHORE_BIT;
-       if (iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE, PUNIT_SEMAPHORE, data))
+       if (iosf_mbi_modify(BT_MBI_UNIT_PMC, MBI_REG_READ, PUNIT_SEMAPHORE,
+                           0, PUNIT_SEMAPHORE_BIT))
                dev_err(dev->dev, "iosf failed to reset punit semaphore during write\n");
 
        pm_qos_update_request(&dev->pm_qos, PM_QOS_DEFAULT_VALUE);