From patchwork Tue Apr 18 23:17:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Cvek X-Patchwork-Id: 9686645 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 01A28601C2 for ; Tue, 18 Apr 2017 23:17:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E767E20265 for ; Tue, 18 Apr 2017 23:17:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC28220564; Tue, 18 Apr 2017 23:17:22 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7577B20265 for ; Tue, 18 Apr 2017 23:17:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:References:To:Subject:From:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8J131V9DE0TmdaxRDYd7Bm8oI0wPRlzgFTxqDjAZNk0=; b=cYG73vBssuZ/DI AWwntmJ2r5c3BtwFoKY+sf6hYeBe6GJCtbjMjue2nat3SAuTV4wQTtw94pEElyEq9NWZ/lw7t1m8W cVIRsvylqCs2z7IyXpP1U2qC8qI7fgVu+pz5Ib5cO4nP64wokeIG2tTaXjK0XcbJW0LnhkNNTg0EQ W+f8I0SRg5nFPNHLWd++m9GDYmI1UXAVAsFz06USTZ8tKkIbWDWNlQgdX3sijWNhRB45d5tXUQHZv kiFCf86Ti7tLsecVtl8sNn97DNlGW0M/A1nRDR/1e5KkIG1RNXYqCGsVEiNuALMXJ53tnvSNxT9Ry /T/pasQYuQ+d13RnxtdA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d0cN8-0000Q5-5h; Tue, 18 Apr 2017 23:17:22 +0000 Received: from bubo.tul.cz ([147.230.16.1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d0cN3-0000N6-4j for linux-arm-kernel@lists.infradead.org; Tue, 18 Apr 2017 23:17:20 +0000 X-Virus-Scanned: amavisd-new at tul.cz Received: from [IPv6:2001:1ae9:ff1:f191:60c5:33b1:380e:2367] (unknown [IPv6:2001:1ae9:ff1:f191:60c5:33b1:380e:2367]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by bubo.tul.cz (Postfix) with ESMTPSA id 6A20718050A0B; Wed, 19 Apr 2017 01:16:51 +0200 (CEST) From: Petr Cvek Subject: [PATCH 2/4] mmc: pxamci: Enhance error checking To: ulf.hansson@linaro.org, robert.jarzmik@free.fr References: Message-ID: Date: Wed, 19 Apr 2017 01:17:21 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170418_161717_445223_E53F4640 X-CRM114-Status: GOOD ( 12.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mmc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The pxamci_dma_irq() and pxamci_data_done() should print errors if they obtains invalid parameters. Make the pxamci_dma_irq() call with the MMC_DATA_READ flag a fault as the DMA callback is used only for write. Signed-off-by: Petr Cvek --- drivers/mmc/host/pxamci.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c index 80bc8065b50f..48c26d848e9f 100644 --- a/drivers/mmc/host/pxamci.c +++ b/drivers/mmc/host/pxamci.c @@ -354,13 +354,22 @@ static int pxamci_data_done(struct pxamci_host *host, unsigned int stat) struct mmc_data *data = host->data; struct dma_chan *chan; - if (!data) + if (!data) { + pr_err("%s: Missing data structure\n", + mmc_hostname(host->mmc)); return 0; + } if (data->flags & MMC_DATA_READ) chan = host->dma_chan_rx; - else + else if (data->flags & MMC_DATA_WRITE) chan = host->dma_chan_tx; + else { + pr_err("%s: Unknown data direction, flags=%08x\n", + mmc_hostname(host->mmc), data->flags); + return 0; + } + dma_unmap_sg(chan->device->dev, data->sg, data->sg_len, host->dma_dir); @@ -558,21 +567,27 @@ static void pxamci_dma_irq(void *param) spin_lock_irqsave(&host->lock, flags); - if (!host->data) + if (!host->data) { + pr_err("%s: Missing data structure\n", + mmc_hostname(host->mmc)); goto out_unlock; + } - if (host->data->flags & MMC_DATA_READ) - chan = host->dma_chan_rx; - else - chan = host->dma_chan_tx; + if (!(host->data->flags & MMC_DATA_WRITE)) { + pr_err("%s: DMA callback is only for tx channel, flags=%x\n", + mmc_hostname(host->mmc), host->data->flags); + goto out_unlock; + } + + chan = host->dma_chan_tx; status = dmaengine_tx_status(chan, host->dma_cookie, &state); if (likely(status == DMA_COMPLETE)) { writel(BUF_PART_FULL, host->base + MMC_PRTBUF); } else { - pr_err("%s: DMA error on %s channel\n", mmc_hostname(host->mmc), - host->data->flags & MMC_DATA_READ ? "rx" : "tx"); + pr_err("%s: Invalid DMA status %i\n", mmc_hostname(host->mmc), + status); host->data->error = -EIO; pxamci_data_done(host, 0); }