From patchwork Wed Jun 26 12:22:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 2788351 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 74BE2C0AB1 for ; Wed, 26 Jun 2013 21:01:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4352A203F1 for ; Wed, 26 Jun 2013 21:01:46 +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 C3F80203EC for ; Wed, 26 Jun 2013 21:01:44 +0000 (UTC) Received: from merlin.infradead.org ([205.233.59.134]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UrsEW-0002UM-Tl; Wed, 26 Jun 2013 16:06:15 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UrsCR-0006KM-34; Wed, 26 Jun 2013 16:04:03 +0000 Received: from bombadil.infradead.org ([2001:1868:205::9]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Urs1H-0005IC-So for linux-arm-kernel@merlin.infradead.org; Wed, 26 Jun 2013 15:52:31 +0000 Received: from mail-pb0-x234.google.com ([2607:f8b0:400e:c01::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UromI-0004z0-1v for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2013 12:24:51 +0000 Received: by mail-pb0-f52.google.com with SMTP id xa12so14109448pbc.11 for ; Wed, 26 Jun 2013 05:24:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=g9woYb4pwG5F9b86JWWCNHbrKZVyVill98cdzGxaMrE=; b=eOb1LG/lCA+Yw7BNVU58Zoogz0zcGJ/6vcMzMYZC7NHAg4iYkJQKB5DKyMgyIvClTB UeWxV9m0UbFWgTTLvbgvyhFtJ9yhVrQkJTnxDuwtXpWyhRWEJrVsfxCFVJ7ZKkx7xwvR RF9TQZ9WXuxBJcqNEisRO5v7vCduBhhf6U0nsTK9K0qmaX48a9aKtuVpjbYK3grtywKk OHWFkuzEAg9MJoqg8pu+Tnkv0gpVkFgJePrklPb+B4d0ow/HWhnjfz/EN+UmbaHTuiP2 B6kqPBiKXoV8yZD2woIFJn8YlqU2N/g+okEfSXkaMP0Jo1tw1BDYP5hDS0Qo93/n9LWd acuA== X-Received: by 10.68.255.196 with SMTP id as4mr382751pbd.54.1372249448164; Wed, 26 Jun 2013 05:24:08 -0700 (PDT) Received: from localhost.localdomain ([60.166.221.252]) by mx.google.com with ESMTPSA id pm7sm28090437pbb.31.2013.06.26.05.24.02 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Jun 2013 05:24:07 -0700 (PDT) From: Zhangfei Gao To: Arnd Bergmann , Vinod Koul Subject: [PATCH] dmaengine: add interface of dma_get_slave_channel Date: Wed, 26 Jun 2013 20:22:50 +0800 Message-Id: <1372249370-10658-1-git-send-email-zhangfei.gao@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQlnlQ6d1RZ9broPtLli4P+Pso0e9ltLumIb5wG9ROJGb3e1zowjjeaObkIxjjmB87+0+VI+ X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130626_052450_674298_3E521BB5 X-CRM114-Status: GOOD ( 10.41 ) X-Spam-Score: 0.0 (/) 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=-5.5 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 --- drivers/dma/dmaengine.c | 26 ++++++++++++++++++++++++++ include/linux/dmaengine.h | 1 + 2 files changed, 27 insertions(+) diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index 93f7992..78dbbe0 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -504,6 +504,32 @@ 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); + else + chan = NULL; + + mutex_unlock(&dma_list_mutex); + + if (err) + pr_debug("%s: failed to get %s: (%d)\n", + __func__, dma_chan_name(chan), err); + + 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 96d3e4a..4e1c843 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -1000,6 +1000,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) \