Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp255196pxx; Wed, 28 Oct 2020 04:13:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwElXbVCHrE9cp0NqsQNkPL36h5ZSFD6jTeMpTt1Gv6TXdRio/11OYUHKlsSDnkPqeNpD80 X-Received: by 2002:a17:906:9588:: with SMTP id r8mr7159000ejx.389.1603883606189; Wed, 28 Oct 2020 04:13:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603883606; cv=none; d=google.com; s=arc-20160816; b=vfN1Ie8t9/I5/neTkVoVZ0YlKWu8rgNOoc3KBsvDRbiadnfbE3NiJ58k1IqFbdOMN8 ULhQSOYndoo21uZ2/WcgT8iWDd6JeqG9G1W/Ydihqf4gkf1fHemrAdRx/iurKkEzHCLb QZurTAdXN8PIsNKm4p/g+h8+pKXr2qH9h8NtdzZ8OdY6V73wbajse64b3VJICMHwpyo0 KogydUT4jV/O568xc/sWRTAAzx0KEaJZORp2QeHpk4plBxEz/jpyXLc4fs50ztLLxSrD VGhJHbzEHDG5/m/2R2PrdAl7FZVY2DsXeg9VduUOtkvLX/3uMiU+hZ3C3pSt9SzInvFh 1SYA== 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=5qZRB6sgue2ZnXD0le6OXAivZ5KX+Ll1UBUQgr2lOh8=; b=CM8HmB6gOYL88ZTE7lsC0E8egA8s92+40FTqWAPImTGR81LuPZcr9/SXdEApko8Rp/ hkkYPmJpSts9Ye+bFlqTCyG0YXrE6g2DO4QDlF2nLjp3Vjk06xP5ZsHOiamtZdM63cWT yEkaRTK+P9UFFxv43z/wfFP72AgIzJKzDxNpwYu+I4HcrEvtlbSzsOUvt9FgnwohiAk6 hbmd+ZNBw8NynOVicONo4gd7XzX8sTzns+GX2wT3tHBk02QOxisJzkUbx52v7C7SWnGP 5vdw89+EA0LanitIFR9OX01XlEJ8MZ+SEMCSOzmF29KZsfBI9Xq6U2kxxeb9n+08Cmmq 7bKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="c3J/eYYn"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lg14si2653130ejb.82.2020.10.28.04.13.03; Wed, 28 Oct 2020 04:13:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="c3J/eYYn"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1787491AbgJ0PAK (ORCPT + 99 others); Tue, 27 Oct 2020 11:00:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:53742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1775997AbgJ0OxU (ORCPT ); Tue, 27 Oct 2020 10:53:20 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4D92C2225E; Tue, 27 Oct 2020 14:53:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810399; bh=/MpkjtwbIeJqfHde6uoQ+qIVHoHiphfOXqQaZX7nSp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c3J/eYYnmjKBQ+L3VhUeR752f19R2Rf94MUThFSjo6H8c1v7Cez8N89t5DVWd3rcU 4FX+GVKUNcAu3Q1gFM4im92ue6bbCY6KkhoSdD7Zz812w9VzCEg5MRdZArFqRECLwe FnPX/n7vTgBEvBr8Me4xK+f1jS998wWMeT6VjWqQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brad Bishop , Eddie James , Joel Stanley , Mark Brown , Sasha Levin Subject: [PATCH 5.8 126/633] spi: fsi: Fix use of the bneq+ sequencer instruction Date: Tue, 27 Oct 2020 14:47:49 +0100 Message-Id: <20201027135528.610555087@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Brad Bishop [ Upstream commit 7909eebb2bea7fdbb2de0aa794cf29843761ed5b ] All of the switches in N2_count_control in the counter configuration are required to make the branch if not equal and increment command work. Set them when using bneq+. A side effect of this mode requires a dummy write to TDR when both transmitting and receiving otherwise the controller won't start shifting receive data. It is likely not possible to avoid TDR underrun errors in this mode and they are harmless, so do not check for them. Fixes: bbb6b2f9865b ("spi: Add FSI-attached SPI controller driver") Signed-off-by: Brad Bishop Signed-off-by: Eddie James Reviewed-by: Joel Stanley Signed-off-by: Joel Stanley Link: https://lore.kernel.org/r/20200909222857.28653-4-eajames@linux.ibm.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-fsi.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-fsi.c b/drivers/spi/spi-fsi.c index 8f64af0140e09..bb18b407cdcf3 100644 --- a/drivers/spi/spi-fsi.c +++ b/drivers/spi/spi-fsi.c @@ -29,6 +29,10 @@ #define SPI_FSI_ERROR 0x0 #define SPI_FSI_COUNTER_CFG 0x1 #define SPI_FSI_COUNTER_CFG_LOOPS(x) (((u64)(x) & 0xffULL) << 32) +#define SPI_FSI_COUNTER_CFG_N2_RX BIT_ULL(8) +#define SPI_FSI_COUNTER_CFG_N2_TX BIT_ULL(9) +#define SPI_FSI_COUNTER_CFG_N2_IMPLICIT BIT_ULL(10) +#define SPI_FSI_COUNTER_CFG_N2_RELOAD BIT_ULL(11) #define SPI_FSI_CFG1 0x2 #define SPI_FSI_CLOCK_CFG 0x3 #define SPI_FSI_CLOCK_CFG_MM_ENABLE BIT_ULL(32) @@ -61,7 +65,7 @@ #define SPI_FSI_STATUS_RDR_OVERRUN BIT_ULL(62) #define SPI_FSI_STATUS_RDR_FULL BIT_ULL(63) #define SPI_FSI_STATUS_ANY_ERROR \ - (SPI_FSI_STATUS_ERROR | SPI_FSI_STATUS_TDR_UNDERRUN | \ + (SPI_FSI_STATUS_ERROR | \ SPI_FSI_STATUS_TDR_OVERRUN | SPI_FSI_STATUS_RDR_UNDERRUN | \ SPI_FSI_STATUS_RDR_OVERRUN) #define SPI_FSI_PORT_CTRL 0x9 @@ -238,6 +242,7 @@ static int fsi_spi_sequence_transfer(struct fsi_spi *ctx, int rc; u8 len = min(transfer->len, 8U); u8 rem = transfer->len % len; + u64 cfg = 0ULL; loops = transfer->len / len; @@ -258,8 +263,14 @@ static int fsi_spi_sequence_transfer(struct fsi_spi *ctx, if (loops > 1) { fsi_spi_sequence_add(seq, SPI_FSI_SEQUENCE_BRANCH(idx)); - rc = fsi_spi_write_reg(ctx, SPI_FSI_COUNTER_CFG, - SPI_FSI_COUNTER_CFG_LOOPS(loops - 1)); + cfg = SPI_FSI_COUNTER_CFG_LOOPS(loops - 1); + if (transfer->rx_buf) + cfg |= SPI_FSI_COUNTER_CFG_N2_RX | + SPI_FSI_COUNTER_CFG_N2_TX | + SPI_FSI_COUNTER_CFG_N2_IMPLICIT | + SPI_FSI_COUNTER_CFG_N2_RELOAD; + + rc = fsi_spi_write_reg(ctx, SPI_FSI_COUNTER_CFG, cfg); if (rc) return rc; } @@ -275,6 +286,7 @@ static int fsi_spi_transfer_data(struct fsi_spi *ctx, { int rc = 0; u64 status = 0ULL; + u64 cfg = 0ULL; if (transfer->tx_buf) { int nb; @@ -312,6 +324,16 @@ static int fsi_spi_transfer_data(struct fsi_spi *ctx, u64 in = 0ULL; u8 *rx = transfer->rx_buf; + rc = fsi_spi_read_reg(ctx, SPI_FSI_COUNTER_CFG, &cfg); + if (rc) + return rc; + + if (cfg & SPI_FSI_COUNTER_CFG_N2_IMPLICIT) { + rc = fsi_spi_write_reg(ctx, SPI_FSI_DATA_TX, 0); + if (rc) + return rc; + } + while (transfer->len > recv) { do { rc = fsi_spi_read_reg(ctx, SPI_FSI_STATUS, -- 2.25.1