Skip to contentSkip to conversation

Add irq PM wakeup

PATCH In review Basavaraj Natikar 4 participants 7 messages Aug 31, 2021 – Sep 16, 2021

Subsystems (3)
lore
Share & tools
lore

Basavaraj Natikar

author maintainer
#0 lore raw

cover Add irq PM wakeup

Changes include to handle IRQ wakeup mode wake the system from sleep states like "suspend to RAM".

Basavaraj Natikar (2):
pinctrl: amd: Add irq field data
pinctrl: amd: Handle wake-up interrupt

 drivers/pinctrl/pinctrl-amd.c | 19 ++++++++++++++-----
 drivers/pinctrl/pinctrl-amd.h |  1 +
 2 files changed, 15 insertions(+), 5 deletions(-)
Signature · 1 line
2.25.1
author maintainer
#1 lore raw

PATCH 1/2 pinctrl: amd: Add irq field data

pinctrl_amd use gpiochip_get_data() to get their local state containers back from the gpiochip passed as amd_gpio chip data.

Hence added irq field data to get directly using amd_gpio chip data.

---
 drivers/pinctrl/pinctrl-amd.c | 9 ++++-----
 drivers/pinctrl/pinctrl-amd.h | 1 +
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/pinctrl/pinctrl-amd.c +4 -5
index 5b764740b829..79b8b7f91996 100644
@@ -904,7 +904,6 @@ static struct pinctrl_desc amd_pinctrl_desc = {
 static int amd_gpio_probe(struct platform_device *pdev)
 {
 	int ret = 0;
-	int irq_base;
 	struct resource *res;
 	struct amd_gpio *gpio_dev;
 	struct gpio_irq_chip *girq;
@@ -927,9 +926,9 @@ static int amd_gpio_probe(struct platform_device *pdev)
 	if (!gpio_dev->base)
 		return -ENOMEM;
 
-	irq_base = platform_get_irq(pdev, 0);
-	if (irq_base < 0)
-		return irq_base;
+	gpio_dev->irq = platform_get_irq(pdev, 0);
+	if (gpio_dev->irq < 0)
+		return gpio_dev->irq;
 
 #ifdef CONFIG_PM_SLEEP
 	gpio_dev->saved_regs = devm_kcalloc(&pdev->dev, amd_pinctrl_desc.npins,
@@ -989,7 +988,7 @@ static int amd_gpio_probe(struct platform_device *pdev)
 		goto out2;
 	}
 
-	ret = devm_request_irq(&pdev->dev, irq_base, amd_gpio_irq_handler,
+	ret = devm_request_irq(&pdev->dev, gpio_dev->irq, amd_gpio_irq_handler,
 			       IRQF_SHARED, KBUILD_MODNAME, gpio_dev);
 	if (ret)
 		goto out2;
drivers/pinctrl/pinctrl-amd.h +1 -0
index 95e763424042..1d4317073654 100644
@@ -98,6 +98,7 @@ struct amd_gpio {
 	struct resource         *res;
 	struct platform_device  *pdev;
 	u32			*saved_regs;
+	int			irq;
 };
 
 /*  KERNCZ configuration*/
Signature · 1 line
2.25.1
author maintainer
#2 lore raw

PATCH 2/2 pinctrl: amd: Handle wake-up interrupt

In reply to Basavaraj Natikar

Enable/disable power management wakeup mode, which is disabled by default. enable_irq_wake enables wakes the system from sleep.

Hence added enable/disable irq_wake to handle wake-up interrupt.

---
 drivers/pinctrl/pinctrl-amd.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/pinctrl/pinctrl-amd.c +10 -0
index 79b8b7f91996..d19974aceb2e 100644
@@ -445,6 +445,7 @@ static int amd_gpio_irq_set_wake(struct irq_data *d, unsigned int on)
 	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
 	struct amd_gpio *gpio_dev = gpiochip_get_data(gc);
 	u32 wake_mask = BIT(WAKE_CNTRL_OFF_S0I3) | BIT(WAKE_CNTRL_OFF_S3);
+	int err;
 
 	raw_spin_lock_irqsave(&gpio_dev->lock, flags);
 	pin_reg = readl(gpio_dev->base + (d->hwirq)*4);
@@ -457,6 +458,15 @@ static int amd_gpio_irq_set_wake(struct irq_data *d, unsigned int on)
 	writel(pin_reg, gpio_dev->base + (d->hwirq)*4);
 	raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
 
+	if (on)
+		err = enable_irq_wake(gpio_dev->irq);
+	else
+		err = disable_irq_wake(gpio_dev->irq);
+
+	if (err)
+		dev_err(&gpio_dev->pdev->dev, "failed to %s wake-up interrupt\n",
+			on ? "enable" : "disable");
+
 	return 0;
 }
 
Signature · 1 line
2.25.1
maintainer Acked-by on the v1 series
#3 lore raw
In reply to Basavaraj Natikar
Quoted 11 lines · Basavaraj Natikar

Changes include to handle IRQ wakeup mode wake the system from sleep states like "suspend to RAM".

Basavaraj Natikar (2):
pinctrl: amd: Add irq field data
pinctrl: amd: Handle wake-up interrupt

 drivers/pinctrl/pinctrl-amd.c | 19 ++++++++++++++-----
 drivers/pinctrl/pinctrl-amd.h |  1 +
 2 files changed, 15 insertions(+), 5 deletions(-)

Series Looks good to me.

#4 lore raw
Quoted 10 lines · Shyam Sundar S K
Quoted 7 lines · Basavaraj Natikar

Changes include to handle IRQ wakeup mode wake the system from sleep states like "suspend to RAM".

Basavaraj Natikar (2):
pinctrl: amd: Add irq field data
pinctrl: amd: Handle wake-up interrupt

Quoted 9 lines
Quoted 4 lines
  drivers/pinctrl/pinctrl-amd.c | 19 ++++++++++++++-----
  drivers/pinctrl/pinctrl-amd.h |  1 +
  2 files changed, 15 insertions(+), 5 deletions(-)

Series Looks good to me.

I've confirmed this helps wake-ups on some problematic systems as well myself.

#5 lore raw

[Public]

Quoted 26 lines

-----Original Message-----
From: Limonciello, Mario
Sent: Tuesday, September 7, 2021 13:35
To: S-k, Shyam-sundar <[email protected]>; Natikar, Basavaraj <[email protected]>; [email protected]; linux- [email protected]
Subject: Re: [PATCH 0/2] Add irq PM wakeup

Quoted 17 lines · Shyam Sundar S K
Quoted 11 lines · Basavaraj Natikar

Changes include to handle IRQ wakeup mode wake the system from sleep states like "suspend to RAM".

Basavaraj Natikar (2):
pinctrl: amd: Add irq field data
pinctrl: amd: Handle wake-up interrupt

  drivers/pinctrl/pinctrl-amd.c | 19 ++++++++++++++-----
  drivers/pinctrl/pinctrl-amd.h |  1 +
  2 files changed, 15 insertions(+), 5 deletions(-)

Series Looks good to me.

Quoted 7 lines
Quoted 2 lines

I've confirmed this helps wake-ups on some problematic systems as well myself.

Linus Walleij, Bartosz,

Ping on this one?

Thanks,

#6 lore raw
In reply to Basavaraj Natikar
Quoted 6 lines · Basavaraj Natikar

Changes include to handle IRQ wakeup mode wake the system from sleep states like "suspend to RAM".

Basavaraj Natikar (2):
pinctrl: amd: Add irq field data
pinctrl: amd: Handle wake-up interrupt

Patches applied for fixes.

Thanks! And sorry for taking so long.

Yours,
Linus Walleij