Received: by 10.213.65.68 with SMTP id h4csp1720334imn; Mon, 19 Mar 2018 11:23:18 -0700 (PDT) X-Google-Smtp-Source: AG47ELuQ/GHwYfkhPW9dmRggzCtFL7U0LcFXIpNRx9sJ6WxsDaenSVop/5fNhH+KHhAYw9yzcWtd X-Received: by 2002:a17:902:b408:: with SMTP id x8-v6mr7879864plr.7.1521483798543; Mon, 19 Mar 2018 11:23:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521483798; cv=none; d=google.com; s=arc-20160816; b=QaRbj4Kaaq0lr62bKDGTSOsin3qj4Hq+8dp6+819CVFtZ37dex4LPHbhbiEp5fBgYm 4GDoJq/fIrZMgKkftG44c3Cv+gTflhIkCBv8sLARBMZ/9g6iZaUSkkwtZ7lJoXF+Pc0Z 6Y5KKTj1LdbV1nEYeWGyLu6pWwkPJWHVhlFzmWabpnOo9z/QkpW5JM861kY+v0MRpIaN PKoguO9oi5LzBTWVRcCW/5yBlArclheEHYr2BOZNWw4lamiUfLGvKKl2noJ3B7gCnNfT Av7PPuOEb3jtqcjN5Y7heAocCNW8fcuO34aAnb1SptzmxvdQWQtrktqQNwFK0Gy4+erR Kv/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=VihABIU+AsGwm09SqpznluNQSjyX30Z2qkCqymLygck=; b=XOjFVvTYr5ugBC9Lttp6nZvRfuZc72AbyprYv///oUJU4SOzVou94HO7MQOOWycsrv 3f4/tmaZlqKibhyLgtndwBHAszErufXrpnX5Hb6ycXoLSIP05KuBnELdonDNIjplu5mN EEjKYSAjcbm9Uw/P4A4mZiZkLaEGytEjwxp3Ntk+vrdDI0dy37eYrLhTwIw+JLOZ4G/l 5ZyuhX8ZlSYZnbDImsAyEyigjYoGyaAk6mxTOftMYuO/xurvjYrKm1fyoL59aqbPvAy5 XE6o/2RpctEidrOLyqgJnBQQtaYhUqtno2wh+TG93F3aaSlpuhpVF/dc/0EGRfTaY2Gq JP2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z23-v6si381864plo.272.2018.03.19.11.23.04; Mon, 19 Mar 2018 11:23:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031157AbeCSSVj (ORCPT + 99 others); Mon, 19 Mar 2018 14:21:39 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48096 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031117AbeCSSV2 (ORCPT ); Mon, 19 Mar 2018 14:21:28 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7E09D1258; Mon, 19 Mar 2018 18:21:27 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Brown , Akinobu Mita , Sasha Levin Subject: [PATCH 4.9 063/241] spi: omap2-mcspi: poll OMAP2_MCSPI_CHSTAT_RXS for PIO transfer Date: Mon, 19 Mar 2018 19:05:28 +0100 Message-Id: <20180319180753.809101115@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180319180751.172155436@linuxfoundation.org> References: <20180319180751.172155436@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Akinobu Mita [ Upstream commit 812613591cb652344186c4cd912304ed02138566 ] When running the spi-loopback-test with slower clock rate like 10 KHz, the test for 251 bytes transfer was failed. This failure triggered an spi-omap2-mcspi's error message "DMA RX last word empty". This message means that PIO for reading the remaining bytes due to the DMA transfer length reduction is failed. This problem can be fixed by polling OMAP2_MCSPI_CHSTAT_RXS bit in channel status register to wait until the receive buffer register is filled. Cc: Mark Brown Signed-off-by: Akinobu Mita Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-omap2-mcspi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -454,6 +454,8 @@ omap2_mcspi_rx_dma(struct spi_device *sp int elements = 0; int word_len, element_count; struct omap2_mcspi_cs *cs = spi->controller_state; + void __iomem *chstat_reg = cs->base + OMAP2_MCSPI_CHSTAT0; + mcspi = spi_master_get_devdata(spi->master); mcspi_dma = &mcspi->dma_channels[spi->chip_select]; count = xfer->len; @@ -549,8 +551,8 @@ omap2_mcspi_rx_dma(struct spi_device *sp if (l & OMAP2_MCSPI_CHCONF_TURBO) { elements--; - if (likely(mcspi_read_cs_reg(spi, OMAP2_MCSPI_CHSTAT0) - & OMAP2_MCSPI_CHSTAT_RXS)) { + if (!mcspi_wait_for_reg_bit(chstat_reg, + OMAP2_MCSPI_CHSTAT_RXS)) { u32 w; w = mcspi_read_cs_reg(spi, OMAP2_MCSPI_RX0); @@ -568,8 +570,7 @@ omap2_mcspi_rx_dma(struct spi_device *sp return count; } } - if (likely(mcspi_read_cs_reg(spi, OMAP2_MCSPI_CHSTAT0) - & OMAP2_MCSPI_CHSTAT_RXS)) { + if (!mcspi_wait_for_reg_bit(chstat_reg, OMAP2_MCSPI_CHSTAT_RXS)) { u32 w; w = mcspi_read_cs_reg(spi, OMAP2_MCSPI_RX0);