From nobody Tue Nov 26 12:36:17 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=1706906955; cv=none; d=zohomail.com; s=zohoarc; b=DMY0pOPprHA1WTmkxdldDQsVIkEmEC0qLDHNEum8vgQ80H3uyU+0Hi2qddasR5OcSzTkydgvxVkdB8/iRbOk+mX4ebta6Yb1nCW2MwsuiW7tEZ6tMBfKh5FHNeMXLk3mQFK3oPmxUaIjo23K56pnH8pOIds3Euk7zO39WDIJ9gs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706906955; 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=8WeuC7JvPagfraa2WTEH94EGGshXGZXY2HdGa0YFfR8=; b=EORCLxn9JKZu1FGvsxeTPjUBwjVGresczi+Ey81tM2iJu0nvykLGMNX4SMjkW1ss8e9BWqhM4ofvLgjMp98akxIH79H020GQnjorJyrVReAXZHVPAXsvqcGIv5C3wbrsxpJJIdH9YPtsEUIrd0J8k9OUFdW/MxGWvvzCGi/3p8E= 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 1706906955620294.3546046204965; Fri, 2 Feb 2024 12:49:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rW0T2-0000xV-9I; Fri, 02 Feb 2024 15:48:56 -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 <3M1W9ZQcKCggswutwlqowwotm.kwuymu2-lm3mtvwvov2.wzo@flex--komlodi.bounces.google.com>) id 1rW0T0-0000vH-LC for qemu-devel@nongnu.org; Fri, 02 Feb 2024 15:48:54 -0500 Received: from mail-pj1-x104a.google.com ([2607:f8b0:4864:20::104a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3M1W9ZQcKCggswutwlqowwotm.kwuymu2-lm3mtvwvov2.wzo@flex--komlodi.bounces.google.com>) id 1rW0Sz-000082-8k for qemu-devel@nongnu.org; Fri, 02 Feb 2024 15:48:54 -0500 Received: by mail-pj1-x104a.google.com with SMTP id 98e67ed59e1d1-2963a56416dso879436a91.3 for ; Fri, 02 Feb 2024 12:48:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706906931; x=1707511731; 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=8WeuC7JvPagfraa2WTEH94EGGshXGZXY2HdGa0YFfR8=; b=QSRl9x/UrbNLoO3ZDwQn+8PxwnMxykfB2RbfPwBZjQV6AgqeWYKCybqHzHL7GrEq4O b6lFb/7QAF62xZPdaOprbjOGqRC1KFI9T7vQDErhPazj0TeVJkZb/beImVaUhumWPbar g28JpaIXL9dBJ6ntdmvsdUYhRokuvUtacVb2LfZZnpXSNc7B6AZt62cwkYAT+9NpcXAU o7H0v3JxrilG+sQovjC5mhthV5HEXwB7/aDlPo2P+kl5/gbwQx87mk6RLhUMaywxtEKE t7JJy6W5lPy+MnFmiUWOZGxYh+b5LSCSd6lr8Y8U/Wxt1a3NyFclwLaUnxPpFHdEwECa VwKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706906931; x=1707511731; 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=8WeuC7JvPagfraa2WTEH94EGGshXGZXY2HdGa0YFfR8=; b=ASOkCQxD6qN2VTZ0K7FvyeTBktgsNUooc2gI2uDLv6aQp0z3Z9xfQoZnAU37dBfcOT xNUP13ABmeyniLgKrvtFz927A5azfaCi1kAqdZYl07QybBZTZhemBlY7hHNi0tN+li4i hWgiKLAQy4U07McdTRhTakPFHa1FDzbDpxo4BCYoPPrUots1KKQbBnLa3W+EHzCbWOf8 5YnlVNth53KnEwTA/L9wiUk88RfBDwWl/ub5cJzkOpQIcgZavwMkEGiXUdhHH7ZUm4jp aJ4vrV8QilHT/YYBMLjLV5/P8LvsBrKyTF1nyCbnZ/ovauLEdYtBlKACn43vL1maFxvZ ZsiA== X-Gm-Message-State: AOJu0Yx6HX2KfeMHUj9ay4lmg8rr3Oh0ltaNmi2octV1ZZ+cNbXuocuo 4ggurOV7QIWN1VEBXd+DPJ3e4zxDTOPUiGhdGHzlGTT6BUt1kCdSFxsQiYR9pI8Etve/eFS1Jqa XUVSraL9D8rfmte1NZJ0FyA0sKPqKHgz8uEMx+4uaJplt5K+YWx8k+rt8VMxPyACsfIBSMnHtpP 5Vnjg2u5kUJCkFyT6XNoJvq1z5Npifib7p6PUD X-Google-Smtp-Source: AGHT+IHoGumHwsKdV+lrp3vsfV2sl9AUx2eObHzrlz/abfSdNG6E1LA1YfQ+64UGCGepIFTMHOSLeh+EN+9U X-Received: from komlodi.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:35ee]) (user=komlodi job=sendgmr) by 2002:a17:90b:2e8b:b0:296:3718:2dcd with SMTP id sn11-20020a17090b2e8b00b0029637182dcdmr21731pjb.0.1706906931234; Fri, 02 Feb 2024 12:48:51 -0800 (PST) Date: Fri, 2 Feb 2024 20:48:45 +0000 In-Reply-To: <20240202204847.2062798-1-komlodi@google.com> Mime-Version: 1.0 References: <20240202204847.2062798-1-komlodi@google.com> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog Message-ID: <20240202204847.2062798-2-komlodi@google.com> Subject: [PATCH v3 1/3] hw/i2c: core: Add reset From: Joe Komlodi To: qemu-devel@nongnu.org Cc: venture@google.com, komlodi@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::104a; envelope-from=3M1W9ZQcKCggswutwlqowwotm.kwuymu2-lm3mtvwvov2.wzo@flex--komlodi.bounces.google.com; helo=mail-pj1-x104a.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: 1706906957693100003 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 +++++++++++++++++++ include/hw/i2c/i2c.h | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) 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) diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h index 2a3abacd1b..49580e30e2 100644 --- a/include/hw/i2c/i2c.h +++ b/include/hw/i2c/i2c.h @@ -64,7 +64,7 @@ struct I2CSlave { }; =20 #define TYPE_I2C_BUS "i2c-bus" -OBJECT_DECLARE_SIMPLE_TYPE(I2CBus, I2C_BUS) +OBJECT_DECLARE_TYPE(I2CBus, I2CBusClass, I2C_BUS) =20 typedef struct I2CNode I2CNode; =20 --=20 2.43.0.594.gd9cf4e227d-goog From nobody Tue Nov 26 12:36:17 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=1706906975; cv=none; d=zohomail.com; s=zohoarc; b=TMXrMMMS/DRbSDz6CGA7ER8kiVdPPvKD+1uj7s7XI3FsmhkmYHmkm9j5a0acUgVTe2aDmaWQSM86XKKG3p94g0bxC942W1TiFbPKPfos+gzgEAo4dMRiqRtyBfpUC4ZF9t/KQ4/j8DvpnBnvamn/eCkwVCeF886kd4v7SI2SwPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706906975; 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=5g3sLXPxpiK7LDiVehLWDyyJwIbWvaSWBTkeuyNpcN4=; b=BmWJvY4gHSsE9qwtPmPntmOPCFatii9dJVXxJ3J8UMkMpP5nGw24xS1fO0d7Y3yb60D4ig9YxXbGzG/OZsBCwSD5Slgodzj5iKtVjH7ngG+JNL+CM5jvg7BDWHAXeNdtM47yyOjZX9nRjD4v1bfL7sgnswSoy3NDmGGJxmQ/9T0= 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 1706906975450826.7029093545594; Fri, 2 Feb 2024 12:49:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rW0T3-0000xm-Tb; Fri, 02 Feb 2024 15:48:57 -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 <3NFW9ZQcKCgktxvuxmrpxxpun.lxvznv3-mn4nuwxwpw3.x0p@flex--komlodi.bounces.google.com>) id 1rW0T2-0000xc-FA for qemu-devel@nongnu.org; Fri, 02 Feb 2024 15:48:56 -0500 Received: from mail-yw1-x1149.google.com ([2607:f8b0:4864:20::1149]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3NFW9ZQcKCgktxvuxmrpxxpun.lxvznv3-mn4nuwxwpw3.x0p@flex--komlodi.bounces.google.com>) id 1rW0T1-00008C-0j for qemu-devel@nongnu.org; Fri, 02 Feb 2024 15:48:56 -0500 Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-5fc6463b0edso42279717b3.0 for ; Fri, 02 Feb 2024 12:48:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706906933; x=1707511733; 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=5g3sLXPxpiK7LDiVehLWDyyJwIbWvaSWBTkeuyNpcN4=; b=xgXHQeD8z2iSU8b1z4BcrRLkKo33yRfZCTJI57yQPoG6ToPQWaITxGxyrRC36zPJqh 1Tkki8Ycn4BW7z/rT0EkeD74cpWKiULNa7+XNpgst7kUhoCdHPD2Vs5Tq4zL7VM+r22x owM0EBQs93q8ScLrcYtl4VtKoApfKKKlNVWbDvzeQGSRdaBGwls+IlnGHTXWGEspyu6P 43I+t7Q68kfiHSqbPc2GKvV7K9uO8k/1fK8BKxjMZoZ2YoVeel3FakFt0StxWtctKUAX +njjZBHiBQWQKQpyucL6cKlzTX8pE5ZEViHaQ6GXCBm5s+Q+tkDs/+6Sjz60l+D3X5vW vHlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706906933; x=1707511733; 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=5g3sLXPxpiK7LDiVehLWDyyJwIbWvaSWBTkeuyNpcN4=; b=GFQ6lufk18ZquXPEldfHZ+6mOB9VOiHeZNLHM6R8x+yER+XbZ+mcTbHPpDUzGXEe8T 6PoqvJRPCGhqAVGMlY7Jv+1wcTu+Xj+6D+NsjFD3Zd5HeSD2OtJhBinvuLYfrGZnuZ8h ek6COBvsULrZk7f8fl+NNncfjrl4m5KtTafL16pTAr3HHA9e+t3OmSO7BjRRwi1imBiD EPvcT55sq+XEE2hCeg/ZXWeXjzt19EK8mxbCHEsnYJu/vbmd9tsCMMY/A8Ki1p9pvWCm X+C9B+Tkrj2ETcalFiP/sisBMTBHiGTz5Je77OgBR9X58lgm5dcZJ1HmJqaNqP/lXnWm k5Hg== X-Gm-Message-State: AOJu0Yz6GGpamO8TbyUoe+0a2lAXF6HhBjCbQpqw/Uvwdh7Hn+cYYbS7 tCw9Q92tQ/cZY6wHXR7CxVkndPUi2Zbp0IjpgWznIWA7cj51R4aGQtz2M2fDnunOvkqixcT462z AV8dGRoGJxnO1JU+2yQtbcvn3vjIMyze5Rmqrpzu40qcQePT3FtDvgQQqfBEwszSn0bJ4plKrhG Ra3w/hwcic2qBDOW+wb4F+Rkk1c+6cuTLuqpwY X-Google-Smtp-Source: AGHT+IFjh/v0izNeSezdOTH8uoVXK54jMK56bBmHJOc58pQn8MNiC258Zc0Mfw9nailMMROez6IkXttCz482 X-Received: from komlodi.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:35ee]) (user=komlodi job=sendgmr) by 2002:a05:690c:12:b0:5fc:4ef9:9d6b with SMTP id bc18-20020a05690c001200b005fc4ef99d6bmr615670ywb.9.1706906932843; Fri, 02 Feb 2024 12:48:52 -0800 (PST) Date: Fri, 2 Feb 2024 20:48:46 +0000 In-Reply-To: <20240202204847.2062798-1-komlodi@google.com> Mime-Version: 1.0 References: <20240202204847.2062798-1-komlodi@google.com> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog Message-ID: <20240202204847.2062798-3-komlodi@google.com> Subject: [PATCH v3 2/3] hw/i2c/smbus_slave: Add object path on error prints From: Joe Komlodi To: qemu-devel@nongnu.org Cc: venture@google.com, komlodi@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::1149; envelope-from=3NFW9ZQcKCgktxvuxmrpxxpun.lxvznv3-mn4nuwxwpw3.x0p@flex--komlodi.bounces.google.com; helo=mail-yw1-x1149.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: 1706906975836100001 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 --- 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.43.0.594.gd9cf4e227d-goog From nobody Tue Nov 26 12:36:17 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=1706906969; cv=none; d=zohomail.com; s=zohoarc; b=MKTHn+RmzCDlRkNMF9RnAEAxsyLexnYbMaISEWLByEVMNH4JcozTou3qv0cLt4LzAlyOQbj2yWP4FJ9kq94/Fa+m5FoWjsgvSu3OUaA4sZLmFRYkxR1Bt3GmR5UCfTOvz0fEyYcy5Rh/4pzATuY9la6FCE7RRXHhqk+Tz7rMhyo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706906969; 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=GvmTyKAa6pFctd7IemM9i6KPSxPf0pawWWlJgwP74x8=; b=jpLik6YYAmvrQDgijX3Kk2W0avK7ruv0esHtC9v7alhZ9UM+4r8NQkiEXPz42RVPd0ySfh/Y8Tx/g9NTS88krq4abzSvFVKh+7DaZdaa7V4VKBRmNtHoq3zenfJYFVywC1xyRkIbgRopLayQ4FlHowq+28CL/wVrs58TM3zHpcU= 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 1706906969025359.7666119263117; Fri, 2 Feb 2024 12:49:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rW0T5-0000zz-T3; Fri, 02 Feb 2024 15:48:59 -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 <3NlW9ZQcKCgsvzxwzotrzzrwp.nzx1px5-op6pwyzyry5.z2r@flex--komlodi.bounces.google.com>) id 1rW0T4-0000xr-6Q for qemu-devel@nongnu.org; Fri, 02 Feb 2024 15:48:58 -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 <3NlW9ZQcKCgsvzxwzotrzzrwp.nzx1px5-op6pwyzyry5.z2r@flex--komlodi.bounces.google.com>) id 1rW0T2-00008R-OS for qemu-devel@nongnu.org; Fri, 02 Feb 2024 15:48:57 -0500 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-dc6ba5fdf1aso3398681276.1 for ; Fri, 02 Feb 2024 12:48:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706906935; x=1707511735; 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=GvmTyKAa6pFctd7IemM9i6KPSxPf0pawWWlJgwP74x8=; b=BpVrJBiIIyUSuzqVe/DrDgJmvlTjNy7soK+v13eK3OW9wd+MyEl6hevaYun9E8Qjcy rwVIplvhHnQ/R0feUEbN7G2Nf74Bp3VyCKgXtHpUGKnO85ixQVaeDEL4bXlVOtyt50cW +ZdiuEDhwGVUO5Yhe0hPET9uk9FtMVYn0rLOVPlOWWvjeZCrbfrwjxopLDRba3q5ChTU Q1vHymkHaRFR0p3TJkLx92dgdU+AITA1pQWfyqUM7t8Qr6P5xehuVBuckXA37SYEB9Wz d7biBvrwP26kfmJ7++RD0B/KRGqFPQnoOggWEBlnyfD1hpDw9fQ7uiTXMw2e1MAknz2T FJtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706906935; x=1707511735; 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=GvmTyKAa6pFctd7IemM9i6KPSxPf0pawWWlJgwP74x8=; b=OVdZeop4MnmsdF7/+xW2dZYLLg83qdT5OiFRjRIbCg4uI6MMQRSo9bldZ0GwFoveXG S6CFgR0mk1l93rOXv2k/+euZ6mmXajFe044TP5VZJ2CUAYogC6XE7g1uBu9GrEmeqa0o VWeOAz4txDVqH4lwq1wpCQTq4LPYpurUK8aWrpALVOrd2SG/x3Kng40hOoNughYLwmt5 8d4BCWLaD77Nj7pfcw1aoUbvIeLZwq2UKOCNJET7etFKrV0Vld5ZmWdUK6NtEjRZCYxw 48IEtKFBZPC3GcswT58B+SqCG3NJfk55E3mPRPeviNCDBKiW44FoDEQi7AW84pbRZW9C IIhA== X-Gm-Message-State: AOJu0YylE5ksMxoQB8HDtq7s872eoGgELcVJiDT56D9M0DtHnXfu2kih 3y2ucor+oJFZkB+5GPTVoIE9LjYiX6HquIRHA++Jh6Dwu0YN1GrUyIhzBwX48xtRbgcmyqrnZo7 JdX6C557iot6fHcuWoMtsWFXt/LZ4T9OCYE+/tb2syZzDlt3H4JAJsFY7v4MRALYh0qiCWLn5Mi nb9wfA3SgnlowIn8mLNHl5L+Iash6JF0GIqa8L X-Google-Smtp-Source: AGHT+IFdm6eMdq8T6axYOVqlMZJZ7N5G+cb+zvEK9k0OlFmukvrYp89yQ8ScYfGxQwq9a5ge8f3IuJmjk9x7 X-Received: from komlodi.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:35ee]) (user=komlodi job=sendgmr) by 2002:a05:6902:260c:b0:dc2:3426:c9ee with SMTP id dw12-20020a056902260c00b00dc23426c9eemr181997ybb.11.1706906934909; Fri, 02 Feb 2024 12:48:54 -0800 (PST) Date: Fri, 2 Feb 2024 20:48:47 +0000 In-Reply-To: <20240202204847.2062798-1-komlodi@google.com> Mime-Version: 1.0 References: <20240202204847.2062798-1-komlodi@google.com> X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog Message-ID: <20240202204847.2062798-4-komlodi@google.com> Subject: [PATCH v3 3/3] hw/i2c: smbus_slave: Reset state on reset From: Joe Komlodi To: qemu-devel@nongnu.org Cc: venture@google.com, komlodi@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=3NlW9ZQcKCgsvzxwzotrzzrwp.nzx1px5-op6pwyzyry5.z2r@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: 1706906969787100003 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.43.0.594.gd9cf4e227d-goog