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: 41999 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 10105202E0 for ; Mon, 8 Dec 2014 12:04:34 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id r20sf1669106wiv.9 for ; Mon, 08 Dec 2014 04:04:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=nIt7io8mQfCPCFenmWl0BRmw6sUbpXAq5XeG9tsvU/I=; b=jmjPlna0EPqY+TpjOnKQm4uLnRH4vXBjwcHUA1agd0oTEReUrfWvYfpzB7VT7kZWXe LuOdHheMtNul1Fu88bT/TFakp5DLS8G9lEwUXWssYobE432VELzleu5gvqz/8kk1pUNs gD4+1SebTQBONOT+nZxo4LKp2oOifkwTIoxLZIVuMJ5HJ+wkqYBEvyx8Y3/NcSAR8jQC 4RbpkbxsPUm82o3g0CFG8VP0hTLTFCtEI/+KPuicR264xtRptGdVdF1ozKfN1TCnHKgs xDxZkuG5kV85WmZpeHDAG315aBFSAbe8lB5mIcrCngM/2m1wxizyhLXJCaJi7LWT1p9s wSvQ== X-Gm-Message-State: ALoCoQn79LgNn6IFiv1oVJKSZsG2DdEwSv/auqkzl4mHcxd68DTsDNo5Twc1JEgSw3zivuTcixtc X-Received: by 10.152.26.72 with SMTP id j8mr6216928lag.3.1418040273289; Mon, 08 Dec 2014 04:04:33 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.170.227 with SMTP id ap3ls615079lac.60.gmail; Mon, 08 Dec 2014 04:04:33 -0800 (PST) X-Received: by 10.152.170.226 with SMTP id ap2mr16301654lac.4.1418040273114; Mon, 08 Dec 2014 04:04:33 -0800 (PST) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id t10si36742308lat.82.2014.12.08.04.04.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 08 Dec 2014 04:04:33 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id f15so3974126lbj.37 for ; Mon, 08 Dec 2014 04:04:33 -0800 (PST) X-Received: by 10.112.138.137 with SMTP id qq9mr15919648lbb.80.1418040272999; Mon, 08 Dec 2014 04:04:32 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp591163lbc; Mon, 8 Dec 2014 04:04:32 -0800 (PST) X-Received: by 10.66.163.196 with SMTP id yk4mr38476412pab.57.1418040271423; Mon, 08 Dec 2014 04:04:31 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hl9si54605456pac.146.2014.12.08.04.04.25 for ; Mon, 08 Dec 2014 04:04:31 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932091AbaLHMEH (ORCPT + 27 others); Mon, 8 Dec 2014 07:04:07 -0500 Received: from mail-pa0-f49.google.com ([209.85.220.49]:40141 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752470AbaLHMED (ORCPT ); Mon, 8 Dec 2014 07:04:03 -0500 Received: by mail-pa0-f49.google.com with SMTP id eu11so5097683pac.22 for ; Mon, 08 Dec 2014 04:04:02 -0800 (PST) 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: [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> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: pang.xunlei@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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);