]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
pinctrl: amd: Don't save/restore interrupt status and wake status bits
authorBasavaraj Natikar <Basavaraj.Natikar@amd.com>
Mon, 13 Jun 2022 06:41:26 +0000 (12:11 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:45:18 +0000 (11:45 +0200)
commit b8c824a869f220c6b46df724f85794349bafbf23 upstream.

Saving/restoring interrupt and wake status bits across suspend can
cause the suspend to fail if an IRQ is serviced across the
suspend cycle.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
Fixes: 79d2c8bede2c ("pinctrl/amd: save pin registers over suspend/resume")
Link: https://lore.kernel.org/r/20220613064127.220416-3-Basavaraj.Natikar@amd.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/pinctrl/pinctrl-amd.c

index 0645c2c24f508b48ccb9909843ea206a1d2c1406..06923e8859b789499086bd6fdc2dbfb9671e3ff2 100644 (file)
@@ -917,6 +917,7 @@ static int amd_gpio_suspend(struct device *dev)
 {
        struct amd_gpio *gpio_dev = dev_get_drvdata(dev);
        struct pinctrl_desc *desc = gpio_dev->pctrl->desc;
+       unsigned long flags;
        int i;
 
        for (i = 0; i < desc->npins; i++) {
@@ -925,7 +926,9 @@ static int amd_gpio_suspend(struct device *dev)
                if (!amd_gpio_should_save(gpio_dev, pin))
                        continue;
 
-               gpio_dev->saved_regs[i] = readl(gpio_dev->base + pin*4);
+               raw_spin_lock_irqsave(&gpio_dev->lock, flags);
+               gpio_dev->saved_regs[i] = readl(gpio_dev->base + pin * 4) & ~PIN_IRQ_PENDING;
+               raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
        }
 
        return 0;
@@ -935,6 +938,7 @@ static int amd_gpio_resume(struct device *dev)
 {
        struct amd_gpio *gpio_dev = dev_get_drvdata(dev);
        struct pinctrl_desc *desc = gpio_dev->pctrl->desc;
+       unsigned long flags;
        int i;
 
        for (i = 0; i < desc->npins; i++) {
@@ -943,7 +947,10 @@ static int amd_gpio_resume(struct device *dev)
                if (!amd_gpio_should_save(gpio_dev, pin))
                        continue;
 
-               writel(gpio_dev->saved_regs[i], gpio_dev->base + pin*4);
+               raw_spin_lock_irqsave(&gpio_dev->lock, flags);
+               gpio_dev->saved_regs[i] |= readl(gpio_dev->base + pin * 4) & PIN_IRQ_PENDING;
+               writel(gpio_dev->saved_regs[i], gpio_dev->base + pin * 4);
+               raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
        }
 
        return 0;