From patchwork Wed Sep 7 13:22:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 9319275 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 BFE3160752 for ; Wed, 7 Sep 2016 13:32:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9C10292EE for ; Wed, 7 Sep 2016 13:32:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E177292F1; Wed, 7 Sep 2016 13:32:58 +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.0 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, 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 47A4A292EE for ; Wed, 7 Sep 2016 13:32:58 +0000 (UTC) Received: from localhost ([::1]:41027 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhcyH-000285-D7 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 07 Sep 2016 09:32:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhcp6-0001cQ-EU for qemu-devel@nongnu.org; Wed, 07 Sep 2016 09:23:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhcp5-0005iP-1Z for qemu-devel@nongnu.org; Wed, 07 Sep 2016 09:23:28 -0400 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]:33866) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhcp4-0005hd-Qy; Wed, 07 Sep 2016 09:23:26 -0400 Received: by mail-lf0-x244.google.com with SMTP id 29so830675lfv.1; Wed, 07 Sep 2016 06:23:26 -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=kBlC89+jislZ+IPNNYdKi0ZJ8fOfiOLrjgU05JvMSjs=; b=rEFi14V6cNaqNiHLqAB/HbRxSUDPjQ+OgMQWuKXNtI1+fUjbuN4MqcK9R1p3aDsoEx uWZG7VM2c8RW9ZTSvepltKrYH7uHll/BdW2cIUC/QwSUyVZmO5Ho+PG145D/pZ9wJh/A oq6SW/wwJUgU5WpHnOfm96ODqTBphk/9vG5lIpCRkFbrQ6y69SXYqajc27IbnkA+vOHm mFuyRTT0aPZmCVBQ7aVZ6jAZkqMie7SMED5bQHLMEOv3Hqsz9qPkW1xh0uORc7D+LShU 5nZRHZgvBvlSRRJECC/Shb79TrhN6/cS7RvI2lpXGpNmNk9IlFmldVn7fJ1DAMLOP4i1 xIUQ== 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=kBlC89+jislZ+IPNNYdKi0ZJ8fOfiOLrjgU05JvMSjs=; b=TDOvo0vURM+O44yD2NWQj0maKqdnza3lxT7DEJZkREJXXumwWsa/isu2dK+UE+bLZW O3M0eGrKZ2d1VUmOh5suM5wRy0a/18ZJyEUroXrvnL+veZHgLxiOT/JDWMnpjMiY4YN4 LidQTzXeCVIZXyTKPLKAkYFxxJgOCjXnmnnc5SzCRE11e0O+BaXS6Adah2WbG9yIucd2 ehT94RjqJjdL2R6O4NkXfAR4zZZ2KxWnxpJe4MxkWhBjvXuAkRAkf38zO743hjKbclKi Oi3eUpdxv69LfRgMN7D+PW4+SWuT7Heq0g9MYbFXXMgbT1tXjX/wPc0u8JWLssKFA2Fr QGNg== X-Gm-Message-State: AE9vXwNvYDM+EhpC+g7p3j+x+LlEStT6v5eG1cRKDj9QSYk4UV/HtgUW/ozaY5MgdvVPig== X-Received: by 10.46.71.147 with SMTP id u141mr12438527lja.15.1473254602051; Wed, 07 Sep 2016 06:23:22 -0700 (PDT) Received: from localhost.localdomain (ppp109-252-52-17.pppoe.spdop.ru. [109.252.52.17]) by smtp.gmail.com with ESMTPSA id h29sm11375lfi.18.2016.09.07.06.23.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Sep 2016 06:23:21 -0700 (PDT) From: Dmitry Osipenko To: QEMU Developers , qemu-arm@nongnu.org Date: Wed, 7 Sep 2016 16:22:18 +0300 Message-Id: X-Mailer: git-send-email 2.9.3 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::244 Subject: [Qemu-devel] [PATCH v16 07/16] 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 | 18 +++++++++++++++++- include/hw/ptimer.h | 4 ++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c index e9b2e15..97ce8ae 100644 --- a/hw/core/ptimer.c +++ b/hw/core/ptimer.c @@ -45,7 +45,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) { if (!qtest_enabled()) { fprintf(stderr, "Timer with period zero, disabling\n"); } @@ -58,6 +59,21 @@ 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) { + if (!qtest_enabled()) { + 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 a13a12e..4c9c700 100644 --- a/include/hw/ptimer.h +++ b/include/hw/ptimer.h @@ -38,6 +38,10 @@ * 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; typedef void (*ptimer_cb)(void *opaque);