From patchwork Thu Oct 17 13:23:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 176646 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp967094ill; Thu, 17 Oct 2019 06:59:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPfq+1mJDa9dVSh+meiaZG3OdpMGJ6lYdZufBTknvmMLh9dF3d4rjF4z0F810KVsgECOKn X-Received: by 2002:a37:67cb:: with SMTP id b194mr3397764qkc.238.1571320776171; Thu, 17 Oct 2019 06:59:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571320776; cv=none; d=google.com; s=arc-20160816; b=OGwLjdX1Y/y2Y1fv9Dm8QBWrGJGkjoNXmcTt919EUGOoloBkxlbz6EiekA8dGJHrvy gtWE1LM1LuehhvvnsLkHYMkefBCsNSuNjqIyzJddkAtZm+KasbSbEqEBUaLhqEcH+8+y cl4uCtPFWAd9OnQBlhCzynn1/o+AQ4KHp2JzxWJsC+pa9cfjTivZEjOoxzNatsvc+eHn ndP0tgFSI/JDStywzJRY42Y31TzEs76HICdLiYy0myFhGSbij0saSA0ldHPdjmz9eAS6 YRyscFmmbBrOJv5U4gekl7rVYi2uq9qJGMTEdtp/x4ngu8QH23ClMgKLeeoubTJUmQLp 9Kcw== 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=AoRIF8ofQDbeGLT/YF+4ga2y/BWkoNekd0m2fWT6Bak=; b=R/hcFGeSHzaHUZhonhIv3+YKrBUcPnLcLSvFZHS1ag6oqj1CDR0TLxHUWk+mqrUh86 um5kP4t+//4Otx44kqcI4nskDF9OnwbYFJMFTthzzQoDGwLJWtRnl20CnpQM+okNZXQl LcCvHnxAmjvJVtA1ciE9VjzAgF/qUUzAgTgYV2oUC+ZJ9RxE3Ce93bQEeVC8BYMctmqD fL0ltl3xGjhTRnv9jTZa86uQr2YQXkkO7DZP16eK/5PfPgGsgG7jFFneweWXlPU+96DB 90SPlCI+Z7qVYc6avAtdj4aKMifrv4x3no6oHjlWbJz0w6am+pdKn3zqAJ/8eUbZ1Ehw 5W5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=DSdLYlYe; 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 t17si2239107qve.135.2019.10.17.06.59.36 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 06:59:36 -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=DSdLYlYe; 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]:48632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL6JT-0001G3-3Z for patch@linaro.org; Thu, 17 Oct 2019 09:59:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35256) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL5l1-00009E-Pr for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:24:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL5l0-0000wL-Jc for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:23:59 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:36741) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL5kz-0000vv-JM for qemu-devel@nongnu.org; Thu, 17 Oct 2019 09:23:57 -0400 Received: by mail-wr1-x444.google.com with SMTP id w18so1784297wrt.3 for ; Thu, 17 Oct 2019 06:23:56 -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=AoRIF8ofQDbeGLT/YF+4ga2y/BWkoNekd0m2fWT6Bak=; b=DSdLYlYePYGsQ7d48WwCcj5p2pP0d4ZKLNjl6g/zqByUaw38CU+VB5GX12D/O63zzu fiEUVMFhf6PcNa6nVuBcDugHbpZiVt9vLL/eNztvM5dg8ykewfB9C2lTfqb8+qTIlNJv DYNwGSsJWTiLcjDlzUcqjsuXIJf2hD74vlxv0M7WRfC7AVTkSFulqv7VSkZMfKkEH3GE HyyW//m7ukXTnIzutQ7tFp///EBqev7swFmByG86jnJyk8Xk3MScijSu6uD2YCd7nhXW O2XIggX3Od0gwnmiTAHUX4uMpIDLJ46rLnJQDkt6vfVNeKQkjL8HDcxiRPBFkTrDr507 sxvA== 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=AoRIF8ofQDbeGLT/YF+4ga2y/BWkoNekd0m2fWT6Bak=; b=g0sJ5slTri6ZnnWSzVXEZcacttjTfn6V6miAQPNX/HyJDQOTovAMb1shoGTPYbsjRm wvwBYUWaxojU0hYw0xa62aF2r4yPfW7nNj3yOHts3cfGbIHagziLeyKarXM2f03JNykD d52+SAfnE0plG7fg9x7dai2VtYCfNIxwT+ooxOa2LA5qUafX2VQCguZtxAQzh25vSwmw u/+ZFZaSZ1e6O/5BVvrRqBuJLi6/paASvNF7LZ3CgzwO/50WtmxMreiWsNBsaIeOKYzA ZG4WUdkjKGNFlEFhCgc/oMkgtE93b2n12X2skr4kfltmdjiw7iPZAcbSReWzjLehrcqA nhMQ== X-Gm-Message-State: APjAAAV5FyVNDYz7tB/IgXGF2P3RVSjQeGfL4eQNFA9BWcL4B+XcyL3E cqZHzYyxOxlpHxjq5lWdgxtMZcHS3Ww4HQ== X-Received: by 2002:a5d:51c3:: with SMTP id n3mr3073602wrv.5.1571318635719; Thu, 17 Oct 2019 06:23:55 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id z9sm2270302wrp.26.2019.10.17.06.23.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:23:54 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH 1/2] hw/timer/grlib_gptimer.c: Switch to transaction-based ptimer API Date: Thu, 17 Oct 2019 14:23:50 +0100 Message-Id: <20191017132351.4762-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191017132351.4762-1-peter.maydell@linaro.org> References: <20191017132351.4762-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::444 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: KONRAD Frederic , 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 --- hw/timer/grlib_gptimer.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé 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,