Skip to contentSkip to conversation

ipq8064 NAND support

PATCH RESEND In review Thomas Pedersen 4 participants 15 messages Jun 28, 2016 – Dec 27, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover ipq8064 NAND support

These patches complete NAND flash support for ipq8064 based boards.

Andy Gross (3):
dtbindings: qcom_adm: Fix channel specifiers
dmaengine: Add ADM driver
arm: qcom: dts: ipq8064: Add ADM device node

Archit Taneja (2):
arm: qcom: dts: Add NAND controller node for ipq806x
arm: qcom: dts: Enable NAND node on IPQ8064 AP148 platform

 Documentation/devicetree/bindings/dma/qcom_adm.txt |  16 +-
 arch/arm/boot/dts/qcom-ipq8064-ap148.dts           |  42 +
 arch/arm/boot/dts/qcom-ipq8064.dtsi                |  38 +
 drivers/dma/qcom/Kconfig                           |  10 +
 drivers/dma/qcom/Makefile                          |   1 +
 drivers/dma/qcom/qcom_adm.c                        | 900 +++++++++++++++++++++
 6 files changed, 997 insertions(+), 10 deletions(-)
 create mode 100644 drivers/dma/qcom/qcom_adm.c
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#1 lore raw

PATCH RESEND 1/5 dtbindings: qcom_adm: Fix channel specifiers

From: Andy Gross <[email protected]>

This patch removes the crci information from the dma channel property. At least one client device requires using more than one CRCI value for a channel. This does not match the current binding and the crci information needs to be removed.

Instead, the client device will provide this information via other means.

---
 Documentation/devicetree/bindings/dma/qcom_adm.txt | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/dma/qcom_adm.txt +6 -10
index 9bcab91..38d45f8 100644
@@ -4,8 +4,7 @@ Required properties:
 - compatible: must contain "qcom,adm" for IPQ/APQ8064 and MSM8960
 - reg: Address range for DMA registers
 - interrupts: Should contain one interrupt shared by all channels
-- #dma-cells: must be <2>.  First cell denotes the channel number.  Second cell
-  denotes CRCI (client rate control interface) flow control assignment.
+- #dma-cells: must be <1>.  First cell denotes the channel number.
 - clocks: Should contain the core clock and interface clock.
 - clock-names: Must contain "core" for the core clock and "iface" for the
   interface clock.
@@ -22,7 +21,7 @@ Example:
 			compatible = "qcom,adm";
 			reg = <0x18300000 0x100000>;
 			interrupts = <0 170 0>;
-			#dma-cells = <2>;
+			#dma-cells = <1>;
 
 			clocks = <&gcc ADM0_CLK>, <&gcc ADM0_PBUS_CLK>;
 			clock-names = "core", "iface";
@@ -35,15 +34,12 @@ Example:
 			qcom,ee = <0>;
 		};
 
-DMA clients must use the format descripted in the dma.txt file, using a three
+DMA clients must use the format descripted in the dma.txt file, using a two
 cell specifier for each channel.
 
-Each dmas request consists of 3 cells:
+Each dmas request consists of two cells:
  1. phandle pointing to the DMA controller
  2. channel number
- 3. CRCI assignment, if applicable.  If no CRCI flow control is required, use 0.
-    The CRCI is used for flow control.  It identifies the peripheral device that
-    is the source/destination for the transferred data.
 
 Example:
 
@@ -56,7 +52,7 @@ Example:
 
 		cs-gpios = <&qcom_pinmux 20 0>;
 
-		dmas = <&adm_dma 6 9>,
-			<&adm_dma 5 10>;
+		dmas = <&adm_dma 6>,
+			<&adm_dma 5>;
 		dma-names = "rx", "tx";
 	};
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#8 lore raw

PATCH RESEND 2/5 dmaengine: Add ADM driver

In reply to Thomas Pedersen

From: Andy Gross <[email protected]>

Add the DMA engine driver for the QCOM Application Data Mover (ADM) DMA controller found in the MSM8x60 and IPQ/APQ8064 platforms.

The ADM supports both memory to memory transactions and memory to/from peripheral device transactions. The controller also provides flow control capabilities for transactions to/from peripheral devices.

The initial release of this driver supports slave transfers to/from peripherals and also incorporates CRCI (client rate control interface) flow control.

---
 drivers/dma/qcom/Kconfig    |  10 +
 drivers/dma/qcom/Makefile   |   1 +
 drivers/dma/qcom/qcom_adm.c | 900 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 911 insertions(+)
 create mode 100644 drivers/dma/qcom/qcom_adm.c
drivers/dma/qcom/Kconfig +10 -0
index a7761c4..a88769e 100644
@@ -27,3 +27,13 @@ config QCOM_HIDMA
 	  (user to kernel, kernel to kernel, etc.).  It only supports
 	  memcpy interface. The core is not intended for general
 	  purpose slave DMA.
+
+config QCOM_ADM
+	tristate "Qualcomm ADM support"
+	depends on ARCH_QCOM || (COMPILE_TEST && OF && ARM)
+	select DMA_ENGINE
+	select DMA_VIRTUAL_CHANNELS
+	---help---
+	  Enable support for the Qualcomm ADM DMA controller.  This controller
+	  provides DMA capabilities for both general purpose and on-chip
+	  peripheral devices.
drivers/dma/qcom/Makefile +1 -0
index 4bfc38b..b557769 100644
@@ -3,3 +3,4 @@ obj-$(CONFIG_QCOM_HIDMA_MGMT) += hdma_mgmt.o
 hdma_mgmt-objs	 := hidma_mgmt.o hidma_mgmt_sys.o
 obj-$(CONFIG_QCOM_HIDMA) +=  hdma.o
 hdma-objs        := hidma_ll.o hidma.o hidma_dbg.o
