Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2765570rdh; Wed, 27 Sep 2023 12:00:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFy1ZiDYXeT4ehVQ6lwHzcc+iN4NwsKf0JpUklf6KwczLVeGuYOhFlvoUuUSuH6QjlCsQ1t X-Received: by 2002:a17:902:db05:b0:1c0:cbaf:6954 with SMTP id m5-20020a170902db0500b001c0cbaf6954mr4740822plx.25.1695841258560; Wed, 27 Sep 2023 12:00:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695841258; cv=none; d=google.com; s=arc-20160816; b=SGqgGep6rXEzn4gXtdG8R6va6sA8/33ENjIvj4a2celgWJxVbiIKYKVrOB31T+ZXDr FIUybokrG99UJfROdrN7Ofj5EGgIi6u3934afl53pRlR788HmD/ekJvm+f+eIigidb7K /Nju7GKwsw9fkIasqxLHao95rPgYL4uP6qpTN8CcxOUpgzrQpns8FPVzuoUzz8yvocjb lLxyhi0aJtWaNRznO+aLHykoNpDtrQfbx+V1Qw/NumInUEnPx1+30SgpHcik1DAYhAuq 02KLwD9p+GzJbddx8ABnvFVlmR8C01RZBcRhsGJZkk5cPdm8b/RLr5HXwbnW/evR/2Gm zruQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=e+KczYJ63iTfnuMsHD4IMClJxOV5m4dNcMyA1mqDD9g=; fh=NBUkgZ+E4Gy5MssCjMC5+AbXJGAxDygRlAl0JbRczGg=; b=jNSF1ksFgm6kCFN6sD/jXlzweOFfvmmM8u5brfchtO4MOhafb5ODx443xJ8VTb9RKv gaatnLSau/8xZILmF4QhV0pBNB39xvN74MnxtrKcaGHkXzQ7BJfFiLzDc3I8XPTgeigQ YDNAQM1epDhZkYdcoi586dgA3aIMSou3nM0W3Y0q25MnEyah18VjBe7MhdMfgtruQNhI 1gqDIbnmlWoLGmWLFhjjacuLWVKmn1vnkBIFzVT0movojxXizzq5CXA7XpXPPbqSn3Af V1i9+cN1Ho10JccSFnwhQdiUDS5KYEXdjziHcnTpot5smbah1mBiPD25aPcDinOs+G+e 8S1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=RLhwbE5c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id b7-20020a170903228700b001c7345bc007si34748plh.486.2023.09.27.12.00.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 12:00:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=RLhwbE5c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 3DC73809C3B5; Wed, 27 Sep 2023 08:51:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232782AbjI0Puo (ORCPT + 99 others); Wed, 27 Sep 2023 11:50:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232772AbjI0Pu0 (ORCPT ); Wed, 27 Sep 2023 11:50:26 -0400 Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D3E0D036 for ; Wed, 27 Sep 2023 08:42:51 -0700 (PDT) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-690b7cb71aeso8719228b3a.0 for ; Wed, 27 Sep 2023 08:42:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1695829370; x=1696434170; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=e+KczYJ63iTfnuMsHD4IMClJxOV5m4dNcMyA1mqDD9g=; b=RLhwbE5cF0AchcrKRjBTtVBNA2oVXu2QTVVh6MJ9Ue4WgkSdIkayZ6YTp2NI5dr2G8 Ozy2UO4I8rx3jZdn+ycpNbQ7rewp4IBrVrEMHneNdjbMi2hxhqyhrbK5Ehf3AwWwZYQW Sqv4TL1DIhUcNfGnxYBIxRfkXimpF8nQX+i7wOUWZ8h4/vhkLGoH1EqQZ2qa3fgLh9rS Z34lIsCHRNLOFEJ5MtSXRBBU6EwP45inYMrrQyowlhXjkVWTJ5xllTZGvOualR3eqTte lrm6a8uiXM6SmqR632zFc+hHyImYQ0bXojujQCy40bLTacK3/24fcmVyXyeyyF4GA7bB N8xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695829370; x=1696434170; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=e+KczYJ63iTfnuMsHD4IMClJxOV5m4dNcMyA1mqDD9g=; b=K+eHP+9XNRcodbOUX327+KEWzlrgjCQTsFY/IgYauvyNa7JTWxmFvirvU6r5NrfJ/G SPCQ1l7FanLTdx1MLzuQvCwKMKHnZ+6ziI7iMdgl8aVd2/xSw08zGnnSxXqwD/S6Z0Zy 0jK/fM7jhNj/PenuWvXVdaF+lfBuGDjwUVBeLsorVAubkHJnyV9kkgskL1x+EkTzM04t NFRV/wF3vlIQEQWl4XBBT4Xk3UWwLwaye0RfSYzFD57vSOOVCmHxamiwiQkXBjaH88f1 kFYdFugSjz5mZ8ocuPvQkzykSdwwFWQGOYarbjomJyg8K1cLS4u/d2QoWFPk7fjoSVKb HsXw== X-Gm-Message-State: AOJu0YwXeMoeXu4NdwyY/dOHkGqYf6LoExUBlPwW81MjBd24l9jQPYdM diI2ReSXKHWxzzUl9UylMI+fuA== X-Received: by 2002:a05:6a21:9983:b0:15d:1646:285a with SMTP id ve3-20020a056a21998300b0015d1646285amr3860484pzb.21.1695829370365; Wed, 27 Sep 2023 08:42:50 -0700 (PDT) Received: from localhost ([49.7.199.230]) by smtp.gmail.com with ESMTPSA id v3-20020a655c43000000b005782ad723casm10120152pgr.27.2023.09.27.08.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 08:42:50 -0700 (PDT) From: Jian Zhang To: brendan.higgins@linux.dev, benh@kernel.crashing.org, joel@jms.id.au, andrew@aj.id.au Cc: zhangjian3032@gmail.com, yulei.sh@bytedance.com, xiexinnan@bytedance.com, Andi Shyti , Tommy Huang , Wolfram Sang , linux-i2c@vger.kernel.org (open list:ARM/ASPEED I2C DRIVER), openbmc@lists.ozlabs.org (moderated list:ARM/ASPEED I2C DRIVER), linux-arm-kernel@lists.infradead.org (moderated list:ARM/ASPEED MACHINE SUPPORT), linux-aspeed@lists.ozlabs.org (moderated list:ARM/ASPEED MACHINE SUPPORT), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] i2c: aspeed: Fix i2c bus hang in slave read Date: Wed, 27 Sep 2023 23:42:43 +0800 Message-Id: <20230927154244.3774670-1-zhangjian.3032@bytedance.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 27 Sep 2023 08:51:00 -0700 (PDT) When the `CONFIG_I2C_SLAVE` option is enabled and the device operates as a slave, a situation arises where the master sends a START signal without the accompanying STOP signal. This action results in a persistent I2C bus timeout. The core issue stems from the fact that the i2c controller remains in a slave read state without a timeout mechanism. As a consequence, the bus perpetually experiences timeouts. In this case, the i2c bus will be reset, but the slave_state reset is missing. Fixes: fee465150b45 ("i2c: aspeed: Reset the i2c controller when timeout occurs") Signed-off-by: Jian Zhang --- drivers/i2c/busses/i2c-aspeed.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c index 5a416b39b818..18f618625472 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -933,6 +933,7 @@ static int aspeed_i2c_init(struct aspeed_i2c_bus *bus, /* If slave has already been registered, re-enable it. */ if (bus->slave) __aspeed_i2c_reg_slave(bus, bus->slave->addr); + bus->slave_state = ASPEED_I2C_SLAVE_INACTIVE; #endif /* CONFIG_I2C_SLAVE */ /* Set interrupt generation of I2C controller */ -- 2.30.2