Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3562616pxy; Tue, 4 May 2021 05:13:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjvGwxN1kPgnM/1lHzqtRDlbONdfucOOMzTWguk2lc5/tcNqfeRRoL8SOHlGdHc04smhVa X-Received: by 2002:a65:5a8f:: with SMTP id c15mr23703416pgt.0.1620130418803; Tue, 04 May 2021 05:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620130418; cv=none; d=google.com; s=arc-20160816; b=rDHCCPU6EkqgVr7HZxj2O17GEKWvFdtP679+WYwtyGkibHa1fIn7mftoHAOdOti2g5 Qmz/qBmqjuSwNGqS0nSPpwnboDp5fWqzJ8rpBvCqpiFTCIzK1rsroGnRV5H9RjNs38Bx SJSl7bTnHlK70U/uwOopLA+7Yka6dkzF7eDDpd10VaFJIMg1eFXQbspXGlecpWKtqQ/j JyRCTC2RJs52FgkMt58swCOmFIPNO1QyCexnlAARTHRYhPEEu1cSndGKkN5Q45LwJh6q gHuhec4zdTKjfoCvlWMKgudG46BY/2ZKy+rjYFt7Xfv6hMfhXda2WZlUGrEietV7lODu b87Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=5bkGkW7dhxmQDeG1kwQWBcNBiBBRme3u35SU7Y3DUBQ=; b=qWbE+Tl3zZWy+kMDd315IupOwD+61+aiF5MhpK+EQ+R0pdH4XnF0bzAAltDKEVYV4q YklqS6rqyFiNzoZQ8BQEGVKDfetn2VVDVKUgs+anfzdxxur3U6ECSeJ9S4LnNTua61ok 7uIKRA8giVuZCLxwdDGguVgzZNnrc+OyOjpdBKa6vASK0wCepLEwBoJIJYabpxVLvlsE zbXAsg/c15q2PS93YQQhhHrT2fAJ2YgigXxcBqm6IESviu9oa+qFYoBkT0ZXihgK2VGn R/vr7Z0EbmDSeoUmjg4vfIkxEjO5IeiQ3h9LCtbX78qq/1yPRe41gmzT4gnN9yanCPWA 9pKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y6si3277793pjc.163.2021.05.04.05.13.25; Tue, 04 May 2021 05:13:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230197AbhEDMNu (ORCPT + 99 others); Tue, 4 May 2021 08:13:50 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:49303 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230110AbhEDMNt (ORCPT ); Tue, 4 May 2021 08:13:49 -0400 Received: from localhost (lfbn-lyo-1-1676-55.w90-65.abo.wanadoo.fr [90.65.108.55]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 65F8D240004; Tue, 4 May 2021 12:12:51 +0000 (UTC) Date: Tue, 4 May 2021 14:12:50 +0200 From: Alexandre Belloni To: Martin Kaiser 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: References: <20210430093210.7034-1-martin@kaiser.cx> <20210504100858.4i2crnfwchlcopr7@viti.kaiser.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210504100858.4i2crnfwchlcopr7@viti.kaiser.cx> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/05/2021 12:08:58+0200, Martin Kaiser wrote: > 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. > Doesn't everyone expect the RTC to be a wakeup source? :) > 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? > Yes, when you don't have alarmtimer ;) I honestly think the RTC selection needs to be a bit more dynamic but at the same time, it would not be great to change it at suspend time. I guess the best way would be to allow module unloading and tracking when the RTC disappears. -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com