Skip to contentSkip to conversation

dmaengine: fsl-dpaa2-qdma: Add the DPDMAI(Data Path DMA Interface) support

PATCH Superseded Peng Ma 3 participants 9 messages Apr 9, 2019 – Jun 14, 2019 dmaengine

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Peng Ma

author
#0 lore raw

PATCH v3 1/2 dmaengine: fsl-dpaa2-qdma: Add the DPDMAI(Data Path DMA Interface) support

The MC exports the DPDMAI object as an interface to operate the DPAA2 QDMA Engine. The DPDMAI enables sending frame-based requests to QDMA and receiving back confirmation response on transaction completion, utilizing the DPAA2 QBMan infrastructure. DPDMAI object provides up to two priorities for processing QDMA requests.
The following list summarizes the DPDMAI main features and capabilities:
1. Supports up to two scheduling priorities for processing service requests.
- Each DPDMAI transmit queue is mapped to one of two service priorities, allowing further prioritization in hardware between requests from different DPDMAI objects.
2. Supports up to two receive queues for incoming transaction completion confirmations.
- Each DPDMAI receive queue is mapped to one of two receive priorities, allowing further prioritization between other interfaces when associating the DPDMAI receive queues to DPIO or DPCON objects.
3. Supports different scheduling options for processing received packets:
- Queues can be configured either in 'parked' mode (default), oattached to a DPIO object, or attached to DPCON object.
4. Allows interaction with one or more DPIO objects for dequeueing/enqueueing frame descriptors(FD) and for acquiring/releasing buffers.
5. Supports enable, disable, and reset operations.
Add dpdmai to support some platforms with dpaa2 qdma engine.

---
changed for v3:
- no changed

 drivers/dma/fsl-dpaa2-qdma/dpdmai.c     |  483 ++++++++++++++++++++++++++++
 drivers/dma/fsl-dpaa2-qdma/dpdmai.h     |  524 +++++++++++++++++++++++++++++++
 drivers/dma/fsl-dpaa2-qdma/dpdmai_cmd.h |  197 ++++++++++++
 3 files changed, 1204 insertions(+), 0 deletions(-)
 create mode 100644 drivers/dma/fsl-dpaa2-qdma/dpdmai.c
 create mode 100644 drivers/dma/fsl-dpaa2-qdma/dpdmai.h
 create mode 100644 drivers/dma/fsl-dpaa2-qdma/dpdmai_cmd.h
drivers/dma/fsl-dpaa2-qdma/dpdmai.c new file +483 -0
new file mode 100644
index 0000000..685eabe
@@ -0,0 +1,483 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright 2014-2018 NXP
+
+#include <linux/types.h>
+#include <linux/io.h>
+#include "dpdmai.h"
+#include "dpdmai_cmd.h"
+#include <linux/fsl/mc.h>
+
+struct dpdmai_cmd_open {
+	__le32 dpdmai_id;
+};
+
+struct dpdmai_rsp_get_attributes {
+	__le32 id;
+	u8 num_of_priorities;
+	u8 pad0[3];
+	__le16 major;
+	__le16 minor;
+};
+
+struct dpdmai_cmd_queue {
+	__le32 dest_id;
+	u8 priority;
+	u8 queue;
+	u8 dest_type;
+	u8 pad;
+	__le64 user_ctx;
+	union {
+		__le32 options;
+		__le32 fqid;
+	};
+};
+
+struct dpdmai_rsp_get_tx_queue {
+	__le64 pad;
+	__le32 fqid;
+};
+
+int dpdmai_open(struct fsl_mc_io *mc_io,
+		u32 cmd_flags,
+		int dpdmai_id,
+		u16 *token)
+{
+	struct fsl_mc_command cmd = { 0 };
+	struct dpdmai_cmd_open *cmd_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_OPEN,
+					  cmd_flags,
+					  0);
+
+	cmd_params = (struct dpdmai_cmd_open *)cmd.params;
+	cmd_params->dpdmai_id = cpu_to_le32(dpdmai_id);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	*token = mc_cmd_hdr_read_token(&cmd);
+	return 0;
+}
+
+int dpdmai_close(struct fsl_mc_io *mc_io,
+		 u32 cmd_flags,
+		 u16 token)
+{
+	struct fsl_mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_CLOSE,
+					  cmd_flags, token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+int dpdmai_create(struct fsl_mc_io *mc_io,
+		  u32 cmd_flags,
+		  const struct dpdmai_cfg *cfg,
+		  u16 *token)
+{
+	struct fsl_mc_command cmd = { 0 };
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_CREATE,
+					  cmd_flags,
+					  0);
+	DPDMAI_CMD_CREATE(cmd, cfg);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	*token = MC_CMD_HDR_READ_TOKEN(cmd.header);
+
+	return 0;
+}
+
+int dpdmai_destroy(struct fsl_mc_io *mc_io,
+		   u32 cmd_flags,
+		   u16 token)
+{
+	struct fsl_mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_DESTROY,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+int dpdmai_enable(struct fsl_mc_io *mc_io,
+		  u32 cmd_flags,
+		  u16 token)
+{
+	struct fsl_mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_ENABLE,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+int dpdmai_disable(struct fsl_mc_io *mc_io,
+		   u32 cmd_flags,
+		   u16 token)
+{
+	struct fsl_mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_DISABLE,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+int dpdmai_is_enabled(struct fsl_mc_io *mc_io,
+		      u32 cmd_flags,
+		      u16 token,
+		      int *en)
+{
+	struct fsl_mc_command cmd = { 0 };
+	int err;
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_IS_ENABLED,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	DPDMAI_RSP_IS_ENABLED(cmd, *en);
+
+	return 0;
+}
+
+int dpdmai_reset(struct fsl_mc_io *mc_io,
+		 u32 cmd_flags,
+		 u16 token)
+{
+	struct fsl_mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_RESET,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+int dpdmai_get_irq(struct fsl_mc_io *mc_io,
+		   u32 cmd_flags,
+		   u16 token,
+		   u8 irq_index,
+		   int *type,
+		   struct dpdmai_irq_cfg	*irq_cfg)
+{
+	struct fsl_mc_command cmd = { 0 };
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_GET_IRQ,
+					  cmd_flags,
+					  token);
+	DPDMAI_CMD_GET_IRQ(cmd, irq_index);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	DPDMAI_RSP_GET_IRQ(cmd, *type, irq_cfg);
+
+	return 0;
+}
+
+int dpdmai_set_irq(struct fsl_mc_io *mc_io,
+		   u32 cmd_flags,
+		   u16 token,
+		   u8 irq_index,
+		   struct dpdmai_irq_cfg *irq_cfg)
+{
+	struct fsl_mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_SET_IRQ,
+					  cmd_flags,
+					  token);
+	DPDMAI_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+int dpdmai_get_irq_enable(struct fsl_mc_io *mc_io,
+			  u32 cmd_flags,
+			  u16 token,
+			  u8 irq_index,
+			  u8 *en)
+{
+	struct fsl_mc_command cmd = { 0 };
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_GET_IRQ_ENABLE,
+					  cmd_flags,
+					  token);
+	DPDMAI_CMD_GET_IRQ_ENABLE(cmd, irq_index);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	DPDMAI_RSP_GET_IRQ_ENABLE(cmd, *en);
+
+	return 0;
+}
+
+int dpdmai_set_irq_enable(struct fsl_mc_io *mc_io,
+			  u32 cmd_flags,
+			  u16 token,
+			  u8 irq_index,
+			  u8 en)
+{
+	struct fsl_mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_SET_IRQ_ENABLE,
+					  cmd_flags,
+					  token);
+	DPDMAI_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+int dpdmai_get_irq_mask(struct fsl_mc_io *mc_io,
+			u32 cmd_flags,
+			u16 token,
+			u8 irq_index,
+			u32 *mask)
+{
+	struct fsl_mc_command cmd = { 0 };
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_GET_IRQ_MASK,
+					  cmd_flags,
+					  token);
+	DPDMAI_CMD_GET_IRQ_MASK(cmd, irq_index);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	DPDMAI_RSP_GET_IRQ_MASK(cmd, *mask);
+
+	return 0;
+}
+
+int dpdmai_set_irq_mask(struct fsl_mc_io *mc_io,
+			u32 cmd_flags,
+			u16 token,
+			u8 irq_index,
+			u32 mask)
+{
+	struct fsl_mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_SET_IRQ_MASK,
+					  cmd_flags,
+					  token);
+	DPDMAI_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+int dpdmai_get_irq_status(struct fsl_mc_io *mc_io,
+			  u32 cmd_flags,
+			  u16 token,
+			  u8 irq_index,
+			  u32 *status)
+{
+	struct fsl_mc_command cmd = { 0 };
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_GET_IRQ_STATUS,
+					  cmd_flags,
+					  token);
+	DPDMAI_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	DPDMAI_RSP_GET_IRQ_STATUS(cmd, *status);
+
+	return 0;
+}
+
+int dpdmai_clear_irq_status(struct fsl_mc_io *mc_io,
+			    u32 cmd_flags,
+			    u16 token,
+			    u8 irq_index,
+			    u32 status)
+{
+	struct fsl_mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_CLEAR_IRQ_STATUS,
+					  cmd_flags,
+					  token);
+	DPDMAI_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+int dpdmai_get_attributes(struct fsl_mc_io *mc_io,
+			  u32 cmd_flags,
+			  u16 token,
+			  struct dpdmai_attr *attr)
+{
+	struct fsl_mc_command cmd = { 0 };
+	int err;
+	struct dpdmai_rsp_get_attributes *rsp_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_GET_ATTR,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmai_rsp_get_attributes *)cmd.params;
+	attr->id = le32_to_cpu(rsp_params->id);
+	attr->version.major = le16_to_cpu(rsp_params->major);
+	attr->version.minor = le16_to_cpu(rsp_params->minor);
+	attr->num_of_priorities = rsp_params->num_of_priorities;
+
+	return 0;
+}
+
+int dpdmai_set_rx_queue(struct fsl_mc_io *mc_io,
+			u32 cmd_flags,
+			u16 token,
+			u8 priority,
+			const struct dpdmai_rx_queue_cfg *cfg)
+{
+	struct fsl_mc_command cmd = { 0 };
+	struct dpdmai_cmd_queue *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_SET_RX_QUEUE,
+					  cmd_flags,
+					  token);
+
+	cmd_params = (struct dpdmai_cmd_queue *)cmd.params;
+	cmd_params->dest_id = cpu_to_le32(cfg->dest_cfg.dest_id);
+	cmd_params->priority = cfg->dest_cfg.priority;
+	cmd_params->queue = priority;
+	cmd_params->dest_type = cfg->dest_cfg.dest_type;
+	cmd_params->user_ctx = cpu_to_le64(cfg->user_ctx);
+	cmd_params->options = cpu_to_le32(cfg->options);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+int dpdmai_get_rx_queue(struct fsl_mc_io *mc_io,
+			u32 cmd_flags,
+			u16 token,
+			u8 priority, struct dpdmai_rx_queue_attr *attr)
+{
+	struct fsl_mc_command cmd = { 0 };
+	struct dpdmai_cmd_queue *cmd_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_GET_RX_QUEUE,
+					  cmd_flags,
+					  token);
+
+	cmd_params = (struct dpdmai_cmd_queue *)cmd.params;
+	cmd_params->queue = priority;
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	attr->dest_cfg.dest_id = le32_to_cpu(cmd_params->dest_id);
+	attr->dest_cfg.priority = cmd_params->priority;
+	attr->dest_cfg.dest_type = cmd_params->dest_type;
+	attr->user_ctx = le64_to_cpu(cmd_params->user_ctx);
+	attr->fqid = le32_to_cpu(cmd_params->fqid);
+
+	return 0;
+}
+
+int dpdmai_get_tx_queue(struct fsl_mc_io *mc_io,
+			u32 cmd_flags,
+			u16 token,
+			u8 priority,
+			struct dpdmai_tx_queue_attr *attr)
+{
+	struct fsl_mc_command cmd = { 0 };
+	struct dpdmai_cmd_queue *cmd_params;
+	struct dpdmai_rsp_get_tx_queue *rsp_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_GET_TX_QUEUE,
+					  cmd_flags,
+					  token);
+
+	cmd_params = (struct dpdmai_cmd_queue *)cmd.params;
+	cmd_params->queue = priority;
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+
+	rsp_params = (struct dpdmai_rsp_get_tx_queue *)cmd.params;
+	attr->fqid = le32_to_cpu(rsp_params->fqid);
+
+	return 0;
+}
drivers/dma/fsl-dpaa2-qdma/dpdmai.h new file +524 -0