+obj-$(CONFIG_QCOM_ADM) += qcom_adm.o
drivers/dma/qcom/qcom_adm.c new file +900 -0

900 lines not on this page · raw message

Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#13 lore raw

PATCH RESEND 4/5 arm: qcom: dts: Add NAND controller node for ipq806x

In reply to Thomas Pedersen

From: Archit Taneja <[email protected]>

---
 arch/arm/boot/dts/qcom-ipq8064.dtsi | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
arch/arm/boot/dts/qcom-ipq8064.dtsi +17 -0
index 1a3549f..3183e66 100644
@@ -362,5 +362,22 @@
 
 			status = "disabled";
 		};
+
+		nand@1ac00000 {
+			compatible = "qcom,ipq806x-nand";
+			reg = <0x1ac00000 0x800>;
+
+			clocks = <&gcc EBI2_CLK>,
+				 <&gcc EBI2_AON_CLK>;
+			clock-names = "core", "aon";
+
+			dmas = <&adm_dma 3>;
+			dma-names = "rxtx";
+			qcom,cmd-crci = <15>;
+			qcom,data-crci = <3>;
+
+			status = "disabled";
+		};
+
 	};
 };
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#14 lore raw

PATCH RESEND 5/5 arm: qcom: dts: Enable NAND node on IPQ8064 AP148 platform

In reply to Thomas Pedersen

From: Archit Taneja <[email protected]>

Enable the NAND controller node on the AP148 platform. Provide pinmux information.

---
 arch/arm/boot/dts/qcom-ipq8064-ap148.dts | 42 ++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
arch/arm/boot/dts/qcom-ipq8064-ap148.dts +42 -0
index d501382..0a4b5e3 100644
@@ -38,6 +38,28 @@
 					bias-none;
 				};
 			};
+			nand_pins: nand_pins {
+				mux {
+					pins = "gpio34", "gpio35", "gpio36",
+					       "gpio37", "gpio38", "gpio39",
+					       "gpio40", "gpio41", "gpio42",
+					       "gpio43", "gpio44", "gpio45",
+					       "gpio46", "gpio47";
+					function = "nand";
+					drive-strength = <10>;
+					bias-disable;
+				};
+				pullups {
+					pins = "gpio39";
+					bias-pull-up;
+				};
+				hold {
+					pins = "gpio40", "gpio41", "gpio42",
+					       "gpio43", "gpio44", "gpio45",
+					       "gpio46", "gpio47";
+					bias-bus-hold;
+				};
+			};
 		};
 
 		gsbi@16300000 {
@@ -97,5 +119,25 @@
 		sata@29000000 {
 			status = "ok";
 		};
+
+		nand@1ac00000 {
+			status = "ok";
+
+			pinctrl-0 = <&nand_pins>;
+			pinctrl-names = "default";
+
+			nandcs@0 {
+				compatible = "qcom,nandcs";
+				reg = <0>;
+
+				nand-ecc-strength = <4>;
+				nand-ecc-step-size = <512>;
+				nand-bus-width = <8>;
+			};
+		};
 	};
 };
+
+&adm_dma {
+	status = "ok";
+};
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#12 lore raw

PATCH RESEND 3/5 arm: qcom: dts: ipq8064: Add ADM device node

In reply to Thomas Pedersen

From: Andy Gross <[email protected]>

---
 arch/arm/boot/dts/qcom-ipq8064.dtsi | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
arch/arm/boot/dts/qcom-ipq8064.dtsi +21 -0
index 2601a90..1a3549f 100644
@@ -1,9 +1,11 @@
 /dts-v1/;
 
 #include "skeleton.dtsi"
+#include <dt-bindings/reset/qcom,gcc-ipq806x.h>
 #include <dt-bindings/clock/qcom,gcc-ipq806x.h>
 #include <dt-bindings/clock/qcom,lcc-ipq806x.h>
 #include <dt-bindings/soc/qcom,gsbi.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
 
 / {
 	model = "Qualcomm IPQ8064";
@@ -341,5 +343,24 @@
 			#reset-cells = <1>;
 		};
 
+		adm_dma: dma@18300000 {
+			compatible = "qcom,adm";
+			reg = <0x18300000 0x100000>;
+			interrupts = <GIC_SPI 170 IRQ_TYPE_NONE>;
+			#dma-cells = <1>;
+
+			clocks = <&gcc ADM0_CLK>, <&gcc ADM0_PBUS_CLK>;
+			clock-names = "core", "iface";
+
+			resets = <&gcc ADM0_RESET>,
+				 <&gcc ADM0_PBUS_RESET>,
+				 <&gcc ADM0_C0_RESET>,
+				 <&gcc ADM0_C1_RESET>,
+				 <&gcc ADM0_C2_RESET>;
+			reset-names = "clk", "pbus", "c0", "c1", "c2";
+			qcom,ee = <0>;
+
+			status = "disabled";
+		};
 	};
 };
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#2 lore raw

Re: [RESEND PATCH 1/5] dtbindings: qcom_adm: Fix channel specifiers

In reply to Thomas Pedersen
Quoted 22 lines · Thomas Pedersen

