From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753437AbcAVMGN (ORCPT ); Fri, 22 Jan 2016 07:06:13 -0500 Received: from lists.s-osg.org ([54.187.51.154]:37700 "EHLO lists.s-osg.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753394AbcAVMF6 (ORCPT ); Fri, 22 Jan 2016 07:05:58 -0500 Subject: Re: [PATCH v2 03/10] rtc: max77686: Use usleep_range() instead of msleep() To: Laxman Dewangan , linux-kernel@vger.kernel.org References: <1453407813-14646-1-git-send-email-javier@osg.samsung.com> <1453407813-14646-4-git-send-email-javier@osg.samsung.com> <56A1F935.2040904@nvidia.com> Cc: Kukjin Kim , rtc-linux@googlegroups.com, Chanwoo Choi , Alexandre Belloni , Krzysztof Kozlowski , linux-samsung-soc@vger.kernel.org From: Javier Martinez Canillas Message-ID: <56A21B1D.8030303@osg.samsung.com> Date: Fri, 22 Jan 2016 09:05:49 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <56A1F935.2040904@nvidia.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Laxman, On 01/22/2016 06:41 AM, Laxman Dewangan wrote: > > On Friday 22 January 2016 01:53 AM, Javier Martinez Canillas wrote: >> RTC_SEC = 0, >> @@ -130,7 +130,8 @@ static int max77686_rtc_update(struct max77686_rtc_info *info, >> __func__, ret, data); >> else { >> /* Minimum 16ms delay required before RTC update. */ >> - msleep(MAX77686_RTC_UPDATE_DELAY); >> + usleep_range(MAX77686_RTC_UPDATE_DELAY, >> + MAX77686_RTC_UPDATE_DELAY * 2); >> } >> > > Instead of making usleep_range(16000, 32000), can we make small range as > usleep_range(16000, 17000)? > Yes, I also didn't know how to make the delay smaller. If I do for example usleep_range(delay, delay + 10000), then the 10000 delta would be too big for max77802 (50 times the minimum required 200 delay). So I used delay * 2 for two reasons: 1) That way is generic enough and can work for any delay 2) My understanding is that most of times the delay should be precise and is not that bad if sometimes the delay is the worst case (2 * X) since after all the delay is the minimum required. I also see that usleep_range(X, X * 2) is a used pattern across the kernel. > I am using as usleep_range(16000, 16000) always. According to Documentation/timers/timers-howto.txt, that's not a good idea since usleep_range() is implemented using high-resolution timers so by not using a range, the kernel won't be able to merge the wakeup with other wakeups which leads to much more interrupts being triggered. Best regards, -- Javier Martinez Canillas Open Source Group Samsung Research America