Skip to contentSkip to conversation

dmaengine: ti: k3-udma: Support for per channel atype

PATCH Applied Peter Ujfalusi 3 participants 5 messages Feb 18, 2020 – Mar 2, 2020

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

cover dmaengine: ti: k3-udma: Support for per channel atype

Hi,

The series is on top of the 5.6 update patches:
https://lore.kernel.org/lkml/[email protected]/

UDMA channels have ATYPE property which tells UDMA on how to treat the pointers within descriptors (and TRs).
The ATYPE defined for j721e are:
0: pointers are physical addresses (no translation)
1: pointers are intermediate addresses (PVU)
2: pointers are virtual addresses (SMMU)

When Linux is booting within a virtualized environment channels must have the ATYPE configured correctly to be able to access memory (ATYPE == 0 is not allowed).
The ATYPE can be different for channels and their ATYPE depends on which endpoint they are servicing, but it is not hardwired.

In order to be able to tell the driver the ATYPE for the channel we need to extend the dma-cells in case the device is going to be used in virtualized setup.

Non virtualized setups can still use dma-cells == 1.

If dma-cells == 2, then the UDMA node must have ti,udma-atype property which is used for non slave channels (where no DT binding is exist for a channel).

Regards,
Peter
---
Peter Ujfalusi (2):
dt-bindings: dma: ti: k3-udma: Update for atype support
(virtualization)
dmaengine: ti: k3-udma: Implement support for atype (for
virtualization)

 .../devicetree/bindings/dma/ti/k3-udma.yaml   | 19 ++++++-
 drivers/dma/ti/k3-udma-glue.c                 | 18 ++++++-
 drivers/dma/ti/k3-udma.c                      | 50 ++++++++++++++++---
 3 files changed, 76 insertions(+), 11 deletions(-)
Signature · 4 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
#1 lore raw

PATCH 1/2 dt-bindings: dma: ti: k3-udma: Update for atype support (virtualization)

In UDMA each channel can use different ATYPE value which tells UDMA how the addresses in the descriptors should be treated:
0: pointers are physical addresses (no translation)
1: pointers are intermediate addresses (PVU)
2: pointers are virtual addresses (SMMU)

When virtualized environment is used then the dma binding should use additional cell to configure the desired ATYPE for the channel.

---
 .../devicetree/bindings/dma/ti/k3-udma.yaml   | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/dma/ti/k3-udma.yaml +18 -1
index 8b5c346f23f6..567bb820b182 100644
@@ -45,7 +45,8 @@ allOf:
 
 properties:
   "#dma-cells":
-    const: 1
+    minimum: 1
+    maximum: 2
     description: |
       The cell is the PSI-L  thread ID of the remote (to UDMAP) end.
       Valid ranges for thread ID depends on the data movement direction:
@@ -55,6 +56,8 @@ properties:
       Please refer to the device documentation for the PSI-L thread map and also
       the PSI-L peripheral chapter for the correct thread ID.
 
+      When #dma-cells is 2, the second parameter is the channel ATYPE.
+
   compatible:
     enum:
       - ti,am654-navss-main-udmap
@@ -131,6 +134,20 @@ required:
   - ti,sci-rm-range-rchan
   - ti,sci-rm-range-rflow
 
+if:
+  properties:
+    "#dma-cells":
+      const: 2
+then:
+  properties:
+    ti,udma-atype:
+      description: ATYPE value which should be used by non slave channels
+      allOf:
+        - $ref: /schemas/types.yaml#/definitions/uint32
+
+  required:
+    - ti,udma-atype
+
 examples:
   - |+
     cbass_main {
Signature · 4 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
maintainer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] dt-bindings: dma: ti: k3-udma: Update for atype support (virtualization)

Quoted 6 lines · Peter Ujfalusi

In UDMA each channel can use different ATYPE value which tells UDMA how the addresses in the descriptors should be treated:
0: pointers are physical addresses (no translation)
1: pointers are intermediate addresses (PVU)
2: pointers are virtual addresses (SMMU)

Quoted 8 lines

When virtualized environment is used then the dma binding should use additional cell to configure the desired ATYPE for the channel.

---
 .../devicetree/bindings/dma/ti/k3-udma.yaml   | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
#3 lore raw

PATCH 2/2 dmaengine: ti: k3-udma: Implement support for atype (for virtualization)

In reply to Peter Ujfalusi

The DT for virtualized hosts have dma-cells == 2 where the second parameter is the ATYPE for the channel.

In case of dma-cells == 1 we can configure the ATYPE as 0 (reset value).

The ATYPE defined for j721e are:
0: pointers are physical addresses (no translation) 1: pointers are intermediate addresses (PVU) 2: pointers are virtual addresses (SMMU)

---
 drivers/dma/ti/k3-udma-glue.c | 18 +++++++++++--
 drivers/dma/ti/k3-udma.c      | 50 +++++++++++++++++++++++++++++------
 2 files changed, 58 insertions(+), 10 deletions(-)
