Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp1192369rdb; Wed, 1 Nov 2023 14:13:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGbfTdmsmu3Im/MICp/1dbw/pjJz0Wre6UTg3u8iRDM0ccNS7Ql+SR9/bbleCAsXkBJkJYE X-Received: by 2002:a17:90a:d497:b0:27d:4282:e3d2 with SMTP id s23-20020a17090ad49700b0027d4282e3d2mr13274565pju.30.1698873203017; Wed, 01 Nov 2023 14:13:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698873203; cv=none; d=google.com; s=arc-20160816; b=x2aDYr9ZkwEF/n9me9nzb+70VGTLJFZEbxrbeKVXlIDGB12dRv30sLKrjkN7WanoPL rSTPDyPp38DW78owwk/pnqprJHq3nSsq9opKUTIdz0mLvoYY7+vfJqmkXaHbJlmEz0/Y iia27/TPVztVAFRf5c6NfYUsbqugM+wcGdtXMnc9R32wV1RMYKQDExVxkizVNPBL8IMA d/YSzJ50Ag/NNui9LZfC/LIqzM1/sZgW0Ww8YG78t1VPY3Cpf6UM1O5ni1370yl6g1L5 S1u4R5504X0Kgs093xKNY6YAQ48G4ArN0z5c1Dyy2Ly25kbVbFA8TY30tO3uL9TVM5j4 GDcg== 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 :references:message-id:in-reply-to:subject:cc:to:reply-to:from:date :original-cc:author:original-subject:original-reply-to :dkim-signature; bh=LGvdfFN+4CI0ILsYYBUqVyLSwsn985/pmVLgko+fWgg=; fh=BFcoep8bkeaOHEgZjYgm+YMo36dxqsAS7oxwDdzV+5A=; b=oxImxKJDO96l7Hb56lg4e/wHO7qlxSX1s/Q/YKjS67PAHd3Jc3T+c4qPIWbxza70PB V2qavQvm59jqY/f+jfbZ7dYl3orcCsBGRrDH/9umFfi/cDOt57JCTVn9ZZDU0Mrm0OEw yGwTnXXebeQjCBqfxyYwPu4ByhRk3OdBsVM9GgefJfNAIC00qhq/X5wMHKzvveB8bPOo 1a2AOX/kRvTEfQevp5wVsfbMfKJkpnBKDvnRRDN/zLj7wdQWsgGX498vdFSnpu/vEoLf Gs4ue1XB9jJFw2ZB9DOYim0zzcEnvDS6EZLkYhS4yb28tjYWD2BI/eXykCrZeRgiKHBY vxiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@isely.net header.s=deb header.b="CJ/o74tY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id ch11-20020a17090af40b00b0027d1aed872dsi1574579pjb.95.2023.11.01.14.13.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 14:13:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@isely.net header.s=deb header.b="CJ/o74tY"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 6D52A80BFEE4; Wed, 1 Nov 2023 14:13:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345104AbjKAVMW (ORCPT + 99 others); Wed, 1 Nov 2023 17:12:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345140AbjKAVMU (ORCPT ); Wed, 1 Nov 2023 17:12:20 -0400 Received: from cnc.isely.net (cnc.isely.net [192.69.181.175]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 514C6110 for ; Wed, 1 Nov 2023 14:12:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isely.net; s=deb; t=1698873133; bh=LGvdfFN+4CI0ILsYYBUqVyLSwsn985/pmVLgko+fWgg=; h=Date:From:Reply-To:To:cc:Subject:In-Reply-To:References; b=CJ/o74tY7gVNPdAk9QyAn1daeydqENIFhNocIJQz5iTwKuzTxsmL7yCdpOcU6XJLN Anx5W6oTcySh61ZLX0wbuOEl3ww8jqkNjtybeGBlNfOStC8wtUabgZ3IhKGuk+2Sgg hNreVvd9mLJZl3+Qsyt267GuxjbazL90sW7ar3eKARWCewMofWk93mskjiSVq Original-Reply-To: Mike Isely at pobox Original-Subject: aborting i2c bcm2835 controller [was: [PATCH 2/2] [i2c-bcm2835] ALWAYS enable INTD] Author: Mike Isely Original-cc: Stefan Wahren , mike.isely@cobaltdigital.com, Andi Shyti , Florian Fainelli , Phil Elwell , Broadcom internal kernel review list , Ray Jui , Scott Branden , linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Linux Kernel Mailing List , Mike Isely at pobox Received: from ts3-dock1.isely.net (ts3-dock1.isely.net [::ffff:192.168.23.13]) (AUTH: PLAIN isely, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by cnc.isely.net with ESMTPSA id 0000000000080569.000000006542BF2D.00005394; Wed, 01 Nov 2023 16:12:13 -0500 Date: Wed, 1 Nov 2023 16:12:13 -0500 (CDT) From: Mike Isely Reply-To: Mike Isely at pobox To: Dave Stevenson cc: Stefan Wahren , mike.isely@cobaltdigital.com, Andi Shyti , Florian Fainelli , Phil Elwell , Broadcom internal kernel review list , Ray Jui , Scott Branden , linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Linux Kernel Mailing List , Mike Isely at pobox Subject: aborting i2c bcm2835 controller [was: [PATCH 2/2] [i2c-bcm2835] ALWAYS enable INTD] In-Reply-To: Message-ID: <2c8c3030-ede6-5283-a0a9-703df43245ac@isely.net> References: <20231030162114.3603829-1-mike.isely@cobaltdigital.com> <20231030162114.3603829-3-mike.isely@cobaltdigital.com> <750b1864-c271-fb64-dcca-e982f818e719@isely.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 01 Nov 2023 14:13:05 -0700 (PDT) On Wed, 1 Nov 2023, Mike Isely wrote: [...] > > > Given that the hardware can detect clock stretch problems then there > > > really should be no circumstance where the controller silicon can leave > > > the bus stuck. > > > > I can't find my debug notes from May, but it was aborting part way > > through a multi-byte read from the touchscreen without a STOP > > condition, leaving the touch controller still thinking it was still > > clocking out the current byte, so it messed up the next transaction. > > Hitting BCM2835_I2C_C with BCM2835_I2C_C_CLEAR whilst BCM2835_I2C_S_TA > > is set will abort immediately with no STOP :-( > > That's probably because the DLEN register still has a non-zero value and > now the hardware is waiting for you to push more bytes into the FIFO > (since you just cleared out what was already there). Thus it won't > release the bus until it has processed all expected bytes. Setting DLEN > to zero first then clearing the FIFO might be the way to fix that. I just re-read the datasheet and it does indeed state that clearing the FIFO would abort the transaction. But are you doing the clearing by just writing a word to the control register with CLEAR set or were you ensuring to preserve the state of I2CEN as well? Because if you were also unintentionally writing a zero to I2CEN as well I can see that freezing the RTL's state machine and thus jamming the bus. To actually do the abort still requires a few state transitions in order release the bus - and if the controller has been disabled then a jam would not be unexpected. In all other cases in the driver, you're only writing to the control register after the hardware has idled, so disabling the controller in this way would be working ok. I wonder if hitting CLEAR while also keeping I2CEN set and INTD on would then allow the hardware to sequence itself to release the bus then issue a DONE back to the driver once everything is idle. [...] -Mike