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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68E51C433EF for ; Tue, 29 Mar 2022 19:59:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241119AbiC2UAx (ORCPT ); Tue, 29 Mar 2022 16:00:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241108AbiC2UAu (ORCPT ); Tue, 29 Mar 2022 16:00:50 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80B9315FFE; Tue, 29 Mar 2022 12:59:06 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 660C65C01BB; Tue, 29 Mar 2022 15:59:05 -0400 (EDT) Received: from imap47 ([10.202.2.97]) by compute3.internal (MEProxy); Tue, 29 Mar 2022 15:59:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; bh=ECeje11hlUWWc7 ahU+melr+v3923TUV1SOEn+aMSwfc=; b=IDkyQ8wvClEa9bEVHsgEqxUSqV0Cqf 0X7a5NoChmomd/wU1PWKAzdiPjS8DgkvrrqPi6Wv0Uta2ngB9z/OnTkK5lkyVx0q 1u7KmRN4XcTAFWSq/SH4SBA7jOUsYsvH/VoZQt6NCJ3z4hD5abm1Z2qOHjFTUDil UpwTPJa4ZNACsyT38uouIFQA4nBUP+5bcJsy8XlvSA8IqWhcbOPQ5szbncCB78NC ZXaHGW8YBtjqX9rNqG4PN0pvyRZqPlTOuNRrpj6rntgWEaMXEyyXLoFj3pr3XwNS cBWpfnOPwud9JERKOCiPSNm+DA92TbRbK3iZyC0XX+AKrdvqsi6LwYtQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=ECeje11hlUWWc7ahU+melr+v3923TUV1SOEn+aMSw fc=; b=MXBIEYDu0Diu7AlV79qmpfV03zUCN1oIh30QqCzW2JH0EBCCiKmllCFjl FHIBVeFNemPwI9U8LbzqFRgJTWgO9ot149wgeULc9+lmBHKkMV2+Jo55eLcauOJd VaV1TND7gvEFTXr9vmsL0M3pjb/8diL9ECBh4QUYpHqALVeY0KBTeStCNi9rVXMb YR7l392wToBSdZ2rfhDFUJZMes3IlZFNrO43zIBI4prttkCZxYoVaV5lS2qdbdLT f47kBEaKl7ZKNtOhosOFwnliOXguDnQ/lvyFGzg7gdRxtLwLiuj60Bxb//dOFmMc OTLQfju6c7tMuFomfwDq2g0CANarA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudeitddguddukecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtgfesthhqredtreerjeenucfhrhhomhepfdfu vhgvnhcurfgvthgvrhdfuceoshhvvghnsehsvhgvnhhpvghtvghrrdguvghvqeenucggtf frrghtthgvrhhnpeetueduleetfeeuledvleehheeivedvhfekheejjeduhfeileffffdu hfekieelgeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsvhgvnhesshhvvghnphgvthgvrhdruggvvh X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 8FE2F2740137; Tue, 29 Mar 2022 15:59:03 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-4911-g925b585eab-fm-20220323.003-g925b585e Mime-Version: 1.0 Message-Id: <74a36bce-3d6e-4124-add1-8ed44ba2c80d@www.fastmail.com> In-Reply-To: <20220329183817.21656-1-povik+lin@cutebit.org> References: <20220329183817.21656-1-povik+lin@cutebit.org> Date: Tue, 29 Mar 2022 21:58:43 +0200 From: "Sven Peter" To: =?UTF-8?Q?Martin_Povi=C5=A1er?= , "Hector Martin" , "Michael Ellerman" Cc: "Alyssa Rosenzweig" , "Benjamin Herrenschmidt" , "Paul Mackerras" , "Jean Delvare" , "Olof Johansson" , linux-arm-kernel@lists.infradead.org, linuxppc-dev , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, "Janne Grunau" Subject: Re: [PATCH] i2c: pasemi: Wait for write xfers to finish Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 29, 2022, at 20:38, Martin Povi=C5=A1er wrote: > Wait for completion of write transfers before returning from the drive= r. > At first sight it may seem advantageous to leave write transfers queued > for the controller to carry out on its own time, but there's a couple = of > issues with it: > > * Driver doesn't check for FIFO space. Maybe we should also check that in a follow-up patch :-) > > * The queued writes can complete while the driver is in its I2C read > transfer path which means it will get confused by the raising of > XEN (the 'transaction ended' signal). This can cause a spurious > ENODATA error due to premature reading of the MRXFIFO register. > > Adding the wait fixes some unreliability issues with the driver. There= 's > some efficiency cost to it (especially with pasemi_smb_waitready doing > its polling), but that will be alleviated once the driver receives > interrupt support. > > Fixes: beb58aa39e6e ("i2c: PA Semi SMBus driver") > Signed-off-by: Martin Povi=C5=A1er > --- Reviewed-by: Sven Peter > > Tested on Apple's t8103 chip. To my knowledge the PA Semi controller > in its pre-Apple occurences behaves the same as far as this patch is > concerned. > > drivers/i2c/busses/i2c-pasemi-core.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/i2c/busses/i2c-pasemi-core.c=20 > b/drivers/i2c/busses/i2c-pasemi-core.c > index 7728c8460dc0..9028ffb58cc0 100644 > --- a/drivers/i2c/busses/i2c-pasemi-core.c > +++ b/drivers/i2c/busses/i2c-pasemi-core.c > @@ -137,6 +137,12 @@ static int pasemi_i2c_xfer_msg(struct i2c_adapter=20 > *adapter, >=20 > TXFIFO_WR(smbus, msg->buf[msg->len-1] | > (stop ? MTXFIFO_STOP : 0)); > + > + if (stop) { > + err =3D pasemi_smb_waitready(smbus); > + if (err) > + goto reset_out; > + } Looks like pasemi_smb_xfer doesn't suffer from the same issue. I wonder if every device connected to the bus on the original PA Semi bo= ards only used that path and that's why no one noticed it. Sven