diff mbox series

[V3,3/4] coresight: trbe: Add a representative coresight_platform_data for TRBE

Message ID 20230803055652.1322801-4-anshuman.khandual@arm.com (mailing list archive)
State New, archived
Headers show
Series coresight: trbe: Enable ACPI based devices | expand

Commit Message

Anshuman Khandual Aug. 3, 2023, 5:56 a.m. UTC
TRBE coresight devices do not need regular connections information, as the
paths get built between all percpu source and their respective percpu sink
devices. Please refer 'commit 2cd87a7b293d ("coresight: core: Add support
for dedicated percpu sinks")' which added support for percpu sink devices.

coresight_register() expect device connections via the platform_data. TRBE
devices do not have any graph connections and thus is empty. With upcoming
ACPI support for TRBE, we do not get a real acpi_device and thus
coresight_get_platform_dat() will end up in failures. Hence this allocates
a zeroed coresight_platform_data structure and assigns that back into the
device.

Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
 drivers/hwtracing/coresight/coresight-trbe.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Suzuki K Poulose Aug. 3, 2023, 1:55 p.m. UTC | #1
On 03/08/2023 06:56, Anshuman Khandual wrote:
> TRBE coresight devices do not need regular connections information, as the
> paths get built between all percpu source and their respective percpu sink
> devices. Please refer 'commit 2cd87a7b293d ("coresight: core: Add support
> for dedicated percpu sinks")' which added support for percpu sink devices.
> 
> coresight_register() expect device connections via the platform_data. TRBE
> devices do not have any graph connections and thus is empty. With upcoming
> ACPI support for TRBE, we do not get a real acpi_device and thus
> coresight_get_platform_dat() will end up in failures. Hence this allocates
> a zeroed coresight_platform_data structure and assigns that back into the
> device.
> 
> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> Cc: Mike Leach <mike.leach@linaro.org>
> Cc: Leo Yan <leo.yan@linaro.org>
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Cc: coresight@lists.linaro.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
>   drivers/hwtracing/coresight/coresight-trbe.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
> index 7720619909d6..e1d9d06e7725 100644
> --- a/drivers/hwtracing/coresight/coresight-trbe.c
> +++ b/drivers/hwtracing/coresight/coresight-trbe.c
> @@ -1494,9 +1494,9 @@ static int arm_trbe_device_probe(struct platform_device *pdev)
>   	if (!drvdata)
>   		return -ENOMEM;
>   
> -	pdata = coresight_get_platform_data(dev);
> -	if (IS_ERR(pdata))
> -		return PTR_ERR(pdata);
> +	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
> +	if (!pdata)
> +		return -ENOMEM;

Please could you add a comment in here, on why we use a dummy platform
data ? It is good to have documented it in the code too.

Suzuki


>   
>   	dev_set_drvdata(dev, drvdata);
>   	dev->platform_data = pdata;
Anshuman Khandual Aug. 4, 2023, 9:18 a.m. UTC | #2
On 8/3/23 19:25, Suzuki K Poulose wrote:
> On 03/08/2023 06:56, Anshuman Khandual wrote:
>> TRBE coresight devices do not need regular connections information, as the
>> paths get built between all percpu source and their respective percpu sink
>> devices. Please refer 'commit 2cd87a7b293d ("coresight: core: Add support
>> for dedicated percpu sinks")' which added support for percpu sink devices.
>>
>> coresight_register() expect device connections via the platform_data. TRBE
>> devices do not have any graph connections and thus is empty. With upcoming
>> ACPI support for TRBE, we do not get a real acpi_device and thus
>> coresight_get_platform_dat() will end up in failures. Hence this allocates
>> a zeroed coresight_platform_data structure and assigns that back into the
>> device.
>>
>> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
>> Cc: Mike Leach <mike.leach@linaro.org>
>> Cc: Leo Yan <leo.yan@linaro.org>
>> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
>> Cc: coresight@lists.linaro.org
>> Cc: linux-arm-kernel@lists.infradead.org
>> Cc: linux-kernel@vger.kernel.org
>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>> ---
>>   drivers/hwtracing/coresight/coresight-trbe.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
>> index 7720619909d6..e1d9d06e7725 100644
>> --- a/drivers/hwtracing/coresight/coresight-trbe.c
>> +++ b/drivers/hwtracing/coresight/coresight-trbe.c
>> @@ -1494,9 +1494,9 @@ static int arm_trbe_device_probe(struct platform_device *pdev)
>>       if (!drvdata)
>>           return -ENOMEM;
>>   -    pdata = coresight_get_platform_data(dev);
>> -    if (IS_ERR(pdata))
>> -        return PTR_ERR(pdata);
>> +    pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
>> +    if (!pdata)
>> +        return -ENOMEM;
> 
> Please could you add a comment in here, on why we use a dummy platform
> data ? It is good to have documented it in the code too.

