From patchwork Thu Apr 17 22:04:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Gross X-Patchwork-Id: 4011511 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 94C37BFF02 for ; Thu, 17 Apr 2014 22:06:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ACA05202EC for ; Thu, 17 Apr 2014 22:06:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C0663202EA for ; Thu, 17 Apr 2014 22:06:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WauQF-0004qG-VN; Thu, 17 Apr 2014 22:04:43 +0000 Received: from smtp.codeaurora.org ([198.145.11.231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WauQC-0004kZ-PW for linux-arm-kernel@lists.infradead.org; Thu, 17 Apr 2014 22:04:41 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id E8C5A13F459; Thu, 17 Apr 2014 22:04:19 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id CEC1F13F4BA; Thu, 17 Apr 2014 22:04:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost (rrcs-67-52-129-61.west.biz.rr.com [67.52.129.61]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: agross@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 48DF813F459; Thu, 17 Apr 2014 22:04:18 +0000 (UTC) From: Andy Gross To: Vinod Koul Subject: [PATCH] dmaengine: qcom_bam_dma: Add descriptor flag APIs Date: Thu, 17 Apr 2014 17:04:02 -0500 Message-Id: <1397772242-4048-1-git-send-email-agross@codeaurora.org> X-Mailer: git-send-email 1.7.9.5 X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140417_150440_869055_0A634989 X-CRM114-Status: GOOD ( 21.40 ) X-Spam-Score: -0.7 (/) Cc: dmaengine@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Andy Gross X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds APIs that allow for BAM hardware flags to be set per descriptor. Each one of the new flags informs the attached peripheral of a special behavior that is required. The EOT flag requests that the peripheral assert an end of transaction interrupt when that descriptor is complete. It also results in special signaling protocol that is used between the attached peripheral and the core using the DMA controller. The NWD flag requests that the peripheral wait until the data has been fully processed before signaling an interrupt. The CMD flag informs the peripheral that the descriptor payload contains command descriptors and not data descriptors. Signed-off-by: Andy Gross --- drivers/dma/qcom_bam_dma.c | 48 ++++++++++++++++++++++++++++++++++++-- include/linux/dma/qcom_bam_dma.h | 23 ++++++++++++++++++ 2 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 include/linux/dma/qcom_bam_dma.h diff --git a/drivers/dma/qcom_bam_dma.c b/drivers/dma/qcom_bam_dma.c index 02f7fef..f6c8ef1 100644 --- a/drivers/dma/qcom_bam_dma.c +++ b/drivers/dma/qcom_bam_dma.c @@ -61,12 +61,18 @@ struct bam_desc_hw { #define DESC_FLAG_INT BIT(15) #define DESC_FLAG_EOT BIT(14) #define DESC_FLAG_EOB BIT(13) +#define DESC_FLAG_NWD BIT(12) +#define DESC_FLAG_CMD BIT(11) struct bam_async_desc { struct virt_dma_desc vd; u32 num_desc; u32 xfer_len; + + /* transaction flags, EOT|EOB|NWD|CMD */ + u16 flags; + struct bam_desc_hw *curr_desc; enum dma_transfer_direction dir; @@ -800,6 +806,34 @@ static void bam_apply_new_config(struct bam_chan *bchan, bchan->reconfigure = 0; } +void qcom_bam_set_desc_eot(struct dma_async_tx_descriptor *txd) +{ + struct bam_async_desc *async_desc = container_of(txd, + struct bam_async_desc, vd.tx); + + async_desc->flags |= DESC_FLAG_EOT; +} +EXPORT_SYMBOL(qcom_bam_set_desc_eot); + +void qcom_bam_set_desc_cmd(struct dma_async_tx_descriptor *txd) +{ + struct bam_async_desc *async_desc = container_of(txd, + struct bam_async_desc, vd.tx); + + async_desc->flags |= DESC_FLAG_CMD; +} +EXPORT_SYMBOL(qcom_bam_set_desc_cmd); + +void qcom_bam_set_desc_nwd(struct dma_async_tx_descriptor *txd) +{ + struct bam_async_desc *async_desc = container_of(txd, + struct bam_async_desc, vd.tx); + + async_desc->flags |= DESC_FLAG_NWD; +} +EXPORT_SYMBOL(qcom_bam_set_desc_nwd); + + /** * bam_start_dma - start next transaction * @bchan - bam dma channel @@ -812,6 +846,7 @@ static void bam_start_dma(struct bam_chan *bchan) struct bam_desc_hw *desc; struct bam_desc_hw *fifo = PTR_ALIGN(bchan->fifo_virt, sizeof(struct bam_desc_hw)); + int i; lockdep_assert_held(&bchan->vc.lock); @@ -838,8 +873,17 @@ static void bam_start_dma(struct bam_chan *bchan) else async_desc->xfer_len = async_desc->num_desc; - /* set INT on last descriptor */ - desc[async_desc->xfer_len - 1].flags |= DESC_FLAG_INT; + /* set command descriptor flag, if applicable */ + if (async_desc->flags & DESC_FLAG_CMD) + for (i = 0; i < async_desc->xfer_len; i++) + desc[i].flags |= DESC_FLAG_CMD; + + /* set EOT or INT based on flag settings and if final transaction */ + if (async_desc->flags & DESC_FLAG_EOT && + async_desc->num_desc == async_desc->xfer_len) + desc[async_desc->xfer_len - 1].flags |= DESC_FLAG_EOT; + else + desc[async_desc->xfer_len - 1].flags |= DESC_FLAG_INT; if (bchan->tail + async_desc->xfer_len > MAX_DESCRIPTORS) { u32 partial = MAX_DESCRIPTORS - bchan->tail; diff --git a/include/linux/dma/qcom_bam_dma.h b/include/linux/dma/qcom_bam_dma.h new file mode 100644 index 0000000..65a371eb --- /dev/null +++ b/include/linux/dma/qcom_bam_dma.h @@ -0,0 +1,23 @@ +#ifndef _QCOM_BAM_DMA_H_ +#define _QCOM_BAM_DMA_H_ +/* + * Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +#include + +void qcom_bam_set_desc_cmd(struct dma_async_tx_descriptor *); +void qcom_bam_set_desc_eot(struct dma_async_tx_descriptor *); +void qcom_bam_set_desc_nwd(struct dma_async_tx_descriptor *); + +#endif