2020-10-08 11:57:53

by Peter Ujfalusi

[permalink] [raw]
Subject: [PATCH v2 00/11] firmware/soc: ti_sci, ringacc/inta: Preparation for AM64 DMA support

Hi,

Changes since v1:
- Use AM64X as family name in patch 11
- Added Reviewed-by tag from Grygorii for patch 6-10

The series prepares the ti_sci, ringacc, inta to support the new DMAs introduced
with AM64.

Separate series has been sent for the inta irqchip driver (v2):
https://lore.kernel.org/lkml/[email protected]/

Patches for the DMA support will be based on this series due to build and
feature dependencies.

To support the new DMSS we need to change the ti_sci ring config API in order to
be able to support the new parameters needed in the future.

We also need to add support for the second range in RM as along with the AM64
support, the resource allocation is going to change for existing SoC which used
only the first range for resource allocation.

The tx_tdtype support has been also missing from ti_sci for a long time and
the AM64 specific extended_ch_type depends on the existence of it in the message
struct.

Santosh: if you plan to take this series for 5.11, then can you create an
immutable branch which I can refer to Vinod for the DMA patches I'm going to
send soon.

Regards,
Peter
---
Peter Ujfalusi (11):
firmware: ti_sci: rm: Add support for tx_tdtype parameter for tx
channel
firmware: ti_sci: Use struct ti_sci_resource_desc in get_range ops
firmware: ti_sci: rm: Add support for second resource range
soc: ti: ti_sci_inta_msi: Add support for second range in resource
ranges
firmware: ti_sci: rm: Add support for extended_ch_type for tx channel
firmware: ti_sci: rm: Remove ring_get_config support
firmware: ti_sci: rm: Add new ops for ring configuration
soc: ti: k3-ringacc: Use the ti_sci set_cfg callback for ring
configuration
firmware: ti_sci: rm: Remove unused config() from
ti_sci_rm_ringacc_ops
soc: ti: k3-ringacc: Use correct device for allocation in RING mode
soc: ti: k3-socinfo: Add entry for AM64X SoC family

drivers/firmware/ti_sci.c | 213 ++++++++-----------------
drivers/firmware/ti_sci.h | 72 +++------
drivers/soc/ti/k3-ringacc.c | 93 +++++------
drivers/soc/ti/k3-socinfo.c | 1 +
drivers/soc/ti/ti_sci_inta_msi.c | 12 ++
include/linux/soc/ti/k3-ringacc.h | 5 +
include/linux/soc/ti/ti_sci_protocol.h | 85 ++++++----
7 files changed, 212 insertions(+), 269 deletions(-)

--
Peter

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


2020-10-08 11:59:06

by Peter Ujfalusi

[permalink] [raw]
Subject: [PATCH v2 01/11] firmware: ti_sci: rm: Add support for tx_tdtype parameter for tx channel

The system controller's resource manager have support for configuring the
TDTYPE of TCHAN_CFG register on j721e.
With this parameter the teardown completion can be controlled:
TDTYPE == 0: Return without waiting for peer to complete the teardown
TDTYPE == 1: Wait for peer to complete the teardown

Signed-off-by: Peter Ujfalusi <[email protected]>
Reviewed-by: Tero Kristo <[email protected]>
Tested-by: Keerthy <[email protected]>
Reviewed-by: Grygorii Strashko <[email protected]>
---
drivers/firmware/ti_sci.c | 1 +
drivers/firmware/ti_sci.h | 7 +++++++
include/linux/soc/ti/ti_sci_protocol.h | 2 ++
3 files changed, 10 insertions(+)

diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index 896f53ec7857..65a8c2e82093 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -2362,6 +2362,7 @@ static int ti_sci_cmd_rm_udmap_tx_ch_cfg(const struct ti_sci_handle *handle,
req->fdepth = params->fdepth;
req->tx_sched_priority = params->tx_sched_priority;
req->tx_burst_size = params->tx_burst_size;
+ req->tx_tdtype = params->tx_tdtype;

ret = ti_sci_do_xfer(info, xfer);
if (ret) {
diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h
index 57cd04062994..dca19ca5fc49 100644
--- a/drivers/firmware/ti_sci.h
+++ b/drivers/firmware/ti_sci.h
@@ -910,6 +910,7 @@ struct rm_ti_sci_msg_udmap_rx_flow_opt_cfg {
* 12 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::tx_credit_count
* 13 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::fdepth
* 14 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::tx_burst_size
+ * 15 - Valid bit for @ref ti_sci_msg_rm_udmap_tx_ch_cfg::tx_tdtype
*
* @nav_id: SoC device ID of Navigator Subsystem where tx channel is located
*
@@ -973,6 +974,11 @@ struct rm_ti_sci_msg_udmap_rx_flow_opt_cfg {
*
* @tx_burst_size: UDMAP transmit channel burst size configuration to be
* programmed into the tx_burst_size field of the TCHAN_TCFG register.
+ *
+ * @tx_tdtype: UDMAP transmit channel teardown type configuration to be
+ * programmed into the tdtype field of the TCHAN_TCFG register:
+ * 0 - Return immediately
+ * 1 - Wait for completion message from remote peer
*/
struct ti_sci_msg_rm_udmap_tx_ch_cfg_req {
struct ti_sci_msg_hdr hdr;
@@ -994,6 +1000,7 @@ struct ti_sci_msg_rm_udmap_tx_ch_cfg_req {
u16 fdepth;
u8 tx_sched_priority;
u8 tx_burst_size;
+ u8 tx_tdtype;
} __packed;

/**
diff --git a/include/linux/soc/ti/ti_sci_protocol.h b/include/linux/soc/ti/ti_sci_protocol.h
index cf27b080e148..d254d99fd45b 100644
--- a/include/linux/soc/ti/ti_sci_protocol.h
+++ b/include/linux/soc/ti/ti_sci_protocol.h
@@ -345,6 +345,7 @@ struct ti_sci_msg_rm_udmap_tx_ch_cfg {
#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_SUPR_TDPKT_VALID BIT(11)
#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_CREDIT_COUNT_VALID BIT(12)
#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_FDEPTH_VALID BIT(13)
+#define TI_SCI_MSG_VALUE_RM_UDMAP_CH_TX_TDTYPE_VALID BIT(15)
u16 nav_id;
u16 index;
u8 tx_pause_on_err;
@@ -362,6 +363,7 @@ struct ti_sci_msg_rm_udmap_tx_ch_cfg {
u16 fdepth;
u8 tx_sched_priority;
u8 tx_burst_size;
+ u8 tx_tdtype;
};

/**
--
Peter

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

2020-10-08 11:59:44

by Peter Ujfalusi

[permalink] [raw]
Subject: [PATCH v2 11/11] soc: ti: k3-socinfo: Add entry for AM64X SoC family

It's JTAG PARTNO is 0xBB38.

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

diff --git a/drivers/soc/ti/k3-socinfo.c b/drivers/soc/ti/k3-socinfo.c
index bbbc2d2b7091..fd91129de6e5 100644
--- a/drivers/soc/ti/k3-socinfo.c
+++ b/drivers/soc/ti/k3-socinfo.c
@@ -40,6 +40,7 @@ static const struct k3_soc_id {
{ 0xBB5A, "AM65X" },
{ 0xBB64, "J721E" },
{ 0xBB6D, "J7200" },
+ { 0xBB38, "AM64X" }
};

static int
--
Peter

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

2020-10-08 11:59:46

by Peter Ujfalusi

[permalink] [raw]
Subject: [PATCH v2 08/11] soc: ti: k3-ringacc: Use the ti_sci set_cfg callback for ring configuration

Switch to the new set_cfg to configure the ring.

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

diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c
index 1147dc4c1d59..9ddd77113c5a 100644
--- a/drivers/soc/ti/k3-ringacc.c
+++ b/drivers/soc/ti/k3-ringacc.c
@@ -365,20 +365,16 @@ EXPORT_SYMBOL_GPL(k3_ringacc_request_rings_pair);

static void k3_ringacc_ring_reset_sci(struct k3_ring *ring)
{
+ struct ti_sci_msg_rm_ring_cfg ring_cfg = { 0 };
struct k3_ringacc *ringacc = ring->parent;
int ret;

- ret = ringacc->tisci_ring_ops->config(
- ringacc->tisci,
- TI_SCI_MSG_VALUE_RM_RING_COUNT_VALID,
- ringacc->tisci_dev_id,
- ring->ring_id,
- 0,
- 0,
- ring->size,
- 0,
- 0,
- 0);
+ ring_cfg.nav_id = ringacc->tisci_dev_id;
+ ring_cfg.index = ring->ring_id;
+ ring_cfg.valid_params = TI_SCI_MSG_VALUE_RM_RING_COUNT_VALID;
+ ring_cfg.count = ring->size;
+
+ ret = ringacc->tisci_ring_ops->set_cfg(ringacc->tisci, &ring_cfg);
if (ret)
dev_err(ringacc->dev, "TISCI reset ring fail (%d) ring_idx %d\n",
ret, ring->ring_id);
@@ -398,20 +394,16 @@ EXPORT_SYMBOL_GPL(k3_ringacc_ring_reset);
static void k3_ringacc_ring_reconfig_qmode_sci(struct k3_ring *ring,
enum k3_ring_mode mode)
{
+ struct ti_sci_msg_rm_ring_cfg ring_cfg = { 0 };
struct k3_ringacc *ringacc = ring->parent;
int ret;

- ret = ringacc->tisci_ring_ops->config(
- ringacc->tisci,
- TI_SCI_MSG_VALUE_RM_RING_MODE_VALID,
- ringacc->tisci_dev_id,
- ring->ring_id,
- 0,
- 0,
- 0,
- mode,
- 0,
- 0);
+ ring_cfg.nav_id = ringacc->tisci_dev_id;
+ ring_cfg.index = ring->ring_id;
+ ring_cfg.valid_params = TI_SCI_MSG_VALUE_RM_RING_MODE_VALID;
+ ring_cfg.mode = mode;
+
+ ret = ringacc->tisci_ring_ops->set_cfg(ringacc->tisci, &ring_cfg);
if (ret)
dev_err(ringacc->dev, "TISCI reconf qmode fail (%d) ring_idx %d\n",
ret, ring->ring_id);
@@ -478,20 +470,15 @@ EXPORT_SYMBOL_GPL(k3_ringacc_ring_reset_dma);

static void k3_ringacc_ring_free_sci(struct k3_ring *ring)
{
+ struct ti_sci_msg_rm_ring_cfg ring_cfg = { 0 };
struct k3_ringacc *ringacc = ring->parent;
int ret;

- ret = ringacc->tisci_ring_ops->config(
- ringacc->tisci,
- TI_SCI_MSG_VALUE_RM_ALL_NO_ORDER,
- ringacc->tisci_dev_id,
- ring->ring_id,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0);
+ ring_cfg.nav_id = ringacc->tisci_dev_id;
+ ring_cfg.index = ring->ring_id;
+ ring_cfg.valid_params = TI_SCI_MSG_VALUE_RM_ALL_NO_ORDER;
+
+ ret = ringacc->tisci_ring_ops->set_cfg(ringacc->tisci, &ring_cfg);
if (ret)
dev_err(ringacc->dev, "TISCI ring free fail (%d) ring_idx %d\n",
ret, ring->ring_id);
@@ -575,28 +562,26 @@ EXPORT_SYMBOL_GPL(k3_ringacc_get_ring_irq_num);

static int k3_ringacc_ring_cfg_sci(struct k3_ring *ring)
{
+ struct ti_sci_msg_rm_ring_cfg ring_cfg = { 0 };
struct k3_ringacc *ringacc = ring->parent;
- u32 ring_idx;
int ret;

if (!ringacc->tisci)
return -EINVAL;

- ring_idx = ring->ring_id;
- ret = ringacc->tisci_ring_ops->config(
- ringacc->tisci,
- TI_SCI_MSG_VALUE_RM_ALL_NO_ORDER,
- ringacc->tisci_dev_id,
- ring_idx,
- lower_32_bits(ring->ring_mem_dma),
- upper_32_bits(ring->ring_mem_dma),
- ring->size,
- ring->mode,
- ring->elm_size,
- 0);
+ ring_cfg.nav_id = ringacc->tisci_dev_id;
+ ring_cfg.index = ring->ring_id;
+ ring_cfg.valid_params = TI_SCI_MSG_VALUE_RM_ALL_NO_ORDER;
+ ring_cfg.addr_lo = lower_32_bits(ring->ring_mem_dma);
+ ring_cfg.addr_hi = upper_32_bits(ring->ring_mem_dma);
+ ring_cfg.count = ring->size;
+ ring_cfg.mode = ring->mode;
+ ring_cfg.size = ring->elm_size;
+
+ ret = ringacc->tisci_ring_ops->set_cfg(ringacc->tisci, &ring_cfg);
if (ret)
dev_err(ringacc->dev, "TISCI config ring fail (%d) ring_idx %d\n",
- ret, ring_idx);
+ ret, ring->ring_id);

return ret;
}
--
Peter

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

2020-10-08 12:00:01

by Peter Ujfalusi

[permalink] [raw]
Subject: [PATCH v2 09/11] firmware: ti_sci: rm: Remove unused config() from ti_sci_rm_ringacc_ops

The ringacc driver has been converted to use the new set_cfg function to
configure the ring, the old config ops can be removed.

Signed-off-by: Peter Ujfalusi <[email protected]>
Reviewed-by: Grygorii Strashko <[email protected]>
---
drivers/firmware/ti_sci.c | 72 --------------------------
include/linux/soc/ti/ti_sci_protocol.h | 7 ---
2 files changed, 79 deletions(-)

diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index a4d2b318795c..235c7e7869aa 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -2048,77 +2048,6 @@ static int ti_sci_cmd_free_event_map(const struct ti_sci_handle *handle,
ia_id, vint, global_event, vint_status_bit, 0);
}

-/**
- * ti_sci_cmd_ring_config() - configure RA ring
- * @handle: Pointer to TI SCI handle.
- * @valid_params: Bitfield defining validity of ring configuration
- * parameters
- * @nav_id: Device ID of Navigator Subsystem from which the ring is
- * allocated
- * @index: Ring index
- * @addr_lo: The ring base address lo 32 bits
- * @addr_hi: The ring base address hi 32 bits
- * @count: Number of ring elements
- * @mode: The mode of the ring
- * @size: The ring element size.
- * @order_id: Specifies the ring's bus order ID
- *
- * Return: 0 if all went well, else returns appropriate error value.
- *
- * See @ti_sci_msg_rm_ring_cfg_req for more info.
- */
-static int ti_sci_cmd_ring_config(const struct ti_sci_handle *handle,
- u32 valid_params, u16 nav_id, u16 index,
- u32 addr_lo, u32 addr_hi, u32 count,
- u8 mode, u8 size, u8 order_id)
-{
- struct ti_sci_msg_rm_ring_cfg_req *req;
- struct ti_sci_msg_hdr *resp;
- struct ti_sci_xfer *xfer;
- struct ti_sci_info *info;
- struct device *dev;
- int ret = 0;
-
- if (IS_ERR_OR_NULL(handle))
- return -EINVAL;
-
- info = handle_to_ti_sci_info(handle);
- dev = info->dev;
-
- xfer = ti_sci_get_one_xfer(info, TI_SCI_MSG_RM_RING_CFG,
- TI_SCI_FLAG_REQ_ACK_ON_PROCESSED,
- sizeof(*req), sizeof(*resp));
- if (IS_ERR(xfer)) {
- ret = PTR_ERR(xfer);
- dev_err(dev, "RM_RA:Message config failed(%d)\n", ret);
- return ret;
- }
- req = (struct ti_sci_msg_rm_ring_cfg_req *)xfer->xfer_buf;
- req->valid_params = valid_params;
- req->nav_id = nav_id;
- req->index = index;
- req->addr_lo = addr_lo;
- req->addr_hi = addr_hi;
- req->count = count;
- req->mode = mode;
- req->size = size;
- req->order_id = order_id;
-
- ret = ti_sci_do_xfer(info, xfer);
- if (ret) {
- dev_err(dev, "RM_RA:Mbox config send fail %d\n", ret);
- goto fail;
- }
-
- resp = (struct ti_sci_msg_hdr *)xfer->xfer_buf;
- ret = ti_sci_is_response_ack(resp) ? 0 : -ENODEV;
-
-fail:
- ti_sci_put_one_xfer(&info->minfo, xfer);
- dev_dbg(dev, "RM_RA:config ring %u ret:%d\n", index, ret);
- return ret;
-}
-
/**
* ti_sci_cmd_rm_ring_cfg() - Configure a NAVSS ring
* @handle: Pointer to TI SCI handle.
@@ -2908,7 +2837,6 @@ static void ti_sci_setup_ops(struct ti_sci_info *info)
iops->free_irq = ti_sci_cmd_free_irq;
iops->free_event_map = ti_sci_cmd_free_event_map;

- rops->config = ti_sci_cmd_ring_config;
rops->set_cfg = ti_sci_cmd_rm_ring_cfg;

psilops->pair = ti_sci_cmd_rm_psil_pair;
diff --git a/include/linux/soc/ti/ti_sci_protocol.h b/include/linux/soc/ti/ti_sci_protocol.h
index d1711050cd9d..0aad7009b50e 100644
--- a/include/linux/soc/ti/ti_sci_protocol.h
+++ b/include/linux/soc/ti/ti_sci_protocol.h
@@ -310,16 +310,9 @@ struct ti_sci_msg_rm_ring_cfg {

/**
* struct ti_sci_rm_ringacc_ops - Ring Accelerator Management operations
- * @config: configure the SoC Navigator Subsystem Ring Accelerator ring
- * Deprecated
* @set_cfg: configure the SoC Navigator Subsystem Ring Accelerator ring
*/
struct ti_sci_rm_ringacc_ops {
- int (*config)(const struct ti_sci_handle *handle,
- u32 valid_params, u16 nav_id, u16 index,
- u32 addr_lo, u32 addr_hi, u32 count, u8 mode,
- u8 size, u8 order_id
- );
int (*set_cfg)(const struct ti_sci_handle *handle,
const struct ti_sci_msg_rm_ring_cfg *params);
};
--
Peter

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

2020-10-08 12:00:04

by Peter Ujfalusi

[permalink] [raw]
Subject: [PATCH v2 03/11] firmware: ti_sci: rm: Add support for second resource range

Sysfw added support for a second range in the resource range API to be able
to describe complex allocations mainly for DMA channels.

Update the ti_sci part to consider the second range as well.

Signed-off-by: Peter Ujfalusi <[email protected]>
---
drivers/firmware/ti_sci.c | 48 +++++++++++++++++---------
drivers/firmware/ti_sci.h | 8 +++--
include/linux/soc/ti/ti_sci_protocol.h | 8 +++--
3 files changed, 43 insertions(+), 21 deletions(-)

diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c
index 7a777e91ce3e..2793bb923881 100644
--- a/drivers/firmware/ti_sci.c
+++ b/drivers/firmware/ti_sci.c
@@ -1751,11 +1751,14 @@ static int ti_sci_get_resource_range(const struct ti_sci_handle *handle,

if (!ti_sci_is_response_ack(resp)) {
ret = -ENODEV;
- } else if (!resp->range_start && !resp->range_num) {
+ } else if (!resp->range_num && !resp->range_num_sec) {
+ /* Neither of the two resource range is valid */
ret = -ENODEV;
} else {
desc->start = resp->range_start;
desc->num = resp->range_num;
+ desc->start_sec = resp->range_start_sec;
+ desc->num_sec = resp->range_num_sec;
};

fail:
@@ -3157,12 +3160,18 @@ u16 ti_sci_get_free_resource(struct ti_sci_resource *res)

raw_spin_lock_irqsave(&res->lock, flags);
for (set = 0; set < res->sets; set++) {
- free_bit = find_first_zero_bit(res->desc[set].res_map,
- res->desc[set].num);
- if (free_bit != res->desc[set].num) {
- set_bit(free_bit, res->desc[set].res_map);
+ struct ti_sci_resource_desc *desc = &res->desc[set];
+ int res_count = desc->num + desc->num_sec;
+
+ free_bit = find_first_zero_bit(desc->res_map, res_count);
+ if (free_bit != res_count) {
+ set_bit(free_bit, desc->res_map);
raw_spin_unlock_irqrestore(&res->lock, flags);
- return res->desc[set].start + free_bit;
+
+ if (desc->num && free_bit < desc->num)
+ return desc->start + free_bit;
+ else
+ return desc->start_sec + free_bit;
}
}
raw_spin_unlock_irqrestore(&res->lock, flags);
@@ -3183,10 +3192,14 @@ void ti_sci_release_resource(struct ti_sci_resource *res, u16 id)

raw_spin_lock_irqsave(&res->lock, flags);
for (set = 0; set < res->sets; set++) {
- if (res->desc[set].start <= id &&
- (res->desc[set].num + res->desc[set].start) > id)
- clear_bit(id - res->desc[set].start,
- res->desc[set].res_map);
+ struct ti_sci_resource_desc *desc = &res->desc[set];
+
+ if (desc->num && desc->start <= id &&
+ (desc->start + desc->num) > id)
+ clear_bit(id - desc->start, desc->res_map);
+ else if (desc->num_sec && desc->start_sec <= id &&
+ (desc->start_sec + desc->num_sec) > id)
+ clear_bit(id - desc->start_sec, desc->res_map);
}
raw_spin_unlock_irqrestore(&res->lock, flags);
}
@@ -3203,7 +3216,7 @@ u32 ti_sci_get_num_resources(struct ti_sci_resource *res)
u32 set, count = 0;

for (set = 0; set < res->sets; set++)
- count += res->desc[set].num;
+ count += res->desc[set].num + res->desc[set].num_sec;

return count;
}
@@ -3227,7 +3240,7 @@ devm_ti_sci_get_resource_sets(const struct ti_sci_handle *handle,
{
struct ti_sci_resource *res;
bool valid_set = false;
- int i, ret;
+ int i, ret, res_count;

res = devm_kzalloc(dev, sizeof(*res), GFP_KERNEL);
if (!res)
@@ -3246,18 +3259,19 @@ devm_ti_sci_get_resource_sets(const struct ti_sci_handle *handle,
if (ret) {
dev_dbg(dev, "dev = %d subtype %d not allocated for this host\n",
dev_id, sub_types[i]);
- res->desc[i].start = 0;
- res->desc[i].num = 0;
+ memset(&res->desc[i], 0, sizeof(res->desc[i]));
continue;
}

- dev_dbg(dev, "dev = %d, subtype = %d, start = %d, num = %d\n",
+ dev_dbg(dev, "dev/sub_type: %d/%d, start/num: %d/%d | %d/%d\n",
dev_id, sub_types[i], res->desc[i].start,
- res->desc[i].num);
+ res->desc[i].num, res->desc[i].start_sec,
+ res->desc[i].num_sec);

valid_set = true;
+ res_count = res->desc[i].num + res->desc[i].num_sec;
res->desc[i].res_map =
- devm_kzalloc(dev, BITS_TO_LONGS(res->desc[i].num) *
+ devm_kzalloc(dev, BITS_TO_LONGS(res_count) *
sizeof(*res->desc[i].res_map), GFP_KERNEL);
if (!res->desc[i].res_map)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/firmware/ti_sci.h b/drivers/firmware/ti_sci.h
index dca19ca5fc49..4d980eb592c4 100644
--- a/drivers/firmware/ti_sci.h
+++ b/drivers/firmware/ti_sci.h
@@ -574,8 +574,10 @@ struct ti_sci_msg_req_get_resource_range {
/**
* struct ti_sci_msg_resp_get_resource_range - Response to resource get range.
* @hdr: Generic Header
- * @range_start: Start index of the resource range.
- * @range_num: Number of resources in the range.
+ * @range_start: Start index of the first resource range.
+ * @range_num: Number of resources in the first range.
+ * @range_start_sec: Start index of the second resource range.
+ * @range_num_sec: Number of resources in the second range.
*
* Response to request TI_SCI_MSG_GET_RESOURCE_RANGE.
*/
@@ -583,6 +585,8 @@ struct ti_sci_msg_resp_get_resource_range {
struct ti_sci_msg_hdr hdr;
u16 range_start;
u16 range_num;
+ u16 range_start_sec;
+ u16 range_num_sec;
} __packed;

/**
diff --git a/include/linux/soc/ti/ti_sci_protocol.h b/include/linux/soc/ti/ti_sci_protocol.h
index 6cd537db4d33..9699b260de59 100644
--- a/include/linux/soc/ti/ti_sci_protocol.h
+++ b/include/linux/soc/ti/ti_sci_protocol.h
@@ -197,13 +197,17 @@ struct ti_sci_clk_ops {

/**
* struct ti_sci_resource_desc - Description of TI SCI resource instance range.
- * @start: Start index of the resource.
- * @num: Number of resources.
+ * @start: Start index of the first resource range.
+ * @num: Number of resources in the first range.
+ * @start_sec: Start index of the second resource range.
+ * @num_sec: Number of resources in the second range.
* @res_map: Bitmap to manage the allocation of these resources.
*/
struct ti_sci_resource_desc {
u16 start;
u16 num;
+ u16 start_sec;
+ u16 num_sec;
unsigned long *res_map;
};

--
Peter

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

2020-10-08 15:49:34

by Peter Ujfalusi

[permalink] [raw]
Subject: [PATCH v2 10/11] soc: ti: k3-ringacc: Use correct device for allocation in RING mode

In RING mode the ringacc does not access the ring memory. In this access
mode the ringacc coherency does not have meaning.

If the ring is configured in RING mode, then the ringacc itself will not
access to the ring memory. Only the requester (user) of the ring is going
to read/write to the memory.
Extend the ring configuration parameters with a device pointer to be used
for DMA API when the ring is configured in RING mode.

Extending the ring configuration struct will allow per ring selection of
device to be used for allocation, thus allowing per ring coherency.

To avoid regression, fall back to use the ringacc dev in case the alloc_dev
is not provided.

Signed-off-by: Peter Ujfalusi <[email protected]>
Reviewed-by: Grygorii Strashko <[email protected]>
---
drivers/soc/ti/k3-ringacc.c | 14 +++++++++++---
include/linux/soc/ti/k3-ringacc.h | 5 +++++
2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/soc/ti/k3-ringacc.c b/drivers/soc/ti/k3-ringacc.c
index 9ddd77113c5a..7d0b4092fce8 100644
--- a/drivers/soc/ti/k3-ringacc.c
+++ b/drivers/soc/ti/k3-ringacc.c
@@ -141,6 +141,7 @@ struct k3_ring_state {
* @parent: Pointer on struct @k3_ringacc
* @use_count: Use count for shared rings
* @proxy_id: RA Ring Proxy Id (only if @K3_RINGACC_RING_USE_PROXY)
+ * @dma_dev: device to be used for DMA API (allocation, mapping)
*/
struct k3_ring {
struct k3_ring_rt_regs __iomem *rt;
@@ -160,6 +161,7 @@ struct k3_ring {
struct k3_ringacc *parent;
u32 use_count;
int proxy_id;
+ struct device *dma_dev;
};

struct k3_ringacc_ops {
@@ -508,11 +510,12 @@ int k3_ringacc_ring_free(struct k3_ring *ring)

k3_ringacc_ring_free_sci(ring);

- dma_free_coherent(ringacc->dev,
+ dma_free_coherent(ring->dma_dev,
ring->size * (4 << ring->elm_size),
ring->ring_mem_virt, ring->ring_mem_dma);
ring->flags = 0;
ring->ops = NULL;
+ ring->dma_dev = NULL;
if (ring->proxy_id != K3_RINGACC_PROXY_NOT_USED) {
clear_bit(ring->proxy_id, ringacc->proxy_inuse);
ring->proxy = NULL;
@@ -633,8 +636,12 @@ int k3_ringacc_ring_cfg(struct k3_ring *ring, struct k3_ring_cfg *cfg)
switch (ring->mode) {
case K3_RINGACC_RING_MODE_RING:
ring->ops = &k3_ring_mode_ring_ops;
+ ring->dma_dev = cfg->dma_dev;
+ if (!ring->dma_dev)
+ ring->dma_dev = ringacc->dev;
break;
case K3_RINGACC_RING_MODE_MESSAGE:
+ ring->dma_dev = ringacc->dev;
if (ring->proxy)
ring->ops = &k3_ring_mode_proxy_ops;
else
@@ -646,7 +653,7 @@ int k3_ringacc_ring_cfg(struct k3_ring *ring, struct k3_ring_cfg *cfg)
goto err_free_proxy;
}

- ring->ring_mem_virt = dma_alloc_coherent(ringacc->dev,
+ ring->ring_mem_virt = dma_alloc_coherent(ring->dma_dev,
ring->size * (4 << ring->elm_size),
&ring->ring_mem_dma, GFP_KERNEL);
if (!ring->ring_mem_virt) {
@@ -669,12 +676,13 @@ int k3_ringacc_ring_cfg(struct k3_ring *ring, struct k3_ring_cfg *cfg)
return 0;

err_free_mem:
- dma_free_coherent(ringacc->dev,
+ dma_free_coherent(ring->dma_dev,
ring->size * (4 << ring->elm_size),
ring->ring_mem_virt,
ring->ring_mem_dma);
err_free_ops:
ring->ops = NULL;
+ ring->dma_dev = NULL;
err_free_proxy:
ring->proxy = NULL;
return ret;
diff --git a/include/linux/soc/ti/k3-ringacc.h b/include/linux/soc/ti/k3-ringacc.h
index 5a472eca5ee4..658dc71d2901 100644
--- a/include/linux/soc/ti/k3-ringacc.h
+++ b/include/linux/soc/ti/k3-ringacc.h
@@ -67,6 +67,9 @@ struct k3_ring;
* few times. It's usable when the same ring is used as Free Host PD ring
* for different flows, for example.
* Note: Locking should be done by consumer if required
+ * @dma_dev: Master device which is using and accessing to the ring
+ * memory when the mode is K3_RINGACC_RING_MODE_RING. Memory allocations
+ * should be done using this device.
*/
struct k3_ring_cfg {
u32 size;
@@ -74,6 +77,8 @@ struct k3_ring_cfg {
enum k3_ring_mode mode;
#define K3_RINGACC_RING_SHARED BIT(1)
u32 flags;
+
+ struct device *dma_dev;
};

#define K3_RINGACC_RING_ID_ANY (-1)
--
Peter

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

2020-10-09 01:07:51

by Santosh Shilimkar

[permalink] [raw]
Subject: Re: [PATCH v2 00/11] firmware/soc: ti_sci, ringacc/inta: Preparation for AM64 DMA support

On 10/8/20 4:52 AM, Peter Ujfalusi wrote:
> Santosh: if you plan to take this series for 5.11, then can you create an
> immutable branch which I can refer to Vinod for the DMA patches I'm going to
> send soon.

I will set it up right after the 5.10-rc1 is tagged.

regards,
Santosh

2020-10-09 03:27:00

by Santosh Shilimkar

[permalink] [raw]
Subject: Re: [PATCH v2 00/11] firmware/soc: ti_sci, ringacc/inta: Preparation for AM64 DMA support

On 10/8/20 4:52 AM, Peter Ujfalusi wrote:
> Santosh: if you plan to take this series for 5.11, then can you create an
> immutable branch which I can refer to Vinod for the DMA patches I'm going to
> send soon.

I will set it up right after the 5.10-rc1 is tagged.

regards,
Santosh

2020-10-09 04:15:25

by Nishanth Menon

[permalink] [raw]
Subject: Re: [PATCH v2 10/11] soc: ti: k3-ringacc: Use correct device for allocation in RING mode

On 14:52-20201008, Peter Ujfalusi wrote:
> - ring->ring_mem_virt = dma_alloc_coherent(ringacc->dev,
> + ring->ring_mem_virt = dma_alloc_coherent(ring->dma_dev,
> ring->size * (4 << ring->elm_size),
> &ring->ring_mem_dma, GFP_KERNEL);

Any chance of getting a cleanup of the file for 5.11? I know this series
has'nt introduced this warning or set of warnings, but I am starting to
get concerned that we are carrying over too much of a debt now?

https://pastebin.ubuntu.com/p/tT2kPDsCWD/

Checkpatch does point this:

--- /tmp/kernel-patch-verify.25812/ptest_check-start 2020-10-08
19:33:31.025898581 +0000
+++ /tmp/kernel-patch-verify.25812/ptest_check-end 2020-10-08
19:33:31.593893830 +0000
@@ -0,0 +1,6 @@
+CHECK: Alignment should match open parenthesis
+#84: FILE: drivers/soc/ti/k3-ringacc.c:657:
++ ring->ring_mem_virt = dma_alloc_coherent(ring->dma_dev,
+ ring->size * (4 << ring->elm_size),

--
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D

2020-10-09 07:45:18

by Peter Ujfalusi

[permalink] [raw]
Subject: Re: [PATCH v2 10/11] soc: ti: k3-ringacc: Use correct device for allocation in RING mode

Nishanth,

On 09/10/2020 6.02, Nishanth Menon wrote:
> On 14:52-20201008, Peter Ujfalusi wrote:
>> - ring->ring_mem_virt = dma_alloc_coherent(ringacc->dev,
>> + ring->ring_mem_virt = dma_alloc_coherent(ring->dma_dev,
>> ring->size * (4 << ring->elm_size),
>> &ring->ring_mem_dma, GFP_KERNEL);
>
> Any chance of getting a cleanup of the file for 5.11? I know this series
> has'nt introduced this warning or set of warnings, but I am starting to
> get concerned that we are carrying over too much of a debt now?
>
> https://pastebin.ubuntu.com/p/tT2kPDsCWD/

Right, you know that git blame points the finger at you on ti_sci.c errors?

Never the less, I have run the tool locally on my linux-next-wip with
these patches:
https://pastebin.ubuntu.com/p/myJwjvKYw8/

and I don't see the noise you see.

> Checkpatch does point this:
>
> --- /tmp/kernel-patch-verify.25812/ptest_check-start 2020-10-08
> 19:33:31.025898581 +0000
> +++ /tmp/kernel-patch-verify.25812/ptest_check-end 2020-10-08
> 19:33:31.593893830 +0000
> @@ -0,0 +1,6 @@
> +CHECK: Alignment should match open parenthesis
> +#84: FILE: drivers/soc/ti/k3-ringacc.c:657:
> ++ ring->ring_mem_virt = dma_alloc_coherent(ring->dma_dev,
> + ring->size * (4 << ring->elm_size),

Yes, that's correct. Readability VS very long lines

- Péter

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

2020-10-09 08:10:37

by Peter Ujfalusi

[permalink] [raw]
Subject: Re: [PATCH v2 00/11] firmware/soc: ti_sci, ringacc/inta: Preparation for AM64 DMA support



On 09/10/2020 3.56, [email protected] wrote:
> On 10/8/20 4:52 AM, Peter Ujfalusi wrote:
>> Santosh: if you plan to take this series for 5.11, then can you create an
>> immutable branch which I can refer to Vinod for the DMA patches I'm
>> going to
>> send soon.
>
> I will set it up right after the 5.10-rc1 is tagged.

Thank you!

>
> regards,
> Santosh

- Péter

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

2020-10-09 18:34:40

by Nishanth Menon

[permalink] [raw]
Subject: Re: [PATCH v2 10/11] soc: ti: k3-ringacc: Use correct device for allocation in RING mode

On 10:43-20201009, Peter Ujfalusi wrote:
> Nishanth,
>
> On 09/10/2020 6.02, Nishanth Menon wrote:
> > On 14:52-20201008, Peter Ujfalusi wrote:
> >> - ring->ring_mem_virt = dma_alloc_coherent(ringacc->dev,
> >> + ring->ring_mem_virt = dma_alloc_coherent(ring->dma_dev,
> >> ring->size * (4 << ring->elm_size),
> >> &ring->ring_mem_dma, GFP_KERNEL);
> >
> > Any chance of getting a cleanup of the file for 5.11? I know this series
> > has'nt introduced this warning or set of warnings, but I am starting to
> > get concerned that we are carrying over too much of a debt now?
> >
> > https://pastebin.ubuntu.com/p/tT2kPDsCWD/
>
> Right, you know that git blame points the finger at you on ti_sci.c errors?
>
> Never the less, I have run the tool locally on my linux-next-wip with
> these patches:
> https://pastebin.ubuntu.com/p/myJwjvKYw8/
>
> and I don't see the noise you see.


Hmm.. Looks like gcc9/10 make W=2 does generate those warnings with
container_of .. I will investigate it later today.. just checking to see
if it is just me seeing this..

Yes, I introduced the container_of() usage, which is pretty standard
usage in other subsystems as well, but lots of checks have gotten
stricter and catches new issues since I introduced things in 2016..
Time to get the new issues (if valid) fixed up.

>
> > Checkpatch does point this:
> >
> > --- /tmp/kernel-patch-verify.25812/ptest_check-start 2020-10-08
> > 19:33:31.025898581 +0000
> > +++ /tmp/kernel-patch-verify.25812/ptest_check-end 2020-10-08
> > 19:33:31.593893830 +0000
> > @@ -0,0 +1,6 @@
> > +CHECK: Alignment should match open parenthesis
> > +#84: FILE: drivers/soc/ti/k3-ringacc.c:657:
> > ++ ring->ring_mem_virt = dma_alloc_coherent(ring->dma_dev,
> > + ring->size * (4 << ring->elm_size),
>
> Yes, that's correct. Readability VS very long lines


checkpatch limit in linux kernel is now 100 chars (I know, it is
hard to update .vimrc etc.. to the new norm..)but, anyways.. will
be good not to see such warnings esp when you are touching the same
lines.

--
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D

2020-10-09 18:35:03

by Peter Ujfalusi

[permalink] [raw]
Subject: Re: [PATCH v2 10/11] soc: ti: k3-ringacc: Use correct device for allocation in RING mode



On 09/10/2020 14.59, Nishanth Menon wrote:
> On 10:43-20201009, Peter Ujfalusi wrote:
>> Nishanth,
>>
>> On 09/10/2020 6.02, Nishanth Menon wrote:
>>> On 14:52-20201008, Peter Ujfalusi wrote:
>>>> - ring->ring_mem_virt = dma_alloc_coherent(ringacc->dev,
>>>> + ring->ring_mem_virt = dma_alloc_coherent(ring->dma_dev,
>>>> ring->size * (4 << ring->elm_size),
>>>> &ring->ring_mem_dma, GFP_KERNEL);
>>>
>>> Any chance of getting a cleanup of the file for 5.11? I know this series
>>> has'nt introduced this warning or set of warnings, but I am starting to
>>> get concerned that we are carrying over too much of a debt now?
>>>
>>> https://pastebin.ubuntu.com/p/tT2kPDsCWD/
>>
>> Right, you know that git blame points the finger at you on ti_sci.c errors?
>>
>> Never the less, I have run the tool locally on my linux-next-wip with
>> these patches:
>> https://pastebin.ubuntu.com/p/myJwjvKYw8/
>>
>> and I don't see the noise you see.
>
>
> Hmm.. Looks like gcc9/10 make W=2 does generate those warnings with
> container_of .. I will investigate it later today.. just checking to see
> if it is just me seeing this..

It looks that way. W=2 is a kind of noisy if you throw it at a random
file, like:
make kernel/exec_domain.o W=2

> Yes, I introduced the container_of() usage, which is pretty standard
> usage in other subsystems as well, but lots of checks have gotten
> stricter and catches new issues since I introduced things in 2016..
> Time to get the new issues (if valid) fixed up.
>
>>
>>> Checkpatch does point this:
>>>
>>> --- /tmp/kernel-patch-verify.25812/ptest_check-start 2020-10-08
>>> 19:33:31.025898581 +0000
>>> +++ /tmp/kernel-patch-verify.25812/ptest_check-end 2020-10-08
>>> 19:33:31.593893830 +0000
>>> @@ -0,0 +1,6 @@
>>> +CHECK: Alignment should match open parenthesis
>>> +#84: FILE: drivers/soc/ti/k3-ringacc.c:657:
>>> ++ ring->ring_mem_virt = dma_alloc_coherent(ring->dma_dev,
>>> + ring->size * (4 << ring->elm_size),
>>
>> Yes, that's correct. Readability VS very long lines
>
>
> checkpatch limit in linux kernel is now 100 chars (I know, it is
> hard to update .vimrc etc.. to the new norm..)but, anyways.. will
> be good not to see such warnings esp when you are touching the same
> lines.

Right, I can send v3 on Monday after a bit of re-adjustment of my editors ;)

- Péter

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

2020-11-02 03:47:12

by Santosh Shilimkar

[permalink] [raw]
Subject: Re: [PATCH v2 00/11] firmware/soc: ti_sci, ringacc/inta: Preparation for AM64 DMA support

Hi Peter,

On 10/8/20 5:56 PM, [email protected] wrote:
> On 10/8/20 4:52 AM, Peter Ujfalusi wrote:
>> Santosh: if you plan to take this series for 5.11, then can you create an
>> immutable branch which I can refer to Vinod for the DMA patches I'm
>> going to
>> send soon.
>
> I will set it up right after the 5.10-rc1 is tagged.
>
Series is pushed to soc branch.

git://git.kernel.org/pub/scm/linux/kernel/git/ssantosh/linux-keystone.git
for_5.11/drivers-soc
Regards,
Santosh