From: Ben Dooks <ben-linux@fluff.org>
To: linux-kernel@vger.kernel.org
Cc: drzeus-mmc@drzeus.cx, sdhci-devel@list.drzeus.cx,
Ben Dooks <ben-linux@fluff.org>
Subject: [patch 6/7] SDHCI: Check DMA for overruns at end of transfer
Date: Mon, 03 Nov 2008 20:09:50 +0000 [thread overview]
Message-ID: <20081103201010.820070757@fluff.org.uk> (raw)
In-Reply-To: 20081103200944.099353331@fluff.org.uk
[-- Attachment #1: simtec/s3c64xx/debug-card.patch --]
[-- Type: text/plain, Size: 1961 bytes --]
At the end of a transfer, check that the DMA engine in the
SDHCI controller actually did what it was meant to and didn't
overrun the end of the buffer.
This seems to be triggered by a timeout during an CMD25 (multiple block
write) to a card. The mmc_block module then issues a command to find out
how much data was moved and this seems to end up triggering this DMA
check. The result is the card's queue generates an OOPS as the stack has
been trampled on due to the extra data transfered.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Index: linux.git/drivers/mmc/host/sdhci.c
===================================================================
--- linux.git.orig/drivers/mmc/host/sdhci.c 2008-10-29 16:59:38.000000000 +0000
+++ linux.git/drivers/mmc/host/sdhci.c 2008-10-29 16:59:41.000000000 +0000
@@ -736,6 +736,23 @@ static void sdhci_set_transfer_mode(stru
writew(mode, host->ioaddr + SDHCI_TRANSFER_MODE);
}
+static void shdci_check_dma_overrun(struct sdhci_host *host, struct mmc_data *data)
+{
+ u32 dma_pos = readl(host->ioaddr + SDHCI_DMA_ADDRESS);
+ u32 dma_start = sg_dma_address(data->sg);
+ u32 dma_end = dma_start + data->sg->length;
+
+ /* Test whether we ended up moving more data than
+ * was originally requested. */
+
+ if (dma_pos <= dma_end)
+ return;
+
+ printk(KERN_ERR "%s: dma overrun, dma %08x, req %08x..%08x\n",
+ mmc_hostname(host->mmc), dma_pos,
+ dma_start, dma_end);
+}
+
static void sdhci_finish_data(struct sdhci_host *host)
{
struct mmc_data *data;
@@ -749,6 +766,8 @@ static void sdhci_finish_data(struct sdh
if (host->flags & SDHCI_USE_ADMA)
sdhci_adma_table_post(host, data);
else {
+ shdci_check_dma_overrun(host, data);
+
dma_unmap_sg(mmc_dev(host->mmc), data->sg,
data->sg_len, (data->flags & MMC_DATA_READ) ?
DMA_FROM_DEVICE : DMA_TO_DEVICE);
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
next prev parent reply other threads:[~2008-11-03 20:10 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-03 20:09 [patch 0/7] SDHCI support for Samsung SoC Ben Dooks
2008-11-03 20:09 ` [patch 1/7] SDHCI: Add timeout hooks Ben Dooks
2008-11-14 21:29 ` Pierre Ossman
2008-11-03 20:09 ` [patch 2/7] SDHCI: Print ADMA status and pointer on debug Ben Dooks
2008-11-14 21:29 ` Pierre Ossman
2008-11-03 20:09 ` [patch 3/7] SDHCI: Add set_ios hook Ben Dooks
2008-11-14 21:32 ` Pierre Ossman
2008-11-03 20:09 ` [patch 4/7] SDHCI: Add quirk for controller with no end-of-busy IRQ Ben Dooks
2008-11-14 21:41 ` Pierre Ossman
2008-11-15 23:58 ` Ben Dooks
2008-11-03 20:09 ` [patch 5/7] SDHCI: Samsung SDHCI (HSMMC) driver Ben Dooks
2008-11-14 21:48 ` Pierre Ossman
2008-11-16 0:03 ` Ben Dooks
2008-11-19 18:38 ` Pierre Ossman
2008-11-03 20:09 ` Ben Dooks [this message]
2008-11-03 21:12 ` [patch 6/7] SDHCI: Check DMA for overruns at end of transfer Henrique de Moraes Holschuh
2008-11-03 21:16 ` Ben Dooks
2008-11-04 1:28 ` Henrique de Moraes Holschuh
2008-11-10 9:58 ` Ben Dooks
2008-11-14 22:00 ` Pierre Ossman
2008-11-16 0:05 ` Ben Dooks
2008-11-19 18:41 ` Pierre Ossman
2008-11-03 20:09 ` [patch 7/7] SDHCI: Add change_clock callback for glue drivers Ben Dooks
2008-11-14 22:20 ` Pierre Ossman
2008-11-15 23:57 ` Ben Dooks
2008-11-19 18:43 ` Pierre Ossman
2008-11-10 10:57 ` [patch 0/7] SDHCI support for Samsung SoC Ben Dooks
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=20081103201010.820070757@fluff.org.uk \
--to=ben-linux@fluff.org \
--cc=drzeus-mmc@drzeus.cx \
--cc=linux-kernel@vger.kernel.org \
--cc=sdhci-devel@list.drzeus.cx \
/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