From: Andy Gross <[email protected]>

This patch removes the crci information from the dma channel property. At least one client device requires using more than one CRCI value for a channel. This does not match the current binding and the crci information needs to be removed.

Instead, the client device will provide this information via other means.

---
 Documentation/devicetree/bindings/dma/qcom_adm.txt | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/dma/qcom_adm.txt +0 -0
index 9bcab91..38d45f8 100644

Documentation/devicetree/bindings/dma/qcom_adm.txt Required properties: · line 7

Quoted 6 lines
Documentation/devicetree/bindings/dma/qcom_adm.txt +1 -2
@@ -4,8 +4,7 @@ Required properties:
 - compatible: must contain "qcom,adm" for IPQ/APQ8064 and MSM8960
 - reg: Address range for DMA registers
 - interrupts: Should contain one interrupt shared by all channels
-- #dma-cells: must be <2>.  First cell denotes the channel number.  Second cell
-  denotes CRCI (client rate control interface) flow control assignment.
+- #dma-cells: must be <1>.  First cell denotes the channel number.

I've actually been thinking more about this. The crci being specified in the slave config is probably the wrong approach. What we really need is each physical DMA channel to allow for virtual channels that allow for a CRCI setting (0 being no flow control). This would require the properties to continue to be 2 for the dma definition.

This would also require clients to get multiple references to the same DMA channel if they require some communications with and without flow control.

For NAND, this would mean having two channels for dma. One for flow controlled and one without.

Anyone have reservations with this?

Regards,

Andy

#3 lore raw

Re: [RESEND PATCH 1/5] dtbindings: qcom_adm: Fix channel specifiers

Hi Andy,

Quoted 30 lines · Andy Gross
Quoted 29 lines · Thomas Pedersen

From: Andy Gross <[email protected]>

This patch removes the crci information from the dma channel property. At least one client device requires using more than one CRCI value for a channel. This does not match the current binding and the crci information needs to be removed.

Instead, the client device will provide this information via other means.

---
 Documentation/devicetree/bindings/dma/qcom_adm.txt | 16 
++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/dma/qcom_adm.txt +0 -1
index 9bcab91..38d45f8 100644
@@ -4,8 +4,7 @@ Required properties:
 - compatible: must contain "qcom,adm" for IPQ/APQ8064 and MSM8960
 - reg: Address range for DMA registers
 - interrupts: Should contain one interrupt shared by all channels
-- #dma-cells: must be <2>.  First cell denotes the channel number.  

Second cell
- denotes CRCI (client rate control interface) flow control

Quoted 8 lines
Quoted 2 lines

assignment.
+- #dma-cells: must be <1>. First cell denotes the channel number.

I've actually been thinking more about this. The crci being specified in the slave config is probably the wrong approach. What we really need is each physical DMA channel to allow for virtual channels that allow for a CRCI setting (0 being no flow control). This would require the properties to continue to be 2 for the dma definition.

AFAICT the cmd-crci and data-crci properties in the NAND controller client are really just the slave_id for the DMA engine. Flow control is decided by some other heuristic such as whether it's a read/write/etc. command.

Quoted 5 lines

This would also require clients to get multiple references to the same DMA channel if they require some communications with and without flow control.

For NAND, this would mean having two channels for dma. One for flow controlled and one without.

So the NAND DT would look something like:

	dmas = <&adm_dma 3 0>, <%&adm_dma 3 1>;
	dma-names = "rxtx", "rxtx_fc";
	qcom,cmd-crci = <15>;
	qcom,data-crci = <3>;

? We'd still need the cmd-crci and data-crci properties for the slave_id, unless I'm confusing something?

Thanks,

Signature · 1 line
thomas
#4 lore raw

Re: [RESEND PATCH 1/5] dtbindings: qcom_adm: Fix channel specifiers

Quoted 59 lines · Thomas Pedersen

Hi Andy,

Quoted 33 lines · Andy Gross
Quoted 28 lines · Thomas Pedersen

From: Andy Gross <[email protected]>

This patch removes the crci information from the dma channel property. At least one client device requires using more than one CRCI value for a channel. This does not match the current binding and the crci information needs to be removed.

Instead, the client device will provide this information via other means.

---
Documentation/devicetree/bindings/dma/qcom_adm.txt | 16
++++++----------

1 file changed, 6 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/dma/qcom_adm.txt +0 -4
index 9bcab91..38d45f8 100644
@@ -4,8 +4,7 @@ Required properties:
- compatible: must contain "qcom,adm" for IPQ/APQ8064 and MSM8960
- reg: Address range for DMA registers
- interrupts: Should contain one interrupt shared by all channels
-- #dma-cells: must be <2>.  First cell denotes the channel number.
Quoted 3 lines

Second cell
- denotes CRCI (client rate control interface) flow control assignment. +- #dma-cells: must be <1>. First cell denotes the channel number.

Quoted 8 lines

I've actually been thinking more about this. The crci being specified in the
slave config is probably the wrong approach. What we really need is each physical DMA channel to allow for virtual channels that allow for a CRCI setting
(0 being no flow control). This would require the properties to continue to be
2 for the dma definition.

AFAICT the cmd-crci and data-crci properties in the NAND controller client are
really just the slave_id for the DMA engine. Flow control is decided by some other heuristic such as whether it's a read/write/etc. command.

Quoted 6 lines

This would also require clients to get multiple references to the same DMA channel if they require some communications with and without flow control.

