From bc4503a998d8bb3567a59fa6821ba9bd1a3b97b4 Mon Sep 17 00:00:00 2001 From: px4dev Date: Sun, 8 Sep 2013 10:38:01 -0700 Subject: 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). --- nuttx/drivers/mmcsd/mmcsd_sdio.c | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'nuttx/drivers') 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 -- cgit v1.2.3