From patchwork Mon Jul 16 15:14:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 10527075 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A1B0E603ED for ; Mon, 16 Jul 2018 15:14:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D66F28E6D for ; Mon, 16 Jul 2018 15:14:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81B1128E73; Mon, 16 Jul 2018 15:14:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3228528E6D for ; Mon, 16 Jul 2018 15:14:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730027AbeGPPmh (ORCPT ); Mon, 16 Jul 2018 11:42:37 -0400 Received: from foss.arm.com ([217.140.101.70]:33916 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729360AbeGPPmh (ORCPT ); Mon, 16 Jul 2018 11:42:37 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1370F7A9; Mon, 16 Jul 2018 08:14:45 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B2C5F3F5A0; Mon, 16 Jul 2018 08:14:43 -0700 (PDT) From: Andre Przywara To: Andrew Jones Cc: Marc Zyngier , Christoffer Dall , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, qemu-devel@nongnu.org Subject: [kvm-unit-tests PATCH 2/2] arm64: timer: Add TVAL timeout IRQ trigger test Date: Mon, 16 Jul 2018 16:14:38 +0100 Message-Id: <20180716151438.9877-3-andre.przywara@arm.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180716151438.9877-1-andre.przywara@arm.com> References: <20180716151438.9877-1-andre.przywara@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP So far we were only testing the CVAL register. Add a test which programs a (relative) TVAL value to check this functionality as well. Also we go into WFI and wait for the interrupt to release us from it. The timer tests are run with a 2 second timeout on the host side, so that any failure in coming back would be covered. Signed-off-by: Andre Przywara Reviewed-by: Andrew Jones --- arm/timer.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arm/timer.c b/arm/timer.c index 1c9ef44..275d049 100644 --- a/arm/timer.c +++ b/arm/timer.c @@ -211,6 +211,7 @@ static void test_timer(struct timer_info *info) u64 now = info->read_counter(); u64 time_10s = read_sysreg(cntfrq_el0) * 10; u64 later = now + time_10s; + s32 left; /* We don't want the irq handler to fire because that will change the * timer state and we want to test the timer output signal. We can @@ -236,6 +237,15 @@ static void test_timer(struct timer_info *info) /* Disable the timer again */ info->write_ctl(0); + + /* Test TVAL and IRQ trigger */ + info->irq_received = false; + info->write_tval(read_sysreg(cntfrq_el0) / 100); /* 10 ms */ + info->write_ctl(ARCH_TIMER_CTL_ENABLE); + wfi(); + left = info->read_tval(); + report("interrupt received after TVAL/WFI", info->irq_received); + report("timer has expired (%d)", left < 0, left); } static void test_vtimer(void)