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: 19165 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f69.google.com (mail-qa0-f69.google.com [209.85.216.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 541342486D for ; Thu, 15 Aug 2013 07:03:05 +0000 (UTC) Received: by mail-qa0-f69.google.com with SMTP id bv4sf662571qab.4 for ; Thu, 15 Aug 2013 00:03:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=BbVgHRcQ0q1bTZKYwl8Oun8q165MnTMCFLYrheuAePw=; b=aIQoCMg+RMf/am/b+b+lgJtVjVuzWDJpGjdfGiYADBuIVYqiDSLy8jY6kw/VIZEdFE RqIMdrNpV42beG3FdRZqfOhfsq4EXwgTK+0VO9a/i3zZkYujeRC8cBy88WExmnyQQXgX +CoXoG/VMl9DUiaaqy2unerNNnHMmDsbW6VjYIpoXuSMLmkhkBnxXy1dATNEesd7r7Wr s2OZwSsiwveqfwc92OpkKWvn2uDuVmX3ITbl2BUzptShEi6f6eUCS+FBdhU6EJ1xJTcH kNLhb2+tYfA8McVrFhJWbmUAjlv4RwfZ/0Abh64dbRA1DdB5qu95LYKX+ifkkJUCQfbD 5Iyw== X-Received: by 10.58.189.3 with SMTP id ge3mr4078697vec.36.1376550185069; Thu, 15 Aug 2013 00:03:05 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.130.196 with SMTP id og4ls201519qeb.69.gmail; Thu, 15 Aug 2013 00:03:04 -0700 (PDT) X-Received: by 10.58.237.105 with SMTP id vb9mr13249549vec.2.1376550184806; Thu, 15 Aug 2013 00:03:04 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id cz7si12209326veb.33.2013.08.15.00.03.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Aug 2013 00:03:04 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id oy10so320392veb.34 for ; Thu, 15 Aug 2013 00:03:04 -0700 (PDT) X-Gm-Message-State: ALoCoQkcoBGHPhWC8NemTq731iXdg4PqiKF4/0GBsV0Sl3k+m3oQq2h1tWrLCq76PcQe6riocTWN X-Received: by 10.52.232.165 with SMTP id tp5mr11202943vdc.11.1376550184681; Thu, 15 Aug 2013 00:03:04 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp256444vcz; Thu, 15 Aug 2013 00:03:04 -0700 (PDT) X-Received: by 10.15.94.201 with SMTP id bb49mr20763663eeb.23.1376550183599; Thu, 15 Aug 2013 00:03:03 -0700 (PDT) Received: from mail-ea0-f179.google.com (mail-ea0-f179.google.com [209.85.215.179]) by mx.google.com with ESMTPS id o6si40062184eea.39.2013.08.15.00.03.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Aug 2013 00:03:03 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.179 is neither permitted nor denied by best guess record for domain of zhangfei.gao@linaro.org) client-ip=209.85.215.179; Received: by mail-ea0-f179.google.com with SMTP id b10so175994eae.10 for ; Thu, 15 Aug 2013 00:03:03 -0700 (PDT) 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 Cc: linux-arm-kernel@lists.infradead.org, Zhangfei Gao 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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: zhangfei.gao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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) \