From patchwork Tue Oct 22 13:31:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 177169 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp4881295ill; Tue, 22 Oct 2019 06:41:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNZNeCN2FU0/0lAA7RJ5yFfV39PYza3sTzvVq8r/6eRdlPGpOyz2ZNZizADL6KHew0Jgpg X-Received: by 2002:ac8:1408:: with SMTP id k8mr3273291qtj.327.1571751664369; Tue, 22 Oct 2019 06:41:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571751664; cv=none; d=google.com; s=arc-20160816; b=EASDj1Obq+v6Ck8Dr3e0D1ZYjlUONOtvlhrSEoRIEbXYQNE0anZjHqmoJ7v4HWgOYB lAKLspcHvZVqe0axNRyb4c/h38RxlpW3ij6iCwvJEsQ3qaOagm8OCPCxw8ZEq2SG9YXz jhohPNxyL9r65EG3ooxPgS1u0I6hO0oCxS53klnWhyXINwSHZWml7eaHaE/2KS/j0uey aw+7E1we6DS5anm3XZBpYATUTWTnLMZkFshx/7pgG3PEnO8S8ocP0b2tTe0Qu3Sdp5p0 PXX/LS1rLiyYqbT+9VP6FH49nDtkCAQnkMxqX3LHYhy4vXVy9j3xtBxJywVioK/yYpLs o3hw== 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=S/QCyLDKmYi4qFNoLejQGFlQ6w8d+jjMc7szR08wghI=; b=wmOzWqxuW6UAAEZnM5UBPlb7rFCyKX7E372E7ffCoMwXlk7Q1XYvlryq1huLoYdQl1 GnPL9d1/eOd6kHHIlnLqwMmH2p1paTrPeWa5u9F8sF3unaxkRbIilHqEuwiXVZh60XjC EFAO81pnQDfHMpSb2I34FWS1YpxbOxBDDV6bYr+MI6C74gZnc4uVkhyhJHda/x1tnfSB zmT6PnxLNuEhr8Iy3OrxeWtnWqUVIzvpYcRgcPTQoTCEIaUHjIxmcBIpmtkCA76Z0myj FQPPQ5MItanKXpkJrZ+3lrr2Vh9zewbPn+yx3f9ICiJIb1kSgGmKEepAIhANc7zlmFOp N+TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xRrPIVPZ; 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 o22si6949457qvh.30.2019.10.22.06.41.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 22 Oct 2019 06:41:04 -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=xRrPIVPZ; 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]:57538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMuPH-0005pb-JL for patch@linaro.org; Tue, 22 Oct 2019 09:41:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36682) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMuGZ-0002QE-6t for qemu-devel@nongnu.org; Tue, 22 Oct 2019 09:32:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iMuGX-0001EM-SC for qemu-devel@nongnu.org; Tue, 22 Oct 2019 09:32:03 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:51970) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iMuGX-0001E5-MJ for qemu-devel@nongnu.org; Tue, 22 Oct 2019 09:32:01 -0400 Received: by mail-wm1-x344.google.com with SMTP id q70so10126193wme.1 for ; Tue, 22 Oct 2019 06:32:01 -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=S/QCyLDKmYi4qFNoLejQGFlQ6w8d+jjMc7szR08wghI=; b=xRrPIVPZ492raVhjOCqPdOZNBB/RY8d64YbKQqsI629hGWLCQWpb8W4TZ8gz/PG0pS 3gPZySL0YJxTfJ+OMxEmjEZI8xi4vZVKuIYZ6ABssfJ9l5jKwhC/Iwik59mCf28yQYb/ fQx8ElmIIQA9EE8e3BPpEBouW2kN1NPgN+CRpOuSb/gaBkFw04u60H9X5CAuFIUxqmu5 SQ4XvFeRuXoeG32e3FGtc64Q4+33WV6AW9bmJI7KA/5N6253uz56a7i5qH+poDfRpao5 SxhOKnLXEA22oN969Kh6jX5fhuVWbdcoROfZVtDOljlzs8uMTNRwOkfafgqyS8FT4U6W os7g== 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=S/QCyLDKmYi4qFNoLejQGFlQ6w8d+jjMc7szR08wghI=; b=HBI0vTXPN9Z/2I1nAoyCqI4cjplfNPeTWyj6hKV28YvNxkSlZ8ZGAkkm5Kdm1jyp+/ eTSu1dB9nLC6uoeylKxZBVl+1+ryt9XJYpz+1neZipXbnkWtriaVG5J4wMyfw3ahk2dL 6J/A67gHgtoX0un8P5oxsqSFr+R2smQHb53hA95os132zE51TIAZTmWYzGYLVf+pJEnJ gR9ia0WdEqwlFnSGNyoROwtKl4bA16JJP1Ly5b91qmxrJAbBHfaecVmx+bju2yKh7ZzQ enuHeWMhwphBRrEitnr8CwJWigu49Tms02IL6Cpi2dpoL7/pXJoLSaOVfDn3FcHJz7Up 1iMQ== X-Gm-Message-State: APjAAAVFz2Uz9YTkCzC4VKJcNL8gx70Ct9lJA2CD7FIgggGmVK/SheCS ZdKlYcd2gOSu4PosqCdirIXvov4N+mc= X-Received: by 2002:a05:600c:225a:: with SMTP id a26mr3110214wmm.73.1571751120082; Tue, 22 Oct 2019 06:32:00 -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.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 06:31:58 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 08/41] hw/timer/altera_timer.c: Switch to transaction-based ptimer API Date: Tue, 22 Oct 2019 14:31:01 +0100 Message-Id: <20191022133134.14487-9-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::344 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 altera_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-6-peter.maydell@linaro.org --- hw/timer/altera_timer.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/hw/timer/altera_timer.c b/hw/timer/altera_timer.c index ee32e0ec1ff..79fc381252d 100644 --- a/hw/timer/altera_timer.c +++ b/hw/timer/altera_timer.c @@ -19,7 +19,6 @@ */ #include "qemu/osdep.h" -#include "qemu/main-loop.h" #include "qemu/module.h" #include "qapi/error.h" @@ -53,7 +52,6 @@ typedef struct AlteraTimer { MemoryRegion mmio; qemu_irq irq; uint32_t freq_hz; - QEMUBH *bh; ptimer_state *ptimer; uint32_t regs[R_MAX]; } AlteraTimer; @@ -105,6 +103,7 @@ static void timer_write(void *opaque, hwaddr addr, break; case R_CONTROL: + ptimer_transaction_begin(t->ptimer); t->regs[R_CONTROL] = value & (CONTROL_ITO | CONTROL_CONT); if ((value & CONTROL_START) && !(t->regs[R_STATUS] & STATUS_RUN)) { @@ -115,10 +114,12 @@ static void timer_write(void *opaque, hwaddr addr, ptimer_stop(t->ptimer); t->regs[R_STATUS] &= ~STATUS_RUN; } + ptimer_transaction_commit(t->ptimer); break; case R_PERIODL: case R_PERIODH: + ptimer_transaction_begin(t->ptimer); t->regs[addr] = value & 0xFFFF; if (t->regs[R_STATUS] & STATUS_RUN) { ptimer_stop(t->ptimer); @@ -126,6 +127,7 @@ static void timer_write(void *opaque, hwaddr addr, } tvalue = (t->regs[R_PERIODH] << 16) | t->regs[R_PERIODL]; ptimer_set_limit(t->ptimer, tvalue + 1, 1); + ptimer_transaction_commit(t->ptimer); break; case R_SNAPL: @@ -183,9 +185,10 @@ static void altera_timer_realize(DeviceState *dev, Error **errp) return; } - t->bh = qemu_bh_new(timer_hit, t); - t->ptimer = ptimer_init_with_bh(t->bh, PTIMER_POLICY_DEFAULT); + t->ptimer = ptimer_init(timer_hit, t, PTIMER_POLICY_DEFAULT); + ptimer_transaction_begin(t->ptimer); ptimer_set_freq(t->ptimer, t->freq_hz); + ptimer_transaction_commit(t->ptimer); memory_region_init_io(&t->mmio, OBJECT(t), &timer_ops, t, TYPE_ALTERA_TIMER, R_MAX * sizeof(uint32_t)); @@ -204,8 +207,10 @@ static void altera_timer_reset(DeviceState *dev) { AlteraTimer *t = ALTERA_TIMER(dev); + ptimer_transaction_begin(t->ptimer); ptimer_stop(t->ptimer); ptimer_set_limit(t->ptimer, 0xffffffff, 1); + ptimer_transaction_commit(t->ptimer); memset(t->regs, 0, sizeof(t->regs)); }