From patchwork Tue Dec 22 19:19:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 58954 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp3433974lbb; Tue, 22 Dec 2015 11:30:30 -0800 (PST) X-Received: by 10.98.14.143 with SMTP id 15mr38405863pfo.154.1450812629159; Tue, 22 Dec 2015 11:30:29 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id mi6si5852661pab.95.2015.12.22.11.30.28; Tue, 22 Dec 2015 11:30:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933549AbbLVTa1 (ORCPT + 29 others); Tue, 22 Dec 2015 14:30:27 -0500 Received: from mail-bn1on0087.outbound.protection.outlook.com ([157.56.110.87]:41604 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933526AbbLVTaY (ORCPT ); Tue, 22 Dec 2015 14:30:24 -0500 Received: from CY1PR12MB0444.namprd12.prod.outlook.com (10.163.91.22) by CY1PR12MB0853.namprd12.prod.outlook.com (10.164.70.11) with Microsoft SMTP Server (TLS) id 15.1.361.13; Tue, 22 Dec 2015 19:30:20 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; Received: from ssuthiku-cz-dev.amd.com (165.204.77.1) by CY1PR12MB0444.namprd12.prod.outlook.com (10.163.91.22) with Microsoft SMTP Server (TLS) id 15.1.361.13; Tue, 22 Dec 2015 19:30:18 +0000 From: Suravee Suthikulpanit To: , , , , CC: , , Suravee Suthikulpanit Subject: [PATCH 3/6] iommu/amd: Introduce amd_iommu_get_num_iommus() Date: Tue, 22 Dec 2015 13:19:14 -0600 Message-ID: <1450811957-1511-4-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450811957-1511-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1450811957-1511-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BY2PR04CA0009.namprd04.prod.outlook.com (10.255.247.19) To CY1PR12MB0444.namprd12.prod.outlook.com (25.163.91.22) X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0444; 2:fSMb8FzLAQ5FppeEnPFIZgIAXin2mCusAk6zLrxHtwzfaqW4YIkGhJYejSw4CK2m+wSn0u785acX/8KDxO8i2di5KpD/Tee/Rf9mVRmQZoE4qPvoHrpAUWoyCpgm2XmJJTD4g83xqSvajZ3/ANMvFw==; 3:DIm1CfcTCUvbmBu8AKBzCHzoF0QW6PhTfcJx1Urkej1LgvK96bfRIc6UQhEtNfTNVo5br1+kJujoTpmyAZ9XjaaU+xTmNNBEdfn2zg7ST3QBkbo3POfl/Q3yA/i4INBU; 25:F521jmn90xmv+89rvhnBd0CT9ElphdxIAM7D/avostnna7blOfN0pQNTKm9mV2swcGbDuEyla+pXV7AFOmGajP4sZGiR1pkourkDeH48f4PPVWllThaOmzngQXlPlG0xnpS85nHd0RBWV4ucBpqRHglGOUEHuPYisAXwjB73hvfgZydycSHkAMNzRVB3MvXLxTfVHIeEiYRD/Jl5x91DphtidZqbjuRRL/Ag/s+aU6NMbIoDZjDXX42tzkwVj/mL X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR12MB0444; X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0444; 20:L1pIsNKLbt8ul/En5pnPiIsyEJx8SybOTaYyoR1HmWpqgc7LwNGK46S9Tn6xZt0DUfcJiIFi7rXxeXpw3YzcFHANcSeNwyHBTWYLUu0+q+/w/nfHMQ97Pdm4nzfWfZb544zf9baSv6koyWG+UlCIW0DFTriDcV4NDdNReiB1uDPuomQXNktlL37n1vXVvPjWy6vczdP1vMwhl3RjTwH4wDvMgmFP0+7+yHHkOdL4+ce83VQlO0ZKxcBgcDwrgj/EeOFFST/0mdUY2IkI3XPapnq3XNFMykhSYUM+J4/AJT3aWs5r7k3TIg7nQpeOeDTKwf++lwVV8NJFOUGf5uhRDJZStkPH/e6XP8W6cACVCaQKgj25WkpzO2RLHfYLQDbIxnWg+08sr1Jx67nUuODe9MvtnaQmhyRHYiCV6jrd0PDNg3UnBIL0e0wYhPaBKqBe9rUqq7bkUnGL4nkHRn3Z56tVC4ch7R5kPDg9j/x3E1N7CeJ9Ki2r8hzjcc5g/2e+; 4:Gbh4MnG3hpmTbFm4UQJEBFKm4Mnoo39QuBJtGANpDV4Ph+SGazl8vp/6v6w6B7XQssvv5OyoFT3J5q7CVCSOVeoT0twymvGAKgP6fX5YfuYIWXHdNBBAEhxUP/JbcH9/5wejuMDSmp8Bqmk0YNU35tcGvCMVloCWwLm9mRnd7T0SFyTctTyr3aG43S2fhjZRiFlRSkh5ADtV4gI+soxCbT3Js7+UanaAjBhB90sE1vMSeN+1oUPljBt7CjjJC3UiSn3Y/id/Lyfmn+cxZseQN7N3hRAyogp4+PxUy94Wz6Wwv6Iov6LPzrmbHLWNpBh2TUd84bbay/fB053q6/+Y2kFlndARTTSTmoeGzFCWjutzj55MrIDagzAfQA4ykMGQnyvqh/3ERc6di8nZVHkJs2Rr1v13P7vMlgo4Osv9VY4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(3002001)(10201501046); SRVR:CY1PR12MB0444; BCL:0; PCL:0; RULEID:; SRVR:CY1PR12MB0444; X-Forefront-PRVS: 0798146F16 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(189002)(199003)(105586002)(101416001)(53416004)(19580395003)(50466002)(40100003)(19580405001)(106356001)(5001770100001)(42186005)(97736004)(575784001)(47776003)(50986999)(87976001)(2201001)(3846002)(48376002)(5003940100001)(76176999)(229853001)(66066001)(86362001)(189998001)(2950100001)(6116002)(36756003)(5004730100002)(50226001)(77096005)(586003)(5008740100001)(1096002)(92566002)(122386002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR12MB0444; H:ssuthiku-cz-dev.amd.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR12MB0444; 23:mKuLLtSi6k+TerCgyXlfyYiP4L4ORiJOUzizw8Zym?= =?us-ascii?Q?0XnLybXM7L8+sqvpfp+gUKfszBFdpPv+h3S66kJwZW8cEg9V/oK2h2Fn1Gw9?= =?us-ascii?Q?lwNBSrr3rpt1t0lccUuZzr+DMveXGqoJj6nqytOKnVVODGt8butrjl3ir2qB?= =?us-ascii?Q?kr+vH4uTzvygJxRY2ayloItCAV48vUv9iWNIeWtxF5nO69GMsSM372CFHINC?= =?us-ascii?Q?xsxzIcoVpYqONANFgDAbjdYyR3cHsnhAg3IsHf5Uk4UxoGHr88HsXQCOomMJ?= =?us-ascii?Q?0H33eNEr8zEdlpy+cEmPK042Jr9im/WLiVi+qaW29YVjZqYhkGXCeGHu3JN8?= =?us-ascii?Q?tJ0iQrtSYdRI+fL1ERa2bUgXal15Hw7N/y+kdADgMZ9bENfsUF5zfkknploq?= =?us-ascii?Q?TFWkGydQ2KP19eXXbUIKQA4WemdDg13ig2or1ay9Dyprbsi2j5ATcpxqi2pr?= =?us-ascii?Q?KHo53a0KwTGekpJOBpMGvz99vdpx2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AzqaRO6xVYrr0H0sdcU6eElrd57bAX5v45VO+2etRkoHFaJ/OpjFj3G2RBh/8NDL+Sz3VKRj6VtYH1+/WyzstZ88WJXcB91fkUVOgQeP+MH2ZHwRND1Zs2wGJs60Dizol3rMglWif74x2og1STC8FitF79oEo X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2015 19:30:18.1728 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR12MB0444 X-Microsoft-Exchange-Diagnostics: 1; CY1PR12MB0853; 2:A7E0Pl9HsGRLqButFYwOggSbdDo1q0yr+lag5IDXTaT5zwrz801QBxgD0gwqt/P/aoxlw1brvPgZm9sYqdbL1PHnz28jwieW0PkZvhWS91oRsVV4TFSvHQ5IPnNy2rlnjLm6YPIA8sUUSrUVNXrrsA==; 23:citMA4OgTK1gbtjCtaH00Ao6xgYhO7/H/2EnTFO79KDOz8A+Pg1+pzdlE2Qy6yP5gLkpGq56MpYltn3an2nPHWJwf9fqY6bfX5u6OUSr2i45Xsi94GPY8MlGMZmbMtStCBXS9zjZ9PNOS5zdU2RK0quj7aKPn71gCdErrqhjfMJjJGPhW+Ui5eF9p25trN3H X-OriginatorOrg: amd.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch introduces amd_iommu_get_num_iommus(). Initially, this is intended to be used by Perf AMD IOMMU driver. Signed-off-by: Suravee Suthikulpanit --- drivers/iommu/amd_iommu_init.c | 16 ++++++++++++++++ include/linux/perf/perf_event_amd_iommu.h | 2 ++ 2 files changed, 18 insertions(+) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 275c0f5..9c62613 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -2244,6 +2244,22 @@ bool amd_iommu_v2_supported(void) } EXPORT_SYMBOL(amd_iommu_v2_supported); +static int amd_iommu_cnt; + +int amd_iommu_get_num_iommus(void) +{ + struct amd_iommu *iommu; + + if (amd_iommu_cnt) + return amd_iommu_cnt; + + for_each_iommu(iommu) + amd_iommu_cnt++; + + return amd_iommu_cnt; +} +EXPORT_SYMBOL(amd_iommu_get_num_iommus); + /**************************************************************************** * * IOMMU EFR Performance Counter support functionality. This code allows diff --git a/include/linux/perf/perf_event_amd_iommu.h b/include/linux/perf/perf_event_amd_iommu.h index 815eabb..cb820c2 100644 --- a/include/linux/perf/perf_event_amd_iommu.h +++ b/include/linux/perf/perf_event_amd_iommu.h @@ -25,6 +25,8 @@ #define PC_MAX_SPEC_CNTRS 16 /* amd_iommu_init.c external support functions */ +extern int amd_iommu_get_num_iommus(void); + extern bool amd_iommu_pc_supported(void); extern u8 amd_iommu_pc_get_max_banks(void);