Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3076929pxb; Mon, 18 Apr 2022 15:16:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznud0twlyitBy3l8v//tpN+oRKMel6LB7rv/cOO7q/biYVewBKdgj6jlq6zTOEy7VEFgDb X-Received: by 2002:aa7:c946:0:b0:416:226f:f8a6 with SMTP id h6-20020aa7c946000000b00416226ff8a6mr14214159edt.360.1650320166463; Mon, 18 Apr 2022 15:16:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650320166; cv=none; d=google.com; s=arc-20160816; b=joWsKZXvcImEVZO76j7ukX17gVVcTOSgYOV7iSBIgP6ptBezi/fn1hl5iiViCyLREc 5HrMQCkO3qresiwyymI9LnoXS6HRtxvNEG69j+LIO7fwhBlkksBxW/laAjBaZs+jX9q6 zqRpK9l3g5rO/NupaT8p2d4p7WEza0HTmNZZCVX+tc77cEeeA4pGTTMlrX87vF23dZXz B6I8yz512MV7R5XdLTGxXpExd30ZNp50YcDnlKcQ7JZhjkrUyW05bBoP1amJlQ7f1ye7 5HL20TLTcWf556dkJbpRT7fcx/LNUjU3iovp5Yyh6hxa57KyAf+M6U7Cl6Q7NFwdTK5v 5+Jg== 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=qqRTkR9JM+g0UnHOQVCGd3lEbyFO7Pm6jCOpwoFwh7A=; b=hH81lLMngY/ykeROS+TltvWqtg0axvS9onSDeoPwa4o8NVzyv/VxryezewxwEWQsZH 4l2RbKgTsfavD8diMJVtboSQHwGh/LP/d18n7c95LXupPRYer4MDQ74wq3VJSqyEQF6e PMQM2q0VhMBCvMcOLfBIg8WfnAgKD6xHyXWWLhi5PWHAsxf0FT5/znrBpCq+ppIbBUIl d3jarpx1PdQiWUwy0jsDg63SjD34CKmXuGiFFjQPvvpGSYTF3+ATyGE/Qx3aN8RnbMVB y8Dzcftu4Io628NUdyIiMvgzJMPp36KL7PLag8xh5x1AsPTi9eyMgWG7HCMzsqrN2qFL uZLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="yMDhF77/"; 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 q24-20020a056402033800b00418c2b5bd65si6776896edw.71.2022.04.18.15.15.42; Mon, 18 Apr 2022 15:16:06 -0700 (PDT) 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="yMDhF77/"; 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 S245670AbiDROHD (ORCPT + 99 others); Mon, 18 Apr 2022 10:07:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244982AbiDRNuh (ORCPT ); Mon, 18 Apr 2022 09:50:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4728043ED9; Mon, 18 Apr 2022 06:01:55 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 992D160B3C; Mon, 18 Apr 2022 13:01:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FB1EC385A1; Mon, 18 Apr 2022 13:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286914; bh=qt6zVlScKlgp/UWRwAPjnLop5XpVwyg8xY7P3/aVvDE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yMDhF77/khFo99jstRfZI/L93PJkyoDeuzvTVTKU+P67MKsByE9vF2loQ5CQqWanC la2O0dk+lmv4b15F5S1Tll9l0uAac23WIPA2k99RaG3q0t6nkGl+WRtqaQ6TF8Cv2H sg6aHyg4dwTOti2+qL2jXcVUDZZzQVDPQNJ/o9/o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Martin=20Povi=C5=A1er?= , Sven Peter , Wolfram Sang Subject: [PATCH 4.14 284/284] i2c: pasemi: Wait for write xfers to finish Date: Mon, 18 Apr 2022 14:14:25 +0200 Message-Id: <20220418121221.361218307@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@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.7 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: Martin Povišer commit bd8963e602c77adc76dbbbfc3417c3cf14fed76b upstream. Wait for completion of write transfers before returning from the driver. 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. * 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šer Reviewed-by: Sven Peter Signed-off-by: Wolfram Sang Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/busses/i2c-pasemi.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/i2c/busses/i2c-pasemi.c +++ b/drivers/i2c/busses/i2c-pasemi.c @@ -145,6 +145,12 @@ static int pasemi_i2c_xfer_msg(struct i2 TXFIFO_WR(smbus, msg->buf[msg->len-1] | (stop ? MTXFIFO_STOP : 0)); + + if (stop) { + err = pasemi_smb_waitready(smbus); + if (err) + goto reset_out; + } } return 0;