From patchwork Thu Dec 15 09:55:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Abhishek Sahu X-Patchwork-Id: 9475781 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C239B607EE for ; Thu, 15 Dec 2016 09:58:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0863285CA for ; Thu, 15 Dec 2016 09:58:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A513A2867A; Thu, 15 Dec 2016 09:58:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23E89285CA for ; Thu, 15 Dec 2016 09:58:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757428AbcLOJ4k (ORCPT ); Thu, 15 Dec 2016 04:56:40 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:59652 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757939AbcLOJ4i (ORCPT ); Thu, 15 Dec 2016 04:56:38 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E2FAD61620; Thu, 15 Dec 2016 09:56:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1481795792; bh=oL6HcNpcdWk6WdO73mXr4/2pGJmqWcwWEYpvNmMoNdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fqFRvv4DXvOzECJRKVv7tr8dLMFZli5Wg7WH4azA/zcpe+JZ+2vjhPTkK33pJtHHt KLqJvsrM8KbMG/XRi/Btza2a4JmtcxaNDtMjBtttYqbJ9LBzJ/ozdzc8tLEB0goXbh KHKTrgRgkTgvoTK+maVSviTm8Lj+PQv0VERdA36U= Received: from chen-lnxbld15.qualcomm.com (unknown [202.46.23.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: absahu@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 6A3BE61634; Thu, 15 Dec 2016 09:56:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1481795791; bh=oL6HcNpcdWk6WdO73mXr4/2pGJmqWcwWEYpvNmMoNdk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HrU34byTTObR4ujX0YzKHQLPC04lrUutQAhlyHx1Cp99oGAcP2G6xKwP7HuBNR5sN ojh/kvFbZAewdphwCwdMh+y31PPXcdKPvWx4jSd4femrjEmP96vhr1lDFm5DjcIe6b Oxjqzciy39yn3Ew1gPKuQm1s4AZEM6jjnbKGHgB4= DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org 6A3BE61634 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=absahu@codeaurora.org From: Abhishek Sahu To: vinod.koul@intel.com, dan.j.williams@intel.com, andy.gross@linaro.org Cc: stanimir.varbanov@linaro.org, mcgrof@suse.com, okaya@codeaurora.org, pramod.gurav@linaro.org, arnd@arndb.de, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, linux-arm-msm@vger.kernel.org, Abhishek Sahu Subject: [PATCH 3/5] dmaengine: qca: bam_dma: Add support for bam sgl Date: Thu, 15 Dec 2016 15:25:53 +0530 Message-Id: <1481795755-15302-4-git-send-email-absahu@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1481795755-15302-1-git-send-email-absahu@codeaurora.org> References: <1481795755-15302-1-git-send-email-absahu@codeaurora.org> Sender: dmaengine-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: dmaengine@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The default SG does not have flag field but the BAM requires flags to be passed for each SG. Since SG is linux generic and other subsystem drivers also use this SG, so we cannot add flag field in default SG. Now, this patch adds BAM SG and its mapping operations. This BAM SG contains generic SG and DMA flag field. The mapping operations are just wrapper functions over generic SG functions with per-SG DMA flag support. Signed-off-by: Abhishek Sahu --- include/linux/dma/qcom_bam_dma.h | 78 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/include/linux/dma/qcom_bam_dma.h b/include/linux/dma/qcom_bam_dma.h index c3b68c2..2307c4d 100644 --- a/include/linux/dma/qcom_bam_dma.h +++ b/include/linux/dma/qcom_bam_dma.h @@ -17,9 +17,87 @@ #ifndef _QCOM_BAM_DMA_H #define _QCOM_BAM_DMA_H +#include + #define DESC_FLAG_INT BIT(15) #define DESC_FLAG_EOT BIT(14) #define DESC_FLAG_EOB BIT(13) #define DESC_FLAG_NWD BIT(12) +/* + * QCOM BAM DMA SGL struct + * + * @sgl: DMA SGL + * @dma_flags: BAM DMA flags + */ +struct qcom_bam_sgl { + struct scatterlist sgl; + unsigned int dma_flags; +}; + +/* + * qcom_bam_sg_init_table - Init QCOM BAM SGL + * @bam_sgl: bam sgl + * @nents: number of entries in bam sgl + * + * This function performs the initialization for each SGL in BAM SGL + * with generic SGL API. + */ +static inline void qcom_bam_sg_init_table(struct qcom_bam_sgl *bam_sgl, + unsigned int nents) +{ + int i; + + for (i = 0; i < nents; i++) + sg_init_table(&bam_sgl[i].sgl, 1); +} + +/* + * qcom_bam_unmap_sg - Unmap QCOM BAM SGL + * @dev: device for which unmapping needs to be done + * @bam_sgl: bam sgl + * @nents: number of entries in bam sgl + * @dir: dma transfer direction + * + * This function performs the DMA unmapping for each SGL in BAM SGL + * with generic SGL API. + */ +static inline void qcom_bam_unmap_sg(struct device *dev, + struct qcom_bam_sgl *bam_sgl, int nents, enum dma_data_direction dir) +{ + int i; + + for (i = 0; i < nents; i++) + dma_unmap_sg(dev, &bam_sgl[i].sgl, 1, dir); +} + +/* + * qcom_bam_map_sg - Map QCOM BAM SGL + * @dev: device for which mapping needs to be done + * @bam_sgl: bam sgl + * @nents: number of entries in bam sgl + * @dir: dma transfer direction + * + * This function performs the DMA mapping for each SGL in BAM SGL + * with generic SGL API. + * + * returns 0 on error and > 0 on success + */ +static inline int qcom_bam_map_sg(struct device *dev, + struct qcom_bam_sgl *bam_sgl, int nents, enum dma_data_direction dir) +{ + int i, ret = 0; + + for (i = 0; i < nents; i++) { + ret = dma_map_sg(dev, &bam_sgl[i].sgl, 1, dir); + if (!ret) + break; + } + + /* unmap the mapped sgl from previous loop in case of error */ + if (!ret) + qcom_bam_unmap_sg(dev, bam_sgl, i, dir); + + return ret; +} #endif