Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2070.outbound.protection.outlook.com [40.107.6.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E051817754 for ; Wed, 9 Aug 2023 14:13:40 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HVSumRyYcPymrhcTl/pntGsDggqFtav4Zwd4aI3Uq6z0Eb4DhG3dkaIrXNharcmZHTk21inxyhOtMYZSOtwpqzlcZe1NJ1uBAWtQ6aKKwcNByOPNrWtA9J0j1T652VoNwcmpeeYYQVWgo1HykHmCaz66Po+1A4wVoDMKHaeGTDoE/Qyo5PM3CiGMPa9KPxTKyfbzqlTQYyAC5770MfJ7isilhyvxesXs9D9jOvejJAuSC3+exOjRA8jvjF8SOqLbWDbz0FEVoYgJqjCLPF99vRNmWbSd5QkZ/zAUbWitHViCaxvP8b64LVuX9pp057dh22zYvcT5m7SSt4TT0T/u2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=baoGaDBzi0cOLI1fCPGNUzt1jP5mYQGLse0iPerljXs=; b=KXyKt6HKbqpRKhx/GLdmcwbgtqxRm84yGoF9tuHghn5RFsviYmD22J5DTOw5IziYOGPgTVCzOTFeY5iyBXpZJjRcRFCVH0j9JXVaUptV/zRpgM0m3VPONFMsVex+ORAf7jCuO2u+KfOZg8DVeNzE57TZ99pCZyJ2A+FCIfQ98LbTgB7oWJWJPWCCvNGKLpkZniZqRtVkzlmD/f952LY+cRwSauoO8pcE0nDK7Pi+DIZxjSl7EYykFyOBjDNHdn+cENDcrLmfZUQ4muIcOyVXWhhZ0RbAWrIqS+Ux1ED0BR9m1gpypyu7EcTBUkq8IXceEpozEvxiQdcWTqHUcmexzg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=baoGaDBzi0cOLI1fCPGNUzt1jP5mYQGLse0iPerljXs=; b=N10lnOZLfF7ExbaEfBDeqI6Q+bSsacGYk3T2SCEq/w62R9kUDTDlLsRQvCTw9gOSBBJCDGBP7Dbbl+ryLT0VZ1KmP8RoHFRyJIfn5LVFDL3fHAm1ls/PbgL+Bz+fTJLJNA1fCm7JaLdsZJj8SRQbr7etz68iznluQvxBaou1kMg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9185.eurprd04.prod.outlook.com (2603:10a6:102:231::11) by AM0PR04MB7121.eurprd04.prod.outlook.com (2603:10a6:208:19a::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.28; Wed, 9 Aug 2023 14:13:37 +0000 Received: from PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::d4ee:8daa:92f4:9671]) by PAXPR04MB9185.eurprd04.prod.outlook.com ([fe80::d4ee:8daa:92f4:9671%3]) with mapi id 15.20.6652.028; Wed, 9 Aug 2023 14:13:37 +0000 From: Shenwei Wang To: Linus Walleij , Bartosz Golaszewski Cc: Andy Shevchenko , linux-gpio@vger.kernel.org, imx@lists.linux.dev, linux-imx@nxp.com, Shenwei Wang Subject: [PATCH v2] gpio: mxc: release the parent IRQ in runtime suspend Date: Wed, 9 Aug 2023 09:13:24 -0500 Message-Id: <20230809141324.400448-1-shenwei.wang@nxp.com> X-Mailer: git-send-email 2.34.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR03CA0350.namprd03.prod.outlook.com (2603:10b6:a03:39c::25) To PAXPR04MB9185.eurprd04.prod.outlook.com (2603:10a6:102:231::11) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9185:EE_|AM0PR04MB7121:EE_ X-MS-Office365-Filtering-Correlation-Id: d640de3d-1ec5-4fbe-00b0-08db98e2d316 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GTCUtwaQb3V+mdg4SygyBv/p7xFhLinN8hxZbjlzLHz9S120tnJEmIotcGKFWpyJRsHgM6KI1WrdUaMsIitl5w9j3QC2P1nlJFOjI8Itma0Jj9l3dXeJmTBqQeNGXJfHKyn11bm4JhZgFcH064Z+ZO8Soe5hj3eLON+ZSfwNQe4lmI7nfHYWNg10yQDWdAd3UogS51aQYJos6C/SBGV4i0peU6v4bfXAJwZcQMDcEBspmBXYwj0J83Q+z0ccfyqF/wFsjQAQnIQzLw0spSiux2QPBscemFdAzEjd29sILuVYiUVl7zhLSqM/ywnSlepCLkHILKD78wk9jQTxqXNuIxXGUYYUmTAHTh61AIUyw9rWdVYuj7wd15k8KaAQ75xqR8c/T9feBtb7E2zINLFoTkkWgC3t5mTzJ6crVnm6WuOo+eapkbDiA0YefhvNSE1lnMuoBh7+HejLl2hHzBtfVoavijhcte341BO5eGgPNVaMp91JflAvKvGE+GtEPIt1uOklObRqcQeYsbWU6r+aBzcgyks/7UbGlg8ktIjB1IBk487fTuI3asD7oc18BRCnCEkEqgOknwNk3YrE5pfzmGIpGzvutoYnhJlIbrmZsS+cLL3BmIEeYZCyLM53DKQD X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9185.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(346002)(136003)(366004)(39860400002)(396003)(1800799006)(451199021)(186006)(55236004)(6506007)(54906003)(52116002)(26005)(1076003)(478600001)(110136005)(6486002)(6512007)(6666004)(36756003)(83380400001)(2616005)(66556008)(66946007)(4326008)(316002)(5660300002)(8936002)(41300700001)(66476007)(8676002)(2906002)(15650500001)(86362001)(38350700002)(38100700002)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?cDYXQed6WohqfLIFOdjev7VPOo49+Cm4IDZfI/hDq9Ydsz3Fnr8yTpXGq8WU?= =?us-ascii?Q?EVHfAsTfi25yn0ezTm2pAJTH5rokPWOnfxyPAUOoOohHiZAARPNajQFhnegO?= =?us-ascii?Q?gFzsICTMo3JJM9CYbm1BHldl91YGTS7cnhg3csdNio9N/DhHuCa1VCK9tpUe?= =?us-ascii?Q?+3vnEzqgdVslF9z1Hiv4toGXXxnJV9bYPGs9pin//c+uy6uMjm2n+wBnKnC0?= =?us-ascii?Q?GBpr1/Iccc0lpqTk3qOZrlxcXQ7+LRXgNm5svnYRI7N9uAU8k6MJLDFWVgeW?= =?us-ascii?Q?k7Ig4fIZeN8oH/aPzqX0oKLIwKqLLwuLVJvNFsFRydE/uQiS+5UhDtCgvOJW?= =?us-ascii?Q?cR/Aqy+2loVJuKJlxLhqay2/xQ4scuR2TSnHQyd7aM+BR0YDKDHfWE6KPb9t?= =?us-ascii?Q?vqrIlJeLenWxmF+M/KYaZANQxheCTqHYpY6b0KHQd1XPm+fJ8LCuqvJd9MaD?= =?us-ascii?Q?QpT+r2p5Up7jmHfbZOIdwCk+GXkBWWFOaAVm5lsE8vNqhK1zje/Crl9R6r3I?= =?us-ascii?Q?eywuVQoCVVEz8GIw2NxtA1IVA7cQd3GH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DlXk3djsyNGi1UthgJbpQExH3s1cX04vOCN0wytxJ3vaU8?= =?us-ascii?Q?rI1Vgz7ILJLoUCW7l+c7zpL3tWFfWh0O8FZUc/XA+Dzadov9CqPUJCsbX5w5?= =?us-ascii?Q?ZK76/vmDdTycYFVb7CqoDGQNxfHMJA0AzVKiWe9l?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d640de3d-1ec5-4fbe-00b0-08db98e2d316 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9185.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2023 14:13:37.8024 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: e64Xm5gcD8ldZWtRde2wdOBcnYxKh4dPWQ5zNciYqilZFXdIZB6OZG78LbJowe2QdC7v1Q+u8BX4F63BRwZGSg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7121 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 --- 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