From nobody Tue Apr 15 10:50:06 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1615226076; cv=none; d=zohomail.com; s=zohoarc; b=MpXHVca/gkyJfd5dXZqnlCM4QhHS4t3qEmLvE+anSo9qecdMrJRNE9y2gEDRPZ8Dy2aUHFosIgm/8RjPV4H05ZCss1tEY+lHL3FBFLz/qTQv6xmHNn+GeLsmHHGXeDBTUJFnqc5LUNSfuk73OC0tWqhGBAN/YJTTHh0VJY8KoQY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615226076; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZaDTvaQiW6HmR9jZg8/+Dh4T9ld6iz8Wno9OhchiORM=; b=XwyUdUxu4NQ1eUllCjOn7tmVhJepPfzl7du2POb7SQZnHZ8ufF0w4daxW4NeZpyEN4Nco8/xeJ7/2JSKKuMT+HhXXheK35Y0HMPniERZtPbdD10xC+3R4vyygswH1VV/ssG+57S6ufk7SXPzjOIqPkhqEvSAj9ROQ1pjB+6i8pg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16152260765891011.0310344051641; Mon, 8 Mar 2021 09:54:36 -0800 (PST) Received: from localhost ([::1]:41714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lJK5T-0005dW-JI for importer@patchew.org; Mon, 08 Mar 2021 12:54:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lJJkS-0006KW-6g for qemu-devel@nongnu.org; Mon, 08 Mar 2021 12:32:52 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:46601) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lJJkQ-0006zq-1K for qemu-devel@nongnu.org; Mon, 08 Mar 2021 12:32:51 -0500 Received: by mail-wr1-x42a.google.com with SMTP id a18so12282281wrc.13 for ; Mon, 08 Mar 2021 09:32:49 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id i10sm18628217wrs.11.2021.03.08.09.32.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 09:32:48 -0800 (PST) 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=ZaDTvaQiW6HmR9jZg8/+Dh4T9ld6iz8Wno9OhchiORM=; b=nFIHkGKbsmpjMr/8NMOOkv7yU+NpZ8Ol8xIxn9WIGkGNqQ/H7jOI1GJ1uGc3kaJJqf yrfN4SngKninrjtCOzKYyhKA9im2NOYfsZQCzmycfi2WlrvaOr4U57xEddpeUJehmAOk 7oeh633VT2JM7bDCbu80JZ+qYrUQjIEiVn4YaezDq90f7nvZw75ylp4GjEz8abzt+sx/ LBe8W6q6/HqLiBsPKc09VoJHW+SCwo+WxIVO5Yg6q8nq8ZG/u5NOoxN7WlsPYBC99TAo glvPHkWsnQrBEQ0GHrrq0J4JsAyyYEsUY3ownEDcGOGItqqNEzYWr3JBp4kEjxn3gBTX B1Jw== 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=ZaDTvaQiW6HmR9jZg8/+Dh4T9ld6iz8Wno9OhchiORM=; b=tocqh1lwmLmfKcsTg9w1/IJMPNjZnwtj6K3B/MNWPs/ODK3909AJcDFDaz/G12Bjy/ cSZuy/rk1L94iSaYaf6E/ttHVDBY/JvQRfHC5kKnQrtdm60UY/WMKApVnyuZ6cwif7vZ VFx/wu5vY7EiBT+LbjDaX34RJRso8RruuC7ogXFrSpF4utlwS5evnmBMSJhnPkPPck0t jBS80lHseGutArCb2Ws17xmCkcwlFGGepTZzUR8hkvFZZWFldyVW4UMBTtItBWxF3XUy RkV/UKPKWfmu1jua9OFL8Vv1XflshCXGGRWSw1yYabgpmBfQNk5MmyzNKRVw5yrZNGYH /nNw== X-Gm-Message-State: AOAM530Qu4p0voyJcbV3nCfFyUt+hQZwnC8vjWZSex2iAhEp7UBB1Aqc VkuUWSZIJ+O3JKZsp1Iyhmio+WOrrETWEQ== X-Google-Smtp-Source: ABdhPJwqeTL7S0UFKLhPhNo6Fy2Mq2snXF8jCCPs4cX4N94RMFzY8DeGjY2AMizu5hKVV6j6in4C1A== X-Received: by 2002:adf:f7cc:: with SMTP id a12mr24030175wrq.54.1615224768381; Mon, 08 Mar 2021 09:32:48 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/54] clock: Add ClockPreUpdate callback event type Date: Mon, 8 Mar 2021 17:31:52 +0000 Message-Id: <20210308173244.20710-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210308173244.20710-1-peter.maydell@linaro.org> References: <20210308173244.20710-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Add a new callback event type ClockPreUpdate, which is called on period changes before the period is updated. Signed-off-by: Peter Maydell Reviewed-by: Luc Michel Reviewed-by: Hao Wu Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20210219144617.4782-3-peter.maydell@linaro.org --- docs/devel/clocks.rst | 9 ++++++++- include/hw/clock.h | 1 + hw/core/clock.c | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/devel/clocks.rst b/docs/devel/clocks.rst index cd344e3fe5d..f0391e76b4f 100644 --- a/docs/devel/clocks.rst +++ b/docs/devel/clocks.rst @@ -181,7 +181,14 @@ events. =20 The events currently supported are: =20 - * ``ClockUpdate`` : called after the input clock's period has changed + * ``ClockPreUpdate`` : called when the input clock's period is about to + update. This is useful if the device needs to do some action for + which it needs to know the old value of the clock period. During + this callback, Clock API functions like ``clock_get()`` or + ``clock_ticks_to_ns()`` will use the old period. + * ``ClockUpdate`` : called after the input clock's period has changed. + During this callback, Clock API functions like ``clock_ticks_to_ns()`` + will use the new period. =20 Note that a clock only has one callback: it is not possible to register different functions for different events. You must register a single diff --git a/include/hw/clock.h b/include/hw/clock.h index 282a37f7c5a..2ba44e14424 100644 --- a/include/hw/clock.h +++ b/include/hw/clock.h @@ -30,6 +30,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(Clock, CLOCK) */ typedef enum ClockEvent { ClockUpdate =3D 1, /* Clock period has just updated */ + ClockPreUpdate =3D 2, /* Clock period is about to update */ } ClockEvent; =20 typedef void ClockCallback(void *opaque, ClockEvent event); diff --git a/hw/core/clock.c b/hw/core/clock.c index 4479eff145b..fc5a99683f8 100644 --- a/hw/core/clock.c +++ b/hw/core/clock.c @@ -81,6 +81,9 @@ static void clock_propagate_period(Clock *clk, bool call_= callbacks) =20 QLIST_FOREACH(child, &clk->children, sibling) { if (child->period !=3D clk->period) { + if (call_callbacks) { + clock_call_callback(child, ClockPreUpdate); + } child->period =3D clk->period; trace_clock_update(CLOCK_PATH(child), CLOCK_PATH(clk), CLOCK_PERIOD_TO_HZ(clk->period), --=20 2.20.1