For NAND, this would mean having two channels for dma. One for flow controlled
and one without.

So the NAND DT would look something like:

Quoted 8 lines
	dmas = <&adm_dma 3 0>, <%&adm_dma 3 1>;
	dma-names = "rxtx", "rxtx_fc";
	qcom,cmd-crci = <15>;
	qcom,data-crci = <3>;

? We'd still need the cmd-crci and data-crci properties for the slave_id, unless
I'm confusing something?

No, what we would have are separate channels for cmd and data that would be virtual channels sharing the same hardware channel. At least that is what I am
thinking. So

dmas = <&adm 3 0>, <&adm 3 15>, <&adm 3 3>;
dma-names = "rxtx", "rxtx-cmd", "rxtx-data"; # insert better names here

All three would use channel 3, but the virtual channel would know about the crci. CRCI = 0 is no flow control.

I need to look at the nand a little harder to see how they formulate the dma requests.

Regards,

Andy

#5 lore raw

Re: [RESEND PATCH 1/5] dtbindings: qcom_adm: Fix channel specifiers

Quoted 73 lines · Andy Gross
Quoted 59 lines · Thomas Pedersen

Hi Andy,

Quoted 33 lines · Andy Gross
Quoted 28 lines · Thomas Pedersen

From: Andy Gross <[email protected]>

This patch removes the crci information from the dma channel property. At least one client device requires using more than one CRCI value for a channel. This does not match the current binding and the crci information needs to be removed.

Instead, the client device will provide this information via other means.

---
Documentation/devicetree/bindings/dma/qcom_adm.txt | 16
++++++----------

1 file changed, 6 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/dma/qcom_adm.txt +0 -4
index 9bcab91..38d45f8 100644
@@ -4,8 +4,7 @@ Required properties:
- compatible: must contain "qcom,adm" for IPQ/APQ8064 and MSM8960
- reg: Address range for DMA registers
- interrupts: Should contain one interrupt shared by all channels
-- #dma-cells: must be <2>.  First cell denotes the channel number.
Quoted 3 lines

Second cell
- denotes CRCI (client rate control interface) flow control assignment. +- #dma-cells: must be <1>. First cell denotes the channel number.

Quoted 8 lines

I've actually been thinking more about this. The crci being specified in the
slave config is probably the wrong approach. What we really need is each physical DMA channel to allow for virtual channels that allow for a CRCI setting
(0 being no flow control). This would require the properties to continue to be
2 for the dma definition.

AFAICT the cmd-crci and data-crci properties in the NAND controller client are
really just the slave_id for the DMA engine. Flow control is decided by some other heuristic such as whether it's a read/write/etc. command.

Quoted 6 lines

This would also require clients to get multiple references to the same DMA channel if they require some communications with and without flow control.

For NAND, this would mean having two channels for dma. One for flow controlled
and one without.

So the NAND DT would look something like:

Quoted 8 lines
	dmas = <&adm_dma 3 0>, <%&adm_dma 3 1>;
	dma-names = "rxtx", "rxtx_fc";
	qcom,cmd-crci = <15>;
	qcom,data-crci = <3>;

? We'd still need the cmd-crci and data-crci properties for the slave_id, unless
I'm confusing something?

No, what we would have are separate channels for cmd and data that would be virtual channels sharing the same hardware channel. At least that is what I am
thinking. So

Quoted 8 lines

dmas = <&adm 3 0>, <&adm 3 15>, <&adm 3 3>;
dma-names = "rxtx", "rxtx-cmd", "rxtx-data"; # insert better names here

All three would use channel 3, but the virtual channel would know about the crci. CRCI = 0 is no flow control.

I need to look at the nand a little harder to see how they formulate the dma requests.

Did you have a chance to look into this? If not, can you provide some more specific pointers (like would these virtual channels be in the NAND controller or ADM driver?), and I can give it a try?

Signature · 1 line
thomas
#6 lore raw

Re: [RESEND PATCH 1/5] dtbindings: qcom_adm: Fix channel specifiers

Quoted 87 lines · Thomas Pedersen
Quoted 86 lines · Andy Gross
Quoted 66 lines · Thomas Pedersen

Hi Andy,

Quoted 33 lines · Andy Gross
Quoted 28 lines · Thomas Pedersen

From: Andy Gross <[email protected]>

This patch removes the crci information from the dma channel property. At least one client device requires using more than one CRCI value for a channel. This does not match the current binding and the crci information needs to be removed.

Instead, the client device will provide this information via other means.

---
Documentation/devicetree/bindings/dma/qcom_adm.txt | 16
++++++----------

1 file changed, 6 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/dma/qcom_adm.txt +0 -4
index 9bcab91..38d45f8 100644
@@ -4,8 +4,7 @@ Required properties:
- compatible: must contain "qcom,adm" for IPQ/APQ8064 and MSM8960
- reg: Address range for DMA registers
- interrupts: Should contain one interrupt shared by all channels
-- #dma-cells: must be <2>.  First cell denotes the channel number.
Quoted 3 lines

Second cell
- denotes CRCI (client rate control interface) flow control assignment. +- #dma-cells: must be <1>. First cell denotes the channel number.

Quoted 8 lines

I've actually been thinking more about this. The crci being specified in the
slave config is probably the wrong approach. What we really need is each physical DMA channel to allow for virtual channels that allow for a CRCI setting
(0 being no flow control). This would require the properties to continue to be
2 for the dma definition.

