From patchwork Tue Nov 7 14:13:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10046763 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5A76060247 for ; Tue, 7 Nov 2017 14:14:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EEFF28EC3 for ; Tue, 7 Nov 2017 14:14:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4377F28FDE; Tue, 7 Nov 2017 14:14:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C39C228EC3 for ; Tue, 7 Nov 2017 14:14:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933599AbdKGONy (ORCPT ); Tue, 7 Nov 2017 09:13:54 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:51457 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933899AbdKGONv (ORCPT ); Tue, 7 Nov 2017 09:13:51 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue004 [212.227.15.129]) with ESMTPA (Nemesis) id 0Lxru4-1fH2pT1d9o-015JMz; Tue, 07 Nov 2017 15:13:39 +0100 From: Arnd Bergmann To: Benjamin Herrenschmidt , Bartlomiej Zolnierkiewicz Cc: Arnd Bergmann , Colin Ian King , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] fbdev: radeon: stop use ktime_get() for HZ calibration Date: Tue, 7 Nov 2017 15:13:06 +0100 Message-Id: <20171107141319.3390036-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171107141319.3390036-1-arnd@arndb.de> References: <20171107141319.3390036-1-arnd@arndb.de> X-Provags-ID: V03:K0:a4MM7vSDtC54XQBNE/I0OZnwU6XmD9V46OAWyeEjIPFbntTl9H6 41jQ10qEGa+My6tH82p58UcnXD6hfX5XtrCVQiLP1bvFKEdL8RK7MEgUUyVAy0maSjybzQm +pTkUiLxZ75qWxBk/j47/zdij6PnVj2EInc4+M/UtTMBlS6ZIX/k1UX5b9J56x0ZmTiEH3T ucdzQz70wEcYgXDVSdXuA== X-UI-Out-Filterresults: notjunk:1; V01:K0:B0dufTc+Z4c=:xOv5f3G8P+PrPsBJCjvgUN qicSI/tNaT852BdxwNHQP8O2ovYTFlSa4dWccMWq3AdhmbrlpHRFz37kTCYrFnm6Y+EAZCJ5W +kLqrxE+aZKDf2Q/mNszSs7mR0aNBWqoDPgVHh5+QqWajV4mFv7EsfoKcZ+wUcaM89kQAjood qAzQela532cNLx6wxEVNVIhU5os7dVEpChqlfR3jPP4LZtauLzS+UaVvIHs3ffEOY17IDnhUe rdBLRLU2D4WhSqTMZKkpLsLDaNQIbDUjQFypUyf8iVKFj/MgAAZhkwMuMoLjCvi6nEDS2EliT PDSbKig7MtrwtOThzxEI+SEWncvDY1fugqDTCk+VGqEYx39RDcWBC1k/EaHQEaIoGOX5KvX7W E3WHoKlmS/uyY+6x7K7RzmRc2t3CIpf8bhs3Eq/XI3vK6lxlnMYl0hdLYPBIDeygP6bjDLTGl RWi5JmjMYv+BLJ/1hWq6BKJb9Kz2EB0S9gn6pzS7gtW7u97P050+tMqD0IHa0sCtdZS3pGTH2 kpCvYhT46kGvGF2yJ2rIZoRq/xN71kCLdWAZe6r4qvDbf8mGj2QXoG/AlFisGABsmIvHilGKO U5FcDjvIeOIzbpWbS2D6GILAacvP+trE4IllglXCeTWSzl/Bl2ktUy/u/1FbsiB8FATHLjzdu 9JNNP4GpkqyApkeGkFdR4/UAuEBKGO+QDkgNHQBNMrPTwBIVz8EjkobqHpA2czdCNA57vAeiV DOWnqTHmxoFuq31f1/PveWKssS/8MTd3/m/tRQ== Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP do_gettimeofday() is deprecated and a bit clumsy. This changes radeon_probe_pll_params() over to using ktime_get() with monotonic times. There is no need to check for negative values any more since the monotonic clocksource cannot go backwards, but I'm adding a check for zero-division in case of a bad clocksource. Signed-off-by: Arnd Bergmann --- drivers/video/fbdev/aty/radeon_base.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c index 8ad1643e7d1c..8b7048fbf6dc 100644 --- a/drivers/video/fbdev/aty/radeon_base.c +++ b/drivers/video/fbdev/aty/radeon_base.c @@ -583,8 +583,8 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo) int hTotal, vTotal, num, denom, m, n; unsigned long long hz, vclk; long xtal; - struct timeval start_tv, stop_tv; - long total_secs, total_usecs; + ktime_t start_time, stop_time; + u64 total_usecs; int i; /* Ugh, we cut interrupts, bad bad bad, but we want some precision @@ -600,7 +600,7 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo) if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) == 0) break; - do_gettimeofday(&start_tv); + start_time = ktime_get(); for(i=0; i<1000000; i++) if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) != 0) @@ -610,18 +610,14 @@ static int radeon_probe_pll_params(struct radeonfb_info *rinfo) if (((INREG(CRTC_VLINE_CRNT_VLINE) >> 16) & 0x3ff) == 0) break; - do_gettimeofday(&stop_tv); + stop_time = ktime_get(); local_irq_enable(); - total_secs = stop_tv.tv_sec - start_tv.tv_sec; - if (total_secs > 10) + total_usecs = ktime_us_delta(stop_time, start_time); + if (total_usecs >= 10 * USEC_PER_SEC || total_usecs == 0) return -1; - total_usecs = stop_tv.tv_usec - start_tv.tv_usec; - total_usecs += total_secs * 1000000; - if (total_usecs < 0) - total_usecs = -total_usecs; - hz = 1000000/total_usecs; + hz = USEC_PER_SEC/(u32)total_usecs; hTotal = ((INREG(CRTC_H_TOTAL_DISP) & 0x1ff) + 1) * 8; vTotal = ((INREG(CRTC_V_TOTAL_DISP) & 0x3ff) + 1);