From patchwork Thu Aug 15 07:02:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 2845003 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C1B979F239 for ; Thu, 15 Aug 2013 07:04:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C92E620381 for ; Thu, 15 Aug 2013 07:04:04 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CA4292034A for ; Thu, 15 Aug 2013 07:04:03 +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 1V9ray-000208-Oh; Thu, 15 Aug 2013 07:03:45 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V9rap-00089l-GE; Thu, 15 Aug 2013 07:03:35 +0000 Received: from mail-ee0-f46.google.com ([74.125.83.46]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V9rae-00088H-Py for linux-arm-kernel@lists.infradead.org; Thu, 15 Aug 2013 07:03:26 +0000 Received: by mail-ee0-f46.google.com with SMTP id c13so173109eek.19 for ; Thu, 15 Aug 2013 00:03:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BbVgHRcQ0q1bTZKYwl8Oun8q165MnTMCFLYrheuAePw=; b=dh23jWeBIs/3m7UNGqkrovCUa9eB1zq5EeRSpynweer9c6qcKJjB0K1rM3jhgMJ3Zl sL89vYvocf4dVdb3YHkZ8iQjl1yUGHHXWIWgWkxFvjkGHtw91pNGK2BZesiBvaRZddY6 hKj9xKGVhqDqh8V6rmVolACMIop58MJPbncfZxE6MsU6sHdQhkeLskOhzGqM9nCj9qwP Hhjo3fLflcaISXygFcfGQKsRRQbpTyuw4Pz+HKlUDPjSuHi7D0PckxeUlkEOpWerHNTr jRO8ZkT3NBQ8QD1VVDmKTDHYgKnyGk8zvvtlEjjenLmExhKh4EI3AQ4X2HPWL9wxxoim eMaA== X-Gm-Message-State: ALoCoQkRVIarBMk+1z3sYFb1b1V/3bSAZzXFnRgKDOYLR/u1SYVy/VfMAN7Kkv0SqOgFyiSBvg/m X-Received: by 10.14.219.198 with SMTP id m46mr20365681eep.41.1376550182932; Thu, 15 Aug 2013 00:03:02 -0700 (PDT) Received: from localhost.localdomain ([213.122.173.130]) by mx.google.com with ESMTPSA id a1sm81812209eem.1.2013.08.15.00.02.57 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Aug 2013 00:03:01 -0700 (PDT) From: Zhangfei Gao To: Arnd Bergmann , Vinod Koul , Dan Carpenter Subject: [PATCH v3 1/2] dmaengine: add interface of dma_get_slave_channel Date: Thu, 15 Aug 2013 15:02:42 +0800 Message-Id: <1376550163-30145-2-git-send-email-zhangfei.gao@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1376550163-30145-1-git-send-email-zhangfei.gao@linaro.org> References: <1376550163-30145-1-git-send-email-zhangfei.gao@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130815_030325_000681_F096A100 X-CRM114-Status: GOOD ( 12.95 ) X-Spam-Score: -2.6 (--) Cc: Zhangfei Gao , 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Suggested by Arnd, add dma_get_slave_channel interface Dma host driver could get specific channel specificied by request line, rather than filter. host example: static struct dma_chan *xx_of_dma_simple_xlate(struct of_phandle_args *dma_spec, struct of_dma *ofdma) { struct xx_dma_dev *d = ofdma->of_dma_data; unsigned int request = dma_spec->args[0]; if (request > d->dma_requests) return NULL; return dma_get_slave_channel(&(d->chans[request].vc.chan)); } probe: of_dma_controller_register((&op->dev)->of_node, xx_of_dma_simple_xlate, d); Signed-off-by: Zhangfei Gao Acked-by: Arnd Bergmann --- drivers/dma/dmaengine.c | 25 +++++++++++++++++++++++++ include/linux/dmaengine.h | 1 + 2 files changed, 26 insertions(+) diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 9e56745..38dd8c3 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -504,6 +504,31 @@ static struct dma_chan *private_candidate(const dma_cap_mask_t *mask, } /** + * dma_request_channel - try to get specific channel exclusively + * @chan: target channel + */ +struct dma_chan *dma_get_slave_channel(struct dma_chan *chan) +{ + int err = -EBUSY; + + /* lock against __dma_request_channel */ + mutex_lock(&dma_list_mutex); + + if (chan->client_count == 0) { + err = dma_chan_get(chan); + if (err) + pr_debug("%s: failed to get %s: (%d)\n", + __func__, dma_chan_name(chan), err); + } else + chan = NULL; + + mutex_unlock(&dma_list_mutex); + + return chan; +} +EXPORT_SYMBOL_GPL(dma_get_slave_channel); + +/** * dma_request_channel - try to allocate an exclusive channel * @mask: capabilities that the channel must satisfy * @fn: optional callback to disposition available channels diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index cb286b1..c271608 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -995,6 +995,7 @@ int dma_async_device_register(struct dma_device *device); void dma_async_device_unregister(struct dma_device *device); void dma_run_dependencies(struct dma_async_tx_descriptor *tx); struct dma_chan *dma_find_channel(enum dma_transaction_type tx_type); +struct dma_chan *dma_get_slave_channel(struct dma_chan *chan); struct dma_chan *net_dma_find_channel(void); #define dma_request_channel(mask, x, y) __dma_request_channel(&(mask), x, y) #define dma_request_slave_channel_compat(mask, x, y, dev, name) \