From patchwork Wed Sep 27 15:42:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jian Zhang X-Patchwork-Id: 1840322 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=g4sLXxsh; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linux-aspeed-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rwgrb1QScz1yp0 for ; Thu, 28 Sep 2023 01:43:59 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=g4sLXxsh; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4RwgrZ2t4gz3cNj for ; Thu, 28 Sep 2023 01:43:58 +1000 (AEST) X-Original-To: linux-aspeed@lists.ozlabs.org Delivered-To: linux-aspeed@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bytedance.com header.i=@bytedance.com header.a=rsa-sha256 header.s=google header.b=g4sLXxsh; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=bytedance.com (client-ip=2607:f8b0:4864:20::42b; helo=mail-pf1-x42b.google.com; envelope-from=zhangjian.3032@bytedance.com; receiver=lists.ozlabs.org) Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4RwgqN5TdZz3c8W for ; Thu, 28 Sep 2023 01:42:55 +1000 (AEST) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-690d2441b95so8721116b3a.1 for ; Wed, 27 Sep 2023 08:42:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1695829370; x=1696434170; darn=lists.ozlabs.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=g4sLXxshYIcvDFVXgVFI65z8Fny+3aeUxj/t48w742pvpvRd5o+u7gkzSIxYd5yl7+ IwuT7Gh8DsRHE+sVsdBo59iWQTgmhYN3tbPchWCc6ugKS+zQv41BzxxPCwh2saYZ4kYZ XV213pnF1T/on1dtOu2hV0MIDE6tLuPwGqRsk4lK1UtglRcjCEq2/FK2oCbf6EyTNDiB NeyN82kjrbJZ4EDZO8y9lWgDKGpzMfcSJX/JHcuSgOgZ7d8EnmbPaPZ+BIs9O6yfuGjW 3d0tiIgZQywx1rsDl+YDS9sXpgN77f48ijXyOfboShS+m7/XGBlCbmp3GNijaml06EoW LRIw== 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=cWAOFpSp3rxRGowhNUw4R9fsqZwD8WE/ygGPuOi0deMgv1tzOKeJeySndHBieAeePc zRvFbdMUTDMr42PQxfUYw57g+BSY5Yzx/p2sXMFycn2xEpgjlxOGZuT41rYxtJO6F+bl Y+KbYsUWB5g35NsmYqlTkjd7vH7dpwZhw1G3oiU8EYgYDugaHnnui0xVCnyxs/SC9RzT 6gKssnjmQ6dzTMCZOY2KdFk5XYBY4rt90oJiKAO7agDg536fTA4Kk+EJOpu0MDkKO+VT BHy8DB2/9z4N0KgCllbewkRk/KrKJPmObzbvv3ahozdSEbxIqi7cNfELEm4yeyyhVO5+ ZuLg== X-Gm-Message-State: AOJu0Ywl4rh7tLOqu2UNHaJNeEHzKoLzk+6AZIQUGo4NLqQcDwHJwOrq t6jxGS6IJMVpvMRhzd+Pl1NFPA== X-Google-Smtp-Source: AGHT+IFRfQ/0KX1bSuu5UuM2JxSiQwHD4x642i16XMLdBILDBkTo7GJS+ledc4uHjgaqOgLCqUIbcg== 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 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 X-BeenThere: linux-aspeed@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux ASPEED SoC development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andi Shyti , "moderated list:ARM/ASPEED MACHINE SUPPORT" , "moderated list:ARM/ASPEED I2C DRIVER" , open list , Wolfram Sang , "open list:ARM/ASPEED I2C DRIVER" , zhangjian3032@gmail.com, "moderated list:ARM/ASPEED MACHINE SUPPORT" , xiexinnan@bytedance.com Errors-To: linux-aspeed-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linux-aspeed" 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 Acked-by: Andi Shyti Tested-by: Andrew Jeffery Reviewed-by: Andrew Jeffery --- drivers/i2c/busses/i2c-aspeed.c | 1 + 1 file changed, 1 insertion(+) -- 2.30.2 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 */