From patchwork Sat Jan 30 16:43:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 8171571 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 354A59F818 for ; Sat, 30 Jan 2016 16:48:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9302A20395 for ; Sat, 30 Jan 2016 16:48:13 +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 ED4A820382 for ; Sat, 30 Jan 2016 16:48:12 +0000 (UTC) Received: from localhost ([::1]:39115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPYh2-0002gF-Bc for patchwork-qemu-devel@patchwork.kernel.org; Sat, 30 Jan 2016 11:48:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPYgh-0002Wl-Vg for qemu-devel@nongnu.org; Sat, 30 Jan 2016 11:47:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aPYgh-0002Dj-66 for qemu-devel@nongnu.org; Sat, 30 Jan 2016 11:47:51 -0500 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]:35981) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aPYgg-0002DL-Tt; Sat, 30 Jan 2016 11:47:51 -0500 Received: by mail-lf0-x243.google.com with SMTP id t141so5187265lfd.3; Sat, 30 Jan 2016 08:47:50 -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=T9Wxh2Ec9/WgavfJ4F3Ps/VO1v9nR4C4/sOz0L9YkiE=; b=C5deYzwRHw2bfnVHikgtt/Vzih87k49kMEcWLyIUpsTXVgmBpfRdafK6s5KhP5R48x Xe0clqUIeuzsxlCf9sf3P1yEG1MYTQKbHMNn6E9jykguABKP81APGn7kv0TBJLLIMTmO nPRyJ972oO7O2BOWxflbWk33SpPPOHA70fp94dJYfAN+dLO1p2xnvDiiz/WZ9oP9foGd VeBlQGdU807StGQsg5CLMVYXV8B+hB03bMIT76D0TM0h3vORwV2O6XoYsvjuuVWAReFV NJpVwxFhQgObteKYGhoHVYGhI7A+OFQvMbx8SfEDdQMdCrhlg6Ykq+I7PYkmcGfJq57s 5bmw== 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=T9Wxh2Ec9/WgavfJ4F3Ps/VO1v9nR4C4/sOz0L9YkiE=; b=Vb/Ze0gYAfwI9KktrWheynj0WmTq07uta2IWPsWWfHYMPm/z1bpvxUwhjC/NoiPvuC ZZ2/9cEv2/lp6pFaQBaGcnxMuxYrATLi2DdxFMZuJka/KD18xSdHKbIFRTDrfQhZ2d6H 0Wz4UxX1CgFTFezOomAjl5v5GeKAJwcxZk1Em19OCd1CosEzRvZeuYl4pae9k+AAxBHw dPHnGlEXa1taWyO5uK2FFHYy2WLT2HWoMhlzvBPdzPFvZ6u0PguPh7lDjXHeKHiixEz2 DVoklHraXJ0wCTrBc1CH8H/Y8bbSET07KKjYj9NYe9s42TpRjW9XnKEtr286lSMDiCB4 08XQ== X-Gm-Message-State: AG10YOS49c5agwIq5BmFWa+MmB2oBzAxUcoUdXNk/dssbbwW86tQFFEo6ESKr2GPxY0szA== X-Received: by 10.25.28.134 with SMTP id c128mr4509157lfc.95.1454172470121; Sat, 30 Jan 2016 08:47:50 -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.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 30 Jan 2016 08:47:49 -0800 (PST) From: Dmitry Osipenko To: QEMU Developers , qemu-arm@nongnu.org Date: Sat, 30 Jan 2016 19:43:12 +0300 Message-Id: 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::243 Cc: Peter Maydell , Peter Crosthwaite Subject: [Qemu-devel] [PATCH v12 3/9] hw/ptimer: Update .delta on period/freq change 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 Delta value must be updated on period/freq change, otherwise running timer would be restarted (counter reloaded with old delta). Only m68k/mcf520x and arm/arm_timer devices are currently doing freq change correctly, i.e. stopping the timer. Perform delta update to fix affected devices and eliminate potential further mistakes. Signed-off-by: Dmitry Osipenko Reviewed-by: Peter Crosthwaite --- hw/core/ptimer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c index d4452d3..f58790a 100644 --- a/hw/core/ptimer.c +++ b/hw/core/ptimer.c @@ -189,6 +189,7 @@ void ptimer_stop(ptimer_state *s) /* Set counter increment interval in nanoseconds. */ void ptimer_set_period(ptimer_state *s, int64_t period) { + s->delta = ptimer_get_count(s); s->period = period; s->period_frac = 0; if (s->enabled) { @@ -200,6 +201,7 @@ void ptimer_set_period(ptimer_state *s, int64_t period) /* Set counter frequency in Hz. */ void ptimer_set_freq(ptimer_state *s, uint32_t freq) { + s->delta = ptimer_get_count(s); s->period = 1000000000ll / freq; s->period_frac = (1000000000ll << 32) / freq; if (s->enabled) {