* [PATCH v2] gpio: mxc: release the parent IRQ in runtime suspend
@ 2023-08-09 14:13 Shenwei Wang
2023-08-10 9:59 ` Andy Shevchenko
2023-08-11 14:23 ` Bartosz Golaszewski
0 siblings, 2 replies; 3+ messages in thread
From: Shenwei Wang @ 2023-08-09 14:13 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski
Cc: Andy Shevchenko, linux-gpio, imx, linux-imx, Shenwei Wang
Release the parent interrupt request during runtime suspend, allowing
the parent interrupt controller to enter runtime suspend if there are
no active users.
This change may not have a visible impact if the parent controller is
the GIC, but it can enable significant power savings for parent IRQ
controllers like IRQSteer inside a subsystem on i.MX8 SoCs. Releasing
the parent IRQ provides an opportunity for the subsystem to enter suspend
states if there are no active users.
Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
---
Changes in v2:
- Reorg the codes for better understanding per Andy's comments.
drivers/gpio/gpio-mxc.c | 41 +++++++++++++++++++++++++++++------------
1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
index 377d3ab8d626..004c6ad7ce52 100644
--- a/drivers/gpio/gpio-mxc.c
+++ b/drivers/gpio/gpio-mxc.c
@@ -62,6 +62,7 @@ struct mxc_gpio_port {
struct clk *clk;
int irq;
int irq_high;
+ void (*mx_irq_handler)(struct irq_desc *desc);
struct irq_domain *domain;
struct gpio_chip gc;
struct device *dev;
@@ -399,6 +400,24 @@ static void mxc_gpio_free(struct gpio_chip *chip, unsigned int offset)
pm_runtime_put(chip->parent);
}
+static void mxc_update_irq_chained_handler(struct mxc_gpio_port *port, bool enable)
+{
+ if (enable)
+ irq_set_chained_handler_and_data(port->irq, port->mx_irq_handler, port);
+ else
+ irq_set_chained_handler_and_data(port->irq, NULL, NULL);
+
+ /* setup handler for GPIO 16 to 31 */
+ if (port->irq_high > 0) {
+ if (enable)
+ irq_set_chained_handler_and_data(port->irq_high,
+ port->mx_irq_handler,
+ port);
+ else
+ irq_set_chained_handler_and_data(port->irq_high, NULL, NULL);
+ }
+}
+
static int mxc_gpio_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
@@ -460,18 +479,12 @@ static int mxc_gpio_probe(struct platform_device *pdev)
* the handler is needed only once, but doing it for every port
* is more robust and easier.
*/
- irq_set_chained_handler(port->irq, mx2_gpio_irq_handler);
- } else {
- /* setup one handler for each entry */
- irq_set_chained_handler_and_data(port->irq,
- mx3_gpio_irq_handler, port);
- if (port->irq_high > 0)
- /* setup handler for GPIO 16 to 31 */
- irq_set_chained_handler_and_data(port->irq_high,
- mx3_gpio_irq_handler,
- port);
- }
+ port->irq_high = -1;
+ port->mx_irq_handler = mx2_gpio_irq_handler;
+ } else
+ port->mx_irq_handler = mx3_gpio_irq_handler;
+ mxc_update_irq_chained_handler(port, true);
err = bgpio_init(&port->gc, &pdev->dev, 4,
port->base + GPIO_PSR,
port->base + GPIO_DR, NULL,
@@ -604,6 +617,7 @@ static int mxc_gpio_runtime_suspend(struct device *dev)
mxc_gpio_save_regs(port);
clk_disable_unprepare(port->clk);
+ mxc_update_irq_chained_handler(port, false);
return 0;
}
@@ -613,9 +627,12 @@ static int mxc_gpio_runtime_resume(struct device *dev)
struct mxc_gpio_port *port = dev_get_drvdata(dev);
int ret;
+ mxc_update_irq_chained_handler(port, true);
ret = clk_prepare_enable(port->clk);
- if (ret)
+ if (ret) {
+ mxc_update_irq_chained_handler(port, false);
return ret;
+ }
mxc_gpio_restore_regs(port);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] gpio: mxc: release the parent IRQ in runtime suspend
2023-08-09 14:13 [PATCH v2] gpio: mxc: release the parent IRQ in runtime suspend Shenwei Wang
@ 2023-08-10 9:59 ` Andy Shevchenko
2023-08-11 14:23 ` Bartosz Golaszewski
1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2023-08-10 9:59 UTC (permalink / raw)
To: Shenwei Wang
Cc: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, linux-gpio,
imx, linux-imx
On Wed, Aug 9, 2023 at 5:13 PM Shenwei Wang <shenwei.wang@nxp.com> wrote:
>
> Release the parent interrupt request during runtime suspend, allowing
> the parent interrupt controller to enter runtime suspend if there are
> no active users.
>
> This change may not have a visible impact if the parent controller is
> the GIC, but it can enable significant power savings for parent IRQ
> controllers like IRQSteer inside a subsystem on i.MX8 SoCs. Releasing
> the parent IRQ provides an opportunity for the subsystem to enter suspend
> states if there are no active users.
Assumed that this change has been tested (esp. when an IRQ is wakeup
source), I'm fine with it,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] gpio: mxc: release the parent IRQ in runtime suspend
2023-08-09 14:13 [PATCH v2] gpio: mxc: release the parent IRQ in runtime suspend Shenwei Wang
2023-08-10 9:59 ` Andy Shevchenko
@ 2023-08-11 14:23 ` Bartosz Golaszewski
1 sibling, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2023-08-11 14:23 UTC (permalink / raw)
To: Shenwei Wang; +Cc: Linus Walleij, Andy Shevchenko, linux-gpio, imx, linux-imx
On Wed, Aug 9, 2023 at 4:13 PM Shenwei Wang <shenwei.wang@nxp.com> wrote:
>
> Release the parent interrupt request during runtime suspend, allowing
> the parent interrupt controller to enter runtime suspend if there are
> no active users.
>
> This change may not have a visible impact if the parent controller is
> the GIC, but it can enable significant power savings for parent IRQ
> controllers like IRQSteer inside a subsystem on i.MX8 SoCs. Releasing
> the parent IRQ provides an opportunity for the subsystem to enter suspend
> states if there are no active users.
>
> Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
> ---
Applied, thanks!
Bart
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-11 14:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-09 14:13 [PATCH v2] gpio: mxc: release the parent IRQ in runtime suspend Shenwei Wang
2023-08-10 9:59 ` Andy Shevchenko
2023-08-11 14:23 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).