From patchwork Fri Oct 19 02:51:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Porter X-Patchwork-Id: 1616291 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by patchwork1.kernel.org (Postfix) with ESMTP id EA1593FCFC for ; Fri, 19 Oct 2012 03:53:51 +0000 (UTC) Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id q9J2pKOa015639; Thu, 18 Oct 2012 21:51:20 -0500 Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id q9J2pKij015163; Thu, 18 Oct 2012 21:51:20 -0500 Received: from dlelxv23.itg.ti.com (172.17.1.198) by dfle73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.1.323.3; Thu, 18 Oct 2012 21:51:19 -0500 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 q9J2pJn4000959; Thu, 18 Oct 2012 21:51:19 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id DE41C80627; Thu, 18 Oct 2012 21:51:19 -0500 (CDT) 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 53B4780626 for ; Thu, 18 Oct 2012 21:50:15 -0500 (CDT) Received: from red.ext.ti.com (red.ext.ti.com [192.94.93.37]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id q9J2oFCQ022625 for ; Thu, 18 Oct 2012 21:50:15 -0500 (CDT) Received: from psmtp.com (na3sys009amx177.postini.com [74.125.149.158]) by red.ext.ti.com (8.13.7/8.13.7) with SMTP id q9J2oEJU009619 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 18 Oct 2012 21:50:14 -0500 Received: from mail-ie0-f173.google.com ([209.85.223.173]) (using TLSv1) by na3sys009amx177.postini.com ([74.125.148.10]) with SMTP; Thu, 18 Oct 2012 22:50:14 EDT Received: by mail-ie0-f173.google.com with SMTP id 17so9420iea.4 for ; Thu, 18 Oct 2012 19:50:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=p3mc9zRA7R8BWH5wZklV8HXdtWG5oKt2QM9vAujk7zg=; b=RCtTK7PVQ1Iwo6uom/5zS+4eKwFMWq5pgqQwG7FP5hp9UKIuYZo40xa0YR3IBY6Q2u l/C0p/u0l2z/sGo/oK2aZ4OSSKlE1i1Z97naTw7oLAgs9Ivw1gClNqJOxxWeTzrBFIO4 VHgJ/AUKwMplfv5Z0odu9Dzo+Bg5IqyG1nUj8cRcBQU0izGWchLA5gfns7STj9LHjjnE Rs1rvInHPMAsx39sKAMKqqqHzwst9pvsZrU6tIavhv5olFEvEO2whXN5W+mIRSQ7EL5s xl25/6BBm96oVOJTSGjhxkbpvvACuud2H7ehCQTYFAGMq9FUsK+QfReEnOpz0GWz/8JU ywYg== Received: by 10.43.48.129 with SMTP id uw1mr16867321icb.10.1350615013964; Thu, 18 Oct 2012 19:50:13 -0700 (PDT) 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 rd10sm5461208igb.1.2012.10.18.19.50.12 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 18 Oct 2012 19:50:13 -0700 (PDT) From: Matt Porter To: Vinod Koul Subject: [RFC PATCH 1/3] dmaengine: add dma_get_channel_caps() Date: Thu, 18 Oct 2012 22:51:26 -0400 Message-ID: <1350615088-14562-2-git-send-email-mporter@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1350615088-14562-1-git-send-email-mporter@ti.com> References: <1350615088-14562-1-git-send-email-mporter@ti.com> X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:99.90000/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-dkim: 1 skipped:not-enabled X-pstn-settings: 2 (0.5000:0.0050) s cv GT3 gt2 gt1 r p m c X-pstn-addresses: from [82/3] CC: Linux DaVinci Kernel List , Chris Ball , Linux MMC List , Linux Kernel Mailing List , Dan Williams 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@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 | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index 11d9e25..0181887 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -371,6 +371,38 @@ struct dma_slave_config { unsigned int slave_id; }; +enum dmaengine_apis { + DMAENGINE_MEMCPY = 0x0001, + DMAENGINE_XOR = 0x0002, + DMAENGINE_XOR_VAL = 0x0004, + DMAENGINE_PQ = 0x0008, + DMAENGINE_PQ_VAL = 0x0010, + DMAENGINE_MEMSET = 0x0020, + DMAENGINE_SLAVE = 0x0040, + DMAENGINE_CYCLIC = 0x0080, + DMAENGINE_INTERLEAVED = 0x0100, + DMAENGINE_SG = 0x0200, +}; + +/* 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 + * + * @ops: or'ed api capability + * @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 { + enum dmaengine_apis ops; + 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 +566,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 +635,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 +1004,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);