From patchwork Tue Jul 10 21:48:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 1179031 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-linux-mmc@patchwork.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 864D740CFC for ; Tue, 10 Jul 2012 21:49:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754342Ab2GJVtI (ORCPT ); Tue, 10 Jul 2012 17:49:08 -0400 Received: from na3sys009aog101.obsmtp.com ([74.125.149.67]:58378 "EHLO na3sys009aog101.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754405Ab2GJVtG (ORCPT ); Tue, 10 Jul 2012 17:49:06 -0400 Received: from mail-pb0-f42.google.com ([209.85.160.42]) (using TLSv1) by na3sys009aob101.postini.com ([74.125.148.12]) with SMTP ID DSNKT/yjTy6YV9sAZZYeYeJUqHi7r9XQJv8b@postini.com; Tue, 10 Jul 2012 14:49:06 PDT Received: by pbbrp12 with SMTP id rp12so1026784pbb.29 for ; Tue, 10 Jul 2012 14:48:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:organization:references:date:in-reply-to :message-id:user-agent:mime-version:content-type:x-gm-message-state; bh=Jcw6M0X4bj34pKBmzMTqLU2/R61mIE0UxZUhoEAUDAg=; b=BPcoo4q9ZvWjLIjXtY6yU17KyLTg9o25Dvas+8LfH7o92w1NMGogGLwFeZQxlz/hWN UQnRWAjuU9G6jGILP+4TmgfYSeEocJju5tQX9IaxCELNlxYKRrR/y6GgHVQZCc8H9fEe eAJ+BNUNjiFU8MWWs/SW14SQLS3WbqQL0JBJfbS1ZnN1oNhuepUPFpCr6r5Y8EkBBA2L MauuUe294c0zCxLNqx8Xz9ALNb+jrTA36b9x0w+xwgawJ4ONgikTx/LoFj7Tng5ZS/6C YmUa1/5BZcWZnbKbPWifzyuG4Ws0f0BAFS4YBwvpyTRDeM5jB1bElAvnibFd19shnEU4 oX0Q== Received: by 10.68.194.234 with SMTP id hz10mr73372704pbc.126.1341956936561; Tue, 10 Jul 2012 14:48:56 -0700 (PDT) Received: from localhost (c-24-19-7-36.hsd1.wa.comcast.net. [24.19.7.36]) by mx.google.com with ESMTPS id tj4sm291869pbc.33.2012.07.10.14.48.55 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 10 Jul 2012 14:48:55 -0700 (PDT) From: Kevin Hilman To: Russell King Cc: linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, Chris Ball , linux-mmc@vger.kernel.org Subject: Re: [CFT 03/11] mmc: omap_hsmmc: remove private DMA API implementation Organization: Texas Instruments, Inc. References: <20120607110610.GB15973@n2100.arm.linux.org.uk> Date: Tue, 10 Jul 2012 14:48:56 -0700 In-Reply-To: (Russell King's message of "Thu, 07 Jun 2012 12:07:13 +0100") Message-ID: <87vchvl22f.fsf@ti.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQkehzTYbOq395r+qlWQ5c5mlESWQwbvxrd+GC0kYYSSaGsM7nydLo+NFVewJ97HjysXPKuT Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Hi Russell, Russell King writes: > Remove the private DMA API implementation from omap_hsmmc, making it > use entirely the DMA engine API. > > Signed-off-by: Russell King While testing this, I noticed a minor problem in the case of probe failure (e.g. if dmaengine is not built into the kernel.) The current driver suffers from this same problem but should probably be fixed when converting to dmaengine... [...] > @@ -2048,36 +1919,28 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev) > dev_err(mmc_dev(host->mmc), "cannot get DMA TX channel\n"); > goto err_irq; > } > - host->dma_line_tx = res->start; > + tx_req = res->start; > > res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx"); > if (!res) { > dev_err(mmc_dev(host->mmc), "cannot get DMA RX channel\n"); > goto err_irq; > } > - host->dma_line_rx = res->start; > + rx_req = res->start; > > - { > - dma_cap_mask_t mask; > - unsigned sig; > - extern bool omap_dma_filter_fn(struct dma_chan *chan, void *param); > - > - dma_cap_zero(mask); > - dma_cap_set(DMA_SLAVE, mask); > -#if 1 > - sig = host->dma_line_rx; > - host->rx_chan = dma_request_channel(mask, omap_dma_filter_fn, &sig); > - if (!host->rx_chan) { > - dev_warn(mmc_dev(host->mmc), "unable to obtain RX DMA engine channel %u\n", sig); > - } > -#endif > -#if 1 > - sig = host->dma_line_tx; > - host->tx_chan = dma_request_channel(mask, omap_dma_filter_fn, &sig); > - if (!host->tx_chan) { > - dev_warn(mmc_dev(host->mmc), "unable to obtain TX DMA engine channel %u\n", sig); > - } > -#endif > + dma_cap_zero(mask); > + dma_cap_set(DMA_SLAVE, mask); > + > + host->rx_chan = dma_request_channel(mask, omap_dma_filter_fn, &rx_req); > + if (!host->rx_chan) { > + dev_err(mmc_dev(host->mmc), "unable to obtain RX DMA engine channel %u\n", rx_req); > + goto err_irq; > + } > + > + host->tx_chan = dma_request_channel(mask, omap_dma_filter_fn, &tx_req); > + if (!host->tx_chan) { > + dev_err(mmc_dev(host->mmc), "unable to obtain TX DMA engine channel %u\n", tx_req); > + goto err_irq; > } If either of these fails, ret is zero so even though this results in a failed probe, the return value (ret) is zero meaning the driver still gets bound to the device. The patch below fixes this and applies on your 'for-next' branch. Or, feel free to fold this into the original if you prefer. Kevin From af7537997b46ee3991985fecd4b4a302bdc0df31 Mon Sep 17 00:00:00 2001 From: Kevin Hilman Date: Tue, 10 Jul 2012 14:30:18 -0700 Subject: [PATCH] mmc: omap_hsmmc: ensure probe returns error if DMA channel request fails If dma_request_channel() fails (e.g. because DMA engine is not built into the kernel), the return value from probe is zero causing the driver to be bound to the device even though probe failed. To fix, ensure that probe returns an error value when a DMA channel request fail. Cc: Russell King Signed-off-by: Kevin Hilman --- drivers/mmc/host/omap_hsmmc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 2338703..ddcecf8 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -1924,12 +1924,14 @@ static int __devinit omap_hsmmc_probe(struct platform_device *pdev) host->rx_chan = dma_request_channel(mask, omap_dma_filter_fn, &rx_req); if (!host->rx_chan) { dev_err(mmc_dev(host->mmc), "unable to obtain RX DMA engine channel %u\n", rx_req); + ret = -ENXIO; goto err_irq; } host->tx_chan = dma_request_channel(mask, omap_dma_filter_fn, &tx_req); if (!host->tx_chan) { dev_err(mmc_dev(host->mmc), "unable to obtain TX DMA engine channel %u\n", tx_req); + ret -ENXIO; goto err_irq; }