From patchwork Fri Jun 28 12:39:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhangfei Gao X-Patchwork-Id: 2798701 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 8B0D0BF4A1 for ; Fri, 28 Jun 2013 12:41:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 25C4A201B2 for ; Fri, 28 Jun 2013 12:41:34 +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 B1FEE201B1 for ; Fri, 28 Jun 2013 12:41:32 +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 1UsXyW-0002aE-Ch; Fri, 28 Jun 2013 12:40:28 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UsXyF-000476-CQ; Fri, 28 Jun 2013 12:40:11 +0000 Received: from mail-pb0-f42.google.com ([209.85.160.42]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UsXy4-00044x-S1 for linux-arm-kernel@lists.infradead.org; Fri, 28 Jun 2013 12:40:02 +0000 Received: by mail-pb0-f42.google.com with SMTP id un1so2237996pbc.15 for ; Fri, 28 Jun 2013 05:39:38 -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:in-reply-to:references :x-gm-message-state; bh=g9woYb4pwG5F9b86JWWCNHbrKZVyVill98cdzGxaMrE=; b=Mmcu3sXCMNTQwdtDuiOlGpJe74hMkUXc6XWxLsRQujMBqvWXCn/5x98K5cJbvYqg89 b9WmJJnzPCyTBpK8vy4/E9lEIPVY/eluIXpAmHSyRjSfH8spAyRSbSQ2IyDuF7XIj3u9 2NfBwGqIGMv+5WP8N2hJvvyOlhSVuxV3PYA4hK1wOJflQfG6pPB0hx297mUBq2N842Ka XugIlcpLRRkr4ELbkIqTBBScry4ZWCzc5qRqvrc10ChqDCXsYuEJ6wQSYWuoI/05wwKD 7nfxG3CVNelTe6mZEftRDhYuEIe4lGC3quTLdCzlTL4rnb5V58efKbxmWTI/3mH8CwBt D+hw== X-Received: by 10.66.163.38 with SMTP id yf6mr11203701pab.45.1372423175292; Fri, 28 Jun 2013 05:39:35 -0700 (PDT) Received: from localhost.localdomain ([124.73.89.237]) by mx.google.com with ESMTPSA id tt7sm7969299pbc.34.2013.06.28.05.39.30 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Jun 2013 05:39:34 -0700 (PDT) From: Zhangfei Gao To: Arnd Bergmann , Vinod Koul , Russell King - ARM Linux Subject: [PATCH v2 1/2] dmaengine: add interface of dma_get_slave_channel Date: Fri, 28 Jun 2013 20:39:12 +0800 Message-Id: <1372423153-6742-2-git-send-email-zhangfei.gao@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1372423153-6742-1-git-send-email-zhangfei.gao@linaro.org> References: <1372423153-6742-1-git-send-email-zhangfei.gao@linaro.org> X-Gm-Message-State: ALoCoQk92ux/Thwt4LYnp0F7G4xtWZb6H703L2Spk0S0+8hD32mkiUBkvGcL9eZdpjJ+lOSAjhTF X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130628_084001_032723_38DBA0FA X-CRM114-Status: GOOD ( 15.29 ) 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=-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 Acked-by: Arnd Bergmann --- 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) \