From patchwork Thu Apr 18 09:25:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 2458491 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id 4DC4E3FCA5 for ; Thu, 18 Apr 2013 09:27:09 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1USl6v-0003EN-CF; Thu, 18 Apr 2013 09:26:34 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1USl6T-0008Lg-4a; Thu, 18 Apr 2013 09:26:05 +0000 Received: from moutng.kundenserver.de ([212.227.126.186]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1USl6Q-0008L7-IT for linux-arm-kernel@lists.infradead.org; Thu, 18 Apr 2013 09:26:03 +0000 Received: from klappe2.localnet (HSI-KBW-095-208-002-043.hsi5.kabel-badenwuerttemberg.de [95.208.2.43]) by mrelayeu.kundenserver.de (node=mrbap2) with ESMTP (Nemesis) id 0Lvywf-1UcFfi1dID-017TI9; Thu, 18 Apr 2013 11:25:47 +0200 From: Arnd Bergmann To: "Russell King - ARM Linux" Subject: Re: [PATCH] mmc: mmci: Allow MMCI to request channels with information acquired from DT Date: Thu, 18 Apr 2013 11:25:44 +0200 User-Agent: KMail/1.12.2 (Linux/3.8.0-18-generic; KDE/4.3.2; x86_64; ; ) References: <1366205534-25079-1-git-send-email-lee.jones@linaro.org> <20130418080238.GB3137@gmail.com> <20130418081549.GE14496@n2100.arm.linux.org.uk> In-Reply-To: <20130418081549.GE14496@n2100.arm.linux.org.uk> MIME-Version: 1.0 Message-Id: <201304181125.44983.arnd@arndb.de> X-Provags-ID: V02:K0:HGs4jvCbGiAZVBj7koLQ+ekcu3JmQlyLa0ClxHNqGUH DOgovapFBvIZ9um1xyweJL26Q4ij+1UAXQw/DUHByUyeltl2wo hXzqCGGL8XdGsEOD5ByXM6/KN3x4uX76VAvu+cXvNm7m5rKSKB SwBO8ChjjNUFTyl4XG2vsAGEG0kuvnK6O/3B9fX1nPwgfh47x/ dWdx5zyz/H07w9srgnsPjN34zIbZ8/cB9YYfUlXYCagZJSk95c qUxyODh4GegRSAW+ZaTej6F9yeQRTPEkQnNbQoacfzt2onAeBO xC7gpbtf0WIe3KAjW0QwttmiwngmhzaNi6haP7sZGtsl4iOonp oJY1O0QM701DgkL/eQlw= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130418_052602_907016_E66959C1 X-CRM114-Status: GOOD ( 26.33 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.227.126.186 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linus.walleij@stericsson.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Ball , Lee Jones , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org On Thursday 18 April 2013, Russell King - ARM Linux wrote: > On Thu, Apr 18, 2013 at 09:02:38AM +0100, Lee Jones wrote: > > @@ -321,19 +323,21 @@ static void mmci_dma_setup(struct mmci_host *host) > > * attempt to use it bidirectionally, however if it is > > * is specified but cannot be located, DMA will be disabled. > > */ > > - if (plat->dma_rx_param) { > > - host->dma_rx_channel = dma_request_channel(mask, > > - plat->dma_filter, > > - plat->dma_rx_param); > > + if (plat->dma_rx_param || np) { > > + host->dma_rx_channel = dma_request_slave_channel_compat(mask, > > + plat->dma_filter, > > + plat->dma_rx_param, > > + &dev->dev, "rx"); > > /* E.g if no DMA hardware is present */ > > if (!host->dma_rx_channel) > > dev_err(mmc_dev(host->mmc), "no RX DMA channel\n"); > > I don't think this is right - I think Arnd has been leading you up the > garden path saying that this can be simplified. Why? > > If you look at what this code does, the DMA channels are optional. If > they're not provided, then you don't get an error or a warning printk from > the code. However, after your conversion, if you use DT and avoid giving > the DMA information (which you have to avoid on the majority of ARM > platforms) then "np" will be non-NULL, and > dma_request_slave_channel_compat() will return NULL, causing the error > and/or warning to be printed. Right, so I guess we should print the warning only if plat->dma_filter is non-NULL, or we don't use dma_request_slave_channel_compat, which does not actually simplify the code here. Arnd diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 375c109..c97bc92 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -298,20 +298,11 @@ static void mmci_init_sg(struct mmci_host *host, struct mmc_data *data) * no custom DMA interfaces are supported. */ #ifdef CONFIG_DMA_ENGINE -static void mmci_dma_setup(struct mmci_host *host) +static int mmci_dma_plat_setup(struct mmci_host *host) { struct mmci_platform_data *plat = host->plat; - const char *rxname, *txname; dma_cap_mask_t mask; - if (!plat || !plat->dma_filter) { - dev_info(mmc_dev(host->mmc), "no DMA platform data\n"); - return; - } - - /* initialize pre request cookie */ - host->next_data.cookie = 1; - /* Try to acquire a generic DMA engine slave channel */ dma_cap_zero(mask); dma_cap_set(DMA_SLAVE, mask); @@ -339,6 +330,25 @@ static void mmci_dma_setup(struct mmci_host *host) } else { host->dma_tx_channel = host->dma_rx_channel; } +} + +static void mmci_dma_setup(struct device *dev, struct mmci_host *host) +{ + const char *rxname, *txname; + + host->dma_rx_channel = dma_request_slave_channel(dev, "rx"); + host->dma_tx_channel = dma_request_slave_channel(dev, "tx"); + + if (!host->dma_rx_channel && !host->dma_tx_channel) { + if (host->plat && host->plat->dma_filter) + mmci_dma_plat_setup(host); + else + dev_info(mmc_dev(host->mmc), "no DMA platform data\n"); + return; + } + + /* initialize pre request cookie */ + host->next_data.cookie = 1; if (host->dma_rx_channel) rxname = dma_chan_name(host->dma_rx_channel);