From patchwork Mon Oct 14 16:03:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 176281 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4729994ill; Mon, 14 Oct 2019 09:27:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzd6hYT9WLKUo7HXc91o5URIxTiVGSBjanhdJiGtDhRUNJSyy+OwvdqHPoDJ/Px6mexHEcd X-Received: by 2002:a05:620a:16b9:: with SMTP id s25mr31652990qkj.102.1571070438987; Mon, 14 Oct 2019 09:27:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571070438; cv=none; d=google.com; s=arc-20160816; b=ZABJ3T2yFuH1GOLYnbN0lRCWVVpqbrzq0BCfHKEC2E4O0qrux8fzPYDfOMF955nHrt qXSOOIFX3LB7kkO4r0MW2p+iRieiPJyiHGkqcCF8gCvCUZxJBsqNr/A5hV2/i38KqwsG 5TQiqhO5XTPPOlyMb3M2vIPCp+X5krdDgOl4BIsisjWBp2USv1tZG/MsTotYcOi8kfLu 5CY8X8ZhXdBCAECsmD6VL25vVxiWoTbJcN6MZqYJD6XixX81Ycy6H1hDd+KByl8aWopA 5Zrb/eTV5wu670mWk5FK3gyO3FBWAa6jkLEiBtPIO3MCe5IE7MEjS1jAi67EiJt5Eyos gcCg== 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=jTmeC9fsNiMpPjbvhf5TS5+W4xCHxtvz7UPSHxJb4Z4=; b=rarhfO/8CYrDd1ZNmiw+Rr/EsyAwU0nBvW9WWXbijX5zXgWgc2EONWORw/ta1MRTjs ftGEvDdrpg/EoS7qi40rAGlLLQyxb5RjIAsW8/6OnU6GxuNVCh3j71DklTY4QmxrTIAN nOSx8KY5O3pK3scXonQQRLF0BEOKdSAhWt04Q8tzFJEyAcJzbolpXmaQUvIl0G3HLT6d ZjZRtA+XA+bnskUMSZxf5MK3zSsO+LB/pqugZju53WWwuvgHikrilFbNGbixoeIKaP7p hGJiiJUeqzn9guKPJYlirh9Loc1m4A+KVzCCmyREvoGl2hOQvjRfXsmsMS90GZrtG/Us rHIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JeKjaw9+; 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 z42si18260989qvg.83.2019.10.14.09.27.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 09:27:18 -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=JeKjaw9+; 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]:53234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iK3Bm-00070g-0J for patch@linaro.org; Mon, 14 Oct 2019 12:27:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36843) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iK2pw-0003xg-0d for qemu-devel@nongnu.org; Mon, 14 Oct 2019 12:04:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iK2pq-0007CG-OJ for qemu-devel@nongnu.org; Mon, 14 Oct 2019 12:04:43 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:54046) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iK2pq-0007AR-I5 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 12:04:38 -0400 Received: by mail-wm1-x32e.google.com with SMTP id i16so17853342wmd.3 for ; Mon, 14 Oct 2019 09:04:38 -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=jTmeC9fsNiMpPjbvhf5TS5+W4xCHxtvz7UPSHxJb4Z4=; b=JeKjaw9+M/YsItBnjcbCAp/pV/wuARXfNGr6Mkbf4CWjFxT4RKEoW2me5k6ADPjy2O F75BuuMaPsHMB/y3bMIIxtdmp8UwUg/4kuB93k5pmpKzF5qqW8gvfWPMCrLrZpLougbD Yo0wZ9jChJYAiQI/itKGmKSyVhKNQElXFV1zZRRqoyorZ2PA147zT02OLel9qRuidBxu +YfxLpI+Ha/NYKAY6aiEbHD1C6PTeGQMhL2calGh1XM7gnLsZv9LXwV/q3LjlhiEMKY/ 9A4u/q07l4ZLxwAVNniSXluycp/9leO+933jSR6Vl7+WeigExWHhcvgC0lckvmossWq2 MLjw== 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=jTmeC9fsNiMpPjbvhf5TS5+W4xCHxtvz7UPSHxJb4Z4=; b=eyrLtk2MyrhyfsLkbaDPPSirBgqUL7s0RZggCIQ/GrYv6hJkwsShvOL5uNpiJc5jtf vt5lgr8LEofSaRAMZ7ZSsP+q5UjIfKFAwMPqHNB8wPv7n/pMQkma10reDhP1bQZZEmhe ZtuYMrAb4HIHeaVMkXoPqqAx+Rdio6doQcogqBEr6fOTHD/s5YY+jeH7o9uwu35iZlDi 5j0k+SQbrjMvdApDogMaOAf/tTOtyQGWbQK31fm8SnSfy1ivIjXgjO6KejUxfhPKtCwU 547TgxrdhRMVEmiFDJ+nUpwhgGFwtGVrAjzRvCIRwm3J0pmfJ4BxWIh0yHKywh412NlZ a4Rw== X-Gm-Message-State: APjAAAVleNl5xAD6wh1Dgf0LuZYW7fEDVtPgwh0bl7eaIahrEC8IV3cc zugGC3v0hQvInBgiECFv/qjyp911C20GfQ== X-Received: by 2002:a7b:c006:: with SMTP id c6mr16047082wmb.45.1571069077039; Mon, 14 Oct 2019 09:04:37 -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.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 09:04:36 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 14/68] hw/timer/exynos4210_mct.c: Switch GFRC to transaction-based ptimer API Date: Mon, 14 Oct 2019 17:03:10 +0100 Message-Id: <20191014160404.19553-15-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::32e 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" We want to switch the exynos MCT code away from bottom-half based ptimers to the new transaction-based ptimer API. The MCT is complicated and uses multiple different ptimers, so it's clearer to switch it a piece at a time. Here we change over only the GFRC. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20191008171740.9679-12-peter.maydell@linaro.org --- hw/timer/exynos4210_mct.c | 48 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/hw/timer/exynos4210_mct.c b/hw/timer/exynos4210_mct.c index 9f2e8dd0a42..fcf91c75cc5 100644 --- a/hw/timer/exynos4210_mct.c +++ b/hw/timer/exynos4210_mct.c @@ -364,6 +364,7 @@ static void exynos4210_mct_update_freq(Exynos4210MCTState *s); /* * Set counter of FRC global timer. + * Must be called within exynos4210_gfrc_tx_begin/commit block. */ static void exynos4210_gfrc_set_count(Exynos4210MCTGT *s, uint64_t count) { @@ -385,6 +386,7 @@ static uint64_t exynos4210_gfrc_get_count(Exynos4210MCTGT *s) /* * Stop global FRC timer + * Must be called within exynos4210_gfrc_tx_begin/commit block. */ static void exynos4210_gfrc_stop(Exynos4210MCTGT *s) { @@ -395,6 +397,7 @@ static void exynos4210_gfrc_stop(Exynos4210MCTGT *s) /* * Start global FRC timer + * Must be called within exynos4210_gfrc_tx_begin/commit block. */ static void exynos4210_gfrc_start(Exynos4210MCTGT *s) { @@ -403,6 +406,21 @@ static void exynos4210_gfrc_start(Exynos4210MCTGT *s) ptimer_run(s->ptimer_frc, 1); } +/* + * Start ptimer transaction for global FRC timer; this is just for + * consistency with the way we wrap operations like stop and run. + */ +static void exynos4210_gfrc_tx_begin(Exynos4210MCTGT *s) +{ + ptimer_transaction_begin(s->ptimer_frc); +} + +/* Commit ptimer transaction for global FRC timer. */ +static void exynos4210_gfrc_tx_commit(Exynos4210MCTGT *s) +{ + ptimer_transaction_commit(s->ptimer_frc); +} + /* * Find next nearest Comparator. If current Comparator value equals to other * Comparator value, skip them both @@ -492,6 +510,7 @@ static uint64_t exynos4210_gcomp_get_distance(Exynos4210MCTState *s, int32_t id) /* * Restart global FRC timer + * Must be called within exynos4210_gfrc_tx_begin/commit block. */ static void exynos4210_gfrc_restart(Exynos4210MCTState *s) { @@ -933,6 +952,19 @@ static void exynos4210_ltick_event(void *opaque) exynos4210_ltick_int_start(&s->tick_timer); } +static void tx_ptimer_set_freq(ptimer_state *s, uint32_t freq) +{ + /* + * callers of exynos4210_mct_update_freq() never do anything + * else that needs to be in the same ptimer transaction, so + * to avoid a lot of repetition we have a convenience function + * for begin/set_freq/commit. + */ + ptimer_transaction_begin(s); + ptimer_set_freq(s, freq); + ptimer_transaction_commit(s); +} + /* update timer frequency */ static void exynos4210_mct_update_freq(Exynos4210MCTState *s) { @@ -945,7 +977,7 @@ static void exynos4210_mct_update_freq(Exynos4210MCTState *s) DPRINTF("freq=%dHz\n", s->freq); /* global timer */ - ptimer_set_freq(s->g_timer.ptimer_frc, s->freq); + tx_ptimer_set_freq(s->g_timer.ptimer_frc, s->freq); /* local timer */ ptimer_set_freq(s->l_timer[0].tick_timer.ptimer_tick, s->freq); @@ -965,7 +997,9 @@ static void exynos4210_mct_reset(DeviceState *d) /* global timer */ memset(&s->g_timer.reg, 0, sizeof(s->g_timer.reg)); + exynos4210_gfrc_tx_begin(&s->g_timer); exynos4210_gfrc_stop(&s->g_timer); + exynos4210_gfrc_tx_commit(&s->g_timer); /* local timer */ memset(s->l_timer[0].reg.cnt, 0, sizeof(s->l_timer[0].reg.cnt)); @@ -1144,7 +1178,9 @@ static void exynos4210_mct_write(void *opaque, hwaddr offset, } s->g_timer.reg.cnt = new_frc; + exynos4210_gfrc_tx_begin(&s->g_timer); exynos4210_gfrc_restart(s); + exynos4210_gfrc_tx_commit(&s->g_timer); break; case G_CNT_WSTAT: @@ -1168,7 +1204,9 @@ static void exynos4210_mct_write(void *opaque, hwaddr offset, s->g_timer.reg.wstat |= G_WSTAT_COMP_L(index); } + exynos4210_gfrc_tx_begin(&s->g_timer); exynos4210_gfrc_restart(s); + exynos4210_gfrc_tx_commit(&s->g_timer); break; case G_TCON: @@ -1178,6 +1216,8 @@ static void exynos4210_mct_write(void *opaque, hwaddr offset, DPRINTF("global timer write to reg.g_tcon %llx\n", value); + exynos4210_gfrc_tx_begin(&s->g_timer); + /* Start FRC if transition from disabled to enabled */ if ((value & G_TCON_TIMER_ENABLE) > (old_val & G_TCON_TIMER_ENABLE)) { @@ -1195,6 +1235,8 @@ static void exynos4210_mct_write(void *opaque, hwaddr offset, exynos4210_gfrc_restart(s); } } + + exynos4210_gfrc_tx_commit(&s->g_timer); break; case G_INT_CSTAT: @@ -1428,8 +1470,8 @@ static void exynos4210_mct_init(Object *obj) QEMUBH *bh[2]; /* Global timer */ - bh[0] = qemu_bh_new(exynos4210_gfrc_event, s); - s->g_timer.ptimer_frc = ptimer_init_with_bh(bh[0], PTIMER_POLICY_DEFAULT); + s->g_timer.ptimer_frc = ptimer_init(exynos4210_gfrc_event, s, + PTIMER_POLICY_DEFAULT); memset(&s->g_timer.reg, 0, sizeof(struct gregs)); /* Local timers */