From patchwork Mon Jan 9 08:41:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 640582 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2025659pvb; Mon, 9 Jan 2023 00:42:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXt/IQ8XeY8DRKZ6iUifSujjqyvS+ZEF/IM7VaOGXMYax/TkqRg2jNd/tK9RBCxcjsSM3aXI X-Received: by 2002:ac8:7386:0:b0:3a8:1896:e2fc with SMTP id t6-20020ac87386000000b003a81896e2fcmr90334291qtp.35.1673253749307; Mon, 09 Jan 2023 00:42:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673253749; cv=none; d=google.com; s=arc-20160816; b=AdxIwiJFS2i2buwiFicqELO40PJWp9sVG974j7TaEHbhMIks44TUH/0mz/Rodu8ZfN a1OkrZRSkOLL05784DNPSamWvzfaSP2SQYNreUdjebb/Fq9whqpdMBFgxZnButnH1W0p IdrRVhVWiWzWdjY/vihexOOJ3//ZfF8QAf4KRe3GAY7CYHFMGc8qZ9V2inqoyw9etLeM mwVB1CKkdIn+rfKd4ZJwIcdpODy/SfyI3UCFugVeqwScLf8jEkaFgRZPgzXz3cNp54Iz BncQwiWA73OS2D6qLFWFb2oakXKVyiNGEfevlwiMMbVc42ev0oYQ0/ZGZFdzSbrQQbRi teeQ== 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:cc:to :from:dkim-signature; bh=jJ6oumXx0s46lM7s2kykoKISxxsiXAQ5N5QK1WgQl4I=; b=0wyezJoCQEYUOcyMOa7ZojXH9+bCmDfONPYHeu3yNMjkuz1zmqV622rHWm+mDoR5Um NB4JD3weq74k146Sa1rQHlnO0uPfflKsUgr417gs/J0b7hpjzhyiPLNKIPzgABgMU216 8aJYOYfVBUKTQFJz9OG0tgOvIsdHbJJiTSN9G2vxKzmYF3faS7PfVjPdZfT4mXMr42Xn 6o1+5bFwgTInrt6HvxExzewUpwyYQZ66qPeU03XtNPUCFtL9a3tWXzoPZwjURMXN/ud7 lQfqDVs20qT/J4HBSvy4ympCcyP9e8BFdIgHqBIPmBrlXUcT2EqwCbEdoFx/M48VTrcw v4kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Yavy+ORR; 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 bc8-20020a05622a1cc800b003ab4b7617b5si4013191qtb.197.2023.01.09.00.42.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Jan 2023 00:42:29 -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=Yavy+ORR; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pEnj2-0005mh-Dg; Mon, 09 Jan 2023 03:41:48 -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 1pEnj0-0005lo-9C for qemu-devel@nongnu.org; Mon, 09 Jan 2023 03:41:46 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pEniy-0002Ie-5l for qemu-devel@nongnu.org; Mon, 09 Jan 2023 03:41:46 -0500 Received: by mail-wm1-x329.google.com with SMTP id i17-20020a05600c355100b003d99434b1cfso6004670wmq.1 for ; Mon, 09 Jan 2023 00:41:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=jJ6oumXx0s46lM7s2kykoKISxxsiXAQ5N5QK1WgQl4I=; b=Yavy+ORRYI+PCW0FoOAkryDjunEHMv4VbCloNwKNkbyRCzdm3JuXUcf5dL2TcZzORV FlN+ZBJdM1WsonoO+v2ie0zDvNXeEkFn0mD6spBnYchyENb4McReZMoJQaKJTlThEYTE 2ZcsUdVlKu1LtOjIfc7d5FJZbXdHbkr/mgOQ5cX4GUaek2SND/8i/QbbpmHDH9JiP2SY qLKI/E5rl10jbQPQCThC9IiMsj3LALX8dImKXdl/4ayPZbRjPTgyuULmtAgM3+EMKGw7 uiPrkQrTuk2Mzn85K+dH6IrSiPbfJomnuTPwt36OSEhmjtRaCyzmAUOmd1k9cBUpPZ52 SQfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=jJ6oumXx0s46lM7s2kykoKISxxsiXAQ5N5QK1WgQl4I=; b=xwU6dwKHwVQ5LcrKnXWAvy7PvQNATJ0Pj71bZCmPdjWmqEvJIUFjmRFLkJ9uvSsv8o /USc0S8lpCRd9VOdor2iZhKFUv5/aaZtjbaWUqxZK3kg6LPxOLyE9VuSwaaf2LWsodNk nC2pNE313XookQODQQRPIS/6sNvIWoDXM7bEgS8poj1+BIK4e0/CdNZtaDiBqJvCWcBP RINbIM9LDwR0J3w3I08n2Rp/TZpYBYm6SK9+IMN4WgEDMjQvhkgRsx/IXVK17co4V7i8 f1Uys094SKaM3xWeCIVe7DfMmutSSB/AhPbPiBzHknGR3ryGjiTYmpUw+Yc8fRGc0Xc6 nbXg== X-Gm-Message-State: AFqh2kqu8umuzvbvEkJohRHv+XRznMisfZankUS270zJ5zDVFM+bkez/ SbmIYKHLkmQmjzC8lTrcKcCQEgn9uNWXD0ni X-Received: by 2002:a05:600c:1c9d:b0:3d1:f3eb:c718 with SMTP id k29-20020a05600c1c9d00b003d1f3ebc718mr55762456wms.19.1673253702592; Mon, 09 Jan 2023 00:41:42 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id e18-20020a05600c4e5200b003d9876aa04asm12553969wmq.41.2023.01.09.00.41.41 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 09 Jan 2023 00:41:42 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Peter Maydell , Thomas Huth , qemu-arm@nongnu.org, qemu-trivial@nongnu.org, Jan Kiszka , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH 4/5] hw/i2c/bitbang_i2c: Trace state changes Date: Mon, 9 Jan 2023 09:41:20 +0100 Message-Id: <20230109084121.72138-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230109084121.72138-1-philmd@linaro.org> References: <20230109084121.72138-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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 Trace bitbang state machine changes with trace events. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- hw/i2c/bitbang_i2c.c | 34 +++++++++++++++++++++++++++++----- hw/i2c/trace-events | 3 +++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c index bf4b781393..9fa19cf8b1 100644 --- a/hw/i2c/bitbang_i2c.c +++ b/hw/i2c/bitbang_i2c.c @@ -16,6 +16,7 @@ #include "hw/sysbus.h" #include "qemu/module.h" #include "qom/object.h" +#include "trace.h" //#define DEBUG_BITBANG_I2C @@ -26,15 +27,42 @@ do { printf("bitbang_i2c: " fmt , ## __VA_ARGS__); } while (0) #define DPRINTF(fmt, ...) do {} while(0) #endif +/* bitbang_i2c_state enum to name */ +static const char *sname[] = { +#define NAME(e) [e] = stringify(e) + NAME(STOPPED), + [SENDING_BIT7] = "SENDING_BIT7 (START)", + NAME(SENDING_BIT6), + NAME(SENDING_BIT5), + NAME(SENDING_BIT4), + NAME(SENDING_BIT3), + NAME(SENDING_BIT2), + NAME(SENDING_BIT1), + NAME(SENDING_BIT0), + NAME(WAITING_FOR_ACK), + [RECEIVING_BIT7] = "RECEIVING_BIT7 (ACK)", + NAME(RECEIVING_BIT7), + NAME(RECEIVING_BIT6), + NAME(RECEIVING_BIT5), + NAME(RECEIVING_BIT4), + NAME(RECEIVING_BIT3), + NAME(RECEIVING_BIT2), + NAME(RECEIVING_BIT1), + NAME(RECEIVING_BIT0), + NAME(SENDING_ACK), + NAME(SENT_NACK) +#undef NAME +}; + static void bitbang_i2c_set_state(bitbang_i2c_interface *i2c, bitbang_i2c_state state) { + trace_bitbang_i2c_state(sname[i2c->state], sname[state]); i2c->state = state; } static void bitbang_i2c_enter_stop(bitbang_i2c_interface *i2c) { - DPRINTF("STOP\n"); if (i2c->current_addr >= 0) i2c_end_transfer(i2c->bus); i2c->current_addr = -1; @@ -73,7 +101,6 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) return bitbang_i2c_nop(i2c); } if (level == 0) { - DPRINTF("START\n"); /* START condition. */ bitbang_i2c_set_state(i2c, SENDING_BIT7); i2c->current_addr = -1; @@ -122,7 +149,6 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) /* NACK (either addressing a nonexistent device, or the * device we were sending to decided to NACK us). */ - DPRINTF("Got NACK\n"); bitbang_i2c_set_state(i2c, SENT_NACK); bitbang_i2c_enter_stop(i2c); return bitbang_i2c_ret(i2c, 1); @@ -147,11 +173,9 @@ int bitbang_i2c_set(bitbang_i2c_interface *i2c, int line, int level) case SENDING_ACK: if (data != 0) { - DPRINTF("NACKED\n"); bitbang_i2c_set_state(i2c, SENT_NACK); i2c_nack(i2c->bus); } else { - DPRINTF("ACKED\n"); bitbang_i2c_set_state(i2c, RECEIVING_BIT7); } return bitbang_i2c_ret(i2c, 1); diff --git a/hw/i2c/trace-events b/hw/i2c/trace-events index af181d43ee..2a479c1c12 100644 --- a/hw/i2c/trace-events +++ b/hw/i2c/trace-events @@ -1,5 +1,8 @@ # See docs/devel/tracing.rst for syntax documentation. +# bitbang_i2c.c +bitbang_i2c_state(const char *old_state, const char *new_state) "state %s -> %s" + # core.c i2c_event(const char *event, uint8_t address) "%s(addr:0x%02x)"