From patchwork Tue Nov 16 11:35:36 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: 12692756 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 2B30EC433F5 for ; Tue, 16 Nov 2021 11:54:32 +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 E75ED611C3 for ; Tue, 16 Nov 2021 11:54:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E75ED611C3 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=/SRDcHb4hbRGhmv+jpSdQivuK4Cs8yL8NglT/9Pu/qQ=; b=B/3Ox+FskGVeID XRsz5SlFhqJ0JnsqQO0yJW7NPcpt7WvwOqcL75UchAPfIljXV+iGl12GZqd4Uft4DdHm0UdBM1Oyy 8yEmnqglHZJBkdWJOXEOyGAD7ohf5eK4R8MiL/fwMQMBkNbhs83ScSeWayWEe0ld/zgOUJvHrxqV1 Ve3FfrflFFO7bsOUMWdOOcVYgPxwHsaggu0sFR5frtxLXoBSjpYyRVGFPnIZBn4t4Z5EBP1HE30PT lfIY2pPr1hfP3E4/ZhlBb1BzUCsGcTv8F/OwDYXxQWXCM2OvAjBCPt+B4n0zsNkgGr1jeUe7P0Kk1 nT0zjEXFc6Q7Kz33FM0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmx1M-001Yzw-5O; Tue, 16 Nov 2021 11:53:04 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmx0a-001YXI-4a for linux-arm-kernel@lists.infradead.org; Tue, 16 Nov 2021 11:52:18 +0000 Received: by mail-wr1-x434.google.com with SMTP id c4so36922333wrd.9 for ; Tue, 16 Nov 2021 03:52:15 -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=Uzf6TNNMxMPnOfXBHYbEbeDQIC8p4g1MVfRgzs5DDGs=; b=oKTFvd4w68oBu2CeuPt31sqqYIjNp9IAcQ7NcI6owvfCJYmX6gfLEBtIhuxK/esVRG BUShtrErXbhwl0N3F5y1vzNLm8bzBGb+qUKBYDEpXGohxzSNg3Z+1ik+QjFpZ2Ive+7Y kgILxurA4lyt2wId8zgdPW/qvoKrKIFLn5tRCbu//hAodJmEkp94+YympfrF6+0t4Xzw 2akgbzEimSjJ6cV8zz8hv69AsEEIHbwCEU4ppcPOb6d4aA8Z/zADjAaH4fLri2kIu3HX IPBhXSMMEuDHKaUD4FYqxNWA0TpqElOmD8f+W1waO92gvbgXhHBAIRcTvWuGJHetCN+3 hnAA== 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=Uzf6TNNMxMPnOfXBHYbEbeDQIC8p4g1MVfRgzs5DDGs=; b=ZCDltymwdpFPkgnAKS5EhT5daTtm7m8HulVK+nk5sOFxtyZEp2a5w40rN4c+VXj/WV 31LhRlvo0m4GNjL7tQUG/t9XV6PO4GviGBS1NhcVQ1RtEHzK+zKiXM8il2MxTVbReiUa TSju7/VNo5uxr8IJs6a27iHUDj7pSAkbUBEPB39Y7ROVqYOTut/gHF3zQaAA3WSF5gi3 j3f1UfBjVKx06yvW3ChYpplPZ36B1u0ZgEcTkaJao4CQn6soICwMUFRtGwjL/lxci3pw yh4Zy+beNgohxXXsecm/IXubmX3tUxnruVJiyyjFJaFZk7sKTzGe9bmE49XuXEA/6qxJ +Qwg== X-Gm-Message-State: AOAM532Ls+MCjpPWShU0dPnmEYQOekh706QowgJ1N428LNzG7VLVho37 UwMPiFP9IW0/hGEqglnfJfnusw== X-Google-Smtp-Source: ABdhPJzIvcIdlgIhMAdlJboo29rVKBN0AAQX8dR01v87R/BtaSGuwYHNT8+GzAGQsOFuKHHGbQ/WSA== X-Received: by 2002:a5d:6d07:: with SMTP id e7mr8159934wrq.311.1637063534170; Tue, 16 Nov 2021 03:52:14 -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 b6sm2232846wmq.45.2021.11.16.03.52.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 03:52:13 -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 1/2] dt-bindings: Add Arm SMMUv3 PMCG binding Date: Tue, 16 Nov 2021 11:35:36 +0000 Message-Id: <20211116113536.69758-2-jean-philippe@linaro.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211116113536.69758-1-jean-philippe@linaro.org> References: <20211116113536.69758-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-20211116_035216_234590_5CFEE933 X-CRM114-Status: GOOD ( 13.73 ) 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 --- .../bindings/iommu/arm,smmu-v3-pmcg.yaml | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Documentation/devicetree/bindings/iommu/arm,smmu-v3-pmcg.yaml diff --git a/Documentation/devicetree/bindings/iommu/arm,smmu-v3-pmcg.yaml b/Documentation/devicetree/bindings/iommu/arm,smmu-v3-pmcg.yaml new file mode 100644 index 000000000000..a893e071fdb4 --- /dev/null +++ b/Documentation/devicetree/bindings/iommu/arm,smmu-v3-pmcg.yaml @@ -0,0 +1,67 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iommu/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: + - enum: + - hisilicon,smmu-v3-pmcg-hip08 + - const: arm,smmu-v3-pmcg + - const: arm,smmu-v3-pmcg + + reg: + description: | + Base addresses of the PMCG registers. Either a single address for Page 0 + or an additional address for Page 1, where some registers can be + relocated with SMMU_PMCG_CFGR.RELOC_CTRS. + minItems: 1 + maxItems: 2 + + interrupts: + maxItems: 1 + + msi-parent: true + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - |+ + #include + #include + + pmu@2b420000 { + compatible = "arm,smmu-v3-pmcg"; + reg = <0 0x2b420000 0 0x1000>, + <0 0x2b430000 0 0x1000>; + interrupts = ; + msi-parent = <&its 0xff0000>; + }; + + pmu@2b440000 { + compatible = "arm,smmu-v3-pmcg"; + reg = <0 0x2b440000 0 0x1000>, + <0 0x2b450000 0 0x1000>; + interrupts = ; + msi-parent = <&its 0xff0000>; + }; From patchwork Tue Nov 16 11:35:37 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: 12692757 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 BDFE9C433FE for ; Tue, 16 Nov 2021 11:55:19 +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 7BEEF611C3 for ; Tue, 16 Nov 2021 11:55:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7BEEF611C3 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=sMo35+Z07xvubqK8iQtV1WQEYi3mi/eRatwdELSEEYM=; b=4MDeHW/zb2NOhr 46hV6YJACDt5wjlGtSfptjBB8rybUs05OK+JRGwxh/gu+g95NwmekdCN5ICP8cBcIPwzxFtOc81mS 6/0Icn5N2ZQ8iCH3pt8dY5FQTcq22tzla2iSa+DUHhMsnrzhGqS+BjZzxR8TYP1DBwITM7bBXrfpK u57anXjuGlY16MtntV9lZgWfpGzVStkAJBs0BkwX0ZcHsfv8wiYGvEYdXotWwUvb/zYDZg3bOckqT 6cbmL+dk6Qu5k83QdYfLcp1kGsfxAX8a/gm5LozVuHRTL/xA7JZn8/fU+2nsPTX4+VdbgPQCGCaaG yT8TVwMT9rF0AdgVytGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmx25-001ZRH-Iw; Tue, 16 Nov 2021 11:53:50 +0000 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmx0b-001YXy-6S for linux-arm-kernel@lists.infradead.org; Tue, 16 Nov 2021 11:52:18 +0000 Received: by mail-wr1-x429.google.com with SMTP id s13so37064181wrb.3 for ; Tue, 16 Nov 2021 03:52:16 -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=v+QJmLY5BpY25I0rmG78uwWISNO+pZrvFRBP61oe3sw=; b=uTPfcujUExOV/32d5d9pSrPEzKYFf5z6TJEcXUumrFiczlKJgsd5gWhYVXEnWbQWkD Nt8svDH+tR6/Vny21lKjS0WIx/B3VDusxxiqOwiReFz5tj8CI0gJGH4B1wVSW8X+g8PM LrpWCwYB7cy7ZvlA/Oy5DVIJ5pmrFgnSaYs5lEvGgpy6K/WSaCNB1fOS+hcUuy+xGy2K 9hSjun1Z8ndBPzf47bchnYkViBnhdaF18oPx6QW1W3GVVLvDo6Pu2B30vwJHIyC8NV2k 4lbU7RZ1iuDMosa0hk6fCqaaGQoB2RYQzt5k6nBmJnsoYT6SFi03SX2y+zb5JKdW/7dq /erw== 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=v+QJmLY5BpY25I0rmG78uwWISNO+pZrvFRBP61oe3sw=; b=fLzkyTSAhu2AqDNsf39cOA0Wcq8zdcz0bLZtZFXo44dVpLBEDHLYLuiIp2UKlatk1K xWIDPqZj6oh6auLw2bR9fDLBhNFMr5EI3tL512Ox11VC0JPDJObl5wQVXq/ZIOZtJ4f8 CDldjY8PNQGQVhmJiVcvmj7tjP16DuL5HiNLQ4H97YU5tNMMrDoOY2aUKf43Igi2YKn5 S8VCu1N9flOuwd6WW7+OjNlXGIjqaOH7OF5E5ddFx7X2T+Lstl/ETxdqj0JKDrEt4shb 5rBGqOI9vkaR1biC1SzsAm7tf6u+NUlFay8Am0bYXcwwARgnMIoDuuIIR9xPPTo80fGt e9BA== X-Gm-Message-State: AOAM531apZDhiaw7tp8txLiwkOBu9FTvpSYudbtneF5xE+NBCRHMpWM1 GDaRqCWlQhFlhUGw3RjjVWV7Yg== X-Google-Smtp-Source: ABdhPJw0qnoPTZDC82Hez68IY85kWriu4gxeza20OUJa40OGiN4vAnqPql5KOwe325d01vJPGd55+g== X-Received: by 2002:a5d:64ea:: with SMTP id g10mr8938553wri.242.1637063535219; Tue, 16 Nov 2021 03:52:15 -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 b6sm2232846wmq.45.2021.11.16.03.52.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Nov 2021 03:52:14 -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 2/2] perf/smmuv3: Add devicetree support Date: Tue, 16 Nov 2021 11:35:37 +0000 Message-Id: <20211116113536.69758-3-jean-philippe@linaro.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211116113536.69758-1-jean-philippe@linaro.org> References: <20211116113536.69758-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-20211116_035217_329112_38F053F4 X-CRM114-Status: GOOD ( 18.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 device-tree support to the SMMUv3 PMCG. One small cosmetic change while factoring the option mask printout: don't display it when zero, it only contains one erratum at the moment. Signed-off-by: Jay Chen Signed-off-by: Jean-Philippe Brucker --- drivers/perf/arm_smmuv3_pmu.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c index 226348822ab3..958325ac103a 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 @@ -750,8 +751,15 @@ static void smmu_pmu_get_acpi_options(struct smmu_pmu *smmu_pmu) smmu_pmu->options |= SMMU_PMCG_EVCNTR_RDONLY; break; } +} + +static void smmu_pmu_get_of_options(struct smmu_pmu *smmu_pmu) +{ + struct device_node *node = smmu_pmu->dev->of_node; - dev_notice(smmu_pmu->dev, "option mask 0x%x\n", smmu_pmu->options); + if (of_device_is_compatible(node, "hisilicon,smmu-v3-pmcg-hip08")) + /* HiSilicon Erratum 162001800 */ + smmu_pmu->options |= SMMU_PMCG_EVCNTR_RDONLY; } static int smmu_pmu_probe(struct platform_device *pdev) @@ -834,7 +842,13 @@ 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_of_options(smmu_pmu); + else + smmu_pmu_get_acpi_options(smmu_pmu); + + if (smmu_pmu->options) + dev_notice(dev, "option mask 0x%x\n", smmu_pmu->options); /* Pick one CPU to be the preferred one to use */ smmu_pmu->on_cpu = raw_smp_processor_id(); @@ -884,10 +898,17 @@ static void smmu_pmu_shutdown(struct platform_device *pdev) smmu_pmu_disable(&smmu_pmu->pmu); } +static const struct of_device_id arm_smmu_pmu_match[] = { + { .compatible = "arm,smmu-v3-pmcg" }, + {}, +}; +MODULE_DEVICE_TABLE(of, arm_smmu_pmu_match); + static struct platform_driver smmu_pmu_driver = { .driver = { .name = "arm-smmu-v3-pmcg", .suppress_bind_attrs = true, + .of_match_table = of_match_ptr(arm_smmu_pmu_match), }, .probe = smmu_pmu_probe, .remove = smmu_pmu_remove,