Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2890085ybk; Mon, 18 May 2020 10:23:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+HaEbGvA4y/oeJjdE95ih3YlStJemtBbHAs7GBlCn7nH4CIjHFMur31EHUin7lbRxESnW X-Received: by 2002:a05:6402:2c4:: with SMTP id b4mr14915163edx.331.1589822611507; Mon, 18 May 2020 10:23:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589822611; cv=none; d=google.com; s=arc-20160816; b=QXizVdfjFFS09d7ef9237IlYHbsw8w4NGoGdz6iXVKgNQjH5gsYH/c7MN1EIAtCTXt ac3aDXZtLpKiFLjQLjmwkvusUq1+tBvDefyiQCew2ikDywWQwv5DK7RqlG+6sMn+Ksys HVdcpCmi7UCiLLBt/fHXVanbMk1n4dKVYrVJ7CQ9XMlv1cdNag6TRD3Hfg3EdqiQQrEC CiPOS4ioGzKZ5kjWFb6gaCHo364cyqmBb2geAQZ20dyf4SZ7YFYXvgMQB+nDX1BqJIKJ GuqIpV8MvMwQAfjrw2SHSiEDf3yP8u/sy8GEHX9lVdXP5E8w1z76SbRP2HhnpGXxJOZO BlTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=H/IvCja4sCl1wPenh9VO1hbJNkA1n1A5hRPfpzshjqg=; b=NzhKnBTQmKa1XT2YxQ28J3sypZ/m+Bpz+blcILNYGFSDAMSAA7nFa6mUIB6ruDtyix xIX3Gr+i183dk33pTgbPIDGPM7xv8hKvvgbLzWHs/hG5LFWvokhK/FVZWcA1HgDUL+Nw 9xxw0E2rFowMZjvedecHoAzUoEOkYP+3Eu59vFSOYbH6lPyDJXT1YsTtIG+I/YXNfotC 1/cKE+WH799E453MO/3Z/Mrg3RDkDsak4edQGee4gm/0hdJn+uAnTBYVEfQBGpchTxpX kQn9I4sbgX76uGud/DO5RVMSl1Y0Pz5hHtICuKLPV6V0DyPbpsPG0/9FtVGcPNGclpoY /fGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RdQQF5HS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s9si3336049eju.20.2020.05.18.10.23.05; Mon, 18 May 2020 10:23:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RdQQF5HS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728357AbgERRVi (ORCPT + 99 others); Mon, 18 May 2020 13:21:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:55132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726958AbgERRVi (ORCPT ); Mon, 18 May 2020 13:21:38 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0F7602070A; Mon, 18 May 2020 17:21:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589822497; bh=r5GpIZm99JIcJLaW6N8soEyvPIfJsbLCLSFGc1rY7XI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RdQQF5HSiiTdxmfa2jxGtQZABy79/T5D7pilxBhd9EF/9DEQ/5cNBPaFbSspQkGQZ h7LepYdnHzb8rYcXfYdUi/11hv/A9yj/nD1neWb6qD8Iw4SB0Ez4tjnV71pwM6KxGy CwOwBf3+6PM+z5C+Q2PgjNqrUB/ZUFWtxUa3sjDQ= Date: Mon, 18 May 2020 18:21:32 +0100 From: Will Deacon To: Tuan Phan , suzuki.poulose@arm.com Cc: patches@amperecomputing.com, Mark Rutland , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] perf: arm_dsu: Support DSU ACPI devices. Message-ID: <20200518172132.GA2601@willie-the-truck> References: <1589229160-18558-1-git-send-email-tuanphan@os.amperecomputing.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1589229160-18558-1-git-send-email-tuanphan@os.amperecomputing.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 11, 2020 at 01:32:40PM -0700, Tuan Phan wrote: > Add ACPI node probing device support. Each DSU ACPI node > defines a "cpus" package with a per cpu MPIDR element. > > Signed-off-by: Tuan Phan > --- > Changes in v2: > - Removed IRQF_SHARED. > - Fixed ACPI runtime detection. > > The ACPI binding spec for DSU ACPI node is under beta and located > in ARM server group under project "ACPI on ARM". > > drivers/perf/arm_dsu_pmu.c | 71 ++++++++++++++++++++++++++++++++++++++++------ > 1 file changed, 63 insertions(+), 8 deletions(-) I've added Suzuki to cc, because I'd like his ack on this before I merge it. Thanks, Will > diff --git a/drivers/perf/arm_dsu_pmu.c b/drivers/perf/arm_dsu_pmu.c > index 70968c8..784d177 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 > #include > #include > #include > @@ -603,18 +604,21 @@ 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_dt_get_cpus: Get the list of CPUs in the cluster > + * from device tree. > */ > -static int dsu_pmu_dt_get_cpus(struct device_node *dev, cpumask_t *mask) > +static int dsu_pmu_dt_get_cpus(struct platform_device *pdev) > { > 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,11 +630,54 @@ 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; > } > > +/** > + * dsu_pmu_acpi_get_cpus: Get the list of CPUs in the cluster > + * from ACPI. > + */ > +static int dsu_pmu_acpi_get_cpus(struct platform_device *pdev) > +{ > + 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_PACKAGE, &obj); > + if (ret < 0) > + return ret; > + > + 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; > +} > + > +static int dsu_pmu_platform_get_cpus(struct platform_device *pdev) > +{ > + int ret = -ENOENT; > + struct fwnode_handle *fwnode = dev_fwnode(&pdev->dev); > + > + if (IS_ERR_OR_NULL(fwnode)) > + return ret; > + > + if (is_of_node(fwnode)) > + ret = dsu_pmu_dt_get_cpus(pdev); > + else if (is_acpi_device_node(fwnode)) > + ret = dsu_pmu_acpi_get_cpus(pdev); > + > + return ret; > +} > + > /* > * dsu_pmu_probe_pmu: Probe the PMU details on a CPU in the cluster. > */ > @@ -683,7 +730,9 @@ static int dsu_pmu_device_probe(struct platform_device *pdev) > if (IS_ERR(dsu_pmu)) > return PTR_ERR(dsu_pmu); > > - rc = dsu_pmu_dt_get_cpus(pdev->dev.of_node, &dsu_pmu->associated_cpus); > + platform_set_drvdata(pdev, dsu_pmu); > + > + rc = dsu_pmu_platform_get_cpus(pdev); > if (rc) { > dev_warn(&pdev->dev, "Failed to parse the CPUs\n"); > return rc; > @@ -707,7 +756,6 @@ static int dsu_pmu_device_probe(struct platform_device *pdev) > } > > dsu_pmu->irq = irq; > - platform_set_drvdata(pdev, dsu_pmu); > rc = cpuhp_state_add_instance(dsu_pmu_cpuhp_state, > &dsu_pmu->cpuhp_node); > if (rc) > @@ -754,11 +802,19 @@ static const struct of_device_id dsu_pmu_of_match[] = { > { .compatible = "arm,dsu-pmu", }, > {}, > }; > +MODULE_DEVICE_TABLE(of, dsu_pmu_of_match); > + > +static const struct acpi_device_id dsu_pmu_acpi_match[] = { > + { "ARMHD500", 0}, > + {}, > +}; > +MODULE_DEVICE_TABLE(acpi, dsu_pmu_acpi_match); > > static struct platform_driver dsu_pmu_driver = { > .driver = { > .name = DRVNAME, > .of_match_table = of_match_ptr(dsu_pmu_of_match), > + .acpi_match_table = ACPI_PTR(dsu_pmu_acpi_match), > }, > .probe = dsu_pmu_device_probe, > .remove = dsu_pmu_device_remove, > @@ -827,7 +883,6 @@ static void __exit dsu_pmu_exit(void) > module_init(dsu_pmu_init); > module_exit(dsu_pmu_exit); > > -MODULE_DEVICE_TABLE(of, dsu_pmu_of_match); > MODULE_DESCRIPTION("Perf driver for ARM DynamIQ Shared Unit"); > MODULE_AUTHOR("Suzuki K Poulose "); > MODULE_LICENSE("GPL v2"); > -- > 2.7.4 >