Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp734083pxb; Tue, 5 Apr 2022 20:56:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVLb7ak/JxMW1o6CfeXszi9bt8V6wvujMqy/6t9NFnxAk4st8gzwVd5UkJzcK4k44BiGtO X-Received: by 2002:aa7:888e:0:b0:4fd:96f6:7f28 with SMTP id z14-20020aa7888e000000b004fd96f67f28mr6841324pfe.0.1649217364444; Tue, 05 Apr 2022 20:56:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649217364; cv=none; d=google.com; s=arc-20160816; b=lLV+jzAMn/VERJXArZF5kILTYBlHDm9hYDTF16wiya0VsVWLV0pfsKTFt5nTtmh0ep hljBPfUtRLgkaPkVi/myQJrUHuHdaXd0LP9vdAj+u4uDlRfNxNTf1PUd17Oxd4SCOIZM lnL+nGr3LIu0b9vNQC27tXgeG2wMgKHisaKXmuDThk0BlGDqqwXK26UZsORjnKPlpqUs F1HTTsrH8bd83J9fp2seu5SfIO5iiNED13frK7kC53zj6aC2WeVj6chkKz7M2M+I52g+ r3vVjYhn3yLCuTUNLZZ0f9HZUbsGLPyXmZh7FuWUZNKb8DFFP5O0qb23rysyXkhfxw8I FX5Q== 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=qoQynnyI62lMIBIE9PnK+bVnZAt8vu2k/Bc/QP58Qlyb8mi1/eEZNR0a/2/yFebkko wUuPbS4MpX5E2XqJ83CodZaoslmuSl3URfeOjb09ZimZ9yhoXQEdaLCJvgSLjtf8hzgw eos6sh+KD4s2VVcG9RARl/g93T/NqB5iO0t5t8Je5kOxOvye6Gvwi9gODURJut+RTzBw mrB2Ze6DJGpFZJ7HAmHKShwfrgDDjNZ3GO/9RebS60KD6CtECH/nGkdSmpNS4cls3vpX aHPwEfaz8efjTq4+eyIlRL2SZebH1dBb9hdlzp1o/40oznKWGbruy5Tdj4CAYzpJlaln 3NnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qeZblR0D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i66-20020a628745000000b004fa3a8e0091si13802111pfe.328.2022.04.05.20.56.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 20:56:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qeZblR0D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 01C97215BF2; Tue, 5 Apr 2022 20:31:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232119AbiDEHtC (ORCPT + 99 others); Tue, 5 Apr 2022 03:49:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232089AbiDEHpy (ORCPT ); Tue, 5 Apr 2022 03:45:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEC99985AA; Tue, 5 Apr 2022 00:41:39 -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 6CD6D6169A; Tue, 5 Apr 2022 07:41:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77078C340EE; Tue, 5 Apr 2022 07:41:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649144498; bh=3TnHiDcoE4UN7piXzw8IEQIziQxDeP2KahwoBf8cuVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qeZblR0DjPUFxkzw5YTo0I9qO6VHZVRuj6rHWgsfqLU3H6PSk1PPJXxEF75UmcXFn tZ4zRyfoA1cqEq7isMonI9yQTyJxycY1eZTlfNNHtN940YJ0yDinftsXLO79BK0ONT iiBAEDVQZvJG1BNYFXkv7UfUCkv4WwYahZPG3fek= 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.17 0067/1126] spi: mxic: Fix the transmit path Date: Tue, 5 Apr 2022 09:13:34 +0200 Message-Id: <20220405070409.536027954@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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);