From patchwork Mon Dec 16 14:18:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gustavo Romero X-Patchwork-Id: 851231 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp2872804wry; Mon, 16 Dec 2024 06:20:20 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXtGqiiNNOlvVPXg1zV1WY/V4wZ8iNMLze8nLRqGctseUQ0grzm9soYtWlKrvxkuUvaswzEOg==@linaro.org X-Google-Smtp-Source: AGHT+IETwgMNI2BPS175blNpuqcu1b1C6ZmLIS8eXx/e3w0fCFtmOcwls7ckjNKKHgL7XVDnyu4B X-Received: by 2002:a05:6214:246f:b0:6d8:a7e1:e270 with SMTP id 6a1803df08f44-6dc96853996mr193451266d6.40.1734358820229; Mon, 16 Dec 2024 06:20:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734358820; cv=none; d=google.com; s=arc-20240605; b=aJUjzejcPlk+iqeCKYRNO6mxsncjymlbRQEOF0BCfljDHBgMxmV9rGG1sfLH783u9y Fmc7qHaEo0LdX6m8T7oNk9VCsAHvpGKl1176RhrjO861itgAZTFw5TARh4yTT1hnyDKG vUcZSpQ/wMrjSkT03/zo69qZa4yqDpWuTWWDpt1CvfFtA3W8qKIk6P1P7Lr0/edUjU5w MnkVdSeYqTisEfWjRxMGSgPC4sBbE21ed6Mhlo5QDilB6RS6H98X5l8GMCxuuiWj3DOj ifCQBDYTB0IhAdjkzf6T5yzrwqqZIRomlp3OH6LWQcG0bi23YxAkkFiB40xxONC8GnYg Jg0w== 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:cc:to :from:dkim-signature; bh=oTXeIKSE6vctrvuU18gwO4YmTcatQ3MxyH1mPVyZvCY=; fh=jfd24O/GUpQfDSGxn8P/HXLb4WlfrJJDNmj5ELhosqU=; b=REF2KFWjqatywXa6oXhewFzu2kmSpZrxsBHjREVzkkbj5SA7iWOM+IV2GM5LeoYnOS CihkYv1EwGQ0D2YsskEzLTQRv1QfgaoBMb1I5r8KpIFh8bVL+ix+N7KFoqgCWxT8RJtY sSXXLAF4TQGBUVmWJiSEtoft76stRoXz9PezUbf0LgNQ0P3WMkm1kifc1RpQhZpv/I6V QsWJ/tDjuwvWg59UmMfa1Ftotnba3hPVJRes/JNFUTbjDar/lYSkduw41yl7olMod/vx vEgxPOhlGs6wpNHYSK0XcNcprwH82XaxFNPQVfGTfUrarOf7t7xR+/9rprjSHJUmwX6O lINQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aIbnF1ZG; 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-6dccd3b78fbsi70218696d6.534.2024.12.16.06.20.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Dec 2024 06:20:20 -0800 (PST) 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=aIbnF1ZG; 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 1tNBwU-0004Qi-Jw; Mon, 16 Dec 2024 09:19:29 -0500 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 1tNBwH-0004EV-Ss for qemu-devel@nongnu.org; Mon, 16 Dec 2024 09:19:15 -0500 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tNBwE-0000EU-Uo for qemu-devel@nongnu.org; Mon, 16 Dec 2024 09:19:13 -0500 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-725d9f57d90so2995596b3a.1 for ; Mon, 16 Dec 2024 06:19:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734358749; x=1734963549; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oTXeIKSE6vctrvuU18gwO4YmTcatQ3MxyH1mPVyZvCY=; b=aIbnF1ZGtdSbxKgrlNAbFNHXL8KONWxKFNusK3QJFRAcJ8iXGNZCEeiadelr35YSTp bxpxyEK++kVCw10KUAIJiCAaf98Z96b3KYQmOEeoNnamifh+dbx/GX8i7ZeNEBjvMR1i BfIASi4f8zUW9IY3cgbyYtC5wXaopqH15m6OAr5CFuyE6DzEYToDLV6kQKaw6vGrwRJr fJmsHkUcNoFRGucWyUPkq75s609Gfr85L35tsEA3O847XAREb4DLmlHPdoYa3eGdpoOr q+EqLRgoLq2IW9aE/9oUJbGNJe3oUu9Z8qewQcnBj8KKL0qSAkEI7pLKuowylMQvGzQ2 myPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734358749; x=1734963549; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oTXeIKSE6vctrvuU18gwO4YmTcatQ3MxyH1mPVyZvCY=; b=u3dpu8X0LabPsdBTU42Q2NOPzxLYKIPx/avhsxRIY26L5TQiiDpmYRyp7EUrmE4lpQ FPC3MNKvazZyduF690md2DbudbMJT8/UMzRA9E/HSXVkHvm8WXmqFslyyYOs/pFgGN6s e5X57HHrr1H3LegCdHLyo8UZ4sDqjpT0SLoKHojH2goWqb+DH2JhNI5GDpJUEVKHsxQY UvZJVbavB8yVXz/M/UC4ci53PkiXIjkMgjryihqVOFnPAbD4nFwB2LZJQ7OkNrgfxcrn 1CT3M3elQco0fEX6mKkUWmqclCWByr1/k3+4NwgzWoCOTy4Yv6oJynpl2BfwtllShTsZ YltA== X-Gm-Message-State: AOJu0YwOjm3unr1rrSZMNyjXS/NpGIboz2vXjCE2C42kA+szQ+eWtQBw sDc8PNkICg9qf9msrhzDwmmBbHeo81vbwfnHKuk5R9k2UJhRzkT+b9/BjT5V4qxB7XwQeBOXZkX R X-Gm-Gg: ASbGncszBCk8DUK9iCeNnpnofw9M51ygKFbVLWDCi3jCX5Esh1ezx4QpZlVyCMC8ki0 Juz/GFEhRHpWwyo4pX2wyZG+KmGNQgrJ+kNAwpKM4296HU+yXlxTEpSZjQy5OIWuW6SwnO/YzrU odH/fMMcNbVSnjyTg33PfHnUqQHSJpE08Gh1g82dhWXpXzvswWYuz1yRlXthyAKHdQyb/P+jU19 fdAC0R5h0XrUjpY8qyc9DrKEnGVgnENCI6/bkQ5xd65lOzPbg/7JSGFE4s+55k= X-Received: by 2002:a05:6a20:6a11:b0:1e1:aef4:9ce8 with SMTP id adf61e73a8af0-1e1dfe6a00bmr20051541637.28.1734358749223; Mon, 16 Dec 2024 06:19:09 -0800 (PST) Received: from gromero0.. ([177.189.100.90]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72918bad8acsm4948815b3a.146.2024.12.16.06.19.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2024 06:19:08 -0800 (PST) From: Gustavo Romero To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, philmd@linaro.org, alex.bennee@linaro.org, thuth@redhat.com, armbru@redhat.com Cc: gustavo.romero@linaro.org Subject: [PATCH v3 6/7] tests/qtest: Add API functions to capture IRQ toggling Date: Mon, 16 Dec 2024 14:18:17 +0000 Message-Id: <20241216141818.111255-7-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241216141818.111255-1-gustavo.romero@linaro.org> References: <20241216141818.111255-1-gustavo.romero@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=gustavo.romero@linaro.org; helo=mail-pf1-x432.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=unavailable 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 Currently, the QTest API does not provide a function to capture when an IRQ line is raised or lowered, although the QTest Protocol already reports such IRQ transitions. As a consequence, it is also not possible to capture when an IRQ line is toggled. Functions like qtest_get_irq() only read the current state of the intercepted IRQ lines, which is already high (or low) when the function is called if the IRQ line is toggled. Therefore, these functions miss the IRQ line state transitions. This commit introduces two new API functions: qtest_get_irq_raised_counter() and qtest_get_irq_lowered_counter(). These functions allow capturing the number of times an observed IRQ line transitioned from low to high state or from high to low state, respectively. When used together, these new API functions then allow checking if one or more pulses were generated (indicating if the IRQ line was toggled). Signed-off-by: Gustavo Romero Reviewed-by: Philippe Mathieu-Daudé Acked-by: Thomas Huth --- tests/qtest/libqtest.c | 24 ++++++++++++++++++++++++ tests/qtest/libqtest.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 8de5f1fde3..dfe3139a88 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -83,6 +83,8 @@ struct QTestState int expected_status; bool big_endian; bool irq_level[MAX_IRQ]; + uint64_t irq_raised_counter[MAX_IRQ]; + uint64_t irq_lowered_counter[MAX_IRQ]; GString *rx; QTestTransportOps ops; GList *pending_events; @@ -515,6 +517,8 @@ static QTestState *qtest_init_internal(const char *qemu_bin, s->rx = g_string_new(""); for (i = 0; i < MAX_IRQ; i++) { s->irq_level[i] = false; + s->irq_raised_counter[i] = 0; + s->irq_lowered_counter[i] = 0; } /* @@ -706,8 +710,10 @@ redo: g_assert_cmpint(irq, <, MAX_IRQ); if (strcmp(words[1], "raise") == 0) { + s->irq_raised_counter[irq]++; s->irq_level[irq] = true; } else { + s->irq_lowered_counter[irq]++; s->irq_level[irq] = false; } @@ -999,6 +1005,22 @@ bool qtest_get_irq(QTestState *s, int num) return s->irq_level[num]; } +uint64_t qtest_get_irq_raised_counter(QTestState *s, int num) +{ + /* dummy operation in order to make sure irq is up to date */ + qtest_inb(s, 0); + + return s->irq_raised_counter[num]; +} + +uint64_t qtest_get_irq_lowered_counter(QTestState *s, int num) +{ + /* dummy operation in order to make sure irq is up to date */ + qtest_inb(s, 0); + + return s->irq_lowered_counter[num]; +} + void qtest_module_load(QTestState *s, const char *prefix, const char *libname) { qtest_sendf(s, "module_load %s %s\n", prefix, libname); @@ -1902,6 +1924,8 @@ QTestState *qtest_inproc_init(QTestState **s, bool log, const char* arch, qts->wstatus = 0; for (int i = 0; i < MAX_IRQ; i++) { qts->irq_level[i] = false; + qts->irq_raised_counter[i] = 0; + qts->irq_lowered_counter[i] = 0; } qtest_client_set_rx_handler(qts, qtest_client_inproc_recv_line); diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index f23d80e9e5..b73c04139e 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -389,6 +389,34 @@ void qtest_module_load(QTestState *s, const char *prefix, const char *libname); */ bool qtest_get_irq(QTestState *s, int num); +/** + * qtest_get_irq_raised_counter: + * @s: #QTestState instance to operate on. + * @num: Interrupt to observe. + * + * This function can be used in conjunction with the + * qtest_get_irq_lowered_counter() to check if one or more pulses where + * generated on the observed interrupt. + * + * Returns: The number of times IRQ @num was raised, i.e., transitioned from + * a low state (false) to a high state (true). + */ +uint64_t qtest_get_irq_raised_counter(QTestState *s, int num); + +/** + * qtest_get_irq_lowered_counter: + * @s: #QTestState instance to operate on. + * @num: Interrupt to observe. + * + * This function can be used in conjunction with the + * qtest_get_irq_raised_counter() to check if one or more pulses where + * generated on the observed interrupt. + * + * Returns: The number of times IRQ @num was lowered, i.e., transitioned from + * a high state (true) to a low state (false). + */ +uint64_t qtest_get_irq_lowered_counter(QTestState *s, int num); + /** * qtest_irq_intercept_in: * @s: #QTestState instance to operate on.