From patchwork Wed Jan 18 20:50:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liang, Kan" X-Patchwork-Id: 45490 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2560894wrn; Wed, 18 Jan 2023 13:02:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXu3rJU2ZQN/Pyg3MBJuSSy1prKmb0jvqEi/kcDPk065pfMNa81lWhafOxX9jqqQduv6Hu62 X-Received: by 2002:a17:907:8c89:b0:871:74c:b1f1 with SMTP id td9-20020a1709078c8900b00871074cb1f1mr13644659ejc.12.1674075756254; Wed, 18 Jan 2023 13:02:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674075756; cv=none; d=google.com; s=arc-20160816; b=oLOJt3vFhbFcwmk0jju7+AoU8h8cTXvFSOEFzqvBxHHMk5/UfdrLFbEcxgJkUZr4+P MdrqlGSpXhwP0y6SCRvXgkWLV9Ump53lkLBRjP7k/fyLnmNoQkXK3WXq4OBIaW/AnBuP C7UlHxwZI5BeWova/5Ea0JsUsawWqWuMRpjpVoihQKnyITH96wuxLSgGYD5SUn6lKoDs fOuOlQc2fJr4Iai5fGa2BOYZygzPtyAb2y6fOJZjVmepCSJEA6GE1cRn18eyVbB7Pv5m IU69wHXXxKmonple3XqBtphAXyt5ycOpnVcdCyhOLkxr/Pof4EFgxf1ndgVghxqIUNAj wM7Q== 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=rwMsOTKFd5HBcOmyCPHBpXd993elanLgSQ4fHzHJU2M=; b=oMSq+ydVpukKHsHXBYrfnMURjDg8BT3prCazlrPBogNat4O28Kq6bp9uTIGSgsWaU3 kn53GnJ2bpnJTcoZTwGN7M/Nv8xbdl3MBcALmBPDA1RASVdJlTpHRrVUTFQPkVewgUFn fMw6rx/utV3N8JGEdNMGNd9lFmXND3dyWc/q25rpqpU3p05ycEpee7lpfDfuSXclYrgs DTTIHhaQw1oLfddlks6AEBNs0NIat0yhghqcDqQxbD+DUkWxmrp7/eto/DdkU/fIQDFS QhxfVRics1F0ls/5Hv3b2O7NcLij6vVKPTNPXMVq8JNoezmr+AajDUQ1/cATBMCHQ/Hc y+Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZJ0mhFx2; 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 hg6-20020a1709072cc600b0086e4b1b433fsi15596604ejc.802.2023.01.18.13.02.02; Wed, 18 Jan 2023 13:02:36 -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=ZJ0mhFx2; 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 S230190AbjARUvG (ORCPT + 99 others); Wed, 18 Jan 2023 15:51:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbjARUui (ORCPT ); Wed, 18 Jan 2023 15:50:38 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E2725FD5D for ; Wed, 18 Jan 2023 12:50:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674075031; x=1705611031; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UUSm4a6ZJ8U7q5K9VrdMYAPG5NJGLTN019sVcMdjlro=; b=ZJ0mhFx2xtTkPAmIxKX+yCKPy+IEE58sdXkgBzWQ9eBwP2ncJw+hHVD2 0FNf6+LO/WaZyqxqAWOoFs4rxSO7BMc2VN09jbMKto9mI6D8K+wVJF0io dDWneSGJKKnVCfTYP/LAtIVVZ3QLKaJ3WZQ9nU6WktUnA6gJReFK/jij0 55eb2s8nNrIVG9PYiRN1ILzdTsY9PkWawHAo+VVWc7A1+epLpNes9Kz+4 QOCiaZAv/HP30d+AjZS7WGtDIC0RSkcw4RMM5c+MgII9Umq+L41z5a546 mFjd09mw2ulC6TTy5dkZHSlRaB8AJptHbxdrp/bNiUaq8lJqwFnls4eqw g==; X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="323784167" X-IronPort-AV: E=Sophos;i="5.97,226,1669104000"; d="scan'208";a="323784167" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2023 12:50:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="833739587" X-IronPort-AV: E=Sophos;i="5.97,226,1669104000"; d="scan'208";a="833739587" Received: from kanliang-dev.jf.intel.com ([10.165.154.102]) by orsmga005.jf.intel.com with ESMTP; 18 Jan 2023 12:50:27 -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 V2 7/7] iommu/vt-d: Enable IOMMU perfmon support Date: Wed, 18 Jan 2023 12:50:06 -0800 Message-Id: <20230118205006.3182907-8-kan.liang@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230118205006.3182907-1-kan.liang@linux.intel.com> References: <20230118205006.3182907-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?1755395660427177007?= X-GMAIL-MSGID: =?utf-8?q?1755395660427177007?= 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 c557c61a28ee..2094f0592536 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 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);