2020-07-01 10:31:23

by Grygorii Strashko

[permalink] [raw]
Subject: [PATCH next 0/6] soc: ti: k3-ringacc: updates

Hi Santosh,

This series is a set of non critical updates for The TI K3 AM654x/J721E
Ring Accelerator driver.

Patch 1 - convert bindings to json-schema
Patches 2,3,5 - code reworking
Patch 4 - adds new API to request pair of rings k3_ringacc_request_rings_pair()
Patch 6 - updates K3 UDMA to use new API

Grygorii Strashko (4):
dt-bindings: soc: ti: k3-ringacc: convert bindings to json-schema
soc: ti: k3-ringacc: add ring's flags to dump
soc: ti: k3-ringacc: add request pair of rings api.
soc: ti: k3-ringacc: separate soc specific initialization

Peter Ujfalusi (2):
soc: ti: k3-ringacc: Move state tracking variables under a struct
dmaengine: ti: k3-udma: Switch to k3_ringacc_request_rings_pair

.../devicetree/bindings/soc/ti/k3-ringacc.txt | 59 ------
.../bindings/soc/ti/k3-ringacc.yaml | 102 +++++++++
drivers/dma/ti/k3-udma-glue.c | 40 ++--
drivers/dma/ti/k3-udma.c | 34 +--
drivers/soc/ti/k3-ringacc.c | 194 ++++++++++++------
include/linux/soc/ti/k3-ringacc.h | 4 +
6 files changed, 261 insertions(+), 172 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/soc/ti/k3-ringacc.txt
create mode 100644 Documentation/devicetree/bindings/soc/ti/k3-ringacc.yaml

--
2.17.1


2020-07-01 10:31:38

by Grygorii Strashko

[permalink] [raw]
Subject: [PATCH next 2/6] soc: ti: k3-ringacc: Move state tracking variables under a struct

From: Peter Ujfalusi <[email protected]>

Move the free, occ, windex and rindex under a struct. We can use memset to
zero them and it will allow a cleaner way to extend driver functionality in
the future,

Signed-off-by: Peter Ujfalusi <[email protected]>
Signed-off-by: Grygorii Strashko <[email protected]>
---
drivers/soc/ti/k3-ringacc.c | 99 +++++++++++++++++++------------------
1 file changed, 51 insertions(+), 48 deletions(-)

diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c
index 19156f15af0a..d2dc9c144a89 100644
--- a/drivers/soc/ti/k3-ringacc.c
+++ b/drivers/soc/ti/k3-ringacc.c
@@ -108,6 +108,21 @@ struct k3_ring_ops {
int (*pop_head)(struct k3_ring *ring, void *elm);
};

