diff mbox series

coresight: core: Add coresight name support

Message ID 20230208110716.18321-1-quic_jinlmao@quicinc.com (mailing list archive)
State New, archived
Headers show
Series coresight: core: Add coresight name support | expand

Commit Message

Mao Jinlong Feb. 8, 2023, 11:07 a.m. UTC
Apart from STM and ETM sources, there will be more sources added to
coresight components. For example, there are over 10 TPDM sources.
Add coresight name support for custom names which will be
easy to identify the source.

Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
---
 drivers/hwtracing/coresight/coresight-core.c | 34 +++++++++++---------
 1 file changed, 19 insertions(+), 15 deletions(-)

Comments

Suzuki K Poulose Feb. 8, 2023, 2:26 p.m. UTC | #1
On 08/02/2023 11:07, Mao Jinlong wrote:
> Apart from STM and ETM sources, there will be more sources added to
> coresight components. For example, there are over 10 TPDM sources.
> Add coresight name support for custom names which will be
> easy to identify the source.
> 

As we have previously discussed, please don't make this a generic
code change. If your device has a "specifici" name, use that for
allocating in the driver and leave the core code alone.

Suzuki


> Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
> ---
>   drivers/hwtracing/coresight/coresight-core.c | 34 +++++++++++---------
>   1 file changed, 19 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
> index d3bf82c0de1d..5e95d9c7f256 100644
> --- a/drivers/hwtracing/coresight/coresight-core.c
> +++ b/drivers/hwtracing/coresight/coresight-core.c
> @@ -1733,28 +1733,32 @@ char *coresight_alloc_device_name(struct coresight_dev_list *dict,
>   {
>   	int idx;
>   	char *name = NULL;
> +	const char *coresight_name = NULL;
>   	struct fwnode_handle **list;
> +	struct device_node *node = dev->of_node;
>   
>   	mutex_lock(&coresight_mutex);
>   
> -	idx = coresight_search_device_idx(dict, dev_fwnode(dev));
> -	if (idx < 0) {
> -		/* Make space for the new entry */
> -		idx = dict->nr_idx;
> -		list = krealloc_array(dict->fwnode_list,
> -				      idx + 1, sizeof(*dict->fwnode_list),
> -				      GFP_KERNEL);
> -		if (ZERO_OR_NULL_PTR(list)) {
> -			idx = -ENOMEM;
> -			goto done;
> +	if (!of_property_read_string(node, "coresight-name", &coresight_name))
> +		name = devm_kasprintf(dev, GFP_KERNEL, "%s", coresight_name);
> +	else {
> +		idx = coresight_search_device_idx(dict, dev_fwnode(dev));
> +		if (idx < 0) {
> +			/* Make space for the new entry */
> +			idx = dict->nr_idx;
> +			list = krealloc_array(dict->fwnode_list,
> +					      idx + 1, sizeof(*dict->fwnode_list),
> +					      GFP_KERNEL);
> +			if (ZERO_OR_NULL_PTR(list))
> +				goto done;
> +
> +			list[idx] = dev_fwnode(dev);
> +			dict->fwnode_list = list;
> +			dict->nr_idx = idx + 1;
>   		}
>   
> -		list[idx] = dev_fwnode(dev);
> -		dict->fwnode_list = list;
> -		dict->nr_idx = idx + 1;
> +		name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, idx);
>   	}
> -
> -	name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, idx);
>   done:
>   	mutex_unlock(&coresight_mutex);
>   	return name;
Mao Jinlong Feb. 9, 2023, 2:16 a.m. UTC | #2
On 2/8/2023 10:26 PM, Suzuki K Poulose wrote:
> On 08/02/2023 11:07, Mao Jinlong wrote:
>> Apart from STM and ETM sources, there will be more sources added to
>> coresight components. For example, there are over 10 TPDM sources.
>> Add coresight name support for custom names which will be
>> easy to identify the source.
>>
>
> As we have previously discussed, please don't make this a generic
> code change. If your device has a "specifici" name, use that for
> allocating in the driver and leave the core code alone.
>
> Suzuki
>
Hi Suzuki,

Not only for TPDMs. There could be dozens of CTI devices.
It is hard for user to know which CTI device it is with current names.

Thanks
Jinlong Mao
>
>> Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
>> ---
>>   drivers/hwtracing/coresight/coresight-core.c | 34 +++++++++++---------
>>   1 file changed, 19 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/hwtracing/coresight/coresight-core.c 
>> b/drivers/hwtracing/coresight/coresight-core.c
>> index d3bf82c0de1d..5e95d9c7f256 100644
>> --- a/drivers/hwtracing/coresight/coresight-core.c
>> +++ b/drivers/hwtracing/coresight/coresight-core.c
>> @@ -1733,28 +1733,32 @@ char *coresight_alloc_device_name(struct 
>> coresight_dev_list *dict,
>>   {
>>       int idx;
>>       char *name = NULL;
>> +    const char *coresight_name = NULL;
>>       struct fwnode_handle **list;
>> +    struct device_node *node = dev->of_node;
>>         mutex_lock(&coresight_mutex);
>>   -    idx = coresight_search_device_idx(dict, dev_fwnode(dev));
>> -    if (idx < 0) {
>> -        /* Make space for the new entry */
>> -        idx = dict->nr_idx;
>> -        list = krealloc_array(dict->fwnode_list,
>> -                      idx + 1, sizeof(*dict->fwnode_list),
>> -                      GFP_KERNEL);
>> -        if (ZERO_OR_NULL_PTR(list)) {
>> -            idx = -ENOMEM;
>> -            goto done;
>> +    if (!of_property_read_string(node, "coresight-name", 
>> &coresight_name))
>> +        name = devm_kasprintf(dev, GFP_KERNEL, "%s", coresight_name);
>> +    else {
>> +        idx = coresight_search_device_idx(dict, dev_fwnode(dev));
>> +        if (idx < 0) {
>> +            /* Make space for the new entry */
>> +            idx = dict->nr_idx;
>> +            list = krealloc_array(dict->fwnode_list,
>> +                          idx + 1, sizeof(*dict->fwnode_list),
>> +                          GFP_KERNEL);
>> +            if (ZERO_OR_NULL_PTR(list))
>> +                goto done;
>> +
>> +            list[idx] = dev_fwnode(dev);
>> +            dict->fwnode_list = list;
>> +            dict->nr_idx = idx + 1;
>>           }
>>   -        list[idx] = dev_fwnode(dev);
>> -        dict->fwnode_list = list;
>> -        dict->nr_idx = idx + 1;
>> +        name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, idx);
>>       }
>> -
>> -    name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, idx);
>>   done:
>>       mutex_unlock(&coresight_mutex);
>>       return name;
>
Mao Jinlong March 1, 2023, 3:11 p.m. UTC | #3
Hi Suzuki,

On 2/9/2023 10:16 AM, Jinlong Mao wrote:
>
> On 2/8/2023 10:26 PM, Suzuki K Poulose wrote:
>> On 08/02/2023 11:07, Mao Jinlong wrote:
>>> Apart from STM and ETM sources, there will be more sources added to
>>> coresight components. For example, there are over 10 TPDM sources.
>>> Add coresight name support for custom names which will be
>>> easy to identify the source.
>>>
>>
>> As we have previously discussed, please don't make this a generic
>> code change. If your device has a "specifici" name, use that for
>> allocating in the driver and leave the core code alone.
>>
>> Suzuki
>>
> Hi Suzuki,
>
> Not only for TPDMs. There could be dozens of CTI devices.
> It is hard for user to know which CTI device it is with current names.
>
> Thanks
> Jinlong Mao

The coresight name support is applicable to CTI and TPDM devices.
This is a generic change for the source which has dozens of devices.

Thanks
Jinlong Mao

>>
>>> Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
>>> ---
>>>   drivers/hwtracing/coresight/coresight-core.c | 34 
>>> +++++++++++---------
>>>   1 file changed, 19 insertions(+), 15 deletions(-)
>>>
>>> diff --git a/drivers/hwtracing/coresight/coresight-core.c 
>>> b/drivers/hwtracing/coresight/coresight-core.c
>>> index d3bf82c0de1d..5e95d9c7f256 100644
>>> --- a/drivers/hwtracing/coresight/coresight-core.c
>>> +++ b/drivers/hwtracing/coresight/coresight-core.c
>>> @@ -1733,28 +1733,32 @@ char *coresight_alloc_device_name(struct 
>>> coresight_dev_list *dict,
>>>   {
>>>       int idx;
>>>       char *name = NULL;
>>> +    const char *coresight_name = NULL;
>>>       struct fwnode_handle **list;
>>> +    struct device_node *node = dev->of_node;
>>>         mutex_lock(&coresight_mutex);
>>>   -    idx = coresight_search_device_idx(dict, dev_fwnode(dev));
>>> -    if (idx < 0) {
>>> -        /* Make space for the new entry */
>>> -        idx = dict->nr_idx;
>>> -        list = krealloc_array(dict->fwnode_list,
>>> -                      idx + 1, sizeof(*dict->fwnode_list),
>>> -                      GFP_KERNEL);
>>> -        if (ZERO_OR_NULL_PTR(list)) {
>>> -            idx = -ENOMEM;
>>> -            goto done;
>>> +    if (!of_property_read_string(node, "coresight-name", 
>>> &coresight_name))
>>> +        name = devm_kasprintf(dev, GFP_KERNEL, "%s", coresight_name);
>>> +    else {
>>> +        idx = coresight_search_device_idx(dict, dev_fwnode(dev));
>>> +        if (idx < 0) {
>>> +            /* Make space for the new entry */
>>> +            idx = dict->nr_idx;
>>> +            list = krealloc_array(dict->fwnode_list,
>>> +                          idx + 1, sizeof(*dict->fwnode_list),
>>> +                          GFP_KERNEL);
>>> +            if (ZERO_OR_NULL_PTR(list))
>>> +                goto done;
>>> +
>>> +            list[idx] = dev_fwnode(dev);
>>> +            dict->fwnode_list = list;
>>> +            dict->nr_idx = idx + 1;
>>>           }
>>>   -        list[idx] = dev_fwnode(dev);
>>> -        dict->fwnode_list = list;
>>> -        dict->nr_idx = idx + 1;
>>> +        name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, 
>>> idx);
>>>       }
>>> -
>>> -    name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, idx);
>>>   done:
>>>       mutex_unlock(&coresight_mutex);
>>>       return name;
>>
> _______________________________________________
> CoreSight mailing list -- coresight@lists.linaro.org
> To unsubscribe send an email to coresight-leave@lists.linaro.org
Suzuki K Poulose March 13, 2023, 9:16 a.m. UTC | #4
Cc: Rob

On 01/03/2023 15:11, Jinlong Mao wrote:
> Hi Suzuki,
> 
> On 2/9/2023 10:16 AM, Jinlong Mao wrote:
>>
>> On 2/8/2023 10:26 PM, Suzuki K Poulose wrote:
>>> On 08/02/2023 11:07, Mao Jinlong wrote:
>>>> Apart from STM and ETM sources, there will be more sources added to
>>>> coresight components. For example, there are over 10 TPDM sources.
>>>> Add coresight name support for custom names which will be
>>>> easy to identify the source.
>>>>
>>>
>>> As we have previously discussed, please don't make this a generic
>>> code change. If your device has a "specifici" name, use that for
>>> allocating in the driver and leave the core code alone.
>>>
>>> Suzuki
>>>
>> Hi Suzuki,
>>
>> Not only for TPDMs. There could be dozens of CTI devices.
>> It is hard for user to know which CTI device it is with current names.
>>
>> Thanks
>> Jinlong Mao
> 
> The coresight name support is applicable to CTI and TPDM devices.
> This is a generic change for the source which has dozens of devices.

I took a look at the CTI situation and I agree that the situation
is a bit tricky. The CTI could be connected to multiple devices,
some of them may not be even CoreSight devices. Given there could
be numerous of them, we need some way to make the "devices" naming
a bit more intuitive.

Before we go ahead and add something specific to coresight, I would
like to see if there is a generic property. Ideally, the "labels"
in the DTS sources would have been an ideal choice, but can't
see how that is available in the FDT.

Suzuki


> 
> Thanks
> Jinlong Mao
> 
>>>
>>>> Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
>>>> ---
>>>>   drivers/hwtracing/coresight/coresight-core.c | 34 
>>>> +++++++++++---------
>>>>   1 file changed, 19 insertions(+), 15 deletions(-)
>>>>
>>>> diff --git a/drivers/hwtracing/coresight/coresight-core.c 
>>>> b/drivers/hwtracing/coresight/coresight-core.c
>>>> index d3bf82c0de1d..5e95d9c7f256 100644
>>>> --- a/drivers/hwtracing/coresight/coresight-core.c
>>>> +++ b/drivers/hwtracing/coresight/coresight-core.c
>>>> @@ -1733,28 +1733,32 @@ char *coresight_alloc_device_name(struct 
>>>> coresight_dev_list *dict,
>>>>   {
>>>>       int idx;
>>>>       char *name = NULL;
>>>> +    const char *coresight_name = NULL;
>>>>       struct fwnode_handle **list;
>>>> +    struct device_node *node = dev->of_node;
>>>>         mutex_lock(&coresight_mutex);
>>>>   -    idx = coresight_search_device_idx(dict, dev_fwnode(dev));
>>>> -    if (idx < 0) {
>>>> -        /* Make space for the new entry */
>>>> -        idx = dict->nr_idx;
>>>> -        list = krealloc_array(dict->fwnode_list,
>>>> -                      idx + 1, sizeof(*dict->fwnode_list),
>>>> -                      GFP_KERNEL);
>>>> -        if (ZERO_OR_NULL_PTR(list)) {
>>>> -            idx = -ENOMEM;
>>>> -            goto done;
>>>> +    if (!of_property_read_string(node, "coresight-name", 
>>>> &coresight_name))
>>>> +        name = devm_kasprintf(dev, GFP_KERNEL, "%s", coresight_name);
>>>> +    else {
>>>> +        idx = coresight_search_device_idx(dict, dev_fwnode(dev));
>>>> +        if (idx < 0) {
>>>> +            /* Make space for the new entry */
>>>> +            idx = dict->nr_idx;
>>>> +            list = krealloc_array(dict->fwnode_list,
>>>> +                          idx + 1, sizeof(*dict->fwnode_list),
>>>> +                          GFP_KERNEL);
>>>> +            if (ZERO_OR_NULL_PTR(list))
>>>> +                goto done;
>>>> +
>>>> +            list[idx] = dev_fwnode(dev);
>>>> +            dict->fwnode_list = list;
>>>> +            dict->nr_idx = idx + 1;
>>>>           }
>>>>   -        list[idx] = dev_fwnode(dev);
>>>> -        dict->fwnode_list = list;
>>>> -        dict->nr_idx = idx + 1;
>>>> +        name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, 
>>>> idx);
>>>>       }
>>>> -
>>>> -    name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, idx);
>>>>   done:
>>>>       mutex_unlock(&coresight_mutex);
>>>>       return name;
>>>
>> _______________________________________________
>> CoreSight mailing list -- coresight@lists.linaro.org
>> To unsubscribe send an email to coresight-leave@lists.linaro.org
Suzuki K Poulose March 17, 2023, 2:25 p.m. UTC | #5
On 17/03/2023 05:34, Jinlong Mao wrote:
> 
> On 3/13/2023 5:16 PM, Suzuki K Poulose wrote:
>> Cc: Rob
>>
>> On 01/03/2023 15:11, Jinlong Mao wrote:
>>> Hi Suzuki,
>>>
>>> On 2/9/2023 10:16 AM, Jinlong Mao wrote:
>>>>
>>>> On 2/8/2023 10:26 PM, Suzuki K Poulose wrote:
>>>>> On 08/02/2023 11:07, Mao Jinlong wrote:
>>>>>> Apart from STM and ETM sources, there will be more sources added to
>>>>>> coresight components. For example, there are over 10 TPDM sources.
>>>>>> Add coresight name support for custom names which will be
>>>>>> easy to identify the source.
>>>>>>
>>>>>
>>>>> As we have previously discussed, please don't make this a generic
>>>>> code change. If your device has a "specifici" name, use that for
>>>>> allocating in the driver and leave the core code alone.
>>>>>
>>>>> Suzuki
>>>>>
>>>> Hi Suzuki,
>>>>
>>>> Not only for TPDMs. There could be dozens of CTI devices.
>>>> It is hard for user to know which CTI device it is with current names.
>>>>
>>>> Thanks
>>>> Jinlong Mao
>>>
>>> The coresight name support is applicable to CTI and TPDM devices.
>>> This is a generic change for the source which has dozens of devices.
>>
>> I took a look at the CTI situation and I agree that the situation
>> is a bit tricky. The CTI could be connected to multiple devices,
>> some of them may not be even CoreSight devices. Given there could
>> be numerous of them, we need some way to make the "devices" naming
>> a bit more intuitive.
>>
>> Before we go ahead and add something specific to coresight, I would
>> like to see if there is a generic property. Ideally, the "labels"
>> in the DTS sources would have been an ideal choice, but can't
>> see how that is available in the FDT.
>>
>> Suzuki
> Hi Suzuki,
> 
> Shall we use the full_name of device_node struct as coresight 
> component's name ?
> 
>    struct device_node {
>      const char *name;
>      phandle phandle;
> *    const char *full_name;
> 
> *For component below, the full_name will be "coresight-tpdm-ipcc".
> *
> **coresight-tpdm-ipcc* {

Does that go against the convention of naming the DT nodes ?
I am not sure. Also, we would need a way to solve this for ACPI too.

Suzuki


>      compatible = "qcom,coresight-tpdm", "arm,primecell";
>      reg = <0 0x10c29000 0 0x1000>;
> 
>      clocks = <&aoss_qmp>;
>      clock-names = "apb_pclk";
> 
>      out-ports {
>              port {
>                      tpdm_ipcc_out_tpda_dl_center_27: endpoint {
>                              remote-endpoint =
> <&tpda_dl_center_27_in_tpdm_ipcc>;
>                      };
>              };
>      };
> };*
> 
> *Thanks
> Jinlong Mao
>>
>>
>>>
>>> Thanks
>>> Jinlong Mao
>>>
>>>>>
>>>>>> Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
>>>>>> ---
>>>>>>   drivers/hwtracing/coresight/coresight-core.c | 34 
>>>>>> +++++++++++---------
>>>>>>   1 file changed, 19 insertions(+), 15 deletions(-)
>>>>>>
>>>>>> diff --git a/drivers/hwtracing/coresight/coresight-core.c 
>>>>>> b/drivers/hwtracing/coresight/coresight-core.c
>>>>>> index d3bf82c0de1d..5e95d9c7f256 100644
>>>>>> --- a/drivers/hwtracing/coresight/coresight-core.c
>>>>>> +++ b/drivers/hwtracing/coresight/coresight-core.c
>>>>>> @@ -1733,28 +1733,32 @@ char *coresight_alloc_device_name(struct 
>>>>>> coresight_dev_list *dict,
>>>>>>   {
>>>>>>       int idx;
>>>>>>       char *name = NULL;
>>>>>> +    const char *coresight_name = NULL;
>>>>>>       struct fwnode_handle **list;
>>>>>> +    struct device_node *node = dev->of_node;
>>>>>>         mutex_lock(&coresight_mutex);
>>>>>>   -    idx = coresight_search_device_idx(dict, dev_fwnode(dev));
>>>>>> -    if (idx < 0) {
>>>>>> -        /* Make space for the new entry */
>>>>>> -        idx = dict->nr_idx;
>>>>>> -        list = krealloc_array(dict->fwnode_list,
>>>>>> -                      idx + 1, sizeof(*dict->fwnode_list),
>>>>>> -                      GFP_KERNEL);
>>>>>> -        if (ZERO_OR_NULL_PTR(list)) {
>>>>>> -            idx = -ENOMEM;
>>>>>> -            goto done;
>>>>>> +    if (!of_property_read_string(node, "coresight-name", 
>>>>>> &coresight_name))
>>>>>> +        name = devm_kasprintf(dev, GFP_KERNEL, "%s", 
>>>>>> coresight_name);
>>>>>> +    else {
>>>>>> +        idx = coresight_search_device_idx(dict, dev_fwnode(dev));
>>>>>> +        if (idx < 0) {
>>>>>> +            /* Make space for the new entry */
>>>>>> +            idx = dict->nr_idx;
>>>>>> +            list = krealloc_array(dict->fwnode_list,
>>>>>> +                          idx + 1, sizeof(*dict->fwnode_list),
>>>>>> +                          GFP_KERNEL);
>>>>>> +            if (ZERO_OR_NULL_PTR(list))
>>>>>> +                goto done;
>>>>>> +
>>>>>> +            list[idx] = dev_fwnode(dev);
>>>>>> +            dict->fwnode_list = list;
>>>>>> +            dict->nr_idx = idx + 1;
>>>>>>           }
>>>>>>   -        list[idx] = dev_fwnode(dev);
>>>>>> -        dict->fwnode_list = list;
>>>>>> -        dict->nr_idx = idx + 1;
>>>>>> +        name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, 
>>>>>> idx);
>>>>>>       }
>>>>>> -
>>>>>> -    name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, idx);
>>>>>>   done:
>>>>>>       mutex_unlock(&coresight_mutex);
>>>>>>       return name;
>>>>>
>>>> _______________________________________________
>>>> CoreSight mailing list -- coresight@lists.linaro.org
>>>> To unsubscribe send an email to coresight-leave@lists.linaro.org
>>
Mao Jinlong April 24, 2023, 1:42 p.m. UTC | #6
On 3/17/2023 10:25 PM, Suzuki K Poulose wrote:

> On 17/03/2023 05:34, Jinlong Mao wrote:
>>
>> On 3/13/2023 5:16 PM, Suzuki K Poulose wrote:
>>> Cc: Rob
>>>
>>> On 01/03/2023 15:11, Jinlong Mao wrote:
>>>> Hi Suzuki,
>>>>
>>>> On 2/9/2023 10:16 AM, Jinlong Mao wrote:
>>>>>
>>>>> On 2/8/2023 10:26 PM, Suzuki K Poulose wrote:
>>>>>> On 08/02/2023 11:07, Mao Jinlong wrote:
>>>>>>> Apart from STM and ETM sources, there will be more sources added to
>>>>>>> coresight components. For example, there are over 10 TPDM sources.
>>>>>>> Add coresight name support for custom names which will be
>>>>>>> easy to identify the source.
>>>>>>>
>>>>>>
>>>>>> As we have previously discussed, please don't make this a generic
>>>>>> code change. If your device has a "specifici" name, use that for
>>>>>> allocating in the driver and leave the core code alone.
>>>>>>
>>>>>> Suzuki
>>>>>>
>>>>> Hi Suzuki,
>>>>>
>>>>> Not only for TPDMs. There could be dozens of CTI devices.
>>>>> It is hard for user to know which CTI device it is with current 
>>>>> names.
>>>>>
>>>>> Thanks
>>>>> Jinlong Mao
>>>>
>>>> The coresight name support is applicable to CTI and TPDM devices.
>>>> This is a generic change for the source which has dozens of devices.
>>>
>>> I took a look at the CTI situation and I agree that the situation
>>> is a bit tricky. The CTI could be connected to multiple devices,
>>> some of them may not be even CoreSight devices. Given there could
>>> be numerous of them, we need some way to make the "devices" naming
>>> a bit more intuitive.
>>>
>>> Before we go ahead and add something specific to coresight, I would
>>> like to see if there is a generic property. Ideally, the "labels"
>>> in the DTS sources would have been an ideal choice, but can't
>>> see how that is available in the FDT.
>>>
>>> Suzuki
>> Hi Suzuki,
>>
>> Shall we use the full_name of device_node struct as coresight 
>> component's name ?
>>
>>    struct device_node {
>>      const char *name;
>>      phandle phandle;
>> *    const char *full_name;
>>
>> *For component below, the full_name will be "coresight-tpdm-ipcc".
>> *
>> **coresight-tpdm-ipcc* {
>
> Does that go against the convention of naming the DT nodes ?
> I am not sure. Also, we would need a way to solve this for ACPI too.
>
> Suzuki
Hi Suzuki,

Does ACPI device also use "coresight_alloc_device_name" to get the 
device's name ?

Thanks
Jinlong Mao

>
>
>>      compatible = "qcom,coresight-tpdm", "arm,primecell";
>>      reg = <0 0x10c29000 0 0x1000>;
>>
>>      clocks = <&aoss_qmp>;
>>      clock-names = "apb_pclk";
>>
>>      out-ports {
>>              port {
>>                      tpdm_ipcc_out_tpda_dl_center_27: endpoint {
>>                              remote-endpoint =
>> <&tpda_dl_center_27_in_tpdm_ipcc>;
>>                      };
>>              };
>>      };
>> };*
>>
>> *Thanks
>> Jinlong Mao
>>>
>>>
>>>>
>>>> Thanks
>>>> Jinlong Mao
>>>>
>>>>>>
>>>>>>> Signed-off-by: Mao Jinlong <quic_jinlmao@quicinc.com>
>>>>>>> ---
>>>>>>>   drivers/hwtracing/coresight/coresight-core.c | 34 
>>>>>>> +++++++++++---------
>>>>>>>   1 file changed, 19 insertions(+), 15 deletions(-)
>>>>>>>
>>>>>>> diff --git a/drivers/hwtracing/coresight/coresight-core.c 
>>>>>>> b/drivers/hwtracing/coresight/coresight-core.c
>>>>>>> index d3bf82c0de1d..5e95d9c7f256 100644
>>>>>>> --- a/drivers/hwtracing/coresight/coresight-core.c
>>>>>>> +++ b/drivers/hwtracing/coresight/coresight-core.c
>>>>>>> @@ -1733,28 +1733,32 @@ char *coresight_alloc_device_name(struct 
>>>>>>> coresight_dev_list *dict,
>>>>>>>   {
>>>>>>>       int idx;
>>>>>>>       char *name = NULL;
>>>>>>> +    const char *coresight_name = NULL;
>>>>>>>       struct fwnode_handle **list;
>>>>>>> +    struct device_node *node = dev->of_node;
>>>>>>>         mutex_lock(&coresight_mutex);
>>>>>>>   -    idx = coresight_search_device_idx(dict, dev_fwnode(dev));
>>>>>>> -    if (idx < 0) {
>>>>>>> -        /* Make space for the new entry */
>>>>>>> -        idx = dict->nr_idx;
>>>>>>> -        list = krealloc_array(dict->fwnode_list,
>>>>>>> -                      idx + 1, sizeof(*dict->fwnode_list),
>>>>>>> -                      GFP_KERNEL);
>>>>>>> -        if (ZERO_OR_NULL_PTR(list)) {
>>>>>>> -            idx = -ENOMEM;
>>>>>>> -            goto done;
>>>>>>> +    if (!of_property_read_string(node, "coresight-name", 
>>>>>>> &coresight_name))
>>>>>>> +        name = devm_kasprintf(dev, GFP_KERNEL, "%s", 
>>>>>>> coresight_name);
>>>>>>> +    else {
>>>>>>> +        idx = coresight_search_device_idx(dict, dev_fwnode(dev));
>>>>>>> +        if (idx < 0) {
>>>>>>> +            /* Make space for the new entry */
>>>>>>> +            idx = dict->nr_idx;
>>>>>>> +            list = krealloc_array(dict->fwnode_list,
>>>>>>> +                          idx + 1, sizeof(*dict->fwnode_list),
>>>>>>> +                          GFP_KERNEL);
>>>>>>> +            if (ZERO_OR_NULL_PTR(list))
>>>>>>> +                goto done;
>>>>>>> +
>>>>>>> +            list[idx] = dev_fwnode(dev);
>>>>>>> +            dict->fwnode_list = list;
>>>>>>> +            dict->nr_idx = idx + 1;
>>>>>>>           }
>>>>>>>   -        list[idx] = dev_fwnode(dev);
>>>>>>> -        dict->fwnode_list = list;
>>>>>>> -        dict->nr_idx = idx + 1;
>>>>>>> +        name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", 
>>>>>>> dict->pfx, idx);
>>>>>>>       }
>>>>>>> -
>>>>>>> -    name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, 
>>>>>>> idx);
>>>>>>>   done:
>>>>>>>       mutex_unlock(&coresight_mutex);
>>>>>>>       return name;
>>>>>>
>>>>> _______________________________________________
>>>>> CoreSight mailing list -- coresight@lists.linaro.org
>>>>> To unsubscribe send an email to coresight-leave@lists.linaro.org
>>>
>
Suzuki K Poulose April 24, 2023, 10:26 p.m. UTC | #7
On 24/04/2023 14:42, Jinlong Mao wrote:
> On 3/17/2023 10:25 PM, Suzuki K Poulose wrote:
> 
>> On 17/03/2023 05:34, Jinlong Mao wrote:
>>>
>>> On 3/13/2023 5:16 PM, Suzuki K Poulose wrote:
>>>> Cc: Rob
>>>>
>>>> On 01/03/2023 15:11, Jinlong Mao wrote:
>>>>> Hi Suzuki,
>>>>>
>>>>> On 2/9/2023 10:16 AM, Jinlong Mao wrote:
>>>>>>
>>>>>> On 2/8/2023 10:26 PM, Suzuki K Poulose wrote:
>>>>>>> On 08/02/2023 11:07, Mao Jinlong wrote:
>>>>>>>> Apart from STM and ETM sources, there will be more sources added to
>>>>>>>> coresight components. For example, there are over 10 TPDM sources.
>>>>>>>> Add coresight name support for custom names which will be
>>>>>>>> easy to identify the source.
>>>>>>>>
>>>>>>>
>>>>>>> As we have previously discussed, please don't make this a generic
>>>>>>> code change. If your device has a "specifici" name, use that for
>>>>>>> allocating in the driver and leave the core code alone.
>>>>>>>
>>>>>>> Suzuki
>>>>>>>
>>>>>> Hi Suzuki,
>>>>>>
>>>>>> Not only for TPDMs. There could be dozens of CTI devices.
>>>>>> It is hard for user to know which CTI device it is with current 
>>>>>> names.
>>>>>>
>>>>>> Thanks
>>>>>> Jinlong Mao
>>>>>
>>>>> The coresight name support is applicable to CTI and TPDM devices.
>>>>> This is a generic change for the source which has dozens of devices.
>>>>
>>>> I took a look at the CTI situation and I agree that the situation
>>>> is a bit tricky. The CTI could be connected to multiple devices,
>>>> some of them may not be even CoreSight devices. Given there could
>>>> be numerous of them, we need some way to make the "devices" naming
>>>> a bit more intuitive.
>>>>
>>>> Before we go ahead and add something specific to coresight, I would
>>>> like to see if there is a generic property. Ideally, the "labels"
>>>> in the DTS sources would have been an ideal choice, but can't
>>>> see how that is available in the FDT.
>>>>
>>>> Suzuki
>>> Hi Suzuki,
>>>
>>> Shall we use the full_name of device_node struct as coresight 
>>> component's name ?
>>>
>>>    struct device_node {
>>>      const char *name;
>>>      phandle phandle;
>>> *    const char *full_name;
>>>
>>> *For component below, the full_name will be "coresight-tpdm-ipcc".
>>> *
>>> **coresight-tpdm-ipcc* {
>>
>> Does that go against the convention of naming the DT nodes ?
>> I am not sure. Also, we would need a way to solve this for ACPI too.
>>
>> Suzuki
> Hi Suzuki,
> 
> Does ACPI device also use "coresight_alloc_device_name" to get the 
> device's name ?

All driver code is common for both DT & ACPI. The only difference is
the coresight_get_platform_data() which uses DT vs ACPI information
and populates the platform_data.  See coresight-platform.c.

Suzuki
diff mbox series

Patch

diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
index d3bf82c0de1d..5e95d9c7f256 100644
--- a/drivers/hwtracing/coresight/coresight-core.c
+++ b/drivers/hwtracing/coresight/coresight-core.c
@@ -1733,28 +1733,32 @@  char *coresight_alloc_device_name(struct coresight_dev_list *dict,
 {
 	int idx;
 	char *name = NULL;
+	const char *coresight_name = NULL;
 	struct fwnode_handle **list;
+	struct device_node *node = dev->of_node;
 
 	mutex_lock(&coresight_mutex);
 
-	idx = coresight_search_device_idx(dict, dev_fwnode(dev));
-	if (idx < 0) {
-		/* Make space for the new entry */
-		idx = dict->nr_idx;
-		list = krealloc_array(dict->fwnode_list,
-				      idx + 1, sizeof(*dict->fwnode_list),
-				      GFP_KERNEL);
-		if (ZERO_OR_NULL_PTR(list)) {
-			idx = -ENOMEM;
-			goto done;
+	if (!of_property_read_string(node, "coresight-name", &coresight_name))
+		name = devm_kasprintf(dev, GFP_KERNEL, "%s", coresight_name);
+	else {
+		idx = coresight_search_device_idx(dict, dev_fwnode(dev));
+		if (idx < 0) {
+			/* Make space for the new entry */
+			idx = dict->nr_idx;
+			list = krealloc_array(dict->fwnode_list,
+					      idx + 1, sizeof(*dict->fwnode_list),
+					      GFP_KERNEL);
+			if (ZERO_OR_NULL_PTR(list))
+				goto done;
+
+			list[idx] = dev_fwnode(dev);
+			dict->fwnode_list = list;
+			dict->nr_idx = idx + 1;
 		}
 
-		list[idx] = dev_fwnode(dev);
-		dict->fwnode_list = list;
-		dict->nr_idx = idx + 1;
+		name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, idx);
 	}
-
-	name = devm_kasprintf(dev, GFP_KERNEL, "%s%d", dict->pfx, idx);
 done:
 	mutex_unlock(&coresight_mutex);
 	return name;