AFAICT the cmd-crci and data-crci properties in the NAND controller client
are
really just the slave_id for the DMA engine. Flow control is decided by some
other heuristic such as whether it's a read/write/etc. command.

Quoted 6 lines

This would also require clients to get multiple references to the same DMA channel if they require some communications with and without flow control.

For NAND, this would mean having two channels for dma. One for flow controlled
and one without.

So the NAND DT would look something like:

	dmas = <&adm_dma 3 0>, <%&adm_dma 3 1>;
	dma-names = "rxtx", "rxtx_fc";
	qcom,cmd-crci = <15>;
	qcom,data-crci = <3>;
Quoted 4 lines

? We'd still need the cmd-crci and data-crci properties for the slave_id,
unless
I'm confusing something?

No, what we would have are separate channels for cmd and data that would be
virtual channels sharing the same hardware channel. At least that is what I am
thinking. So

dmas = <&adm 3 0>, <&adm 3 15>, <&adm 3 3>;
dma-names = "rxtx", "rxtx-cmd", "rxtx-data"; # insert better names
here

All three would use channel 3, but the virtual channel would know about the
crci. CRCI = 0 is no flow control.

Quoted 8 lines
Quoted 3 lines

I need to look at the nand a little harder to see how they formulate the dma
requests.

Did you have a chance to look into this? If not, can you provide some more specific pointers (like would these virtual channels be in the NAND controller
or ADM driver?), and I can give it a try?

The virtual channels would be in the ADM driver. So when you specify the dmas in the DT, you'd specify adm, channel X, crci Y. This in turn would return a dma channel that encapsulates the channel + crci. This takes away the requirement of having to do the slave_config.

As it is right now with the current ADM driver, you grab one channel and then slave_config it before you add descriptors. This simplifies the number of dma channels, but complicates things by requiring you to constantly slave_config if you are going from crci, to no crci.

Separating the channel+crci into a virtual channel means that the ADM driver itself will collate the requests as they come in, and apply them to the actual hardware channel.

That make sense? If so, this requires modifying the DT doc to specify the crci in the binding, modifying the ADM driver to identify/add channels based on the channel + crci, and modifying the clients which use both flow control and non-flow control.

#7 lore raw

Re: [RESEND PATCH 1/5] dtbindings: qcom_adm: Fix channel specifiers

Quoted 107 lines · Andy Gross
Quoted 87 lines · Thomas Pedersen
Quoted 86 lines · Andy Gross
Quoted 66 lines · Thomas Pedersen

Hi Andy,

Quoted 33 lines · Andy Gross
Quoted 28 lines · Thomas Pedersen

From: Andy Gross <[email protected]>

This patch removes the crci information from the dma channel property. At least one client device requires using more than one CRCI value for a channel. This does not match the current binding and the crci information needs to be removed.

Instead, the client device will provide this information via other means.

---
Documentation/devicetree/bindings/dma/qcom_adm.txt | 16
++++++----------

1 file changed, 6 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/dma/qcom_adm.txt +0 -4
index 9bcab91..38d45f8 100644
@@ -4,8 +4,7 @@ Required properties:
- compatible: must contain "qcom,adm" for IPQ/APQ8064 and MSM8960
- reg: Address range for DMA registers
- interrupts: Should contain one interrupt shared by all channels
-- #dma-cells: must be <2>.  First cell denotes the channel number.
Quoted 3 lines

Second cell
- denotes CRCI (client rate control interface) flow control assignment. +- #dma-cells: must be <1>. First cell denotes the channel number.

Quoted 8 lines

I've actually been thinking more about this. The crci being specified in the
slave config is probably the wrong approach. What we really need is each physical DMA channel to allow for virtual channels that allow for a CRCI setting
(0 being no flow control). This would require the properties to continue to be
2 for the dma definition.

AFAICT the cmd-crci and data-crci properties in the NAND controller client
are
really just the slave_id for the DMA engine. Flow control is decided by some
other heuristic such as whether it's a read/write/etc. command.

Quoted 6 lines

This would also require clients to get multiple references to the same DMA channel if they require some communications with and without flow control.

For NAND, this would mean having two channels for dma. One for flow controlled
and one without.

So the NAND DT would look something like:

	dmas = <&adm_dma 3 0>, <%&adm_dma 3 1>;
	dma-names = "rxtx", "rxtx_fc";
	qcom,cmd-crci = <15>;
	qcom,data-crci = <3>;
Quoted 4 lines

? We'd still need the cmd-crci and data-crci properties for the slave_id,
unless
I'm confusing something?

No, what we would have are separate channels for cmd and data that would be
virtual channels sharing the same hardware channel. At least that is what I am
thinking. So

dmas = <&adm 3 0>, <&adm 3 15>, <&adm 3 3>;
dma-names = "rxtx", "rxtx-cmd", "rxtx-data"; # insert better names
here

All three would use channel 3, but the virtual channel would know about the
crci. CRCI = 0 is no flow control.

Quoted 8 lines
Quoted 3 lines

I need to look at the nand a little harder to see how they formulate the dma
requests.

Did you have a chance to look into this? If not, can you provide some more specific pointers (like would these virtual channels be in the NAND controller
or ADM driver?), and I can give it a try?

The virtual channels would be in the ADM driver. So when you specify the dmas in the DT, you'd specify adm, channel X, crci Y. This in turn would return a dma channel that encapsulates the channel + crci. This takes away the requirement of having to do the slave_config.

