From patchwork Wed Nov 17 14:48:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 12692928 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03B9EC433F5 for ; Wed, 17 Nov 2021 14:58:08 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 C698961B2B for ; Wed, 17 Nov 2021 14:58:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C698961B2B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IQKt3ey+mU/sKTW57Wey5bZ23P/fEpjU4sH2kwnnyfo=; b=VOFAyddP2098LQ cf8N4DecI/W0vTYfr2lFich1naD/YrFllSrI6Wh+IfS9GqxchD9c0juA8GkVmp1Jqt9QlfjNmIG0N XB+mUeRCNqT/OY4A7jj8dNdId6IZVju29Dlf3mdNKi3HqC+ySiNYXXiT8JoijIzJ3TMfeYo2/LnOY pxBi04+YqCT6eF4Cic0MlUkgPj7WtPn1b2zxIfcF0KcQMNE1AynAMqeWUc11kfAbr/+emuSDdYb2x y2gNNaLSwrRyBjksedqiMupG2GpJIdRqoo+quVyZoXRAnHwbyD3By2LhX4MFUF2m6Sa5wbOc1CoOd oRnSKF2bLzASJlc95a6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnMMD-005GBR-DK; Wed, 17 Nov 2021 14:56:18 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnMIg-005Ei7-QB for linux-arm-kernel@lists.infradead.org; Wed, 17 Nov 2021 14:52:40 +0000 Received: by mail-ed1-x534.google.com with SMTP id w1so12265552edd.10 for ; Wed, 17 Nov 2021 06:52:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6a4q4pVmQUXtzn45oqIQ9MFMoZugw/FbbL0Z8a0gnOg=; b=rUtkJyDRSqarprvrSuT5wzU3tWckAsA4nxQrLS6fI/rjg9yCAfIUAYsw2Xh78wJir6 uMpgv0/Dv08euJ1JMFVLijyLbdf3oUHnfoeTp7nKGM/aOEAO4zMIDG0E3MbnKwyJP0GZ QA8FRC0w5SQa5Djk+ory93VLGjtjzZbWrm+PzPodr0WyLRNV41q2HFugiwMsSe0XX1y7 RFsb+j1o5sU/R6CkLqFA1qRZO56JEVcWrtxfajNJW4cBcIEFdKQEjFaf5PLTHz0/SXmD ULhxuhsyysxIAWf/l1GMyDFI7K91UWKXZ8T+jWEDwZTsxa3tYoBA1d4m8K5gMn94x6yp 3hSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6a4q4pVmQUXtzn45oqIQ9MFMoZugw/FbbL0Z8a0gnOg=; b=byL9avrpu/tW3qpnlwaYcBp3eXcyLWYMLy5bxaMjPi1GPlGgRirTNAdX6ixOhUzJqC S3Rswnpdrwix6e/S+fxjPMhGw1kR/bqWnpp20FP2LI6LIb2LyQJyXvSKWCke+RQRem5F LdN2+UX6tqtOhYpejLenliu1wnk6fCfc51d0zsMiJ/kDpAjlIeCAfz5CLQ4mCGepC60/ q8d8czi+g6C9imf5QjmpdKobX62I7TCeXdyUwZ1hEj4U9v8omGiAhO6oBoPNY616oW0A NebRgy6YoUgc7UoSDTmLC71VkGmg3J+qm9fW2YMJjbV/8kjcGso2p5AU86M5VUM0MSop 4TwQ== X-Gm-Message-State: AOAM5325EmNGcobvpzD+jXihTM99ZDlsIVJngTU5jID7UWi9FMbunM9Q Xe4OxiS6Vn3+f+2rVQMUwpUUGg== X-Google-Smtp-Source: ABdhPJwHaeJCQFolHmoVIN0lPrlp5s2Djgnu9qxNlKfuAMmCjAAT2Yf+Qc4rCkHRafGx6mc9LtDV1Q== X-Received: by 2002:a05:6402:d49:: with SMTP id ec9mr22561651edb.235.1637160757182; Wed, 17 Nov 2021 06:52:37 -0800 (PST) Received: from localhost.localdomain (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id gs15sm63917ejc.42.2021.11.17.06.52.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Nov 2021 06:52:36 -0800 (PST) From: Jean-Philippe Brucker To: robh+dt@kernel.org Cc: iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, will@kernel.org, robin.murphy@arm.com, joro@8bytes.org, mark.rutland@arm.com, jkchen@linux.alibaba.com, leo.yan@linaro.org, uchida.jun@socionext.com, Jean-Philippe Brucker Subject: [PATCH v2 1/3] dt-bindings: Add Arm SMMUv3 PMCG binding Date: Wed, 17 Nov 2021 14:48:43 +0000 Message-Id: <20211117144844.241072-2-jean-philippe@linaro.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211117144844.241072-1-jean-philippe@linaro.org> References: <20211117144844.241072-1-jean-philippe@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211117_065238_904308_2334252F X-CRM114-Status: GOOD ( 13.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add binding for the Arm SMMUv3 PMU. Each node represents a PMCG, and is placed as a sibling node of the SMMU. Although the PMCGs registers may be within the SMMU MMIO region, they are separate devices, and there can be multiple PMCG devices for each SMMU (for example one for the TCU and one for each TBU). Signed-off-by: Jean-Philippe Brucker Signed-off-by: Robin Murphy --- .../bindings/perf/arm,smmu-v3-pmcg.yaml | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/perf/arm,smmu-v3-pmcg.yaml diff --git a/Documentation/devicetree/bindings/perf/arm,smmu-v3-pmcg.yaml b/Documentation/devicetree/bindings/perf/arm,smmu-v3-pmcg.yaml new file mode 100644 index 000000000000..a4b53a6a1ebf --- /dev/null +++ b/Documentation/devicetree/bindings/perf/arm,smmu-v3-pmcg.yaml @@ -0,0 +1,70 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/perf/arm,smmu-v3-pmcg.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Arm SMMUv3 Performance Monitor Counter Group + +maintainers: + - Will Deacon + - Robin Murphy + +description: | + An SMMUv3 may have several Performance Monitor Counter Group (PMCG). + They are standalone performance monitoring units that support both + architected and IMPLEMENTATION DEFINED event counters. + +properties: + $nodename: + pattern: "^pmu@[0-9a-f]*" + compatible: + oneOf: + - items: + - const: arm,mmu-600-pmcg + - const: arm,smmu-v3-pmcg + - const: arm,smmu-v3-pmcg + + reg: + items: + - description: Register page 0 + - description: Register page 1, if SMMU_PMCG_CFGR.RELOC_CTRS = 1 + minItems: 1 + + interrupts: + maxItems: 1 + + msi-parent: true + +required: + - compatible + - reg + +anyOf: + - required: + - interrupts + - required: + - msi-parent + +additionalProperties: false + +examples: + - | + #include + #include + + pmu@2b420000 { + compatible = "arm,smmu-v3-pmcg"; + reg = <0x2b420000 0x1000>, + <0x2b430000 0x1000>; + interrupts = ; + msi-parent = <&its 0xff0000>; + }; + + pmu@2b440000 { + compatible = "arm,smmu-v3-pmcg"; + reg = <0x2b440000 0x1000>, + <0x2b450000 0x1000>; + interrupts = ; + msi-parent = <&its 0xff0000>; + }; From patchwork Wed Nov 17 14:48:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 12692929 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E191C433EF for ; Wed, 17 Nov 2021 14:58:52 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 44E6C6137B for ; Wed, 17 Nov 2021 14:58:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 44E6C6137B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BGpdYpTYKWT0YIlBjaF8cftHpwt1/vczssiesyc/jyg=; b=B+vrkSbdsHVIch EBww0EXSyLuI7HR8vwjJQyqmcsKwF3gYjrywAuqYvNrUZRveRHn7yJ/mn/ojOIZVICdGIZcF9l6cn bGjMOLarFVf7UwfKMqEvZe75Qbjm8FnadPTwcAVVDjt6hdzhxCT3kio9dyTtjc9kKVw4RuEdc7GwO XguRMnWE4fieWDbyfLbJinp/iHzon1xP7IFv2fbp7dGvzTsuAoL/D3ADM0l7hSdNvEjQY5Z23HCC3 90PuXuRnHKRyj+Mg0ZvuAou4zk3PqipclL7ftH4VutE4pmZZeR+Yjcf4uX2fmsgQPMoKKbHgwL14t lj7yk6brVf/qGGzdcL0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnMMy-005GTS-9V; Wed, 17 Nov 2021 14:57:05 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnMIh-005EiT-FV for linux-arm-kernel@lists.infradead.org; Wed, 17 Nov 2021 14:52:41 +0000 Received: by mail-ed1-x52c.google.com with SMTP id z5so12406652edd.3 for ; Wed, 17 Nov 2021 06:52:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ve7xUdb+Hg9RyjwNTpj23ptdpIMs4Ic4sw4mtKsRCdI=; b=aCdXOLY+9NDzmRPSjazal00RnVkQVSTQqDf7QhIFc6VvfA28TXUiGJr2J19Hi/xU9F KNecCTvatmx6S8+we2pQXqPq4nGfHfj0oix8SjtSf1NFJ+KjyBD6UcWWT35Y1Iyu50Lv 2ubSZutvglNIG4c6DENgdkquq9iYE6Mi6IVhLNGs/4fojWaa/bzD+SpSascqK30sFqmz mclY2y8z8f+LNV/hcAglYycYBNXAAfU34F2bFa48UqNCDtY49A1fuPCMOkwoyjRAPc+m oU+J6j1PsqD1Dz8CuO0KxEVNiIivrmdRKDCd0qJ58Wii7TBQRyYRsbnDGfsTDg7aXUY4 VQZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ve7xUdb+Hg9RyjwNTpj23ptdpIMs4Ic4sw4mtKsRCdI=; b=EBAtsU63eTNImhqofcaIhGnHs7wJs3AUnr9Q4I181hc7GW0iaxKX4c6MmKZbHTVsUS bjgjbU5naLy2AEw8ceRIaTlOB59G+SC041syrXG1blEo5KBJiMAkUhJu+bGwwzU/ZqSd vWiLXgaEFgt4W5IurTYc0lORJQXRukKlzLswDxejSO1GKl1CCSOjbefyuN6wU3e6qKQF 9QNUzpqAOmTl3t+1t4hlTrB0+GSJh4/vLRMjdJUNUkp+BTNsXyHAi4z2FySGSxwkWz1q aKoEuH2GsEpowYXo4tzQcNYP2uEbuMOLwSaU4Ou2tpNuwXEjyCoPj+kwp/wP2B8fzHYa rp2A== X-Gm-Message-State: AOAM530Uc8WYC5DookZCMApaVyifcBiH6tCQ1Jz2CqGA7MBM6sPcGIx5 Q0brS3RUCYYBft1b0rNOZW5/qQ== X-Google-Smtp-Source: ABdhPJxXDaM8+yb04iLwMEzyFoVFkjg3TtfgBGe99zo3k2qNu2dlD3sGtXI1PTF/PPYHNdu0Y6Bhlg== X-Received: by 2002:a17:907:7805:: with SMTP id la5mr22724677ejc.188.1637160758136; Wed, 17 Nov 2021 06:52:38 -0800 (PST) Received: from localhost.localdomain (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id gs15sm63917ejc.42.2021.11.17.06.52.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Nov 2021 06:52:37 -0800 (PST) From: Jean-Philippe Brucker To: robh+dt@kernel.org Cc: iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, will@kernel.org, robin.murphy@arm.com, joro@8bytes.org, mark.rutland@arm.com, jkchen@linux.alibaba.com, leo.yan@linaro.org, uchida.jun@socionext.com, Jean-Philippe Brucker Subject: [PATCH v2 2/3] perf/smmuv3: Add devicetree support Date: Wed, 17 Nov 2021 14:48:44 +0000 Message-Id: <20211117144844.241072-3-jean-philippe@linaro.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211117144844.241072-1-jean-philippe@linaro.org> References: <20211117144844.241072-1-jean-philippe@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211117_065239_573499_9F4782A9 X-CRM114-Status: GOOD ( 15.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add device-tree support to the SMMUv3 PMCG driver. Signed-off-by: Jay Chen Signed-off-by: Jean-Philippe Brucker Signed-off-by: Robin Murphy --- drivers/perf/arm_smmuv3_pmu.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c index 226348822ab3..19697617153a 100644 --- a/drivers/perf/arm_smmuv3_pmu.c +++ b/drivers/perf/arm_smmuv3_pmu.c @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -834,7 +835,8 @@ 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_acpi_options(smmu_pmu); /* Pick one CPU to be the preferred one to use */ smmu_pmu->on_cpu = raw_smp_processor_id(); @@ -884,9 +886,16 @@ 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" }, + {} +}; +MODULE_DEVICE_TABLE(of, smmu_pmu_of_match); + static struct platform_driver smmu_pmu_driver = { .driver = { .name = "arm-smmu-v3-pmcg", + .of_match_table = of_match_ptr(smmu_pmu_of_match), .suppress_bind_attrs = true, }, .probe = smmu_pmu_probe, From patchwork Wed Nov 17 14:48:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 12692930 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93F7EC433F5 for ; Wed, 17 Nov 2021 14:59:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 5FB3561B29 for ; Wed, 17 Nov 2021 14:59:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5FB3561B29 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NNOhIS2fo8EP/XoeJkuX7nP39OvYSKlbKyuiH0e4rNA=; b=nz+lIuzxnoo304 2RX+VPPF8yP8m5voeFlyGWeeNfjuXBadfAbf72+n40cgWIBFtJU81aHMUa5h8kiNuofTuPCoJuNjR hda4Bcu4lHXXp+7tpPKYSHi7Vnkgy6WL2qnVyh31uPTTIli8gdes5uVj61xeSMAZoD1XgZiYhaCLV fiJMyxfV3Oyi60ITiMJtACxOg7NRU7LvnlUCcsspeKGZM6fvMurX0lbn4ogQHGHgVX1n1pqhHjrjT et0qfSUuO0mPFqMeMpi70d7WFdKu3dR1WPDnyvpEpSjYpGVSTYrG6I6oAw1PozB1S9MDHt23ShK3X RS720CXSBcIeLtKh9YKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnMNe-005GiH-Bl; Wed, 17 Nov 2021 14:57:46 +0000 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnMIi-005Ej7-Pr for linux-arm-kernel@lists.infradead.org; Wed, 17 Nov 2021 14:52:42 +0000 Received: by mail-ed1-x532.google.com with SMTP id z5so12406854edd.3 for ; Wed, 17 Nov 2021 06:52:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jqVNNzLQfZFMm9T0Ib+FdeXKGDJ/YUZsGGIsBRM+Cmg=; b=bqwCM7JgZZ07zSsk3K2Xrlf91noWxlvCOW5wvJUoTK8t6dYhg6c/W8jcW9SIvxFzVc +umgW36friR/RPIaCX0Sl/vT9LPXAhuFKt88gHA9BzDkEYrIUbUh0Mrp4+gaMEChKBCH tpiazOQm2MovHH3f5Hbw+R4cIKHaSIdM8Uqgbvd/BWj1gDYS14BXrsme2BQUTa733X4y DarpTagh/vumiPE3/HTrTqiwkeRQELgSshaz5PNRFtnYbb+k1ve4a4K3EUWQfP7twxgb OdaPplKdnlUoe4UzpXRQcAPWITxVSUs95AYOSUzCosFm2Biy5quvNAAVKvuqp2fVJKmC z31w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jqVNNzLQfZFMm9T0Ib+FdeXKGDJ/YUZsGGIsBRM+Cmg=; b=S140Jb750YxXkRau4KpzMy//yLrkQaDt8l64l3s9CzUu3m3TQWYksMMqrPhf+M1Lsr j+vPj/R0ypQW61+4Tj5a++Mnp3iDdCuOCiNVp0F/pcMC7mJcYQBVhmiWgdjWbsTNlK/X TJYRrM+KiZbBU++MHrsNXnT68G+KUnoYiuADIHNBP9k7ZMYLgg+ts8TpcGsdZvo6C/p3 TukyZoqa6Z4f69yEcknCVUdrrrddbE8rFJf6V7KcokrEg/KZcuNjjjzWbZ7nXVwrZQ6S 00X1fz6gSVlLpKp4bcXagonuOEh22VLlWWo72PrpCp1J5++AGRgybeyFIL8hwz8c+A6h /LoQ== X-Gm-Message-State: AOAM5333ouGy2sqghFduiIibk9WeYgSrCNI2XLvN7DiSpjYp5DzCV6Cb 8XEpDfxxZiZeiUV0P/3bTWO7lg== X-Google-Smtp-Source: ABdhPJyTqJmr6Aa39fh4WLBhW8g73puWWy3pIo0FXWd0YPuiRAy0BtvSlaKkOf5iRgrfCWs6kyp4zg== X-Received: by 2002:aa7:c943:: with SMTP id h3mr22592072edt.233.1637160759080; Wed, 17 Nov 2021 06:52:39 -0800 (PST) Received: from localhost.localdomain (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id gs15sm63917ejc.42.2021.11.17.06.52.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Nov 2021 06:52:38 -0800 (PST) From: Jean-Philippe Brucker To: robh+dt@kernel.org Cc: iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, will@kernel.org, robin.murphy@arm.com, joro@8bytes.org, mark.rutland@arm.com, jkchen@linux.alibaba.com, leo.yan@linaro.org, uchida.jun@socionext.com, Jean-Philippe Brucker Subject: [PATCH v2 3/3] perf/smmuv3: Synthesize IIDR from CoreSight ID registers Date: Wed, 17 Nov 2021 14:48:45 +0000 Message-Id: <20211117144844.241072-4-jean-philippe@linaro.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211117144844.241072-1-jean-philippe@linaro.org> References: <20211117144844.241072-1-jean-philippe@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211117_065240_916627_47910E9F X-CRM114-Status: GOOD ( 14.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Robin Murphy The SMMU_PMCG_IIDR register was not present in older revisions of the Arm SMMUv3 spec. On Arm Ltd. implementations, the IIDR value consists of fields from several PIDR registers, allowing us to present a standardized identifier to userspace. Signed-off-by: Robin Murphy Signed-off-by: Jean-Philippe Brucker --- drivers/perf/arm_smmuv3_pmu.c | 55 ++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c index 19697617153a..598d6978280d 100644 --- a/drivers/perf/arm_smmuv3_pmu.c +++ b/drivers/perf/arm_smmuv3_pmu.c @@ -76,6 +76,10 @@ #define SMMU_PMCG_CR 0xE04 #define SMMU_PMCG_CR_ENABLE BIT(0) #define SMMU_PMCG_IIDR 0xE08 +#define SMMU_PMCG_IIDR_PRODUCTID GENMASK(31, 20) +#define SMMU_PMCG_IIDR_VARIANT GENMASK(19, 16) +#define SMMU_PMCG_IIDR_REVISION GENMASK(15, 12) +#define SMMU_PMCG_IIDR_IMPLEMENTER GENMASK(11, 0) #define SMMU_PMCG_CEID0 0xE20 #define SMMU_PMCG_CEID1 0xE28 #define SMMU_PMCG_IRQ_CTRL 0xE50 @@ -84,6 +88,20 @@ #define SMMU_PMCG_IRQ_CFG1 0xE60 #define SMMU_PMCG_IRQ_CFG2 0xE64 +/* IMP-DEF ID registers */ +#define SMMU_PMCG_PIDR0 0xFE0 +#define SMMU_PMCG_PIDR0_PART_0 GENMASK(7, 0) +#define SMMU_PMCG_PIDR1 0xFE4 +#define SMMU_PMCG_PIDR1_DES_0 GENMASK(7, 4) +#define SMMU_PMCG_PIDR1_PART_1 GENMASK(3, 0) +#define SMMU_PMCG_PIDR2 0xFE8 +#define SMMU_PMCG_PIDR2_REVISION GENMASK(7, 4) +#define SMMU_PMCG_PIDR2_DES_1 GENMASK(2, 0) +#define SMMU_PMCG_PIDR3 0xFEC +#define SMMU_PMCG_PIDR3_REVAND GENMASK(7, 4) +#define SMMU_PMCG_PIDR4 0xFD0 +#define SMMU_PMCG_PIDR4_DES_2 GENMASK(3, 0) + /* MSI config fields */ #define MSI_CFG0_ADDR_MASK GENMASK_ULL(51, 2) #define MSI_CFG2_MEMATTR_DEVICE_nGnRE 0x1 @@ -755,6 +773,41 @@ 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); } +static bool smmu_pmu_coresight_id_regs(struct smmu_pmu *smmu_pmu) +{ + return of_device_is_compatible(smmu_pmu->dev->of_node, + "arm,mmu-600-pmcg"); +} + +static void smmu_pmu_get_iidr(struct smmu_pmu *smmu_pmu) +{ + u32 iidr = readl_relaxed(smmu_pmu->reg_base + SMMU_PMCG_IIDR); + + if (!iidr && smmu_pmu_coresight_id_regs(smmu_pmu)) { + u32 pidr0 = readl(smmu_pmu->reg_base + SMMU_PMCG_PIDR0); + u32 pidr1 = readl(smmu_pmu->reg_base + SMMU_PMCG_PIDR1); + u32 pidr2 = readl(smmu_pmu->reg_base + SMMU_PMCG_PIDR2); + u32 pidr3 = readl(smmu_pmu->reg_base + SMMU_PMCG_PIDR3); + u32 pidr4 = readl(smmu_pmu->reg_base + SMMU_PMCG_PIDR4); + + u32 productid = FIELD_GET(SMMU_PMCG_PIDR0_PART_0, pidr0) | + (FIELD_GET(SMMU_PMCG_PIDR1_PART_1, pidr1) << 8); + u32 variant = FIELD_GET(SMMU_PMCG_PIDR2_REVISION, pidr2); + u32 revision = FIELD_GET(SMMU_PMCG_PIDR3_REVAND, pidr3); + u32 implementer = + FIELD_GET(SMMU_PMCG_PIDR1_DES_0, pidr1) | + (FIELD_GET(SMMU_PMCG_PIDR2_DES_1, pidr2) << 4) | + (FIELD_GET(SMMU_PMCG_PIDR4_DES_2, pidr4) << 8); + + iidr = FIELD_PREP(SMMU_PMCG_IIDR_PRODUCTID, productid) | + FIELD_PREP(SMMU_PMCG_IIDR_VARIANT, variant) | + FIELD_PREP(SMMU_PMCG_IIDR_REVISION, revision) | + FIELD_PREP(SMMU_PMCG_IIDR_IMPLEMENTER, implementer); + } + + smmu_pmu->iidr = iidr; +} + static int smmu_pmu_probe(struct platform_device *pdev) { struct smmu_pmu *smmu_pmu; @@ -826,7 +879,7 @@ static int smmu_pmu_probe(struct platform_device *pdev) return err; } - smmu_pmu->iidr = readl_relaxed(smmu_pmu->reg_base + SMMU_PMCG_IIDR); + smmu_pmu_get_iidr(smmu_pmu); name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "smmuv3_pmcg_%llx", (res_0->start) >> SMMU_PMCG_PA_SHIFT);