524 lines not on this page · raw message

drivers/dma/fsl-dpaa2-qdma/dpdmai_cmd.h new file +197 -0

197 lines not on this page · raw message

author
#1 lore raw

PATCH v3 2/2 dmaengine: fsl-dpaa2-qdma: Add NXP dpaa2 qDMA controller driver for Layerscape SoCs

DPPA2(Data Path Acceleration Architecture 2) qDMA
The qDMA supports channel virtualization by allowing DMA jobs to be enqueued into different frame queues. Core can initiate a DMA transaction by preparing a frame descriptor(FD) for each DMA job and enqueuing this job to a frame queue. through a hardware portal. The qDMA prefetches DMA jobs from the frame queues. It then schedules and dispatches to internal DMA hardware engines, which generate read and write requests. Both qDMA source data and destination data can be either contiguous or non-contiguous using one or more scatter/gather tables. The qDMA supports global bandwidth flow control where all DMA transactions are stalled if the bandwidth threshold has been reached. Also supported are transaction based read throttling.

Add NXP dppa2 qDMA to support some of Layerscape SoCs. such as: LS1088A, LS208xA, LX2, etc.

---
changed for v3:
- Add depends on arm64 for dpaa2 qdma driver
- The dpaa2_io_service_[de]register functions have a new parameter So update all calls to some functions

 drivers/dma/Kconfig                     |    2 +
 drivers/dma/Makefile                    |    1 +
 drivers/dma/fsl-dpaa2-qdma/Kconfig      |    9 +
 drivers/dma/fsl-dpaa2-qdma/Makefile     |    3 +
 drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c |  782 +++++++++++++++++++++++++++++++
 drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.h |  152 ++++++
 6 files changed, 949 insertions(+), 0 deletions(-)
 create mode 100644 drivers/dma/fsl-dpaa2-qdma/Kconfig
 create mode 100644 drivers/dma/fsl-dpaa2-qdma/Makefile
 create mode 100644 drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
 create mode 100644 drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.h
drivers/dma/Kconfig +2 -0
index eaf78f4..08aae01 100644
@@ -671,6 +671,8 @@ source "drivers/dma/sh/Kconfig"
 
 source "drivers/dma/ti/Kconfig"
 
+source "drivers/dma/fsl-dpaa2-qdma/Kconfig"
+
 # clients
 comment "DMA Clients"
 	depends on DMA_ENGINE
drivers/dma/Makefile +1 -0
index 6126e1c..2499ed8 100644
@@ -75,6 +75,7 @@ obj-$(CONFIG_UNIPHIER_MDMAC) += uniphier-mdmac.o
 obj-$(CONFIG_XGENE_DMA) += xgene-dma.o
 obj-$(CONFIG_ZX_DMA) += zx_dma.o
 obj-$(CONFIG_ST_FDMA) += st_fdma.o
+obj-$(CONFIG_FSL_DPAA2_QDMA) += fsl-dpaa2-qdma/
 
 obj-y += mediatek/
 obj-y += qcom/
drivers/dma/fsl-dpaa2-qdma/Kconfig new file +9 -0
new file mode 100644
index 0000000..258ed6b
@@ -0,0 +1,9 @@
+menuconfig FSL_DPAA2_QDMA
+	tristate "NXP DPAA2 QDMA"
+	depends on ARM64
+	depends on FSL_MC_BUS && FSL_MC_DPIO
+	select DMA_ENGINE
+	select DMA_VIRTUAL_CHANNELS
+	help
+	  NXP Data Path Acceleration Architecture 2 QDMA driver,
+	  using the NXP MC bus driver.
drivers/dma/fsl-dpaa2-qdma/Makefile new file +3 -0
new file mode 100644
index 0000000..c1d0226
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+# Makefile for the NXP DPAA2 qDMA controllers
+obj-$(CONFIG_FSL_DPAA2_QDMA) += dpaa2-qdma.o dpdmai.o
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +782 -0

782 lines not on this page · raw message

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.h new file +152 -0

152 lines not on this page · raw message

maintainer
#2 lore raw

Re: [V3 2/2] dmaengine: fsl-dpaa2-qdma: Add NXP dpaa2 qDMA controller driver for Layerscape SoCs

Quoted 166 lines · Peng Ma

DPPA2(Data Path Acceleration Architecture 2) qDMA
The qDMA supports channel virtualization by allowing DMA jobs to be enqueued into different frame queues. Core can initiate a DMA transaction by preparing a frame descriptor(FD) for each DMA job and enqueuing this job to a frame queue. through a hardware portal. The qDMA prefetches DMA jobs from the frame queues. It then schedules and dispatches to internal DMA hardware engines, which generate read and write requests. Both qDMA source data and destination data can be either contiguous or non-contiguous using one or more scatter/gather tables. The qDMA supports global bandwidth flow control where all DMA transactions are stalled if the bandwidth threshold has been reached. Also supported are transaction based read throttling.

Add NXP dppa2 qDMA to support some of Layerscape SoCs. such as: LS1088A, LS208xA, LX2, etc.

---
changed for v3:
- Add depends on arm64 for dpaa2 qdma driver
- The dpaa2_io_service_[de]register functions have a new parameter So update all calls to some functions

 drivers/dma/Kconfig                     |    2 +
 drivers/dma/Makefile                    |    1 +
 drivers/dma/fsl-dpaa2-qdma/Kconfig      |    9 +
 drivers/dma/fsl-dpaa2-qdma/Makefile     |    3 +
 drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c |  782 +++++++++++++++++++++++++++++++
 drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.h |  152 ++++++
 6 files changed, 949 insertions(+), 0 deletions(-)
 create mode 100644 drivers/dma/fsl-dpaa2-qdma/Kconfig
 create mode 100644 drivers/dma/fsl-dpaa2-qdma/Makefile
 create mode 100644 drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
 create mode 100644 drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.h
drivers/dma/Kconfig +2 -0
index eaf78f4..08aae01 100644
@@ -671,6 +671,8 @@ source "drivers/dma/sh/Kconfig"
 
 source "drivers/dma/ti/Kconfig"
 
+source "drivers/dma/fsl-dpaa2-qdma/Kconfig"
+
 # clients
 comment "DMA Clients"
 	depends on DMA_ENGINE
drivers/dma/Makefile +1 -0
index 6126e1c..2499ed8 100644
@@ -75,6 +75,7 @@ obj-$(CONFIG_UNIPHIER_MDMAC) += uniphier-mdmac.o
 obj-$(CONFIG_XGENE_DMA) += xgene-dma.o
 obj-$(CONFIG_ZX_DMA) += zx_dma.o
 obj-$(CONFIG_ST_FDMA) += st_fdma.o
+obj-$(CONFIG_FSL_DPAA2_QDMA) += fsl-dpaa2-qdma/
 
 obj-y += mediatek/
 obj-y += qcom/
