From patchwork Tue Oct 22 13:31:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 177166 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp4879385ill; Tue, 22 Oct 2019 06:39:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqw6aSJmuPSMt5tS4dLk27qOSklJMTRn+BxgYkvVRKlfdwis1n3I+h8yDv32OKkHHwdlJV9l X-Received: by 2002:a05:620a:16cb:: with SMTP id a11mr3010790qkn.415.1571751571082; Tue, 22 Oct 2019 06:39:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571751571; cv=none; d=google.com; s=arc-20160816; b=KnfnteQ3sw4/cfh8duTAYnsZxjWNZ90mzhCeWVyPJISbms7ZSgvDyR19yEcVevxRV4 +ohPU03zDLmATNL6EbefS7tfOYqp/bm8ZOFM1jW2+TKVaLzt4oORmmK9ynEVu6wzb0fP Te1dTcIufu6j2xz67dr/AaNzEggWApn2vl4+7v4HuRWfZmVDqy3uU992EJjniFREU3ue uakkx1omb2kpvm7yeQYnW9CA+vQOF/7B7jEV25FbxLyyhwT4OQ3aM2b/s36RnOdvybE3 bF6c8mWZazYf9wCrBrE+hvTIjMn2l7+kK5kh2b0PARLg6QAd5Lki3VCgrQVhpW3MKO5c gGPA== 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=c/CnNVHFORCd4oE1CaU05xljf7UHrrubl901brpFpx8=; b=IToKyJyY4gsDxemnp26IkeW5/ITdUBQSJJAzNpFjo9OBa5J2UWb+BB9wsgDCpQD3M9 yQw3aa9xfhZwWwTO9eEXZEiPeUsFd7NuWpnwEyRxKaU9cHMhfE3ao3dAKbeNimvmwXbi lcBkm2YGssv//G7oy+7GK+bhF+ktY73HYNAIbJZm8PD/mC7WjGXN1iWl5PO2vR6i/Hrg SQjh3aLa+aW2oXXt2RP8Cd7lFhKjLGbwQVIE6jOMAYC8nZBQDT3Az5Y6uWhnhDrt7m+y FeDpGTf6TkjqKdO4bvkqpm/oD5Cap/1ohJ8Z6VVYaNLCwJymZrjHcrrl+jDhNB8pCHqw cIww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bDjuAcZw; 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 o19si10569246qkj.182.2019.10.22.06.39.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Oct 2019 06:39:31 -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=bDjuAcZw; 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]:57508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMuNl-000476-Rk for patch@linaro.org; Tue, 22 Oct 2019 09:39:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36694) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMuGc-0002T1-15 for qemu-devel@nongnu.org; Tue, 22 Oct 2019 09:32:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iMuGa-0001Ev-KV for qemu-devel@nongnu.org; Tue, 22 Oct 2019 09:32:05 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:53086) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iMuGZ-0001Eg-Tl for qemu-devel@nongnu.org; Tue, 22 Oct 2019 09:32:04 -0400 Received: by mail-wm1-x344.google.com with SMTP id r19so17321817wmh.2 for ; Tue, 22 Oct 2019 06:32:03 -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=c/CnNVHFORCd4oE1CaU05xljf7UHrrubl901brpFpx8=; b=bDjuAcZwrG2L0E+zhgbnXzRSlXp0zQbaQBvued8E766giyJPloeZh2zxlF1EosCXet AIzzX/amIY+mwhnMByzqpxqVPRn8PL+Zs41YG/aMuCeB03leQJ05tMyr+xDEPgbEwnPk Ve/0Oh3bkL6iKUkZm+xs5fL6sNdGfi/FhtsSSNelaGiUXQtAsk7RATN0uCuo+Z8gNQxB hIe/t2PejtpNp26p0CtZxwaoTlYjQ2gZMrbAt+4K76DTqObHdKc3SzgckpAHM4X/3nTg gFAsm7bMf2C6SrcyW43Rr1Q/q2vaOwWVYPyj9Wt8cqambFLX4LTVufkOk32Z9p2kFGmr F5tg== 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=c/CnNVHFORCd4oE1CaU05xljf7UHrrubl901brpFpx8=; b=Yze5Z4VfMMrC57/BWIwIZmFazrx7ii15EOuwaQ2ixh9FyhoDuY8qy/R1s7XJClefzR kkcD+af5yL7vy7FIleZbfo/OfIK5ByfXPr/8wtpTr7HTbwFIxJV8Vbqevs5fkVPRlntO lS0sr/G8Z/G/oR+hQJCEXhE/ezU/Vse25pH2Q0TrCjkau6bwPWva7lUqfZEC/OM9Ri+B WQtJ76Lpn/KZc4EfwyHtclc63z0btZfjJSANdjw91UJREFOF2EHaLi48S1fXXkZTWdvh 6Rf1M6kr1aC53/IjoFevUlYzBIC1gODbtoareTV8hTzmjJMTnSrNm4FeviLdyK2UOBrg 0sbg== X-Gm-Message-State: APjAAAU2LNjhvnAZ+e1eHLLza4bLDD3r+NAUqQ1rvX29sJN9cGam50hK loYNm1grm4HZb7UQyI2rwRSzi5OdJSE= X-Received: by 2002:a1c:6a04:: with SMTP id f4mr3151360wmc.60.1571751122530; Tue, 22 Oct 2019 06:32:02 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id r2sm20263856wma.1.2019.10.22.06.32.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 06:32:00 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 09/41] hw/watchdog/etraxfs_timer.c: Switch to transaction-based ptimer API Date: Tue, 22 Oct 2019 14:31:02 +0100 Message-Id: <20191022133134.14487-10-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191022133134.14487-1-peter.maydell@linaro.org> References: <20191022133134.14487-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::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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Switch the etraxfs_timer 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 Reviewed-by: Philippe Mathieu-Daudé Message-id: 20191017132905.5604-7-peter.maydell@linaro.org --- hw/timer/etraxfs_timer.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) -- 2.20.1 diff --git a/hw/timer/etraxfs_timer.c b/hw/timer/etraxfs_timer.c index ab27fe1895b..afe3d30a8ea 100644 --- a/hw/timer/etraxfs_timer.c +++ b/hw/timer/etraxfs_timer.c @@ -26,7 +26,6 @@ #include "hw/sysbus.h" #include "sysemu/reset.h" #include "sysemu/runstate.h" -#include "qemu/main-loop.h" #include "qemu/module.h" #include "qemu/timer.h" #include "hw/irq.h" @@ -59,9 +58,6 @@ typedef struct ETRAXTimerState { qemu_irq irq; qemu_irq nmi; - QEMUBH *bh_t0; - QEMUBH *bh_t1; - QEMUBH *bh_wd; ptimer_state *ptimer_t0; ptimer_state *ptimer_t1; ptimer_state *ptimer_wd; @@ -155,6 +151,7 @@ static void update_ctrl(ETRAXTimerState *t, int tnum) } D(printf ("freq_hz=%d div=%d\n", freq_hz, div)); + ptimer_transaction_begin(timer); ptimer_set_freq(timer, freq_hz); ptimer_set_limit(timer, div, 0); @@ -176,6 +173,7 @@ static void update_ctrl(ETRAXTimerState *t, int tnum) abort(); break; } + ptimer_transaction_commit(timer); } static void timer_update_irq(ETRAXTimerState *t) @@ -240,6 +238,7 @@ static inline void timer_watchdog_update(ETRAXTimerState *t, uint32_t value) t->wd_hits = 0; + ptimer_transaction_begin(t->ptimer_wd); ptimer_set_freq(t->ptimer_wd, 760); if (wd_cnt == 0) wd_cnt = 256; @@ -250,6 +249,7 @@ static inline void timer_watchdog_update(ETRAXTimerState *t, uint32_t value) ptimer_stop(t->ptimer_wd); t->rw_wd_ctrl = value; + ptimer_transaction_commit(t->ptimer_wd); } static void @@ -311,9 +311,15 @@ static void etraxfs_timer_reset(void *opaque) { ETRAXTimerState *t = opaque; + ptimer_transaction_begin(t->ptimer_t0); ptimer_stop(t->ptimer_t0); + ptimer_transaction_commit(t->ptimer_t0); + ptimer_transaction_begin(t->ptimer_t1); ptimer_stop(t->ptimer_t1); + ptimer_transaction_commit(t->ptimer_t1); + ptimer_transaction_begin(t->ptimer_wd); ptimer_stop(t->ptimer_wd); + ptimer_transaction_commit(t->ptimer_wd); t->rw_wd_ctrl = 0; t->r_intr = 0; t->rw_intr_mask = 0; @@ -325,12 +331,9 @@ static void etraxfs_timer_realize(DeviceState *dev, Error **errp) ETRAXTimerState *t = ETRAX_TIMER(dev); SysBusDevice *sbd = SYS_BUS_DEVICE(dev); - t->bh_t0 = qemu_bh_new(timer0_hit, t); - t->bh_t1 = qemu_bh_new(timer1_hit, t); - t->bh_wd = qemu_bh_new(watchdog_hit, t); - t->ptimer_t0 = ptimer_init_with_bh(t->bh_t0, PTIMER_POLICY_DEFAULT); - t->ptimer_t1 = ptimer_init_with_bh(t->bh_t1, PTIMER_POLICY_DEFAULT); - t->ptimer_wd = ptimer_init_with_bh(t->bh_wd, PTIMER_POLICY_DEFAULT); + t->ptimer_t0 = ptimer_init(timer0_hit, t, PTIMER_POLICY_DEFAULT); + t->ptimer_t1 = ptimer_init(timer1_hit, t, PTIMER_POLICY_DEFAULT); + t->ptimer_wd = ptimer_init(watchdog_hit, t, PTIMER_POLICY_DEFAULT); sysbus_init_irq(sbd, &t->irq); sysbus_init_irq(sbd, &t->nmi);