From patchwork Sat Jan 28 20:04:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liang, Kan" X-Patchwork-Id: 49902 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1487256wrn; Sat, 28 Jan 2023 12:18:17 -0800 (PST) X-Google-Smtp-Source: AK7set/92fkLyqjteL0Amipbw6Qhy/cfKZVSn91nxI1y0r9Spwp6QMoJIqseRWQJM9k6gDvT53nH X-Received: by 2002:a05:6a20:3b14:b0:b6:55e:caa0 with SMTP id c20-20020a056a203b1400b000b6055ecaa0mr3026276pzh.17.1674937097008; Sat, 28 Jan 2023 12:18:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674937096; cv=none; d=google.com; s=arc-20160816; b=ykXpLC3A7G8afLhYAcddeRemID8Zs767+H1mWVnRBbSkSFmeoy9CxH7RDDk/iz3MmV OFITLSdEUoS+XGHfpcayEb+vQKr4GH6thjvotiR29UWEPR8z/KKA/+fUji5w3vA9DUjG 7zp17ihjYtNsXV81efvDQsEFFMDY0Ba3qw9dJnwPg4wOJyuqPQXMrp1P79RorONPJMeO viDK1cw51l44EdpHwXx0EjJ+dx6Y2CXEM+ZBvOjo0tEEbPUf+QjMGQQ1whUsQjOx+uaO 7kW9KUek+CHJbj692Krpwj9qwkr+5NmZe1D77mCY7oiHgZCqFaQaGsA1QnxC6ryotNmW m5ug== 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=md4H3lAeJOxy/2DgetE3eqpLxFgmKnIsViis3ebWG/k=; b=qppR/trTTgAPkJYlhdsKS9v5vbDtFq3RICMyrHFe2N54OgZ2xIZzdFE/ygTLSH4p91 vB87xDFH96Mgj391ZnIaNjWzpx878hjuhy1Kas8IowxAL2NGWCi7OuNVeGMqwb7VCp4K ysFQmX5gGEMtdQruDEIqzvXvSaPauCvtIDTyV8rqqAY+PBQ0jnVB+VfeSBCX/hTC2b6V MtYl9uxLUuEipTrUjitazxQiymYJwMTbF3BwzO7rnM3/ovzbz6u4l5YQazb71rLhgP7M Ww9++X1gK2gtzLxnkOCxsTJcNMBflGIOgO4IW+S025uMObr7ehCgPR8dIThtLbkS8lPx wOpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mMIAl8mV; 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 u22-20020aa78496000000b00593115af5a6si4512033pfn.260.2023.01.28.12.18.04; Sat, 28 Jan 2023 12:18:16 -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=mMIAl8mV; 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 S234835AbjA1UE4 (ORCPT + 99 others); Sat, 28 Jan 2023 15:04:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234649AbjA1UEf (ORCPT ); Sat, 28 Jan 2023 15:04:35 -0500 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7DF12528F for ; Sat, 28 Jan 2023 12:04: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=1674936274; x=1706472274; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e/6p+lUBUIA2oZrnZvhOAPE95Uoj/IOijy7wsmhLAB0=; b=mMIAl8mV1zBemt5vIVf09U57oyCJx3GiUbiTcfMNy4Cz+cMTgAadrE7j JCtZIXBt2W6cV/XXs4Rtky6Q6XFrxgKffAgoUble/kmEU5j/DQEDfn4Am FHB6HgF3GP1FGN7GHKCnM93DRL9OPbWGMzwIOWXZOro9TKSqq1kTbJz2C wu+3zx85tmWvMqSlCPGV53qp/CwPspZQ/tqBo2emxJuuC+3qn/+1Edblt tEQrg8WBWmPRAaka0Vf0O40kazGC6unaofJVp9/dx5bTg6ve1sSVw/M/x Kst+q0OaL9Xkc6JJY3PUHTj419h3+IqVXPiMNWSr7L5VFlMwX8phZX0gk A==; X-IronPort-AV: E=McAfee;i="6500,9779,10604"; a="325022531" X-IronPort-AV: E=Sophos;i="5.97,254,1669104000"; d="scan'208";a="325022531" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jan 2023 12:04:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10604"; a="909038382" X-IronPort-AV: E=Sophos;i="5.97,254,1669104000"; d="scan'208";a="909038382" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by fmsmga006.fm.intel.com with ESMTP; 28 Jan 2023 12:04:31 -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: yu-cheng.yu@intel.com, Kan Liang Subject: [PATCH V4 7/7] iommu/vt-d: Enable IOMMU perfmon support Date: Sat, 28 Jan 2023 12:04:28 -0800 Message-Id: <20230128200428.1459118-8-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230128200428.1459118-1-kan.liang@linux.intel.com> References: <20230128200428.1459118-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,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?1756298841350450227?= X-GMAIL-MSGID: =?utf-8?q?1756298841350450227?= 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 43db6ebe8b57..6acfe879589c 100644 --- a/drivers/iommu/intel/dmar.c +++ b/drivers/iommu/intel/dmar.c @@ -1144,6 +1144,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; @@ -1166,6 +1168,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 e9221960e310..6a80d3848626 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -29,6 +29,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);