From patchwork Wed Jan 11 20:25:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liang, Kan" X-Patchwork-Id: 42188 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3524308wrt; Wed, 11 Jan 2023 12:34:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXtQz5VyMmmzJSw3PttMd4DfJuT2BgGTEzoQ4/y0JcrTqfud9Ys/8CCVafuwKdAB14FJZG3z X-Received: by 2002:a05:6a20:2ca:b0:b6:4ca8:eb7d with SMTP id 10-20020a056a2002ca00b000b64ca8eb7dmr2935708pzb.50.1673469250234; Wed, 11 Jan 2023 12:34:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673469250; cv=none; d=google.com; s=arc-20160816; b=wxVbGMJwA/78mFeQbonVhPzMBpLja443TqJnmtC68/duUPelGrIjwrqOTDpkEuhfJ3 I6Xo92b6OlbCgvV48ku5OCTe4LO3LAnSs+BxKifiWRSaBuyEAcEq9kSe/8ChQjSgqpod kPPwkpaYKc7/RlN/twrTtGiCX79xJ/ZsAKgPVPKo5YmQdkxFxFu4pgxJ+3rx8fBSxa+9 FlH7T5c4OZc/0fiXu0413GEi9nKJwSCu3bXe3NAf3bVCxBHY/LjonwiJSwdkdHNP4FkJ 2mUbW4swhG5Ua48pAXaFtaB7uwSQ33DBB5HQKJfcV30Kokje2wFJ4YnjEaEKI8uwJkX3 akkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fLF54QdZMiYKwIC5D1w0DyQ0LgPRur4tnYaIbPpMKM0=; b=J7Ui/oPXkxY5bgUDgum6y4g6TfJVXOOkGNmZYU95V375puXm24V+lTL8xswBOR2JX4 qqPUSBnTgjsP1T2ocUjDhS29dMCp2L3v9qUlKqri+S1wtQLcIVb19j6HZE77SdhweCHL R7Z5yqD2P49K2AI+2AitoEL3Eq3WhrBpAz30E7NQ85LJdAFQDWrvnQxbxEf1/JfpmAuj /S3FWPo4ZmB3WK7tmIm9/OMGphzj1WGPwnn1eYsiS0gb2GeGUQ+HJVdS54800OGVrV3E cpgwo8eQUiG4mX1P7I9fgdCaxM1z4eceVaR7eUOw4Q65gzjZ6gvWh3MEFFV3KZeXWNfQ Hb2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cJGBnAOL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i64-20020a638743000000b004b5b1c44f6csi2801757pge.183.2023.01.11.12.33.56; Wed, 11 Jan 2023 12:34:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cJGBnAOL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236169AbjAKU01 (ORCPT + 99 others); Wed, 11 Jan 2023 15:26:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235935AbjAKUZf (ORCPT ); Wed, 11 Jan 2023 15:25:35 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4A001260C for ; Wed, 11 Jan 2023 12:25:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673468734; x=1705004734; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PbKbzo0ebhNuat4Mu85n5Nyk3Ge5hASt79m3RxYgmac=; b=cJGBnAOLXcfKCnhZVlBMpX1MyvB71oCzPIBYYEtMgcGsv3LRaUIphrmr 4Haxm7WSZPqa7fkuLyzmkGZ6agVNb0p2M04NJspw19ISjxuXncSZL6iS9 Um/5HSrswZW5UUca0oMdp/QkX0CB+XIiWhS+UVqhoSdpA3KNimdOfD3sp TEkfUJ9fhE7iKjRPUz2h7Tc5F9zSerTczhgsgZpur4lM+O8x2QfuyYlHS x3cJPq8nRyo4D6jmsJsdarI1zXGoqx+b8PzXBnN8BQYccivywptou5OHw k/4CUNXgplCdwt2N/oIfbhrpz8tMYOs5dF52GhKRkiapseU/wAAdNucO7 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="350755011" X-IronPort-AV: E=Sophos;i="5.96,317,1665471600"; d="scan'208";a="350755011" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jan 2023 12:25:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="781518080" X-IronPort-AV: E=Sophos;i="5.96,317,1665471600"; d="scan'208";a="781518080" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by orsmga004.jf.intel.com with ESMTP; 11 Jan 2023 12:25:28 -0800 From: kan.liang@linux.intel.com To: joro@8bytes.org, will@kernel.org, baolu.lu@linux.intel.com, dwmw2@infradead.org, robin.murphy@arm.com, robert.moore@intel.com, rafael.j.wysocki@intel.com, lenb@kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Kan Liang Subject: [PATCH 7/7] iommu/vt-d: Enable IOMMU perfmon support Date: Wed, 11 Jan 2023 12:25:04 -0800 Message-Id: <20230111202504.378258-8-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230111202504.378258-1-kan.liang@linux.intel.com> References: <20230111202504.378258-1-kan.liang@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754759692568248409?= X-GMAIL-MSGID: =?utf-8?q?1754759692568248409?= From: Kan Liang Register and enable an IOMMU perfmon for each active IOMMU device. The failure of IOMMU perfmon registration doesn't impact other functionalities of an IOMMU device. Signed-off-by: Kan Liang --- drivers/iommu/intel/dmar.c | 3 +++ drivers/iommu/intel/iommu.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c index 94e314320cd9..5a33df9e19ce 100644 --- a/drivers/iommu/intel/dmar.c +++ b/drivers/iommu/intel/dmar.c @@ -1152,6 +1152,8 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd) err = iommu_device_register(&iommu->iommu, &intel_iommu_ops, NULL); if (err) goto err_sysfs; + + iommu_pmu_register(iommu); } drhd->iommu = iommu; @@ -1174,6 +1176,7 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd) static void free_iommu(struct intel_iommu *iommu) { if (intel_iommu_enabled && !iommu->drhd->ignored) { + iommu_pmu_unregister(iommu); iommu_device_unregister(&iommu->iommu); iommu_device_sysfs_remove(&iommu->iommu); } diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 59df7e42fd53..c57e60c5f353 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -30,6 +30,7 @@ #include "../iommu-sva.h" #include "pasid.h" #include "cap_audit.h" +#include "perfmon.h" #define ROOT_SIZE VTD_PAGE_SIZE #define CONTEXT_SIZE VTD_PAGE_SIZE @@ -4013,6 +4014,8 @@ int __init intel_iommu_init(void) intel_iommu_groups, "%s", iommu->name); iommu_device_register(&iommu->iommu, &intel_iommu_ops, NULL); + + iommu_pmu_register(iommu); } up_read(&dmar_global_lock);