Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2258425pxa; Mon, 17 Aug 2020 05:26:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpOH/X3h55Yy/RbOcHDwx7qJwdAJjs4oeTliZ/q3RM7vuGHkJY8jKOBucTRUkwUmWa4/Iu X-Received: by 2002:a17:906:414b:: with SMTP id l11mr14914703ejk.334.1597667213388; Mon, 17 Aug 2020 05:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597667213; cv=none; d=google.com; s=arc-20160816; b=f0aCKjJMmRzYHJwsjuAFtJcGK4abXVfyhDOreGV1Zufmr5/8RfzxU3RivkeTjPB54O +8rTvweDy0ntdyERl9VuUMrjDf4/xF26vLgT9G2sO8SDgGri4neeuq5wrw3/7U+hR0JQ k0oaC82PdGYPh7w35pKLLh5VEXwGRiMqTIrvVQ5YBe8xmWD8nlwN+v+CRoJYAvKiR3bh 9fXmaPIVdnOA84NhCT0ry6EiVrPebWLzTEIn17gkIifYD+m/JZ3gTAq79rHL5scBE8Le Cck2mjFOcSKX6JV5r8pVyVY1eN9b6xEwGhf8TuZkqY5cosvmReUpWw+3RE5vacyUDp2g vP+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=mu3aZMqHeSt1wfgSRhXZMkjDuDV4hKhLNYdj/a2usCE=; b=RetK+tc/GSSiaxmGCeiUgKqIL7zGJeXAJuNDlilaRB2sRgSVwSuu05h+3L1MJJBtrJ 9//mLdF7VpNaivCvni+XY1/nrUjDOxheaWUq4H8sdpZeaceOaLUc2j523iKJoQvfNUJD urwXA8710Yx3OeH2wLLbsXGFmQKu2AHZMSn9bDjutQcHGgWOc150yWwT/g8g9nI/eVPH lC39NBNLWn5EIbvcmu/LkstHp3mptUqQ7476u7gK8051Ci8xdriPB8+0ea2H1YBSA6Lr wuFZzSpLSYw+ODBuLK+EpjbQrPwInxVnFaqpQPNUVhRg8sproaz4+S3ezRBffwGqnCsS 55sg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c38si11806720edf.153.2020.08.17.05.26.30; Mon, 17 Aug 2020 05:26:53 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728089AbgHQMYi (ORCPT + 99 others); Mon, 17 Aug 2020 08:24:38 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:9751 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726151AbgHQMYf (ORCPT ); Mon, 17 Aug 2020 08:24:35 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 832306C4C976C8803297; Mon, 17 Aug 2020 20:24:30 +0800 (CST) Received: from DESKTOP-5IS4806.china.huawei.com (10.174.187.22) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.487.0; Mon, 17 Aug 2020 20:24:20 +0800 From: Keqian Zhu To: , , , CC: Marc Zyngier , Steven Price , "Andrew Jones" , Catalin Marinas , "Will Deacon" , James Morse , Suzuki K Poulose , , Keqian Zhu Subject: [PATCH 2/2] clocksource: arm_arch_timer: Correct fault programming of CNTKCTL_EL1.EVNTI Date: Mon, 17 Aug 2020 20:24:15 +0800 Message-ID: <20200817122415.6568-3-zhukeqian1@huawei.com> X-Mailer: git-send-email 2.8.4.windows.1 In-Reply-To: <20200817122415.6568-1-zhukeqian1@huawei.com> References: <20200817122415.6568-1-zhukeqian1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.187.22] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-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 6e11c60..4140a37 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -794,10 +794,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--; /* enable event stream */ arch_timer_evtstrm_enable(min(pos, 15)); -- 1.8.3.1