+/**
+ * struct k3_ring_state - Internal state tracking structure
+ *
+ * @free: Number of free entries
+ * @occ: Occupancy
+ * @windex: Write index
+ * @rindex: Read index
+ */
+struct k3_ring_state {
+ u32 free;
+ u32 occ;
+ u32 windex;
+ u32 rindex;
+};
+
/**
* struct k3_ring - RA Ring descriptor
*
@@ -121,10 +136,6 @@ struct k3_ring_ops {
* @elm_size: Size of the ring element
* @mode: Ring mode
* @flags: flags
- * @free: Number of free elements
- * @occ: Ring occupancy
- * @windex: Write index (only for @K3_RINGACC_RING_MODE_RING)
- * @rindex: Read index (only for @K3_RINGACC_RING_MODE_RING)
* @ring_id: Ring Id
* @parent: Pointer on struct @k3_ringacc
* @use_count: Use count for shared rings
@@ -143,10 +154,7 @@ struct k3_ring {
u32 flags;
#define K3_RING_FLAG_BUSY BIT(1)
#define K3_RING_FLAG_SHARED BIT(2)
- u32 free;
- u32 occ;
- u32 windex;
- u32 rindex;
+ struct k3_ring_state state;
u32 ring_id;
struct k3_ringacc *parent;
u32 use_count;
@@ -339,10 +347,7 @@ void k3_ringacc_ring_reset(struct k3_ring *ring)
if (!ring || !(ring->flags & K3_RING_FLAG_BUSY))
return;

- ring->occ = 0;
- ring->free = 0;
- ring->rindex = 0;
- ring->windex = 0;
+ memset(&ring->state, 0, sizeof(ring->state));

k3_ringacc_ring_reset_sci(ring);
}
@@ -592,10 +597,7 @@ int k3_ringacc_ring_cfg(struct k3_ring *ring, struct k3_ring_cfg *cfg)
ring->size = cfg->size;
ring->elm_size = cfg->elm_size;
ring->mode = cfg->mode;
- ring->occ = 0;
- ring->free = 0;
- ring->rindex = 0;
- ring->windex = 0;
+ memset(&ring->state, 0, sizeof(ring->state));

if (ring->proxy_id != K3_RINGACC_PROXY_NOT_USED)
ring->proxy = ringacc->proxy_target_base +
@@ -666,10 +668,10 @@ u32 k3_ringacc_ring_get_free(struct k3_ring *ring)
if (!ring || !(ring->flags & K3_RING_FLAG_BUSY))
return -EINVAL;

- if (!ring->free)
- ring->free = ring->size - readl(&ring->rt->occ);
+ if (!ring->state.free)
+ ring->state.free = ring->size - readl(&ring->rt->occ);

- return ring->free;
+ return ring->state.free;
}
EXPORT_SYMBOL_GPL(k3_ringacc_ring_get_free);

@@ -740,7 +742,7 @@ static int k3_ringacc_ring_access_proxy(struct k3_ring *ring, void *elem,
"proxy:memcpy_fromio(x): --> ptr(%p), mode:%d\n", ptr,
access_mode);
memcpy_fromio(elem, ptr, (4 << ring->elm_size));
- ring->occ--;
+ ring->state.occ--;
break;
case K3_RINGACC_ACCESS_MODE_PUSH_TAIL:
case K3_RINGACC_ACCESS_MODE_PUSH_HEAD:
@@ -748,14 +750,14 @@ static int k3_ringacc_ring_access_proxy(struct k3_ring *ring, void *elem,
"proxy:memcpy_toio(x): --> ptr(%p), mode:%d\n", ptr,
access_mode);
memcpy_toio(ptr, elem, (4 << ring->elm_size));
- ring->free--;
+ ring->state.free--;
break;
default:
return -EINVAL;
}

- dev_dbg(ring->parent->dev, "proxy: free%d occ%d\n", ring->free,
- ring->occ);
+ dev_dbg(ring->parent->dev, "proxy: free%d occ%d\n", ring->state.free,
+ ring->state.occ);
return 0;
}

@@ -810,7 +812,7 @@ static int k3_ringacc_ring_access_io(struct k3_ring *ring, void *elem,
"memcpy_fromio(x): --> ptr(%p), mode:%d\n", ptr,
access_mode);
memcpy_fromio(elem, ptr, (4 << ring->elm_size));
- ring->occ--;
+ ring->state.occ--;
break;
case K3_RINGACC_ACCESS_MODE_PUSH_TAIL:
case K3_RINGACC_ACCESS_MODE_PUSH_HEAD:
@@ -818,14 +820,15 @@ static int k3_ringacc_ring_access_io(struct k3_ring *ring, void *elem,
"memcpy_toio(x): --> ptr(%p), mode:%d\n", ptr,
access_mode);
memcpy_toio(ptr, elem, (4 << ring->elm_size));
- ring->free--;
+ ring->state.free--;
break;
default:
return -EINVAL;
}

- dev_dbg(ring->parent->dev, "free%d index%d occ%d index%d\n", ring->free,
- ring->windex, ring->occ, ring->rindex);
+ dev_dbg(ring->parent->dev, "free%d index%d occ%d index%d\n",
+ ring->state.free, ring->state.windex, ring->state.occ,
+ ring->state.rindex);
return 0;
}

@@ -857,16 +860,16 @@ static int k3_ringacc_ring_push_mem(struct k3_ring *ring, void *elem)
{
void *elem_ptr;

- elem_ptr = k3_ringacc_get_elm_addr(ring, ring->windex);
+ elem_ptr = k3_ringacc_get_elm_addr(ring, ring->state.windex);

memcpy(elem_ptr, elem, (4 << ring->elm_size));

- ring->windex = (ring->windex + 1) % ring->size;
- ring->free--;
+ ring->state.windex = (ring->state.windex + 1) % ring->size;
+ ring->state.free--;
writel(1, &ring->rt->db);

dev_dbg(ring->parent->dev, "ring_push_mem: free%d index%d\n",
- ring->free, ring->windex);
+ ring->state.free, ring->state.windex);

return 0;
}
@@ -875,16 +878,16 @@ static int k3_ringacc_ring_pop_mem(struct k3_ring *ring, void *elem)
{
void *elem_ptr;

- elem_ptr = k3_ringacc_get_elm_addr(ring, ring->rindex);
+ elem_ptr = k3_ringacc_get_elm_addr(ring, ring->state.rindex);

memcpy(elem, elem_ptr, (4 << ring->elm_size));

- ring->rindex = (ring->rindex + 1) % ring->size;
- ring->occ--;
+ ring->state.rindex = (ring->state.rindex + 1) % ring->size;
+ ring->state.occ--;
writel(-1, &ring->rt->db);

dev_dbg(ring->parent->dev, "ring_pop_mem: occ%d index%d pos_ptr%p\n",
- ring->occ, ring->rindex, elem_ptr);
+ ring->state.occ, ring->state.rindex, elem_ptr);
return 0;
}

@@ -895,8 +898,8 @@ int k3_ringacc_ring_push(struct k3_ring *ring, void *elem)
if (!ring || !(ring->flags & K3_RING_FLAG_BUSY))
return -EINVAL;

- dev_dbg(ring->parent->dev, "ring_push: free%d index%d\n", ring->free,
- ring->windex);
+ dev_dbg(ring->parent->dev, "ring_push: free%d index%d\n",
+ ring->state.free, ring->state.windex);

if (k3_ringacc_ring_is_full(ring))
return -ENOMEM;
@@ -916,7 +919,7 @@ int k3_ringacc_ring_push_head(struct k3_ring *ring, void *elem)
return -EINVAL;

dev_dbg(ring->parent->dev, "ring_push_head: free%d index%d\n",
- ring->free, ring->windex);
+ ring->state.free, ring->state.windex);

if (k3_ringacc_ring_is_full(ring))
return -ENOMEM;
@@ -935,13 +938,13 @@ int k3_ringacc_ring_pop(struct k3_ring *ring, void *elem)
if (!ring || !(ring->flags & K3_RING_FLAG_BUSY))
return -EINVAL;

- if (!ring->occ)
- ring->occ = k3_ringacc_ring_get_occ(ring);
+ if (!ring->state.occ)
+ ring->state.occ = k3_ringacc_ring_get_occ(ring);

- dev_dbg(ring->parent->dev, "ring_pop: occ%d index%d\n", ring->occ,
- ring->rindex);
+ dev_dbg(ring->parent->dev, "ring_pop: occ%d index%d\n", ring->state.occ,
+ ring->state.rindex);

- if (!ring->occ)
+ if (!ring->state.occ)
return -ENODATA;

if (ring->ops && ring->ops->pop_head)
@@ -958,13 +961,13 @@ int k3_ringacc_ring_pop_tail(struct k3_ring *ring, void *elem)
if (!ring || !(ring->flags & K3_RING_FLAG_BUSY))
return -EINVAL;

- if (!ring->occ)
- ring->occ = k3_ringacc_ring_get_occ(ring);
+ if (!ring->state.occ)
+ ring->state.occ = k3_ringacc_ring_get_occ(ring);

- dev_dbg(ring->parent->dev, "ring_pop_tail: occ%d index%d\n", ring->occ,
- ring->rindex);
+ dev_dbg(ring->parent->dev, "ring_pop_tail: occ%d index%d\n",
+ ring->state.occ, ring->state.rindex);

- if (!ring->occ)
+ if (!ring->state.occ)
return -ENODATA;

if (ring->ops && ring->ops->pop_tail)
--
2.17.1

2020-07-01 10:31:39

by Grygorii Strashko

[permalink] [raw]
Subject: [PATCH next 1/6] dt-bindings: soc: ti: k3-ringacc: convert bindings to json-schema

Convert the K3 NavigatorSS Ring Accelerator bindings documentation to
json-schema.

Cc: Rob Herring <[email protected]>
Signed-off-by: Grygorii Strashko <[email protected]>
---
.../devicetree/bindings/soc/ti/k3-ringacc.txt | 59 ----------
.../bindings/soc/ti/k3-ringacc.yaml | 102 ++++++++++++++++++
2 files changed, 102 insertions(+), 59 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/soc/ti/k3-ringacc.txt
create mode 100644 Documentation/devicetree/bindings/soc/ti/k3-ringacc.yaml

diff --git a/Documentation/devicetree/bindings/soc/ti/k3-ringacc.txt b/Documentation/devicetree/bindings/soc/ti/k3-ringacc.txt
deleted file mode 100644
index 59758ccce809..000000000000
--- a/Documentation/devicetree/bindings/soc/ti/k3-ringacc.txt
+++ /dev/null
@@ -1,59 +0,0 @@
-* Texas Instruments K3 NavigatorSS Ring Accelerator
-
-The Ring Accelerator (RA) is a machine which converts read/write accesses
-from/to a constant address into corresponding read/write accesses from/to a
-circular data structure in memory. The RA eliminates the need for each DMA
-controller which needs to access ring elements from having to know the current
-state of the ring (base address, current offset). The DMA controller
-performs a read or write access to a specific address range (which maps to the
-source interface on the RA) and the RA replaces the address for the transaction
-with a new address which corresponds to the head or tail element of the ring
-(head for reads, tail for writes).
-
-The Ring Accelerator is a hardware module that is responsible for accelerating
-management of the packet queues. The K3 SoCs can have more than one RA instances
-
-Required properties:
-- compatible : Must be "ti,am654-navss-ringacc";
-- reg : Should contain register location and length of the following
- named register regions.
-- reg-names : should be
- "rt" - The RA Ring Real-time Control/Status Registers
- "fifos" - The RA Queues Registers
- "proxy_gcfg" - The RA Proxy Global Config Registers
- "proxy_target" - The RA Proxy Datapath Registers
-- ti,num-rings : Number of rings supported by RA
-- ti,sci-rm-range-gp-rings : TI-SCI RM subtype for GP ring range
-- ti,sci : phandle on TI-SCI compatible System controller node
-- ti,sci-dev-id : TI-SCI device id of the ring accelerator
-- msi-parent : phandle for "ti,sci-inta" interrupt controller
-
-Optional properties:
- -- ti,dma-ring-reset-quirk : enable ringacc / udma ring state interoperability
- issue software w/a
-
-Example:
-
-ringacc: ringacc@3c000000 {
- compatible = "ti,am654-navss-ringacc";
- reg = <0x0 0x3c000000 0x0 0x400000>,
- <0x0 0x38000000 0x0 0x400000>,
- <0x0 0x31120000 0x0 0x100>,
- <0x0 0x33000000 0x0 0x40000>;
- reg-names = "rt", "fifos",
- "proxy_gcfg", "proxy_target";
- ti,num-rings = <818>;
- ti,sci-rm-range-gp-rings = <0x2>; /* GP ring range */
- ti,dma-ring-reset-quirk;
- ti,sci = <&dmsc>;
- ti,sci-dev-id = <187>;
- msi-parent = <&inta_main_udmass>;
-};
-
-client:
-
-dma_ipx: dma_ipx@<addr> {
- ...
- ti,ringacc = <&ringacc>;
- ...
-}
diff --git a/Documentation/devicetree/bindings/soc/ti/k3-ringacc.yaml b/Documentation/devicetree/bindings/soc/ti/k3-ringacc.yaml
new file mode 100644
index 000000000000..ae33fc957141
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/ti/k3-ringacc.yaml
@@ -0,0 +1,102 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/soc/ti/k3-ringacc.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Texas Instruments K3 NavigatorSS Ring Accelerator
+
+maintainers:
+ - Santosh Shilimkar <[email protected]>
+ - Grygorii Strashko <[email protected]>
+
+description: |
+ The Ring Accelerator (RA) is a machine which converts read/write accesses
+ from/to a constant address into corresponding read/write accesses from/to a
+ circular data structure in memory. The RA eliminates the need for each DMA
+ controller which needs to access ring elements from having to know the current
+ state of the ring (base address, current offset). The DMA controller
+ performs a read or write access to a specific address range (which maps to the
+ source interface on the RA) and the RA replaces the address for the transaction
+ with a new address which corresponds to the head or tail element of the ring
+ (head for reads, tail for writes).
+
+ The Ring Accelerator is a hardware module that is responsible for accelerating
+ management of the packet queues. The K3 SoCs can have more than one RA instances
+
+properties:
+ compatible:
+ items:
+ - const: ti,am654-navss-ringacc
+
+ reg:
+ items:
+ - description: real time registers regions
+ - description: fifos registers regions
+ - description: proxy gcfg registers regions
+ - description: proxy target registers regions
+
+ reg-names:
+ items:
+ - const: rt
+ - const: fifos
+ - const: proxy_gcfg
+ - const: proxy_target
+
+ msi-parent: true
+
+ ti,num-rings:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: Number of rings supported by RA
+
+ ti,sci-rm-range-gp-rings:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: TI-SCI RM subtype for GP ring range
+
+ ti,sci:
+ $ref: /schemas/types.yaml#definitions/phandle-array
+ description: phandle on TI-SCI compatible System controller node
+
+ ti,sci-dev-id:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: TI-SCI device id of the ring accelerator
+
+ ti,dma-ring-reset-quirk:
+ $ref: /schemas/types.yaml#definitions/flag
+ description: |
+ enable ringacc/udma ring state interoperability issue software w/a
+
+required:
+ - compatible
+ - reg
+ - reg-names
+ - msi-parent
+ - ti,num-rings
+ - ti,sci-rm-range-gp-rings
+ - ti,sci
+ - ti,sci-dev-id
+
+additionalProperties: false
+
+examples:
+ - |
+ bus {
+ #address-cells = <2>;
+ #size-cells = <2>;
+
+ ringacc: ringacc@3c000000 {
+ compatible = "ti,am654-navss-ringacc";
+ reg = <0x0 0x3c000000 0x0 0x400000>,
+ <0x0 0x38000000 0x0 0x400000>,
+ <0x0 0x31120000 0x0 0x100>,
+ <0x0 0x33000000 0x0 0x40000>;
+ reg-names = "rt", "fifos", "proxy_gcfg", "proxy_target";
+ ti,num-rings = <818>;
+ ti,sci-rm-range-gp-rings = <0x2>; /* GP ring range */
+ ti,dma-ring-reset-quirk;
+ ti,sci = <&dmsc>;
+ ti,sci-dev-id = <187>;
+ msi-parent = <&inta_main_udmass>;
+ };
+ };
--
2.17.1

