linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] mmci: calculate remaining bytes at error correctly
Date: Mon, 31 Jan 2011 10:27:26 +0000	[thread overview]
Message-ID: <20110131102726.GA8948@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <AANLkTi=HzzOkVmD9z=9uRdzHsaixFAfOv9BmxoY=u7uf@mail.gmail.com>

On Mon, Jan 31, 2011 at 11:17:42AM +0100, Linus Walleij wrote:
> 2011/1/30 Russell King - ARM Linux <linux@arm.linux.org.uk>:
> 
> > 8<----
> > Subject: [PATCH 1/2] ARM: mmci: complete the transaction on error
> >
> > When we encounter an error, make sure we complete the transaction
> > otherwise we'll leave the request dangling.
> >
> > Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> > ---
> > ?drivers/mmc/host/mmci.c | ? ?2 +-
> > ?1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
> > index b6fd6dc..175a623 100644
> > --- a/drivers/mmc/host/mmci.c
> > +++ b/drivers/mmc/host/mmci.c
> > @@ -319,7 +319,7 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
> > ? ? ? ?if (status & MCI_DATABLOCKEND)
> > ? ? ? ? ? ? ? ?dev_err(mmc_dev(host->mmc), "stray MCI_DATABLOCKEND interrupt\n");
> >
> > - ? ? ? if (status & MCI_DATAEND) {
> > + ? ? ? if (status & MCI_DATAEND || data->error) {
> > ? ? ? ? ? ? ? ?mmci_stop_data(host);
> 
> The hardware always sets the MCI_DATAEND bit if there is
> some error, so these flags always appear simultaneously, but
> it doesn't hurt to take some extra precaution, so

The hardware may do, but you won't see that here.  When we setup a
transfer, we do this:

        writel(readl(base + MMCIMASK0) & ~MCI_DATAENDMASK, base + MMCIMASK0);

When we receive an interrupt:

                status = readl(host->base + MMCISTATUS);
                status &= readl(host->base + MMCIMASK0);

                if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN|
                              MCI_RXOVERRUN|MCI_DATAEND|MCI_DATABLOCKEND) && data)
                        mmci_data_irq(host, data, status);

When we get to the end of a transfer:

        /*
         * If we run out of data, disable the data IRQs; this
         * prevents a race where the FIFO becomes empty before
         * the chip itself has disabled the data path, and
         * stops us racing with our data end IRQ.
         */
        if (host->size == 0) {
                mmci_set_mask1(host, 0);
                writel(readl(base + MMCIMASK0) | MCI_DATAENDMASK, base + MMCIMASK0);
        }

So, we'll only see DATAEND when we actually reach the end of a transfer.
If we error out before hand, we won't see it.

  reply	other threads:[~2011-01-31 10:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-27 14:14 [PATCH] mmci: calculate remaining bytes at error correctly Linus Walleij
2011-01-27 16:36 ` Russell King - ARM Linux
2011-01-27 16:43   ` Linus Walleij
2011-01-27 16:47     ` Russell King - ARM Linux
2011-01-30 21:28 ` Russell King - ARM Linux
2011-01-30 21:29   ` Russell King - ARM Linux
2011-01-31 10:24     ` Linus Walleij
2011-02-03  0:30       ` Russell King - ARM Linux
2011-02-03 14:00         ` Russell King - ARM Linux
2011-02-04 13:24           ` Linus Walleij
2011-01-31 10:17   ` Linus Walleij
2011-01-31 10:27     ` Russell King - ARM Linux [this message]
2011-01-31 10:31       ` Linus Walleij
2011-01-31 10:40         ` Russell King - ARM Linux
2011-01-31 13:53           ` Linus Walleij
2011-01-31 14:00             ` Russell King - ARM Linux
2011-01-31 12:00   ` Sergei Shtylyov
2011-01-31 12:25     ` Russell King - ARM Linux
2011-01-31 12:31       ` Sergei Shtylyov
2011-02-01 23:40         ` Russell King - ARM Linux
  -- strict thread matches above, loose matches on Subject: below --
2011-01-27 14:02 Linus Walleij

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=20110131102726.GA8948@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@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;
as well as URLs for NNTP newsgroup(s).