From patchwork Mon Mar 26 17:56:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 891160 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ql5khky3"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40921835Fmz9ryr for ; Tue, 27 Mar 2018 04:57:47 +1100 (AEDT) Received: from localhost ([::1]:58319 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0WNL-0002iv-PF for incoming@patchwork.ozlabs.org; Mon, 26 Mar 2018 13:57:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0WMt-0002id-Ld for qemu-devel@nongnu.org; Mon, 26 Mar 2018 13:57:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0WMs-0005Mo-HS for qemu-devel@nongnu.org; Mon, 26 Mar 2018 13:57:15 -0400 Received: from mail-lf0-x242.google.com ([2a00:1450:4010:c07::242]:37150) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f0WMs-0005MP-A2 for qemu-devel@nongnu.org; Mon, 26 Mar 2018 13:57:14 -0400 Received: by mail-lf0-x242.google.com with SMTP id m16-v6so25712204lfc.4 for ; Mon, 26 Mar 2018 10:57:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=x0WcDQxoDXVn+/i5AoqCjGqi+bSk7tsXkzh0GBCjr4g=; b=ql5khky3TZ8uOKlHCpfx/0yfXgDzX1Dso67wV9qmWflwLOKfcscmo5aRnVm4zjGT0D wPUFIlKQl4eShMzdvGtjPsLXHxD2i4LMALVD3zPo2IOmUE3Af0skZxigwFwtifPZTLhT kND5VwVaEkxz7Q0cewn1InrtjptiXL2MQ0hAGXXwLRpdxxRMaRxtnnLRgTnQssqjDExY HckmZeth7hSL5pILlVdfLKtFaGSEHGI0IGLM4AnaWXclLXOUQ07sVZYvv3gC9zEJimd3 O6+wHP+51+rND0VS9C5UpFsyU583kZy4P5Ts/nL8ahFNRbnO7+oVNGfdgxZPu2ihED/H 6mZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=x0WcDQxoDXVn+/i5AoqCjGqi+bSk7tsXkzh0GBCjr4g=; b=k4IN+f7r7l/2pqYhIuiYPsdQNsKjlNZQ84aCpx7cabvMBWWBkqoDbRDxJyiyZaE/MX EO1NdkXu2edLbpuT967/lhDP5s09z7HZ4Cow6LegfKsuPm8bmd56J89GENSljL/nfph7 B6XpeNVOEpmPS7kQEjotBD+b74e508qxSc0QjX8IgPUDVUtn3e8BhdCJmjYv34bwUsH8 QzvDTe6Ddsgi4L7ealQzHbp1LE79yeQu5oN+vl4wEUG1sC1C6UMTJ9NmTssTUN6bSUr3 F082zBEJn6k8AmsLNTLVZIuep3y9DQDbCpAq4luGHSIGAMFV9JJerBSv0Ate7+Uu7IFb XsqA== X-Gm-Message-State: AElRT7FTiwyA23IDq2Sm5PiqeT622jrlW7oaTrN/fTTD7iZREPBRxD+p nrA27G17SUsJTi1JdK7bvhjMHg== X-Google-Smtp-Source: AG47ELszJiprpIBzNNHux2ZhnJLcRoroxTXTyDvFvY/wURecDxgMz/yRPUwkK6C5zWAtuNJlEn1H9w== X-Received: by 2002:a19:ea16:: with SMTP id i22-v6mr28083100lfh.65.1522087032338; Mon, 26 Mar 2018 10:57:12 -0700 (PDT) Received: from octofox.cadence.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id y70-v6sm2531725lfk.24.2018.03.26.10.57.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Mar 2018 10:57:11 -0700 (PDT) From: Max Filippov To: qemu-devel@nongnu.org Date: Mon, 26 Mar 2018 10:56:57 -0700 Message-Id: <20180326175657.13761-1-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::242 Subject: [Qemu-devel] [PATCH v2] target/xtensa: fix timers test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Filippov , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= , Pavel Dovgaluk Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The value of CCOUNT special register is calculated as time elapsed since CCOUNT == 0 multiplied by the core frequency. In icount mode time increment between consecutive instructions that don't involve time warps is constant, but unless the result of multiplication of this constant by the core frequency is a whole number the CCOUNT increment between these instructions may not be constant. E.g. with icount=7 each instruction takes 128ns, with core clock of 10MHz CCOUNT values for consecutive instructions are: 502: (128 * 502 * 10000000) / 1000000000 = 642.56 503: (128 * 503 * 10000000) / 1000000000 = 643.84 504: (128 * 504 * 10000000) / 1000000000 = 645.12 I.e.the CCOUNT increments depend on the absolute time. This results in varying CCOUNT differences for consecutive instructions in tests that involve time warps and don't set CCOUNT explicitly. Change frequency of the core used in tests so that clock cycle takes exactly 64ns. Change icount power used in tests to 6, so that each instruction takes exactly 1 clock cycle. With these changes CCOUNT increments only depend on the number of executed instructions and that's what timer tests expect, so they work correctly. Longer story: http://lists.nongnu.org/archive/html/qemu-devel/2018-03/msg04326.html Cc: Pavel Dovgaluk Cc: Philippe Mathieu-Daudé Signed-off-by: Max Filippov Reviewed-by: Philippe Mathieu-Daudé --- Changes v1->v2: - expand changelog; - replace clock_freq_khz initializer constant with a more meaningful expression. target/xtensa/core-dc232b.c | 2 +- tests/tcg/xtensa/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/target/xtensa/core-dc232b.c b/target/xtensa/core-dc232b.c index aa07018af4e7..7331eeea2fb6 100644 --- a/target/xtensa/core-dc232b.c +++ b/target/xtensa/core-dc232b.c @@ -47,7 +47,7 @@ static XtensaConfig dc232b __attribute__((unused)) = { } }, .isa_internal = &xtensa_modules, - .clock_freq_khz = 10000, + .clock_freq_khz = (NANOSECONDS_PER_SECOND / 64) / 1000, DEFAULT_SECTIONS }; diff --git a/tests/tcg/xtensa/Makefile b/tests/tcg/xtensa/Makefile index 2882c431e4a9..091518c05583 100644 --- a/tests/tcg/xtensa/Makefile +++ b/tests/tcg/xtensa/Makefile @@ -5,7 +5,7 @@ CROSS=xtensa-$(CORE)-elf- ifndef XT SIM = ../../../xtensa-softmmu/qemu-system-xtensa -SIMFLAGS = -M sim -cpu $(CORE) -nographic -semihosting -icount 7 $(EXTFLAGS) -kernel +SIMFLAGS = -M sim -cpu $(CORE) -nographic -semihosting -icount 6 $(EXTFLAGS) -kernel SIMDEBUG = -s -S else SIM = xt-run