Received: by 10.192.165.156 with SMTP id m28csp69774imm; Tue, 10 Apr 2018 16:37:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/R+GEyOjJGJGwOR5xR/vW6JXhdsf4h9MwWCi5XIT6WmcYgOeAYXrwJTgYB9LRZWyGZcFrt X-Received: by 2002:a17:902:2f03:: with SMTP id s3-v6mr2576331plb.274.1523403460392; Tue, 10 Apr 2018 16:37:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523403460; cv=none; d=google.com; s=arc-20160816; b=YoX0oOnglMOHfEMpApb2K8vVwkUojkavgK3M2tnSYIxmd+82KBjewvDTANQTr9Q1R7 jAlgORSXgzwD0sHcIBmge9RQOTXrGL+oOv8sum2SgOJ19X7rFTHTFca4Hixcbp1xyFRH WCBdwcOQRx7Nz7sI4yLUq6PaE2NDq1TUAXdYBgJNYWw4+OSR2TR3Px5eSwJe4KMUMqLW bJFjAvzC4b4zrDMC4x1Ott3tRW/55KGdlW5Y+SJVa9DzByFH9fUV8sFZMrB2AUVjhQrG fcrGf4DHUy7a4g5M092EcXt9fHWYCwX7gatbSkZ+4cFGg3sm8/GL8x/Bi+cIqOIrASrR JsGw== 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=CbSgfOdMZAQ4MOsO1ZYg65FnSEJdOGpLOAk/zUvPdfc=; b=i/dAoCuw8Si87ZBOYMqgUrvqALzCxHglblm2uM2We6ZiOTpkai2zIgpK5kf36kvu5o lkQS59qUzmg7fWsHH8x2sYyOdibR9oItNsLoRlIfHYOm3mGcMRQjqvTyzdpDqIzSKWlX kVdIQyNcg7blJu0bNS9491PpLGd1BC+4DFM0xMaPoKlQT3YP2/aEfTboX8m92HArTBYI pjJyTx+iF3OxuI0ATLUvy8JZek217qtb/qL9yqnJW64nOy/j4xifh4xm2JhO0JbKOnOy OiLaAP3Arocy4OcJ15U2ZAXUqwJF/aPNDJuAuhZZgorxyVVYgaC3Z3A2wR724z08Lmgg oJBA== 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 h13si345080pgs.525.2018.04.10.16.37.04; Tue, 10 Apr 2018 16:37:40 -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 S1754043AbeDJW21 (ORCPT + 99 others); Tue, 10 Apr 2018 18:28:27 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:39088 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753982AbeDJW2Y (ORCPT ); Tue, 10 Apr 2018 18:28:24 -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 1EE83D16; Tue, 10 Apr 2018 22:28:21 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Mark Brown , Sasha Levin Subject: [PATCH 4.15 038/168] spi: sh-msiof: Fix timeout failures for TX-only DMA transfers Date: Wed, 11 Apr 2018 00:23:00 +0200 Message-Id: <20180410212801.816711702@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212800.144079021@linuxfoundation.org> References: <20180410212800.144079021@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.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Geert Uytterhoeven [ Upstream commit 89434c3c35081439627baa2225622d5bd12242fe ] When using RX (with or without TX), the DMA interrupt triggers completion when the RX FIFO has been emptied, i.e. after the full transfer has finished. However, when using TX without RX, the DMA interrupt triggers completion as soon as the DMA engine has filled the TX FIFO, i.e. before the full transfer has finished. Then sh_msiof_modify_ctr_wait() will spin until the transfer has really finished and the TFSE bit is cleared, for at most 1 ms. For slow speeds and/or large transfers, this may cause timeouts and transfer failures: spi_sh_msiof e6e10000.spi: failed to shut down hardware 74x164 spi2.0: SPI transfer failed: -110 spi_master spi2: failed to transfer one message from queue 74x164 spi2.0: Failed writing: -110 Fix this by waiting explicitly until the TX FIFO has been emptied. Based on a patch in the BSP by Hiromitsu Yamasaki. Signed-off-by: Geert Uytterhoeven Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-sh-msiof.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) --- a/drivers/spi/spi-sh-msiof.c +++ b/drivers/spi/spi-sh-msiof.c @@ -797,11 +797,21 @@ static int sh_msiof_dma_once(struct sh_m goto stop_dma; } - /* wait for tx fifo to be emptied / rx fifo to be filled */ + /* wait for tx/rx DMA completion */ ret = sh_msiof_wait_for_completion(p); if (ret) goto stop_reset; + if (!rx) { + reinit_completion(&p->done); + sh_msiof_write(p, IER, IER_TEOFE); + + /* wait for tx fifo to be emptied */ + ret = sh_msiof_wait_for_completion(p); + if (ret) + goto stop_reset; + } + /* clear status bits */ sh_msiof_reset_str(p);