drivers/dma/ti/k3-udma-glue.c +16 -2
index c1511298ece2..dbccdc7c0ed5 100644
@@ -32,6 +32,7 @@ struct k3_udma_glue_common {
 	bool epib;
 	u32  psdata_size;
 	u32  swdata_size;
+	u32  atype;
 };
 
 struct k3_udma_glue_tx_channel {
@@ -121,6 +122,15 @@ static int of_k3_udma_glue_parse_chn(struct device_node *chn_np,
 		return -ENOENT;
 
 	thread_id = dma_spec.args[0];
+	if (dma_spec.args_count == 2) {
+		if (dma_spec.args[1] > 2) {
+			dev_err(common->dev, "Invalid channel atype: %u\n",
+				dma_spec.args[1]);
+			ret = -EINVAL;
+			goto out_put_spec;
+		}
+		common->atype = dma_spec.args[1];
+	}
 
 	if (tx_chn && !(thread_id & K3_PSIL_DST_THREAD_ID_OFFSET)) {
 		ret = -EINVAL;
@@ -202,7 +212,8 @@ static int k3_udma_glue_cfg_tx_chn(struct k3_udma_glue_tx_channel *tx_chn)
 			TI_SCI_MSG_VALUE_RM_UDMAP_CH_CHAN_TYPE_VALID |
 			TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_SUPR_TDPKT_VALID |
 			TI_SCI_MSG_VALUE_RM_UDMAP_CH_FETCH_SIZE_VALID |
-			TI_SCI_MSG_VALUE_RM_UDMAP_CH_CQ_QNUM_VALID;
+			TI_SCI_MSG_VALUE_RM_UDMAP_CH_CQ_QNUM_VALID |
+			TI_SCI_MSG_VALUE_RM_UDMAP_CH_ATYPE_VALID;
 	req.nav_id = tisci_rm->tisci_dev_id;
 	req.index = tx_chn->udma_tchan_id;
 	if (tx_chn->tx_pause_on_err)
@@ -216,6 +227,7 @@ static int k3_udma_glue_cfg_tx_chn(struct k3_udma_glue_tx_channel *tx_chn)
 		req.tx_supr_tdpkt = 1;
 	req.tx_fetch_size = tx_chn->common.hdesc_size >> 2;
 	req.txcq_qnum = k3_ringacc_get_ring_id(tx_chn->ringtxcq);
+	req.tx_atype = tx_chn->common.atype;
 
 	return tisci_rm->tisci_udmap_ops->tx_ch_cfg(tisci_rm->tisci, &req);
 }
@@ -502,7 +514,8 @@ static int k3_udma_glue_cfg_rx_chn(struct k3_udma_glue_rx_channel *rx_chn)
 			   TI_SCI_MSG_VALUE_RM_UDMAP_CH_CQ_QNUM_VALID |
 			   TI_SCI_MSG_VALUE_RM_UDMAP_CH_CHAN_TYPE_VALID |
 			   TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_FLOWID_START_VALID |
-			   TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_FLOWID_CNT_VALID;
+			   TI_SCI_MSG_VALUE_RM_UDMAP_CH_RX_FLOWID_CNT_VALID |
+			   TI_SCI_MSG_VALUE_RM_UDMAP_CH_ATYPE_VALID;
 
 	req.nav_id = tisci_rm->tisci_dev_id;
 	req.index = rx_chn->udma_rchan_id;
@@ -519,6 +532,7 @@ static int k3_udma_glue_cfg_rx_chn(struct k3_udma_glue_rx_channel *rx_chn)
 		req.flowid_cnt = rx_chn->flow_num;
 	}
 	req.rx_chan_type = TI_SCI_RM_UDMAP_CHAN_TYPE_PKT_PBRR;
+	req.rx_atype = rx_chn->common.atype;
 
 	ret = tisci_rm->tisci_udmap_ops->rx_ch_cfg(tisci_rm->tisci, &req);
 	if (ret)
drivers/dma/ti/k3-udma.c +42 -8

139 lines not on this page · raw message

Signature · 4 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
maintainer Applied
#4 lore raw
In reply to Peter Ujfalusi
Quoted 18 lines · Peter Ujfalusi

Hi,

The series is on top of the 5.6 update patches:
https://lore.kernel.org/lkml/[email protected]/

UDMA channels have ATYPE property which tells UDMA on how to treat the pointers within descriptors (and TRs).
The ATYPE defined for j721e are:
0: pointers are physical addresses (no translation)
1: pointers are intermediate addresses (PVU)
2: pointers are virtual addresses (SMMU)

When Linux is booting within a virtualized environment channels must have the ATYPE configured correctly to be able to access memory (ATYPE == 0 is not allowed).
The ATYPE can be different for channels and their ATYPE depends on which endpoint they are servicing, but it is not hardwired.

Quoted 8 lines

In order to be able to tell the driver the ATYPE for the channel we need to extend the dma-cells in case the device is going to be used in virtualized setup.

Non virtualized setups can still use dma-cells == 1.

If dma-cells == 2, then the UDMA node must have ti,udma-atype property which is used for non slave channels (where no DT binding is exist for a channel).

Applied, thanks

Signature · 1 line
~Vinod