From patchwork Mon Oct 21 13:43:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 177090 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3443238ill; Mon, 21 Oct 2019 06:46:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqz/uOBKIKkEXKgmt/B6LITlS/JiCfYJbxcDAUtNhnAxCMqmdI2yMWsPSDb+Jt0ALYl8Airj X-Received: by 2002:a17:906:a459:: with SMTP id cb25mr21744555ejb.63.1571665607626; Mon, 21 Oct 2019 06:46:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571665607; cv=none; d=google.com; s=arc-20160816; b=XIvTB6qKZgXMBIXpjNirDvHnC0032+/mIG1ERZYuIECjypnJPCDCPnHlU0MP2LqYR6 8Wy+skadhJebTzgfRD0EBb6qqhYV+cTC9AQ6PQT7CHytZZ1J/gvXfqTB0bp/ND5zEA39 E+kDiLjJCa4l34AhaTzPCTMF5x2Q+aEX3DgA3UnhXehOt1VwhOgC1ECFXEuWLLscrHSV cNvi5Pcw2yRfteVm/FK+AHhKylINdwclt5+8RpYfkRcZsCoD2zrAa6q/jMiiyTYNGQBZ lPC5LXdC2gbiwJ1QwZlfaHGkx/dqdoRHbc5cX0nSZ+H0ZAl/TQHFfw961xQuaX+D/svW CYbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=r8iZh3rlVFkRbMfWM6WompjfbpM52UZR9Y4A8GedhyE=; b=NTOvldExkBi6vcNWT6Sk67tXKxSj2ts2/wT+8IZnQ52LbO0ucfA6gXsMxXN5GafCIr Jbs7jwQ7crTFSxojEgmtxlKquFVlmRXbUYypZX7mnYBekD3CuorcUWV/XT81aveprK5A GKwfTJHEFs0wn7bSAeJt/ti/8WN6EvSRpZLErxFZg1xBlakVOMXm3Olw2BbjV8hAJB/N 7tpDquUO/OnuxrgUV4x9OrlpEQn6SvZTOzW+Glu0TMcmB2uwjlvsGDSz2jdTFr0JrQGo vbC+x9vBZy1LUYjWOcGFCOg863vISVnUzTY875wslNVNbxB+iJQxeXvVicVazzHFX6yB RTCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=cyCUG8C2; 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=fail (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 p3si9068859ejj.347.2019.10.21.06.46.47 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Oct 2019 06:46:47 -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=fail header.i=@linaro.org header.s=google header.b=cyCUG8C2; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42236 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMY1G-0002LP-4E for patch@linaro.org; Mon, 21 Oct 2019 09:46:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41514) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMXyf-0007vg-Rd for qemu-devel@nongnu.org; Mon, 21 Oct 2019 09:44:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iMXye-0000m4-Iz for qemu-devel@nongnu.org; Mon, 21 Oct 2019 09:44:05 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:33999) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iMXye-0000li-Cs for qemu-devel@nongnu.org; Mon, 21 Oct 2019 09:44:04 -0400 Received: by mail-wr1-x441.google.com with SMTP id t16so8931582wrr.1 for ; Mon, 21 Oct 2019 06:44:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=r8iZh3rlVFkRbMfWM6WompjfbpM52UZR9Y4A8GedhyE=; b=cyCUG8C2k5DYc7CeXzPwKffsUKhTwgVhdVReecPghs/ZZjyrQB3ValEEEgxVXwNNMC lMQXPUtp3LfSrK9jxVippy/byUlGzm+UVbD/Y5ecVe7JyG7yEw0fUiII6DLxV81ymN7C MZTHmXf1zwcQqunA1KVht5hk5IZojrOs9inWcs8HOOqISkozBh1suOIFozaZDMYnqMyq ZPGaI0JtjbvrjN+/YfPlcAH5TAD3SIZCiyRTMCYxkxasnmikFB9ee9YqNh0dB4dYGR0N 1qwCiEgMY2GDXv98YXeBIcMI9ySYm/DLmCdWRpmYXha0B0LLu1e4wNIfb2kRcEkXD5Ve DJBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r8iZh3rlVFkRbMfWM6WompjfbpM52UZR9Y4A8GedhyE=; b=nLwyjAEcl+4TyXfvq++3wjxUgLcO1KQu4Jk/nTFB9os1HOteM0bzW+D3BuXbAIJMjA L0pv7OySAXl4Mv4j5MTlDMMQpinkaMrIVrWAmj0x0TgR4jf1HSTSE96zLDL5zB0ZxNoZ yyAOD1SnMdm8PVHmYVlBWP9iU979rPpi7e/4xRcfQqr2Pqw3HJnOhau24Xm3JIJtKuDt 5VGl/SgV/VYIeakCghwCDoIg4oSHGYAy810CTXC4Y+XDxocpouQKjf7CFj7B1S93re8P YGTQiQ7Dp5YKMoepdjJyqzULetZU7FEJNBbqdwaDROLUxSyatbK42L2kYm8xvcsOqFU/ yBUw== X-Gm-Message-State: APjAAAVTnYTrKqUdaA2J7UfG9anj9iYh9Q4AkqJZgRhz6nN55B3XRoUp uIfWVj3ugjuK9qgFR+ARKvPzYaXgC9E= X-Received: by 2002:a5d:54d1:: with SMTP id x17mr18619139wrv.297.1571665443014; Mon, 21 Oct 2019 06:44:03 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id q196sm10443689wme.23.2019.10.21.06.44.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 06:44:02 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH v2 2/3] hw/timer/grlib_gptimer.c: Switch to transaction-based ptimer API Date: Mon, 21 Oct 2019 14:43:56 +0100 Message-Id: <20191021134357.14266-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021134357.14266-1-peter.maydell@linaro.org> References: <20191021134357.14266-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::441 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: , Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , KONRAD Frederic , Richard Henderson , Mark Cave-Ayland , Fabien Chouteau Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Switch the grlib_gptimer 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é --- hw/timer/grlib_gptimer.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/hw/timer/grlib_gptimer.c b/hw/timer/grlib_gptimer.c index bb09268ea14..7a9371c0e30 100644 --- a/hw/timer/grlib_gptimer.c +++ b/hw/timer/grlib_gptimer.c @@ -29,7 +29,6 @@ #include "hw/irq.h" #include "hw/ptimer.h" #include "hw/qdev-properties.h" -#include "qemu/main-loop.h" #include "qemu/module.h" #include "trace.h" @@ -63,7 +62,6 @@ typedef struct GPTimer GPTimer; typedef struct GPTimerUnit GPTimerUnit; struct GPTimer { - QEMUBH *bh; struct ptimer_state *ptimer; qemu_irq irq; @@ -93,6 +91,17 @@ struct GPTimerUnit { uint32_t config; }; +static void grlib_gptimer_tx_begin(GPTimer *timer) +{ + ptimer_transaction_begin(timer->ptimer); +} + +static void grlib_gptimer_tx_commit(GPTimer *timer) +{ + ptimer_transaction_commit(timer->ptimer); +} + +/* Must be called within grlib_gptimer_tx_begin/commit block */ static void grlib_gptimer_enable(GPTimer *timer) { assert(timer != NULL); @@ -115,6 +124,7 @@ static void grlib_gptimer_enable(GPTimer *timer) ptimer_run(timer->ptimer, 1); } +/* Must be called within grlib_gptimer_tx_begin/commit block */ static void grlib_gptimer_restart(GPTimer *timer) { assert(timer != NULL); @@ -141,7 +151,9 @@ static void grlib_gptimer_set_scaler(GPTimerUnit *unit, uint32_t scaler) trace_grlib_gptimer_set_scaler(scaler, value); for (i = 0; i < unit->nr_timers; i++) { + ptimer_transaction_begin(unit->timers[i].ptimer); ptimer_set_freq(unit->timers[i].ptimer, value); + ptimer_transaction_commit(unit->timers[i].ptimer); } } @@ -266,8 +278,10 @@ static void grlib_gptimer_write(void *opaque, hwaddr addr, switch (timer_addr) { case COUNTER_OFFSET: trace_grlib_gptimer_writel(id, addr, value); + grlib_gptimer_tx_begin(&unit->timers[id]); unit->timers[id].counter = value; grlib_gptimer_enable(&unit->timers[id]); + grlib_gptimer_tx_commit(&unit->timers[id]); return; case COUNTER_RELOAD_OFFSET: @@ -291,6 +305,7 @@ static void grlib_gptimer_write(void *opaque, hwaddr addr, /* gptimer_restart calls gptimer_enable, so if "enable" and "load" bits are present, we just have to call restart. */ + grlib_gptimer_tx_begin(&unit->timers[id]); if (value & GPTIMER_LOAD) { grlib_gptimer_restart(&unit->timers[id]); } else if (value & GPTIMER_ENABLE) { @@ -301,6 +316,7 @@ static void grlib_gptimer_write(void *opaque, hwaddr addr, value &= ~(GPTIMER_LOAD & GPTIMER_DEBUG_HALT); unit->timers[id].config = value; + grlib_gptimer_tx_commit(&unit->timers[id]); return; default: @@ -344,9 +360,11 @@ static void grlib_gptimer_reset(DeviceState *d) timer->counter = 0; timer->reload = 0; timer->config = 0; + ptimer_transaction_begin(timer->ptimer); ptimer_stop(timer->ptimer); ptimer_set_count(timer->ptimer, 0); ptimer_set_freq(timer->ptimer, unit->freq_hz); + ptimer_transaction_commit(timer->ptimer); } } @@ -365,14 +383,16 @@ static void grlib_gptimer_realize(DeviceState *dev, Error **errp) GPTimer *timer = &unit->timers[i]; timer->unit = unit; - timer->bh = qemu_bh_new(grlib_gptimer_hit, timer); - timer->ptimer = ptimer_init_with_bh(timer->bh, PTIMER_POLICY_DEFAULT); + timer->ptimer = ptimer_init(grlib_gptimer_hit, timer, + PTIMER_POLICY_DEFAULT); timer->id = i; /* One IRQ line for each timer */ sysbus_init_irq(sbd, &timer->irq); + ptimer_transaction_begin(timer->ptimer); ptimer_set_freq(timer->ptimer, unit->freq_hz); + ptimer_transaction_commit(timer->ptimer); } memory_region_init_io(&unit->iomem, OBJECT(unit), &grlib_gptimer_ops,