From patchwork Wed Sep 7 13:22:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 9319281 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 E7DE26077F for ; Wed, 7 Sep 2016 13:37:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF5B52927A for ; Wed, 7 Sep 2016 13:37:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4106292F1; Wed, 7 Sep 2016 13:37:18 +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 00F26292EE for ; Wed, 7 Sep 2016 13:37:16 +0000 (UTC) Received: from localhost ([::1]:41059 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhd2R-0006Wk-C9 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 07 Sep 2016 09:37:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhcp4-0001Zx-0Y for qemu-devel@nongnu.org; Wed, 07 Sep 2016 09:23:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhcp2-0005h2-S0 for qemu-devel@nongnu.org; Wed, 07 Sep 2016 09:23:25 -0400 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]:35795) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhcp2-0005gf-JU; Wed, 07 Sep 2016 09:23:24 -0400 Received: by mail-lf0-x243.google.com with SMTP id s64so834376lfs.2; Wed, 07 Sep 2016 06:23:24 -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=akRnbvVs9mMrzAqRjeDiiwPbVMvGxFlcNTZrRHM+50U=; b=w2XgPQfHK2cF3FFfrlZ9PQjG2gSKhXk9OwiUzg9MsT+M8qN/d+aoHCKu3pLHHgrodS IyMlTNFTJiZ9Qn1LfzB+G5GJYDhXWSVlqLKYZVSDHULXJ7aRpiZmHj4m0jG9xV/LC0DU ZAKgRJZlMOtG0kVzLJQ7JoV80BSmjJXg9+Ir43q1VYvx4jL2MeU3uRyAoZ6jR5W61K2A 5wvJ7OVtG4bfsOvv8RHZyiVUXSi9emM24nIihPR8R261iZs4aLmzHPGqSz6vnJUAzzDe 54MsnNvO34q2XNJglVgKSFLNRiHrN82Rfj2vDSrWq+LEd8YTuPBtKlXB2/V86t1NoxZp r7kg== 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=akRnbvVs9mMrzAqRjeDiiwPbVMvGxFlcNTZrRHM+50U=; b=h7BB8W4G+jxU8Syv6rg59d+MyjKkiRallOiuTFsX6P4ipAaQ6zlfvvrHumS7t4EkEr cVvUtDYrG3IFtTG10e2X+SqLgaf3w2kPZgj0ioa2+eIY4j5co5uPYLwk1gV0W7i4zsM7 r84qWtMQBgt5KxLIn4HJXwk1Osi6EIWO4WKevmXjy/6ah4QqTI1NVtGFLG8c5ngVqXdZ wAukBXbUyACvqeKem/m/R17jh8vK+1a3Q9Q1RAYtHpTCoh5PEIg8veDGqx2T4JWtCpHn EGZDKrfG915VgVZm483nP5iQHPRtUVJvRarbp00zuoK/J3V5xmuljRZsqJl0dJvTgdvd Wn3A== X-Gm-Message-State: AE9vXwPGEZUEewiRk10b94zytuJi2zUgCi1+8LNvEbwsVJJS7oD+8pWXPQQji10FVjVNjA== X-Received: by 10.25.91.148 with SMTP id p142mr10661lfb.161.1473254603739; Wed, 07 Sep 2016 06:23:23 -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.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Sep 2016 06:23:23 -0700 (PDT) From: Dmitry Osipenko To: QEMU Developers , qemu-arm@nongnu.org Date: Wed, 7 Sep 2016 16:22:20 +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::243 Subject: [Qemu-devel] [PATCH v16 09/16] 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 | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/hw/core/ptimer.c b/hw/core/ptimer.c index 97ce8ae..018589d 100644 --- a/hw/core/ptimer.c +++ b/hw/core/ptimer.c @@ -41,8 +41,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; } @@ -65,6 +68,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) { if (!qtest_enabled()) { fprintf(stderr, "Timer with delta zero, disabling\n"); diff --git a/include/hw/ptimer.h b/include/hw/ptimer.h index e2f4c55..4b7c53c 100644 --- a/include/hw/ptimer.h +++ b/include/hw/ptimer.h @@ -42,6 +42,10 @@ * 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; typedef void (*ptimer_cb)(void *opaque);