From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: tuanphan@os.amperecomputing.com
Cc: mark.rutland@arm.com, linux-kernel@vger.kernel.org,
sudeep.holla@arm.com, patches@amperecomputing.com,
will@kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 2/2] perf: arm_dsu: Support DSU ACPI devices.
Date: Thu, 19 Mar 2020 00:45:37 +0000 [thread overview]
Message-ID: <a571cf7e-c2a5-e8f8-e782-8087249143b0@arm.com> (raw)
In-Reply-To: <1584491323-31436-1-git-send-email-tuanphan@os.amperecomputing.com>
Hello,
Please find my comments below.
On 03/18/2020 12:28 AM, Tuan Phan wrote:
> Add support for probing device from ACPI node.
> Each DSU ACPI node defines "cpus" package which
> each element is the MPIDR of associated cpu.
>
> Signed-off-by: Tuan Phan <tuanphan@os.amperecomputing.com>
> ---
> drivers/perf/arm_dsu_pmu.c | 53 +++++++++++++++++++++++++++++++++++++++-------
> 1 file changed, 45 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/perf/arm_dsu_pmu.c b/drivers/perf/arm_dsu_pmu.c Tua
> index 2622900..6ef762c 100644
> --- a/drivers/perf/arm_dsu_pmu.c
> +++ b/drivers/perf/arm_dsu_pmu.c
> @@ -11,6 +11,7 @@
> #define DRVNAME PMUNAME "_pmu"
> #define pr_fmt(fmt) DRVNAME ": " fmt
>
> +#include <linux/acpi.h>
> #include <linux/bitmap.h>
> #include <linux/bitops.h>
> #include <linux/bug.h>
> @@ -603,18 +604,22 @@ static struct dsu_pmu *dsu_pmu_alloc(struct platform_device *pdev)
> }
>
> /**
> - * dsu_pmu_dt_get_cpus: Get the list of CPUs in the cluster.
> + * dsu_pmu_get_cpus: Get the list of CPUs in the cluster.
> */
> -static int dsu_pmu_dt_get_cpus(struct device_node *dev, cpumask_t *mask)
> +static int dsu_pmu_get_cpus(struct platform_device *pdev)
> {
> +#ifndef CONFIG_ACPI
> + /* Get the list of CPUs from device tree */
What if we have a kernel with both:
CONFIG_OF=y
CONFIG_ACPI=y
and boot the kernel on a system with DT ? In other words, the decision
to choose the DT vs ACPI must be runtime decision, not buildtime.
See
drivers/hwtracing/coresight/coresight-platform.c:coresight_get_platform_data()
for an example.
> int i = 0, n, cpu;
> struct device_node *cpu_node;
> + struct dsu_pmu *dsu_pmu =
> + (struct dsu_pmu *) platform_get_drvdata(pdev);
>
> - n = of_count_phandle_with_args(dev, "cpus", NULL);
> + n = of_count_phandle_with_args(pdev->dev.of_node, "cpus", NULL);
> if (n <= 0)
> return -ENODEV;
> for (; i < n; i++) {
> - cpu_node = of_parse_phandle(dev, "cpus", i);
> + cpu_node = of_parse_phandle(pdev->dev.of_node, "cpus", i);
> if (!cpu_node)
> break;
> cpu = of_cpu_node_to_id(cpu_node);
> @@ -626,9 +631,33 @@ static int dsu_pmu_dt_get_cpus(struct device_node *dev, cpumask_t *mask)
> */
> if (cpu < 0)
> continue;
> - cpumask_set_cpu(cpu, mask);
> + cpumask_set_cpu(cpu, &dsu_pmu->associated_cpus);
> }
> return 0;
> +#else /* CONFIG_ACPI */
> + int i, cpu, ret;
> + const union acpi_object *obj;
> + struct acpi_device *adev = ACPI_COMPANION(&pdev->dev);
> + struct dsu_pmu *dsu_pmu =
> + (struct dsu_pmu *) platform_get_drvdata(pdev);
> +
> + ret = acpi_dev_get_property(adev, "cpus", ACPI_TYPE_ANY, &obj);
Is the binding documented somewhere ?
nit: Also, why not :
ret = acpi_dev_get_propert(adev, "cpus", ACPI_TYPE_PACKAGE, &obj);
if (ret < 0)
return ret;
?
> + if (ret < 0)
> + return -EINVAL;
> +
> + if (obj->type != ACPI_TYPE_PACKAGE)
> + return -EINVAL;
> +
> + for (i = 0; i < obj->package.count; i++) {
> + /* Each element is the MPIDR of associated cpu */
> + for_each_possible_cpu(cpu) {
> + if (cpu_physical_id(cpu) ==
> + obj->package.elements[i].integer.value)
> + cpumask_set_cpu(cpu, &dsu_pmu->associated_cpus);
> + }
> + }
> + return 0;
> +#endif
> }
>
Otherwise looks good to me.
Suzuki
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-03-19 0:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-18 0:28 [PATCH 2/2] perf: arm_dsu: Support DSU ACPI devices Tuan Phan
2020-03-18 10:27 ` Robin Murphy
2020-03-19 0:45 ` Suzuki K Poulose [this message]
2020-03-19 2:42 ` Tuan Phan
2020-03-19 22:49 ` Tuan Phan
2020-03-20 10:27 ` Suzuki K Poulose
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a571cf7e-c2a5-e8f8-e782-8087249143b0@arm.com \
--to=suzuki.poulose@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=patches@amperecomputing.com \
--cc=sudeep.holla@arm.com \
--cc=tuanphan@os.amperecomputing.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).