Commit 2c8d96a4 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Ulf Hansson

mmc: meson-gx: improve setting data->bytes_xfered

Centralize setting data->bytes_xfered in one place and make sure
that the number of transfererd bytes is set only if we receive
the end-of-chain interrupt and there was no error.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Reviewed-by: default avatarKevin Hilman <khilman@baylibre.com>
parent 1f8066d9
...@@ -484,7 +484,6 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd) ...@@ -484,7 +484,6 @@ static void meson_mmc_start_cmd(struct mmc_host *mmc, struct mmc_command *cmd)
WARN_ON(xfer_bytes > host->bounce_buf_size); WARN_ON(xfer_bytes > host->bounce_buf_size);
sg_copy_to_buffer(data->sg, data->sg_len, sg_copy_to_buffer(data->sg, data->sg_len,
host->bounce_buf, xfer_bytes); host->bounce_buf, xfer_bytes);
data->bytes_xfered = xfer_bytes;
dma_wmb(); dma_wmb();
} }
...@@ -539,6 +538,7 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) ...@@ -539,6 +538,7 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id)
{ {
struct meson_host *host = dev_id; struct meson_host *host = dev_id;
struct mmc_command *cmd; struct mmc_command *cmd;
struct mmc_data *data;
u32 irq_en, status, raw_status; u32 irq_en, status, raw_status;
irqreturn_t ret = IRQ_HANDLED; irqreturn_t ret = IRQ_HANDLED;
...@@ -550,6 +550,8 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) ...@@ -550,6 +550,8 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id)
if (WARN_ON(!cmd)) if (WARN_ON(!cmd))
return IRQ_NONE; return IRQ_NONE;
data = cmd->data;
spin_lock(&host->lock); spin_lock(&host->lock);
irq_en = readl(host->regs + SD_EMMC_IRQ_EN); irq_en = readl(host->regs + SD_EMMC_IRQ_EN);
raw_status = readl(host->regs + SD_EMMC_STATUS); raw_status = readl(host->regs + SD_EMMC_STATUS);
...@@ -590,9 +592,11 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) ...@@ -590,9 +592,11 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id)
if (status & IRQ_SDIO) if (status & IRQ_SDIO)
dev_dbg(host->dev, "Unhandled IRQ: SDIO.\n"); dev_dbg(host->dev, "Unhandled IRQ: SDIO.\n");
if (status & (IRQ_END_OF_CHAIN | IRQ_RESP_STATUS)) if (status & (IRQ_END_OF_CHAIN | IRQ_RESP_STATUS)) {
if (data && !cmd->error)
data->bytes_xfered = data->blksz * data->blocks;
ret = IRQ_WAKE_THREAD; ret = IRQ_WAKE_THREAD;
else { } else {
dev_warn(host->dev, "Unknown IRQ! status=0x%04x: MMC CMD%u arg=0x%08x flags=0x%08x stop=%d\n", dev_warn(host->dev, "Unknown IRQ! status=0x%04x: MMC CMD%u arg=0x%08x flags=0x%08x stop=%d\n",
status, cmd->opcode, cmd->arg, status, cmd->opcode, cmd->arg,
cmd->flags, cmd->mrq->stop ? 1 : 0); cmd->flags, cmd->mrq->stop ? 1 : 0);
...@@ -633,7 +637,6 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id) ...@@ -633,7 +637,6 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id)
WARN_ON(xfer_bytes > host->bounce_buf_size); WARN_ON(xfer_bytes > host->bounce_buf_size);
sg_copy_from_buffer(data->sg, data->sg_len, sg_copy_from_buffer(data->sg, data->sg_len,
host->bounce_buf, xfer_bytes); host->bounce_buf, xfer_bytes);
data->bytes_xfered = xfer_bytes;
} }
if (!data || !data->stop || cmd->mrq->sbc) if (!data || !data->stop || cmd->mrq->sbc)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment