From nobody Thu Nov 14 06:54:42 2024 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=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1708463520; cv=none; d=zohomail.com; s=zohoarc; b=oGVJ3H3mEmEQjbqM8vQe4ImMrZBRC9JHydh2gL5/rgHUOAbOAfDKXVFStWzU0EeVCrF7DYgBbw146dArc2Scwn5gnF4ZP0DDbQaFhpR8QlmCrokteRYJdn5hWpcL9vZTG3htOO2Xg0BsTXTdTv4ZQ2M7wKyGajGjMPOTquy923I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708463520; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8wwc0g2kzl5Lc5KX2u5/DCKV1h4w5LnDzJMObYTiZgU=; b=CoPWuk9uXV51BV0bzE0EW6IqmvYiiz4/w0MWjUcW0u8MYqap0dp3PZUkwgIxGPdwcczy7D+MKBrJ3a/0eCxYQzmckyQj2N5A6lb/GuOPzrc7irNSH0GnJbQjiO4As6HsCWacRBxU3n6kR3GEfnFbY6WUveHYS2n6SGLDh1BA1S8= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708463520039488.312201417143; Tue, 20 Feb 2024 13:12:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcXOo-0003xj-BA; Tue, 20 Feb 2024 16:11:34 -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 <3fxXVZQcKCjQaecbeTYWeeWbU.SecgUck-TUlUbdedWdk.ehW@flex--komlodi.bounces.google.com>) id 1rcXOl-0003vD-97 for qemu-devel@nongnu.org; Tue, 20 Feb 2024 16:11:31 -0500 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3fxXVZQcKCjQaecbeTYWeeWbU.SecgUck-TUlUbdedWdk.ehW@flex--komlodi.bounces.google.com>) id 1rcXOj-0008QC-SR for qemu-devel@nongnu.org; Tue, 20 Feb 2024 16:11:31 -0500 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-60802b0afd2so39888157b3.1 for ; Tue, 20 Feb 2024 13:11:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708463487; x=1709068287; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=8wwc0g2kzl5Lc5KX2u5/DCKV1h4w5LnDzJMObYTiZgU=; b=Jmb5/g7bPuBJti77TiXaU/u/zffv7uQiobBGTGqdXV9q86cZP6TXnGC2CtncOupWRo aDL3Tdyqy7vOimIjBs2dBidHelDzqeoSlwtvfgV4JgFBJ46envgRIpy9Uuvg9aXF89p9 GFnpJgjKb7G41AtZKbynLex9zhT/nZXTm/HM5edMnDyQmdRf77kpc0JnglWl9PSOh5Pg ycCCKLjVGGyJeIsuySMETdgnAHizdHgOMjVTcW3S+gBahNrHhTQrOYgz0YrJLBu/BHxT H9kKWHHlQaLms2MufZYpIg9EIowqaYD/BMg+bcknh8anN2XrHOpbTYE7h9/FcLPhA5D/ PELw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708463487; x=1709068287; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8wwc0g2kzl5Lc5KX2u5/DCKV1h4w5LnDzJMObYTiZgU=; b=rV3cC2q+qQlZI2AmHJ13YkniC5ewlZEDJqIYeU8Prytgux72NhpVtDLAfqRK81FWoz YWfcN4hxVkDOLsIW//SSWIreYzDKuwcOT3vmCl3STp9SAHHdMuItrHUuoDaAWZODgJqK LUTU7ta2vVYeX7B1hW5ziHh/trtHCVLvDIBExfOqpq5XtWIssIEAHQNxT5FJKyW5JFDf 1Pz+l1d+TkaNZlEbY7VCXEagjzHO1rRrMwn7BmQUqgTwtNlUj3fZbpbHodoCRN3oY0X4 QAKvhzJjSnUdH/c37P1kw0PmD8q3AqLUKCED2AO3fcbayEnTJErQlsyDfZA7Rsyk4fbv 3hbg== X-Gm-Message-State: AOJu0YwJanO8rY9QCeY8anRTe8uH7d026c0mZI8rjXxUQab3YNKgiW4m 8D1Y1wYL0VQ8bxrIM0f3k0pTCET9hK6wcyJA+tZawQH8aaZRXxaGU25bD/BsP4Up26K4Jxyi1ou 8gfwPLzwXBwOfXxxPOGsvZZR48IHbVY+J9KWR8v4o3sqjvhZHGHXpQZA3/Wa3FCsGRd0Bbw02eW /f8CBztolehWg8KKFJweZjEORYpEIiaN4caTLc X-Google-Smtp-Source: AGHT+IFzTnHujQ/EqNFe9ptLqdFqdJxZhWd0kXmpcI+CaGfZ675rAdINE4TdmESUz/twsLY3yGaX7vQoauvF X-Received: from komlodi.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:35ee]) (user=komlodi job=sendgmr) by 2002:a05:690c:2f86:b0:608:6b9:bf09 with SMTP id ew6-20020a05690c2f8600b0060806b9bf09mr2037416ywb.1.1708463487655; Tue, 20 Feb 2024 13:11:27 -0800 (PST) Date: Tue, 20 Feb 2024 21:11:21 +0000 In-Reply-To: <20240220211123.2664977-1-komlodi@google.com> Mime-Version: 1.0 References: <20240220211123.2664977-1-komlodi@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240220211123.2664977-2-komlodi@google.com> Subject: [PATCH v4 1/3] hw/i2c: core: Add reset From: Joe Komlodi To: qemu-devel@nongnu.org Cc: komlodi@google.com, venture@google.com, minyard@acm.org, peter.maydell@linaro.org 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=2607:f8b0:4864:20::114a; envelope-from=3fxXVZQcKCjQaecbeTYWeeWbU.SecgUck-TUlUbdedWdk.ehW@flex--komlodi.bounces.google.com; helo=mail-yw1-x114a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1708463521403100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It's possible for a reset to come in the middle of a transaction, which causes the bus to be in an old state when a new transaction comes in. Signed-off-by: Joe Komlodi --- hw/i2c/core.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hw/i2c/core.c b/hw/i2c/core.c index 4cf30b2c86..3128067bba 100644 --- a/hw/i2c/core.c +++ b/hw/i2c/core.c @@ -23,10 +23,29 @@ static Property i2c_props[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +static void i2c_bus_hold_reset(Object *obj) +{ + I2CBus *bus =3D I2C_BUS(obj); + I2CNode *node, *next; + + bus->broadcast =3D false; + QLIST_FOREACH_SAFE(node, &bus->current_devs, next, next) { + QLIST_REMOVE(node, next); + g_free(node); + } +} + +static void i2c_bus_class_init(ObjectClass *klass, void *data) +{ + ResettableClass *rc =3D RESETTABLE_CLASS(klass); + rc->phases.hold =3D i2c_bus_hold_reset; +} + static const TypeInfo i2c_bus_info =3D { .name =3D TYPE_I2C_BUS, .parent =3D TYPE_BUS, .instance_size =3D sizeof(I2CBus), + .class_init =3D i2c_bus_class_init, }; =20 static int i2c_bus_pre_save(void *opaque) --=20 2.44.0.rc0.258.g7320e95886-goog From nobody Thu Nov 14 06:54:42 2024 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=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1708463545; cv=none; d=zohomail.com; s=zohoarc; b=d3/5hNho8FNBhLzomp9NYKXRZ7v+kQdWNDZEOLC0CYW9sas0/FZ4bCpGWc0rr9vNvAyeK5X95N/OIj9t4qw+v9tfjBbN3oVf8GfP4KE/eWBFi4KduyWK2MV9I+rnoH4+wuNv1SSy0zd2Pwsw1cGOwM2qxDbJarNegBNZ4wbijmU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708463545; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ROn/UHUR1Rw30ZBr5JAvf733dMegwZEnijudzImnin8=; b=Atzhfr0wqvfJmjuiKU9Fdt9HyMi+MHmQxQiOOrDSyE3PgT7CpBoUW4ClM4WBF/4BN5zvAtgHr/1b5R+t/AhmHuDxAq5G6ebnAdxOIaP0ltbTl/U+LTz+LqGL+kQXuDPh7wJKSkyn9yTOfDlG+55I0TaFxzcscPRoRjZgFoQU5aw= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708463545726144.3395197756863; Tue, 20 Feb 2024 13:12:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcXOt-00042Z-Bx; Tue, 20 Feb 2024 16:11:39 -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 <3gRXVZQcKCjYcgedgVaYggYdW.UgeiWem-VWnWdfgfYfm.gjY@flex--komlodi.bounces.google.com>) id 1rcXOo-0003yn-Hl for qemu-devel@nongnu.org; Tue, 20 Feb 2024 16:11:34 -0500 Received: from mail-pg1-x54a.google.com ([2607:f8b0:4864:20::54a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3gRXVZQcKCjYcgedgVaYggYdW.UgeiWem-VWnWdfgfYfm.gjY@flex--komlodi.bounces.google.com>) id 1rcXOm-0008QK-6x for qemu-devel@nongnu.org; Tue, 20 Feb 2024 16:11:33 -0500 Received: by mail-pg1-x54a.google.com with SMTP id 41be03b00d2f7-5c65e666609so5160396a12.1 for ; Tue, 20 Feb 2024 13:11:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708463490; x=1709068290; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ROn/UHUR1Rw30ZBr5JAvf733dMegwZEnijudzImnin8=; b=UT75fZh268oTh2TK9ni7H6Zi725x+0dllBnlJP+KwL1tyjdlosXyy1bSsVdayCeli4 uLs++MjtKkPGUHX9JlwTV0G6WwbZrVdSmK5OY9K6iTgKUQKMVI2jtPEPHY+saJW51pR5 5YcOY/7aqI2usja8ZZQGLhNmY3tNgKZ6QSxSZFnMB15AMC/fj7vfI4vSZmLYOxDgATa5 XqTxlPURCpDubASTg0AcSjVnrHqBgv4lBSTAT3CzjueQmXT7QK/pT3NW05m8P/c0a2GB XRnUWesXR6LPOnCoR+7Py3OV2saSzkjeXVZFqQRRgBVjjQfENHx76uT3qJk/fE3mAY1g 0GUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708463490; x=1709068290; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ROn/UHUR1Rw30ZBr5JAvf733dMegwZEnijudzImnin8=; b=AopQsC7oIco+PF6vTsXSmKl8tj3N1WWfy4ItzOag/EEnf9Glfg4wajkOxaQNj7/zlb C4iRI2zUd3kGrqEcnZY00jS8ALY64+D0gmEcPq9+A/kYMHiXwQKhZLy6K6QVFab4e3aF 0/ob7ELmOygFBIi5bW1U0PMk0Mmb0fTo1Putd+y+dI4UocUop0i+ZcvVTe8tcYPyNPCQ o6Kd/v+ZBqQE1u0wzgdzmEsHqlwlo4vHEzA6pCeSWPHHFnBGFseMR4No1U16I2t7DDw2 IwvWJUnLqwbiPOVKxEsXgOudtKC8LmgccPyiBzRIo90MVdmAxo92YEyOXaexfK+/zUX4 uuxw== X-Gm-Message-State: AOJu0YwCPfFZWPxt4t45jHIkuUeUEHBtKRTDIw3ogaBRzItHFknxBxuT Rsq/PRHjHF9UHG88Fsf01B6WLQiB0xCY68v1R7FiP7/O5ytXhuMZwavJoi9jadmPwnIag/ltGgB tplBTC5Z6vCHvbG46zGBPFoy2R09nUc0COKhuKvXHNoZTpgfGMOe7pU15zRGcCeQMnpl15l5Gms +acYPW6Ai974Q+zuKw9USU7Kos53EyhuIHNQbL X-Google-Smtp-Source: AGHT+IEFk6pV6okFHuuA92zIWwRoT+SWAbczcX0elUKXoKhQDnfca1efDFCFve4ZKDc6sWPXowtAdpiTmkC5 X-Received: from komlodi.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:35ee]) (user=komlodi job=sendgmr) by 2002:a65:6943:0:b0:5d6:cfc:2f39 with SMTP id w3-20020a656943000000b005d60cfc2f39mr92357pgq.11.1708463489505; Tue, 20 Feb 2024 13:11:29 -0800 (PST) Date: Tue, 20 Feb 2024 21:11:22 +0000 In-Reply-To: <20240220211123.2664977-1-komlodi@google.com> Mime-Version: 1.0 References: <20240220211123.2664977-1-komlodi@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240220211123.2664977-3-komlodi@google.com> Subject: [PATCH v4 2/3] hw/i2c/smbus_slave: Add object path on error prints From: Joe Komlodi To: qemu-devel@nongnu.org Cc: komlodi@google.com, venture@google.com, minyard@acm.org, peter.maydell@linaro.org 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=2607:f8b0:4864:20::54a; envelope-from=3gRXVZQcKCjYcgedgVaYggYdW.UgeiWem-VWnWdfgfYfm.gjY@flex--komlodi.bounces.google.com; helo=mail-pg1-x54a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1708463547572100005 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The current logging doesn't tell us which specific smbus device is an error state. Signed-off-by: Joe Komlodi Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/i2c/smbus_slave.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/i2c/smbus_slave.c b/hw/i2c/smbus_slave.c index 1300c9ec72..9f9afc25a4 100644 --- a/hw/i2c/smbus_slave.c +++ b/hw/i2c/smbus_slave.c @@ -25,11 +25,15 @@ #define DPRINTF(fmt, ...) \ do { printf("smbus(%02x): " fmt , dev->i2c.address, ## __VA_ARGS__); } whi= le (0) #define BADF(fmt, ...) \ -do { fprintf(stderr, "smbus: error: " fmt , ## __VA_ARGS__); exit(1);} whi= le (0) +do { g_autofree char *qom_path =3D object_get_canonical_path(OBJECT(dev));= \ + fprintf(stderr, "%s: smbus: error: " fmt , qom_path, ## __VA_ARGS__); \ + exit(1); } while (0) #else #define DPRINTF(fmt, ...) do {} while(0) #define BADF(fmt, ...) \ -do { fprintf(stderr, "smbus: error: " fmt , ## __VA_ARGS__);} while (0) +do { g_autofree char *qom_path =3D object_get_canonical_path(OBJECT(dev));= \ + fprintf(stderr, "%s: smbus: error: " fmt , qom_path, ## __VA_ARGS__); \ + } while (0) #endif =20 enum { --=20 2.44.0.rc0.258.g7320e95886-goog From nobody Thu Nov 14 06:54:42 2024 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=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1708463546; cv=none; d=zohomail.com; s=zohoarc; b=Q/r5gYjuMmkU11TfFrdaL78UkVgqm9rgy6nCCGQNgTrIkQYna32pBqb11DX4M4xBxgqes+2rxFIVmbnpgx06FDLiMfeCrTner25qLQrUFvDwptT8ap36OglGsBS1jqt4VM5b6UP9duFzengFvyglQHWQ1+HTcJg1Kh+dtRSOH1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708463546; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qGn7OqTFb3X8RvO5w9/pHkj8ntGZYMZY8QEa64iaYvY=; b=TWu/2Mwnfe7YoMRHCWPOGIixUg0N/8jHSgYz65j9t6WxCPrspQivUfHaV++LikeXuAjWskSgj4hRGCOPsXSpDDoY8YzFHiErS7XrPOZP546Zix+uc4PPEISjvIJt0FeTh3hinW+3zmik2dKoeAuo+QTPcjputfhd6sOJ24W2qAY= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708463546014104.58345264969887; Tue, 20 Feb 2024 13:12:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcXOt-00042o-Cf; Tue, 20 Feb 2024 16:11:39 -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 <3gxXVZQcKCjgeigfiXcaiiafY.WigkYgo-XYpYfhihaho.ila@flex--komlodi.bounces.google.com>) id 1rcXOp-00041C-Id for qemu-devel@nongnu.org; Tue, 20 Feb 2024 16:11:35 -0500 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3gxXVZQcKCjgeigfiXcaiiafY.WigkYgo-XYpYfhihaho.ila@flex--komlodi.bounces.google.com>) id 1rcXOo-0008QZ-2P for qemu-devel@nongnu.org; Tue, 20 Feb 2024 16:11:35 -0500 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-dcc58cddb50so9386955276.0 for ; Tue, 20 Feb 2024 13:11:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708463491; x=1709068291; darn=nongnu.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=qGn7OqTFb3X8RvO5w9/pHkj8ntGZYMZY8QEa64iaYvY=; b=AWv7nEmM0HmAP+85mRzHwilLNrG8+bxiR1sMjXbqQb/xDLm1VArtbQCy1nJCiwqLC5 tZC2tE9rZkWi40tlpuKtg0vqCydVcQcfH6OZLJ3D34kjJu1EhTm3A4QbeIhptL3vxOdh Bd+FRyNG3WyNjxevC8+rqBgElSPjEg5XSqeUTyJjOsz43Ay/Kx+huo+HKFXVgh3Fu72o /qu71y6D+lX283qt9dbCPS/pyEoiYVaK9nV0ZqmHTZALKtZCsGfWkpxhLFn5fjxjNC8f j63b7UvD1/k7SN0RxCaOM6y7PA5GWp925O8pzziIwtNjNSBkPQNH8nVNzv2MAZMoGeix mlRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708463491; x=1709068291; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qGn7OqTFb3X8RvO5w9/pHkj8ntGZYMZY8QEa64iaYvY=; b=kaNbe31KFE4bNv2qjFLePJX2liYLWix4OL4C615qPRA7I0WmapUWpkH2iWSedfYaFj 7lWw39HMmJ0dFblKB0XUGpzvniLC719C+lpJ5Nu/k0lj3+iw94Ukpv7mRNQoQFfi1k1C RkdCNDIZ/dYqlUEh+NyCnAxf89+A5kkvx/eYeFOyQJYHay718jvvk408+NCdAN4DKcRr aaniU6ebPccv5ZnuxWFXrzs4AIDcDOf6ZgeNc+kBDq/SLRKcf4853Mh4vzVmKSm0MSkt 5SvFX4MSbZap0eQiGopOzWcJO8kZZmQocH5OVv+2pKVW/WmHOl1pvLc4IFTZcWccFY2V DZYg== X-Gm-Message-State: AOJu0Yz9fqoDPwpPwz04bzw9T1tfVyRwTTyx4dgxSJO0iInhJQXpN9Kb 1d8EDtCzVPUx7HBWJWW+zVuLirr6RAxK4o42vFDL1PYcJUXqQyUo7F2uGj4ag8bugL14/J4QPgp /0rrltsJxA3TYpqd4xJ5ytGyydmPUSs4Xc5Od/xch1w+WacDh9XmryfeDdMegkkFj7xG0LfVLFY f4kTL3zkER8eSbjcJuiJlysjIzY6zNTCNn0p1q X-Google-Smtp-Source: AGHT+IENlQ7IaH94cyy5alIC5kqgCw4BXz8ldkulhyGDmFEnJsN0qfgUPqPtk5Pe1zArZKnL9jkMCE4K//+N X-Received: from komlodi.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:35ee]) (user=komlodi job=sendgmr) by 2002:a05:6902:1209:b0:dc6:e1ed:bd1a with SMTP id s9-20020a056902120900b00dc6e1edbd1amr4375448ybu.2.1708463491539; Tue, 20 Feb 2024 13:11:31 -0800 (PST) Date: Tue, 20 Feb 2024 21:11:23 +0000 In-Reply-To: <20240220211123.2664977-1-komlodi@google.com> Mime-Version: 1.0 References: <20240220211123.2664977-1-komlodi@google.com> X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240220211123.2664977-4-komlodi@google.com> Subject: [PATCH v4 3/3] hw/i2c: smbus_slave: Reset state on reset From: Joe Komlodi To: qemu-devel@nongnu.org Cc: komlodi@google.com, venture@google.com, minyard@acm.org, peter.maydell@linaro.org 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=2607:f8b0:4864:20::b4a; envelope-from=3gxXVZQcKCjgeigfiXcaiiafY.WigkYgo-XYpYfhihaho.ila@flex--komlodi.bounces.google.com; helo=mail-yb1-xb4a.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, 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, T_SCC_BODY_TEXT_LINE=-0.01, USER_IN_DEF_DKIM_WL=-7.5 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1708463547572100006 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If a reset comes while the SMBus device is not in its idle state, it's possible for it to get confused on valid transactions post-reset. Signed-off-by: Joe Komlodi Reviewed-by: Peter Maydell --- hw/i2c/smbus_slave.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/i2c/smbus_slave.c b/hw/i2c/smbus_slave.c index 9f9afc25a4..4615e8b097 100644 --- a/hw/i2c/smbus_slave.c +++ b/hw/i2c/smbus_slave.c @@ -201,10 +201,19 @@ static int smbus_i2c_send(I2CSlave *s, uint8_t data) return 0; } =20 +static void smbus_device_hold_reset(Object *obj) +{ + SMBusDevice *dev =3D SMBUS_DEVICE(obj); + dev->mode =3D SMBUS_IDLE; + dev->data_len =3D 0; +} + static void smbus_device_class_init(ObjectClass *klass, void *data) { I2CSlaveClass *sc =3D I2C_SLAVE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); =20 + rc->phases.hold =3D smbus_device_hold_reset; sc->event =3D smbus_i2c_event; sc->recv =3D smbus_i2c_recv; sc->send =3D smbus_i2c_send; --=20 2.44.0.rc0.258.g7320e95886-goog