From patchwork Mon Jul 6 11:22:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jay Chen X-Patchwork-Id: 11645453 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A609892A for ; Mon, 6 Jul 2020 11:25:41 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7FE6F2073E for ; Mon, 6 Jul 2020 11:25:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="BpBqopMw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7FE6F2073E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=j2tJbGCk7Iqnl+TT2A3G4y1I+0rZoyn/B6g4OXlleMU=; b=BpBqopMwIddfyWhmlpmFyYG91 DNEyhd6ag5PSNAj+4Eri2YF9GUxSEdJsFD7Q76DyOdhEbxPviipItjjQEaBGlXPsb42XCCHbIbjXo uz3CqfdY+9f54190wZc/14D7GkvU9esZoPPh/+nQf9+oBqulc6+FYPu6eQBbPSfp+x9Z9BV7r8Wwd 7hIiSK8d9GHq7vV0DHbGXBP/BsM2RF2LtTsA393H3sb4Suw2/IoQBAsratY7H+5Ym/Hl+JKyJXaCD R6tYO3Q1zrvbpZxCqB0jGzVZKQDXc1aobxSTF+AFowLZSb2FgC+GDe9GddVhgJrGsQOiGfP06wXbQ H1ClowSSw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsPEc-0007L8-Av; Mon, 06 Jul 2020 11:24:30 +0000 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsPEX-0007Iu-8j for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2020 11:24:27 +0000 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R641e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e01e07484; MF=jkchen@linux.alibaba.com; NM=1; PH=DS; RN=4; SR=0; TI=SMTPD_---0U1u4RQd_1594034650; Received: from localhost(mailfrom:jkchen@linux.alibaba.com fp:SMTPD_---0U1u4RQd_1594034650) by smtp.aliyun-inc.com(127.0.0.1); Mon, 06 Jul 2020 19:24:11 +0800 From: Jay Chen To: will@kernel.org, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH v1 2/2] perf/smmuv3: To support the dts to get options Date: Mon, 6 Jul 2020 19:22:46 +0800 Message-Id: <20200706112246.92220-3-jkchen@linux.alibaba.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200706112246.92220-1-jkchen@linux.alibaba.com> References: <20200706112246.92220-1-jkchen@linux.alibaba.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200706_072425_549377_170BC478 X-CRM114-Status: GOOD ( 13.98 ) X-Spam-Score: -8.0 (--------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-8.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [115.124.30.44 listed in list.dnswl.org] -7.5 USER_IN_DEF_SPF_WL From: address is in the default SPF white-list -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines -0.5 ENV_AND_HDR_SPF_MATCH Env and Hdr From used in default SPF WL Match X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jay Chen Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org For the smmuv3 pmu for support the dts to get the options Signed-off-by: Jay Chen Signed-off-by: Jean-Philippe Brucker --- drivers/perf/arm_smmuv3_pmu.c | 42 ++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c index 2d09f3e47d12..44e9f4197444 100644 --- a/drivers/perf/arm_smmuv3_pmu.c +++ b/drivers/perf/arm_smmuv3_pmu.c @@ -115,6 +115,16 @@ struct smmu_pmu { bool global_filter; }; +struct smmu_pmu_prop { + u32 opt; + const char *prop; +}; + +static struct smmu_pmu_prop smmu_pmu_options[] = { + { SMMU_PMCG_EVCNTR_RDONLY, "hisilicon,smmu-pmcg-evcntr-rdonly"}, + { 0, NULL}, +}; + #define to_smmu_pmu(p) (container_of(p, struct smmu_pmu, pmu)) #define SMMU_PMU_EVENT_ATTR_EXTRACTOR(_name, _config, _start, _end) \ @@ -708,6 +718,7 @@ static void smmu_pmu_reset(struct smmu_pmu *smmu_pmu) smmu_pmu->reloc_base + SMMU_PMCG_OVSCLR0); } +#ifdef CONFIG_ACPI static void smmu_pmu_get_acpi_options(struct smmu_pmu *smmu_pmu) { u32 model; @@ -723,6 +734,26 @@ static void smmu_pmu_get_acpi_options(struct smmu_pmu *smmu_pmu) dev_notice(smmu_pmu->dev, "option mask 0x%x\n", smmu_pmu->options); } +#else +static void smmu_pmu_get_acpi_options(struct smmu_pmu *smmu_pmu) +{ + +} +#endif + +static void smmu_pmu_get_dt_options(struct smmu_pmu *smmu_pmu) +{ + int i = 0; + + do { + if (of_property_read_bool(smmu_pmu->dev->of_node, + smmu_pmu_options[i].prop)) { + smmu_pmu->options |= smmu_pmu_options[i].opt; + dev_notice(smmu_pmu->dev, "option mask 0x%x\n", + smmu_pmu->options); + } + } while (smmu_pmu_options[++i].opt); +} static int smmu_pmu_probe(struct platform_device *pdev) { @@ -801,7 +832,10 @@ static int smmu_pmu_probe(struct platform_device *pdev) return -EINVAL; } - smmu_pmu_get_acpi_options(smmu_pmu); + if (dev->of_node) + smmu_pmu_get_dt_options(smmu_pmu); + else + smmu_pmu_get_acpi_options(smmu_pmu); /* Pick one CPU to be the preferred one to use */ smmu_pmu->on_cpu = raw_smp_processor_id(); @@ -855,9 +889,15 @@ static void smmu_pmu_shutdown(struct platform_device *pdev) smmu_pmu_disable(&smmu_pmu->pmu); } +static const struct of_device_id smmu_pmu_of_match[] = { + { .compatible = "arm-smmu-v3-pmcg", }, + { }, +}; + static struct platform_driver smmu_pmu_driver = { .driver = { .name = "arm-smmu-v3-pmcg", + .of_match_table = smmu_pmu_of_match, }, .probe = smmu_pmu_probe, .remove = smmu_pmu_remove,