From patchwork Tue Dec 10 09:27:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Yanovich X-Patchwork-Id: 3316761 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 2E3639F37A for ; Tue, 10 Dec 2013 09:28:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 69779201D3 for ; Tue, 10 Dec 2013 09:28:36 +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 08F0C201C8 for ; Tue, 10 Dec 2013 09:28:35 +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 1VqJc2-0005jl-31; Tue, 10 Dec 2013 09:28:18 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VqJbz-0001Qs-LE; Tue, 10 Dec 2013 09:28:15 +0000 Received: from mail-la0-x22b.google.com ([2a00:1450:4010:c03::22b]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VqJbv-0001PK-TM for linux-arm-kernel@lists.infradead.org; Tue, 10 Dec 2013 09:28:13 +0000 Received: by mail-la0-f43.google.com with SMTP id n7so2507374lam.30 for ; Tue, 10 Dec 2013 01:27:49 -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:in-reply-to:references; bh=wZq3Xxr1KEH+XbWYDXMO8CDz4d/Q+QE9+SY5R+YFEoA=; b=B/l/AEsnUeSxDW0CByLCSIRTMJThqVsruNisd4/uyn7DgHYNhdBYrmoA8rPQoSzG+w IRzJX7z9mSUpZtWohfVvZpxKHb+yE/xHFBQrNP9R5sURqU2YCx1rcwcC8BvCjXCG9XeU FGueYJMfv/vUeLWwl6BQlTypQbT60BDfneziObvCI9KYt2gRrxtaIGxsZEBAI2IFcz+t 4wjYBD/+pg4fT3datUc887C2I8iFlqAgU77dt3FnWbYd8m2NLHxbEbD4eMc4iAET7p3x fgH3aTeKzq1w6k7qFnLuvk7GAm9N+6OxjG6yQ9U3CGMlcrmcY6Dk5MGFSIj4SxpY2vID zGOA== X-Received: by 10.152.234.75 with SMTP id uc11mr7608721lac.30.1386667669330; Tue, 10 Dec 2013 01:27:49 -0800 (PST) Received: from host5.omatika.ru (0893675324.static.corbina.ru. [95.31.1.192]) by mx.google.com with ESMTPSA id sd11sm20490872lab.2.2013.12.10.01.27.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Dec 2013 01:27:48 -0800 (PST) From: Sergei Ianovich To: linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 08/20] mmc: host: pxamci: switch over to dmaengine use Date: Tue, 10 Dec 2013 13:27:37 +0400 Message-Id: <1386667657-26355-1-git-send-email-ynvich@gmail.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1375889649-14638-9-git-send-email-zonque> References: <1375889649-14638-9-git-send-email-zonque> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131210_042812_102351_0DC43176 X-CRM114-Status: GOOD ( 17.49 ) 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 }, };