From patchwork Sat Dec 28 01:14:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 13922225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 39694E7718B for ; Sat, 28 Dec 2024 01:17:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=u/zHiXHGzLT0luuezzbyNEzAVvay/MOvR8AuTlEFGyc=; b=pHJeMphIJwtzTkiDG0qbp1iiNm 4JrIHJrCAmEfXIaJLrxTSF9dZVMgx1iVpXGO54lXeDLEFYiypad+kjX2Osi1gXzkArAQ5aNbBrOCU oFHtWmPg5752Ej4kgJTP92+kKFydXi1NQgUNmq30HV73HoxlQrsUu/pbYs/7sOrx+nBtdpb8/TtZA VtAZv09d+usnNmRsevbARZpOQNInEe9mvPnDx74J1xDUXwSBxeOVz/L9wnhkczbk1x3CiWBSvR/lF 3UmvNf6zaUeBq1xNl6vk/lH6EoPuozqeMROB2YPEPfpptAV1TrCc831fMgyocUTdk3T3YcvDdWk8K D4AhGo7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tRLSk-00000001Bio-1oa1; Sat, 28 Dec 2024 01:17:54 +0000 Received: from mail-vi1eur02on20609.outbound.protection.outlook.com ([2a01:111:f403:2607::609] helo=EUR02-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tRLQN-00000001B6K-06sQ; Sat, 28 Dec 2024 01:15:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gVpIBXKGDph7VANcYk4QJZCn4EzewIx7bvYcluc4SZR5svnbJ0byeNPfVc8L9XkqXmlMcYWuzf0/8wARB3oW2cZHpkwL3MYL6g3TsGloe+qFcV1PHpIG3CLqV3n5CRd5xIif53z3VyIR7DcnssS23ma8FwDifqIJVaa8xlV3JUXi0vk0p4ea7GrcXLoV+362g6FJAcjsfezHTEmwNZ2s4emGJ7M4sVEzGffZ+TB4yizfbAKPRtyLBRVC2jt++4yER9QeXh16X0x+L/it5fUF9Du8oofLo6BpzUBNezkEnw2vBxmzkP48/juiOvrr9mQ9LwshaRweIv4Z/CUon/A7HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=LXYTp5BoecHg34e+obK9OingrwQWYhGlKmIRTdHjAGw=; b=A81C6fyc7AIg6W2VB5Vw2VbkwxT/TP+PuzuiH18mOJEeR4aHmcMpv9E18WxYob1Yfv+n3UUO+CUqoCLR2xtEVhAnX74Pqkbl7943MofP2Nsavh2wPcuMA80frFnCMhqEdeudC4P1u3ivSNyreD3uz3Xqvh/Dz3BVZxPfK+6+3TYjBS36UygZRwRo261CwcyJiChWgSaxLcKbUZngsRoEJaBHJbeJgc23U9QGEKMbZZtep7b/MR0xRfdPa5ttvbjt+C5kIa+adSXMcRbkAdsqQUv4Ph0/AKfXAttDK/DpWwfV5hbbAaT6Tmkv7DupfUgzr2K46WbhoYWp9blklWLkwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector1-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LXYTp5BoecHg34e+obK9OingrwQWYhGlKmIRTdHjAGw=; b=G//0vpngaurqRXrrBO8WtE6q50Gf80d3sz9sYm49MRZdJnU6xl8jFew+90FA3J/eKinN9+jsoZZlXXeHOY8aSG7RVYUdsWt4khMMnFk3aPi1uuoZjOHP6aK2xk6/NYW+x/MK/My23b9gDy2DEhys8LJHWofjNotD+kzjXqJp1ffMUi6htbEgpYFbTHVDOwuKscyJaj+EYRuMuJkOmV3cGbgKjsaFU/7VigC9cwdFgSfu0jb3PIOblh/01023p/CMQzr5afYJ16oOd5rTku+GGbvzJWBY7h/royKHBJBwcH6s3EhI947lqokEQaJV/v8iqrWlsmQu4mdrTRBECS4MTg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) by AM0PR04MB7140.eurprd04.prod.outlook.com (2603:10a6:208:192::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8293.15; Sat, 28 Dec 2024 01:15:18 +0000 Received: from PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630]) by PAXPR04MB8459.eurprd04.prod.outlook.com ([fe80::165a:30a2:5835:9630%5]) with mapi id 15.20.8293.000; Sat, 28 Dec 2024 01:15:18 +0000 From: "Peng Fan (OSS)" Date: Sat, 28 Dec 2024 09:14:37 +0800 Subject: [PATCH 01/12] PM: sleep: wakeirq: Introduce device-managed variant of dev_pm_set_wake_irq Message-Id: <20241228-wake_irq-v1-1-09cfca77cd47@nxp.com> References: <20241228-wake_irq-v1-0-09cfca77cd47@nxp.com> In-Reply-To: <20241228-wake_irq-v1-0-09cfca77cd47@nxp.com> To: "Rafael J. Wysocki" , Len Brown , Pavel Machek , Greg Kroah-Hartman , Dmitry Torokhov , Alexandre Belloni , Maxime Coquelin , Alexandre Torgue , Linus Walleij , Conor Dooley , Daire McNamara Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org, linux-rtc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-riscv@lists.infradead.org, Peng Fan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1735348488; l=2367; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=1uWzLxz0ETkHUyA0IoSi0XaXoYut2vJxQmLJwOorGBk=; b=qSMQnYyGM9tDfzHYkMUGmXNyaUzaGa3+ti6BAH9c9FzUsXHbRHcqUk+iAcM38J1RjL8RaqoVX 5f/l7EkwTGjALGnbsV+r7vQCvfEhAsFjc2BLLoZCeIs1xuYV04uru6q X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR02CA0099.apcprd02.prod.outlook.com (2603:1096:4:92::15) To PAXPR04MB8459.eurprd04.prod.outlook.com (2603:10a6:102:1da::15) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8459:EE_|AM0PR04MB7140:EE_ X-MS-Office365-Filtering-Correlation-Id: 78ae5531-0393-418c-85f7-08dd26dd1779 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|376014|7416014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?iw2H2/5LxEvQTdhgFpBNQvR1kkaHZ2S?= =?utf-8?q?UoXgSOmuB02HBKxIwq2aNjfmPbDtgHDVHFVzd/+o8YhDT2uQtEEIClRPenb1to92+?= =?utf-8?q?SsdujO2MR6u1OpAwPlFQSR0EEH7xsas2ZZujBY+ehYjrFAUGHIVirM9fwSp96pk9B?= =?utf-8?q?z/RydD/4D6WAcA5/jVRD71o49tp+AS4wsZkT4r2m6XSx/14lInlzC8HsSruQl1VJd?= =?utf-8?q?+Fb/sqp1dSem02qXVgE+xfRL0q8gbDa08kjscNWxhtk1H1vShZh7vKUTOorDXjuEN?= =?utf-8?q?/xzeQ0NrfrnfW2gXVx1ZHU3eKP0Pk9LHTPgOqZoykGpcShW4IsRbvMEp3pSwQB/Xb?= =?utf-8?q?MExGcUhZkxv7me4t5Q1n0DRwnUJ0b/ctJjpMcHp4BJoP60l9++Dr1A31tbws0mR2p?= =?utf-8?q?CqlnrZgVcspAZXGqBGGAnntashgrah0cYAuI45p+Nzjv3knwUKMc3Uc5anzZ7J7uK?= =?utf-8?q?beOHspl0kSC4E8Yc8WO+Cxhp09ngV5pqkvQ5GQDsIq+QGCYa50qJJcfQODwcCTQQs?= =?utf-8?q?g1sMzy7NQhPOgST7nooFlXDHy+On4UUaEagG0otm/n+PsicIfWKkVIO52mvxBThzS?= =?utf-8?q?1U6YthGsst2AyyHiC59ohRpy1BkY7bH+poEDQ8OEbgVR7g3dB1VCowbmPNqCgJ44a?= =?utf-8?q?TmIhoN83jSDt3+xd1sp0qUo+jMWTh59BRFnYfrxcAVzw4L2g9l2HQO0FuZxU10ffM?= =?utf-8?q?/H6NTwfi4cW3xaCFXMfRWs1Tw7hegqYC/Ugo22l1Freu0rLzJgBXHeiclYJUMccRp?= =?utf-8?q?gCoqW7EndkHHmgrnA/lQFTAACAt3VJkGnfSZ6CV7KpXrZ0dWnTmeSR/BjSZ1AQRyp?= =?utf-8?q?plm7n9poI0jdbMQmaH9goQU7AB5lUwjE1jCrZ/e12p4Ct27q1A1JK+Q1py8GBwGmr?= =?utf-8?q?Z0rHbYN904bF9kKkfdABD/ZKv7G9LXSYgx311n5iYcnZikXWXO6XT05nZZIU1E2Ux?= =?utf-8?q?f4OSNL8/oIK+1j7CiBY/dyMIeD2euJQSQWIBB4+ry+VFwfNA5KACR2u1YepQhs3Gb?= =?utf-8?q?Xt093aVARpVgTCaxtS3jQscoKWuR5O8/2a7YpKUDU15qZRw5jJaHV43FFdAjxniGQ?= =?utf-8?q?JqblFRAS2J3CF2ylrO3FG92KHKUt3L3I1mbv6Ye24IgsvT+RzjLJ2ljQQ7mFGJKtw?= =?utf-8?q?vqwebF5gpoh8q5xDZupizJ8xgCMXfSBU/T1SYcGfT8Um7dgQQ+Qm1XGTwyOrMzxq7?= =?utf-8?q?aggm2pKB1KpNYtdfSVEIROfluEQ6xNAOLmAGcRrkvYE4ozxCkmMaM0Mmnx6naWJAl?= =?utf-8?q?6uNrlz6j9saURkopKRH31mPabxitpc7u3WdAEIsN5DiYKWIBDDHityl0bTqxl+hkM?= =?utf-8?q?Lchq5GVHyT+bsVs8GOIJZfY4oUBq+K/mFeDj2FkkZ6TGYlvrVo0bF/0UQGYetQF8A?= =?utf-8?q?W0R5Lh/9SzdyzsS/Pef+ZaGmQ7yDho9bw=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB8459.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(376014)(7416014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?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dKIZAo2u/T6ylm5Vgmi?= =?utf-8?q?NWKzk6VREc5QCyAo0SSBNFGfVkOPFO/3L31DaUa3I1mnOa8eBduTYdIvViF9VVbDx?= =?utf-8?q?7ypbenpaoIdjilpzf7o75no3LkKuiyCQecaolLHineed9NgtiewOSN84YcEPMkKaJ?= =?utf-8?q?Y4UX1saGIQ5UhRyMo8Jy0NSigDL5FsM7pMql0ec01Hhd3zY7FadFv4rLy4Yf3G9AC?= =?utf-8?q?+AK9BlXsp6woao6mPPhGTSMhBvLAQ4pPj8IsKDIWIFuTGo09Q/Uuna5HUM1wQDgh0?= =?utf-8?q?5jZEsxQQIJ7SM+dZ30gF4lfjBqX/SFyOIiGZPugeDR7gdj+fG6kvl7zni/UPSDbUO?= =?utf-8?q?knqgc3BtwNd4uTkuQ/scS7wzNml7MLZH35gqTNL+ybxXx3/MUVzS+35b7uQ0vCdG6?= =?utf-8?q?7m8lTqWc3q7+O/+Yev9inFgHjikDerPpDoZRFdfdP/wSBI4jZha09hmvUH75fAMTF?= =?utf-8?q?TVogX130C40OsJr5vKKDnBnHuld1Vh4bBRX5Pb6CSlbDe0vQLvUzfYwyIJePwLuFJ?= =?utf-8?q?ZrWXLIzycotbIRivk8mS5jSHsMqdm6bsl5pO97AyLK/HIQWG/swIDB+HkX8fMuRsM?= =?utf-8?q?ov/Cy7RLDpLCFuCmr6Wk5UvI3BSSosg1NjE8mmkZHcZpxskrJ6DQ0WJEJX5VcbcyP?= =?utf-8?q?jr/Ag/0jS+Tw?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78ae5531-0393-418c-85f7-08dd26dd1779 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8459.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Dec 2024 01:15:18.3158 (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: uZpt2V3s6fjoSeNpK+N8ZCTOW9FTqpcYRuuV2IeIZSIS04XS3WUHC1McTJ1X3lhfLJFZTG8YJNo6dPCNO5MxPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7140 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241227_171527_081902_EDC8E939 X-CRM114-Status: GOOD ( 11.56 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Peng Fan Add device-managed variant of dev_pm_set_wake_irq which automatically clear the wake irq on device destruction to simplify error handling and resource management in drivers. Signed-off-by: Peng Fan --- drivers/base/power/wakeirq.c | 25 +++++++++++++++++++++++++ include/linux/pm_wakeirq.h | 6 ++++++ 2 files changed, 31 insertions(+) diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c index 5a5a9e978e85f3fc9d89cb7d43527dc1dd42a9b1..cdc445189f68479c54f85e84be09ae4f488df1b5 100644 --- a/drivers/base/power/wakeirq.c +++ b/drivers/base/power/wakeirq.c @@ -103,6 +103,31 @@ void dev_pm_clear_wake_irq(struct device *dev) } EXPORT_SYMBOL_GPL(dev_pm_clear_wake_irq); +static void devm_pm_clear_wake_irq(void *dev) +{ + dev_pm_clear_wake_irq(dev); +} + +/** + * devm_pm_set_wake_irq - device-managed variant of dev_pm_set_wake_irq + * @dev: Device entry + * @irq: Device IO interrupt + * + * + * Attach a device IO interrupt as a wake IRQ, same with dev_pm_set_wake_irq, + * but the device will be auto clear wake capability on driver detach. + */ +int devm_pm_set_wake_irq(struct device *dev, int irq) +{ + int ret; + + ret = dev_pm_set_wake_irq(dev, irq); + if (ret) + return ret; + + return devm_add_action_or_reset(dev, devm_pm_clear_wake_irq, dev); +} + /** * handle_threaded_wake_irq - Handler for dedicated wake-up interrupts * @irq: Device specific dedicated wake-up interrupt diff --git a/include/linux/pm_wakeirq.h b/include/linux/pm_wakeirq.h index d9642c6cf85211af603ce39e280a5b4de6617ee5..25b63ed51b765c2c6919f259668a12675330835e 100644 --- a/include/linux/pm_wakeirq.h +++ b/include/linux/pm_wakeirq.h @@ -10,6 +10,7 @@ extern int dev_pm_set_wake_irq(struct device *dev, int irq); extern int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq); extern int dev_pm_set_dedicated_wake_irq_reverse(struct device *dev, int irq); extern void dev_pm_clear_wake_irq(struct device *dev); +extern int devm_pm_set_wake_irq(struct device *dev, int irq); #else /* !CONFIG_PM */ @@ -32,5 +33,10 @@ static inline void dev_pm_clear_wake_irq(struct device *dev) { } +static inline int devm_pm_set_wake_irq(struct device *dev, int irq) +{ + return 0; +} + #endif /* CONFIG_PM */ #endif /* _LINUX_PM_WAKEIRQ_H */