From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756944AbcIUUHk (ORCPT ); Wed, 21 Sep 2016 16:07:40 -0400 Received: from down.free-electrons.com ([37.187.137.238]:41617 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755381AbcIUUHi (ORCPT ); Wed, 21 Sep 2016 16:07:38 -0400 Date: Wed, 21 Sep 2016 22:07:35 +0200 From: Alexandre Belloni To: Gabriele Mazzotta Cc: a.zummo@towertech.it, rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org, matthew.garrett@nebula.com Subject: Re: [PATCH v4 1/2] rtc-cmos: Clear ACPI-driven alarms upon resume Message-ID: <20160921200735.nqvs33topaaeq7fv@piout.net> References: <20160919231244.6775-1-gabriele.mzt@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160919231244.6775-1-gabriele.mzt@gmail.com> User-Agent: NeoMutt/20160910 (1.7.0) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Thank you for your perseverance. On 20/09/2016 at 01:12:43 +0200, Gabriele Mazzotta wrote : > Currently ACPI-driven alarms are not cleared when they wake the > system. As consequence, expired alarms must be manually cleared to > program a new alarm. Fix this by correctly handling ACPI-driven > alarms. > > More specifically, the ACPI specification [1] provides for two > alternative implementations of the RTC. Depending on the > implementation, the driver either clear the alarm from the resume > callback or from ACPI interrupt handler: > > - The platform has the RTC wakeup status fixed in hardware > (ACPI_FADT_FIXED_RTC is 0). In this case the driver can determine > if the RTC was the reason of the wakeup from the resume callback > by reading the RTC status register. > > - The platform has no fixed hardware feature event bits. In this > case a GPE is used to wake the system and the driver clears the > alarm from its handler. > > [1] http://www.acpi.info/DOWNLOADS/ACPI_5_Errata%20A.pdf > > Signed-off-by: Gabriele Mazzotta > --- > drivers/rtc/rtc-cmos.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 49 insertions(+) Applied, with the following cosmetic change: @@ -982,13 +982,11 @@ static u32 rtc_handler(void *context) { struct device *dev = context; struct cmos_rtc *cmos = dev_get_drvdata(dev); - unsigned char rtc_control; + unsigned char rtc_control = 0; unsigned char rtc_intr; spin_lock_irq(&rtc_lock); - if (!cmos_rtc.suspend_ctrl) - rtc_control = cmos_rtc.suspend_ctrl; - else + if (cmos_rtc.suspend_ctrl) rtc_control = CMOS_READ(RTC_CONTROL); if (rtc_control & RTC_AIE) { cmos_rtc.suspend_ctrl &= ~RTC_AIE; -- Alexandre Belloni, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com