2020-07-01 10:31:49

by Grygorii Strashko

[permalink] [raw]
Subject: [PATCH next 3/6] soc: ti: k3-ringacc: add ring's flags to dump

Add struct k3_ring *ring->flags to the ring dump.

Signed-off-by: Grygorii Strashko <[email protected]>
---
drivers/soc/ti/k3-ringacc.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c
index d2dc9c144a89..8a8f31d59e24 100644
--- a/drivers/soc/ti/k3-ringacc.c
+++ b/drivers/soc/ti/k3-ringacc.c
@@ -253,6 +253,7 @@ static void k3_ringacc_ring_dump(struct k3_ring *ring)
&ring->ring_mem_dma);
dev_dbg(dev, "dump elmsize %d, size %d, mode %d, proxy_id %d\n",
ring->elm_size, ring->size, ring->mode, ring->proxy_id);
+ dev_dbg(dev, "dump flags %08X\n", ring->flags);

dev_dbg(dev, "dump ring_rt_regs: db%08x\n", readl(&ring->rt->db));
dev_dbg(dev, "dump occ%08x\n", readl(&ring->rt->occ));
--
2.17.1

2020-07-01 10:32:02

by Grygorii Strashko

[permalink] [raw]
Subject: [PATCH next 4/6] soc: ti: k3-ringacc: add request pair of rings api.

Add new API k3_ringacc_request_rings_pair() to request pair of rings at
once, as in the most cases Rings are used with DMA channels, which need to
request pair of rings - one to feed DMA with descriptors (TX/RX FDQ) and
one to receive completions (RX/TX CQ). This will allow to simplify Ringacc
API users.

Signed-off-by: Grygorii Strashko <[email protected]>
---
drivers/soc/ti/k3-ringacc.c | 24 ++++++++++++++++++++++++
include/linux/soc/ti/k3-ringacc.h | 4 ++++
2 files changed, 28 insertions(+)

diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c
index 8a8f31d59e24..4cf1150de88e 100644
--- a/drivers/soc/ti/k3-ringacc.c
+++ b/drivers/soc/ti/k3-ringacc.c
@@ -322,6 +322,30 @@ struct k3_ring *k3_ringacc_request_ring(struct k3_ringacc *ringacc,
}
EXPORT_SYMBOL_GPL(k3_ringacc_request_ring);

+int k3_ringacc_request_rings_pair(struct k3_ringacc *ringacc,
+ int fwd_id, int compl_id,
+ struct k3_ring **fwd_ring,
+ struct k3_ring **compl_ring)
+{
+ int ret = 0;
+
+ if (!fwd_ring || !compl_ring)
+ return -EINVAL;
+
+ *fwd_ring = k3_ringacc_request_ring(ringacc, fwd_id, 0);
+ if (!(*fwd_ring))
+ return -ENODEV;
+
+ *compl_ring = k3_ringacc_request_ring(ringacc, compl_id, 0);
+ if (!(*compl_ring)) {
+ k3_ringacc_ring_free(*fwd_ring);
+ ret = -ENODEV;
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(k3_ringacc_request_rings_pair);
+
static void k3_ringacc_ring_reset_sci(struct k3_ring *ring)
{
struct k3_ringacc *ringacc = ring->parent;
diff --git a/include/linux/soc/ti/k3-ringacc.h b/include/linux/soc/ti/k3-ringacc.h
index 26f73df0a524..7ac115432fa1 100644
--- a/include/linux/soc/ti/k3-ringacc.h
+++ b/include/linux/soc/ti/k3-ringacc.h
@@ -107,6 +107,10 @@ struct k3_ringacc *of_k3_ringacc_get_by_phandle(struct device_node *np,
struct k3_ring *k3_ringacc_request_ring(struct k3_ringacc *ringacc,
int id, u32 flags);

+int k3_ringacc_request_rings_pair(struct k3_ringacc *ringacc,
+ int fwd_id, int compl_id,
+ struct k3_ring **fwd_ring,
+ struct k3_ring **compl_ring);
/**
* k3_ringacc_ring_reset - ring reset
* @ring: pointer on Ring
--
2.17.1

2020-07-01 10:32:11

by Grygorii Strashko

[permalink] [raw]
Subject: [PATCH next 5/6] soc: ti: k3-ringacc: separate soc specific initialization

Separate SoC specific initialization and and OF mach data in preparation of
adding support for more K3 SoCs

Signed-off-by: Grygorii Strashko <[email protected]>
---
drivers/soc/ti/k3-ringacc.c | 70 +++++++++++++++++++++++++++++--------
1 file changed, 55 insertions(+), 15 deletions(-)

diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c
index 4cf1150de88e..1979479db58d 100644
--- a/drivers/soc/ti/k3-ringacc.c
+++ b/drivers/soc/ti/k3-ringacc.c
@@ -161,6 +161,10 @@ struct k3_ring {
int proxy_id;
};

+struct k3_ringacc_ops {
+ int (*init)(struct platform_device *pdev, struct k3_ringacc *ringacc);
+};
+
/**
* struct k3_ringacc - Rings accelerator descriptor
*
@@ -179,6 +183,7 @@ struct k3_ring {
* @tisci: pointer ti-sci handle
* @tisci_ring_ops: ti-sci rings ops
* @tisci_dev_id: ti-sci device id
+ * @ops: SoC specific ringacc operation
*/
struct k3_ringacc {
struct device *dev;
@@ -199,6 +204,8 @@ struct k3_ringacc {
const struct ti_sci_handle *tisci;
const struct ti_sci_rm_ringacc_ops *tisci_ring_ops;
u32 tisci_dev_id;
+
+ const struct k3_ringacc_ops *ops;
};

static long k3_ringacc_ring_get_fifo_pos(struct k3_ring *ring)
@@ -1077,21 +1084,14 @@ static int k3_ringacc_probe_dt(struct k3_ringacc *ringacc)
ringacc->rm_gp_range);
}

-static int k3_ringacc_probe(struct platform_device *pdev)
+static int k3_ringacc_init(struct platform_device *pdev,
+ struct k3_ringacc *ringacc)
{
- struct k3_ringacc *ringacc;
void __iomem *base_fifo, *base_rt;
struct device *dev = &pdev->dev;
struct resource *res;
int ret, i;

- ringacc = devm_kzalloc(dev, sizeof(*ringacc), GFP_KERNEL);
- if (!ringacc)
- return -ENOMEM;
-
- ringacc->dev = dev;
- mutex_init(&ringacc->req_lock);
-
dev->msi_domain = of_msi_get_domain(dev, dev->of_node,
DOMAIN_BUS_TI_SCI_INTA_MSI);
if (!dev->msi_domain) {
@@ -1150,14 +1150,9 @@ static int k3_ringacc_probe(struct platform_device *pdev)
ringacc->rings[i].ring_id = i;
ringacc->rings[i].proxy_id = K3_RINGACC_PROXY_NOT_USED;
}
- dev_set_drvdata(dev, ringacc);

ringacc->tisci_ring_ops = &ringacc->tisci->ops.rm_ring_ops;

- mutex_lock(&k3_ringacc_list_lock);
- list_add_tail(&ringacc->list, &k3_ringacc_list);
- mutex_unlock(&k3_ringacc_list_lock);
-
dev_info(dev, "Ring Accelerator probed rings:%u, gp-rings[%u,%u] sci-dev-id:%u\n",
ringacc->num_rings,
ringacc->rm_gp_range->desc[0].start,
@@ -1167,15 +1162,60 @@ static int k3_ringacc_probe(struct platform_device *pdev)
ringacc->dma_ring_reset_quirk ? "enabled" : "disabled");
dev_info(dev, "RA Proxy rev. %08x, num_proxies:%u\n",
readl(&ringacc->proxy_gcfg->revision), ringacc->num_proxies);
+
return 0;
}

+struct ringacc_match_data {
+ struct k3_ringacc_ops ops;
+};
+
+static struct ringacc_match_data k3_ringacc_data = {
+ .ops = {
+ .init = k3_ringacc_init,
+ },
+};
+
/* Match table for of_platform binding */
static const struct of_device_id k3_ringacc_of_match[] = {
- { .compatible = "ti,am654-navss-ringacc", },
+ { .compatible = "ti,am654-navss-ringacc", .data = &k3_ringacc_data, },
{},
};

+static int k3_ringacc_probe(struct platform_device *pdev)
+{
+ const struct ringacc_match_data *match_data;
+ const struct of_device_id *match;
+ struct device *dev = &pdev->dev;
+ struct k3_ringacc *ringacc;
+ int ret;
+
+ match = of_match_node(k3_ringacc_of_match, dev->of_node);
+ if (!match)
+ return -ENODEV;
+ match_data = match->data;
+
+ ringacc = devm_kzalloc(dev, sizeof(*ringacc), GFP_KERNEL);
+ if (!ringacc)
+ return -ENOMEM;
+
+ ringacc->dev = dev;
+ mutex_init(&ringacc->req_lock);
+ ringacc->ops = &match_data->ops;
+
+ ret = ringacc->ops->init(pdev, ringacc);
+ if (ret)
+ return ret;
+
+ dev_set_drvdata(dev, ringacc);
+
+ mutex_lock(&k3_ringacc_list_lock);
+ list_add_tail(&ringacc->list, &k3_ringacc_list);
+ mutex_unlock(&k3_ringacc_list_lock);
+
+ return 0;
+}
+
static struct platform_driver k3_ringacc_driver = {
.probe = k3_ringacc_probe,
.driver = {
--
2.17.1

2020-07-01 10:32:22

by Grygorii Strashko

[permalink] [raw]
Subject: [PATCH next 6/6] dmaengine: ti: k3-udma: Switch to k3_ringacc_request_rings_pair

From: Peter Ujfalusi <[email protected]>

We only request ring pairs via K3 DMA driver, switch to use the new
k3_ringacc_request_rings_pair() to simplify the code.

Signed-off-by: Peter Ujfalusi <[email protected]>
Signed-off-by: Grygorii Strashko <[email protected]>
---
drivers/dma/ti/k3-udma-glue.c | 40 ++++++++++++-----------------------
drivers/dma/ti/k3-udma.c | 34 ++++++++++-------------------
2 files changed, 24 insertions(+), 50 deletions(-)

diff --git a/drivers/dma/ti/k3-udma-glue.c b/drivers/dma/ti/k3-udma-glue.c
index 64c8955e0cf1..67408dc3b05b 100644
--- a/drivers/dma/ti/k3-udma-glue.c
+++ b/drivers/dma/ti/k3-udma-glue.c
@@ -271,20 +271,12 @@ struct k3_udma_glue_tx_channel *k3_udma_glue_request_tx_chn(struct device *dev,
atomic_set(&tx_chn->free_pkts, cfg->txcq_cfg.size);

/* request and cfg rings */
- tx_chn->ringtx = k3_ringacc_request_ring(tx_chn->common.ringacc,
- tx_chn->udma_tchan_id, 0);
- if (!tx_chn->ringtx) {
- ret = -ENODEV;
- dev_err(dev, "Failed to get TX ring %u\n",
- tx_chn->udma_tchan_id);
- goto err;
- }
-
- tx_chn->ringtxcq = k3_ringacc_request_ring(tx_chn->common.ringacc,
- -1, 0);
- if (!tx_chn->ringtxcq) {
- ret = -ENODEV;
- dev_err(dev, "Failed to get TXCQ ring\n");
+ ret = k3_ringacc_request_rings_pair(tx_chn->common.ringacc,
+ tx_chn->udma_tchan_id, -1,
+ &tx_chn->ringtx,
+ &tx_chn->ringtxcq);
+ if (ret) {
+ dev_err(dev, "Failed to get TX/TXCQ rings %d\n", ret);
goto err;
}

@@ -587,22 +579,16 @@ static int k3_udma_glue_cfg_rx_flow(struct k3_udma_glue_rx_channel *rx_chn,
}

/* request and cfg rings */
- flow->ringrx = k3_ringacc_request_ring(rx_chn->common.ringacc,
- flow_cfg->ring_rxq_id, 0);
- if (!flow->ringrx) {
- ret = -ENODEV;
- dev_err(dev, "Failed to get RX ring\n");
+ ret = k3_ringacc_request_rings_pair(rx_chn->common.ringacc,
+ flow_cfg->ring_rxq_id,
+ flow_cfg->ring_rxfdq0_id,
+ &flow->ringrxfdq,
+ &flow->ringrx);
+ if (ret) {
+ dev_err(dev, "Failed to get RX/RXFDQ rings %d\n", ret);
goto err_rflow_put;
}

- flow->ringrxfdq = k3_ringacc_request_ring(rx_chn->common.ringacc,
- flow_cfg->ring_rxfdq0_id, 0);
- if (!flow->ringrxfdq) {
- ret = -ENODEV;
- dev_err(dev, "Failed to get RXFDQ ring\n");
- goto err_ringrx_free;
- }
-
ret = k3_ringacc_ring_cfg(flow->ringrx, &flow_cfg->rx_cfg);
if (ret) {
dev_err(dev, "Failed to cfg ringrx %d\n", ret);
diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index c91e2dc1bb72..a389aa6d260f 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -1418,17 +1418,12 @@ static int udma_alloc_tx_resources(struct udma_chan *uc)
if (ret)
return ret;

- uc->tchan->t_ring = k3_ringacc_request_ring(ud->ringacc,
- uc->tchan->id, 0);
- if (!uc->tchan->t_ring) {
- ret = -EBUSY;
- goto err_tx_ring;
- }
-
- uc->tchan->tc_ring = k3_ringacc_request_ring(ud->ringacc, -1, 0);
- if (!uc->tchan->tc_ring) {
+ ret = k3_ringacc_request_rings_pair(ud->ringacc, uc->tchan->id, -1,
+ &uc->tchan->t_ring,
+ &uc->tchan->tc_ring);
+ if (ret) {
ret = -EBUSY;
- goto err_txc_ring;
+ goto err_ring;
}

memset(&ring_cfg, 0, sizeof(ring_cfg));
@@ -1447,10 +1442,9 @@ static int udma_alloc_tx_resources(struct udma_chan *uc)
err_ringcfg:
k3_ringacc_ring_free(uc->tchan->tc_ring);
uc->tchan->tc_ring = NULL;
-err_txc_ring:
k3_ringacc_ring_free(uc->tchan->t_ring);
uc->tchan->t_ring = NULL;
-err_tx_ring:
+err_ring:
udma_put_tchan(uc);

return ret;
@@ -1499,16 +1493,11 @@ static int udma_alloc_rx_resources(struct udma_chan *uc)

rflow = uc->rflow;
fd_ring_id = ud->tchan_cnt + ud->echan_cnt + uc->rchan->id;
- rflow->fd_ring = k3_ringacc_request_ring(ud->ringacc, fd_ring_id, 0);
- if (!rflow->fd_ring) {
- ret = -EBUSY;
- goto err_rx_ring;
- }
-
- rflow->r_ring = k3_ringacc_request_ring(ud->ringacc, -1, 0);
- if (!rflow->r_ring) {
+ ret = k3_ringacc_request_rings_pair(ud->ringacc, fd_ring_id, -1,
+ &rflow->fd_ring, &rflow->r_ring);
+ if (ret) {
ret = -EBUSY;
- goto err_rxc_ring;
+ goto err_ring;
}

memset(&ring_cfg, 0, sizeof(ring_cfg));
@@ -1533,10 +1522,9 @@ static int udma_alloc_rx_resources(struct udma_chan *uc)
err_ringcfg:
k3_ringacc_ring_free(rflow->r_ring);
rflow->r_ring = NULL;
-err_rxc_ring:
k3_ringacc_ring_free(rflow->fd_ring);
rflow->fd_ring = NULL;
-err_rx_ring:
+err_ring:
udma_put_rflow(uc);
err_rflow:
udma_put_rchan(uc);
--
2.17.1

2020-07-01 11:54:39

by Peter Ujfalusi

[permalink] [raw]
Subject: Re: [PATCH next 4/6] soc: ti: k3-ringacc: add request pair of rings api.

Hi Grygorii,

On 01/07/2020 13.30, Grygorii Strashko wrote:
> Add new API k3_ringacc_request_rings_pair() to request pair of rings at
> once, as in the most cases Rings are used with DMA channels, which need to
> request pair of rings - one to feed DMA with descriptors (TX/RX FDQ) and
> one to receive completions (RX/TX CQ). This will allow to simplify Ringacc
> API users.
>
> Signed-off-by: Grygorii Strashko <[email protected]>
> ---
> drivers/soc/ti/k3-ringacc.c | 24 ++++++++++++++++++++++++
> include/linux/soc/ti/k3-ringacc.h | 4 ++++
> 2 files changed, 28 insertions(+)
>
> diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c
> index 8a8f31d59e24..4cf1150de88e 100644
> --- a/drivers/soc/ti/k3-ringacc.c
> +++ b/drivers/soc/ti/k3-ringacc.c
> @@ -322,6 +322,30 @@ struct k3_ring *k3_ringacc_request_ring(struct k3_ringacc *ringacc,
> }
> EXPORT_SYMBOL_GPL(k3_ringacc_request_ring);
>
> +int k3_ringacc_request_rings_pair(struct k3_ringacc *ringacc,
> + int fwd_id, int compl_id,
> + struct k3_ring **fwd_ring,
> + struct k3_ring **compl_ring)

Would you consider re-arranging the parameter list to:
int k3_ringacc_request_rings_pair(struct k3_ringacc *ringacc,
struct k3_ring **fwd_ring, int fwd_id,
struct k3_ring **compl_ring, int compl_id)

> +{
> + int ret = 0;
> +
> + if (!fwd_ring || !compl_ring)
> + return -EINVAL;
> +
> + *fwd_ring = k3_ringacc_request_ring(ringacc, fwd_id, 0);
> + if (!(*fwd_ring))
> + return -ENODEV;
> +
> + *compl_ring = k3_ringacc_request_ring(ringacc, compl_id, 0);
> + if (!(*compl_ring)) {
> + k3_ringacc_ring_free(*fwd_ring);
> + ret = -ENODEV;
> + }
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(k3_ringacc_request_rings_pair);
> +
> static void k3_ringacc_ring_reset_sci(struct k3_ring *ring)
> {
> struct k3_ringacc *ringacc = ring->parent;
> diff --git a/include/linux/soc/ti/k3-ringacc.h b/include/linux/soc/ti/k3-ringacc.h
> index 26f73df0a524..7ac115432fa1 100644
> --- a/include/linux/soc/ti/k3-ringacc.h
> +++ b/include/linux/soc/ti/k3-ringacc.h
> @@ -107,6 +107,10 @@ struct k3_ringacc *of_k3_ringacc_get_by_phandle(struct device_node *np,
> struct k3_ring *k3_ringacc_request_ring(struct k3_ringacc *ringacc,
> int id, u32 flags);
>
> +int k3_ringacc_request_rings_pair(struct k3_ringacc *ringacc,
> + int fwd_id, int compl_id,
> + struct k3_ring **fwd_ring,
> + struct k3_ring **compl_ring);
> /**
> * k3_ringacc_ring_reset - ring reset
> * @ring: pointer on Ring
>

- Péter

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

2020-07-01 12:14:19

by Grygorii Strashko

[permalink] [raw]
Subject: Re: [PATCH next 4/6] soc: ti: k3-ringacc: add request pair of rings api.



On 01/07/2020 14:54, Peter Ujfalusi wrote:
> Hi Grygorii,
>
> On 01/07/2020 13.30, Grygorii Strashko wrote:
>> Add new API k3_ringacc_request_rings_pair() to request pair of rings at
>> once, as in the most cases Rings are used with DMA channels, which need to
>> request pair of rings - one to feed DMA with descriptors (TX/RX FDQ) and
>> one to receive completions (RX/TX CQ). This will allow to simplify Ringacc
>> API users.
>>
>> Signed-off-by: Grygorii Strashko <[email protected]>
>> ---
>> drivers/soc/ti/k3-ringacc.c | 24 ++++++++++++++++++++++++
>> include/linux/soc/ti/k3-ringacc.h | 4 ++++
>> 2 files changed, 28 insertions(+)
>>
>> diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c
>> index 8a8f31d59e24..4cf1150de88e 100644
>> --- a/drivers/soc/ti/k3-ringacc.c
>> +++ b/drivers/soc/ti/k3-ringacc.c
>> @@ -322,6 +322,30 @@ struct k3_ring *k3_ringacc_request_ring(struct k3_ringacc *ringacc,
>> }
>> EXPORT_SYMBOL_GPL(k3_ringacc_request_ring);
>>
>> +int k3_ringacc_request_rings_pair(struct k3_ringacc *ringacc,
>> + int fwd_id, int compl_id,
>> + struct k3_ring **fwd_ring,
>> + struct k3_ring **compl_ring)
>
> Would you consider re-arranging the parameter list to:
> int k3_ringacc_request_rings_pair(struct k3_ringacc *ringacc,
> struct k3_ring **fwd_ring, int fwd_id,
> struct k3_ring **compl_ring, int compl_id)
>

i think it's more common to have input parameters first.

>> +{
>> + int ret = 0;
>> +
>> + if (!fwd_ring || !compl_ring)
>> + return -EINVAL;
>> +
>> + *fwd_ring = k3_ringacc_request_ring(ringacc, fwd_id, 0);
>> + if (!(*fwd_ring))
>> + return -ENODEV;
>> +
>> + *compl_ring = k3_ringacc_request_ring(ringacc, compl_id, 0);
>> + if (!(*compl_ring)) {
>> + k3_ringacc_ring_free(*fwd_ring);
>> + ret = -ENODEV;
>> + }
>> +
>> + return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(k3_ringacc_request_rings_pair);
>> +



--
Best regards,
grygorii

2020-07-01 12:33:51

by Peter Ujfalusi

[permalink] [raw]
Subject: Re: [PATCH next 4/6] soc: ti: k3-ringacc: add request pair of rings api.



On 01/07/2020 15.12, Grygorii Strashko wrote:
>
>
> On 01/07/2020 14:54, Peter Ujfalusi wrote:
>> Hi Grygorii,
>>
>> On 01/07/2020 13.30, Grygorii Strashko wrote:
>>> Add new API k3_ringacc_request_rings_pair() to request pair of rings at
>>> once, as in the most cases Rings are used with DMA channels, which
>>> need to
>>> request pair of rings - one to feed DMA with descriptors (TX/RX FDQ) and
>>> one to receive completions (RX/TX CQ). This will allow to simplify
>>> Ringacc
>>> API users.
>>>
>>> Signed-off-by: Grygorii Strashko <[email protected]>
>>> ---
>>>   drivers/soc/ti/k3-ringacc.c       | 24 ++++++++++++++++++++++++
>>>   include/linux/soc/ti/k3-ringacc.h |  4 ++++
>>>   2 files changed, 28 insertions(+)
>>>
>>> diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c
>>> index 8a8f31d59e24..4cf1150de88e 100644
>>> --- a/drivers/soc/ti/k3-ringacc.c
>>> +++ b/drivers/soc/ti/k3-ringacc.c
>>> @@ -322,6 +322,30 @@ struct k3_ring *k3_ringacc_request_ring(struct
>>> k3_ringacc *ringacc,
>>>   }
>>>   EXPORT_SYMBOL_GPL(k3_ringacc_request_ring);
>>>   +int k3_ringacc_request_rings_pair(struct k3_ringacc *ringacc,
>>> +                  int fwd_id, int compl_id,
>>> +                  struct k3_ring **fwd_ring,
>>> +                  struct k3_ring **compl_ring)
>>
>> Would you consider re-arranging the parameter list to:
>> int k3_ringacc_request_rings_pair(struct k3_ringacc *ringacc,
>>                   struct k3_ring **fwd_ring, int fwd_id,
>>                   struct k3_ring **compl_ring, int compl_id)
>>
>
> i think it's more common to have input parameters first.

That's true. I just like parameters grouped.
(ringacc, fwd_id, fwd_ring, compl_id, compl_ring)

having said that, I don't have objection to leave things as they are.

>
>>> +{
>>> +    int ret = 0;
>>> +
>>> +    if (!fwd_ring || !compl_ring)
>>> +        return -EINVAL;
>>> +
>>> +    *fwd_ring = k3_ringacc_request_ring(ringacc, fwd_id, 0);
>>> +    if (!(*fwd_ring))
>>> +        return -ENODEV;
>>> +
>>> +    *compl_ring = k3_ringacc_request_ring(ringacc, compl_id, 0);
>>> +    if (!(*compl_ring)) {
>>> +        k3_ringacc_ring_free(*fwd_ring);
>>> +        ret = -ENODEV;
>>> +    }
>>> +
>>> +    return ret;
>>> +}
>>> +EXPORT_SYMBOL_GPL(k3_ringacc_request_rings_pair);
>>> +
>
>
>

- Péter

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

2020-07-02 12:58:00

by Vinod Koul

[permalink] [raw]
Subject: Re: [PATCH next 6/6] dmaengine: ti: k3-udma: Switch to k3_ringacc_request_rings_pair

On 01-07-20, 13:30, Grygorii Strashko wrote:
> From: Peter Ujfalusi <[email protected]>
>
> We only request ring pairs via K3 DMA driver, switch to use the new
> k3_ringacc_request_rings_pair() to simplify the code.

Acked-By: Vinod Koul <[email protected]>

--
~Vinod

2020-07-08 08:34:44

by Peter Ujfalusi

[permalink] [raw]
Subject: Re: [PATCH next 0/6] soc: ti: k3-ringacc: updates



On 01/07/2020 13.30, Grygorii Strashko wrote:
> Hi Santosh,
>
> This series is a set of non critical updates for The TI K3 AM654x/J721E
> Ring Accelerator driver.
>
> Patch 1 - convert bindings to json-schema
> Patches 2,3,5 - code reworking
> Patch 4 - adds new API to request pair of rings k3_ringacc_request_rings_pair()
> Patch 6 - updates K3 UDMA to use new API

Reviewed-by: Peter Ujfalusi <[email protected]>

> Grygorii Strashko (4):
> dt-bindings: soc: ti: k3-ringacc: convert bindings to json-schema
> soc: ti: k3-ringacc: add ring's flags to dump
> soc: ti: k3-ringacc: add request pair of rings api.
> soc: ti: k3-ringacc: separate soc specific initialization
>
> Peter Ujfalusi (2):
> soc: ti: k3-ringacc: Move state tracking variables under a struct
> dmaengine: ti: k3-udma: Switch to k3_ringacc_request_rings_pair
>
> .../devicetree/bindings/soc/ti/k3-ringacc.txt | 59 ------
> .../bindings/soc/ti/k3-ringacc.yaml | 102 +++++++++
> drivers/dma/ti/k3-udma-glue.c | 40 ++--
> drivers/dma/ti/k3-udma.c | 34 +--
> drivers/soc/ti/k3-ringacc.c | 194 ++++++++++++------
> include/linux/soc/ti/k3-ringacc.h | 4 +
> 6 files changed, 261 insertions(+), 172 deletions(-)
> delete mode 100644 Documentation/devicetree/bindings/soc/ti/k3-ringacc.txt
> create mode 100644 Documentation/devicetree/bindings/soc/ti/k3-ringacc.yaml
>

- Péter

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

2020-07-15 09:46:52

by Grygorii Strashko

[permalink] [raw]
Subject: Re: [PATCH next 1/6] dt-bindings: soc: ti: k3-ringacc: convert bindings to json-schema

Hi Rob,

On 01/07/2020 13:30, Grygorii Strashko wrote:
> Convert the K3 NavigatorSS Ring Accelerator bindings documentation to
> json-schema.
>
> Cc: Rob Herring <[email protected]>
> Signed-off-by: Grygorii Strashko <[email protected]>
> ---
> .../devicetree/bindings/soc/ti/k3-ringacc.txt | 59 ----------
> .../bindings/soc/ti/k3-ringacc.yaml | 102 ++++++++++++++++++
> 2 files changed, 102 insertions(+), 59 deletions(-)
> delete mode 100644 Documentation/devicetree/bindings/soc/ti/k3-ringacc.txt
> create mode 100644 Documentation/devicetree/bindings/soc/ti/k3-ringacc.yaml
>
> diff --git a/Documentation/devicetree/bindings/soc/ti/k3-ringacc.txt b/Documentation/devicetree/bindings/soc/ti/k3-ringacc.txt
> deleted file mode 100644
> index 59758ccce809..000000000000
> --- a/Documentation/devicetree/bindings/soc/ti/k3-ringacc.txt
> +++ /dev/null
> @@ -1,59 +0,0 @@
> -* Texas Instruments K3 NavigatorSS Ring Accelerator
> -
> -The Ring Accelerator (RA) is a machine which converts read/write accesses
> -from/to a constant address into corresponding read/write accesses from/to a
> -circular data structure in memory. The RA eliminates the need for each DMA
> -controller which needs to access ring elements from having to know the current
> -state of the ring (base address, current offset). The DMA controller
> -performs a read or write access to a specific address range (which maps to the
> -source interface on the RA) and the RA replaces the address for the transaction
> -with a new address which corresponds to the head or tail element of the ring
> -(head for reads, tail for writes).
> -
> -The Ring Accelerator is a hardware module that is responsible for accelerating
> -management of the packet queues. The K3 SoCs can have more than one RA instances
> -
> -Required properties:
> -- compatible : Must be "ti,am654-navss-ringacc";
> -- reg : Should contain register location and length of the following
> - named register regions.
> -- reg-names : should be
> - "rt" - The RA Ring Real-time Control/Status Registers
> - "fifos" - The RA Queues Registers
> - "proxy_gcfg" - The RA Proxy Global Config Registers
> - "proxy_target" - The RA Proxy Datapath Registers
> -- ti,num-rings : Number of rings supported by RA
> -- ti,sci-rm-range-gp-rings : TI-SCI RM subtype for GP ring range
> -- ti,sci : phandle on TI-SCI compatible System controller node
> -- ti,sci-dev-id : TI-SCI device id of the ring accelerator
> -- msi-parent : phandle for "ti,sci-inta" interrupt controller
> -
> -Optional properties:
> - -- ti,dma-ring-reset-quirk : enable ringacc / udma ring state interoperability
> - issue software w/a
> -
> -Example:
> -
> -ringacc: ringacc@3c000000 {
> - compatible = "ti,am654-navss-ringacc";
> - reg = <0x0 0x3c000000 0x0 0x400000>,
> - <0x0 0x38000000 0x0 0x400000>,
> - <0x0 0x31120000 0x0 0x100>,
> - <0x0 0x33000000 0x0 0x40000>;
> - reg-names = "rt", "fifos",
> - "proxy_gcfg", "proxy_target";
> - ti,num-rings = <818>;
> - ti,sci-rm-range-gp-rings = <0x2>; /* GP ring range */
> - ti,dma-ring-reset-quirk;
> - ti,sci = <&dmsc>;
> - ti,sci-dev-id = <187>;
> - msi-parent = <&inta_main_udmass>;
> -};
> -
> -client:
> -
> -dma_ipx: dma_ipx@<addr> {
> - ...
> - ti,ringacc = <&ringacc>;
> - ...
> -}
> diff --git a/Documentation/devicetree/bindings/soc/ti/k3-ringacc.yaml b/Documentation/devicetree/bindings/soc/ti/k3-ringacc.yaml
> new file mode 100644
> index 000000000000..ae33fc957141
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/soc/ti/k3-ringacc.yaml
> @@ -0,0 +1,102 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +# Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
> +%YAML 1.2
> +---
> +$id: "http://devicetree.org/schemas/soc/ti/k3-ringacc.yaml#"
> +$schema: "http://devicetree.org/meta-schemas/core.yaml#"
> +
> +title: Texas Instruments K3 NavigatorSS Ring Accelerator
> +
> +maintainers:
> + - Santosh Shilimkar <[email protected]>
> + - Grygorii Strashko <[email protected]>
> +
> +description: |
> + The Ring Accelerator (RA) is a machine which converts read/write accesses
> + from/to a constant address into corresponding read/write accesses from/to a
> + circular data structure in memory. The RA eliminates the need for each DMA
> + controller which needs to access ring elements from having to know the current
> + state of the ring (base address, current offset). The DMA controller
> + performs a read or write access to a specific address range (which maps to the
> + source interface on the RA) and the RA replaces the address for the transaction
> + with a new address which corresponds to the head or tail element of the ring
> + (head for reads, tail for writes).
> +
> + The Ring Accelerator is a hardware module that is responsible for accelerating
> + management of the packet queues. The K3 SoCs can have more than one RA instances
> +
> +properties:
> + compatible:
> + items:
> + - const: ti,am654-navss-ringacc
> +
> + reg:
> + items:
> + - description: real time registers regions
> + - description: fifos registers regions
> + - description: proxy gcfg registers regions
> + - description: proxy target registers regions
> +
> + reg-names:
> + items:
> + - const: rt
> + - const: fifos
> + - const: proxy_gcfg
> + - const: proxy_target
> +
> + msi-parent: true
> +
> + ti,num-rings:
> + $ref: /schemas/types.yaml#/definitions/uint32
> + description: Number of rings supported by RA
> +
> + ti,sci-rm-range-gp-rings:
> + $ref: /schemas/types.yaml#/definitions/uint32
> + description: TI-SCI RM subtype for GP ring range
> +
> + ti,sci:
> + $ref: /schemas/types.yaml#definitions/phandle-array
> + description: phandle on TI-SCI compatible System controller node
> +
> + ti,sci-dev-id:
> + $ref: /schemas/types.yaml#/definitions/uint32
> + description: TI-SCI device id of the ring accelerator
> +
> + ti,dma-ring-reset-quirk:
> + $ref: /schemas/types.yaml#definitions/flag
> + description: |
> + enable ringacc/udma ring state interoperability issue software w/a
> +
> +required:
> + - compatible
> + - reg
> + - reg-names
> + - msi-parent
> + - ti,num-rings
> + - ti,sci-rm-range-gp-rings
> + - ti,sci
> + - ti,sci-dev-id
> +
> +additionalProperties: false
> +
> +examples:
> + - |
> + bus {
> + #address-cells = <2>;
> + #size-cells = <2>;
> +
> + ringacc: ringacc@3c000000 {
> + compatible = "ti,am654-navss-ringacc";
> + reg = <0x0 0x3c000000 0x0 0x400000>,
> + <0x0 0x38000000 0x0 0x400000>,
> + <0x0 0x31120000 0x0 0x100>,
> + <0x0 0x33000000 0x0 0x40000>;
> + reg-names = "rt", "fifos", "proxy_gcfg", "proxy_target";
> + ti,num-rings = <818>;
> + ti,sci-rm-range-gp-rings = <0x2>; /* GP ring range */
> + ti,dma-ring-reset-quirk;
> + ti,sci = <&dmsc>;
> + ti,sci-dev-id = <187>;
> + msi-parent = <&inta_main_udmass>;
> + };
> + };
>

I'd be very appreciated if you can provide your feedback here.

--
Best regards,
grygorii

2020-07-17 12:44:39

by Grygorii Strashko

[permalink] [raw]
Subject: Re: [PATCH next 6/6] dmaengine: ti: k3-udma: Switch to k3_ringacc_request_rings_pair



On 02/07/2020 15:57, Vinod Koul wrote:
> On 01-07-20, 13:30, Grygorii Strashko wrote:
>> From: Peter Ujfalusi <[email protected]>
>>
>> We only request ring pairs via K3 DMA driver, switch to use the new
>> k3_ringacc_request_rings_pair() to simplify the code.
>
> Acked-By: Vinod Koul <[email protected]>
>

There is build warn with this patch - sending v2.

--
Best regards,
grygorii