drivers/dma/fsl-dpaa2-qdma/Kconfig new file +9 -0
new file mode 100644
index 0000000..258ed6b
@@ -0,0 +1,9 @@
+menuconfig FSL_DPAA2_QDMA
+	tristate "NXP DPAA2 QDMA"
+	depends on ARM64
+	depends on FSL_MC_BUS && FSL_MC_DPIO
+	select DMA_ENGINE
+	select DMA_VIRTUAL_CHANNELS
+	help
+	  NXP Data Path Acceleration Architecture 2 QDMA driver,
+	  using the NXP MC bus driver.
drivers/dma/fsl-dpaa2-qdma/Makefile new file +3 -0
new file mode 100644
index 0000000..c1d0226
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+# Makefile for the NXP DPAA2 qDMA controllers
+obj-$(CONFIG_FSL_DPAA2_QDMA) += dpaa2-qdma.o dpdmai.o
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +77 -0
new file mode 100644
index 0000000..0cdde0f
@@ -0,0 +1,782 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright 2014-2018 NXP
+
+/*
+ * Author: Changming Huang <[email protected]>
+ *
+ * Driver for the NXP QDMA engine with QMan mode.
+ * Channel virtualization is supported through enqueuing of DMA jobs to,
+ * or dequeuing DMA jobs from different work queues with QMan portal.
+ * This module can be found on NXP LS2 SoCs.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/dmapool.h>
+#include <linux/of_irq.h>
+#include <linux/iommu.h>
+#include <linux/sys_soc.h>
+#include <linux/fsl/mc.h>
+#include <soc/fsl/dpaa2-io.h>
+
+#include "../virt-dma.h"
+#include "dpdmai_cmd.h"
+#include "dpdmai.h"
+#include "dpaa2-qdma.h"
+
+static bool smmu_disable = true;
+
+static struct dpaa2_qdma_chan *to_dpaa2_qdma_chan(struct dma_chan *chan)
+{
+	return container_of(chan, struct dpaa2_qdma_chan, vchan.chan);
+}
+
+static struct dpaa2_qdma_comp *to_fsl_qdma_comp(struct virt_dma_desc *vd)
+{
+	return container_of(vd, struct dpaa2_qdma_comp, vdesc);
+}
+
+static int dpaa2_qdma_alloc_chan_resources(struct dma_chan *chan)
+{
+	struct dpaa2_qdma_chan *dpaa2_chan = to_dpaa2_qdma_chan(chan);
+	struct dpaa2_qdma_engine *dpaa2_qdma = dpaa2_chan->qdma;
+	struct device *dev = &dpaa2_qdma->priv->dpdmai_dev->dev;
+
+	dpaa2_chan->fd_pool = dma_pool_create("fd_pool", dev,
+					      FD_POOL_SIZE, 32, 0);
+	if (!dpaa2_chan->fd_pool)
+		return -ENOMEM;
+
+	return dpaa2_qdma->desc_allocated++;
+}
+
+static void dpaa2_qdma_free_chan_resources(struct dma_chan *chan)
+{
+	struct dpaa2_qdma_chan *dpaa2_chan = to_dpaa2_qdma_chan(chan);
+	struct dpaa2_qdma_engine *dpaa2_qdma = dpaa2_chan->qdma;
+	unsigned long flags;
+
+	LIST_HEAD(head);
+
+	spin_lock_irqsave(&dpaa2_chan->vchan.lock, flags);
+	vchan_get_all_descriptors(&dpaa2_chan->vchan, &head);
+	spin_unlock_irqrestore(&dpaa2_chan->vchan.lock, flags);
+
+	vchan_dma_desc_free_list(&dpaa2_chan->vchan, &head);
+
+	dpaa2_dpdmai_free_comp(dpaa2_chan, &dpaa2_chan->comp_used);
+	dpaa2_dpdmai_free_comp(dpaa2_chan, &dpaa2_chan->comp_free);
+
+	dma_pool_destroy(dpaa2_chan->fd_pool);
+	dpaa2_qdma->desc_allocated--;
+}
+
+/*
+ * Request a command descriptor for enqueue.
+ */

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 87

Quoted 10 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +10 -0
+static struct dpaa2_qdma_comp *
+dpaa2_qdma_request_desc(struct dpaa2_qdma_chan *dpaa2_chan)
+{
+	struct dpaa2_qdma_comp *comp_temp = NULL;
+	unsigned long flags;
+
+	spin_lock_irqsave(&dpaa2_chan->queue_lock, flags);
+	if (list_empty(&dpaa2_chan->comp_free)) {
+		spin_unlock_irqrestore(&dpaa2_chan->queue_lock, flags);
+		comp_temp = kzalloc(sizeof(*comp_temp), GFP_KERNEL);

GFP_NOWAIT?

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 93

Quoted 6 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +6 -0
+		if (!comp_temp)
+			goto err;
+		comp_temp->fd_virt_addr =
+			dma_pool_alloc(dpaa2_chan->fd_pool, GFP_NOWAIT,
+				       &comp_temp->fd_bus_addr);
+		if (!comp_temp->fd_virt_addr)

err handling seems incorrect, you dont clean up, caller doesnt check return!

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 98

Quoted 5 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +5 -0
+			goto err;
+
+		comp_temp->fl_virt_addr =
+			(void *)((struct dpaa2_fd *)
+				comp_temp->fd_virt_addr + 1);

casts and pointer math, what could go wrong!! This doesnt smell right!

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 100

Quoted 2 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +2 -0
+		comp_temp->fl_bus_addr = comp_temp->fd_bus_addr +
+					sizeof(struct dpaa2_fd);

why not use fl_virt_addr and get the bus_address?

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 105

Quoted 5 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +5 -0
+		comp_temp->desc_virt_addr =
+			(void *)((struct dpaa2_fl_entry *)
+				comp_temp->fl_virt_addr + 3);
+		comp_temp->desc_bus_addr = comp_temp->fl_bus_addr +
+				sizeof(struct dpaa2_fl_entry) * 3;

pointer math in the two calls doesnt match and as I said doesnt look good...

Quoted 10 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +10 -0
+
+		comp_temp->qchan = dpaa2_chan;
+		return comp_temp;
+	}
+	comp_temp = list_first_entry(&dpaa2_chan->comp_free,
+				     struct dpaa2_qdma_comp, list);
+	list_del(&comp_temp->list);
+	spin_unlock_irqrestore(&dpaa2_chan->queue_lock, flags);
+
+	comp_temp->qchan = dpaa2_chan;

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 125

Quoted 10 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +10 -0
+err:
+	return comp_temp;
+}
+
+static void
+dpaa2_qdma_populate_fd(u32 format, struct dpaa2_qdma_comp *dpaa2_comp)
+{
+	struct dpaa2_fd *fd;
+
+	fd = (struct dpaa2_fd *)dpaa2_comp->fd_virt_addr;

whats with the casts! you seem to like them! You are casting away from void!

Quoted 12 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +12 -0
+	memset(fd, 0, sizeof(struct dpaa2_fd));
+
+	/* fd populated */
+	dpaa2_fd_set_addr(fd, dpaa2_comp->fl_bus_addr);
+	/* Bypass memory translation, Frame list format, short length disable */
+	/* we need to disable BMT if fsl-mc use iova addr */
+	if (smmu_disable)
+		dpaa2_fd_set_bpid(fd, QMAN_FD_BMT_ENABLE);
+	dpaa2_fd_set_format(fd, QMAN_FD_FMT_ENABLE | QMAN_FD_SL_DISABLE);
+
+	dpaa2_fd_set_frc(fd, format | QDMA_SER_CTX);
+}

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 147

