From: Abhishek Sahu <absahu@codeaurora.org>
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 <absahu@codeaurora.org>
Subject: [PATCH 3/5] dmaengine: qca: bam_dma: Add support for bam sgl
Date: Thu, 15 Dec 2016 15:25:53 +0530 [thread overview]
Message-ID: <1481795755-15302-4-git-send-email-absahu@codeaurora.org> (raw)
In-Reply-To: <1481795755-15302-1-git-send-email-absahu@codeaurora.org>
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 <absahu@codeaurora.org>
---
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 <linux/dma-mapping.h>
+
#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
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2016-12-15 9:55 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-15 9:55 [PATCH 0/5] Support for QCA BAM DMA command descriptor Abhishek Sahu
2016-12-15 9:55 ` [PATCH 1/5] dmaengine: qca: bam_dma: Add header file for bam driver Abhishek Sahu
2016-12-15 9:55 ` [PATCH 2/5] dmaengine: Add support for custom data mapping Abhishek Sahu
2016-12-18 16:26 ` Vinod Koul
2016-12-19 5:06 ` Andy Gross
2016-12-19 15:49 ` Vinod Koul
2016-12-19 17:52 ` Andy Gross
2016-12-20 19:28 ` Abhishek Sahu
2016-12-20 20:25 ` Andy Gross
2016-12-21 19:34 ` Abhishek Sahu
2016-12-29 17:54 ` Andy Gross
2017-01-02 14:25 ` Abhishek Sahu
2017-01-02 16:12 ` Andy Gross
2017-01-19 5:01 ` Vinod Koul
2017-01-19 14:13 ` Andy Gross
2017-01-19 14:57 ` Abhishek Sahu
2017-01-20 16:56 ` Vinod Koul
2017-04-07 13:58 ` Abhishek Sahu
2016-12-15 9:55 ` Abhishek Sahu [this message]
2016-12-15 9:55 ` [PATCH 4/5] dmaengine: qca: bam_dma: implement " Abhishek Sahu
2016-12-15 9:55 ` [PATCH 5/5] dmaengine: qca: bam_dma: implement command descriptor Abhishek Sahu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1481795755-15302-4-git-send-email-absahu@codeaurora.org \
--to=absahu@codeaurora.org \
--cc=andy.gross@linaro.org \
--cc=arnd@arndb.de \
--cc=dan.j.williams@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@suse.com \
--cc=okaya@codeaurora.org \
--cc=pramod.gurav@linaro.org \
--cc=stanimir.varbanov@linaro.org \
--cc=vinod.koul@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).