As it is right now with the current ADM driver, you grab one channel and then slave_config it before you add descriptors. This simplifies the number of dma channels, but complicates things by requiring you to constantly slave_config if you are going from crci, to no crci.

Quoted 8 lines

Separating the channel+crci into a virtual channel means that the ADM driver itself will collate the requests as they come in, and apply them to the actual hardware channel.

That make sense? If so, this requires modifying the DT doc to specify the crci in the binding, modifying the ADM driver to identify/add channels based on the channel + crci, and modifying the clients which use both flow control and non-flow control.

OK thanks for clearing that up. Would be nice to avoid calling slave_config for each command. I'll give this a shot.

Signature · 1 line
thomas
#9 lore raw

RE: [RESEND,2/5] dmaengine: Add ADM driver

In reply to Thomas Pedersen
Quoted 2 lines

Add the DMA engine driver for the QCOM Application Data Mover (ADM) DMA controller found in the MSM8x60 and IPQ/APQ8064 platforms.

With minor changes I got this working on MDM9615, using qcom_nand. Below are the changes I had to make, please consider them. Patches for MDM9615 NAND are pending.

Quoted 5 lines
drivers/dma/qcom/qcom_adm.c new file +5 -0
+static struct dma_async_tx_descriptor *adm_prep_slave_sg(struct dma_chan *chan,
+	struct scatterlist *sgl, unsigned int sg_len,
+	enum dma_transfer_direction direction, unsigned long flags,
+	void *context)
+{

...

drivers/dma/qcom/qcom_adm.c line 382

Quoted 8 lines
drivers/dma/qcom/qcom_adm.c new file +8 -0
+	/* if using flow control, validate burst and crci values */
+	if (achan->slave.device_fc) {
+
+		blk_size = adm_get_blksize(burst);
+		if (blk_size < 0) {
+			dev_err(adev->dev, "invalid burst value: %d\n",
+				burst);
+			return ERR_PTR(-EINVAL);

Return NULL here, most DMA clients (including qcom_nand) expect NULL if prep_slave_sg() fails.

drivers/dma/qcom/qcom_adm.c line 388

Quoted 6 lines
drivers/dma/qcom/qcom_adm.c new file +6 -0
+		}
+
+		crci = achan->slave.slave_id & 0xf;
+		if (!crci || achan->slave.slave_id > 0x1f) {
+			dev_err(adev->dev, "invalid crci value\n");
+			return ERR_PTR(-EINVAL);

Ditto above.

Quoted 9 lines
drivers/dma/qcom/qcom_adm.c new file +9 -0
+		}
+	}
+
+	/* iterate through sgs and compute allocation size of structures */
+	for_each_sg(sgl, sg, sg_len, i) {
+		if (achan->slave.device_fc) {
+			box_count += DIV_ROUND_UP(sg_dma_len(sg) / burst,
+						  ADM_MAX_ROWS);
+			if (sg_dma_len(sg) % burst)

drivers/dma/qcom/qcom_adm.c line 407

Quoted 10 lines
drivers/dma/qcom/qcom_adm.c new file +10 -0
+				single_count++;
+		} else {
+			single_count += DIV_ROUND_UP(sg_dma_len(sg),
+						     ADM_MAX_XFER);
+		}
+	}
+
+	async_desc = kzalloc(sizeof(*async_desc), GFP_NOWAIT);
+	if (!async_desc)
+		return ERR_PTR(-ENOMEM);

Ditto above.

drivers/dma/qcom/qcom_adm.c line 419

Quoted 12 lines
drivers/dma/qcom/qcom_adm.c new file +12 -0
+
+	if (crci)
+		async_desc->mux = achan->slave.slave_id & ADM_CRCI_MUX_SEL ?
+					ADM_CRCI_CTL_MUX_SEL : 0;
+	async_desc->crci = crci;
+	async_desc->blk_size = blk_size;
+	async_desc->dma_len = single_count * sizeof(struct adm_desc_hw_single) +
+				box_count * sizeof(struct adm_desc_hw_box) +
+				sizeof(*cple) + 2 * ADM_DESC_ALIGN;
+
+	async_desc->cpl = dma_alloc_writecombine(adev->dev, async_desc->dma_len,
+				&async_desc->dma_addr, GFP_NOWAIT);

Under pressure this allocation might fail, resulting in NAND errors. I handled it using wait_event_timeout() to wait until buffers are available. Either that, or clients such as qcom_nand need to handle this failure.

drivers/dma/qcom/qcom_adm.c line 423

Quoted 4 lines
drivers/dma/qcom/qcom_adm.c new file +4 -0
+
+	if (!async_desc->cpl) {
+		kfree(async_desc);
+		return ERR_PTR(-ENOMEM);

Return NULL.

Quoted 1 line
(quoted diff) +1 -0
+	}

...

Quoted 1 line

+}

...

drivers/dma/qcom/qcom_adm.c line 674

Quoted 7 lines
drivers/dma/qcom/qcom_adm.c new file +7 -0
+static void adm_dma_free_desc(struct virt_dma_desc *vd) {
+	struct adm_async_desc *async_desc = container_of(vd,
+			struct adm_async_desc, vd);
+
+	dma_free_writecombine(async_desc->adev->dev, async_desc->dma_len,
+		async_desc->cpl, async_desc->dma_addr);
+	kfree(async_desc);

Do wake_up() here to signal buffer availability.

Quoted 1 line

+}