Sure, will add the following in-code documentation.

+       /*
+        * TRBE coresight devices do not need regular connections
+        * information, as the paths get built between all percpu
+        * source and their respective percpu sink devices. Though
+        * coresight_register() expect device connections via the
+        * platform_data, which TRBE devices do not have. As they
+        * are not real ACPI devices, coresight_get_platform_dat()
+        * ends up failing. Instead let's allocate a dummy zeroed
+        * coresight_platform_data structure and assign that back
+        * into the device for that purpose.
+        */
Suzuki K Poulose Aug. 4, 2023, 10:04 a.m. UTC | #3
On 04/08/2023 10:18, Anshuman Khandual wrote:
> 
> 
> On 8/3/23 19:25, Suzuki K Poulose wrote:
>> On 03/08/2023 06:56, Anshuman Khandual wrote:
>>> TRBE coresight devices do not need regular connections information, as the
>>> paths get built between all percpu source and their respective percpu sink
>>> devices. Please refer 'commit 2cd87a7b293d ("coresight: core: Add support
>>> for dedicated percpu sinks")' which added support for percpu sink devices.
>>>
>>> coresight_register() expect device connections via the platform_data. TRBE
>>> devices do not have any graph connections and thus is empty. With upcoming
>>> ACPI support for TRBE, we do not get a real acpi_device and thus
>>> coresight_get_platform_dat() will end up in failures. Hence this allocates
>>> a zeroed coresight_platform_data structure and assigns that back into the
>>> device.
>>>
>>> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
>>> Cc: Mike Leach <mike.leach@linaro.org>
>>> Cc: Leo Yan <leo.yan@linaro.org>
>>> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
>>> Cc: coresight@lists.linaro.org
>>> Cc: linux-arm-kernel@lists.infradead.org
>>> Cc: linux-kernel@vger.kernel.org
>>> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
>>> ---
>>>    drivers/hwtracing/coresight/coresight-trbe.c | 6 +++---
>>>    1 file changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
>>> index 7720619909d6..e1d9d06e7725 100644
>>> --- a/drivers/hwtracing/coresight/coresight-trbe.c
>>> +++ b/drivers/hwtracing/coresight/coresight-trbe.c
>>> @@ -1494,9 +1494,9 @@ static int arm_trbe_device_probe(struct platform_device *pdev)
>>>        if (!drvdata)
>>>            return -ENOMEM;
>>>    -    pdata = coresight_get_platform_data(dev);
>>> -    if (IS_ERR(pdata))
>>> -        return PTR_ERR(pdata);
>>> +    pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
>>> +    if (!pdata)
>>> +        return -ENOMEM;
>>
>> Please could you add a comment in here, on why we use a dummy platform
>> data ? It is good to have documented it in the code too.
> 
> Sure, will add the following in-code documentation.
> 
> +       /*
> +        * TRBE coresight devices do not need regular connections
> +        * information, as the paths get built between all percpu
> +        * source and their respective percpu sink devices. Though
> +        * coresight_register() expect device connections via the
> +        * platform_data, which TRBE devices do not have. As they
> +        * are not real ACPI devices, coresight_get_platform_dat()

minor nit: s/coresight_get_platform_dat/coresight_get_platform_data/
here and above in the description.

Otherwise, looks good.

Suzuki
diff mbox series

Patch

diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
index 7720619909d6..e1d9d06e7725 100644
--- a/drivers/hwtracing/coresight/coresight-trbe.c
+++ b/drivers/hwtracing/coresight/coresight-trbe.c
@@ -1494,9 +1494,9 @@  static int arm_trbe_device_probe(struct platform_device *pdev)
 	if (!drvdata)
 		return -ENOMEM;
 
-	pdata = coresight_get_platform_data(dev);
-	if (IS_ERR(pdata))
-		return PTR_ERR(pdata);
+	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata)
+		return -ENOMEM;
 
 	dev_set_drvdata(dev, drvdata);
 	dev->platform_data = pdata;