Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1775627pxp; Mon, 7 Mar 2022 02:02:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxlZRKiZjgFTVG0+JdzkmC0DOKyRlL3sPgJUtw8WjEBYCIhA+5xBBZYwWFUfabsx0btFaLa X-Received: by 2002:a65:4785:0:b0:380:64fd:a2de with SMTP id e5-20020a654785000000b0038064fda2demr1628305pgs.479.1646647365933; Mon, 07 Mar 2022 02:02:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646647365; cv=none; d=google.com; s=arc-20160816; b=GJeNm08ySjOi3NZb/3u96OVIZjtCjFLwlzfhIqf3PZbO2mGfCFoSRQkfH/bu3v48rn PwwBi+toFP9jx83eizv6k301RxI9MCRSn9+gOSkHIe0JO2x8NZCdLVcRtRJJdMJ5qayq raw2ZD2ZBsuRNHUDYoNm2T1v7r9W4XpqaIvvgtdG47vh8uOdNP7lP6GrD32JDekAXdvq fVpDvCsqfR5jMNm9oi+Xpbcdsn/fwKQlm8grq80YxeOmQXZvfCK7WxqHzxZNy3badxz6 cTovRfkV3IjUX0lR1tn1Vigi1NEYBVzkjP9h2nGHTZcIBShcKqxeI7ixdpR9pRe+xp0T hgbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0Ak+1H043nLHg+9F6ntR4saH/VnZ1G9EYFljWNMwOCo=; b=LAqnpyP89E4uI/Gunnq2A2AmOHyNYUmiBdPygF9c/Bg5wl7ZeucNK8kATJggxPjrdE w2Q/ZSNS1w9KqNY8or/t5D2NSca4KiLhebKKE7tXBEZEWdBv01M6dAeXM52OkrFAurWn Uwy10rn/R23TzZXGnUSGDiCz1ecAgtLxMuFT3uydZtxf/b5mIJcca+5qLKD5G+EDWxv7 xFvPT+SOn3PiwTz95QXPdKzhmMp/iO+N0aY9N3b82IlZZ412v9xkQ+t+lfzNfVFkIJ1n sq4B4hp+8+duezrDEyMCi+OavzEgmLdvITXI7h44MlsdNs3ZQU5+75uFvRxirSPfMGlD muYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IoftWsXU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id on13-20020a17090b1d0d00b001bf381531a3si419653pjb.127.2022.03.07.02.02.30; Mon, 07 Mar 2022 02:02:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IoftWsXU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236780AbiCGJZA (ORCPT + 99 others); Mon, 7 Mar 2022 04:25:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237171AbiCGJX3 (ORCPT ); Mon, 7 Mar 2022 04:23:29 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FF4551327; Mon, 7 Mar 2022 01:22:01 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D9367B810BC; Mon, 7 Mar 2022 09:21:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 524E1C340E9; Mon, 7 Mar 2022 09:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646644918; bh=p3NpOOloCl+up0CATJ/0J6lmGf3pYfYwJI3ux1MhqfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IoftWsXUwxzLimZdYJC4r9IZ1Dp7TqXZaMGhd+jT4NEZpxLnAsLnXPbOVr3b5WoD8 WczGHKkCOZXyJ80xRocgnquHJmuFwGVzGnK9keUqjyEwKJkG9r6qgZGCdKPoWj/H6J v/KHBGKHqz1eJ8SRAuY6UUe3/n5EzmBFQ3lKfRaA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Anholt , Stefan Wahren , Wolfram Sang , Sasha Levin Subject: [PATCH 4.14 03/42] i2c: bcm2835: Avoid clock stretching timeouts Date: Mon, 7 Mar 2022 10:18:37 +0100 Message-Id: <20220307091636.248501558@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220307091636.146155347@linuxfoundation.org> References: <20220307091636.146155347@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Anholt [ Upstream commit 9495b9b31abe525ebd93da58de2c88b9f66d3a0e ] The CLKT register contains at poweron 0x40, which at our typical 100kHz bus rate means .64ms. But there is no specified limit to how long devices should be able to stretch the clocks, so just disable the timeout. We still have a timeout wrapping the entire transfer. Signed-off-by: Eric Anholt Signed-off-by: Stefan Wahren BugLink: https://github.com/raspberrypi/linux/issues/3064 Signed-off-by: Wolfram Sang Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-bcm2835.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/i2c/busses/i2c-bcm2835.c b/drivers/i2c/busses/i2c-bcm2835.c index 4d19254f78c8a..db1ab9ccc30e7 100644 --- a/drivers/i2c/busses/i2c-bcm2835.c +++ b/drivers/i2c/busses/i2c-bcm2835.c @@ -28,6 +28,11 @@ #define BCM2835_I2C_FIFO 0x10 #define BCM2835_I2C_DIV 0x14 #define BCM2835_I2C_DEL 0x18 +/* + * 16-bit field for the number of SCL cycles to wait after rising SCL + * before deciding the slave is not responding. 0 disables the + * timeout detection. + */ #define BCM2835_I2C_CLKT 0x1c #define BCM2835_I2C_C_READ BIT(0) @@ -398,6 +403,12 @@ static int bcm2835_i2c_probe(struct platform_device *pdev) adap->dev.of_node = pdev->dev.of_node; adap->quirks = &bcm2835_i2c_quirks; + /* + * Disable the hardware clock stretching timeout. SMBUS + * specifies a limit for how long the device can stretch the + * clock, but core I2C doesn't. + */ + bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_CLKT, 0); bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, 0); ret = i2c_add_adapter(adap); -- 2.34.1