From nobody Thu Dec 18 19:34:25 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1571751599; cv=none; d=zoho.com; s=zohoarc; b=ZcRcICL7dw8c/OC1j4/xiIypOF61sE5S6YCV4SdgJpne10oZZcCCuUMjJV5p34VH3mAMlfXZcfMpZP73pztj/RjXZYaqOeJOF2JcAqbLkwjjH+/+9X73HJz0vuyjkSodz6qE9UKrSt9/plsoXGXXU/8p1r/rceWRe+alfGeC058= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571751599; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uDrLBjDpGth9A9xH8MMq1NWvBIh2l7Tya6vjM+QNwc0=; b=ITnN0CkiSMcyb+seEpLl1CQt+qwEd1JqBG51cVHqHmlV7ibJm9UxNlmMtwTcMkBsR2B+807DAOwqEkA9nF7soeVLR+/44Jw0S5QqgfNuORQRJKgq2rkyqqNcBZ/8tHC+WlyIhg3ePvlniVqNe0nRuGg30xwguritADMZhtAy574= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15717515997801006.7740872734175; Tue, 22 Oct 2019 06:39:59 -0700 (PDT) Received: from localhost ([::1]:57500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMuOE-0003qj-KT for importer@patchew.org; Tue, 22 Oct 2019 09:39:58 -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) 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) 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-Google-Smtp-Source: APXvYqwI2MuyNn+8ONOXpoI8Eppq2M67TxSBWZQ+Bu4xUH8lAUA1w3akIWbJeueXpt6/NqiPLLrcyA== X-Received: by 2002:a1c:c912:: with SMTP id f18mr3291383wmb.168.1571751115490; Tue, 22 Oct 2019 06:31:55 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) 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=C3=A9 Message-id: 20191017132905.5604-3-peter.maydell@linaro.org --- hw/timer/sh_timer.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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" =20 //#define DEBUG_TIMER @@ -91,13 +90,18 @@ static void sh_timer_write(void *opaque, hwaddr offset, switch (offset >> 2) { case OFFSET_TCOR: s->tcor =3D 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 =3D 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 ena= ble) printf("sh_timer_start_stop %d (%d)\n", enable, s->enabled); #endif =20 + 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 =3D !!enable; =20 #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; =20 s =3D (sh_timer_state *)g_malloc0(sizeof(sh_timer_state)); s->freq =3D freq; @@ -203,8 +209,7 @@ static void *sh_timer_init(uint32_t freq, int feat, qem= u_irq irq) s->enabled =3D 0; s->irq =3D irq; =20 - bh =3D qemu_bh_new(sh_timer_tick, s); - s->timer =3D ptimer_init_with_bh(bh, PTIMER_POLICY_DEFAULT); + s->timer =3D ptimer_init(sh_timer_tick, s, PTIMER_POLICY_DEFAULT); =20 sh_timer_write(s, OFFSET_TCOR >> 2, s->tcor); sh_timer_write(s, OFFSET_TCNT >> 2, s->tcnt); --=20 2.20.1