Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp700327pxb; Tue, 5 Apr 2022 19:20:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxa/cuwjHr8nrlJRx5UuCumWyBXNngPjz+iOWWvjVgw/TKSYefNmyan5MWOk3fK4oLFlHSX X-Received: by 2002:a63:2f41:0:b0:382:26ba:8855 with SMTP id v62-20020a632f41000000b0038226ba8855mr5099054pgv.310.1649211558160; Tue, 05 Apr 2022 19:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649211558; cv=none; d=google.com; s=arc-20160816; b=YYoRKYSawUjLUH/6+h7a3lO2DQeKLH/XBz/3Eztv4ovbZbF822KGi23tJcJQ3ElGIg dtkyYEhda4gZPGxyVjFAbibMU0R59w5M4FWv1qsItdUCt4Rcrv1qCkoAMAzm0vz0/kp8 e8Xq7emowt9lwu0ZvC7tJ4tiiF6M9cWG1iC08voyHJEqctUGvv8mBuSyECNVKr4pchvx JimuK51PeY/3fCAFsvGilclF4d40yIi8GgM3vuH+BwtzoAt5HIh7GCQGv1K49JJUp6Sy M16uQJ1hWdB2K3bMskDcBOXvoCJhTET5xKKP+ucXOrIDHXb/F2ILonvxknrgdLc7kp7W NLMw== 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=j4pOEvPEzbbLM0+Xh7QbfXcFsuc+FlCqqRgO568vrxTzVbgyZHsV7wbp0hRl0Icg23 Vk2PqSTI1vwp6Jr5ffnZvi8MSIYu+V/+x0VIXfZV2pwOcmovP4PpSUSegog9IyrGPVQ/ EWqo69jq4cy/tzdssco/0+wfRUSIfmnfILLjgpCseC6aGHlSos6pWmX8D1wgS/YX7i/n 05YqCe3T1WZBPOMGT+7NqWPqAKJFJB/GRASMkzQX5C/i61QFNrX9c2K/MtYA/jIyN0aT 3VS+UisLNESz3q8BEvX/aWSmtBWgez4ikrzV4UdA6zlXZIIh/3PY8H55kvAGBwaSzj25 mXJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rOVuOE+J; 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 w2-20020a170902e88200b00153b2d1654csi15614304plg.340.2022.04.05.19.19.01; Tue, 05 Apr 2022 19:19:18 -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=rOVuOE+J; 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 S1384553AbiDEOSM (ORCPT + 99 others); Tue, 5 Apr 2022 10:18:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239005AbiDEJdP (ORCPT ); Tue, 5 Apr 2022 05:33:15 -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 349A71D0FB; Tue, 5 Apr 2022 02:21:38 -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 E4FB7B81C6F; Tue, 5 Apr 2022 09:21:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FC95C385A2; Tue, 5 Apr 2022 09:21:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150495; bh=3TnHiDcoE4UN7piXzw8IEQIziQxDeP2KahwoBf8cuVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rOVuOE+JM5IFVUpNiJIaERhtcJghxBdC2+eh67aGBGovCJlw72BE1OrYeYhmG/bDY tsH+pkyATvWvEYw5Zv3SocE8meD35nQuHUiijuX1lBXvqlWU6+ll9EshiqbBoTrSTz cs5seFWpMK1oAj/9jD58wIPaWcdjGjNGTuWlHvoc= 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.15 075/913] spi: mxic: Fix the transmit path Date: Tue, 5 Apr 2022 09:18:57 +0200 Message-Id: <20220405070342.072193500@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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);