Patch "gpio: pca953x: Add mutex_lock for regcache sync in PM" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    gpio: pca953x: Add mutex_lock for regcache sync in PM

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     gpio-pca953x-add-mutex_lock-for-regcache-sync-in-pm.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit af44a835c93015f8f78d30895d70dc90bac9301a
Author: Haibo Chen <haibo.chen@xxxxxxx>
Date:   Wed Aug 31 18:37:35 2022 +0800

    gpio: pca953x: Add mutex_lock for regcache sync in PM
    
    [ Upstream commit 518e26f11af2fe4f5bebf9a0351595d508c7077f ]
    
    The regcache sync will set the cache_bypass = true, at that
    time, when there is regmap write operation, it will bypass
    the regmap cache, then the regcache sync will write back the
    value from cache to register, which is not as our expectation.
    
    Though regmap already use its internal lock to avoid such issue,
    but this driver force disable the regmap internal lock in its
    regmap config: disable_locking = true
    
    To avoid this issue, use the driver's own lock to do the protect
    in system PM.
    
    Fixes: b76574300504 ("gpio: pca953x: Restore registers after suspend/resume cycle")
    Signed-off-by: Haibo Chen <haibo.chen@xxxxxxx>
    Signed-off-by: Bartosz Golaszewski <brgl@xxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 317f54f19477e..c81d73d5e0159 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -1198,7 +1198,9 @@ static int pca953x_suspend(struct device *dev)
 {
 	struct pca953x_chip *chip = dev_get_drvdata(dev);
 
+	mutex_lock(&chip->i2c_lock);
 	regcache_cache_only(chip->regmap, true);
+	mutex_unlock(&chip->i2c_lock);
 
 	if (atomic_read(&chip->wakeup_path))
 		device_set_wakeup_path(dev);
@@ -1221,13 +1223,17 @@ static int pca953x_resume(struct device *dev)
 		}
 	}
 
+	mutex_lock(&chip->i2c_lock);
 	regcache_cache_only(chip->regmap, false);
 	regcache_mark_dirty(chip->regmap);
 	ret = pca953x_regcache_sync(dev);
-	if (ret)
+	if (ret) {
+		mutex_unlock(&chip->i2c_lock);
 		return ret;
+	}
 
 	ret = regcache_sync(chip->regmap);
+	mutex_unlock(&chip->i2c_lock);
 	if (ret) {
 		dev_err(dev, "Failed to restore register map: %d\n", ret);
 		return ret;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux