From patchwork Mon Dec 8 12:03:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pang.xunlei" X-Patchwork-Id: 418685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-oi0-x23e.google.com (mail-oi0-x23e.google.com [IPv6:2607:f8b0:4003:c06::23e]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A6D0A1400A0 for ; Mon, 8 Dec 2014 23:04:04 +1100 (AEDT) Received: by mail-oi0-f62.google.com with SMTP id u20sf799903oif.7 for ; Mon, 08 Dec 2014 04:04:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :reply-to:content-type:precedence:mailing-list:list-id:list-post :list-help:list-archive:sender:list-subscribe:list-unsubscribe; bh=X6+0ng3AZ3TENHU+azySSkYHi6Q6IOq05WDvfbErUVw=; b=TxIYPt1QPh+pN5XooWMh7oHIJJ4NrOxNZrAtkain7yb2icTEP/pXWiIEMKdnNWmar9 RJeBqT9MwzdYZEAsFhPKcQLSQQqxeYXIq8RojCLaAGW4quwd5Gy1oflI+Z0KPgho68zP LtsSEy7AGw/4odtxnUdrPOq6GnRSAQkBKt1vebyGV3ogbxYdAUHnvexraYkS4Ty/lyNL uD2deJhkBi3P5Cui8jPGxttOVqXjTFZC8swz5kp8/eT4MOuydFaHH40OahWy6/0xPQ0G 0+AStWl10TjjAzqV55OMcfXfxyidv3t5HfshQ5bgVIBSm2Dy7VV43Kt4bXvOkolRZD9z p+ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:reply-to:content-type:precedence :mailing-list:list-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe; bh=X6+0ng3AZ3TENHU+azySSkYHi6Q6IOq05WDvfbErUVw=; b=E1tgUOhCCc8nfNoO7n8DuQNG/L3G2Etfcq0rR85D1QbuCmp0Bc/jJSiUVGZS0aErno J23P9T4tHfY+lfKkgZX1Mkdl6K5pvpb1U3aC1rhKr+XSO2fKPTpnXsVnpXXQVYK7g9/m Fpci9EeQWRi8xEUhGkXGlXeA82gMNM2JtoEdhckWX8nvlq3RZZ4E85Lg94H+5TTrlLGa fjRGmpKaBWQTl/ryE+6Y37+CoXW1jyatNadhoAjw/BJQPHXO/hnXPGbplBPS6FP7+qfG DUxD/R30+yFKLinMsAcZTHpNK86CbZm5QPGls9oZprwm+YujK+2dcg85YdqiwB/ugwCF 03Tw== X-Received: by 10.50.136.226 with SMTP id qd2mr218270igb.15.1418040242667; Mon, 08 Dec 2014 04:04:02 -0800 (PST) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.107.164.38 with SMTP id n38ls1791148ioe.66.gmail; Mon, 08 Dec 2014 04:04:02 -0800 (PST) X-Received: by 10.68.135.134 with SMTP id ps6mr31584448pbb.4.1418040242405; Mon, 08 Dec 2014 04:04:02 -0800 (PST) Received: from mail-pd0-f182.google.com (mail-pd0-f182.google.com. [209.85.192.182]) by gmr-mx.google.com with ESMTPS id ax5si4394536pbd.0.2014.12.08.04.04.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 08 Dec 2014 04:04:02 -0800 (PST) Received-SPF: pass (google.com: domain of pang.xunlei@linaro.org designates 209.85.192.182 as permitted sender) client-ip=209.85.192.182; Received: by mail-pd0-f182.google.com with SMTP id p10so672881pdj.27 for ; Mon, 08 Dec 2014 04:04:02 -0800 (PST) X-Gm-Message-State: ALoCoQll+HxX4oTVeGAjfkG1K6KSQSyu3rzPIYGrihlgFOMcHc1adglOYgbM1Nm6j9GTQ8nTDx/h X-Received: by 10.70.36.236 with SMTP id t12mr20195454pdj.143.1418040242249; Mon, 08 Dec 2014 04:04:02 -0800 (PST) Received: from localhost.localdomain ([210.21.223.3]) by mx.google.com with ESMTPSA id c3sm31180790pdi.96.2014.12.08.04.03.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Dec 2014 04:04:01 -0800 (PST) From: Xunlei Pang To: linux-kernel@vger.kernel.org Cc: rtc-linux@googlegroups.com, Alessandro Zummo , John Stultz , Arnd Bergmann , Xunlei Pang Subject: [rtc-linux] [PATCH 2/2] rtc: Refine rtc_timer_do_work() to consider other set alarm failures Date: Mon, 8 Dec 2014 20:03:07 +0800 Message-Id: <1418040187-5372-2-git-send-email-pang.xunlei@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418040187-5372-1-git-send-email-pang.xunlei@linaro.org> References: <1418040187-5372-1-git-send-email-pang.xunlei@linaro.org> X-Original-Sender: pang.xunlei@linaro.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of pang.xunlei@linaro.org designates 209.85.192.182 as permitted sender) smtp.mail=pang.xunlei@linaro.org Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , rtc_timer_do_work() only judges -ETIME failure of__rtc_set_alarm(), but doesn't handle other failures like -EIO, -EBUSY, etc. If there is a failure other than -ETIME, the next rtc_timer will stay in the timerqueue. Then later rtc_timers will be enqueued directly because they have a later expires time, so the alarm irq will never be programmed. When such failures happen, this patch will retry __rtc_set_alarm(), if still can't program the alarm time, it will remove current rtc_timer from timerqueue and fetch next one, thus preventing it from affecting other rtc timers. Signed-off-by: Xunlei Pang --- drivers/rtc/interface.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index af19213..77a1529 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -898,11 +898,24 @@ again: if (next) { struct rtc_wkalrm alarm; int err; + int retry = 3; + alarm.time = rtc_ktime_to_tm(next->expires); alarm.enabled = 1; +reprogram: err = __rtc_set_alarm(rtc, &alarm); if (err == -ETIME) goto again; + else if (err) { + if (retry-- > 0) + goto reprogram; + + timer = container_of(next, struct rtc_timer, node); + timerqueue_del(&rtc->timerqueue, &timer->node); + timer->enabled = 0; + dev_err(&rtc->dev, "__rtc_set_alarm: err=%d\n", err); + goto again; + } } else rtc_alarm_disable(rtc);