From nobody Sat Jan 3 02:10:38 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D9B3E92FD6 for ; Fri, 6 Oct 2023 02:23:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229821AbjJFCXE (ORCPT ); Thu, 5 Oct 2023 22:23:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229774AbjJFCXC (ORCPT ); Thu, 5 Oct 2023 22:23:02 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18E50106 for ; Thu, 5 Oct 2023 19:22:39 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1c87e55a6baso12418495ad.3 for ; Thu, 05 Oct 2023 19:22:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1696558958; x=1697163758; 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=MgD2XlWyO1IkxKrZZ4NotDzi7FafWvmObFFGZh4fKtk=; b=Im7qPefsjDS9nbLox8rqJoVIvjqksZW2nFDzD7g83S4eQToetBFtf7KowlaD+pp27H 6kZvdBYd/9vvoMkMs2kaTp8k6gcKzeblf+HoT+n82oxQ+F5l8vPLv06AMKG/MXietmI6 lJEA6n7n3YxV1sr1FM1Pe5nljZhDep/nqDao31U9bR+93nyFlB8pQH4EkNeU3OxdmR/+ qtnLQ2A2G5OLcKxmVZiJQE4I7KPloDN7vae6K4IndRPoEBzolxawGmVLkmFYA3uK+uLh BT//2uZyX9/un0E40hNwzW2FZXvks3pPG8/e1aV1ynC9eGo6+KdJAIO3U6RdUttv78Gu G09w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696558958; x=1697163758; 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=MgD2XlWyO1IkxKrZZ4NotDzi7FafWvmObFFGZh4fKtk=; b=AhSBBfWeOreXzNfP/VyvGZB6Mc0gkTuRnwq9xBm7+ty1bbt9y0U3TIwoK+r1P+ECKt +F5cYDMjtSsl+MPAJbhAskGiw46YyvZc/s/EpPdjTqfVPiuQx64b/Wn+Iyka+JrPQVAL xG3IdH/gSmA3IVdZzFTs07nubVsXTwBV2KVqLiY2nVpk2UM/i/O1pMwJLUAqcbS5G2nB x2N4WgBQ6AGtzIgJ3aEUr4c30xoZGu8xzAI4hsd7CPsU4c5LlTynT0LIRog7NiGoWhrO AuwuIKgxHJcSq1udn/GDf1WUznK7wLqYLlpiGguVwW156rftRsN4TenP3q2iq18gNMLa XSyw== X-Gm-Message-State: AOJu0Yx1J9o7ZTIGe1fiEBg8diVKgBJDDkWCs96KL4s2YAs2KBJpwfBH GqpGQ6JyqPuQSAuuNcRzgyVFRA== X-Google-Smtp-Source: AGHT+IG+mQuSZhsZ7s1GbN7oZkzhFLn2RCUCg1Is6VpUBCVfYtfZj/tayH7KU48aIsSbMRFm9GPikA== X-Received: by 2002:a17:902:e542:b0:1c3:d07f:39f7 with SMTP id n2-20020a170902e54200b001c3d07f39f7mr7233603plf.62.1696558958573; Thu, 05 Oct 2023 19:22:38 -0700 (PDT) Received: from localhost ([49.7.199.22]) by smtp.gmail.com with ESMTPSA id 10-20020a170902c20a00b001ae0152d280sm2487893pll.193.2023.10.05.19.22.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 19:22:38 -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 , Andrew Jeffery , 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 v3] i2c: aspeed: Fix i2c bus hang in slave read Date: Fri, 6 Oct 2023 10:22:33 +0800 Message-Id: <20231006022233.3963590-1-zhangjian.3032@bytedance.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 oc= curs") Signed-off-by: Jian Zhang Acked-by: Andi Shyti Tested-by: Andrew Jeffery Reviewed-by: Andrew Jeffery --- Changelog: v3 - move to __aspeed_i2c_reg_slave. v2 - remove the i2c slave reset and only move the `bus->slave_state =3D ASPEED_I2C_SLAVE_INACTIVE` to the aspeed_i2c_init. --- drivers/i2c/busses/i2c-aspeed.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspee= d.c index 5a416b39b818..28e2a5fc4528 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -749,6 +749,8 @@ static void __aspeed_i2c_reg_slave(struct aspeed_i2c_bu= s *bus, u16 slave_addr) func_ctrl_reg_val =3D readl(bus->base + ASPEED_I2C_FUN_CTRL_REG); func_ctrl_reg_val |=3D ASPEED_I2CD_SLAVE_EN; writel(func_ctrl_reg_val, bus->base + ASPEED_I2C_FUN_CTRL_REG); + + bus->slave_state =3D ASPEED_I2C_SLAVE_INACTIVE; } =20 static int aspeed_i2c_reg_slave(struct i2c_client *client) @@ -765,7 +767,6 @@ static int aspeed_i2c_reg_slave(struct i2c_client *clie= nt) __aspeed_i2c_reg_slave(bus, client->addr); =20 bus->slave =3D client; - bus->slave_state =3D ASPEED_I2C_SLAVE_INACTIVE; spin_unlock_irqrestore(&bus->lock, flags); =20 return 0; --=20 2.30.2