From patchwork Wed Feb 29 21:41:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 143823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-we0-f184.google.com (mail-we0-f184.google.com [74.125.82.184]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 343E6B6EF3 for ; Thu, 1 Mar 2012 08:41:14 +1100 (EST) Received: by werm1 with SMTP id m1sf2307060wer.11 for ; Wed, 29 Feb 2012 13:41:11 -0800 (PST) Received-SPF: pass (google.com: domain of rtc-linux+bncCKXK6-CrAhD2trr6BBoEO0meCQ@googlegroups.com designates 10.180.14.69 as permitted sender) client-ip=10.180.14.69; Authentication-Results: mr.google.com; spf=pass (google.com: domain of rtc-linux+bncCKXK6-CrAhD2trr6BBoEO0meCQ@googlegroups.com designates 10.180.14.69 as permitted sender) smtp.mail=rtc-linux+bncCKXK6-CrAhD2trr6BBoEO0meCQ@googlegroups.com; dkim=pass header.i=rtc-linux+bncCKXK6-CrAhD2trr6BBoEO0meCQ@googlegroups.com Received: from mr.google.com ([10.180.14.69]) by 10.180.14.69 with SMTP id n5mr2887742wic.3.1330551671061 (num_hops = 1); Wed, 29 Feb 2012 13:41:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:message-id:date:from:user-agent :mime-version:to:cc:subject:x-enigmail-version:content-type :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:x-google-group-id:list-post :list-help:list-archive:sender:list-subscribe:list-unsubscribe; bh=vD+x0Zdjhg+hSFT7fIiN19T7VgYSg8VI1xV2GB94T5I=; b=GTjhhjhBCWNBc2KtSrzFiwJbSNJC6H1AYhRYHFFxGwqEn8Rg7e1QXhWnulC03Glf+n RF6fjzaT48FYiWvqfiFQSOFU9NQudwcisOqCm7lG9vEOc1ZqgWaRzc0fepSeq0PHqefE G7NRkbJlF6kD++QIv3yJN/YOO1vns1uSmIuPc= Received: by 10.180.14.69 with SMTP id n5mr818428wic.3.1330551670268; Wed, 29 Feb 2012 13:41:10 -0800 (PST) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.14.203.132 with SMTP id f4ls469830eeo.4.gmail; Wed, 29 Feb 2012 13:41:09 -0800 (PST) Received: by 10.14.203.68 with SMTP id e44mr904782eeo.3.1330551669382; Wed, 29 Feb 2012 13:41:09 -0800 (PST) Received: by 10.14.203.68 with SMTP id e44mr904781eeo.3.1330551669368; Wed, 29 Feb 2012 13:41:09 -0800 (PST) Received: from radon.swed.at (a.ns.miles-group.at. [95.130.255.143]) by gmr-mx.google.com with ESMTPS id f9si17062636eea.2.2012.02.29.13.41.09 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 29 Feb 2012 13:41:09 -0800 (PST) Received-SPF: neutral (google.com: 95.130.255.143 is neither permitted nor denied by best guess record for domain of richard@nod.at) client-ip=95.130.255.143; Received: (qmail 9491 invoked by uid 89); 29 Feb 2012 21:41:08 -0000 Received: by simscan 1.3.1 ppid: 9481, pid: 9487, t: 0.6756s scanners: attach: 1.3.1 clamav: 0.96.5/m:53 Received: from unknown (HELO ?192.168.0.2?) (richard@nod.at@91.114.240.248) by radon.swed.at with ESMTPA; 29 Feb 2012 21:41:08 -0000 Message-ID: <4F4E9B71.2010407@nod.at> Date: Wed, 29 Feb 2012 22:41:05 +0100 From: Richard Weinberger User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: john.stultz@linaro.org CC: Thomas Gleixner , a.zummo@towertech.it, rtc-linux@googlegroups.com, "linux-kernel@vger.kernel.org" Subject: [rtc-linux] RTC regression X-Enigmail-Version: 1.3.4 X-Original-Sender: richard@nod.at X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 95.130.255.143 is neither permitted nor denied by best guess record for domain of richard@nod.at) smtp.mail=richard@nod.at 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: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , Hi! hwclock calls the RTC_UIE_ON ioctl to wait for a timer tick. If RTC_UIE_ON was successful it opens /dev/rtcX and waits up to 5 seconds using select() for a tick. Some RTC drivers have no support for RTC_UIE_ON and ioctl just returns -EINVAL. Drivers indicated this by setting rtc_class_ops->update_irq_enable to NULL. In this case hwclock waits in a busy loop for the next timer tick. These two commits changed this behavior: 6610e08 (RTC: Rework RTC code to use timerqueue for events) 51ba60c (RTC: Cleanup rtc_class_ops->update_irq_enable()) rtc_class_ops->update_irq_enable was removed and rtc_update_irq_enable() is now using rtc_class_ops->set_alarm instead of rtc_class_ops->update_irq_enable. Some RTC devices (like mpc515x) don't support intervals smaller than one minute. rtc-mpc5121.c deals with this by rounding up to one minute. But now after commit 6610e08 RTC_UIE_ON will no longer return -EINVAL and the next tick comes somewhen within the next 60 seconds, because the driver rounded up... hwclock's select() is not happy about this and timeouts in most cases. The attached patch fixes the issue for mpc512x. set_alarm returns now -EINVAL if the requested interval is less than one minute. But I'm sure there are more RTC drivers and devices which are unable to handle such short intervals. Their RTC_UIE_ON behavior is currently undefined. Thanks, //richard ---- diff --git a/drivers/rtc/rtc-mpc5121.c b/drivers/rtc/rtc-mpc5121.c index 09ccd8d..dee992c 100644 --- a/drivers/rtc/rtc-mpc5121.c +++ b/drivers/rtc/rtc-mpc5121.c @@ -161,10 +161,18 @@ static int mpc5121_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) { struct mpc5121_rtc_data *rtc = dev_get_drvdata(dev); struct mpc5121_rtc_regs __iomem *regs = rtc->regs; + struct rtc_time now; /* - * the alarm has no seconds so deal with it + * the alarm has no seconds so deal with it: + * - return -EINVAL if the interval is < 1 minute + * - round up to one minute if it's > 1 minute */ + mpc5121_rtc_read_time(dev, &now); + if (alarm->time.tm_min == now.tm_min && + alarm->time.tm_hour == now.tm_hour) + return -EINVAL; + if (alarm->time.tm_sec) { alarm->time.tm_sec = 0; alarm->time.tm_min++;