Regards, Zoran

#10 lore raw

Re: [RESEND,2/5] dmaengine: Add ADM driver

Quoted 81 lines · Zoran Markovic
Quoted 2 lines

Add the DMA engine driver for the QCOM Application Data Mover (ADM) DMA controller found in the MSM8x60 and IPQ/APQ8064 platforms.

With minor changes I got this working on MDM9615, using qcom_nand. Below are the changes I had to make, please consider them. Patches for MDM9615 NAND are pending.

Quoted 5 lines
drivers/dma/qcom/qcom_adm.c new file +5 -0
+static struct dma_async_tx_descriptor *adm_prep_slave_sg(struct dma_chan *chan,
+	struct scatterlist *sgl, unsigned int sg_len,
+	enum dma_transfer_direction direction, unsigned long flags,
+	void *context)
+{

...

drivers/dma/qcom/qcom_adm.c line 382

Quoted 8 lines
drivers/dma/qcom/qcom_adm.c new file +8 -0
+	/* if using flow control, validate burst and crci values */
+	if (achan->slave.device_fc) {
+
+		blk_size = adm_get_blksize(burst);
+		if (blk_size < 0) {
+			dev_err(adev->dev, "invalid burst value: %d\n",
+				burst);
+			return ERR_PTR(-EINVAL);

Return NULL here, most DMA clients (including qcom_nand) expect NULL if prep_slave_sg() fails.

drivers/dma/qcom/qcom_adm.c line 388

Quoted 6 lines
drivers/dma/qcom/qcom_adm.c new file +6 -0
+		}
+
+		crci = achan->slave.slave_id & 0xf;
+		if (!crci || achan->slave.slave_id > 0x1f) {
+			dev_err(adev->dev, "invalid crci value\n");
+			return ERR_PTR(-EINVAL);

Ditto above.

Quoted 9 lines
drivers/dma/qcom/qcom_adm.c new file +9 -0
+		}
+	}
+
+	/* iterate through sgs and compute allocation size of structures */
+	for_each_sg(sgl, sg, sg_len, i) {
+		if (achan->slave.device_fc) {
+			box_count += DIV_ROUND_UP(sg_dma_len(sg) / burst,
+						  ADM_MAX_ROWS);
+			if (sg_dma_len(sg) % burst)

drivers/dma/qcom/qcom_adm.c line 407

Quoted 10 lines
drivers/dma/qcom/qcom_adm.c new file +10 -0
+				single_count++;
+		} else {
+			single_count += DIV_ROUND_UP(sg_dma_len(sg),
+						     ADM_MAX_XFER);
+		}
+	}
+
+	async_desc = kzalloc(sizeof(*async_desc), GFP_NOWAIT);
+	if (!async_desc)
+		return ERR_PTR(-ENOMEM);

Ditto above.

drivers/dma/qcom/qcom_adm.c line 419

Quoted 12 lines
drivers/dma/qcom/qcom_adm.c new file +12 -0
+
+	if (crci)
+		async_desc->mux = achan->slave.slave_id & ADM_CRCI_MUX_SEL ?
+					ADM_CRCI_CTL_MUX_SEL : 0;
+	async_desc->crci = crci;
+	async_desc->blk_size = blk_size;
+	async_desc->dma_len = single_count * sizeof(struct adm_desc_hw_single) +
+				box_count * sizeof(struct adm_desc_hw_box) +
+				sizeof(*cple) + 2 * ADM_DESC_ALIGN;
+
+	async_desc->cpl = dma_alloc_writecombine(adev->dev, async_desc->dma_len,
+				&async_desc->dma_addr, GFP_NOWAIT);

Under pressure this allocation might fail, resulting in NAND errors. I handled it using wait_event_timeout() to wait until buffers are available. Either that, or clients such as qcom_nand need to handle this failure.

drivers/dma/qcom/qcom_adm.c line 423

Quoted 4 lines
drivers/dma/qcom/qcom_adm.c new file +4 -0
+
+	if (!async_desc->cpl) {
+		kfree(async_desc);
+		return ERR_PTR(-ENOMEM);

Return NULL.

Quoted 1 line
(quoted diff) +1 -0
+	}

...

Quoted 1 line

+}

...

drivers/dma/qcom/qcom_adm.c line 674

Quoted 7 lines
drivers/dma/qcom/qcom_adm.c new file +7 -0
+static void adm_dma_free_desc(struct virt_dma_desc *vd) {
+	struct adm_async_desc *async_desc = container_of(vd,
+			struct adm_async_desc, vd);
+
+	dma_free_writecombine(async_desc->adev->dev, async_desc->dma_len,
+		async_desc->cpl, async_desc->dma_addr);
+	kfree(async_desc);

Do wake_up() here to signal buffer availability.

Quoted 4 lines
Quoted 1 line

+}

Regards, Zoran

Hi Zoran,

These are also the fixes we needed to make the ADM work on MDM9615.

Andy, do you plan to resend this driver ?

Neil

#11 lore raw

Re: [RESEND,2/5] dmaengine: Add ADM driver

Quoted 52 lines · Neil Armstrong
Quoted 49 lines · Zoran Markovic
Quoted 2 lines

Add the DMA engine driver for the QCOM Application Data Mover (ADM) DMA controller found in the MSM8x60 and IPQ/APQ8064 platforms.

With minor changes I got this working on MDM9615, using qcom_nand. Below are the changes I had to make, please consider them. Patches for MDM9615 NAND are pending.

