Received: by 2002:aa6:c429:0:b029:98:93ff:f56f with SMTP id g9csp401297lkq; Thu, 3 Dec 2020 07:00:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3IKsNmIP9M3WKUjJn88aztORemkXVEdMkelp6d2vI2wEu6sueDXdu2Y97iFPIGZ4GznwA X-Received: by 2002:a17:906:f6c4:: with SMTP id jo4mr2826391ejb.145.1607007607630; Thu, 03 Dec 2020 07:00:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607007607; cv=none; d=google.com; s=arc-20160816; b=x+HK+nhdm7S5U6OujM9csRwlt7JrX4nKuUwzgZK+pIPIoDjD3ZrNm40OIYRi9qdLDb +3IcR97IWUGxtPlqhePI+Oz+bUUrrqhM7MeWYb6OSWH87Qy//NQaj9uao8gejZPWhKn8 D6El1goC37wBAGYI6BTsBnQUckRKERmiIzXLnUXMnzDI/33tBFsd6JlCeUVM6towSF5y hMH3f7VctnKxfeq1+xT4i6x/7m5iBiI9OByU8ZY34QF61PTjCXqW2EJQ2a6a+RrR4Ux2 OkDIqyZnnWfbkz+bokg1HYENEMdoTYxABTG7FQXKgiZ+w4dTCiku0q2/5PwuEqM5X4Dk S+8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version; bh=rEOeyx0HFIofZguJHe2wjwfiM42YSNqE0jjCzI5RnS8=; b=mOukdpnmVOhJs9gnv2JOzXbMS/HMcnaakTeiqvvNx4gixGwuSqmAHhfBkhz5Z0V26K +xvAZTd6zBH0Dbqx7FCCKfIcVpNEnFGWAFpn2O1A2OGR/RBhfMevG6itiyize41VJ5yr QKMZfT8HEhylnKxIhc6D+bUh8MEtCCUatKRIrcpIpbAx7G3M3i69YaBS0qEj0GwRGjPW uPXrexByy3VYhE72Wod0njNbSt7u6IobpxwSlQQVK6HCtWAb4Go6pr6E/56hLjTUb2p7 82KB8oz+EeP55s2OY+I1kLYutYkUO6YCWlvqcj/hH1IhgK+MXlUGnghxguUqjJO1pFSK /mug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn23si985202edb.27.2020.12.03.06.59.42; Thu, 03 Dec 2020 07:00:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727065AbgLCO6F (ORCPT + 99 others); Thu, 3 Dec 2020 09:58:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:51976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725903AbgLCO6F (ORCPT ); Thu, 3 Dec 2020 09:58:05 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CA2E4206D6; Thu, 3 Dec 2020 14:57:23 +0000 (UTC) Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1kkq2r-00FhLT-G9; Thu, 03 Dec 2020 14:57:21 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 03 Dec 2020 14:57:21 +0000 From: Marc Zyngier To: Keqian Zhu Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, Steven Price , Andrew Jones , Catalin Marinas , Will Deacon , James Morse , Suzuki K Poulose , wanghaibin.wang@huawei.com Subject: Re: [PATCH v2 2/2] clocksource: arm_arch_timer: Correct fault programming of CNTKCTL_EL1.EVNTI In-Reply-To: <20200818032814.15968-3-zhukeqian1@huawei.com> References: <20200818032814.15968-1-zhukeqian1@huawei.com> <20200818032814.15968-3-zhukeqian1@huawei.com> User-Agent: Roundcube Webmail/1.4.9 Message-ID: X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: zhukeqian1@huawei.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, steven.price@arm.com, drjones@redhat.com, catalin.marinas@arm.com, will@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, wanghaibin.wang@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-08-18 04:28, Keqian Zhu wrote: > ARM virtual counter supports event stream, it can only trigger an event > when the trigger bit (the value of CNTKCTL_EL1.EVNTI) of CNTVCT_EL0 > changes, > so the actual period of event stream is 2^(cntkctl_evnti + 1). For > example, > when the trigger bit is 0, then virtual counter trigger an event for > every > two cycles. > > Fixes: 037f637767a8 ("drivers: clocksource: add support for > ARM architected timer event stream") Fixes: tags should on a single line. > Suggested-by: Marc Zyngier > Signed-off-by: Keqian Zhu > --- > drivers/clocksource/arm_arch_timer.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/drivers/clocksource/arm_arch_timer.c > b/drivers/clocksource/arm_arch_timer.c > index 777d38c..e3b2ee0 100644 > --- a/drivers/clocksource/arm_arch_timer.c > +++ b/drivers/clocksource/arm_arch_timer.c > @@ -824,10 +824,14 @@ static void arch_timer_configure_evtstream(void) > { > int evt_stream_div, pos; > > - /* Find the closest power of two to the divisor */ > - evt_stream_div = arch_timer_rate / ARCH_TIMER_EVT_STREAM_FREQ; > + /* > + * Find the closest power of two to the divisor. As the event > + * stream can at most be generated at half the frequency of the > + * counter, use half the frequency when computing the divider. > + */ > + evt_stream_div = arch_timer_rate / ARCH_TIMER_EVT_STREAM_FREQ / 2; > pos = fls(evt_stream_div); > - if (pos > 1 && !(evt_stream_div & (1 << (pos - 2)))) > + if ((pos == 1) || (pos > 1 && !(evt_stream_div & (1 << (pos - 2))))) > pos--; You don't explain why you are special-casing pos == 1. > /* enable event stream */ > arch_timer_evtstrm_enable(min(pos, 15)); Also, please Cc the subsystem maintainers: CLOCKSOURCE, CLOCKEVENT DRIVERS M: Daniel Lezcano M: Thomas Gleixner L: linux-kernel@vger.kernel.org S: Supported T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers/core F: Documentation/devicetree/bindings/timer/ F: drivers/clocksource/ Thanks, M. -- Jazz is not dead. It just smells funny...