Received: by 2002:adf:e804:0:0:0:0:0 with SMTP id o4csp5436900wrm; Tue, 8 Oct 2019 10:22:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQDZRY2nIhYNFvSgMmrMgYg8aw1PX+NpN6K0QBUIwXRolGfmVIdZ+jgUqnw/Yz6kx9dOmz X-Received: by 2002:a50:e79b:: with SMTP id b27mr35261746edn.186.1570555358092; Tue, 08 Oct 2019 10:22:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570555358; cv=none; d=google.com; s=arc-20160816; b=c+DZFsa3rAt49xyJpAnMdEVe95XvOteAf2jIwQCpuOaoiVUxbYfRZKvvE1jqCfF30t vBLhB77+OWsuT8KawIyG2nmH2ediOICCW7OYiAo1x5x2tSF9JmoinC0nC3+dNtjSkljT Bvx20kXEXRecFvfsVWZZ97FsheDt31nEGs/wOJIwNuyYamdsj2L40WXRgTAghz4q2Vw8 O9ozV3HZ75NJEc4zmAPSHB1Mwr3G+IxoBKdfdF+SldcbM99FYcXqSuBL8GYzroRnl1yS PfXa6q+UOWTrVrNnYT0mxCLHPHr4vhhtrVM8Jp9IHLntwz1DSILKIzrWCUAX3+DS8dHx V7eA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=vp4+p4FLQruJ614qug2AywQIur5rU9O0ZC+bqOyPTzg=; b=EknbpLFVhsGQuX/D9WWPJHkfqqfNGU2KX4ROWu3W+JX0gVFgb8HP8g014o96MWBQhZ em0NQFAynfeTAzcAYT8qA6o6+Mh+ZVZb8O0q0bS5I3oNGp9g27rFdrrP3AMxwE1C7Q6l MFK3srqt4LnpjKs8nqmrzY76OX7eVVFUOXDWgh7XEcATZq79yYeyd+36TbS12W/fev2r ucfKqUngJ2Yq9fhb+ME1orSuVFnNGNgfd8X1P3PLze67achv42R09PwfDV4feqmI0cu7 +k5v3ftnnduYQa+p5UaJ2N/7jy3hXw2KpHsGIZiICuRVwI0ivbXObDD/K/o68ZrCTlyn 9+IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PtVYUBhI; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id pv13si8923203ejb.79.2019.10.08.10.22.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Oct 2019 10:22:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PtVYUBhI; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHtC0-0001wk-7k for alex.bennee@linaro.org; Tue, 08 Oct 2019 13:22:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48752) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHt7Q-0006be-Kw for qemu-devel@nongnu.org; Tue, 08 Oct 2019 13:17:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iHt7O-0002DN-JG for qemu-devel@nongnu.org; Tue, 08 Oct 2019 13:17:52 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:40681) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iHt7O-0002Ch-As for qemu-devel@nongnu.org; Tue, 08 Oct 2019 13:17:50 -0400 Received: by mail-wm1-x344.google.com with SMTP id b24so3924572wmj.5 for ; Tue, 08 Oct 2019 10:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vp4+p4FLQruJ614qug2AywQIur5rU9O0ZC+bqOyPTzg=; b=PtVYUBhIWbWgg8zezYNZa6Tzzuev48iYDvlHzBz+NQDGavmE+fwArjtw6U167K/WEw exlh9g3JiFiDY9LU4mhivPo0bD8m1Z9Seqw7ZkZha+L12vQJk2xMHc00lORxM8gV+mHX BkfXxKLd//QpFiJmfWBc0Yx4inQSXPvsjKBt9YG7UQRjuC5ZUJq00ScLjMqd76FmbsUp SJHrX8CfJfKdYcod9fpYo0fMwj8/hkOGXE3C2lpF3Hrw4V33BWXbX50Uc4wRCXOkMK/K CwS5aIPMNeZshkxZj5gb5tIe9bkyCERM9Ewi0o07STsznRkBzrt5ioF/UzdLIcVKbOam tzGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vp4+p4FLQruJ614qug2AywQIur5rU9O0ZC+bqOyPTzg=; b=J2VRDrPs6xpzXIfyWPGrBo3mI9UeuqxhYiSoS+0fVAh5k9QATZaHasOPU3trkegIgF IPSSEhLIy/imopHQDnHQA1kDvgJgmDonmprX5MLyH5jwNrPK1wdVlN97eLXhF08te+LH De/KCiCjIvqF21ovGnQOd4uh7f0sE7UtThyPXMD+j1H76Hrkwi7bkMszE3TFlApeW8Oe peUvp55Z+Se+F7228MrR1rzXO6xZFFOAO2e/2YZT1AUMQzaxm9E3/Xk1YrmsKXjqJG1j vMg08Wz1b2WZY7R02vVQKBv1uCPbLo173dB+kvrMzbgO4G5kcQjY8WqyYLlRnyXCG73Z zrBA== X-Gm-Message-State: APjAAAWjzMKGhhi1EfwcZgY+b1+rHGc4VyX4su3f0i3J40EZrfPCIGyJ WoXJ9lRXqD/eCn2MDgHxAlxQPw== X-Received: by 2002:a1c:540c:: with SMTP id i12mr4958787wmb.90.1570555069072; Tue, 08 Oct 2019 10:17:49 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id z9sm19135541wrl.35.2019.10.08.10.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2019 10:17:48 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 04/21] hw/timer/arm_timer.c: Switch to transaction-based ptimer API Date: Tue, 8 Oct 2019 18:17:23 +0100 Message-Id: <20191008171740.9679-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191008171740.9679-1-peter.maydell@linaro.org> References: <20191008171740.9679-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Richard Henderson , Paolo Bonzini Errors-To: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-devel" X-TUID: qAUBx5umAjsC Switch the arm_timer.c code away from bottom-half based ptimers to the new transaction-based ptimer API. This just requires adding begin/commit calls around the various arms of arm_timer_write() that modify the ptimer state, and using the new ptimer_init() function to create the timer. Fixes: https://bugs.launchpad.net/qemu/+bug/1777777 Signed-off-by: Peter Maydell --- hw/timer/arm_timer.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/hw/timer/arm_timer.c b/hw/timer/arm_timer.c index 848fbcb0e25..255def3deec 100644 --- a/hw/timer/arm_timer.c +++ b/hw/timer/arm_timer.c @@ -14,7 +14,6 @@ #include "hw/irq.h" #include "hw/ptimer.h" #include "hw/qdev-properties.h" -#include "qemu/main-loop.h" #include "qemu/module.h" #include "qemu/log.h" #include "trace.h" @@ -79,7 +78,10 @@ static uint32_t arm_timer_read(void *opaque, hwaddr offset) } } -/* Reset the timer limit after settings have changed. */ +/* + * Reset the timer limit after settings have changed. + * May only be called from inside a ptimer transaction block. + */ static void arm_timer_recalibrate(arm_timer_state *s, int reload) { uint32_t limit; @@ -106,13 +108,16 @@ static void arm_timer_write(void *opaque, hwaddr offset, switch (offset >> 2) { case 0: /* TimerLoad */ s->limit = value; + ptimer_transaction_begin(s->timer); arm_timer_recalibrate(s, 1); + ptimer_transaction_commit(s->timer); break; case 1: /* TimerValue */ /* ??? Linux seems to want to write to this readonly register. Ignore it. */ break; case 2: /* TimerControl */ + ptimer_transaction_begin(s->timer); if (s->control & TIMER_CTRL_ENABLE) { /* Pause the timer if it is running. This may cause some inaccuracy dure to rounding, but avoids a whole lot of other @@ -132,13 +137,16 @@ static void arm_timer_write(void *opaque, hwaddr offset, /* Restart the timer if still enabled. */ ptimer_run(s->timer, (s->control & TIMER_CTRL_ONESHOT) != 0); } + ptimer_transaction_commit(s->timer); break; case 3: /* TimerIntClr */ s->int_level = 0; break; case 6: /* TimerBGLoad */ s->limit = value; + ptimer_transaction_begin(s->timer); arm_timer_recalibrate(s, 0); + ptimer_transaction_commit(s->timer); break; default: qemu_log_mask(LOG_GUEST_ERROR, @@ -170,14 +178,12 @@ static const VMStateDescription vmstate_arm_timer = { static arm_timer_state *arm_timer_init(uint32_t freq) { arm_timer_state *s; - QEMUBH *bh; s = (arm_timer_state *)g_malloc0(sizeof(arm_timer_state)); s->freq = freq; s->control = TIMER_CTRL_IE; - bh = qemu_bh_new(arm_timer_tick, s); - s->timer = ptimer_init_with_bh(bh, PTIMER_POLICY_DEFAULT); + s->timer = ptimer_init(arm_timer_tick, s, PTIMER_POLICY_DEFAULT); vmstate_register(NULL, -1, &vmstate_arm_timer, s); return s; } -- 2.20.1