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: 18131 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f69.google.com (mail-yh0-f69.google.com [209.85.213.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B28AF2390C for ; Wed, 26 Jun 2013 12:24:10 +0000 (UTC) Received: by mail-yh0-f69.google.com with SMTP id b12sf19574609yha.8 for ; Wed, 26 Jun 2013 05:24:10 -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 :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=eMkbxSwRKSbnksLwn0acsicZsLwa0sQC1R9EoCbwytf6LWiIDz9A6FmZi0+eTyOPoA yjdVaa53KF2QA8ghXDSFRBFX84vj+rAZ6zh+ir81ixK0Q11mp8MzctFGwk37nY8DBP3F bcCeUoMS7kMmYhCaXgU57iw1gA4LRGEBH8UQLQNJnFZL8fLJzJFyLgsP0jYi8eDtBmXE 6nD/A6+GyrkPWw803OlXK+j0wQ3s3OGQ9MWzHjPpTB4A/h3pcM2yUS9SDffjNG3IAyE1 tImNiqudkoXAwAh79hXQpK43ufKxz7t3zsuyoDS2DTTUwhegQkCTptSILLukH1AaVoUa NYIw== X-Received: by 10.236.41.103 with SMTP id g67mr1916482yhb.45.1372249449871; Wed, 26 Jun 2013 05:24:09 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.73.137 with SMTP id l9ls396604qev.0.gmail; Wed, 26 Jun 2013 05:24:09 -0700 (PDT) X-Received: by 10.52.90.50 with SMTP id bt18mr1353450vdb.35.1372249449752; Wed, 26 Jun 2013 05:24:09 -0700 (PDT) Received: from mail-vb0-x236.google.com (mail-vb0-x236.google.com [2607:f8b0:400c:c02::236]) by mx.google.com with ESMTPS id u4si7619427ven.10.2013.06.26.05.24.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Jun 2013 05:24:09 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::236 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::236; Received: by mail-vb0-f54.google.com with SMTP id q12so10456064vbe.41 for ; Wed, 26 Jun 2013 05:24:09 -0700 (PDT) X-Received: by 10.52.77.5 with SMTP id o5mr1330716vdw.46.1372249449613; Wed, 26 Jun 2013 05:24:09 -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 yu8csp106666veb; Wed, 26 Jun 2013 05:24:09 -0700 (PDT) X-Received: by 10.68.200.104 with SMTP id jr8mr387115pbc.43.1372249448689; Wed, 26 Jun 2013 05:24:08 -0700 (PDT) Received: from mail-pa0-x234.google.com (mail-pa0-x234.google.com [2607:f8b0:400e:c03::234]) by mx.google.com with ESMTPS id wf5si14167066pab.283.2013.06.26.05.24.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Jun 2013 05:24:08 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400e:c03::234 is neither permitted nor denied by best guess record for domain of zhangfei.gao@linaro.org) client-ip=2607:f8b0:400e:c03::234; Received: by mail-pa0-f52.google.com with SMTP id kq13so14124567pab.11 for ; Wed, 26 Jun 2013 05:24:08 -0700 (PDT) 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 Cc: linux-arm-kernel@lists.infradead.org, Zhangfei Gao 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: ALoCoQlfN8z6aIbiT1thWV2gVMh2vY1qnA+uWO7ulngH28v44uXTKieCSf7nA3iHjyioCrVkjA9i X-Original-Sender: zhangfei.gao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::236 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) \