From patchwork Fri Oct 18 03:49:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tommy Huang X-Patchwork-Id: 13841082 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BB155D3C545 for ; Fri, 18 Oct 2024 03:55:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=5GGhcXJb1lkCLyBtVHLgT6oBHiWzH5A0kRdwe2dPkh8=; b=MV9hISvAHcqws5iKmCaVPeTY0p Eks61dduPZvYw8d625294zlaJ16P95L2Yz5DRgI9LyxqJoHfCIK3shtQnPGEc96OcrRYLnkaaWA9k viOjJwiGqL3A5fD+vS4xPAS93sDTf+MXsv+ZkmeM/ebVXgvALBVEtKi/7Yehonh/EkZUrTy/MWqCz G7S4bgn+Q9WdII0CxBZT7hMVk1uP3wexjfvVP1+6n7HGezX/GzM9K7p0SGMJ8YNBwmMXwDHZBZajP 5mUMfCow1mpF9NQjgBlzCcI/hvnvbAz+Ca8DLSH7dnslLYGd+TLWtIq+XAUFqEm4dxYrZSpujkeKL BnGssyDQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t1e4n-0000000GpvR-0fBK; Fri, 18 Oct 2024 03:54:57 +0000 Received: from mail.aspeedtech.com ([211.20.114.72] helo=TWMBX01.aspeed.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t1dzU-0000000GpQo-2Wld for linux-arm-kernel@lists.infradead.org; Fri, 18 Oct 2024 03:49:30 +0000 Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Fri, 18 Oct 2024 11:49:19 +0800 Received: from mail.aspeedtech.com (192.168.10.10) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Fri, 18 Oct 2024 11:49:19 +0800 From: Tommy Huang To: , , , CC: , , , , , , Subject: [PATCH] i2c: aspeed: Consider i2c reset for muti-master case Date: Fri, 18 Oct 2024 11:49:19 +0800 Message-ID: <20241018034919.974025-1-tommy_huang@aspeedtech.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241017_204928_659622_8AB4B7B5 X-CRM114-Status: GOOD ( 13.44 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In the original code, the device reset would not be triggered when the driver is set to multi-master and bus is free. It needs to be considered with multi-master condition. Fixes: ("i2c: aspeed: Reset the i2c controller when timeout occurs") Signed-off-by: Tommy Huang --- drivers/i2c/busses/i2c-aspeed.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c index cc5a26637fd5..7639ae3ace67 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -716,14 +716,15 @@ static int aspeed_i2c_master_xfer(struct i2c_adapter *adap, if (time_left == 0) { /* * In a multi-master setup, if a timeout occurs, attempt - * recovery. But if the bus is idle, we still need to reset the - * i2c controller to clear the remaining interrupts. + * recovery device. But if the bus is idle, + * we still need to reset the i2c controller to clear + * the remaining interrupts or reset device abnormal condition. */ - if (bus->multi_master && - (readl(bus->base + ASPEED_I2C_CMD_REG) & - ASPEED_I2CD_BUS_BUSY_STS)) - aspeed_i2c_recover_bus(bus); - else + if ((readl(bus->base + ASPEED_I2C_CMD_REG) & + ASPEED_I2CD_BUS_BUSY_STS)){ + if (bus->multi_master) + aspeed_i2c_recover_bus(bus); + } else aspeed_i2c_reset(bus); /*