From patchwork Tue Dec 10 09:24:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Yanovich X-Patchwork-Id: 3316711 Return-Path: X-Original-To: patchwork-linux-arm@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 B3ACA9F37A for ; Tue, 10 Dec 2013 09:25:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 884EC201BA for ; Tue, 10 Dec 2013 09:25:30 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B09F820172 for ; Tue, 10 Dec 2013 09:25:25 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VqJZB-0005CA-4y; Tue, 10 Dec 2013 09:25:21 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VqJZ8-0001JP-MX; Tue, 10 Dec 2013 09:25:18 +0000 Received: from mail-la0-x22a.google.com ([2a00:1450:4010:c03::22a]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VqJZ3-0001HG-Hz for linux-arm-kernel@lists.infradead.org; Tue, 10 Dec 2013 09:25:16 +0000 Received: by mail-la0-f42.google.com with SMTP id ec20so2481606lab.29 for ; Tue, 10 Dec 2013 01:24:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=wZq3Xxr1KEH+XbWYDXMO8CDz4d/Q+QE9+SY5R+YFEoA=; b=bFfORAOpsx+i3f2g1Leg91iMISdsqxL9qck82F2l90Kp64Sqrn4tFkk8E9apMgKEIf vL68tURJDw6ymsjAcP5LK4BOjhHcFPg8fQ/opTSfDylohyR5WV444JQA8eal+7IYIlCU 7Jrezgabd5pkVPbvA9tNtPm9TV5hWduuueL11rbsdFR/Xqsl6mMIayCRWw/Sy4513XL0 wacdg9ppZYBkQsMEL2KDKd7/t2K0gjai2kyKnsT7tws7V6HgKkXtvrOhFPbegvURASWs 21BW7l+nXDVggUggY+4OLC6q8rZKp+T8VKIzStadalrcQE/Do9h+eRyiEALNjBj0v1Lp ZQfQ== X-Received: by 10.152.10.10 with SMTP id e10mr4647350lab.56.1386667488721; Tue, 10 Dec 2013 01:24:48 -0800 (PST) Received: from host5.omatika.ru (0893675324.static.corbina.ru. [95.31.1.192]) by mx.google.com with ESMTPSA id xl4sm20466575lac.9.2013.12.10.01.24.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Dec 2013 01:24:47 -0800 (PST) From: Sergei Ianovich To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 08/20] mmc: host: pxamci: switch over to dmaengine use Date: Tue, 10 Dec 2013 13:24:33 +0400 Message-Id: <1386667473-26243-1-git-send-email-ynvich@gmail.com> X-Mailer: git-send-email 1.8.4.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131210_042513_796578_40363A56 X-CRM114-Status: GOOD ( 17.00 ) X-Spam-Score: -1.9 (-) Cc: Sergei Ianovich , Arnd Bergmann , Daniel Mack X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SBL, RP_MATCHES_RCVD, T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no 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 Tested this patch rebased onto v3.13-rc2 In-kernel DMA driver was not modified. Below is the full diff against Daniel's version based on v3.11-rc5 My changes are at the line 572 to fix build failure and at the lines 630 and 780 to receive DMA channels from device tree. The device works in general, but it is slower than with the old DMA and it reports sporadic failures like that --->8--- [ 2848.451688] mmc0: DMA error on rx channel, status 1 [ 2848.458326] mmcblk0: error -5 transferring data, sector 7037462, nr 2, cmd response 0x900, card status 0x0 [ 2848.469245] end_request: I/O error, dev mmcblk0, sector 7037462 [ 2883.228720] mmc0: DMA error on rx channel, status 1 [ 2883.263844] mmcblk0: error -5 transferring data, sector 7163928, nr 8, cmd response 0x900, card status 0xb00 [ 2883.274240] mmcblk0: retrying using single block read --->8--- diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c index 7aa97eb..e5bafd2 100644 --- a/drivers/mmc/host/pxamci.c +++ b/drivers/mmc/host/pxamci.c @@ -85,7 +85,7 @@ struct pxamci_host { static inline void pxamci_init_ocr(struct pxamci_host *host) { #ifdef CONFIG_REGULATOR - host->vcc = regulator_get(mmc_dev(host->mmc), "vmmc"); + host->vcc = regulator_get_optional(mmc_dev(host->mmc), "vmmc"); if (IS_ERR(host->vcc)) host->vcc = NULL; @@ -555,6 +555,12 @@ static void pxamci_dma_irq(void *param) struct dma_tx_state state; enum dma_status status; struct dma_chan *chan; + unsigned long flags; + + spin_lock_irqsave(&host->lock, flags); + + if (!host->data) + goto out_unlock; if (host->data->flags & MMC_DATA_READ) chan = host->dma_chan_rx; @@ -563,14 +569,17 @@ static void pxamci_dma_irq(void *param) status = dmaengine_tx_status(chan, host->dma_cookie, &state); - if (likely(status == DMA_SUCCESS)) { + if (likely(status == DMA_COMPLETE)) { writel(BUF_PART_FULL, host->base + MMC_PRTBUF); } else { - pr_err("%s: DMA error on %s channel\n", mmc_hostname(host->mmc), - host->data->flags & MMC_DATA_READ ? "rx" : "tx"); + pr_err("%s: DMA error on %s channel, status %i\n", mmc_hostname(host->mmc), + host->data->flags & MMC_DATA_READ ? "rx" : "tx", status); host->data->error = -EIO; pxamci_data_done(host, 0); } + +out_unlock: + spin_unlock_irqrestore(&host->lock, flags); } static irqreturn_t pxamci_detect_irq(int irq, void *devid) @@ -618,11 +627,46 @@ static int pxamci_of_init(struct platform_device *pdev) return 0; } + +static int pxamci_of_init_dma(struct platform_device *pdev, + struct pxamci_host *host) +{ + struct device_node *np = pdev->dev.of_node; + u32 tmp; + int i; + int ret; + + i = of_property_match_string(np, "dma-names", "rx"); + if (i < 0) + return i; + + ret = of_property_read_u32_index(np, "dmas", 2 * i + 1, &tmp); + if (ret < 0) + return ret; + host->dma_drcmrrx = tmp; + + i = of_property_match_string(np, "dma-names", "tx"); + if (i < 0) + return i; + + ret = of_property_read_u32_index(np, "dmas", 2 * i + 1, &tmp); + if (ret < 0) + return ret; + host->dma_drcmrtx = tmp; + + return 0; +} #else static int pxamci_of_init(struct platform_device *pdev) { return 0; } + +static int pxamci_of_init_dma(struct platform_device *pdev, + struct pxamci_host *host) +{ + return -ENODATA; +} #endif static int pxamci_probe(struct platform_device *pdev) @@ -733,7 +777,7 @@ static int pxamci_probe(struct platform_device *pdev) platform_set_drvdata(pdev, mmc); - if (!pdev->dev.of_node) { + if (pxamci_of_init_dma(pdev, host) < 0) { dmarx = platform_get_resource(pdev, IORESOURCE_DMA, 0); if (!dmarx) { ret = -ENXIO; @@ -896,35 +940,6 @@ static int pxamci_remove(struct platform_device *pdev) return 0; } -#ifdef CONFIG_PM -static int pxamci_suspend(struct device *dev) -{ - struct mmc_host *mmc = dev_get_drvdata(dev); - int ret = 0; - - if (mmc) - ret = mmc_suspend_host(mmc); - - return ret; -} - -static int pxamci_resume(struct device *dev) -{ - struct mmc_host *mmc = dev_get_drvdata(dev); - int ret = 0; - - if (mmc) - ret = mmc_resume_host(mmc); - - return ret; -} - -static const struct dev_pm_ops pxamci_pm_ops = { - .suspend = pxamci_suspend, - .resume = pxamci_resume, -}; -#endif - static struct platform_driver pxamci_driver = { .probe = pxamci_probe, .remove = pxamci_remove, @@ -932,9 +947,6 @@ static struct platform_driver pxamci_driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, .of_match_table = of_match_ptr(pxa_mmc_dt_ids), -#ifdef CONFIG_PM - .pm = &pxamci_pm_ops, -#endif }, };