summaryrefslogtreecommitdiff
path: root/nuttx/drivers
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2013-09-08 10:38:01 -0700
committerpx4dev <px4@purgatory.org>2013-09-08 10:38:01 -0700
commitbc4503a998d8bb3567a59fa6821ba9bd1a3b97b4 (patch)
tree3eb797ae20cb63bf4150af4db0fb3557cc399eca /nuttx/drivers
parent514a5a12acbfcf6a5f7f31eaa871fe88ae16b06c (diff)
downloadpx4-nuttx-bc4503a998d8bb3567a59fa6821ba9bd1a3b97b4.tar.gz
px4-nuttx-bc4503a998d8bb3567a59fa6821ba9bd1a3b97b4.tar.bz2
px4-nuttx-bc4503a998d8bb3567a59fa6821ba9bd1a3b97b4.zip
Add an explicit preflight call for SDIO DMA operations, since we can't error out of the DMA setup (the card is already committed at that point).
Diffstat (limited to 'nuttx/drivers')
-rw-r--r--nuttx/drivers/mmcsd/mmcsd_sdio.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/nuttx/drivers/mmcsd/mmcsd_sdio.c b/nuttx/drivers/mmcsd/mmcsd_sdio.c
index 6d975ad63..3afed2a93 100644
--- a/nuttx/drivers/mmcsd/mmcsd_sdio.c
+++ b/nuttx/drivers/mmcsd/mmcsd_sdio.c
@@ -1277,6 +1277,22 @@ static ssize_t mmcsd_readsingle(FAR struct mmcsd_state_s *priv,
return -EPERM;
}
+ /*
+ * If we think we are going to perform a DMA transfer, make sure that we
+ * will be able to before we commit the card to the operation.
+ */
+#ifdef CONFIG_SDIO_DMA
+ if (priv->dma)
+ {
+ ret = SDIO_DMAPREFLIGHT(priv->dev, buffer, priv->blocksize);
+
+ if (ret != OK)
+ {
+ return ret;
+ }
+ }
+#endif
+
/* Verify that the card is ready for the transfer. The card may still be
* busy from the preceding write transfer. It would be simpler to check
* for write busy at the end of each write, rather than at the beginning of
@@ -1391,6 +1407,22 @@ static ssize_t mmcsd_readmultiple(FAR struct mmcsd_state_s *priv,
return -EPERM;
}
+ /*
+ * If we think we are going to perform a DMA transfer, make sure that we
+ * will be able to before we commit the card to the operation.
+ */
+#ifdef CONFIG_SDIO_DMA
+ if (priv->dma)
+ {
+ ret = SDIO_DMAPREFLIGHT(priv->dev, buffer, priv->blocksize);
+
+ if (ret != OK)
+ {
+ return ret;
+ }
+ }
+#endif
+
/* Verify that the card is ready for the transfer. The card may still be
* busy from the preceding write transfer. It would be simpler to check
* for write busy at the end of each write, rather than at the beginning of
@@ -1577,6 +1609,22 @@ static ssize_t mmcsd_writesingle(FAR struct mmcsd_state_s *priv,
return -EPERM;
}
+ /*
+ * If we think we are going to perform a DMA transfer, make sure that we
+ * will be able to before we commit the card to the operation.
+ */
+#ifdef CONFIG_SDIO_DMA
+ if (priv->dma)
+ {
+ ret = SDIO_DMAPREFLIGHT(priv->dev, buffer, priv->blocksize);
+
+ if (ret != OK)
+ {
+ return ret;
+ }
+ }
+#endif
+
/* Verify that the card is ready for the transfer. The card may still be
* busy from the preceding write transfer. It would be simpler to check
* for write busy at the end of each write, rather than at the beginning of
@@ -1695,6 +1743,22 @@ static ssize_t mmcsd_writemultiple(FAR struct mmcsd_state_s *priv,
return -EPERM;
}
+ /*
+ * If we think we are going to perform a DMA transfer, make sure that we
+ * will be able to before we commit the card to the operation.
+ */
+#ifdef CONFIG_SDIO_DMA
+ if (priv->dma)
+ {
+ ret = SDIO_DMAPREFLIGHT(priv->dev, buffer, priv->blocksize);
+
+ if (ret != OK)
+ {
+ return ret;
+ }
+ }
+#endif
+
/* Verify that the card is ready for the transfer. The card may still be
* busy from the preceding write transfer. It would be simpler to check
* for write busy at the end of each write, rather than at the beginning of