From patchwork Thu Jan 10 19:07:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Porter X-Patchwork-Id: 1961571 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from arroyo.ext.ti.com (arroyo.ext.ti.com [192.94.94.40]) by patchwork1.kernel.org (Postfix) with ESMTP id AC6173FC85 for ; Thu, 10 Jan 2013 19:02:47 +0000 (UTC) Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id r0AJ2lI1002267 for ; Thu, 10 Jan 2013 13:02:47 -0600 Received: from DLEE74.ent.ti.com (dlee74.ent.ti.com [157.170.170.8]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id r0AJ2lRS024065 for ; Thu, 10 Jan 2013 13:02:47 -0600 Received: from dlelxv23.itg.ti.com (172.17.1.198) by DLEE74.ent.ti.com (157.170.170.8) with Microsoft SMTP Server id 14.1.323.3; Thu, 10 Jan 2013 13:02:47 -0600 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv23.itg.ti.com (8.13.8/8.13.8) with ESMTP id r0AJ2lxj012006 for ; Thu, 10 Jan 2013 13:02:47 -0600 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 1F67880626 for ; Thu, 10 Jan 2013 13:02:47 -0600 (CST) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id A05A280626 for ; Thu, 10 Jan 2013 13:02:35 -0600 (CST) Received: from white.ext.ti.com (white.ext.ti.com [192.94.93.38]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id r0AJ2ZQh026464 for ; Thu, 10 Jan 2013 13:02:35 -0600 (CST) Received: from mail6.bemta8.messagelabs.com (mail6.bemta8.messagelabs.com [216.82.243.55]) by white.ext.ti.com (8.13.7/8.13.7) with ESMTP id r0AJ2Yc4027824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 10 Jan 2013 13:02:35 -0600 Received: from [216.82.242.147:60641] by server-12.bemta-8.messagelabs.com id C9/6E-21275-A401FE05; Thu, 10 Jan 2013 19:02:34 +0000 X-Env-Sender: ohiomdp@gmail.com X-Msg-Ref: server-8.tower-95.messagelabs.com!1357844554!23972452!1 X-Originating-IP: [209.85.212.44] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.6.1.8; banners=-,-,- X-VirusChecked: Checked Received: (qmail 441 invoked from network); 10 Jan 2013 19:02:34 -0000 Received: from mail-vb0-f44.google.com (HELO mail-vb0-f44.google.com) (209.85.212.44) by server-8.tower-95.messagelabs.com with RC4-SHA encrypted SMTP; 10 Jan 2013 19:02:34 -0000 Received: by mail-vb0-f44.google.com with SMTP id fc26so669377vbb.17 for ; Thu, 10 Jan 2013 11:02:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=84h2gVgVFtDzq3nftj1EiDlzAEHBO0GUNh+HzgTJXsk=; b=UEhbz0NjpjyTcQBL0KA/SyGG6gDqAFGaJ3Db5/Zy1Mb/E/JVc0hnDdQfaNo+uxRwoJ 39BhWzqHMWCW1sZfGJR4jevrY++Vr8Mzu6DtpMYRDoqBauZcbd5Buffk99t8rAqs+KOD M8tfYfw19hafyPRa5Z7N6kOai/yiZLGIID5ouC5hNf7+oJIfvUjqB7p9Bn5Lfmd8zXwg 3PCLlUREUv3spT7UmBV2hr+Npp7ztdV4DYl3DHnQHgrAHwpaHrMxiMEe9uZfq2OkkWCb pVd7PfSbcssDxNMaDN0mTnnBw77WL0GSnBtT36fqOnsfRRLSgLj1SL2ctMEYi9Oifvh/ TAlQ== X-Received: by 10.58.172.103 with SMTP id bb7mr94510078vec.41.1357844553928; Thu, 10 Jan 2013 11:02:33 -0800 (PST) Received: from beef.ohporter.com (cpe-24-166-64-7.neo.res.rr.com. [24.166.64.7]) by mx.google.com with ESMTPS id dx4sm902920vdb.16.2013.01.10.11.02.32 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 10 Jan 2013 11:02:32 -0800 (PST) From: Matt Porter To: Vinod Koul Subject: [PATCH v2 1/3] dmaengine: add dma_get_channel_caps() Date: Thu, 10 Jan 2013 14:07:04 -0500 Message-ID: <1357844826-30746-2-git-send-email-mporter@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1357844826-30746-1-git-send-email-mporter@ti.com> References: <1357844826-30746-1-git-send-email-mporter@ti.com> CC: Linux DaVinci Kernel List , Linux MMC List , Linux Kernel Mailing List , Grant Likely , Dan Williams , Chris Ball X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: Errors-To: davinci-linux-open-source-bounces+patchwork-davinci=patchwork.kernel.org@linux.davincidsp.com Add a dmaengine API to retrieve per channel capabilities. Currently, only channel ops and SG segment limitations are implemented caps. The API is optionally implemented by drivers and when unimplemented will return a NULL pointer. It is intended to be executed after a channel has been requested and, if the channel is intended to be used with slave SG transfers, then it may only be called after dmaengine_slave_config() has executed. The slave driver provides parameters such as burst size and address width which may be necessary for the dmaengine driver to use in order to properly return SG segment limit caps. Suggested-by: Vinod Koul Signed-off-by: Matt Porter --- include/linux/dmaengine.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index c88f302..9fd0c5b 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -371,6 +371,26 @@ struct dma_slave_config { unsigned int slave_id; }; +/* struct dmaengine_chan_caps - expose capability of a channel + * Note: each channel can have same or different capabilities + * + * This primarily classifies capabilities into + * a) APIs/ops supported + * b) channel physical capabilities + * + * @cap_mask: api/ops capability (DMA_INTERRUPT and DMA_PRIVATE + * are invalid api/ops and will never be set) + * @seg_nr: maximum number of SG segments supported on a SG/SLAVE + * channel (0 for no maximum or not a SG/SLAVE channel) + * @seg_len: maximum length of SG segments supported on a SG/SLAVE + * channel (0 for no maximum or not a SG/SLAVE channel) + */ +struct dmaengine_chan_caps { + dma_cap_mask_t cap_mask; + int seg_nr; + int seg_len; +}; + static inline const char *dma_chan_name(struct dma_chan *chan) { return dev_name(&chan->dev->device); @@ -534,6 +554,7 @@ struct dma_tx_state { * struct with auxiliary transfer status information, otherwise the call * will just return a simple status code * @device_issue_pending: push pending transactions to hardware + * @device_channel_caps: return the channel capabilities */ struct dma_device { @@ -602,6 +623,8 @@ struct dma_device { dma_cookie_t cookie, struct dma_tx_state *txstate); void (*device_issue_pending)(struct dma_chan *chan); + struct dmaengine_chan_caps *(*device_channel_caps)( + struct dma_chan *chan, enum dma_transfer_direction direction); }; static inline int dmaengine_device_control(struct dma_chan *chan, @@ -969,6 +992,23 @@ dma_set_tx_state(struct dma_tx_state *st, dma_cookie_t last, dma_cookie_t used, } } +/** + * dma_get_channel_caps - flush pending transactions to HW + * @chan: target DMA channel + * @dir: direction of transfer + * + * Get the channel-specific capabilities. If the dmaengine + * driver does not implement per channel capbilities then + * NULL is returned. + */ +static inline struct dmaengine_chan_caps +*dma_get_channel_caps(struct dma_chan *chan, enum dma_transfer_direction dir) +{ + if (chan->device->device_channel_caps) + return chan->device->device_channel_caps(chan, dir); + return NULL; +} + enum dma_status dma_sync_wait(struct dma_chan *chan, dma_cookie_t cookie); #ifdef CONFIG_DMA_ENGINE enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx);