From patchwork Wed Jan 11 08:50:15 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: 641252 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp3140635pvb; Wed, 11 Jan 2023 00:55:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXvwlZ1z+WNkLX4gTAGzq2WSNFZMHFyG6HrcsjDxt4UGNpba2Ruw4SaC9ue0+npg4Wc3+FFp X-Received: by 2002:a05:6214:5616:b0:531:ab19:4193 with SMTP id mg22-20020a056214561600b00531ab194193mr59182788qvb.2.1673427318189; Wed, 11 Jan 2023 00:55:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673427318; cv=none; d=google.com; s=arc-20160816; b=VdIGzi+7Ntmm+IMrwBWExLm0q1A2EOYFonAZz1IPKr3Tk4fal1UKXHZ5wamNYtZ32Y WJI7KK25LcWcmBTCld1fRWhODMYd6VIm1da/TMYd2KESV34Cz7IyEe+z3uYr5NNmHKAt hwQBTEsy3+xlAK9TRpQahFcZALh0/G1B88B0BP8hthDvYHo+Rjvl059wzBDyvxY9UMOn KUNoizf9saa1u2GPKusugJ7EmOlf7FLUyNQ96EsT9QMR3BZocbfoEb4i56MbZl11lA25 hP/IoDY3Z6S39sK+qEyobdEvnFPDP3DnCBvpLeR1N0c14cnb75s396HJyBp7BKizmnvw cViA== 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=F1k/7mPGH5gDcWWku0OjBNNAk942aGuA5NQSFVWJSqE=; b=EqzJb/xsKuO2IJl4HXSRFWji266f6LmVv/+VRM8ClC54atBWecv33qEUXdwxBufRLh Q0rupy9xJFEOc+r6Lbtn1kuzu3oM+Xu3uG5pgVIZt1TYaJWJAJdU6WoMsPDScPxP8OKi 8WUWkiRjZekt/vEbyRzmm+nCCPKJRqSNwvCl09bLkpWDYrPzExnfhG60ms+AqLIG6+yq cbI7XeaqmqxqjeZjdkmaZvL021UDcZLNx5D9hCAE+q91kjCL+LGscoujy70OxpILX0Nc X1HHvJAyjA2iU7Fwb2ARJbfTWG/DskJbMZVErTWAjbac/cfEnpMYjp0Kf0RaoVYCXEKn W80A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YdQP44Uz; 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 iu5-20020ad45cc5000000b004c750d8def9si8016105qvb.240.2023.01.11.00.55.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Jan 2023 00:55:18 -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=YdQP44Uz; 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 1pFWot-0003Rt-4j; Wed, 11 Jan 2023 03:50:51 -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 1pFWoj-0003Jt-NC for qemu-devel@nongnu.org; Wed, 11 Jan 2023 03:50:42 -0500 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFWoh-0007hK-Kt for qemu-devel@nongnu.org; Wed, 11 Jan 2023 03:50:41 -0500 Received: by mail-wr1-x42e.google.com with SMTP id d17so14307800wrs.2 for ; Wed, 11 Jan 2023 00:50:39 -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=F1k/7mPGH5gDcWWku0OjBNNAk942aGuA5NQSFVWJSqE=; b=YdQP44UzORDUM2gwiED1ZAncZYIEgNPk70Z3okWesFAwhaGWfhuhu6JLrgH40cEJtF TTpCt2psGRmAcEKuYxWBi3EjnyH0zeyDXAtc1wfDFYIwUr/Sc08EVNfeS5pYFF/86aCm 0LcYjO11dWnRTvtqy+jX5yd3a8YKoLpnOn67MkbtcDjix9WTJLdrcvxpT3I66SlMo9Dm uQjc4WCRLuhxjVvTmQDGprBglJYCqQOVZJ+hKrnM2KxqxLyeFjJzJ3VS/JdE55ZjnAZl rd/dTscwK1UsoJU3wbYzAOr1OqVCFqhpBkXJ+FFvE/+RsOEqMOJxdSWhfsauAaWxbHLz FaiA== 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=F1k/7mPGH5gDcWWku0OjBNNAk942aGuA5NQSFVWJSqE=; b=G8islpwpYhiqsiigudBM/qRCi0c15EZh86kDlmf53NK8wC1/E6iEmEiVEA16n6qdNH ijIvFMI3tpYXcKNHQ9MQ2UdOZ6VxA5MeP4TifKbG6YXmd7JsT4upWbpPrrazrvQloc93 HUjMboaCxr1bDa6nWA8Pad4edpOFCtdU+AfVMLjbWmVwzFu0+FGWTDHsvb7xakItG9/Z yUDCUUF+hC24OyUQ6B+kE7NWr7pdHeSXzhQBQyqZtmEZ1waxtj9uuaf9M+yIQdWFNWRE AbbYRKkgwkPegSOufZNceRYchnsSb0yQGdZr8xY0uy9L7IxNEs8IXhW6EuikDWXZ30Tm 0VNQ== X-Gm-Message-State: AFqh2koqwD259tI1xOE1tZyj89Dyj3smjkUaJlo4AFMN7ZCz4V9aDRYS Uilh2G013l6kDvbjTYMhj4frIsm2i7yrTpbE X-Received: by 2002:a5d:4587:0:b0:27f:a81:b819 with SMTP id p7-20020a5d4587000000b0027f0a81b819mr40538188wrq.22.1673427037903; Wed, 11 Jan 2023 00:50:37 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id m10-20020a056000008a00b002683695bf97sm13029515wrx.58.2023.01.11.00.50.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 11 Jan 2023 00:50:37 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , Thomas Huth , Jan Kiszka , qemu-trivial@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PATCH v3 4/5] hw/i2c/bitbang_i2c: Trace state changes Date: Wed, 11 Jan 2023 09:50:15 +0100 Message-Id: <20230111085016.44551-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230111085016.44551-1-philmd@linaro.org> References: <20230111085016.44551-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42e; envelope-from=philmd@linaro.org; helo=mail-wr1-x42e.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. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé --- hw/i2c/bitbang_i2c.c | 33 ++++++++++++++++++++++++++++----- hw/i2c/trace-events | 3 +++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/hw/i2c/bitbang_i2c.c b/hw/i2c/bitbang_i2c.c index bf4b781393..efc49b7502 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,41 @@ 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 * const 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_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 +100,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 +148,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 +172,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)"