Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1292777pxy; Sun, 1 Aug 2021 20:01:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSBAAGe+95l6dpPW8oYoDO0ZDHGCfyYRC+Sh0HGj9CPRizJd4uV+UoWVKg0HYcEu0NJ9Mw X-Received: by 2002:a05:6638:34aa:: with SMTP id t42mr12585984jal.128.1627873295872; Sun, 01 Aug 2021 20:01:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627873295; cv=none; d=google.com; s=arc-20160816; b=EnnezfAkpfDh14v5UzBhfGkc5wq3cYdIdemK2FiXWlY5NMaa5SRszKud2NnVoLogIK 2hjqPkCK33Iymg1h5vbNsAmMMl+vbfExq/1c5KcFA/8Hp8c/e4w2BXw8lewpv+DCMpp1 SosM4w3jc/E8o11F904ROQ5HkY1KzGy7SKaMfIJgsrkNDJoyzaX5Ih3RaS1adS46aZMa +efvyUwyhMcZ1Lt12wFDbXWejlWMHF1/02Z8Dnh6X7KTed0aRczWLZGyZxj2NekJfWwA ylF/Y0tAWxnq1+dbnL/oRDoSrRD6L95lMGn9FAIjbBwbGUyDQK9Dc7xfjVEuhoyehN3K VHKw== 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 :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=l3jwA3sv7LfeA88bUhgOgpW0zu8BYSUhLdnLV59eV+k=; b=Msqv1u6Upj3vyTewPc8OBkC95GflwmC5c+CDI0CkpM0e5BXpr0Bqyvx86HQPcRQODf 5qjl6ABkfBwMghzd71oXztlCya1+2Ik5dohP2Uy7kKSNYlGvuuM3ApSXgA7/9lIwsP5j Brk7Pg39+KIfovu95E3mVnnKlG17przS4l3tssyPQyEb3dtSdU3wZzqhmDzoDCvaeJZA u/soVPwhU4tNX/V98h+upn76SwECw31Pcm1wtt8DgqPYS+rR61Fvp0XsHiehKzI4gRrH Oa1LgX9hyRrKKE3kmghUEqOL7okp2eGVXPEDvpAI5NKU2XwtmgnT0YefqPM4HB8xvCF8 zD2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nN+LqWCq; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l15si11701553ios.94.2021.08.01.20.01.24; Sun, 01 Aug 2021 20:01:35 -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=@gmail.com header.s=20161025 header.b=nN+LqWCq; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231432AbhHBDAh (ORCPT + 99 others); Sun, 1 Aug 2021 23:00:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229908AbhHBDAg (ORCPT ); Sun, 1 Aug 2021 23:00:36 -0400 Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EECAAC06175F; Sun, 1 Aug 2021 20:00:26 -0700 (PDT) Received: by mail-ot1-x336.google.com with SMTP id z6-20020a9d24860000b02904d14e47202cso7538604ota.4; Sun, 01 Aug 2021 20:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=l3jwA3sv7LfeA88bUhgOgpW0zu8BYSUhLdnLV59eV+k=; b=nN+LqWCqdJi31kINH3VCdWbNQxabUcc6kCWZM/JDlZGdJS3mNFTdb5GfvIgONTNa0Z O6jGoRTIdJGUOfTBi0Fev2GSzQq9XD2Hxd2bVFvGctcmz0bMext+57L+gJyk6PyYW8p7 PVZOhhANlRCccizrYkr1uBsM4Sj5+mIT0x6yNEf/Lk1u8mTyByJOsJRtQtY+m/OtlU5z qvNcIO1MX0VPp29isyXQu8ZstXCqBpTWcR45/Lwkkkh8hcsytZ/vZuL15og1wIlbRlgh zV5bgBigCb4Wz6Z+OjO/mOJwT6Ws11MUXhhb2q3LZq3fpA/tRZCYqjrrQFq4i/s+Kg1c ryZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=l3jwA3sv7LfeA88bUhgOgpW0zu8BYSUhLdnLV59eV+k=; b=q5+WUfuMMD+u5PjxKkoGbfXt2SzmU6izHivvV3oVCzGpT6H/5ZcK0CgG5AXZ1AwK6R +dg1yq3T44/Ju0ttkbeM76OrNX7eFHJAtXjfNCl604L1m9Cs+okDm9FzwNbe35+J0ruH ncM18TB4ae0iSNVFwknWlN/B/ABLT4vwB07kXbV4n4j8e9xqRWoSJmiBPgu1wur/Cpvl RMOjG6UIXs+DXNNmtzUVhO/nrvWVK60+kgqIFEER34jZuPLy3m5QMfYvTOXKug1Sa96B /POfGP025/xDgrmq/7WbfMJbQ5y5uMNgnq+0nnfhWGqljlrhB13TTD1P0/9noM381Ndc M9dg== X-Gm-Message-State: AOAM532o9/LOvYZTYhOJQlsjLedGX3lDBSL0QVC6+2NDeTGC/qlBTkK9 10zrWqhWRqXYOS4HxSRd3U0= X-Received: by 2002:a05:6830:2696:: with SMTP id l22mr10773429otu.286.1627873226329; Sun, 01 Aug 2021 20:00:26 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id m35sm40242ooi.38.2021.08.01.20.00.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Aug 2021 20:00:25 -0700 (PDT) Sender: Guenter Roeck From: Guenter Roeck To: Mark Brown Cc: Matthias Brugger , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Guenter Roeck , Peter Hess , Frank Wunderlich , Tzung-Bi Shih , Hsin-Yi Wang Subject: [PATCH] spi: mediatek: Fix fifo transfer Date: Sun, 1 Aug 2021 20:00:23 -0700 Message-Id: <20210802030023.1748777-1-linux@roeck-us.net> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 3a70dd2d0503 ("spi: mediatek: fix fifo rx mode") claims that fifo RX mode was never handled, and adds the presumably missing code to the FIFO transfer function. However, the claim that receive data was not handled is incorrect. It was handled as part of interrupt handling after the transfer was complete. The code added with the above mentioned commit reads data from the receive FIFO before the transfer is started, which is wrong. This results in an actual transfer error on a Hayato Chromebook. Remove the code trying to handle receive data before the transfer is started to fix the problem. Fixes: 3a70dd2d0503 ("spi: mediatek: fix fifo rx mode") Cc: Peter Hess Cc: Frank Wunderlich Cc: Tzung-Bi Shih Cc: Hsin-Yi Wang Signed-off-by: Guenter Roeck --- drivers/spi/spi-mt65xx.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index 68dca8ceb3ad..7914255521c3 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -426,24 +426,15 @@ static int mtk_spi_fifo_transfer(struct spi_master *master, mtk_spi_prepare_transfer(master, xfer); mtk_spi_setup_packet(master); - cnt = xfer->len / 4; - if (xfer->tx_buf) + if (xfer->tx_buf) { + cnt = xfer->len / 4; 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; - if (xfer->tx_buf) { + 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->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.25.1