Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp316955rdb; Tue, 31 Oct 2023 08:17:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFNsvsHPX8b/KowBxsjw2NUCT4Lggk7ZBQUK7KmAVsSt818TqSvp7HKncohlLEdA5ZmRL2N X-Received: by 2002:a17:903:32c2:b0:1cc:4985:fbf8 with SMTP id i2-20020a17090332c200b001cc4985fbf8mr6547062plr.59.1698765450893; Tue, 31 Oct 2023 08:17:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698765450; cv=none; d=google.com; s=arc-20160816; b=hKaw0jA6IKWHr8zOGlZFnH0YIszQRaZKvbamGjTeWjGi2RJSEJipYatkI0uqygWcH+ gURO8lhOrPBV8JQV9WNSAHXYCm9a3gX81pF0tkxUsTZaHOpB6zAukzqrONuOQgVexAet D7LKUFndOsx9HlDEZrUDfsr5388cSvCwGCAY/u9B/ITG53XtqT3/oyr1DWRmnwnsf+vL f8h/KLKlpQYW/VpNNU1xUVMfQt8CtKFS55l7tfIIxPAsCwXRO8snx07FyT1pG4e4DObm auUffWk8xeke7PPHUx3+qxtAJqscE2QlsSAeSXkpTgoC0oxWkxk3H7KzEs0zFKyB+FhL Ftdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=0gKaWhoWtzsS3EARmo5lX0RoQiA/z47wvED5LOnksdU=; fh=zf7s1BGWaV2OWaVlhdh6UWsspaJJLVXsE6SAzMwvHqI=; b=H+PWUZgsTh9c4LbukOiC6CiL4EJUqcmHTW4SoRiyKFGNVJjD80xYbyVHpF2hWIkW/z g1MOxL0FLDrkswHkhdZhNILla4Oygzm7b430mtRlhRFaHwcfC75NK9aoCjxwmmqX8I9x rfliUgM/xYmZZlx5ssoklzY/XTCoSczSlgvtBRzcw27Oj9WBZZdoZ5PWsf0jFZYz9C0R 0E4Ul4yK59YbrQb5LJdkK3e1UfZNXEjwHYXTEg+W28Qo4a1LoQLweIbGwmkLADRveAbG E+Ra6zIte+oioJGzVwqVD1l87vrTsVuRVrQ07YP+7TljSODB3i1iyLqqNRtvsPUlBt9G Fh/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=MLkF8ypP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=raspberrypi.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id u10-20020a17090282ca00b001c9d7a75ab9si1110715plz.444.2023.10.31.08.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 08:17:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=MLkF8ypP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=raspberrypi.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 74AF0801D4B2; Tue, 31 Oct 2023 08:17:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344676AbjJaPQw (ORCPT + 99 others); Tue, 31 Oct 2023 11:16:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345002AbjJaPQ3 (ORCPT ); Tue, 31 Oct 2023 11:16:29 -0400 Received: from mail-yw1-x1131.google.com (mail-yw1-x1131.google.com [IPv6:2607:f8b0:4864:20::1131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B37A170C for ; Tue, 31 Oct 2023 08:14:57 -0700 (PDT) Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-5a87ac9d245so57051457b3.3 for ; Tue, 31 Oct 2023 08:14:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1698765297; x=1699370097; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=0gKaWhoWtzsS3EARmo5lX0RoQiA/z47wvED5LOnksdU=; b=MLkF8ypPd+iQDdw3fovCXCREbMsvAdMhwJa5uz9E8kaN9mUQ8BBSHrsvcmHapgmA9e +yy5pyU6Y5fCDFFBrxbp+85vo/7zMwQNmhZg3KEmeN7b78Q2fI7dSdejLcjepMs2q/5r S/01D2lLLMUVu1rdFundeFjbbsq2VQmOwwNarhe6+OePPy8z4iqUTKj1z3afgxYKt/5m 0ABhp623FAamw8rtDVnYJRF2UJOUSmE96bP8y5x/nTH6l+D4nSt9aTLqM9Xw6Ib3OWYm 5/XPzfgF4uQV08ZzEYHiTyaFRHSipqRJvhu74ipLKoeuVnEiqoglahfffzgCDeN27fDy YouA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698765297; x=1699370097; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=0gKaWhoWtzsS3EARmo5lX0RoQiA/z47wvED5LOnksdU=; b=W95N5qTH1gvRKJA9dV8ygYyYR4ZFte7Fd8K325oHa0kP2eyk1J9sujQcZhc/FNCTWd MOKS25oCj4RjrlpTQl7PV+Pzd4jt3Etl3wP6BDlFi12UKEUocts7R/GrTgog6C+HQ31n r0DgpXjfgxE+ltHhCBcfkCfS8UTrr1pB1F29McrL/uUvm45cpXPbpRe6O+s1xINbi+o8 N0Anl+DpW20Tzgep0RYpFKyjNow9bFg42I+WIlXb/OAvrHQ2HTFzodznJYmP1y8Bm9nJ JDXQ87XPBiqz/Ksnt1LVbByNJf2UvfaFxsgcvMfVSvXXM2wzg7nMPMyhlEv3h1whV7WE IkTQ== X-Gm-Message-State: AOJu0YxH9q83Q+7hvZryZfdtL/U5jlLpDcbnp4NX+QZhUA+rViznCeZH hryiEnASQ9fmIBGte0HWwBBFmhaZHmPWsZOVpiNo9Q== X-Received: by 2002:a81:e301:0:b0:5a7:c4be:3af7 with SMTP id q1-20020a81e301000000b005a7c4be3af7mr11859954ywl.44.1698765296918; Tue, 31 Oct 2023 08:14:56 -0700 (PDT) MIME-Version: 1.0 References: <20231030162114.3603829-1-mike.isely@cobaltdigital.com> <20231030162114.3603829-2-mike.isely@cobaltdigital.com> <20231031114339.nutx2q2vtwbaaw6h@zenone.zhora.eu> In-Reply-To: <20231031114339.nutx2q2vtwbaaw6h@zenone.zhora.eu> From: Dave Stevenson Date: Tue, 31 Oct 2023 15:14:41 +0000 Message-ID: Subject: Re: [PATCH 1/2] [i2c-bcm2835] Fully clean up hardware state machine after a timeout To: Andi Shyti Cc: mike.isely@cobaltdigital.com, Florian Fainelli , Mike Isely , Broadcom internal kernel review list , Ray Jui , Scott Branden , linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 31 Oct 2023 08:17:00 -0700 (PDT) Hi Mike & Andi On Tue, 31 Oct 2023 at 11:44, Andi Shyti wrote: > > Hi Mike, > > > When the driver detects a timeout, there's no guarantee that the ISR > > would have fired. Thus after a timeout, it's the foreground that > > becomes responsible to reset the hardware state machine. The change > > here just duplicates what is already implemented in the ISR. > > Is this a fix? What failing here? > > Can we have a feedback from Florian, Ray or Scott here? > > ... > > > if (!time_left) { > > + /* Since we can't trust the ISR to have cleaned up, do the > > + * full cleanup here... */ > > Please use the > > /* > * comment > * comment > */ > > format > > > bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, > > BCM2835_I2C_C_CLEAR); > > + bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_S, BCM2835_I2C_S_CLKT | > > + BCM2835_I2C_S_ERR | BCM2835_I2C_S_DONE); > > I'm not sure this is really making any difference though. How > have you tested this? > > Have you tried reading those registers before and understand what > went wrong? I guess we may have a race hazard here. The completion has timed out. The write to I2C_C will flush the FIFOs and mask the interrupts out, so if the transaction can complete at that point then the ISR won't handle clearing the status flags. As the flags are "write 1 to reset", they could still be set for the next transfer. It'd be down to the exact timing of hitting I2C_C_CLEAR (to clear the FIFOs and disable the interrupts) and when that terminates the transfer. Ensuring the status bits are cleared will do no harm, but I'm not convinced that there is an issue in the first place that needs fixing. Can you give any more detail of when you've seen this fail? Dave > Andi > > > _______________________________________________ > linux-rpi-kernel mailing list > linux-rpi-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel