From owner-svn-src-projects@FreeBSD.ORG Tue May 19 02:43:23 2009 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 67F3A1065680; Tue, 19 May 2009 02:43:23 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5555B8FC1B; Tue, 19 May 2009 02:43:23 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4J2hLps082408; Tue, 19 May 2009 02:43:21 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4J2hLHh082407; Tue, 19 May 2009 02:43:21 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <200905190243.n4J2hLHh082407@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Tue, 19 May 2009 02:43:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192364 - projects/mips/sys/mips/mips X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 May 2009 02:43:24 -0000 Author: gonzo Date: Tue May 19 02:43:21 2009 New Revision: 192364 URL: http://svn.freebsd.org/changeset/base/192364 Log: - Cleanup ticker initialization code. For some MIPS cpu Counter register increments only every second cycle. The only timing references for us is Count value. Therefore it's better to convert frequencies related to it and use them. Besides cleanup this commit fixes twice more then requested sleep interval problem. Modified: projects/mips/sys/mips/mips/tick.c Modified: projects/mips/sys/mips/mips/tick.c ============================================================================== --- projects/mips/sys/mips/mips/tick.c Tue May 19 01:58:00 2009 (r192363) +++ projects/mips/sys/mips/mips/tick.c Tue May 19 02:43:21 2009 (r192364) @@ -138,25 +138,19 @@ mips_timer_init_params(uint64_t platform * function should be called before cninit. */ counter_freq = platform_counter_freq; + /* + * XXX: Some MIPS32 cores update the Count register only every two + * pipeline cycles. + */ + if (double_count != 0) + counter_freq /= 2; + cycles_per_tick = counter_freq / 1000; - if (double_count) - cycles_per_tick *= 2; cycles_per_hz = counter_freq / hz; cycles_per_usec = counter_freq / (1 * 1000 * 1000); cycles_per_sec = counter_freq ; counter_timecounter.tc_frequency = counter_freq; - /* - * XXX: Some MIPS32 cores update the Count register only every two - * pipeline cycles. - * XXX2: We can read this from the hardware register on some - * systems. Need to investigate. - */ - if (double_count != 0) { - cycles_per_hz /= 2; - cycles_per_usec /= 2; - cycles_per_sec /= 2; - } printf("hz=%d cyl_per_hz:%jd cyl_per_usec:%jd freq:%jd cyl_per_hz:%jd cyl_per_sec:%jd\n", hz, cycles_per_tick, @@ -346,6 +340,7 @@ clock_attach(device_t dev) device_printf(dev, "bus_setup_intr returned %d\n", error); return (error); } + mips_wr_compare(mips_rd_count() + counter_freq / hz); return (0); }