From patchwork Mon Oct 14 16:03:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 176277 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4725888ill; Mon, 14 Oct 2019 09:23:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzsvIxI5BrntPh+SkfAEndwpiTsVQPptjskHtYXCiy8QapmZrJaZS+0MXbz7XdmAbZxP32P X-Received: by 2002:a17:906:b24c:: with SMTP id ce12mr29399142ejb.327.1571070218138; Mon, 14 Oct 2019 09:23:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571070218; cv=none; d=google.com; s=arc-20160816; b=HxETivjmiKJ3hoxaZZvQThx/xprIVyTVa3rk6Gvdus4SwrClSLdf8griAZl2SMBoqb NXXr3jKlqCXnAKq7xcY64dFJTSKvwqGJBNrJ2fsULmsX9BdQAnBxwhBrulhWonmdw3s6 8gijx1Irw0c2ZrmlYtOyR/sELENGB4z5irFHXJz7wGTkG54IesQ8rmpqDpeXul0K3wcB m00lvrvl+cIXJSwi0wCsEhnw/Gpw7b7gEXTVz5xLKsSBtXxZ1PZvr/1e/nwa6bMGjHcn iKBtgWGG7Z9icVaBDv971MSNm7lJuUZJmC3O17O9qxnqisXKOtnD0r0H8ZMl6/4CKRlr 0wfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=MPwTcMBQ1S4get8cdHWOjMJ/U+e/1QSjXd8MI5RrTyI=; b=YzxgSUmCrP0Eq2070Sk3ZnrHH3NevtWWBOY2ABJGQQ1BcBL5CH/94SEHR0XskdyzmO +YXMCmKpeNMRJ/5UsU84bDeyx+TkwI4GcNIz3IT+ri/X90xRlIp5gFTsHW1ub7tRTdDs 4Q1PflaDfg8tpUn6VOVk3SHjKg11QoFQ2hqs7RTfWVn15TzReeahIt4+3Y1f8uXDnyNi qQZt4mX1pLvh1oJZqeSnomRQzXp64uoyIH8XWEfHNWZiG8orHE1i0mnZXv+p6Oze/q8/ 31tD50+jVAJpmx0q62y6Fb8mCm7HbLfRKJgXKdlrkKWjdyrxdmQevuqa+Q3nFz1v+nZQ ik7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XLwOUK0C; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (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 e57si13002712ede.356.2019.10.14.09.23.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 09:23:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XLwOUK0C; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iK38C-0002FZ-LS for patch@linaro.org; Mon, 14 Oct 2019 12:23:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36788) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iK2pq-0003pE-Kp for qemu-devel@nongnu.org; Mon, 14 Oct 2019 12:04:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iK2pp-00079v-F2 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 12:04:38 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:36788) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iK2pp-00079A-95 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 12:04:37 -0400 Received: by mail-wr1-x442.google.com with SMTP id y19so20399321wrd.3 for ; Mon, 14 Oct 2019 09:04:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=MPwTcMBQ1S4get8cdHWOjMJ/U+e/1QSjXd8MI5RrTyI=; b=XLwOUK0CXj/Uk79M6/LLCLvERS+d7J2KlvqW8V37nNN0knqUK7Flc/gPYL7fyiqQtM Ud11Xl5j/XKEO2/dJI1OtL4ZM3cIUj04XUt+7b/QAUzrpenc79gmvvGPvXzDD6HP/gz+ hDvSgGue6lMpvuEATeWJohjYaGVOg8uGY1Sl7YSNw75DcDrZmMuW54KIghyf4TWpb+Ux 7s+A305Rz/itLJhmrTOEFd+r41DLIK6LliwmuljJmq18QyWe2TfpntgjrJ1z3LV5sgQf gdvfzMf3SYS1ltB3gux/49+u4ZHl6gte00Xux/2P3Id9eWAFcTKldaa3OY7Vk5gR4018 diGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MPwTcMBQ1S4get8cdHWOjMJ/U+e/1QSjXd8MI5RrTyI=; b=UFzkhPhGr173hJZlm8BH69ryBAqdzBy7zx/hhP2vWoBaJOHC2gLnc4yWN3nKGXYWCC 55QGciGR6yvc1fFKQqc/mRcvC8LqGrJ64ysgqpkq1NoKKlg47kOWZXdJ98zqOnlj61Hf 2hH0c7aFu3tbrkQZUapAcFQ7Hrfl2jbTYw5uklDwfoXrQa4Or7kjVfvIi5w1lVRIGmCW KqJmcjntGKi5hZEcSz0GdXCdFK07nSEd32+31ADLZ6W9eEVkOofaV7Xf1EZb1ERZVxdk 45nx1AbqD6ra1u0gAJxE2hNdhsVJYohRC8YAL+sQD0clNn5zEQtbhSfIBgWhZNGoiaPU t64A== X-Gm-Message-State: APjAAAU0aeGeDns98HYZ2MF9I9ANVT+0T7IsDAALnSlt1vhSFpaDSZKG RJAd27berT2x9W+iRNhhbPEz073hlZ5ejg== X-Received: by 2002:a05:6000:18d:: with SMTP id p13mr3932123wrx.396.1571069075866; Mon, 14 Oct 2019 09:04:35 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id 5sm18029779wrk.86.2019.10.14.09.04.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 09:04:35 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 13/68] hw/timer/digic-timer.c: Switch to transaction-based ptimer API Date: Mon, 14 Oct 2019 17:03:09 +0100 Message-Id: <20191014160404.19553-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191014160404.19553-1-peter.maydell@linaro.org> References: <20191014160404.19553-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::442 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Switch the digic-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 places that modify the ptimer state, and using the new ptimer_init() function to create the timer. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20191008171740.9679-11-peter.maydell@linaro.org --- hw/timer/digic-timer.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/hw/timer/digic-timer.c b/hw/timer/digic-timer.c index b111e1fe643..32612228daf 100644 --- a/hw/timer/digic-timer.c +++ b/hw/timer/digic-timer.c @@ -29,7 +29,6 @@ #include "qemu/osdep.h" #include "hw/sysbus.h" #include "hw/ptimer.h" -#include "qemu/main-loop.h" #include "qemu/module.h" #include "qemu/log.h" @@ -52,7 +51,9 @@ static void digic_timer_reset(DeviceState *dev) { DigicTimerState *s = DIGIC_TIMER(dev); + ptimer_transaction_begin(s->ptimer); ptimer_stop(s->ptimer); + ptimer_transaction_commit(s->ptimer); s->control = 0; s->relvalue = 0; } @@ -93,16 +94,20 @@ static void digic_timer_write(void *opaque, hwaddr offset, break; } + ptimer_transaction_begin(s->ptimer); if (value & DIGIC_TIMER_CONTROL_EN) { ptimer_run(s->ptimer, 0); } s->control = (uint32_t)value; + ptimer_transaction_commit(s->ptimer); break; case DIGIC_TIMER_RELVALUE: s->relvalue = extract32(value, 0, 16); + ptimer_transaction_begin(s->ptimer); ptimer_set_limit(s->ptimer, s->relvalue, 1); + ptimer_transaction_commit(s->ptimer); break; case DIGIC_TIMER_VALUE: @@ -125,17 +130,24 @@ static const MemoryRegionOps digic_timer_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; +static void digic_timer_tick(void *opaque) +{ + /* Nothing to do on timer rollover */ +} + static void digic_timer_init(Object *obj) { DigicTimerState *s = DIGIC_TIMER(obj); - s->ptimer = ptimer_init_with_bh(NULL, PTIMER_POLICY_DEFAULT); + s->ptimer = ptimer_init(digic_timer_tick, NULL, PTIMER_POLICY_DEFAULT); /* * FIXME: there is no documentation on Digic timer * frequency setup so let it always run at 1 MHz */ + ptimer_transaction_begin(s->ptimer); ptimer_set_freq(s->ptimer, 1 * 1000 * 1000); + ptimer_transaction_commit(s->ptimer); memory_region_init_io(&s->iomem, OBJECT(s), &digic_timer_ops, s, TYPE_DIGIC_TIMER, 0x100);