From patchwork Thu Jul 21 14:31:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 9241797 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 D0B9160574 for ; Thu, 21 Jul 2016 14:42:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2C3927EED for ; Thu, 21 Jul 2016 14:42:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6C2927F46; Thu, 21 Jul 2016 14:42:01 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 6560527EED for ; Thu, 21 Jul 2016 14:42:01 +0000 (UTC) Received: from localhost ([::1]:41226 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQFAm-0002cR-F7 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 21 Jul 2016 10:42:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQF1c-00034N-3m for qemu-devel@nongnu.org; Thu, 21 Jul 2016 10:32:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQF1a-0003mG-MW for qemu-devel@nongnu.org; Thu, 21 Jul 2016 10:32:32 -0400 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]:35648) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQF1a-0003lq-Ds; Thu, 21 Jul 2016 10:32:30 -0400 Received: by mail-lf0-x243.google.com with SMTP id l89so5648283lfi.2; Thu, 21 Jul 2016 07:32:30 -0700 (PDT) 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=xChj0cd9FV5l6e2ZGuNTkfObNGxyJVg0Hbz0BssDals=; b=OcPjAFpz1nfgf52AzuV6sBXhF8UsLjslHlZl48hrCIzxRsTE+683aMUSmz8XFW5B/i Cf1CK6+dzsSqY2UtZwKx4Jc/2G1AfROt5vYIcae0uGnzazJeKF9Z1M1Ci49N4Cn+qBam q4l8T+OcS4+HrmMI/or23YOTJP+Xhlmau3UpN+6o4UbS3xiLyOrkIMKj97IvVn8zFUbj /Glm4jNzZvq13cjJLfdQTNzKhpKYAYDTKKvZ0blkslmZRTxGsSaNWKRnYnxwgdg4MLKt EmEF6vtGtXCLXfYw4lJq8j4FNqlUmNnD77KeHpKZ0rmtYdXOuVkHEpxh9IElvXsJUyGM 4Thg== 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=xChj0cd9FV5l6e2ZGuNTkfObNGxyJVg0Hbz0BssDals=; b=ACHNqMh0QlFRoqubBKz2nuU1rQK/FRKoPBQkkJXakLrz0UCx7lcwGmL60nhwNZOIHf EGAlsmE/1dz/eFYw8c2r6SWhSmyYXcYmb47n6YeFBowF3Luu6K1OCPjw2ZBtJ1HEtz3M 2Tyf2mi3ZY3QwCHNiIJAgvEoLomLtoi5dG6p2bCkkNbYedNF6NEXB4fh7QqmBtD1FrGr yDcMRFYk+rG1nkIhFqMMgDOFtldOuJuRk40IHODT0Af5BTIxkx/WkD1PVE6w4mO67lMz cqmK0IZ3yZ5QqSky7tfpOI0wvKOnODs12w5A+52XUKnQ67qi+0cGt6lVkl05/cZiDJnz wq5Q== X-Gm-Message-State: ALyK8tLJ+ZGxOOt91i6LWcSPVDxJKxM5tXK9pxgbWsH4lsxOC2jcZB9hSZlCnumZs5fSkQ== X-Received: by 10.25.209.68 with SMTP id i65mr25438499lfg.20.1469111549658; Thu, 21 Jul 2016 07:32:29 -0700 (PDT) Received: from localhost.localdomain (ppp109-252-52-30.pppoe.spdop.ru. [109.252.52.30]) by smtp.gmail.com with ESMTPSA id c12sm1887932lfc.40.2016.07.21.07.32.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jul 2016 07:32:29 -0700 (PDT) From: Dmitry Osipenko To: QEMU Developers , qemu-arm@nongnu.org Date: Thu, 21 Jul 2016 17:31:21 +0300 Message-Id: <4f59caa4ce3786410b7d1afee30d480a8ff33aac.1469110137.git.digetx@gmail.com> X-Mailer: git-send-email 2.9.2 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 Subject: [Qemu-devel] [PATCH v15 10/15] hw/ptimer: Add "no immediate trigger" policy 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: Peter Maydell , Peter Crosthwaite Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Performing trigger on setting (or starting to run with) counter = 0 could be a wrong behaviour for some of the timers, provide "no immediate trigger" policy to maintain correct behaviour for such timers. Signed-off-by: Dmitry Osipenko --- hw/core/ptimer.c | 9 ++++++++- include/hw/ptimer.h | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c index 8578861..d37e8ab 100644 --- a/hw/core/ptimer.c +++ b/hw/core/ptimer.c @@ -40,8 +40,11 @@ static void ptimer_reload(ptimer_state *s, int delta_adjust) uint64_t period = s->period; uint64_t delta = s->delta; - if (delta == 0) { + if (delta == 0 && !(s->policy_mask & PTIMER_POLICY_NO_IMMEDIATE_TRIGGER)) { ptimer_trigger(s); + } + + if (delta == 0) { delta = s->delta = s->limit; } @@ -62,6 +65,10 @@ static void ptimer_reload(ptimer_state *s, int delta_adjust) } } + if (delta == 0 && (s->policy_mask & PTIMER_POLICY_NO_IMMEDIATE_TRIGGER)) { + delta = 1; + } + if (delta == 0) { fprintf(stderr, "Timer with delta zero, disabling\n"); timer_del(s->timer); diff --git a/include/hw/ptimer.h b/include/hw/ptimer.h index c97f02e..ec76183 100644 --- a/include/hw/ptimer.h +++ b/include/hw/ptimer.h @@ -19,6 +19,9 @@ /* Periodic timer that has load = 0 would continuously re-trigger every * period. */ #define PTIMER_POLICY_CONTINUOUS_TRIGGER (1 << 1) +/* Starting to run with/setting counter = 0 won't perform immediate + * trigger. */ +#define PTIMER_POLICY_NO_IMMEDIATE_TRIGGER (1 << 2) /* ptimer.c */ typedef struct ptimer_state ptimer_state;