From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9445EC433F5 for ; Fri, 25 Feb 2022 17:13:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JFs02P3y2oNZ9eA1/VRD92kQJ3cXgPlbUZHZJn8PIVY=; b=v2a+1NLPyy8UmN aKLCLbIG21mcNqCEJ6eqz49aDDVte470KYUy6yXTi4pC1R5bQ+//nRw4/kc9t0rNd5aWgFq8DCg2v wj4wvO0AabeCdnK5hOjFg/XPOIMrYD1J/P/mxSgijslkphpbP+0iW7XGG+INC1st2MQn/nux5lSFN aRavRv+vfLUOyfDv6i9/SlaGaDs7zNeN/qDjImWh8VLE82DwN5IRF3+5II6k0shaiiyWn/bCdCIbi Yn4dWlKxZzMfXJVYLEoP0ZH98nDrX2ay/hLcuQsFAB5dydCoJceogwp1rvVaN1IvCQYY9x2nEfh8r uqEczjRNeojJlQ1iyjMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nNe8l-006A6A-Hg; Fri, 25 Feb 2022 17:12:23 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nNe8i-006A5c-5Q for linux-arm-kernel@lists.infradead.org; Fri, 25 Feb 2022 17:12:21 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 713AAED1; Fri, 25 Feb 2022 09:12:17 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.19.59]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 598573F70D; Fri, 25 Feb 2022 09:12:16 -0800 (PST) Date: Fri, 25 Feb 2022 17:12:12 +0000 From: Mark Rutland To: Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Thomas Gleixner , kernel-team@android.com, Daniel Lezcano Subject: Re: [PATCH] clocksource/drivers/arm_arch_timer: Use event stream scaling when available Message-ID: References: <20220203170502.2694422-1-maz@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220203170502.2694422-1-maz@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220225_091220_351332_E26BED27 X-CRM114-Status: GOOD ( 25.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Feb 03, 2022 at 05:05:02PM +0000, Marc Zyngier wrote: > With FEAT_ECV and the 1GHz counter, it is pretty likely that the > event stream divider doesn't fit in the field that holds the > divider value (we only have 4 bits to describe counter bits [15:0] I was worried we'd be orders of magnitude out, but it looks like we're on the borderline here. IIUC if we have a 1GHz counter and *don't* have ECV, the best we can do is count bit 15 transitioning (one-way), and the minimal event frequency we can get is: 1_000_000_000 / 2 / (1 << 15)) Which is ~15KHz. With ECV we can make that, using bit 16 instead we get ~7.5KHz. Is that right? Could we note this in the commit message? Given that, this seems reasonable, but not crititcally important for backporting or whatever. Longer term, for WFET we'll need to consider disabling the event stream (either by default or opt-in). > Thankfully, FEAT_ECV also provides a scaling mechanism to switch > the field to cover counter bits [23:8] instead. > > Enable this on arm64 when ECV is available (32bit doesn't have > any detection infrastructure and is unlikely to be run on an > ARMv8.6 system anyway). > > Signed-off-by: Marc Zyngier > Cc: Mark Rutland > Cc: Daniel Lezcano The logic looks right to me, so FWIW: Acked-by: Mark Rutland Mark. > --- > drivers/clocksource/arm_arch_timer.c | 13 +++++++++++-- > include/clocksource/arm_arch_timer.h | 1 + > 2 files changed, 12 insertions(+), 2 deletions(-) > > diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c > index 1ecd52f903b8..9ab8221ee3c6 100644 > --- a/drivers/clocksource/arm_arch_timer.c > +++ b/drivers/clocksource/arm_arch_timer.c > @@ -880,10 +880,19 @@ static void __arch_timer_setup(unsigned type, > clockevents_config_and_register(clk, arch_timer_rate, 0xf, max_delta); > } > > -static void arch_timer_evtstrm_enable(int divider) > +static void arch_timer_evtstrm_enable(unsigned int divider) > { > u32 cntkctl = arch_timer_get_cntkctl(); > > +#ifdef CONFIG_ARM64 > + /* ECV is likely to require a large divider. Use the EVNTIS flag. */ > + if (cpus_have_const_cap(ARM64_HAS_ECV) && divider > 15) { > + cntkctl |= ARCH_TIMER_EVT_INTERVAL_SCALE; > + divider -= 8; > + } > +#endif > + > + divider = min(divider, 15U); > cntkctl &= ~ARCH_TIMER_EVT_TRIGGER_MASK; > /* Set the divider and enable virtual event stream */ > cntkctl |= (divider << ARCH_TIMER_EVT_TRIGGER_SHIFT) > @@ -912,7 +921,7 @@ static void arch_timer_configure_evtstream(void) > lsb++; > > /* enable event stream */ > - arch_timer_evtstrm_enable(max(0, min(lsb, 15))); > + arch_timer_evtstrm_enable(max(0, lsb)); > } > > static void arch_counter_set_user_access(void) > diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h > index e715bdb720d5..057c8964aefb 100644 > --- a/include/clocksource/arm_arch_timer.h > +++ b/include/clocksource/arm_arch_timer.h > @@ -56,6 +56,7 @@ enum arch_timer_spi_nr { > #define ARCH_TIMER_EVT_TRIGGER_MASK (0xF << ARCH_TIMER_EVT_TRIGGER_SHIFT) > #define ARCH_TIMER_USR_VT_ACCESS_EN (1 << 8) /* virtual timer registers */ > #define ARCH_TIMER_USR_PT_ACCESS_EN (1 << 9) /* physical timer registers */ > +#define ARCH_TIMER_EVT_INTERVAL_SCALE (1 << 17) /* EVNTIS in the ARMv8 ARM */ > > #define ARCH_TIMER_EVT_STREAM_PERIOD_US 100 > #define ARCH_TIMER_EVT_STREAM_FREQ \ > -- > 2.34.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel