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: 4011481 Return-Path: X-Original-To: patchwork-dmaengine@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 19EE49F319 for ; Thu, 17 Apr 2014 22:04:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1D92120303 for ; Thu, 17 Apr 2014 22:04:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C1C57202EC for ; Thu, 17 Apr 2014 22:04:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751104AbaDQWEV (ORCPT ); Thu, 17 Apr 2014 18:04:21 -0400 Received: from smtp.codeaurora.org ([198.145.11.231]:46701 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750983AbaDQWEU (ORCPT ); Thu, 17 Apr 2014 18:04:20 -0400 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=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, Andy Gross 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 Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.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