Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3712461pxv; Mon, 26 Jul 2021 10:01:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwb0BzN/jbsTXQLeB6I7Xx9E6BccP15qhlYLF/5FutOeSfcZcfK8hzcrfysGpM9qx3uuyu4 X-Received: by 2002:a05:6402:2899:: with SMTP id eg25mr22582902edb.13.1627318903081; Mon, 26 Jul 2021 10:01:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627318903; cv=none; d=google.com; s=arc-20160816; b=gm7U4x/778UDWwmhiVjfUsz+Ny7BoObkfOHlHo7U3w9mmEMWVIGkEt9PWT1GtoqtRk nahMV7CbsCb7P1u0N3NE/MWRpUsVBZOY232fWQznCOVKRZsDtJ4e790tSzAA6j+bmdjb EqhMmwMW6qDfJsE1S9IAqfCyP+jUQRoR+aUPul9yhVQ4HdxSSRaxtYHiaMFp405CpSND NmtdoR7ZOKk2oWkEUKbfSubnZauT7dHRGkKEM0CyvN3j6rkbKvCTNX1aJ1s9rNijE+7I TnsQqpraK2Bi0dZt6wVqayXBPyIlLtSUBPDv6UbkOpHZxKM3h6GpTHpNzWyIcrW++v63 kFdw== 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=v12RXM/xuvmx/WTuUlukAd343ts0hbE6RzYe3QHQahk=; b=X+Ox26gWKJdlqtrUSwqgpVuCpmqhpYRFR9ucfqB3zjyUlN2cKN//qD9xaI7DVzdIEr eHazxdEmtj+Tc4WPv3xMS2RUBbynTRrFCC4dV6mEQ82JvDCcYR986/0kd3UZZWkUxJY4 JdZvpvlv4rk+GoB3zA6Y6MHl0ygUXPKXpIRDCMG0sBVqGUThwgdBp7Z33mHCoA3QB11m 9+6LoVnBKK0Z6yl12HpHX2JORmnDnoDpWB5vOwbbSqLlZaIzPhelFi0SlOj2wu77Z+l4 rXZ31nN0pWXRDeFAivDMnoHtfR7e5iF6fScSj48qyjb8K7ooKRGMH6LYS6DaNX6KFAYd 2tLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=s1IE0oML; 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 ga14si441721ejc.427.2021.07.26.10.01.15; Mon, 26 Jul 2021 10:01:43 -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=s1IE0oML; 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 S235027AbhGZPhm (ORCPT + 99 others); Mon, 26 Jul 2021 11:37:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:35964 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237200AbhGZPVk (ORCPT ); Mon, 26 Jul 2021 11:21:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 419FD60FDA; Mon, 26 Jul 2021 16:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315328; bh=ImyeHq6NaMFDLaiQm8ANwqV7fxPDjf6ocC/OjeKZQiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s1IE0oMLY6U/y1MsrNo7hFji5YZtBMTBWEVtWvHji3Dio/ibQmhqlIH5A3nOjlmcF r3pVIwG/g8/S0tE5esASn1cDrJwADwXr0aYnD6SunvhkIRdZzHCNbf95MTjZnhYaCM 1rh953X2kIpCdDgrUbNT/aIOeuexnucv+PguzcnM= 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.10 053/167] spi: mediatek: fix fifo rx mode Date: Mon, 26 Jul 2021 17:38:06 +0200 Message-Id: <20210726153841.193546192@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153839.371771838@linuxfoundation.org> References: <20210726153839.371771838@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 5d643051bf3d..8f2d112f0b5d 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -434,13 +434,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