From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E55FCC43462 for ; Mon, 19 Apr 2021 20:48:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BCCC56101C for ; Mon, 19 Apr 2021 20:48:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242973AbhDSUs7 (ORCPT ); Mon, 19 Apr 2021 16:48:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:55468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242768AbhDSUq5 (ORCPT ); Mon, 19 Apr 2021 16:46:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 72C97613D2; Mon, 19 Apr 2021 20:45:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618865131; bh=M+N2MxbnGQjhURZ3gS5hwFCV7PfmBdMis2chExCLoZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pP1vUPtZy9RxyYyh3YdMrJPQcyAV+pU6O1Cb7NSH89RaqsAzaDUhfN+sgv382U0LU wd1cZ4oriTWkG61brUOIBLSPfVUW7aved8ajwg2plfImyt6spDxP5dwI0uuyHvlFmW DSIsiin+JrHi4a7s/Yjn+nUk0revfAt1Os5raxME6WjB67MYDr7iG7zxM12e1LXgv0 nt63/fAIMzFlaofx5Dl4Xao9iNV9D7IUs7X4t7KzkcAsNL7iYi7ABpDPzoUz91Zp8I PjFcT4KbWrwLts29Io+wTwCQsryQFW1pAe1h3HmWFWD0xws2/AVES0HWq4yiIQxncd N52UoVcGNLpBw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?Marek=20Beh=C3=BAn?= , Gregory CLEMENT , Samuel Holland , Wolfram Sang , Sasha Levin , linux-i2c@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 09/12] i2c: mv64xxx: Fix random system lock caused by runtime PM Date: Mon, 19 Apr 2021 16:45:14 -0400 Message-Id: <20210419204517.6770-9-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210419204517.6770-1-sashal@kernel.org> References: <20210419204517.6770-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Marek BehĂșn [ Upstream commit 39930213e7779b9c4257499972b8afb8858f1a2d ] I noticed a weird bug with this driver on Marvell CN9130 Customer Reference Board. Sometime after boot, the system locks with the following message: [104.071363] i2c i2c-0: mv64xxx: I2C bus locked, block: 1, time_left: 0 The system does not respond afterwards, only warns about RCU stalls. This first appeared with commit e5c02cf54154 ("i2c: mv64xxx: Add runtime PM support"). With further experimentation I discovered that adding a delay into mv64xxx_i2c_hw_init() fixes this issue. This function is called before every xfer, due to how runtime PM works in this driver. It seems that in order to work correctly, a delay is needed after the bus is reset in this function. Since there already is a known erratum with this controller needing a delay, I assume that this is just another place this needs to be applied. Therefore I apply the delay only if errata_delay is true. Signed-off-by: Marek BehĂșn Acked-by: Gregory CLEMENT Reviewed-by: Samuel Holland Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-mv64xxx.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index a5a95ea5b81a..7409cfba2195 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c @@ -218,6 +218,10 @@ mv64xxx_i2c_hw_init(struct mv64xxx_i2c_data *drv_data) writel(0, drv_data->reg_base + drv_data->reg_offsets.ext_addr); writel(MV64XXX_I2C_REG_CONTROL_TWSIEN | MV64XXX_I2C_REG_CONTROL_STOP, drv_data->reg_base + drv_data->reg_offsets.control); + + if (drv_data->errata_delay) + udelay(5); + drv_data->state = MV64XXX_I2C_STATE_IDLE; } -- 2.30.2