From owner-svn-src-head@freebsd.org Thu Jun 14 17:33:12 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C3A9A1016CA8; Thu, 14 Jun 2018 17:33:11 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mail.blih.net (mail.blih.net [212.83.177.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.blih.net", Issuer "mail.blih.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id E769376ED8; Thu, 14 Jun 2018 17:33:10 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mail.blih.net (mail.blih.net [212.83.177.182]) by mail.blih.net (OpenSMTPD) with ESMTP id f2f66d57; Thu, 14 Jun 2018 19:33:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=bidouilliste.com; h=date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mail; bh=etH+I20pdx+StGum9GxjWomeDW8=; b=L5sU0R3McEMc6FtAh2n6IUOeNhtS Usq0DYtks4yzgcpT41sQtWcjtaECuTppvaaeuDAuSo5JocnHMx2+lZyYZa5g0ZHz CGA+G2SsWR7I8mGja9G83HoIFgFX9atyuRChwW+fRkIbPRoRPRlmeO/MMmUXLNay bp1PEeWKwTDWG0o= DomainKey-Signature: a=rsa-sha1; c=nofws; d=bidouilliste.com; h=date :from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; q=dns; s= mail; b=YWlDl97zp7rexgCG2lUYITCj9CaUrKKfKekNtunLgAfkSaS40xZuSe7h UcAQgm6tACtDOObzYIEBhocrI2SYosEfqCyg1JErRG1sUdudrCOVQOFIs4/02oRA Bucir0e87IrJ2UZex+U51ijkqLpxsLeq5ItMgvLqHCvuSwr50vM= Received: from skull.home.blih.net (ip-9.net-89-3-105.rev.numericable.fr [89.3.105.9]) by mail.blih.net (OpenSMTPD) with ESMTPSA id 023f2d0e TLS version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO; Thu, 14 Jun 2018 19:33:08 +0200 (CEST) Date: Thu, 14 Jun 2018 19:33:08 +0200 From: Emmanuel Vadot To: Kyle Evans Cc: Emmanuel Vadot , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r335156 - head/sys/arm/arm Message-Id: <20180614193308.dc3c20f6d98f12f6c628fa0e@bidouilliste.com> In-Reply-To: References: <201806141718.w5EHIFnE093607@repo.freebsd.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; amd64-portbld-freebsd12.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2018 17:33:12 -0000 On Thu, 14 Jun 2018 12:26:38 -0500 Kyle Evans wrote: > On Thu, Jun 14, 2018 at 12:18 PM, Emmanuel Vadot wrote: > > Author: manu > > Date: Thu Jun 14 17:18:15 2018 > > New Revision: 335156 > > URL: https://svnweb.freebsd.org/changeset/base/335156 > > > > Log: > > arm timer: Add workaround for Allwinner A64 timer > > > > The timer present in allwinner A64 SoC is unstable, value can jump backward > > or forward. > > It was found that when bit 11 and upper roll over the low bits can sometimes > > being read as all as 1 or all as 0. > > Simply ignore the values for those cases. > > > > Modified: > > head/sys/arm/arm/generic_timer.c > > > > Modified: head/sys/arm/arm/generic_timer.c > > ============================================================================== > > --- head/sys/arm/arm/generic_timer.c Thu Jun 14 17:09:33 2018 (r335155) > > +++ head/sys/arm/arm/generic_timer.c Thu Jun 14 17:18:15 2018 (r335156) > > @@ -92,6 +92,7 @@ __FBSDID("$FreeBSD$"); > > struct arm_tmr_softc { > > struct resource *res[4]; > > void *ihl[4]; > > + uint64_t (*get_cntxct)(bool); > > uint32_t clkfreq; > > struct eventtimer et; > > bool physical; > > @@ -142,6 +143,28 @@ get_freq(void) > > } > > > > static uint64_t > > +get_cntxct_a64_unstable(bool physical) > > +{ > > + uint64_t val > > +; > > + isb(); > > + if (physical) { > > + do { > > + val = get_el0(cntpct); > > + } > > + while (((val + 1) & 0x7FF) <= 1); > > + } > > + else { > > + do { > > + val = get_el0(cntvct); > > + } > > + while (((val + 1) & 0x7FF) <= 1); > > + } > > + > > + return (val); > > +} > > + > > +static uint64_t > > get_cntxct(bool physical) > > { > > uint64_t val; > > @@ -226,7 +249,7 @@ static unsigned > > arm_tmr_get_timecount(struct timecounter *tc) > > { > > > > - return (get_cntxct(arm_tmr_sc->physical)); > > + return (arm_tmr_sc->get_cntxct(arm_tmr_sc->physical)); > > } > > > > static int > > @@ -379,6 +402,7 @@ arm_tmr_attach(device_t dev) > > if (arm_tmr_sc) > > return (ENXIO); > > > > + sc->get_cntxct = &get_cntxct_a64_unstable; > > #ifdef FDT > > /* Get the base clock frequency */ > > node = ofw_bus_get_node(dev); > > Was it intentional to set sc->get_cntxct to get_cntxct_a64_unstable in > the general case? Seems like this should've been get_cntxct. Fixed in 335161. Thanks, > > @@ -387,6 +411,13 @@ arm_tmr_attach(device_t dev) > > sizeof(clock)); > > if (error > 0) > > sc->clkfreq = clock; > > + > > + if (OF_hasprop(node, "allwinner,sun50i-a64-unstable-timer")) { > > + sc->get_cntxct = &get_cntxct_a64_unstable; > > + if (bootverbose) > > + device_printf(dev, > > + "Enabling allwinner unstable timer workaround\n"); > > + } > > } > > #endif > > > > Since the a64-specific get_cntxct is set here. > > > @@ -518,10 +549,10 @@ arm_tmr_do_delay(int usec, void *arg) > > else > > counts = usec * counts_per_usec; > > > > - first = get_cntxct(sc->physical); > > + first = sc->get_cntxct(sc->physical); > > > > while (counts > 0) { > > - last = get_cntxct(sc->physical); > > + last = sc->get_cntxct(sc->physical); > > counts -= (int32_t)(last - first); > > first = last; > > } > > _______________________________________________ > > svn-src-head@freebsd.org mailing list > > https://lists.freebsd.org/mailman/listinfo/svn-src-head > > To unsubscribe, send any mail to "svn-src-head-unsubscribe@freebsd.org" -- Emmanuel Vadot