2022-02-04 09:23:12

by Sudeep Holla

[permalink] [raw]
Subject: [PATCH] coresight: trbe: Move check for kernelspace unmapped at EL0 to probe

Currently with the check present in the module initialisation, it shouts
on all the systems irrespective of presence of coresight trace buffer
extensions.

Similar to Arm SPE perf driver, move the check for kernelspace unmapping
when running at EL0 to the device probe instead of module initialisation.

Cc: Mathieu Poirier <[email protected]>
Cc: Suzuki K Poulose <[email protected]>
Cc: Mike Leach <[email protected]>
Cc: Leo Yan <[email protected]>
Cc: Anshuman Khandual <[email protected]>
Cc: [email protected]
Signed-off-by: Sudeep Holla <[email protected]>
---
drivers/hwtracing/coresight/coresight-trbe.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
index 276862c07e32..3fe2ce1ba5bf 100644
--- a/drivers/hwtracing/coresight/coresight-trbe.c
+++ b/drivers/hwtracing/coresight/coresight-trbe.c
@@ -1423,6 +1423,11 @@ static int arm_trbe_device_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
int ret;

+ if (arm64_kernel_unmapped_at_el0()) {
+ pr_err("TRBE wouldn't work if kernel gets unmapped at EL0\n");
+ return -EOPNOTSUPP;
+ }
+
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
if (!drvdata)
return -ENOMEM;
@@ -1484,11 +1489,6 @@ static int __init arm_trbe_init(void)
{
int ret;

- if (arm64_kernel_unmapped_at_el0()) {
- pr_err("TRBE wouldn't work if kernel gets unmapped at EL0\n");
- return -EOPNOTSUPP;
- }
-
ret = platform_driver_register(&arm_trbe_driver);
if (!ret)
return 0;
--
2.25.1


2022-02-07 11:28:39

by Anshuman Khandual

[permalink] [raw]
Subject: Re: [PATCH] coresight: trbe: Move check for kernelspace unmapped at EL0 to probe



On 2/1/22 5:52 PM, Sudeep Holla wrote:
> Currently with the check present in the module initialisation, it shouts
> on all the systems irrespective of presence of coresight trace buffer
> extensions.

IIUC a system with CONFIG_CORESIGHT_TRBE enabled but without a TRBE DT
i.e "arm,trace-buffer-extension" complains about kernel space unmapping
at EL0 (even though it does not even really have TRBE HW to initialize).

>
> Similar to Arm SPE perf driver, move the check for kernelspace unmapping
> when running at EL0 to the device probe instead of module initialisation.

Makes sense.

>
> Cc: Mathieu Poirier <[email protected]>
> Cc: Suzuki K Poulose <[email protected]>
> Cc: Mike Leach <[email protected]>
> Cc: Leo Yan <[email protected]>
> Cc: Anshuman Khandual <[email protected]>
> Cc: [email protected]
> Signed-off-by: Sudeep Holla <[email protected]>
> ---
> drivers/hwtracing/coresight/coresight-trbe.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c
> index 276862c07e32..3fe2ce1ba5bf 100644
> --- a/drivers/hwtracing/coresight/coresight-trbe.c
> +++ b/drivers/hwtracing/coresight/coresight-trbe.c
> @@ -1423,6 +1423,11 @@ static int arm_trbe_device_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> int ret;
>

Could you please add a similar comment like SPE driver regarding how
the TRBE buffer will be inaccessible, if kernel gets unmapped at EL0
and trace capture will terminate.

> + if (arm64_kernel_unmapped_at_el0()) {
> + pr_err("TRBE wouldn't work if kernel gets unmapped at EL0\n");
> + return -EOPNOTSUPP;
> + }
> +
> drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
> if (!drvdata)
> return -ENOMEM;
> @@ -1484,11 +1489,6 @@ static int __init arm_trbe_init(void)
> {
> int ret;
>
> - if (arm64_kernel_unmapped_at_el0()) {
> - pr_err("TRBE wouldn't work if kernel gets unmapped at EL0\n");
> - return -EOPNOTSUPP;
> - }
> -
> ret = platform_driver_register(&arm_trbe_driver);
> if (!ret)
> return 0;
>