mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jules Maselbas <jmaselbas@kalray.eu>
To: barebox@lists.infradead.org
Cc: Jules Maselbas <jmaselbas@kalray.eu>
Subject: [PATCH v3 6/7] mci: sdhci: Force DMA update to the next block boundary
Date: Fri, 18 Aug 2023 16:22:43 +0200	[thread overview]
Message-ID: <20230818142244.17157-6-jmaselbas@kalray.eu> (raw)
In-Reply-To: <20230818142244.17157-1-jmaselbas@kalray.eu>

Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 drivers/mci/sdhci.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/mci/sdhci.c b/drivers/mci/sdhci.c
index 4aca3af5aa..b0b83bfaa9 100644
--- a/drivers/mci/sdhci.c
+++ b/drivers/mci/sdhci.c
@@ -279,8 +279,20 @@ int sdhci_transfer_data_dma(struct sdhci *sdhci, struct mci_data *data,
 			goto out;
 		}
 
+		/*
+		 * We currently don't do anything fancy with DMA
+		 * boundaries, but as we can't disable the feature
+		 * we need to at least restart the transfer.
+		 *
+		 * According to the spec sdhci_readl(host, SDHCI_DMA_ADDRESS)
+		 * should return a valid address to continue from, but as
+		 * some controllers are faulty, don't trust them.
+		 */
 		if (irqstat & SDHCI_INT_DMA) {
-			u32 addr = sdhci_read32(sdhci, SDHCI_DMA_ADDRESS);
+			int boundary_cfg = (sdhci->sdma_boundary >> 12) & 0x7;
+			dma_addr_t boundary_size = 4096 << boundary_cfg;
+			/* Force update to the next DMA block boundary. */
+			dma = (dma & ~(boundary_size - 1)) + boundary_size;
 
 			/*
 			 * DMA engine has stopped on buffer boundary. Acknowledge
-- 
2.41.0




  parent reply	other threads:[~2023-08-18 14:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18 14:22 [PATCH v3 1/7] mci: sdhci: Set 8-bit host caps Jules Maselbas
2023-08-18 14:22 ` [PATCH v3 2/7] mci: sdhci: Add registers defines Jules Maselbas
2023-08-18 14:22 ` [PATCH v3 3/7] mci: sdhci: Actually return the error code instead of 0 Jules Maselbas
2023-08-18 14:22 ` [PATCH v3 4/7] mci: sdhci: Add sd host v4 mode Jules Maselbas
2023-08-18 14:22 ` [PATCH v3 5/7] mci: sdhci: Add 64-bit DMA addressing suport for V4 mode Jules Maselbas
2023-08-18 14:22 ` Jules Maselbas [this message]
2023-08-18 14:22 ` [PATCH v3 7/7] mci: Add dwcmshc-sdhci driver Jules Maselbas
2023-08-21  5:59 ` [PATCH v3 1/7] mci: sdhci: Set 8-bit host caps Sascha Hauer
2023-08-24 13:26 ` Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230818142244.17157-6-jmaselbas@kalray.eu \
    --to=jmaselbas@kalray.eu \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox