summaryrefslogtreecommitdiff
path: root/drivers/mmc
diff options
context:
space:
mode:
authorSubhash Jadavani <subhashj@codeaurora.org>2014-09-02 18:02:57 -0700
committerSubhash Jadavani <subhashj@codeaurora.org>2016-05-31 15:28:16 -0700
commit8cd010a89a5207965584aa1b716591ccc9c7f525 (patch)
treef6653b1bb8e2a6a42c31fa812c816100c05376bd /drivers/mmc
parentd69edcbcaed2001b9c305a2b8668dc0599801f2a (diff)
mmc: host: sdhci: don't queue zero length descriptor
If zero length ADMA descriptor with "Tran" attribute is queued to ADMA descriptor table then host controller ADMA engine might get stuck. Currently we are seeing zero length descriptor getting queued in for SDIO transactions: SDHCi driver requires that any data buffer address should be 4-byte aligned for 32-bit ADMA and 8-bytes aligned for 64-bit ADMA. For 64-bit ADMA, it forces 8-byte alignment for any data buffer addresses. This aligment requirement is not an issue with eMMC/SD cards as their transactions are always in multiple of 512-bytes (block size) and hence sdhci driver would always get the data buffers whose address is properly aligned. SDIO can have transactions less than 512-bytes. Hence its quite possible for driver to receives data buffer addresses which are not properly aligned. And if they are not aligned, SDHCi driver bounces the non-aligned bytes to pre-allocated aligned buffer until the rest of the data buffer becomes aligned. But this logic has a bug where after moving the non-aligned number of bytes to aligned buffer, it assumes that we will always be left with non-zero number of bytes in original data buffer and hence driver ends up queuing one more descriptor which can be of zero length. Fix this by checking for the remaining data length before queuing up the next descriptor. Change-Id: I7af77b2a2661c00f2b1da47953717b1506bdba83 Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org> [subhashj@codeaurora.org: fixed merge conflicts] Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/host/sdhci.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 2b34aec58c2c..572555876643 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -626,9 +626,11 @@ static int sdhci_adma_table_pre(struct sdhci_host *host,
BUG_ON(len > 65536);
- /* tran, valid */
- sdhci_adma_write_desc(host, desc, addr, len, ADMA2_TRAN_VALID);
- desc += host->desc_sz;
+ if (len) {
+ /* tran, valid */
+ sdhci_adma_write_desc(host, desc, addr, len, ADMA2_TRAN_VALID);
+ desc += host->desc_sz;
+ }
/*
* If this triggers then we have a calculation bug