Quoted 10 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +10 -0
+
+/* first frame list for descriptor buffer */
+static void
+dpaa2_qdma_populate_first_framel(struct dpaa2_fl_entry *f_list,
+				 struct dpaa2_qdma_comp *dpaa2_comp,
+				 bool wrt_changed)
+{
+	struct dpaa2_qdma_sd_d *sdd;
+
+	sdd = (struct dpaa2_qdma_sd_d *)dpaa2_comp->desc_virt_addr;

again

Quoted 64 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +64 -0
+	memset(sdd, 0, 2 * (sizeof(*sdd)));
+
+	/* source descriptor CMD */
+	sdd->cmd = cpu_to_le32(QDMA_SD_CMD_RDTTYPE_COHERENT);
+	sdd++;
+
+	/* dest descriptor CMD */
+	if (wrt_changed)
+		sdd->cmd = cpu_to_le32(LX2160_QDMA_DD_CMD_WRTTYPE_COHERENT);
+	else
+		sdd->cmd = cpu_to_le32(QDMA_DD_CMD_WRTTYPE_COHERENT);
+
+	memset(f_list, 0, sizeof(struct dpaa2_fl_entry));
+
+	/* first frame list to source descriptor */
+	dpaa2_fl_set_addr(f_list, dpaa2_comp->desc_bus_addr);
+	dpaa2_fl_set_len(f_list, 0x20);
+	dpaa2_fl_set_format(f_list, QDMA_FL_FMT_SBF | QDMA_FL_SL_LONG);
+
+	/* bypass memory translation */
+	if (smmu_disable)
+		f_list->bpid = cpu_to_le16(QDMA_FL_BMT_ENABLE);
+}
+
+/* source and destination frame list */
+static void
+dpaa2_qdma_populate_frames(struct dpaa2_fl_entry *f_list,
+			   dma_addr_t dst, dma_addr_t src,
+			   size_t len, uint8_t fmt)
+{
+	/* source frame list to source buffer */
+	memset(f_list, 0, sizeof(struct dpaa2_fl_entry));
+
+	dpaa2_fl_set_addr(f_list, src);
+	dpaa2_fl_set_len(f_list, len);
+
+	/* single buffer frame or scatter gather frame */
+	dpaa2_fl_set_format(f_list, (fmt | QDMA_FL_SL_LONG));
+
+	/* bypass memory translation */
+	if (smmu_disable)
+		f_list->bpid = cpu_to_le16(QDMA_FL_BMT_ENABLE);
+
+	f_list++;
+
+	/* destination frame list to destination buffer */
+	memset(f_list, 0, sizeof(struct dpaa2_fl_entry));
+
+	dpaa2_fl_set_addr(f_list, dst);
+	dpaa2_fl_set_len(f_list, len);
+	dpaa2_fl_set_format(f_list, (fmt | QDMA_FL_SL_LONG));
+	/* single buffer frame or scatter gather frame */
+	dpaa2_fl_set_final(f_list, QDMA_FL_F);
+	/* bypass memory translation */
+	if (smmu_disable)
+		f_list->bpid = cpu_to_le16(QDMA_FL_BMT_ENABLE);
+}
+
+static struct dma_async_tx_descriptor
+*dpaa2_qdma_prep_memcpy(struct dma_chan *chan, dma_addr_t dst,
+			dma_addr_t src, size_t len, ulong flags)
+{
+	struct dpaa2_qdma_chan *dpaa2_chan = to_dpaa2_qdma_chan(chan);
+	struct dpaa2_qdma_engine *dpaa2_qdma;

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 221

Quoted 10 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +10 -0
+	struct dpaa2_qdma_comp *dpaa2_comp;
+	struct dpaa2_fl_entry *f_list;
+	bool wrt_changed;
+	u32 format;
+
+	dpaa2_qdma = dpaa2_chan->qdma;
+	dpaa2_comp = dpaa2_qdma_request_desc(dpaa2_chan);
+	wrt_changed = (bool)dpaa2_qdma->qdma_wrtype_fixup;
+
+#ifdef LONG_FORMAT

compile flag and define, so else part is dead code??

Quoted 42 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +42 -0
+	format = QDMA_FD_LONG_FORMAT;
+#else
+	format = QDMA_FD_SHORT_FORMAT;
+#endif
+	/* populate Frame descriptor */
+	dpaa2_qdma_populate_fd(format, dpaa2_comp);
+
+	f_list = (struct dpaa2_fl_entry *)dpaa2_comp->fl_virt_addr;
+
+#ifdef LONG_FORMAT
+	/* first frame list for descriptor buffer (logn format) */
+	dpaa2_qdma_populate_first_framel(f_list, dpaa2_comp, wrt_changed);
+
+	f_list++;
+#endif
+
+	dpaa2_qdma_populate_frames(f_list, dst, src, len, QDMA_FL_FMT_SBF);
+
+	return vchan_tx_prep(&dpaa2_chan->vchan, &dpaa2_comp->vdesc, flags);
+}
+
+static enum
+dma_status dpaa2_qdma_tx_status(struct dma_chan *chan,
+				dma_cookie_t cookie,
+				struct dma_tx_state *txstate)
+{
+	return dma_cookie_status(chan, cookie, txstate);
+}
+
+static void dpaa2_qdma_issue_pending(struct dma_chan *chan)
+{
+	struct dpaa2_qdma_chan *dpaa2_chan = to_dpaa2_qdma_chan(chan);
+	struct dpaa2_qdma_engine *dpaa2_qdma = dpaa2_chan->qdma;
+	struct dpaa2_qdma_priv *priv = dpaa2_qdma->priv;
+	struct dpaa2_qdma_comp *dpaa2_comp;
+	struct virt_dma_desc *vdesc;
+	struct dpaa2_fd *fd;
+	unsigned long flags;
+	int err;
+
+	spin_lock_irqsave(&dpaa2_chan->queue_lock, flags);
+	spin_lock(&dpaa2_chan->vchan.lock);

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 273

Quoted 10 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +10 -0
+	if (vchan_issue_pending(&dpaa2_chan->vchan)) {
+		vdesc = vchan_next_desc(&dpaa2_chan->vchan);
+		if (!vdesc)
+			goto err_enqueue;
+		dpaa2_comp = to_fsl_qdma_comp(vdesc);
+
+		fd = (struct dpaa2_fd *)dpaa2_comp->fd_virt_addr;
+
+		list_del(&vdesc->node);
+		list_add_tail(&dpaa2_comp->list, &dpaa2_chan->comp_used);

what does this list do?

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 275

Quoted 2 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +2 -0
+
+		/* TOBO: priority hard-coded to zero */

You mean TODO?

Quoted 18 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +18 -0
+		err = dpaa2_io_service_enqueue_fq(NULL,
+				priv->tx_queue_attr[0].fqid, fd);
+		if (err) {
+			list_del(&dpaa2_comp->list);
+			list_add_tail(&dpaa2_comp->list,
+				      &dpaa2_chan->comp_free);
+		}
+	}
+err_enqueue:
+	spin_unlock(&dpaa2_chan->vchan.lock);
+	spin_unlock_irqrestore(&dpaa2_chan->queue_lock, flags);
+}
+
+static int __cold dpaa2_qdma_setup(struct fsl_mc_device *ls_dev)
+{
+	struct dpaa2_qdma_priv_per_prio *ppriv;
+	struct device *dev = &ls_dev->dev;
+	struct dpaa2_qdma_priv *priv;

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 303

Quoted 10 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +10 -0
+	u8 prio_def = DPDMAI_PRIO_NUM;
+	int err;
+	int i;
+
+	priv = dev_get_drvdata(dev);
+
+	priv->dev = dev;
+	priv->dpqdma_id = ls_dev->obj_desc.id;
+
+	/*Get the handle for the DPDMAI this interface is associate with */

Please run checkpatch, it should have told you that you need space after comment marker /* foo...

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 315

Quoted 12 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +12 -0
+	err = dpdmai_open(priv->mc_io, 0, priv->dpqdma_id, &ls_dev->mc_handle);
+	if (err) {
+		dev_err(dev, "dpdmai_open() failed\n");
+		return err;
+	}
+	dev_info(dev, "Opened dpdmai object successfully\n");
+
+	err = dpdmai_get_attributes(priv->mc_io, 0, ls_dev->mc_handle,
+				    &priv->dpdmai_attr);
+	if (err) {
+		dev_err(dev, "dpdmai_get_attributes() failed\n");
+		return err;

so you dont close what you opened in dpdmai_open() Please give a serious thought and testing to this driver

Quoted 6 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +6 -0
+	}
+
+	if (priv->dpdmai_attr.version.major > DPDMAI_VER_MAJOR) {
+		dev_err(dev, "DPDMAI major version mismatch\n"
+			     "Found %u.%u, supported version is %u.%u\n",
+				priv->dpdmai_attr.version.major,

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 331

Quoted 10 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +10 -0
+				priv->dpdmai_attr.version.minor,
+				DPDMAI_VER_MAJOR, DPDMAI_VER_MINOR);
+	}
+
+	if (priv->dpdmai_attr.version.minor > DPDMAI_VER_MINOR) {
+		dev_err(dev, "DPDMAI minor version mismatch\n"
+			     "Found %u.%u, supported version is %u.%u\n",
+				priv->dpdmai_attr.version.major,
+				priv->dpdmai_attr.version.minor,
+				DPDMAI_VER_MAJOR, DPDMAI_VER_MINOR);

what is the implication of these error, why not bail out on these?

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 335

Quoted 4 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +4 -0
+	}
+
+	priv->num_pairs = min(priv->dpdmai_attr.num_of_priorities, prio_def);
+	ppriv = kcalloc(priv->num_pairs, sizeof(*ppriv), GFP_KERNEL);

what is the context of the fn, sleepy, atomic?

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 337

Quoted 2 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +2 -0
+	if (!ppriv) {
+		dev_err(dev, "kzalloc for ppriv failed\n");

this need not be logged, core will do so

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 338

Quoted 1 line
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +1 -0
+		return -1;

really -1??

I think this driver needs more work, please fix these issues in the comments above and also see in rest of the code

author
#3 lore raw

RE: [EXT] Re: [V3 2/2] dmaengine: fsl-dpaa2-qdma: Add NXP dpaa2 qDMA controller driver for Layerscape SoCs

Hi, Vinod,

Please see my comments inline, thanks very much.

Best Regards,
Peng

Quoted 190 lines

-----Original Message-----
From: Vinod Koul <[email protected]>
Sent: 2019年4月29日 13:32
To: Peng Ma <[email protected]>
Cc: [email protected]; Leo Li <[email protected]>; [email protected]; [email protected]
Subject: [EXT] Re: [V3 2/2] dmaengine: fsl-dpaa2-qdma: Add NXP dpaa2 qDMA controller driver for Layerscape SoCs

Caution: EXT Email

Quoted 4 lines · Peng Ma

DPPA2(Data Path Acceleration Architecture 2) qDMA The qDMA supports channel virtualization by allowing DMA jobs to be enqueued into different frame queues. Core can initiate a DMA transaction by preparing a frame descriptor(FD) for each DMA job and enqueuing this job to

a frame queue.

Quoted 1 line

through a hardware portal. The qDMA prefetches DMA jobs from the frame

queues.

Quoted 3 lines

It then schedules and dispatches to internal DMA hardware engines, which generate read and write requests. Both qDMA source data and destination data can be either contiguous or non-contiguous using one or

more scatter/gather tables.

Quoted 4 lines

The qDMA supports global bandwidth flow control where all DMA transactions are stalled if the bandwidth threshold has been reached. Also supported are transaction based read throttling.

Quoted 8 lines

Add NXP dppa2 qDMA to support some of Layerscape SoCs. such as: LS1088A, LS208xA, LX2, etc.

---
changed for v3:
- Add depends on arm64 for dpaa2 qdma driver
- The dpaa2_io_service_[de]register functions have a new

parameter

drivers/dma/Makefile obj-$(CONFIG_UNIPHIER_MDMAC) +=

Quoted 33 lines

So update all calls to some functions

 drivers/dma/Kconfig                     |    2 +
 drivers/dma/Makefile                    |    1 +
 drivers/dma/fsl-dpaa2-qdma/Kconfig      |    9 +
 drivers/dma/fsl-dpaa2-qdma/Makefile     |    3 +
 drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c |  782
+++++++++++++++++++++++++++++++
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.h |  152 ++++++
 6 files changed, 949 insertions(+), 0 deletions(-)  create mode
100644 drivers/dma/fsl-dpaa2-qdma/Kconfig
 create mode 100644 drivers/dma/fsl-dpaa2-qdma/Makefile
 create mode 100644 drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
 create mode 100644 drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.h
drivers/dma/Kconfig index renamed from drivers/dma/Kconfig +0 -0

eaf78f4..08aae01 100644

drivers/dma/Kconfig +2 -0
@@ -671,6 +671,8 @@ source "drivers/dma/sh/Kconfig"
 
 source "drivers/dma/ti/Kconfig"
 
+source "drivers/dma/fsl-dpaa2-qdma/Kconfig"
+
 # clients
 comment "DMA Clients"
      depends on DMA_ENGINE
drivers/dma/Makefile index renamed from drivers/dma/Makefile +0 -0

6126e1c..2499ed8 100644

drivers/dma/Makefile +0 -0
@@ -75,6 +75,7 @@ obj-$(CONFIG_UNIPHIER_MDMAC) +=

uniphier-mdmac.o

Quoted 70 lines
drivers/dma/Makefile +1 -0
 obj-$(CONFIG_XGENE_DMA) += xgene-dma.o
 obj-$(CONFIG_ZX_DMA) += zx_dma.o
 obj-$(CONFIG_ST_FDMA) += st_fdma.o
+obj-$(CONFIG_FSL_DPAA2_QDMA) += fsl-dpaa2-qdma/
 
 obj-y += mediatek/
 obj-y += qcom/
drivers/dma/fsl-dpaa2-qdma/Kconfig new file +9 -0
new file mode 100644
index 0000000..258ed6b
@@ -0,0 +1,9 @@
+menuconfig FSL_DPAA2_QDMA
+     tristate "NXP DPAA2 QDMA"
+     depends on ARM64
+     depends on FSL_MC_BUS && FSL_MC_DPIO
+     select DMA_ENGINE
+     select DMA_VIRTUAL_CHANNELS
+     help
+       NXP Data Path Acceleration Architecture 2 QDMA driver,
+       using the NXP MC bus driver.
drivers/dma/fsl-dpaa2-qdma/Makefile new file +3 -0
new file mode 100644
index 0000000..c1d0226
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+# Makefile for the NXP DPAA2 qDMA controllers
+obj-$(CONFIG_FSL_DPAA2_QDMA) += dpaa2-qdma.o dpdmai.o
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +30 -0
new file mode 100644
index 0000000..0cdde0f
@@ -0,0 +1,782 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright 2014-2018 NXP
+
+/*
+ * Author: Changming Huang <[email protected]>
+ *
+ * Driver for the NXP QDMA engine with QMan mode.
+ * Channel virtualization is supported through enqueuing of DMA jobs
+to,
+ * or dequeuing DMA jobs from different work queues with QMan portal.
+ * This module can be found on NXP LS2 SoCs.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/dmapool.h>
+#include <linux/of_irq.h>
+#include <linux/iommu.h>
+#include <linux/sys_soc.h>
+#include <linux/fsl/mc.h>
+#include <soc/fsl/dpaa2-io.h>
+
+#include "../virt-dma.h"
+#include "dpdmai_cmd.h"
+#include "dpdmai.h"
+#include "dpaa2-qdma.h"
+
+static bool smmu_disable = true;
+

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 40

Quoted 10 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +10 -0
+static struct dpaa2_qdma_chan *to_dpaa2_qdma_chan(struct dma_chan
+*chan) {
+     return container_of(chan, struct dpaa2_qdma_chan, vchan.chan); }
+
+static struct dpaa2_qdma_comp *to_fsl_qdma_comp(struct virt_dma_desc
+*vd) {
+     return container_of(vd, struct dpaa2_qdma_comp, vdesc); }
+
+static int dpaa2_qdma_alloc_chan_resources(struct dma_chan *chan) {
+     struct dpaa2_qdma_chan *dpaa2_chan =

to_dpaa2_qdma_chan(chan);

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c

Quoted 5 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +5 -0
+     struct dpaa2_qdma_engine *dpaa2_qdma = dpaa2_chan->qdma;
+     struct device *dev = &dpaa2_qdma->priv->dpdmai_dev->dev;
+
+     dpaa2_chan->fd_pool = dma_pool_create("fd_pool", dev,
+                                           FD_POOL_SIZE, 32,

0);

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c

Quoted 7 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +7 -0
+     if (!dpaa2_chan->fd_pool)
+             return -ENOMEM;
+
+     return dpaa2_qdma->desc_allocated++; }
+
+static void dpaa2_qdma_free_chan_resources(struct dma_chan *chan) {
+     struct dpaa2_qdma_chan *dpaa2_chan =

to_dpaa2_qdma_chan(chan);

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c

Quoted 12 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +12 -0
+     struct dpaa2_qdma_engine *dpaa2_qdma = dpaa2_chan->qdma;
+     unsigned long flags;
+
+     LIST_HEAD(head);
+
+     spin_lock_irqsave(&dpaa2_chan->vchan.lock, flags);
+     vchan_get_all_descriptors(&dpaa2_chan->vchan, &head);
+     spin_unlock_irqrestore(&dpaa2_chan->vchan.lock, flags);
+
+     vchan_dma_desc_free_list(&dpaa2_chan->vchan, &head);
+
+     dpaa2_dpdmai_free_comp(dpaa2_chan,

&dpaa2_chan->comp_used);

Quoted 12 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +12 -0
+     dpaa2_dpdmai_free_comp(dpaa2_chan, &dpaa2_chan->comp_free);
+
+     dma_pool_destroy(dpaa2_chan->fd_pool);
+     dpaa2_qdma->desc_allocated--;
+}
+
+/*
+ * Request a command descriptor for enqueue.
+ */
+static struct dpaa2_qdma_comp *
+dpaa2_qdma_request_desc(struct dpaa2_qdma_chan *dpaa2_chan) {
+     struct dpaa2_qdma_comp *comp_temp = NULL;
Quoted 8 lines

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 87

Quoted 6 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +6 -0
+     unsigned long flags;
+
+     spin_lock_irqsave(&dpaa2_chan->queue_lock, flags);
+     if (list_empty(&dpaa2_chan->comp_free)) {
+             spin_unlock_irqrestore(&dpaa2_chan->queue_lock, flags);
+             comp_temp = kzalloc(sizeof(*comp_temp), GFP_KERNEL);

GFP_NOWAIT?

[Peng Ma] Got it.

Quoted 11 lines

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c

Quoted 5 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +4 -0
+             if (!comp_temp)
+                     goto err;
+             comp_temp->fd_virt_addr =
+                     dma_pool_alloc(dpaa2_chan->fd_pool,

GFP_NOWAIT,

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 93

Quoted 2 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +2 -0
+                                    &comp_temp->fd_bus_addr);
+             if (!comp_temp->fd_virt_addr)

err handling seems incorrect, you dont clean up, caller doesnt check return!

[Peng Ma] Yes, It's my fault.

Quoted 6 lines

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 98

Quoted 5 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +5 -0
+                     goto err;
+
+             comp_temp->fl_virt_addr =
+                     (void *)((struct dpaa2_fd *)
+                             comp_temp->fd_virt_addr + 1);
Quoted 6 lines

casts and pointer math, what could go wrong!! This doesnt smell right!

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 100

Quoted 2 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +2 -0
+             comp_temp->fl_bus_addr = comp_temp->fd_bus_addr +
+                                     sizeof(struct dpaa2_fd);

why not use fl_virt_addr and get the bus_address?

What you mean is I should use virt_to_phys to get the bus_address?

Quoted 8 lines

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 105

Quoted 6 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +5 -0
+             comp_temp->desc_virt_addr =
+                     (void *)((struct dpaa2_fl_entry *)
+                             comp_temp->fl_virt_addr + 3);
+             comp_temp->desc_bus_addr = comp_temp->fl_bus_addr +
+                             sizeof(struct dpaa2_fl_entry) * 3;

pointer math in the two calls doesnt match and as I said doesnt look good...

Should I do this as follows:
- comp_temp->fl_virt_addr =
- (void *)((struct dpaa2_fd *)
- comp_temp->fd_virt_addr + 1);
- comp_temp->fl_bus_addr = comp_temp->fd_bus_addr +
- sizeof(struct dpaa2_fd);
- comp_temp->desc_virt_addr =
- (void *)((struct dpaa2_fl_entry *)
- comp_temp->fl_virt_addr + 3);
- comp_temp->desc_bus_addr = comp_temp->fl_bus_addr +
- sizeof(struct dpaa2_fl_entry) * 3;

+               comp_temp->fd_virt_addr = (struct dpaa2_fd *)virt_addr_head++;
+               comp_temp->fl_virt_addr = (struct dpaa2_fl_entry *)virt_addr_head;
+               comp_temp->fl_bus_addr = virt_to_phys(comp_temp->fl_virt_addr);
+               virt_addr_head = (struct dpaa2_fl_entry *)virt_addr_head + 3;
+               comp_temp->desc_virt_addr = (struct dpaa2_qdma_sd_d *)virt_addr_head;
+               comp_temp->desc_bus_addr = virt_to_phys(comp_temp->desc_virt_addr);
Quoted 15 lines
Quoted 15 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +14 -0
+
+             comp_temp->qchan = dpaa2_chan;
+             return comp_temp;
+     }
+     comp_temp = list_first_entry(&dpaa2_chan->comp_free,
+                                  struct dpaa2_qdma_comp, list);
+     list_del(&comp_temp->list);
+     spin_unlock_irqrestore(&dpaa2_chan->queue_lock, flags);
+
+     comp_temp->qchan = dpaa2_chan;
+err:
+     return comp_temp;
+}
+
Quoted 8 lines

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 125

Quoted 6 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +6 -0
+static void
+dpaa2_qdma_populate_fd(u32 format, struct dpaa2_qdma_comp
+*dpaa2_comp) {
+     struct dpaa2_fd *fd;
+
+     fd = (struct dpaa2_fd *)dpaa2_comp->fd_virt_addr;

whats with the casts! you seem to like them! You are casting away from void!

This will avoid after change fd_virt_addr type.

Quoted 19 lines

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c

Quoted 6 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +5 -0
+     memset(fd, 0, sizeof(struct dpaa2_fd));
+
+     /* fd populated */
+     dpaa2_fd_set_addr(fd, dpaa2_comp->fl_bus_addr);
+     /* Bypass memory translation, Frame list format, short length disable

*/

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c

Quoted 11 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +11 -0
+     /* we need to disable BMT if fsl-mc use iova addr */
+     if (smmu_disable)
+             dpaa2_fd_set_bpid(fd, QMAN_FD_BMT_ENABLE);
+     dpaa2_fd_set_format(fd, QMAN_FD_FMT_ENABLE |
+ QMAN_FD_SL_DISABLE);
+
+     dpaa2_fd_set_frc(fd, format | QDMA_SER_CTX); }
+
+/* first frame list for descriptor buffer */ static void
+dpaa2_qdma_populate_first_framel(struct dpaa2_fl_entry *f_list,
+                              struct dpaa2_qdma_comp

*dpaa2_comp,

Quoted 6 lines

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 147

Quoted 4 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +4 -0
+                              bool wrt_changed) {
+     struct dpaa2_qdma_sd_d *sdd;
+
+     sdd = (struct dpaa2_qdma_sd_d *)dpaa2_comp->desc_virt_addr;

again

Same to before.

Quoted 63 lines

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c

Quoted 10 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +9 -0
+     memset(sdd, 0, 2 * (sizeof(*sdd)));
+
+     /* source descriptor CMD */
+     sdd->cmd = cpu_to_le32(QDMA_SD_CMD_RDTTYPE_COHERENT);
+     sdd++;
+
+     /* dest descriptor CMD */
+     if (wrt_changed)
+             sdd->cmd =

cpu_to_le32(LX2160_QDMA_DD_CMD_WRTTYPE_COHERENT);

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 151

Quoted 2 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +2 -0
+     else
+             sdd->cmd =

cpu_to_le32(QDMA_DD_CMD_WRTTYPE_COHERENT);

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c

Quoted 7 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +7 -0
+
+     memset(f_list, 0, sizeof(struct dpaa2_fl_entry));
+
+     /* first frame list to source descriptor */
+     dpaa2_fl_set_addr(f_list, dpaa2_comp->desc_bus_addr);
+     dpaa2_fl_set_len(f_list, 0x20);
+     dpaa2_fl_set_format(f_list, QDMA_FL_FMT_SBF |

QDMA_FL_SL_LONG);

Quoted 30 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +30 -0
+
+     /* bypass memory translation */
+     if (smmu_disable)
+             f_list->bpid = cpu_to_le16(QDMA_FL_BMT_ENABLE); }
+
+/* source and destination frame list */ static void
+dpaa2_qdma_populate_frames(struct dpaa2_fl_entry *f_list,
+                        dma_addr_t dst, dma_addr_t src,
+                        size_t len, uint8_t fmt) {
+     /* source frame list to source buffer */
+     memset(f_list, 0, sizeof(struct dpaa2_fl_entry));
+
+     dpaa2_fl_set_addr(f_list, src);
+     dpaa2_fl_set_len(f_list, len);
+
+     /* single buffer frame or scatter gather frame */
+     dpaa2_fl_set_format(f_list, (fmt | QDMA_FL_SL_LONG));
+
+     /* bypass memory translation */
+     if (smmu_disable)
+             f_list->bpid = cpu_to_le16(QDMA_FL_BMT_ENABLE);
+
+     f_list++;
+
+     /* destination frame list to destination buffer */
+     memset(f_list, 0, sizeof(struct dpaa2_fl_entry));
+
+     dpaa2_fl_set_addr(f_list, dst);
+     dpaa2_fl_set_len(f_list, len);
+     dpaa2_fl_set_format(f_list, (fmt | QDMA_FL_SL_LONG));

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c

Quoted 10 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +10 -0
+     /* single buffer frame or scatter gather frame */
+     dpaa2_fl_set_final(f_list, QDMA_FL_F);
+     /* bypass memory translation */
+     if (smmu_disable)
+             f_list->bpid = cpu_to_le16(QDMA_FL_BMT_ENABLE); }
+
+static struct dma_async_tx_descriptor *dpaa2_qdma_prep_memcpy(struct
+dma_chan *chan, dma_addr_t dst,
+                     dma_addr_t src, size_t len, ulong flags) {
+     struct dpaa2_qdma_chan *dpaa2_chan =

to_dpaa2_qdma_chan(chan);

Quoted 13 lines

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 221

Quoted 11 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +11 -0
+     struct dpaa2_qdma_engine *dpaa2_qdma;
+     struct dpaa2_qdma_comp *dpaa2_comp;
+     struct dpaa2_fl_entry *f_list;
+     bool wrt_changed;
+     u32 format;
+
+     dpaa2_qdma = dpaa2_chan->qdma;
+     dpaa2_comp = dpaa2_qdma_request_desc(dpaa2_chan);
+     wrt_changed = (bool)dpaa2_qdma->qdma_wrtype_fixup;
+
+#ifdef LONG_FORMAT

compile flag and define, so else part is dead code??

Ok, I will add it to Kconfig.

Quoted 48 lines
Quoted 22 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +21 -0
+     format = QDMA_FD_LONG_FORMAT;
+#else
+     format = QDMA_FD_SHORT_FORMAT;
+#endif
+     /* populate Frame descriptor */
+     dpaa2_qdma_populate_fd(format, dpaa2_comp);
+
+     f_list = (struct dpaa2_fl_entry *)dpaa2_comp->fl_virt_addr;
+
+#ifdef LONG_FORMAT
+     /* first frame list for descriptor buffer (logn format) */
+     dpaa2_qdma_populate_first_framel(f_list, dpaa2_comp,
+wrt_changed);
+
+     f_list++;
+#endif
+
+     dpaa2_qdma_populate_frames(f_list, dst, src, len,
+ QDMA_FL_FMT_SBF);
+
+     return vchan_tx_prep(&dpaa2_chan->vchan, &dpaa2_comp->vdesc,

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c

Quoted 10 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +10 -0
+flags); }
+
+static enum
+dma_status dpaa2_qdma_tx_status(struct dma_chan *chan,
+                             dma_cookie_t cookie,
+                             struct dma_tx_state *txstate) {
+     return dma_cookie_status(chan, cookie, txstate); }
+
+static void dpaa2_qdma_issue_pending(struct dma_chan *chan) {
+     struct dpaa2_qdma_chan *dpaa2_chan =

to_dpaa2_qdma_chan(chan);

Quoted 15 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +15 -0
+     struct dpaa2_qdma_engine *dpaa2_qdma = dpaa2_chan->qdma;
+     struct dpaa2_qdma_priv *priv = dpaa2_qdma->priv;
+     struct dpaa2_qdma_comp *dpaa2_comp;
+     struct virt_dma_desc *vdesc;
+     struct dpaa2_fd *fd;
+     unsigned long flags;
+     int err;
+
+     spin_lock_irqsave(&dpaa2_chan->queue_lock, flags);
+     spin_lock(&dpaa2_chan->vchan.lock);
+     if (vchan_issue_pending(&dpaa2_chan->vchan)) {
+             vdesc = vchan_next_desc(&dpaa2_chan->vchan);
+             if (!vdesc)
+                     goto err_enqueue;
+             dpaa2_comp = to_fsl_qdma_comp(vdesc);
Quoted 9 lines

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c

Quoted 6 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +6 -0
+
+             fd = (struct dpaa2_fd *)dpaa2_comp->fd_virt_addr;
+
+             list_del(&vdesc->node);
+             list_add_tail(&dpaa2_comp->list,
+ &dpaa2_chan->comp_used);

what does this list do?

It is will used in interrupt to deal dma jobs.

Quoted 4 lines

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 275

Quoted 2 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +2 -0
+
+             /* TOBO: priority hard-coded to zero */

You mean TODO?

Yes.

Quoted 23 lines
Quoted 23 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +22 -0
+             err = dpaa2_io_service_enqueue_fq(NULL,
+                             priv->tx_queue_attr[0].fqid, fd);
+             if (err) {
+                     list_del(&dpaa2_comp->list);
+                     list_add_tail(&dpaa2_comp->list,
+                                   &dpaa2_chan->comp_free);
+             }
+     }
+err_enqueue:
+     spin_unlock(&dpaa2_chan->vchan.lock);
+     spin_unlock_irqrestore(&dpaa2_chan->queue_lock, flags); }
+
+static int __cold dpaa2_qdma_setup(struct fsl_mc_device *ls_dev) {
+     struct dpaa2_qdma_priv_per_prio *ppriv;
+     struct device *dev = &ls_dev->dev;
+     struct dpaa2_qdma_priv *priv;
+     u8 prio_def = DPDMAI_PRIO_NUM;
+     int err;
+     int i;
+
+     priv = dev_get_drvdata(dev);
+
Quoted 9 lines

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c

Quoted 5 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +5 -0
+     priv->dev = dev;
+     priv->dpqdma_id = ls_dev->obj_desc.id;
+
+     /*Get the handle for the DPDMAI this interface is associate with
+ */

Please run checkpatch, it should have told you that you need space after comment marker /* foo...

Ok, I will check it with --strict.

Quoted 14 lines

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 291

Quoted 1 line
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +1 -0
+     err = dpdmai_open(priv->mc_io, 0, priv->dpqdma_id,

&ls_dev->mc_handle);

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 315

Quoted 11 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +11 -0
+     if (err) {
+             dev_err(dev, "dpdmai_open() failed\n");
+             return err;
+     }
+     dev_info(dev, "Opened dpdmai object successfully\n");
+
+     err = dpdmai_get_attributes(priv->mc_io, 0, ls_dev->mc_handle,
+                                 &priv->dpdmai_attr);
+     if (err) {
+             dev_err(dev, "dpdmai_get_attributes() failed\n");
+             return err;
Quoted 2 lines

so you dont close what you opened in dpdmai_open() Please give a serious thought and testing to this driver

OK, got it.

Quoted 16 lines

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c

Quoted 6 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +5 -0
+     }
+
+     if (priv->dpdmai_attr.version.major > DPDMAI_VER_MAJOR) {
+             dev_err(dev, "DPDMAI major version mismatch\n"
+                          "Found %u.%u, supported version

is %u.%u\n",

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c

Quoted 3 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +3 -0
+                             priv->dpdmai_attr.version.major,
+                             priv->dpdmai_attr.version.minor,
+                             DPDMAI_VER_MAJOR,

DPDMAI_VER_MINOR);

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c

Quoted 5 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +5 -0
+     }
+
+     if (priv->dpdmai_attr.version.minor > DPDMAI_VER_MINOR) {
+             dev_err(dev, "DPDMAI minor version mismatch\n"
+                          "Found %u.%u, supported version
Quoted 7 lines

is %u.%u\n",

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c

Quoted 3 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +3 -0
+                             priv->dpdmai_attr.version.major,
+                             priv->dpdmai_attr.version.minor,
+                             DPDMAI_VER_MAJOR,

DPDMAI_VER_MINOR);

what is the implication of these error, why not bail out on these?

There should be return.

Quoted 8 lines

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c

Quoted 4 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +3 -0
+     }
+
+     priv->num_pairs = min(priv->dpdmai_attr.num_of_priorities,

prio_def);

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 335

Quoted 1 line
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +1 -0
+     ppriv = kcalloc(priv->num_pairs, sizeof(*ppriv), GFP_KERNEL);

what is the context of the fn, sleepy, atomic?

This function will be called on qdma probe,Here is not a critical area, What's the problem about to use GFP_KERNEL, please let me know.

Quoted 5 lines

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 337

Quoted 3 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +2 -0
+     if (!ppriv) {
+             dev_err(dev, "kzalloc for ppriv failed\n");

this need not be logged, core will do so

OK.

Quoted 4 lines

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 325

Quoted 2 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +1 -0
+             return -1;

really -1??

I will update.

Quoted 3 lines

I think this driver needs more work, please fix these issues in the comments above and also see in rest of the code

OK, I will check all of those patch about these issues in rest of the code. Thanks.

Quoted 1 line

Best Regards,
Peng

Quoted 2 lines

--
~Vinod

maintainer
#4 lore raw

Re: [EXT] Re: [V3 2/2] dmaengine: fsl-dpaa2-qdma: Add NXP dpaa2 qDMA controller driver for Layerscape SoCs

Quoted 6 lines · Peng Ma
Quoted 6 lines
Quoted 5 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +5 -0
+                     goto err;
+
+             comp_temp->fl_virt_addr =
+                     (void *)((struct dpaa2_fd *)
+                             comp_temp->fd_virt_addr + 1);
Quoted 7 lines
Quoted 6 lines

casts and pointer math, what could go wrong!! This doesnt smell right!

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 100

Quoted 2 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +2 -0
+             comp_temp->fl_bus_addr = comp_temp->fd_bus_addr +
+                                     sizeof(struct dpaa2_fd);

why not use fl_virt_addr and get the bus_address?

What you mean is I should use virt_to_phys to get the bus_address?

Yes instead of maintaining both pointers, just use one and then when required use one to get other. For bus address I would prefer dma_map_single rather than virt_to_phys()

Signature · 1 line
~Vinod
author
#5 lore raw

RE: [EXT] Re: [V3 2/2] dmaengine: fsl-dpaa2-qdma: Add NXP dpaa2 qDMA controller driver for Layerscape SoCs

Hi Vinod,

Quoted 24 lines

-----Original Message-----
From: Vinod Koul <[email protected]>
Sent: 2019年6月13日 19:03
To: Peng Ma <[email protected]>
Cc: [email protected]; Leo Li <[email protected]>; [email protected]; [email protected]
Subject: Re: [EXT] Re: [V3 2/2] dmaengine: fsl-dpaa2-qdma: Add NXP dpaa2 qDMA controller driver for Layerscape SoCs

Caution: EXT Email

Quoted 11 lines · Peng Ma
Quoted 11 lines

drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c line 98

Quoted 5 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +5 -0
+                     goto err;
+
+             comp_temp->fl_virt_addr =
+                     (void *)((struct dpaa2_fd *)
+                             comp_temp->fd_virt_addr + 1);

casts and pointer math, what could go wrong!! This doesnt smell right!

Quoted 2 lines
drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c new file +2 -0
+             comp_temp->fl_bus_addr = comp_temp->fd_bus_addr +
+                                     sizeof(struct dpaa2_fd);
Quoted 6 lines
Quoted 2 lines
Quoted 1 line

why not use fl_virt_addr and get the bus_address?

What you mean is I should use virt_to_phys to get the bus_address?

Yes instead of maintaining both pointers, just use one and then when required use one to get other. For bus address I would prefer dma_map_single rather than virt_to_phys()

[Peng Ma] ok, thanks, I have already send V4 for this series patch, Please review it in your spare time. Patchwork link: https://patchwork.kernel.org/project/linux-dmaengine/list/?series=131767
Best Regars,
Peng

Quoted 2 lines

--
~Vinod

maintainer
#6 lore raw
In reply to Peng Ma

On 09-04-19, 15:22, Peng Ma wrote:

Subject missed PATCH tag!

Quoted 1 line

The MC exports the DPDMAI object as an interface to operate the DPAA2 QDMA

whats MC, DPDMAI, DPAA2

drivers/dma/fsl-dpaa2-qdma/dpdmai.c line 43

Quoted 9 lines

Engine. The DPDMAI enables sending frame-based requests to QDMA and receiving back confirmation response on transaction completion, utilizing the DPAA2 QBMan infrastructure. DPDMAI object provides up to two priorities for processing QDMA requests.

drivers/dma/fsl-dpaa2-qdma/dpdmai.c new file +4 -0
+int dpdmai_open(struct fsl_mc_io *mc_io,
+		u32 cmd_flags,
+		int dpdmai_id,
+		u16 *token)

could be written as:

int dpdmai_open(struct fsl_mc_io *mc_io, u32 cmd_flags,
int dpdmai_id, u16 *token)

Looks neater, right? It would be to reread coding guidelines and run checkpatch with --strict on this

Review

Quoted 2 lines
(quoted diff) +2 -0
+{
+	struct fsl_mc_command cmd = { 0 };

where is this defined?

drivers/dma/fsl-dpaa2-qdma/dpdmai.c line 54

Quoted 9 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.c new file +9 -0
+	struct dpdmai_cmd_open *cmd_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_OPEN,
+					  cmd_flags,
+					  0);
+
+	cmd_params = (struct dpdmai_cmd_open *)cmd.params;

I dont like casts, can you explain

drivers/dma/fsl-dpaa2-qdma/dpdmai.c line 65

Quoted 11 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.c new file +11 -0
+	cmd_params->dpdmai_id = cpu_to_le32(dpdmai_id);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	*token = mc_cmd_hdr_read_token(&cmd);
+	return 0;
+}

who will call this API?

drivers/dma/fsl-dpaa2-qdma/dpdmai.c line 92

Quoted 12 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.c new file +12 -0
+int dpdmai_create(struct fsl_mc_io *mc_io,
+		  u32 cmd_flags,
+		  const struct dpdmai_cfg *cfg,
+		  u16 *token)
+{
+	struct fsl_mc_command cmd = { 0 };
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_CREATE,
+					  cmd_flags,
+					  0);

why waste a line, last arg can be in previous line!

Quoted 21 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.c new file +21 -0
+int dpdmai_get_tx_queue(struct fsl_mc_io *mc_io,
+			u32 cmd_flags,
+			u16 token,
+			u8 priority,
+			struct dpdmai_tx_queue_attr *attr)
+{
+	struct fsl_mc_command cmd = { 0 };
+	struct dpdmai_cmd_queue *cmd_params;
+	struct dpdmai_rsp_get_tx_queue *rsp_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_GET_TX_QUEUE,
+					  cmd_flags,
+					  token);
+
+	cmd_params = (struct dpdmai_cmd_queue *)cmd.params;
+	cmd_params->queue = priority;
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);

drivers/dma/fsl-dpaa2-qdma/dpdmai.c line 483

Quoted 10 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.c new file +10 -0
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+
+	rsp_params = (struct dpdmai_rsp_get_tx_queue *)cmd.params;
+	attr->fqid = le32_to_cpu(rsp_params->fqid);
+
+	return 0;
+}

Okay this file does not use any of dmaengine apis, is this a dmaengine driver?

Quoted 29 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.h new file +23 -0
new file mode 100644
index 0000000..c8a7b7f
@@ -0,0 +1,524 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright 2014-2018 NXP */
+
+/*
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ * names of any contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") as published by the Free Software
+ * Foundation, either version 2 of that License or (at your option) any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

drivers/dma/fsl-dpaa2-qdma/dpdmai.h line 33

Quoted 10 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.h new file +10 -0
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */

we have SiPDX tag, why do you need ths here!

author
#7 lore raw

Hi Vinod

Sorry to replay so late.
The dpaa2 qdma driver is based on FSL_MC_BUS and FSL_MC_DPIO, so It will used those two drivers Functions or structs. This patch provides some necessary functions and structs for qdma driver(next patch: dpaa2-qdma.c) The dpaa2 driver is not only to write some register on driver side but also need enable FSL_MC_BUS and FSL_MC_DPIO to call some functions provided by them. Such as: mc_encode_cmd_header, mc_send_command etc. I will clear up this driver again. And send V4 to review, thanks for your review.

Best Regards,
Peng

Quoted 11 lines

-----Original Message-----
From: Vinod Koul <[email protected]>
Sent: 2019年4月26日 20:46
To: Peng Ma <[email protected]>
Cc: [email protected]; Leo Li <[email protected]>; [email protected]; [email protected]
Subject: [EXT] Re: [V3 1/2] dmaengine: fsl-dpaa2-qdma: Add the DPDMAI(Data Path DMA Interface) support

Caution: EXT Email

Quoted 9 lines

On 09-04-19, 15:22, Peng Ma wrote:

Subject missed PATCH tag!

Quoted 2 lines

The MC exports the DPDMAI object as an interface to operate the DPAA2 QDMA

whats MC, DPDMAI, DPAA2

[Peng Ma] MC: Management Complex
DPDMAI: Data Path DMA Interface
DPAA2: Data Path Acceleration Architecture, Second Generation I will explain them on next version.

Quoted 10 lines

drivers/dma/fsl-dpaa2-qdma/dpdmai.c line 43

Quoted 9 lines

Engine. The DPDMAI enables sending frame-based requests to QDMA and receiving back confirmation response on transaction completion, utilizing the DPAA2 QBMan infrastructure. DPDMAI object provides up to two priorities for processing QDMA requests.

drivers/dma/fsl-dpaa2-qdma/dpdmai.c new file +4 -0
+int dpdmai_open(struct fsl_mc_io *mc_io,
+             u32 cmd_flags,
+             int dpdmai_id,
+             u16 *token)
Quoted 8 lines

could be written as:

int dpdmai_open(struct fsl_mc_io *mc_io, u32 cmd_flags,
int dpdmai_id, u16 *token)

Looks neater, right? It would be to reread coding guidelines and run checkpatch with --strict on this

[Peng Ma] Ok, got it.

Quoted 5 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+{
+     struct fsl_mc_command cmd = { 0 };

where is this defined?

[Peng Ma] include/linux/fsl/mc.h

Quoted 12 lines

drivers/dma/fsl-dpaa2-qdma/dpdmai.c line 54

Quoted 10 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.c new file +9 -0
+     struct dpdmai_cmd_open *cmd_params;
+     int err;
+
+     /* prepare command */
+     cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_OPEN,
+                                       cmd_flags,
+                                       0);
+
+     cmd_params = (struct dpdmai_cmd_open *)cmd.params;

I dont like casts, can you explain

[Peng Ma] If I didn't use the casts, There are two case:
1: struct fsl_mc_command cmd_org = { 0 };
Struct fsl_mc_command *cmd = &cmd_org;
In this case, we will define one more temporary variable in the stack.
2: Struct fsl_mc_command *cmd = kmalloc();
In this case, we will alloc some memory, It may be produce memory
Fragmentation. Those functions will be called on driver init It is not necessary use this case to those function.

Quoted 15 lines

drivers/dma/fsl-dpaa2-qdma/dpdmai.c line 65

Quoted 12 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.c new file +11 -0
+     cmd_params->dpdmai_id = cpu_to_le32(dpdmai_id);
+
+     /* send command to mc*/
+     err = mc_send_command(mc_io, &cmd);
+     if (err)
+             return err;
+
+     /* retrieve response parameters */
+     *token = mc_cmd_hdr_read_token(&cmd);
+     return 0;
+}

who will call this API?

[Peng Ma] This file is not a driver, some of functions define in this file, the dma driver(dpaa2-qdma.c) will call some of those API and I will delete unuseless API in the future.

Quoted 6 lines
Quoted 6 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.c new file +6 -0
+int dpdmai_create(struct fsl_mc_io *mc_io,
+               u32 cmd_flags,
+               const struct dpdmai_cfg *cfg,
+               u16 *token)
+{
+     struct fsl_mc_command cmd = { 0 };
Quoted 9 lines

drivers/dma/fsl-dpaa2-qdma/dpdmai.c line 92

Quoted 6 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.c new file +6 -0
+     int err;
+
+     /* prepare command */
+     cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_CREATE,
+                                       cmd_flags,
+                                       0);

why waste a line, last arg can be in previous line!

[Peng Ma] sorry, I will remove it.

Quoted 25 lines

drivers/dma/fsl-dpaa2-qdma/dpdmai.c

Quoted 12 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.c new file +12 -0
+int dpdmai_get_tx_queue(struct fsl_mc_io *mc_io,
+                     u32 cmd_flags,
+                     u16 token,
+                     u8 priority,
+                     struct dpdmai_tx_queue_attr *attr) {
+     struct fsl_mc_command cmd = { 0 };
+     struct dpdmai_cmd_queue *cmd_params;
+     struct dpdmai_rsp_get_tx_queue *rsp_params;
+     int err;
+
+     /* prepare command */
+     cmd.header =

mc_encode_cmd_header(DPDMAI_CMDID_GET_TX_QUEUE,

Quoted 12 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.c new file +12 -0
+                                       cmd_flags,
+                                       token);
+
+     cmd_params = (struct dpdmai_cmd_queue *)cmd.params;
+     cmd_params->queue = priority;
+
+     /* send command to mc*/
+     err = mc_send_command(mc_io, &cmd);
+     if (err)
+             return err;
+
+     /* retrieve response parameters */
Quoted 8 lines

drivers/dma/fsl-dpaa2-qdma/dpdmai.c line 483

Quoted 6 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.c new file +6 -0
+
+     rsp_params = (struct dpdmai_rsp_get_tx_queue *)cmd.params;
+     attr->fqid = le32_to_cpu(rsp_params->fqid);
+
+     return 0;
+}

Okay this file does not use any of dmaengine apis, is this a dmaengine driver?

[Peng Ma] please the previous comment.

Quoted 50 lines
Quoted 8 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.h new file +0 -0
new file mode 100644
index 0000000..c8a7b7f

drivers/dma/fsl-dpaa2-qdma/dpdmai.h line 6

Quoted 6 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.h new file +6 -0
@@ -0,0 +1,524 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright 2014-2018 NXP */
+
+/*
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are

met:

Quoted 12 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.h new file +12 -0
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+copyright
+ * notice, this list of conditions and the following disclaimer in
+the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ * names of any contributors may be used to endorse or promote
+products
+ * derived from this software without specific prior written permission.
+ *

drivers/dma/fsl-dpaa2-qdma/dpdmai.h line 28

Quoted 10 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.h new file +10 -0
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of
+the
+ * GNU General Public License ("GPL") as published by the Free
+Software
+ * Foundation, either version 2 of that License or (at your option)
+any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND

CONTRIBUTORS "AS IS"

drivers/dma/fsl-dpaa2-qdma/dpdmai.h line 29

Quoted 1 line
drivers/dma/fsl-dpaa2-qdma/dpdmai.h new file +1 -0
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT

LIMITED

drivers/dma/fsl-dpaa2-qdma/dpdmai.h line 31

Quoted 2 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.h new file +2 -0
+TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A

PARTICULAR

drivers/dma/fsl-dpaa2-qdma/dpdmai.h line 37

Quoted 6 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.h new file +6 -0
+PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,

PROCUREMENT

Quoted 14 lines

drivers/dma/fsl-dpaa2-qdma/dpdmai.h line 48

Quoted 11 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.h new file +11 -0
+OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */

we have SiPDX tag, why do you need ths here!

[Peng Ma] It is my mistake. I will fixe it.

Quoted 2 lines

--
~Vinod

#8 lore raw
Quoted 2 lines · Peng Ma

-----Original Message-----

Quoted 1 line

From: Vinod Koul <[email protected]>

[]

Quoted 63 lines
Quoted 49 lines

drivers/dma/fsl-dpaa2-qdma/dpdmai.h line 6

Quoted 13 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.h new file +6 -0
new file mode 100644
index 0000000..c8a7b7f
@@ -0,0 +1,524 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright 2014-2018 NXP */
+
+/*
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are

met:

Quoted 12 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.h new file +12 -0
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+copyright
+ * notice, this list of conditions and the following disclaimer in
+the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the above-listed copyright holders nor the
+ * names of any contributors may be used to endorse or promote
+products
+ * derived from this software without specific prior written permission.
+ *

drivers/dma/fsl-dpaa2-qdma/dpdmai.h line 28

Quoted 10 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.h new file +10 -0
+ *
+ * ALTERNATIVELY, this software may be distributed under the terms of
+the
+ * GNU General Public License ("GPL") as published by the Free
+Software
+ * Foundation, either version 2 of that License or (at your option)
+any
+ * later version.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND

CONTRIBUTORS "AS IS"

drivers/dma/fsl-dpaa2-qdma/dpdmai.h line 29

Quoted 1 line
drivers/dma/fsl-dpaa2-qdma/dpdmai.h new file +1 -0
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT

LIMITED

drivers/dma/fsl-dpaa2-qdma/dpdmai.h line 31

Quoted 2 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.h new file +2 -0
+TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A

PARTICULAR

drivers/dma/fsl-dpaa2-qdma/dpdmai.h line 37

Quoted 6 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.h new file +6 -0
+PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,

PROCUREMENT

Quoted 14 lines

drivers/dma/fsl-dpaa2-qdma/dpdmai.h line 48

Quoted 11 lines
drivers/dma/fsl-dpaa2-qdma/dpdmai.h new file +11 -0
+OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */

we have SiPDX tag, why do you need ths here!

Quoted 1 line

[Peng Ma] It is my mistake. I will fixe it.

Please have your company review which licenses you are intending to use as the SPDX tag does not match the licenses shown in the text.