From patchwork Sat Jan 30 16:43:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 8171711 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 74874BEEE5 for ; Sat, 30 Jan 2016 16:52:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DAC3520395 for ; Sat, 30 Jan 2016 16:52:42 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4B7BD20320 for ; Sat, 30 Jan 2016 16:52:42 +0000 (UTC) Received: from localhost ([::1]:39161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPYlN-0002F9-D2 for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Jan 2016 11:52:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPYgl-0002aX-7e for qemu-devel@nongnu.org; Sat, 30 Jan 2016 11:47:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aPYgk-0002FX-IS for qemu-devel@nongnu.org; Sat, 30 Jan 2016 11:47:55 -0500 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]:34595) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPYgk-0002FL-9T; Sat, 30 Jan 2016 11:47:54 -0500 Received: by mail-lf0-x241.google.com with SMTP id n70so5192536lfn.1; Sat, 30 Jan 2016 08:47:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=WWer0rc2pWL33b5boJH5xq5RR+38QIgAhR+3ojdQc8w=; b=VvArPQa+odHoN8ZRcTP5OiHZMUmG6gK+k70r8taOCDdV0nXjzkcBAvGwr7B9CMGaEE kSVsuEwX4JkLN6zey9AKpimSrKDsw5fAgTatuuCiO+bkB93o/DDFJ+jGJXW7DNsgQgBI 82NgwYN9N5mDVBvYyYiOwodPxBZeq/9OGV1eXULGqRqWLrZAdETEeI0vwx+L6dh1L3gv VvNCRi8Fal4RfYYPk4yWsgHJ1alsMSCMz2XNw3OK/CESJhd4ik55YGxi8dVETW7OM2i6 t5KOObrHkww0z4bkRNaFUjKKnKXjY/XDYDIjtlX8OKk08D/MEdok+SKTTGmtn+lHSbQb gKYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=WWer0rc2pWL33b5boJH5xq5RR+38QIgAhR+3ojdQc8w=; b=U+K2MyTzCiULdUm51ruysU8IsSsPEQLYNEHEQmPHvbgZQSF9oashSRcKsNJV2tpqvI 6bfL4e7sup0okZUeRe+fssQkXs/5znLy5qIc77YZ15/hPVmkHcLJOmVDKXy3yjcfnYG5 2t/hy4pYXjpnwehKQfOH0BFGP3uKHOrj3cAQubYWdMe/XRe6ICh4jBZI8ZRVthrzDJgZ eGgXB+9coceaEIWw6m4MFL1brPhmM9NQxV0YMZI8dQko+2FYzL+K281ZTQWSm9yd0gFK 4KA4nKJWmRTWUNfYnXjm8rRJ2TMIF7HQDwbcKkKSgTZj0PiYUv7yEGEZjfgZcQw9wUO2 jNWQ== X-Gm-Message-State: AG10YOQerUN2iDrMm5bOAQKBvCQQs35UN1j1wfVAfzMkb1DvXaS+TNrf82p/Ofl8g8P/BA== X-Received: by 10.25.41.203 with SMTP id p194mr5481512lfp.135.1454172473544; Sat, 30 Jan 2016 08:47:53 -0800 (PST) Received: from localhost.localdomain (ppp46-138-151-163.pppoe.spdop.ru. [46.138.151.163]) by smtp.gmail.com with ESMTPSA id b135sm2834417lfe.28.2016.01.30.08.47.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 30 Jan 2016 08:47:53 -0800 (PST) From: Dmitry Osipenko To: QEMU Developers , qemu-arm@nongnu.org Date: Sat, 30 Jan 2016 19:43:16 +0300 Message-Id: <77d17ad13f7b20deb433ca7a7b3d7cf40429665e.1454169735.git.digetx@gmail.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::241 Cc: Peter Maydell , Peter Crosthwaite Subject: [Qemu-devel] [PATCH v12 7/9] hw/ptimer: Fix counter - 1 returned by ptimer_get_count for the active timer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Due to rounding down performed by ptimer_get_count, it returns counter - 1 for the active timer. That's incorrect because counter should decrement only after period been expired, not before. I.e. if running timer has been loaded with value X, then timer counter should stay with X until period expired and decrement after. Fix this by adding 1 to the counter value for the active and unexpired timer. Signed-off-by: Dmitry Osipenko --- hw/core/ptimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c index 62f8cb1..b2044fb 100644 --- a/hw/core/ptimer.c +++ b/hw/core/ptimer.c @@ -136,7 +136,7 @@ uint64_t ptimer_get_count(ptimer_state *s) if ((uint32_t)(period_frac << shift)) div += 1; } - counter = rem / div; + counter = rem / div + (expired ? 0 : 1); if (expired && counter != 0) { /* Wrap around periodic counter. */