From patchwork Wed Sep 20 03:22:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu YiPing X-Patchwork-Id: 113075 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp255692qgf; Tue, 19 Sep 2017 20:22:58 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBwOrN/wNDRD32Aegh/fpYsbW1kGzhZjUPfjWG6IUYyeujT5XPIXxzT9pHJQXzEWkmm3GSH X-Received: by 10.99.119.5 with SMTP id s5mr759105pgc.344.1505877778698; Tue, 19 Sep 2017 20:22:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505877778; cv=none; d=google.com; s=arc-20160816; b=Y9cy0F7VyvkJZpNR6b9n8ntIbOX+gXrqIf8+gPAgIj6ndVTkmVMzWqBtf1ocIdLgGW YRUdTMf+5z6MIcoPhdEvKa88bWtuT0O4Sbtjk4cFRzoixjWQKny6SG/tT9m/Azdbz2hm ufa+owmiwrodYNn0EhSf0/GYvR4O2MXzt8HNlWuz/0crhS0FsghYYACksufjDPIkCuBi zidNeuDdELU0WW5ddeVTvRrPX+rSa4xJb1Da9zAUibiJ/FH4u6O198Lp3CjZETZyqZOQ TFGMQIu+qgSYgLhrMOVEP1GtALQzSvYseqlcSJE3Pwx2I4InFSd3U934s3ZrAa3JG6gl rMXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:to :from:arc-authentication-results; bh=ifJ3ku/lVMQa9we1K0746EHMRm0U6mtXgr+5hgy6xKo=; b=tRFLIgBk3JGd5dpeRN7/rE9MERP9i3O/5gWzYZdY+7A8EH269mAsmeuj708VWCdv+S rAWMXAaKqbpHfeBEARQzYx5jps6Itkhg4cfX0xBagRc3QgOEBLsHcLVKiNXOP+KEzkwI ybZkBd4q3b1gR/oZ2GiUp1+7jopAoFGfQMGjpE9uuCd43KkdpXOKDl9UIOJIQz2Laras 0PddJV4bbJWWx7OrNxomCtmsSB3FrvtdzDgmM6NhRsE5gff+eobW852AqIHrsyrqZi5m 13x2cE9zgVefYRtYw7jqIO9nOzHHOqtrvRYbh2m74n4B7zeqlGHZQM3pF5E5Yq/+88z/ YgTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h4si604973pgs.385.2017.09.19.20.22.58; Tue, 19 Sep 2017 20:22:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751647AbdITDWz (ORCPT + 26 others); Tue, 19 Sep 2017 23:22:55 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:6520 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751009AbdITDWy (ORCPT ); Tue, 19 Sep 2017 23:22:54 -0400 Received: from 172.30.72.60 (EHLO DGGEMS412-HUB.china.huawei.com) ([172.30.72.60]) by dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DHR13802; Wed, 20 Sep 2017 11:22:43 +0800 (CST) Received: from vm167-7.huawei.com (10.177.167.7) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.301.0; Wed, 20 Sep 2017 11:22:32 +0800 From: Xu Yiping To: , , , , , , Subject: [PATCH] rtc: interface: set the next alarm event appropriately Date: Wed, 20 Sep 2017 11:22:31 +0800 Message-ID: <1505877751-26566-1-git-send-email-xuyiping@hisilicon.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.177.167.7] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A010202.59C1DF01.0040, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 5eebb9c1b14e47538fc38741c6044298 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xu YiPing After commit 2b2f5ff00f63 ("rtc: interface: ignore expired timers when enqueuing new timers"), the rtc_timer_enqueue will not reprogram the RTC when there is any non-expired timers in the timerqueue. If we set a RTC_TIMER between now and the next non-expired timers, it won't go into effect in time. So, besides ignoring the expired timers, we should take the next effect timer into account, and reprogram the RTC timer appropriately. Signed-off-by: Xu YiPing Signed-off-by: Chen Jun --- drivers/rtc/interface.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 8cec9a0..e237166 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -766,20 +766,23 @@ static int rtc_timer_enqueue(struct rtc_device *rtc, struct rtc_timer *timer) struct timerqueue_node *next = timerqueue_getnext(&rtc->timerqueue); struct rtc_time tm; ktime_t now; + ktime_t next_effect = KTIME_MAX; timer->enabled = 1; __rtc_read_time(rtc, &tm); now = rtc_tm_to_ktime(tm); - /* Skip over expired timers */ + /* Skip over expired timers, get next effect timer */ while (next) { - if (next->expires >= now) + if (next->expires >= now) { + next_effect = next->expires; break; + } next = timerqueue_iterate_next(next); } timerqueue_add(&rtc->timerqueue, &timer->node); - if (!next) { + if (timer->node.expires < next_effect) { struct rtc_wkalrm alarm; int err; alarm.time = rtc_ktime_to_tm(timer->node.expires);