From patchwork Thu Jul 21 14:31:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 9241791 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 B479D60574 for ; Thu, 21 Jul 2016 14:37:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A42F127D85 for ; Thu, 21 Jul 2016 14:37:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9588127EE2; Thu, 21 Jul 2016 14:37:42 +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 425F827D85 for ; Thu, 21 Jul 2016 14:37:42 +0000 (UTC) Received: from localhost ([::1]:41201 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQF6b-00075O-B9 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 21 Jul 2016 10:37:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39856) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQF1a-00032J-5F for qemu-devel@nongnu.org; Thu, 21 Jul 2016 10:32:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQF1Z-0003kl-3Y for qemu-devel@nongnu.org; Thu, 21 Jul 2016 10:32:30 -0400 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]:36080) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQF1Y-0003kK-Sg; Thu, 21 Jul 2016 10:32:29 -0400 Received: by mail-lf0-x241.google.com with SMTP id 33so5660710lfw.3; Thu, 21 Jul 2016 07:32:28 -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=9ygNI2xroLdsEcg8Ty03eK8ln3q4mUAuapPHXWt6ge0=; b=CcSVlzCo9p+C98k0X2psvSNHuWcDhrUnpwzXBa4LZHMg2SHSyYaKpd+qpolOT3hR6F NSYoLL0tyJVC1tWj5+bs6bUln2P7BrN0IjJ5F3+oaT1R8XkAtWjEMvKlbYCEhpSJIfR7 9E4UdL3AV0FxNlauxYmQetT+2pHfrTXOE5b1K02yscyFlmqg5cCaiUSccvarfeF3W7us TsXhdSsYwW7WXLrDvbKJgwzauSCHAfVyC9tix2lATkx/Vl7AEKYTBBog1mUr9EI1ICss hI/Sg3ukipGU/el0sXnkcaJ9gULSJi5pnyBfrK+g+0uiCZ2i/HTwk97wVsGA3lKH8UIC Rvag== 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=9ygNI2xroLdsEcg8Ty03eK8ln3q4mUAuapPHXWt6ge0=; b=RO7iMilp68a3zQrY/ed38Qln0h9Mm2FGn3oBYD7JaO35gHx4Q6fRywEtV3EeoO1trH SO5isPvdvQFQZip260bBwjg8y7vvEU9HraAgaQpqpQ1PLu0ZCMoMgle9IA0ddqsCm+E0 H2iwCIFLPC66Idde5hW9T2QQ4nif5HmYxenhwc0r2nHyYsiQIaqxuwewF8Csyg6PCvM6 hA7gNq+MypwzJu3AilEl3eezIyKZ2EoqMUZLKh8HqRoLnoj4mH5UAXK9a1zev+QKX0q8 KIuvbpcUindOWnYPYTwerWfIbqzLeSrxbQscnF+MGZmAo1uXKJj2/yGtYw2iPGl5u1GX RWRw== X-Gm-Message-State: ALyK8tJu5CILdM9SatWEOiTIuuNxWHWEXIlyWUBvYCkjkzIdmfy4iPy16IlmPEq0hqGPQg== X-Received: by 10.25.35.19 with SMTP id j19mr21662285lfj.106.1469111547897; Thu, 21 Jul 2016 07:32:27 -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.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Jul 2016 07:32:27 -0700 (PDT) From: Dmitry Osipenko To: QEMU Developers , qemu-arm@nongnu.org Date: Thu, 21 Jul 2016 17:31:19 +0300 Message-Id: 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::241 Subject: [Qemu-devel] [PATCH v15 08/15] hw/ptimer: Add "continuous 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 Currently, periodic timer that has load = delta = 0 performs trigger on timer reload and stops, printing a "period zero" error message. Introduce new policy that makes periodic timer to continuously trigger with a period interval in case of load = 0. Signed-off-by: Dmitry Osipenko --- hw/core/ptimer.c | 16 +++++++++++++++- include/hw/ptimer.h | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c index c697c08..8578861 100644 --- a/hw/core/ptimer.c +++ b/hw/core/ptimer.c @@ -44,7 +44,8 @@ static void ptimer_reload(ptimer_state *s, int delta_adjust) ptimer_trigger(s); delta = s->delta = s->limit; } - if (delta == 0 || s->period == 0) { + + if (s->period == 0) { fprintf(stderr, "Timer with period zero, disabling\n"); timer_del(s->timer); s->enabled = 0; @@ -55,6 +56,19 @@ static void ptimer_reload(ptimer_state *s, int delta_adjust) delta += delta_adjust; } + if (delta == 0 && (s->policy_mask & PTIMER_POLICY_CONTINUOUS_TRIGGER)) { + if (s->enabled == 1) { + delta = 1; + } + } + + if (delta == 0) { + fprintf(stderr, "Timer with delta zero, disabling\n"); + timer_del(s->timer); + s->enabled = 0; + return; + } + /* * Artificially limit timeout rate to something * achievable under QEMU. Otherwise, QEMU spends all diff --git a/include/hw/ptimer.h b/include/hw/ptimer.h index e8de48d..c97f02e 100644 --- a/include/hw/ptimer.h +++ b/include/hw/ptimer.h @@ -16,6 +16,9 @@ /* Periodic timer counter stays with "0" for a one period before wrapping * around. */ #define PTIMER_POLICY_WRAP_AFTER_ONE_PERIOD (1 << 0) +/* Periodic timer that has load = 0 would continuously re-trigger every + * period. */ +#define PTIMER_POLICY_CONTINUOUS_TRIGGER (1 << 1) /* ptimer.c */ typedef struct ptimer_state ptimer_state;