From patchwork Thu Apr 8 02:00:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 417744 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, USER_AGENT_GIT autolearn=ham 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 EF4FCC433ED for ; Thu, 8 Apr 2021 02:00:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CCBE561246 for ; Thu, 8 Apr 2021 02:00:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231219AbhDHCAw (ORCPT ); Wed, 7 Apr 2021 22:00:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:56398 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230334AbhDHCAw (ORCPT ); Wed, 7 Apr 2021 22:00:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A3B23611AF; Thu, 8 Apr 2021 02:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1617847241; bh=cw5M6pxU6yZtM1xJOgHtmP/1L3ZF1wzsAoIgeeXdZV0=; h=From:To:Cc:Subject:Date:From; b=Oj6lBGs0n1L5Q9414P7yA84LveZniVZvi1TL9P3HmGcsdRjRroyLno8buZgcPHpGw KNZAYv8ar2SBCQ8AwKfdwvNikhzW6mEY527rikBLE81hUYbrk+wfF9RtAbOVh7tr+w i5sgFjcZpQ7N9iTLTreXPNGDJwf8+x/ChwuRfUeM9ejiLnkanfrE+aDjf2BlsXMKA6 weFVQ2iBysXOFNFysvYkpp1U5cFhSV4FvWbVfg10o/rFKxr4Zud5HOivRpdiL7r6tN iuGoNOZ5VDh7qHSjdhWVWO7yfrfo8r6Pp1riwSaElqF684ZlESisUzRek244m04GXA sjy77gZOAsY/g== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: linux-i2c@vger.kernel.org, Wolfram Sang , Gregory CLEMENT Cc: Samuel Holland , Ondrej Jirman , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH] i2c: mv64xxx: Fix random system lock caused by runtime PM Date: Thu, 8 Apr 2021 04:00:00 +0200 Message-Id: <20210408020000.21914-1-kabel@kernel.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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 --- 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 c590d36b5fd1..5c8e94b6cdb5 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c @@ -221,6 +221,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; }