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: 18182 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 506CA25DFB for ; Fri, 28 Jun 2013 12:39:39 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id hj3sf1182514wib.4 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=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=g9woYb4pwG5F9b86JWWCNHbrKZVyVill98cdzGxaMrE=; b=cfqWzqotPYHlBro/mDoIVkbEeK4FifNgcbAhDlQbEvTu0pDyJlpN6HHG7Ig7gQ3lL8 IO8Rtqs8UyLJLh6th7zR22Dv8eddq4sRcd9GjaXoiXno71G6tnp6j2iL9HblLLzi+qP8 Oys8E13sh1H04OSrdI1k9X2DqLyh0Ga3zFZMRpn3QFsvpJibBfmFIEbE9ckAEGzlVrDa c9Iq9dwMz5fZHIQ/xwSto4GtCxfyUdfzeSCBweFoxp0rQ4dCKGEzdMX5z3ht1OZKdJLt JrRiEWHfYAphggnkCqs1LoSYLINS26j50qoIopiKpLCpNyTdm7ObJZm0/JImcd7suocB fJLg== X-Received: by 10.180.207.44 with SMTP id lt12mr1612848wic.5.1372423177940; Fri, 28 Jun 2013 05:39:37 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.180.185.78 with SMTP id fa14ls169713wic.46.gmail; Fri, 28 Jun 2013 05:39:37 -0700 (PDT) X-Received: by 10.180.78.98 with SMTP id a2mr2270316wix.27.1372423177741; Fri, 28 Jun 2013 05:39:37 -0700 (PDT) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by mx.google.com with ESMTPS id ev15si2667719wid.41.2013.06.28.05.39.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Jun 2013 05:39:37 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.180 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.180; Received: by mail-ve0-f180.google.com with SMTP id pa12so1734046veb.25 for ; Fri, 28 Jun 2013 05:39:36 -0700 (PDT) X-Received: by 10.220.67.10 with SMTP id p10mr5361028vci.85.1372423176551; Fri, 28 Jun 2013 05:39:36 -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.58.165.8 with SMTP id yu8csp188152veb; Fri, 28 Jun 2013 05:39:36 -0700 (PDT) X-Received: by 10.68.197.226 with SMTP id ix2mr7384801pbc.149.1372423175679; Fri, 28 Jun 2013 05:39:35 -0700 (PDT) Received: from mail-pb0-f47.google.com (mail-pb0-f47.google.com [209.85.160.47]) by mx.google.com with ESMTPS id fa9si4062127pab.137.2013.06.28.05.39.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Jun 2013 05:39:35 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.47 is neither permitted nor denied by best guess record for domain of zhangfei.gao@linaro.org) client-ip=209.85.160.47; Received: by mail-pb0-f47.google.com with SMTP id rr13so2223181pbb.6 for ; Fri, 28 Jun 2013 05:39:35 -0700 (PDT) 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 Cc: linux-arm-kernel@lists.infradead.org, Zhangfei Gao 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: ALoCoQm2MYGeuysDzXyPfkPFJW54kPQTp+gFblL9EKQYun0TGutlfDqpfkbnbmdXRbnGxa+xCT9q X-Original-Sender: zhangfei.gao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.180 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 --- 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) \