mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Michael Olbrich <m.olbrich@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] mci: mmci: Fix read FIFO handling
Date: Mon, 5 Sep 2016 08:31:07 +0200	[thread overview]
Message-ID: <20160905063107.yrndcugua7m3zxsk@pengutronix.de> (raw)
In-Reply-To: <20160902085037.11653-1-m.olbrich@pengutronix.de>

On Fri, Sep 02, 2016 at 10:50:37AM +0200, Michael Olbrich wrote:
> According to the Linux kernel and the qemu code, the MMCIFIFOCNT contains
> the remaining number of words to read, excluding those that are already in
> the FIFO. So the current number of bytes in the FIFO is
> host_remain - (readl(base + MMCIFIFOCNT) << 2).
> 
> Also writing to MMCIDATACTRL will reset the read counter. As a result,
> MCI_DATABLOCKEND is never set and read_bytes() waits forever.
> 
> With this change, SD-Card support on qemu vexpress works correctly.
> 
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> ---
>  drivers/mci/mmci.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/mci/mmci.c b/drivers/mci/mmci.c
> index 9d1e858917de..7489ee03a13c 100644
> --- a/drivers/mci/mmci.c
> +++ b/drivers/mci/mmci.c
> @@ -212,7 +212,7 @@ static u64 mmci_pio_read(struct mmci_host *host, char *buffer, unsigned int host
>  	struct variant_data *variant = host->variant;
>  
>  	do {
> -		int count = readl(base + MMCIFIFOCNT) << 2;
> +		int count = host_remain - (readl(base + MMCIFIFOCNT) << 2);
>  
>  		if (count > host_remain)
>  			count = host_remain;
> @@ -264,7 +264,6 @@ static int read_bytes(struct mci_host *mci, char *dest, unsigned int blkcount, u
>  	dev_dbg(host->hw_dev, "read_bytes: blkcount=%u blksize=%u\n", blkcount, blksize);
>  
>  	do {
> -		mmci_writel(host, MMCIDATACTRL, mmci_readl(host, MMCIDATACTRL));
>  		len = mmci_pio_read(host, dest, xfercount);
>  		xfercount -= len;
>  		dest += len;
> -- 
> 2.9.3
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2016-09-05  6:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-02  8:50 Michael Olbrich
2016-09-05  6:31 ` Sascha Hauer [this message]

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=20160905063107.yrndcugua7m3zxsk@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.olbrich@pengutronix.de \
    /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