Quoted 5 lines
drivers/dma/qcom/qcom_adm.c new file +5 -0
+static struct dma_async_tx_descriptor *adm_prep_slave_sg(struct dma_chan *chan,
+	struct scatterlist *sgl, unsigned int sg_len,
+	enum dma_transfer_direction direction, unsigned long flags,
+	void *context)
+{

...

drivers/dma/qcom/qcom_adm.c line 382

Quoted 8 lines
drivers/dma/qcom/qcom_adm.c new file +8 -0
+	/* if using flow control, validate burst and crci values */
+	if (achan->slave.device_fc) {
+
+		blk_size = adm_get_blksize(burst);
+		if (blk_size < 0) {
+			dev_err(adev->dev, "invalid burst value: %d\n",
+				burst);
+			return ERR_PTR(-EINVAL);

Return NULL here, most DMA clients (including qcom_nand) expect NULL if prep_slave_sg() fails.

drivers/dma/qcom/qcom_adm.c line 388

Quoted 6 lines
drivers/dma/qcom/qcom_adm.c new file +6 -0
+		}
+
+		crci = achan->slave.slave_id & 0xf;
+		if (!crci || achan->slave.slave_id > 0x1f) {
+			dev_err(adev->dev, "invalid crci value\n");
+			return ERR_PTR(-EINVAL);

Ditto above.

Quoted 9 lines
drivers/dma/qcom/qcom_adm.c new file +9 -0
+		}
+	}
+
+	/* iterate through sgs and compute allocation size of structures */
+	for_each_sg(sgl, sg, sg_len, i) {
+		if (achan->slave.device_fc) {
+			box_count += DIV_ROUND_UP(sg_dma_len(sg) / burst,
+						  ADM_MAX_ROWS);
+			if (sg_dma_len(sg) % burst)

drivers/dma/qcom/qcom_adm.c line 407

Quoted 10 lines
drivers/dma/qcom/qcom_adm.c new file +10 -0
+				single_count++;
+		} else {
+			single_count += DIV_ROUND_UP(sg_dma_len(sg),
+						     ADM_MAX_XFER);
+		}
+	}
+
+	async_desc = kzalloc(sizeof(*async_desc), GFP_NOWAIT);
+	if (!async_desc)
+		return ERR_PTR(-ENOMEM);

Ditto above.

Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
drivers/dma/qcom/qcom_adm.c new file +5 -0
+
+	if (crci)
+		async_desc->mux = achan->slave.slave_id & ADM_CRCI_MUX_SEL ?
+					ADM_CRCI_CTL_MUX_SEL : 0;
+	async_desc->crci = crci;
Quoted 8 lines

drivers/dma/qcom/qcom_adm.c line 419

Quoted 7 lines
drivers/dma/qcom/qcom_adm.c new file +7 -0
+	async_desc->blk_size = blk_size;
+	async_desc->dma_len = single_count * sizeof(struct adm_desc_hw_single) +
+				box_count * sizeof(struct adm_desc_hw_box) +
+				sizeof(*cple) + 2 * ADM_DESC_ALIGN;
+
+	async_desc->cpl = dma_alloc_writecombine(adev->dev, async_desc->dma_len,
+				&async_desc->dma_addr, GFP_NOWAIT);

Under pressure this allocation might fail, resulting in NAND errors. I handled it using wait_event_timeout() to wait until buffers are available. Either that, or clients such as qcom_nand need to handle this failure.

prep_slave_sg calls can be made from atomic context. Which is why we do the GFP_NOWAIT. You can't sleep in that function. Instead, the client needs to see that it got ENOMEM and deal with the memory pressure itself. Either that or we need to relax the dma_alloc to a dma_alloc_coherent (I suspect you'll still have the same problem). Or you need to increase the static dma pool.

I've seen this issue with people using ADM w/ SPI. They had other dma pool pressure and the ADM transfers would fail to get buffers.

Quoted 21 lines
Quoted 21 lines

drivers/dma/qcom/qcom_adm.c line 423

Quoted 5 lines
drivers/dma/qcom/qcom_adm.c new file +4 -0
+
+	if (!async_desc->cpl) {
+		kfree(async_desc);
+		return ERR_PTR(-ENOMEM);

Return NULL.

Quoted 1 line
(quoted diff) +1 -0
+	}

...

Quoted 1 line

+}

...

drivers/dma/qcom/qcom_adm.c line 674

Quoted 7 lines
drivers/dma/qcom/qcom_adm.c new file +7 -0
+static void adm_dma_free_desc(struct virt_dma_desc *vd) {
+	struct adm_async_desc *async_desc = container_of(vd,
+			struct adm_async_desc, vd);
+
+	dma_free_writecombine(async_desc->adev->dev, async_desc->dma_len,
+		async_desc->cpl, async_desc->dma_addr);
+	kfree(async_desc);

Do wake_up() here to signal buffer availability.

Quoted 1 line

+}

Quoted 8 lines
Quoted 2 lines

Regards, Zoran

Hi Zoran,

These are also the fixes we needed to make the ADM work on MDM9615.

Andy, do you plan to resend this driver ?

The main outstanding comments I had were specific to the crci encoding and the use of a virtual channel to encapsulate the crci information instead of using the slave_config. I don't see that being done.

I haven't had time to address that and I was hoping that Thomas would do it. But it seems like he moved on to other things, so I need to put this on my list.

Andy