Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3672804pxv; Mon, 26 Jul 2021 09:08:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWn3iSwWpvGRBwzAXq6TY1Ovw1MQyyFW5Ll2WbOpNMm4j+QAfS4d0ubSr0aSuHpoptLQdL X-Received: by 2002:a17:906:4f01:: with SMTP id t1mr9405692eju.388.1627315697148; Mon, 26 Jul 2021 09:08:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627315697; cv=none; d=google.com; s=arc-20160816; b=y6mtVxt7fT+0EHum9+rdL/CXBTarjmFkb+mcCF/ep56PE3z6B1gsbbXhb4I4n+vzUl ROJxhVu60C1i92wRThRNJLz3KXaRaOybUJ388XVfinSx/bPBJaYHH+ZwBvY716aqUNp3 m46qyacem0etKosQfmmYSlJqC2TssMQGb5NckukTcDGNFFDmxmTY39nOibBUw0Oglp59 o9zFkpiJFY6HIq5GGfZnS8LGMKyinqZxpjMPFDVSC7Gd1KA+BgjSUcGSkrft6YHrTPCr 1R1HYpbtQJzqUgOtHMLD68R6cZMPEDYy8PdfcMaGB6Dn6MYF9ZHtzueAylT8LGLVBwlT qt5g== 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=dKBRHoDQZf4RL8/6vWA7FN8SSjSUj/kBWED7G18xttI=; b=kCd7VXlwd46y//R13YMPFvSViJQ4JO5v1hVMjgzeff8bR9MKwd8yRGfUvYroZM6+Pt P57Hb+XzOa1VKtC8asWXf8qZv2JcbO00AlVdyySdqTYkTRwbqrBn6A8jWT+7SvSx0Kv6 I+XMTc6M4C89Jit+sK7I3w3FR4oQUFyRjCdQSvKBKUkniyUverCHs9r8ai1+j7qkugCz fYlwwgCxzYFaOiel2XJS0IJ7PQs212odrbV5GlAXb3b9228m1pcZK+13RF0wAs3GW8lQ M2oye20+6zh1BkLmKlE2dhXoi4xxqO0M5gtWMJ+372mlc+OIYH97g159RhUwinI26xxG Opcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vwfzspk5; 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=pass (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 l3si252005ejd.313.2021.07.26.09.07.54; Mon, 26 Jul 2021 09:08:17 -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=@linuxfoundation.org header.s=korg header.b=vwfzspk5; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237662AbhGZPXp (ORCPT + 99 others); Mon, 26 Jul 2021 11:23:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:53272 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237454AbhGZPPr (ORCPT ); Mon, 26 Jul 2021 11:15:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0C29460F57; Mon, 26 Jul 2021 15:56:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627314961; bh=SEbEwsMH/Af4mYm6ntjbdU3aCmJFneFwqdmEwLIXWAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vwfzspk5p4GXybV88Fgvh2BJysJG0Z1iotTSlN3W3rNhkcYrYK1KRuXgwSVydfDi7 4G+AaBmfePXzuO4e+h5nq/gTwAhTqCvUwCFWPcBDe3jo48LGRDUP7cWcErvjh+GpbX O+DxQ0gjl547guqjnQxkKteL0DcjB4Up6mNDPLYs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Hess , Frank Wunderlich , Mark Brown , Sasha Levin Subject: [PATCH 5.4 035/108] spi: mediatek: fix fifo rx mode Date: Mon, 26 Jul 2021 17:38:36 +0200 Message-Id: <20210726153832.822618350@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153831.696295003@linuxfoundation.org> References: <20210726153831.696295003@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: Peter Hess [ Upstream commit 3a70dd2d050331ee4cf5ad9d5c0a32d83ead9a43 ] In FIFO mode were two problems: - RX mode was never handled and - in this case the tx_buf pointer was NULL and caused an exception fix this by handling RX mode in mtk_spi_fifo_transfer Fixes: a568231f4632 ("spi: mediatek: Add spi bus for Mediatek MT8173") Signed-off-by: Peter Hess Signed-off-by: Frank Wunderlich Link: https://lore.kernel.org/r/20210706121609.680534-1-linux@fw-web.de Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-mt65xx.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index 8acf24f7c5d4..81eac9fbd08c 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -427,13 +427,23 @@ static int mtk_spi_fifo_transfer(struct spi_master *master, mtk_spi_setup_packet(master); cnt = xfer->len / 4; - iowrite32_rep(mdata->base + SPI_TX_DATA_REG, xfer->tx_buf, cnt); + if (xfer->tx_buf) + iowrite32_rep(mdata->base + SPI_TX_DATA_REG, xfer->tx_buf, cnt); + + if (xfer->rx_buf) + ioread32_rep(mdata->base + SPI_RX_DATA_REG, xfer->rx_buf, cnt); remainder = xfer->len % 4; if (remainder > 0) { reg_val = 0; - memcpy(®_val, xfer->tx_buf + (cnt * 4), remainder); - writel(reg_val, mdata->base + SPI_TX_DATA_REG); + if (xfer->tx_buf) { + memcpy(®_val, xfer->tx_buf + (cnt * 4), remainder); + writel(reg_val, mdata->base + SPI_TX_DATA_REG); + } + if (xfer->rx_buf) { + reg_val = readl(mdata->base + SPI_RX_DATA_REG); + memcpy(xfer->rx_buf + (cnt * 4), ®_val, remainder); + } } mtk_spi_enable_transfer(master); -- 2.30.2