From patchwork Tue Oct 15 10:37:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 835409 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c8f:0:b0:37d:45d0:187 with SMTP id z15csp161255wrs; Tue, 15 Oct 2024 03:39:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUm81tWjdqt4tkXY4NlFB83INYuD/P1OmQFgOhGoHh7Gz1cO2fN05UqR+2WF+9Yz5Kf8ux4Zg==@linaro.org X-Google-Smtp-Source: AGHT+IH9lBvYlnXAyfAev5w8lC9G/rbOehf9TrSXKwIhFcSkGlKiRErJ5tfjMDyS1p/MvahXP6QF X-Received: by 2002:a05:6214:5692:b0:6cb:f87f:f2da with SMTP id 6a1803df08f44-6cbf87ff31dmr192670896d6.26.1728988783699; Tue, 15 Oct 2024 03:39:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728988783; cv=none; d=google.com; s=arc-20240605; b=JlfBmGHlZEi83AO9BpTg66WrBlk25oUyPrtbXaHIkrF0aAAi1fPesr4g49aXWWZz5A 6IKxGYSnrmFBYFBsI84PpIEVsdgWbTRJmFXMDvVOkOycXkBrSt8rjDwH47B/pUjJhqmf i8oPLXCuqR7msMUfDEhyY90OjbnSgrMzboPDPG7hqzmTrw29if9ar5K2gjCx1xvwbkHr aEbBA5xlhaeYRlvyWX9xBybXWGwfg0HzoFX+WJdxqoKQ/gMpQtBrLl4fX3T299kOcMe4 +1jwcf5ouM1TeUGUsxscu1MbM1p/M4iGY66ZRgjNTcSrCsZtdsmOWUwla/jUSkBeDR4I o+ag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=uQyiSr+GMXfCOC8blY2Vz0JFIbQgxcDhxoPn/qE/+zs=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=DDOBluJehPwFfriFqJJb9nt4kOxK3BfSlmCgOFUsR/zaboHDsD/Xydh/WPjENk08NJ G+qxfFgiZvF0vTcAzxJnSdJkZK2Xcd2LWEUhEe6eGbL3OD6gSe7hQqGMH5CxSvX/8rdW yRwbFTgp7FpCxz5AgbeL3QI5bHfByCLRYH6zIBEz6VZmm0Prw7YPvwoj12dqNdmkAcRm wtxMXGEhsH7aRWCjFPoPhtKiLEERipYz1PORzHDrhELFNSe4WE+0gIgOdKBYHaoL5JFL lhkgo7Z0k/P/yljUuffQHABaLTs4+W2EIuyAIBgDRjKHSaep0SK7X684Kfh7RgHkp+rR DP8A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u6zOSnTk; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6cc229cc6e7si11146486d6.94.2024.10.15.03.39.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 Oct 2024 03:39:43 -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=u6zOSnTk; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t0ewY-0006gR-OM; Tue, 15 Oct 2024 06:38:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t0ewV-0006do-H5 for qemu-devel@nongnu.org; Tue, 15 Oct 2024 06:38:19 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t0ewS-0005wS-Py for qemu-devel@nongnu.org; Tue, 15 Oct 2024 06:38:19 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-43117ed8adbso58238175e9.2 for ; Tue, 15 Oct 2024 03:38:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728988695; x=1729593495; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=uQyiSr+GMXfCOC8blY2Vz0JFIbQgxcDhxoPn/qE/+zs=; b=u6zOSnTkK5Y83j9DSpDTWHd9Fy+RuO1HiUHXaIock7ueZs1sUNkV8LL9EgHMANyu+K ZpaX9rm5PkBOqV3sFiFua6NKI6hW2O7nk2DFUo6nJrTUmAV/yXQIL//pKWOVs2AMb/t+ M84hG01u7Nly5KDFGcJASGWCAFHkV7bFZ+7cKyDmgLpDbx0hlIIlnRpFKs3fFts5SqRA skYQKDHR02qtQBhjhHI0lhkkkdf5Js0Xr7d5ZBZAeLwapFidKWVbblT/kKP6qP2OkQp1 Lu1Heotr0KifUDX9D9RADytk3jkGoxyt7aZDu7Nx7q7W2nFA0M0QHuQP5ENpkUDckKs+ 94kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728988695; x=1729593495; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uQyiSr+GMXfCOC8blY2Vz0JFIbQgxcDhxoPn/qE/+zs=; b=cf6ZiyXP1JcmNthSsfNrLqnk8ivu09bqgR0W+scB6jMhv2VChdGjhfE484Rd5ivopy cw1pdFXQ0qnsQkHzQ1QyT29VIR50Nhbm1BDVcGjEusY/wMt2r1uPYNkAcsd1XhtKUQKe 94f2UKDuTGPFxoI8DH36RIPMuaWq2ST9KXMiIV7BGEC+e976cmniHLV8nw93QbEMqTju yDpACL7gIfPIDWCi398PuBmpx2FfMiqggL2lhVtr5T3WkiVyaIubrM68D0kjrnsls6T6 Ln7Jp07GfevWRCdwYDBSRXlmUNZFrlVp3aHs+Ns5vzkl5fscZv8fiJ4v4M9FpEQw3dHM Nrrw== X-Gm-Message-State: AOJu0YyN3bm/Usrni+B3c+jPsnNQUHQ0XclMSCMcNRlGc4vG33+KPxjI rJlQUu+LHzvK7fxbAH5tSZz0pN98AkebqZ8yGjHwP3bWfg0lqzM3AeKKlUO7RbDr0mxgMx1y5eW U X-Received: by 2002:a05:6000:11ce:b0:37d:3e6d:6a00 with SMTP id ffacd0b85a97d-37d600d329cmr10271665f8f.47.1728988693548; Tue, 15 Oct 2024 03:38:13 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d7fa7a06dsm1241635f8f.5.2024.10.15.03.38.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2024 03:38:13 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 08/28] hw/clock: Expose 'qtest-clock-period' QOM property for QTests Date: Tue, 15 Oct 2024 11:37:48 +0100 Message-Id: <20241015103808.133024-9-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241015103808.133024-1-peter.maydell@linaro.org> References: <20241015103808.133024-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.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.29 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-bounces+patch=linaro.org@nongnu.org From: Inès Varhol Expose the clock period via the QOM 'qtest-clock-period' property so it can be used in QTests. This property is only accessible in QTests (not via HMP). Signed-off-by: Inès Varhol Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Luc Michel Reviewed-by: Peter Maydell Message-id: 20241003081105.40836-3-ines.varhol@telecom-paris.fr Signed-off-by: Peter Maydell --- docs/devel/clocks.rst | 6 ++++++ hw/core/clock.c | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/docs/devel/clocks.rst b/docs/devel/clocks.rst index 177ee1c90d7..3f744f2be1e 100644 --- a/docs/devel/clocks.rst +++ b/docs/devel/clocks.rst @@ -358,6 +358,12 @@ humans (for instance in debugging), use ``clock_display_freq()``, which returns a prettified string-representation, e.g. "33.3 MHz". The caller must free the string with g_free() after use. +It's also possible to retrieve the clock period from a QTest by +accessing QOM property ``qtest-clock-period`` using a QMP command. +This property is only present when the device is being run under +the ``qtest`` accelerator; it is not available when QEMU is +being run normally. + Calculating expiry deadlines ---------------------------- diff --git a/hw/core/clock.c b/hw/core/clock.c index e212865307b..cbe7b1bc469 100644 --- a/hw/core/clock.c +++ b/hw/core/clock.c @@ -13,6 +13,8 @@ #include "qemu/osdep.h" #include "qemu/cutils.h" +#include "qapi/visitor.h" +#include "sysemu/qtest.h" #include "hw/clock.h" #include "trace.h" @@ -158,6 +160,15 @@ bool clock_set_mul_div(Clock *clk, uint32_t multiplier, uint32_t divider) return true; } +static void clock_period_prop_get(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + Clock *clk = CLOCK(obj); + uint64_t period = clock_get(clk); + visit_type_uint64(v, name, &period, errp); +} + + static void clock_initfn(Object *obj) { Clock *clk = CLOCK(obj); @@ -166,6 +177,11 @@ static void clock_initfn(Object *obj) clk->divider = 1; QLIST_INIT(&clk->children); + + if (qtest_enabled()) { + object_property_add(obj, "qtest-clock-period", "uint64", + clock_period_prop_get, NULL, NULL, NULL); + } } static void clock_finalizefn(Object *obj)