Skip to content

Commit

Permalink
mmc: atmel-mci: pio hang on block errors
Browse files Browse the repository at this point in the history
The driver is doing, by default, multi-block reads. When a block error
occurs, card/block.c instigates a single block read: "mmcblk0: retrying
using single block read".  It leaves the sg chain intact and just changes
the length attribute for the first sg entry and the overall sg_len
parameter.  When atmci_read_data_pio is called to read the single block
of data it ignores the sg_len and expects to read more than 512 bytes as
it sees there are multiple items in the sg list. No more data comes as
the controller has only been commanded to get one block.

Signed-off-by: Terry Barnaby <terry@beam.ltd.uk>
Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Cc: stable <stable@vger.kernel.org> # 3.2+
Signed-off-by: Chris Ball <cjb@laptop.org>
  • Loading branch information
Terry Barnaby authored and Chris Ball committed Apr 8, 2013
1 parent 836dc2f commit bdbc5d0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions drivers/mmc/host/atmel-mci.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ struct atmel_mci {
void __iomem *regs;

struct scatterlist *sg;
unsigned int sg_len;
unsigned int pio_offset;
unsigned int *buffer;
unsigned int buf_size;
Expand Down Expand Up @@ -892,6 +893,7 @@ static u32 atmci_prepare_data(struct atmel_mci *host, struct mmc_data *data)
data->error = -EINPROGRESS;

host->sg = data->sg;
host->sg_len = data->sg_len;
host->data = data;
host->data_chan = NULL;

Expand Down Expand Up @@ -1826,7 +1828,8 @@ static void atmci_read_data_pio(struct atmel_mci *host)
if (offset == sg->length) {
flush_dcache_page(sg_page(sg));
host->sg = sg = sg_next(sg);
if (!sg)
host->sg_len--;
if (!sg || !host->sg_len)
goto done;

offset = 0;
Expand All @@ -1839,7 +1842,8 @@ static void atmci_read_data_pio(struct atmel_mci *host)

flush_dcache_page(sg_page(sg));
host->sg = sg = sg_next(sg);
if (!sg)
host->sg_len--;
if (!sg || !host->sg_len)
goto done;

offset = 4 - remaining;
Expand Down Expand Up @@ -1890,7 +1894,8 @@ static void atmci_write_data_pio(struct atmel_mci *host)
nbytes += 4;
if (offset == sg->length) {
host->sg = sg = sg_next(sg);
if (!sg)
host->sg_len--;
if (!sg || !host->sg_len)
goto done;

offset = 0;
Expand All @@ -1904,7 +1909,8 @@ static void atmci_write_data_pio(struct atmel_mci *host)
nbytes += remaining;

host->sg = sg = sg_next(sg);
if (!sg) {
host->sg_len--;
if (!sg || !host->sg_len) {
atmci_writel(host, ATMCI_TDR, value);
goto done;
}
Expand Down

0 comments on commit bdbc5d0

Please sign in to comment.