Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp710502pxb; Tue, 5 Apr 2022 19:47:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwoYgeS4bpoSKONOTqL0VXL7ACMDNPu7lsDNqy8vsMsQ02myFUppv/lEmBrt2U5IBNPKHX X-Received: by 2002:a05:6402:2553:b0:41c:debb:e4ac with SMTP id l19-20020a056402255300b0041cdebbe4acmr6497083edb.352.1649213271554; Tue, 05 Apr 2022 19:47:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649213271; cv=none; d=google.com; s=arc-20160816; b=vb9k4IUQgH3w6VJgMgzodmPlKCjZCw+bDUfcBKOlL2Wsxzj2oA1QSZBwgG1fsB10XD XhyWpRk69s0xOHS0WDcuLpDsjys25+b01c2bhqPyeuE0uvzipfgWPH0El1ZIxTf7OL2J 2gI8HCyb1Sqfy89Tr5EAVeG1ffNelf9GlMM5X8WmVC+hffwGg+tYPlOHY7k+4auvACQ3 2Z36aA0sERjTkitk2Np81hGR4OLq1EHbVW0q5c8Cy8e9t0cfFds2aHhXPZTNoF9qxh9f rjDRdmGpf3kc4+rQMMFi2YW/5VcbfkgByl3rVAAaAr1r+DHC4mgd/th56RVao0O7vDNo sVeg== 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=4FX08MTwOCIjsy2ukcxLnKoFDg5egl7mRHGjPAkdKmU=; b=UMI17NvSHO8kZqQJYghJzLE1sk0NB1TgxCxOQsBDR8ADNmqUfEYQZK5gUFH6ny2DY8 wzbFig94RH2Xlj8l3Bd7VaAbXcrO9xocvIpJWOpVpj0AlLb5x+cf4ViPpar6PqRKCwc7 t9ekga8nflZzX+rTdod0MpxSRh2AyoKcqKSjWlhyQAztmy6Ax7Cs6AP2EaoyNT0YsszR Wed1GZ9TVsGbKCQyYbZ44l0k38EcfTnysfHnPE391lG5OMS1DnL/rAfA7mTBVo2w0+Ky B49aqh7NMeweQILcsw0KBm6RPYRcgcpCu6wjYHSFObAoreJ08ltS7Qak+2gQSAFaR0u2 zERQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=X3sDX8ec; 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 s7-20020a056402520700b004191e2c82d0si12116321edd.2.2022.04.05.19.47.21; Tue, 05 Apr 2022 19:47:51 -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=X3sDX8ec; 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 S1359794AbiDELUt (ORCPT + 99 others); Tue, 5 Apr 2022 07:20:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240721AbiDEIra (ORCPT ); Tue, 5 Apr 2022 04:47:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 447AD25C6C; Tue, 5 Apr 2022 01:36:26 -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 ams.source.kernel.org (Postfix) with ESMTPS id CA0A1B81BC0; Tue, 5 Apr 2022 08:36:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C4C6C385A0; Tue, 5 Apr 2022 08:36:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649147775; bh=3TnHiDcoE4UN7piXzw8IEQIziQxDeP2KahwoBf8cuVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X3sDX8ec/Mxr45hjEXtV2oYUB063QL3vi4WJ/OVf4+mZom6ZmFEadxv7eFkJVZ6Xr rlG5TNeZXHXrcrt5GrsEnPBm3Sc4FYtw1W3Ij9E6+8wVj0siDpVk05e2HxSkGkG2zA 0aQqP2Pg8C0C2cAOWI5toWvNWWUvjeiuNioGgGnY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mason Yang , Miquel Raynal , Zhengxun Li , Mark Brown Subject: [PATCH 5.16 0078/1017] spi: mxic: Fix the transmit path Date: Tue, 5 Apr 2022 09:16:31 +0200 Message-Id: <20220405070356.506732153@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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.1 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: Miquel Raynal commit 5fd6739e0df7e320bcac103dfb95fe75941fea17 upstream. By working with external hardware ECC engines, we figured out that Under certain circumstances, it is needed for the SPI controller to check INT_TX_EMPTY and INT_RX_NOT_EMPTY in both receive and transmit path (not only in the receive path). The delay penalty being negligible, move this code in the common path. Fixes: b942d80b0a39 ("spi: Add MXIC controller driver") Cc: stable@vger.kernel.org Suggested-by: Mason Yang Signed-off-by: Miquel Raynal Reviewed-by: Zhengxun Li Reviewed-by: Mark Brown Link: https://lore.kernel.org/linux-mtd/20220127091808.1043392-10-miquel.raynal@bootlin.com Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-mxic.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) --- a/drivers/spi/spi-mxic.c +++ b/drivers/spi/spi-mxic.c @@ -304,25 +304,21 @@ static int mxic_spi_data_xfer(struct mxi writel(data, mxic->regs + TXD(nbytes % 4)); - if (rxbuf) { - ret = readl_poll_timeout(mxic->regs + INT_STS, sts, - sts & INT_TX_EMPTY, 0, - USEC_PER_SEC); - if (ret) - return ret; + ret = readl_poll_timeout(mxic->regs + INT_STS, sts, + sts & INT_TX_EMPTY, 0, USEC_PER_SEC); + if (ret) + return ret; - ret = readl_poll_timeout(mxic->regs + INT_STS, sts, - sts & INT_RX_NOT_EMPTY, 0, - USEC_PER_SEC); - if (ret) - return ret; + ret = readl_poll_timeout(mxic->regs + INT_STS, sts, + sts & INT_RX_NOT_EMPTY, 0, + USEC_PER_SEC); + if (ret) + return ret; - data = readl(mxic->regs + RXD); + data = readl(mxic->regs + RXD); + if (rxbuf) { data >>= (8 * (4 - nbytes)); memcpy(rxbuf + pos, &data, nbytes); - WARN_ON(readl(mxic->regs + INT_STS) & INT_RX_NOT_EMPTY); - } else { - readl(mxic->regs + RXD); } WARN_ON(readl(mxic->regs + INT_STS) & INT_RX_NOT_EMPTY);