From patchwork Tue Oct 22 13:30:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 177168 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp4881183ill; Tue, 22 Oct 2019 06:40:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0xWCp+uPVCcwzao+akOoGJdzGUGnUsxb8uJCqlcJV4GJZd18oGhs5OnyyERFfD4F3U9R/ X-Received: by 2002:aed:21f6:: with SMTP id m51mr3347494qtc.307.1571751658606; Tue, 22 Oct 2019 06:40:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571751658; cv=none; d=google.com; s=arc-20160816; b=GjMSV94r83Ztl7kd6Nc94IRZaKrS2OvgYElZ16AW1UseenBttZyntVKXzn/jdXOZXJ 8Tt44Gt36RCiAqnSC0z2NsjaiKmvOJ7vfPPgAtlG+Ek9TVMIP56ntKpT4LuASuR0CELf KFFVKtjnsAf7hba/BSvMgna8DHcl6ednTQvUZrJzG6yzr52SXIr1VBh2U3RqPucyIayN /zljqXoHslqDAXQRDKGOgvUFMKMjJXv/PjHwfy9PcSsy8sk5Gg4h/ScjX6qwJeLQMfWi mx2NSFn8m3Khb7ir/DhrGYQO5FyN160eehCfPgnEllw3j2dYvkq2ZwMuztdGsgfePWNS EssA== 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=uDrLBjDpGth9A9xH8MMq1NWvBIh2l7Tya6vjM+QNwc0=; b=AZtHAjy4viwAxYNv6ALAuenIwJfUyTmYNFysOTi3+r3ptT/82ltJt1MfHMK2jxxLH2 fQt7eBZgsHHAv560aodRL0WPQZaFdrV0Un/arAjZbHJ80SZHM6Dx6Whzt4w7G3XXqkiX jhoAlMK/usKFKm+0Q/Ua4m6SkWDAO0RrZ0hS+QdvAAm9EDohtXJ7k4ruAWf0q5unOUpu 3JlGQLNua5QpY/G2vBhnsTMSq4/eZV3wsW42NcyVOkXKtWybeNjPAzu+zGpdKCd7WUy7 4w72rXS64g5ci+Y5Rs2Q0YgFHj7kapVKf10mkQpMUE5fs0+GR1hwcX4VXYy5sy4DSM1M g0zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pU9FpmRx; 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 f15si8035159qkk.63.2019.10.22.06.40.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Oct 2019 06:40:58 -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=pU9FpmRx; 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]:57534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMuPB-0005i8-TY for patch@linaro.org; Tue, 22 Oct 2019 09:40:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36652) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMuGV-0002Lt-Kv for qemu-devel@nongnu.org; Tue, 22 Oct 2019 09:32:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iMuGU-0001DC-2Q for qemu-devel@nongnu.org; Tue, 22 Oct 2019 09:31:59 -0400 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:36452) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iMuGT-0001Cu-SV for qemu-devel@nongnu.org; Tue, 22 Oct 2019 09:31:58 -0400 Received: by mail-wm1-x341.google.com with SMTP id c22so7078221wmd.1 for ; Tue, 22 Oct 2019 06:31:57 -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=uDrLBjDpGth9A9xH8MMq1NWvBIh2l7Tya6vjM+QNwc0=; b=pU9FpmRxUxoFFgEwr4Xpg/xm+CvLjordbgobZjQa3w8ZZ1x0pxtjgzFz3jHdeOD1TF 4zpJAhQVtcXNoYYVDeNVsF5L+jaLpHT3QvpvtKQlLmCAd1AhwGhKLIx96+cx6ta5kkHc md3ahfAGrvVV5ycfA9ZXC4/iP0wpj3yWxsGF/f1nvr/SSTB3MndSOUWksbPsAbnmI5wS SZse5P+CBD8ut5G4jBPfRnu6XwqkIUi1lDAx452KrLzdUz5n5VVmLh9wEOud9+qZxUaM 1Kc5XdEWmzj4DbRtLySDFA3yzsCbQ8bk/4ZHcJdCBhPJgaotfAfRpjKJdnehpphpvaKS Gcjw== 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=uDrLBjDpGth9A9xH8MMq1NWvBIh2l7Tya6vjM+QNwc0=; b=RZeH/B+W1H/ZCuvJAmvsEvX2u+4U2RMEqeij4hxg6R8Ld/pd1ezteQniqBI3EJQNFI P+chvHFhGvISyEYVuGBgF+0CiOcIvh8a+7ain0TcUN6MtGtpUUoSMspldiK8PHXNefOC le5+orUJsl9f/QCgquHAFINOTi2LVeognSatfMTHI83rrvDg3MC2Q5mhhsb8eCVK2Ngl fE+b01admt4Ofs82GfDOt7JEaancu93lBS7ASggDSJf3AWzEU3DuxwcKuhOtIae3OlvE +ZApZVcP4E9z8zcSgcXr7pBwK+kFL9FhUo/b9sMKQozKzlKweoy6Uae6oHhfBsuZVbx+ ZXVQ== X-Gm-Message-State: APjAAAUuPdhm7ITTc9KUPzoNZ0zKuDbVAp3HOx+Xs/BQAEjLIQs3EzT5 /f5ZP1vd1g6mDHdCbS6TKX0Vy5YjCE0= X-Received: by 2002:a1c:c912:: with SMTP id f18mr3291383wmb.168.1571751115490; Tue, 22 Oct 2019 06:31:55 -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.31.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 06:31:53 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 06/41] hw/timer/sh_timer: Switch to transaction-based ptimer API Date: Tue, 22 Oct 2019 14:30:59 +0100 Message-Id: <20191022133134.14487-7-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::341 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 sh_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-3-peter.maydell@linaro.org --- hw/timer/sh_timer.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/hw/timer/sh_timer.c b/hw/timer/sh_timer.c index 48a81b4dc79..13c4051808f 100644 --- a/hw/timer/sh_timer.c +++ b/hw/timer/sh_timer.c @@ -13,7 +13,6 @@ #include "hw/irq.h" #include "hw/sh4/sh.h" #include "qemu/timer.h" -#include "qemu/main-loop.h" #include "hw/ptimer.h" //#define DEBUG_TIMER @@ -91,13 +90,18 @@ static void sh_timer_write(void *opaque, hwaddr offset, switch (offset >> 2) { case OFFSET_TCOR: s->tcor = value; + ptimer_transaction_begin(s->timer); ptimer_set_limit(s->timer, s->tcor, 0); + ptimer_transaction_commit(s->timer); break; case OFFSET_TCNT: s->tcnt = value; + ptimer_transaction_begin(s->timer); ptimer_set_count(s->timer, s->tcnt); + ptimer_transaction_commit(s->timer); break; case OFFSET_TCR: + ptimer_transaction_begin(s->timer); if (s->enabled) { /* Pause the timer if it is running. This may cause some inaccuracy dure to rounding, but avoids a whole lot of other @@ -148,6 +152,7 @@ static void sh_timer_write(void *opaque, hwaddr offset, /* Restart the timer if still enabled. */ ptimer_run(s->timer, 0); } + ptimer_transaction_commit(s->timer); break; case OFFSET_TCPR: if (s->feat & TIMER_FEAT_CAPT) { @@ -168,12 +173,14 @@ static void sh_timer_start_stop(void *opaque, int enable) printf("sh_timer_start_stop %d (%d)\n", enable, s->enabled); #endif + ptimer_transaction_begin(s->timer); if (s->enabled && !enable) { ptimer_stop(s->timer); } if (!s->enabled && enable) { ptimer_run(s->timer, 0); } + ptimer_transaction_commit(s->timer); s->enabled = !!enable; #ifdef DEBUG_TIMER @@ -191,7 +198,6 @@ static void sh_timer_tick(void *opaque) static void *sh_timer_init(uint32_t freq, int feat, qemu_irq irq) { sh_timer_state *s; - QEMUBH *bh; s = (sh_timer_state *)g_malloc0(sizeof(sh_timer_state)); s->freq = freq; @@ -203,8 +209,7 @@ static void *sh_timer_init(uint32_t freq, int feat, qemu_irq irq) s->enabled = 0; s->irq = irq; - bh = qemu_bh_new(sh_timer_tick, s); - s->timer = ptimer_init_with_bh(bh, PTIMER_POLICY_DEFAULT); + s->timer = ptimer_init(sh_timer_tick, s, PTIMER_POLICY_DEFAULT); sh_timer_write(s, OFFSET_TCOR >> 2, s->tcor); sh_timer_write(s, OFFSET_TCNT >> 2, s->tcnt);