From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 715FAC433B4 for ; Tue, 4 May 2021 10:09:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4AD0B611C0 for ; Tue, 4 May 2021 10:09:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230153AbhEDKKF (ORCPT ); Tue, 4 May 2021 06:10:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230085AbhEDKKD (ORCPT ); Tue, 4 May 2021 06:10:03 -0400 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FD3EC061574; Tue, 4 May 2021 03:09:08 -0700 (PDT) Received: from martin by viti.kaiser.cx with local (Exim 4.89) (envelope-from ) id 1ldrz8-0005ZI-4O; Tue, 04 May 2021 12:08:58 +0200 Date: Tue, 4 May 2021 12:08:58 +0200 From: Martin Kaiser To: Alexandre Belloni Cc: Alessandro Zummo , Shawn Guo , Pengutronix Kernel Team , Fabio Estevam , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, Stephen Boyd Subject: Re: [PATCH] rtc: imxdi: add wakeup support Message-ID: <20210504100858.4i2crnfwchlcopr7@viti.kaiser.cx> References: <20210430093210.7034-1-martin@kaiser.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: Martin Kaiser Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (added Stephen for alarmtimer) Hi Alexandre and all, Thus wrote Alexandre Belloni (alexandre.belloni@bootlin.com): > > platform_set_drvdata(pdev, imxdi); > > + device_set_wakeup_capable(&pdev->dev, true); > Maybe it makes sense to simply use device_init_wakeup here. the explanation for device_init_wakeup "By default, most devices should leave wakeup disabled. The exceptions are devices that everyone expects to be wakeup sources: keyboards, power buttons, ..." made me think that device_set_wakeup_capable is more appropriate here. I can change this if you want. However, if I compile rtc-imxdi as a module and use device_init_wakeup, the module can't be unloaded any more. The reason is that alarmtimer (kernel/time/alarmtimer.c) starts using rtc-imxdi as its backing rtc device and holds a reference to it. It seems that alarmtimer has no way to relinquish its backing rtc device, regardless of any pending alarms. What is the right approach here? Are there any rtc drivers that act as a wakeup source and can still be unloaded if compiled as a module? > > + > > +static SIMPLE_DEV_PM_OPS(dryice_pm, dryice_suspend, dryice_resume); > > + > I'm wondering, can't you use dev_pm_set_wake_irq to avoid having to > keep the changes to a minimum? I did a quick test, this seems to work. I'll change it in v2. Thanks, Martin