From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CD75C433DF for ; Mon, 6 Jul 2020 15:05:08 +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 261D12070B for ; Mon, 6 Jul 2020 15:05:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="DITB3Kn7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 261D12070B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.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-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Ibkd8gH2/X8/i/+0jkpnX8jLtJxfxj8hzBj/z1doi0Y=; b=DITB3Kn7Kpy5wz6/hJnKagNLa mqO4Oglc/K9U/n69Qg0vFjv8+s3UddlClnJH6iHqmjNXS8BYS6BRoz+o6dDvQ+s26heeCnr0OaUB8 qcIbaqPR/lIMAk7PeG89pBhkeCx8RaS86V/+hxP/g2Jad//lBEnRfEDr35Zd/nMPTDaAvcdFG/EEa 7xU9licaQJjSUpjpHdH7AOyqqbBZLM+Q+rsCKpeuJBgsUZ9LYFFAjvBh0SHVzeLnIx2ZCS0XpPCFu x0Aqru/jOGraxPcuKkzN4CAguJJE3Eu9lhIiqVkYSC3CGiZ8My6soGJ93E/+rMyJpjbwjKt/BqiIZ a0h9BSgBA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsSeq-00035e-MR; Mon, 06 Jul 2020 15:03:48 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jsSen-000349-NQ for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2020 15:03:46 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EB86E30E; Mon, 6 Jul 2020 08:03:42 -0700 (PDT) Received: from [10.57.21.32] (unknown [10.57.21.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 144283F71E; Mon, 6 Jul 2020 08:03:41 -0700 (PDT) Subject: Re: [RFC PATCH v1 2/2] perf/smmuv3: To support the dts to get options To: Jay Chen , will@kernel.org, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org, Jean-Philippe Brucker References: <20200706112246.92220-1-jkchen@linux.alibaba.com> <20200706112246.92220-3-jkchen@linux.alibaba.com> From: Robin Murphy Message-ID: <024231fc-cf6e-6785-5153-2e7f45496911@arm.com> Date: Mon, 6 Jul 2020 16:03:34 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200706112246.92220-3-jkchen@linux.alibaba.com> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200706_110345_933711_9AD737AB X-CRM114-Status: GOOD ( 27.60 ) 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: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2020-07-06 12:22, Jay Chen wrote: > For the smmuv3 pmu for support the dts to get the > options > > Signed-off-by: Jay Chen > --- > 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"}, We know this kind of thing doesn't scale well - please define a compatible string for the specific PMU model. In fact my hope was that DT compatibles would map to the same model values we made up for IORT to pass, such that the *only* firmware-specific difference the driver needs to have is whether to retrieve the model from platdata or OF match data, then the actual quirks are applied commonly. > + { 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 Why bother stubbing this out? It shouldn't have any build-time dependency on ACPI code, and saving a whole 48 bytes from the object size (for my local build setup) struggles to justify the source-code clutter. > 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", }, Please define the DT binding first. IIRC Jean-Philippe wrote some patches a while back that never got posted, but I suppose it should be YAML now... > + { }, > +}; How about the thing for module autoloading too? Robin. > + > 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, > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel