From patchwork Mon Oct 14 16:03:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 176303 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4746317ill; Mon, 14 Oct 2019 09:42:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmj1PdFr/70DSQ9yQT5zIMLOwnnWCmrNtJtlB0gT95ZDOlwkkDsvQeWy5ThIRKXLbM4WOV X-Received: by 2002:a17:906:7257:: with SMTP id n23mr30400742ejk.132.1571071335777; Mon, 14 Oct 2019 09:42:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571071335; cv=none; d=google.com; s=arc-20160816; b=rZ5uzx4jL2tCMjEbaSb5mN1oZh4PL6Inqnx6PIqLF8m6OdEV45Kh8xsLBQ4pNAuO7K PFzkY8FDbzCLieLxNquBL6qSE7+AtlYmqG5va9aKaA9u2ewHxB1pBekk87TXn7ZJ0bpU VaNcBaSfcPADYTJTA3FRcFXzlvJ9JRUx0uQ81RMQRBjUGpJpDAfElrC4L8g3hLsWNdUt Ho7zFeoKHk+GCQzn1I8VOM2GMl+LDKlRNSI4JzgMaiFqF/78Pkl4LCHz+ZdkycqBy1U9 WOgkDC5P0otyhegMAhXMMPhKsPta5v3elytTZh8VDfudJY09MbSSmCWLujfkwRBNQHSd YQ2A== 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=AqfOX9DanbrHqfYl2VtcpfIOP77gIYhu/52gPlZVV/I=; b=ULcMP+bXOf08P3XUx8nV3YdHKzjaokq9EgDuSwfVIyJMD4+wbzLzDpD6OOfk7Yz0g+ s0dEQ7qUbliYll4pdN1AWD4TmRBKJunCM/gtHa/0SFv26tEcJcApMCB2HKaRMM5xPUM6 OP6dJpkiCWRPTseinRpCGY28X8oNCdFRahF4nemniGQ5KW1KDAYRz9IQz7y3qOsbVe33 si+vTxicULhe2C+NQAiRFAEyf0MHAsg8iTLTafn+9gXU6Z177/YHex0OcmKPCdo8yo3U 9OoGlzrYMrwS8XYf+izOtHZiKHI7lBRR7qq2XJEAR52qRZRwd7a1yh4wxq6fbyO4huAP JhfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cRXmWSLR; 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 q20si12378636ejn.18.2019.10.14.09.42.15 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Oct 2019 09:42:15 -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=cRXmWSLR; 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]:53542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iK3QD-0002ZU-JQ for patch@linaro.org; Mon, 14 Oct 2019 12:42:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36950) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iK2q4-0004Bx-9A for qemu-devel@nongnu.org; Mon, 14 Oct 2019 12:04:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iK2q2-0007QF-U5 for qemu-devel@nongnu.org; Mon, 14 Oct 2019 12:04:51 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:36894) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iK2q2-0007PI-NK for qemu-devel@nongnu.org; Mon, 14 Oct 2019 12:04:50 -0400 Received: by mail-wr1-x442.google.com with SMTP id p14so20379797wro.4 for ; Mon, 14 Oct 2019 09:04:50 -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=AqfOX9DanbrHqfYl2VtcpfIOP77gIYhu/52gPlZVV/I=; b=cRXmWSLRSUUl2Uag/YMbiBTHxMpURXzmrUSZgQyDLliu45CbNKdzC5LGr3MpfTvwxL GQZQwYrOiT5nMWvWYR6hVRe49JR/6udbg1vgsFoEGTrojCM2yz5cwo4LzbKOnbaziAsA 1kGYuMeJi/ggB7jexRD1X6rLsbMjTKROiajf8xPwhv/Q0ztRp+buE4KzGn5dW0onsKei MLDvAt03ettAgI90YyIl01cCPXLNsLbysfqTHkngbwo7OwmfgXVckq8tR7HLSi39fKmx tPDUdcTA2z8PPsNeFfRBC/hWECNazkYESIHMaqFxRugkNrRCwMj7FRXyKFno2XWup/SF W64Q== 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=AqfOX9DanbrHqfYl2VtcpfIOP77gIYhu/52gPlZVV/I=; b=iSFl+cS8QihyBIDAB7W3rdN1mKVsnwfI0r/KZ98VFPP5cMSvWIwkrF2XYEXBstLqoD BxwXKsyjzAkImRkjD3cu278IFyqvpP8PHmjZofxl9KR1MR8ETGRXA2lJht1thErNIjAD aMyCWXwxac7r+dEjQV7WmYmeHs2/Qs03k7QKGXZQR6+HyUHzlipRvyegvTVP4EjRwz50 pYxj4ysDelPc6juVaCi8jD9At6xso1GrMKTvuBNrunNdfwHUN+x1DzVbbHKPg5E8phVv R6+HZgHtWhB8Vg7o7i/OWdTA8jfMkpnDuEBUTrVxyihoOd25Ml0NOJXPjRUMYafsdvc1 WYxw== X-Gm-Message-State: APjAAAXc1ZTN06pPRnN9hfOpB8ZN4x6gPnSUxNgmYNuMdfTkgmDkoiQP drCV4K0Odyd5cIegKqOxvsJj8gFRf8vf2Q== X-Received: by 2002:a05:6000:103:: with SMTP id o3mr2574464wrx.357.1571069089237; Mon, 14 Oct 2019 09:04:49 -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.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2019 09:04:48 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 22/68] hw/timer/mss-timerc: Switch to transaction-based ptimer API Date: Mon, 14 Oct 2019 17:03:18 +0100 Message-Id: <20191014160404.19553-23-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::442 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 mss-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 Message-id: 20191008171740.9679-20-peter.maydell@linaro.org --- include/hw/timer/mss-timer.h | 1 - hw/timer/mss-timer.c | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/include/hw/timer/mss-timer.h b/include/hw/timer/mss-timer.h index d15d1732f81..e5a784b27e4 100644 --- a/include/hw/timer/mss-timer.h +++ b/include/hw/timer/mss-timer.h @@ -46,7 +46,6 @@ #define R_TIM1_MAX 6 struct Msf2Timer { - QEMUBH *bh; ptimer_state *ptimer; uint32_t regs[R_TIM1_MAX]; diff --git a/hw/timer/mss-timer.c b/hw/timer/mss-timer.c index a34c2402b00..b1c9a805011 100644 --- a/hw/timer/mss-timer.c +++ b/hw/timer/mss-timer.c @@ -24,7 +24,6 @@ */ #include "qemu/osdep.h" -#include "qemu/main-loop.h" #include "qemu/module.h" #include "qemu/log.h" #include "hw/irq.h" @@ -67,6 +66,7 @@ static void timer_update_irq(struct Msf2Timer *st) qemu_set_irq(st->irq, (ier && isr)); } +/* Must be called from within a ptimer_transaction_begin/commit block */ static void timer_update(struct Msf2Timer *st) { uint64_t count; @@ -159,7 +159,9 @@ timer_write(void *opaque, hwaddr offset, switch (addr) { case R_TIM_CTRL: st->regs[R_TIM_CTRL] = value; + ptimer_transaction_begin(st->ptimer); timer_update(st); + ptimer_transaction_commit(st->ptimer); break; case R_TIM_RIS: @@ -171,7 +173,9 @@ timer_write(void *opaque, hwaddr offset, case R_TIM_LOADVAL: st->regs[R_TIM_LOADVAL] = value; if (st->regs[R_TIM_CTRL] & TIMER_CTRL_ENBL) { + ptimer_transaction_begin(st->ptimer); timer_update(st); + ptimer_transaction_commit(st->ptimer); } break; @@ -228,9 +232,10 @@ static void mss_timer_init(Object *obj) for (i = 0; i < NUM_TIMERS; i++) { struct Msf2Timer *st = &t->timers[i]; - st->bh = qemu_bh_new(timer_hit, st); - st->ptimer = ptimer_init_with_bh(st->bh, PTIMER_POLICY_DEFAULT); + st->ptimer = ptimer_init(timer_hit, st, PTIMER_POLICY_DEFAULT); + ptimer_transaction_begin(st->ptimer); ptimer_set_freq(st->ptimer, t->freq_hz); + ptimer_transaction_commit(st->ptimer); sysbus_init_irq(SYS_BUS_DEVICE(obj), &st->irq); }