linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 08/20] mmc: host: pxamci: switch over to dmaengine use
@ 2013-12-10  9:24 Sergei Ianovich
  0 siblings, 0 replies; 8+ messages in thread
From: Sergei Ianovich @ 2013-12-10  9:24 UTC (permalink / raw)
  To: linux-arm-kernel

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
 	},
 };
 

^ permalink raw reply related	[flat|nested] 8+ messages in thread
[parent not found: <1375889649-14638-9-git-send-email-zonque>]
* [PATCH 00/20] ARM: pxa: move core and drivers to dmaengine
@ 2013-08-07 15:33 Daniel Mack
  2013-08-07 15:33 ` [PATCH 08/20] mmc: host: pxamci: switch over to dmaengine use Daniel Mack
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Mack @ 2013-08-07 15:33 UTC (permalink / raw)
  To: linux-arm-kernel

I've been working on teaching the mmp-pdma driver more functions and
porting tree-wide scattered pxa specific drivers over to dmaengine
implementations. I posted the first round of patches for mmp-pdma here:

  http://marc.info/?l=linux-arm-kernel&m=137587082530228


With the following patches applied, I can boot a PXA3xx board boot with
all DMA runtime information determined from DT, using pxa3xx-nand,
pxamci and audio components (cyclic DMA).

However, the transition is quite intrusive and spans across several
subsystem, and due to the nature of the current pxa DMA implementation,
it cannot be gap-less. All drivers currently request an exclusive
channel via code in arch/arm/plat-pxa/dma.c and then do direct register
modifications regarding their obtained channel. We can't allow this
with the mmp-pdma driver of course, and I also have no idea how to
provide sane stubs for the existing hooks which end up in dmaengine
calls.

Hence, all drivers have to be ported over in one series, and all these
changes should be merged by one pull request eventually in order to
prevent both build and functional breakage. Haojian's repository seems
most suitable for that, as he's the PXA maintainer.

What I currently got with respect to existing drivers is the following:

 * pxa3xx-nand:
     ported (with an amended and rebased patch from Zhangfei Gao)
     and successfully tested.

 * pxamci (mmc):
     ported and successfully tested

 * pxa-pcm-lib (audio) and pxa-ssp:
     ported and successfully tested

 * spi:
     Code to make this driver compatible with dmaengine was already
     provided by Mika Westerberg, so we can now just purge the legacy
     bits. I personally only compile-tested this one.

 * pxa-serial:
     #if0'ed legacy was removed that wouldn't even compile when
     enabled. This can be re-done at some point if anyone's interested.

 * pata-pxa:
     I ported the driver over which was simple and straight forward,
     but I lack hardware to actually test it. Maybe Marek Vasut, the
     original author can help here?

 * pxaficp_ir (IRDA):
     I also ported this driver, but I can't test it either. Someone
     with access to hardware would greatly help here with a quick test.

 * smsc911x:
     There are three(!) SMSC 911x driver in the tree right now, and two
     of them have code for PXA-DMA. I'm not sure which of these are
     actually actively used in DMA mode, but I blindly ported over the
     code and compile-tested it.

 * camera driver:
     I started the transition, but I'm not sure how much sense that
     makes without access to the hardware. I'd much appreciate if
     anyone could volunteer for this piece; I'll happily share what
     I got so far. Sascha, Sachin, Guennadi?


So, to summarize: pata-pxa, pxaficp_ir and smsc911x need testing,
and the camera driver still needs to be ported.


The transition path of my patch set is as follows:

 1. port over all the drivers individually, breaking them functionally
    because at runtime, they DMA channel allocation will fail. But they
    will compile.

 2. remove the init calls to the dma subsystem in both mach-pxa and
    mach-mmp (mach-mmp was only compile-tested) and instanciate the
    mmp-pdma device as regular platform_device.

 3. remove the old implementation including its header file that has
    served us so well for 12+ years. Sorry, Nicolas ;)

Regarding the procedure, my proposal is that many people give 
their Tested-by and Acked-by, I'll respin my series a couple of times
and eventually Haojian can take it.

Prerequisities:

  * Linux-3.11-rc4
  * Ezequiel Garcia's pxa3xx-patches:
	http://lists.infradead.org/pipermail/linux-mtd/2013-August/047862.html
  * My mmp-pdma patches:
	http://marc.info/?l=linux-arm-kernel&m=137587082530228

FWIW, the patches can also be found in this tree, but be aware that I
will rebase the commits frequently:

  https://github.com/zonque/linux/commits/pxa-dma



Thanks,
Daniel


Daniel Mack (19):
  mtd: pxa3xx-nand: use mmp_pdma_filter_fn and
    dma_request_slave_channel_compat
  ARM: pxa: ssp: add shortcut for &pdev->dev
  ARM: pxa: ssp: add DT bindings
  ARM: pxa: ssp: use devm_ functions
  tty: serial: pxa: remove old cruft
  spi: spi-pxa2xx: remove legacy PXA DMA bits
  mmc: host: pxamci: switch over to dmaengine use
  ata: pdata_pxa: migrate over to dmaengine usage
  net: irda: pxaficp_ir: switch to dmaengine
  net: smc91x.c: switch to generic buf-to-buf DMA offload
  net: smc911x.c: switch to dmaengine API
  ASoC: pxa: pxa-ssp: add DT bindings
  ASoC: pxa: use snd_dmaengine_dai_dma_data
  ASoC: pxa: pxa-ssp: set dma filter data from startup hook
  ASoC: pxa: add DT bindings for pxa2xx-pcm
  ASoC: pxa: pxa-pcm-lib: switch over to snd-soc-dmaengine-pcm
  ARM: pxa: register static mmp_pdma device
  ARM: mmp: register static mmp_pdma device
  ARM: pxa: remove old DMA implementation

Zhangfei Gao (1):
  mtd: pxa3xx-nand: replace pxa_request_dma with dmaengine

 .../devicetree/bindings/serial/mrvl,pxa-ssp.txt    |  43 ++
 .../devicetree/bindings/sound/mrvl,pxa-ssp.txt     |   7 +
 .../devicetree/bindings/sound/mrvl,pxa2xx-pcm.txt  |  15 +
 arch/arm/mach-mmp/mmp2.c                           |  11 +-
 arch/arm/mach-mmp/pxa168.c                         |  11 +-
 arch/arm/mach-mmp/pxa910.c                         |  11 +-
 arch/arm/mach-pxa/devices.c                        |  26 ++
 arch/arm/mach-pxa/devices.h                        |   1 +
 arch/arm/mach-pxa/include/mach/dma.h               |  21 -
 arch/arm/mach-pxa/pxa25x.c                         |   9 +-
 arch/arm/mach-pxa/pxa27x.c                         |   9 +-
 arch/arm/mach-pxa/pxa3xx.c                         |  11 +-
 arch/arm/plat-pxa/Makefile                         |   2 -
 arch/arm/plat-pxa/dma.c                            | 391 ----------------
 arch/arm/plat-pxa/include/plat/dma.h               |  85 ----
 arch/arm/plat-pxa/ssp.c                            | 144 +++---
 drivers/ata/pata_pxa.c                             | 172 +++-----
 drivers/mmc/host/pxamci.c                          | 188 ++++----
 drivers/mtd/nand/pxa3xx_nand.c                     | 130 +++---
 drivers/net/ethernet/smsc/smc911x.c                |  80 ++--
 drivers/net/ethernet/smsc/smc911x.h                |  83 ++--
 drivers/net/ethernet/smsc/smc91x.c                 |  40 +-
 drivers/net/ethernet/smsc/smc91x.h                 |  71 ++-
 drivers/net/irda/pxaficp_ir.c                      | 242 ++++++----
 drivers/spi/Kconfig                                |   9 +-
 drivers/spi/Makefile                               |   1 -
 drivers/spi/spi-pxa2xx-pxadma.c                    | 490 ---------------------
 drivers/spi/spi-pxa2xx.h                           |   6 +-
 drivers/tty/serial/pxa.c                           |  25 --
 include/linux/spi/pxa2xx_spi.h                     |   1 -
 include/sound/pxa2xx-lib.h                         |   8 -
 sound/arm/Kconfig                                  |   1 +
 sound/arm/pxa2xx-ac97.c                            |  26 +-
 sound/arm/pxa2xx-pcm-lib.c                         | 177 ++------
 sound/arm/pxa2xx-pcm.c                             |  15 +-
 sound/arm/pxa2xx-pcm.h                             |   9 +-
 sound/soc/pxa/mmp-pcm.c                            |   8 +-
 sound/soc/pxa/mmp-sspa.c                           |  11 +-
 sound/soc/pxa/pxa-ssp.c                            |  51 ++-
 sound/soc/pxa/pxa2xx-ac97.c                        |  67 +--
 sound/soc/pxa/pxa2xx-i2s.c                         |  28 +-
 sound/soc/pxa/pxa2xx-pcm.c                         |  43 +-
 42 files changed, 921 insertions(+), 1858 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/serial/mrvl,pxa-ssp.txt
 create mode 100644 Documentation/devicetree/bindings/sound/mrvl,pxa-ssp.txt
 create mode 100644 Documentation/devicetree/bindings/sound/mrvl,pxa2xx-pcm.txt
 delete mode 100644 arch/arm/mach-pxa/include/mach/dma.h
 delete mode 100644 arch/arm/plat-pxa/dma.c
 delete mode 100644 arch/arm/plat-pxa/include/plat/dma.h
 delete mode 100644 drivers/spi/spi-pxa2xx-pxadma.c

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-10-16 17:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-10  9:24 [PATCH 08/20] mmc: host: pxamci: switch over to dmaengine use Sergei Ianovich
     [not found] <1375889649-14638-9-git-send-email-zonque>
2013-12-10  9:27 ` Sergei Ianovich
2013-12-10 10:25   ` Sergei Ianovich
2013-12-10 10:48     ` Daniel Mack
2013-12-10 15:04       ` Sergei Ianovich
  -- strict thread matches above, loose matches on Subject: below --
2013-08-07 15:33 [PATCH 00/20] ARM: pxa: move core and drivers to dmaengine Daniel Mack
2013-08-07 15:33 ` [PATCH 08/20] mmc: host: pxamci: switch over to dmaengine use Daniel Mack
2014-10-15 18:32   ` Vasily Khoruzhick
2014-10-16 17:57     ` Vasily Khoruzhick

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).