From patchwork Fri Aug 2 22:33:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 2838206 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 422D89F492 for ; Fri, 2 Aug 2013 22:33:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6C0B920322 for ; Fri, 2 Aug 2013 22:33:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9665E20308 for ; Fri, 2 Aug 2013 22:33:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752766Ab3HBWdX (ORCPT ); Fri, 2 Aug 2013 18:33:23 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:54895 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751573Ab3HBWdX (ORCPT ); Fri, 2 Aug 2013 18:33:23 -0400 Received: by mail-lb0-f174.google.com with SMTP id w20so837447lbh.33 for ; Fri, 02 Aug 2013 15:33:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=to:subject:cc:from:organization:date:mime-version:content-type :content-transfer-encoding:message-id:x-gm-message-state; bh=7yp8SIxl98HaU0LruTExHOcVnWeftQtzrgQK5H4+eg4=; b=N78g11415g7w8R0bfAK8u4IaN1cbfB9m8ieasY15nMpMSl74VyJVD0XUejRoRRKIM0 ULVTiVdm5YbfKM+bdtt6SmeWs6iStdBomenEAEtUiOMErH65hKym3LaMOAbadFl0cQcT 8lYY4QqcpL2uf8aoehSS3KNM5Plpf4bXE+7uT3OC7TTqMUXJpX/ZGZdnXhwu5AqdwIPm Jh+B96XuHGiOgyGRMh2S8e/pk3lMSsXVbZQ55hcEMFV4KJxJcTa/z4V7byQMWGfQVlhy defcF3tQapsX3q3cBZSJhIILM8ZFHC4pZGwgm0Hw4xhxGX1kwpvDFlJ+o/7DKMfV4bbh hiZA== X-Received: by 10.152.28.162 with SMTP id c2mr3818003lah.45.1375482801611; Fri, 02 Aug 2013 15:33:21 -0700 (PDT) Received: from wasted.dev.rtsoft.ru (ppp91-76-146-79.pppoe.mtu-net.ru. [91.76.146.79]) by mx.google.com with ESMTPSA id b8sm4185013lah.0.2013.08.02.15.33.19 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 02 Aug 2013 15:33:20 -0700 (PDT) To: linux-mmc@vger.kernel.org, g.liakhovetski@gmx.de, ian@mnementh.co.uk, cjb@laptop.org Subject: [PATCH v2] tmio_mmc_dma: fix PIO fallback on SDHI Cc: linux-sh@vger.kernel.org, max.filippov@cogentembedded.com From: Sergei Shtylyov Organization: Cogent Embedded Date: Sat, 3 Aug 2013 02:33:28 +0400 MIME-Version: 1.0 Message-Id: <201308030233.29446.sergei.shtylyov@cogentembedded.com> X-Gm-Message-State: ALoCoQk0+aX0q3lken6I4frA3daDmxtaVXbFXLP0sPDyGlbs21Ss0nfmxDxErbPZMhOO7CfwVe04 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP I'm testing SH-Mobile SDHI driver in DMA mode with a new DMA controller using 'bonnie++' and getting DMA error after which the tmio_mmc_dma.c code falls back to PIO but all commands time out after that. It turned out that the fallback code calls tmio_mmc_enable_dma() with RX/TX channels already freed and pointers to them cleared, so that the function bails out early instead of clearing the DMA bit in the CTL_DMA_ENABLE register. The regression was introduced by commit 162f43e31c5a376ec16336e5d0ac973373d54c89 (mmc: tmio: fix a deadlock). Moving tmio_mmc_enable_dma() calls to the top of the PIO fallback code in tmio_mmc_start_dma_{rx|tx}() helps. Signed-off-by: Sergei Shtylyov Cc: stable@vger.kernel.org # 3.1+ Acked-by: Guennadi Liakhovetski --- The patch is against Chris Ball's 'mmc.git' repo, 'master' branch. Changes in version 2: - removed extra check from tmio_mmc_enable_dma(); - moved tmio_mmc_enable_dma() calls to the top of the PIO fallback code in tmio_mmc_start_dma_{rx|tx}(). drivers/mmc/host/tmio_mmc_dma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: renesas/drivers/mmc/host/tmio_mmc_dma.c =================================================================== --- renesas.orig/drivers/mmc/host/tmio_mmc_dma.c +++ renesas/drivers/mmc/host/tmio_mmc_dma.c @@ -104,6 +104,7 @@ static void tmio_mmc_start_dma_rx(struct pio: if (!desc) { /* DMA failed, fall back to PIO */ + tmio_mmc_enable_dma(host, false); if (ret >= 0) ret = -EIO; host->chan_rx = NULL; @@ -116,7 +117,6 @@ pio: } dev_warn(&host->pdev->dev, "DMA failed: %d, falling back to PIO\n", ret); - tmio_mmc_enable_dma(host, false); } dev_dbg(&host->pdev->dev, "%s(): desc %p, cookie %d, sg[%d]\n", __func__, @@ -185,6 +185,7 @@ static void tmio_mmc_start_dma_tx(struct pio: if (!desc) { /* DMA failed, fall back to PIO */ + tmio_mmc_enable_dma(host, false); if (ret >= 0) ret = -EIO; host->chan_tx = NULL; @@ -197,7 +198,6 @@ pio: } dev_warn(&host->pdev->dev, "DMA failed: %d, falling back to PIO\n", ret); - tmio_mmc_enable_dma(host, false); } dev_dbg(&host->pdev->dev, "%s(): desc %p, cookie %d\n", __func__,