From patchwork Wed Mar 22 21:33:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9640105 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5358E60327 for ; Wed, 22 Mar 2017 21:34:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44CAB2521E for ; Wed, 22 Mar 2017 21:34:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39BE5262F2; Wed, 22 Mar 2017 21:34:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE6052521E for ; Wed, 22 Mar 2017 21:34:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753784AbdCVVeg (ORCPT ); Wed, 22 Mar 2017 17:34:36 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34769 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753756AbdCVVeX (ORCPT ); Wed, 22 Mar 2017 17:34:23 -0400 Received: by mail-wm0-f65.google.com with SMTP id u132so13036883wmg.1 for ; Wed, 22 Mar 2017 14:34:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:references:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=K0uD3xf6DdTzVs+I7J7EAk2rfoLn598VfX/pfdkgssI=; b=lkJ14PNip8ur9ezVZykBeGwRzWvkG+Mf7KzCm4sk51HCM7qBzRNiXfHnPLlGkPxCTL fYHS+qgrHdX4ZlTqZQnEOVQN/KIPIt0qwZPPWqxkAyJ6X1VQ1mao2zOIC1KgUvpqwrp2 zrslttu3qgGJz3x38iamuFlqa8nET19/fkahV5ACU6TpGPKgcHFzJlzhIYmV3wtcUjR8 s+tAQeJZ4ARgGJ9MrChTCLa7UCG6CZdQMEY8KAb0RG6r6TBAOycqYKEm3tZFuFI/Ue6U NjVkFc++9XN3vn9Tjxj/nj+jrMF8nX5FgGHCo3QwWx8I9Qa1Op0rYSyqMSthBeg6XVlJ G9Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:cc:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=K0uD3xf6DdTzVs+I7J7EAk2rfoLn598VfX/pfdkgssI=; b=Lsu1g9tfpQ1ZITJksAQnW/XjeNWTuQ1QCWM82e7BlSEpMouH/9FOV2ax6WDeCC/E3/ TkyYPp86X6K/NklPXRQ83Eo0rMJGWSlquGmH8n2Z7XLedKf3D1RMr3HiENjpL8edKvS3 bdaDBDiIq6qxPNFHReXyCGDI2syuhgaR2gT2kg9GHuXRUocfdmZE8igAUOICOWae/jOY 2yh6mFMjP2c91LfZnXKeSs4IugmEu8Oe9uuqFkmIlKxg1VJIaNm4njim1zGEdJtTP4lD 7y59u60ebUPGjTb4I89P4JJMe9nZxk2xA/MvUf5L79dOQRhmMs4N0dizbL2NbYgBjkte XAbg== X-Gm-Message-State: AFeK/H1N9LH62Dy7aldRYy57ZaCRqXjLu4LB9vhldQbqEDMJyDvF2S+znUgtJ9phIthH8Q== X-Received: by 10.28.20.70 with SMTP id 67mr10299408wmu.86.1490218456806; Wed, 22 Mar 2017 14:34:16 -0700 (PDT) Received: from ?IPv6:2003:c6:ebdc:4000:94d5:56f1:aebf:596a? (p200300C6EBDC400094D556F1AEBF596A.dip0.t-ipconnect.de. [2003:c6:ebdc:4000:94d5:56f1:aebf:596a]) by smtp.googlemail.com with ESMTPSA id y65sm2409670wrb.50.2017.03.22.14.34.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Mar 2017 14:34:16 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH 5/6] mmc: meson-gx: improve setting data->bytes_xfered To: Ulf Hansson , Kevin Hilman References: <8bf58a83-d8d7-615c-c89b-87a62a3c9c40@gmail.com> Cc: "linux-mmc@vger.kernel.org" , linux-amlogic@lists.infradead.org Message-ID: <168682c3-1b46-28ec-36cc-65573efcb896@gmail.com> Date: Wed, 22 Mar 2017 22:33:53 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <8bf58a83-d8d7-615c-c89b-87a62a3c9c40@gmail.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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: Heiner Kallweit --- drivers/mmc/host/meson-gx-mmc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index c4ddd820..87303404 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -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); sg_copy_to_buffer(data->sg, data->sg_len, host->bounce_buf, xfer_bytes); - data->bytes_xfered = xfer_bytes; dma_wmb(); } @@ -539,6 +538,7 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) { struct meson_host *host = dev_id; struct mmc_command *cmd; + struct mmc_data *data; u32 irq_en, status, raw_status; irqreturn_t ret = IRQ_HANDLED; @@ -550,6 +550,8 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) if (WARN_ON(!cmd)) return IRQ_NONE; + data = cmd->data; + spin_lock(&host->lock); irq_en = readl(host->regs + SD_EMMC_IRQ_EN); raw_status = readl(host->regs + SD_EMMC_STATUS); @@ -590,9 +592,11 @@ static irqreturn_t meson_mmc_irq(int irq, void *dev_id) if (status & IRQ_SDIO) 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; - else { + } else { 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, cmd->flags, cmd->mrq->stop ? 1 : 0); @@ -633,7 +637,6 @@ static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id) WARN_ON(xfer_bytes > host->bounce_buf_size); sg_copy_from_buffer(data->sg, data->sg_len, host->bounce_buf, xfer_bytes); - data->bytes_xfered = xfer_bytes; } if (!data || !data->stop || cmd->mrq->sbc)