From patchwork Fri Jan 1 18:13:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 59098 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp4081082lbb; Fri, 1 Jan 2016 10:24:45 -0800 (PST) X-Received: by 10.98.70.136 with SMTP id o8mr69160456pfi.43.1451672685666; Fri, 01 Jan 2016 10:24:45 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7si19945990pas.227.2016.01.01.10.24.45; Fri, 01 Jan 2016 10:24:45 -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 S1752426AbcAASYl (ORCPT + 29 others); Fri, 1 Jan 2016 13:24:41 -0500 Received: from mail-by2on0075.outbound.protection.outlook.com ([207.46.100.75]:54991 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752223AbcAASYf (ORCPT ); Fri, 1 Jan 2016 13:24:35 -0500 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 SN1PR12MB0446.namprd12.prod.outlook.com (10.162.105.14) with Microsoft SMTP Server (TLS) id 15.1.361.13; Fri, 1 Jan 2016 18:24:31 +0000 From: Suravee Suthikulpanit To: , , , , CC: , , Suravee Suthikulpanit Subject: [PATCH v2 3/6] iommu/amd: Introduce amd_iommu_get_num_iommus() Date: Fri, 1 Jan 2016 12:13:37 -0600 Message-ID: <1451672020-2150-4-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1451672020-2150-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1451672020-2150-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BLUPR01CA041.prod.exchangelabs.com (25.160.23.31) To SN1PR12MB0446.namprd12.prod.outlook.com (25.162.105.14) X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0446; 2:slkpPVFXRROlJ4JuRKPri41paleG8KkWIg9ZkDoDsnCDZLuMIxJo6sHu5mp2WtydUUkRG5YSlCEib2Uho6gh9a5hJT/6hd5rPF9SUIWnS8XN1uXwXM7JvyDbxR/qOnVqVRaTlOuuRQoL4RpwJ34W0g==; 3:9PAHV32lukHGWY555y8F3ry+QVJsvDIKOLkdr5e7Z5iBYO5U0Pbrnb80J4/iTkj6KksxKgBt9tdx7XRN/bvpC4mxpwmmrTk//nhvI2lZSyD+yFzl1og8D2eLKFAAlE9Y; 25:/mHitzb0qSigBDlbDpBJIq5C8cwNB1uZdjk8saKbCcmEa81d7Dduw/5WOXoCGBb6wpHwcnS5xfVuXH1agFDIt9L5Ju0TFsNPILiblIr8mX8KV1thh56+dVtFknN3iK6J+Wjsx+NjKAM0Mpm60JeOh8CQ4G352+pO7RtL+8v/xFTCofQ6idDPh1HaDdm2fCaiB8usBhDoCkAHNC7EGQlF7D2JKF8WW8COtclv8ArvV9kSJvhORKYNgbGzdrIWp914 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0446; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0446; 20:v+k+L5XWD+4Wk1MLq6vNy1fZjiHwFDugYHMAIby3BgpA+IbEyCXNUbKH19D4bwJN6w0gpMcEE5KSMHtLVpRKaUe6PNbQEePxaxXw6gjrIxwVZSBcLar2V51JW4RnXtli52CZSVpVjC6rbtgsyxCcC5WdjHhnS6XFxm9ps+Py+ugJDN7UFlvQmHerRX7/N4dGALZ/MVmCEbutXIEdkSfIA16JrLQ1PLnw9e5HkR2v7CljxE9cHKBxmQMSOdBSKH5lWjQDQHzMrDZAZz8oAcv1REB/F6FG15msgXYum0T8DKJ5VtxKwHCvqPYafkF5QJ9aoVawAImJI2gZlBM9C/X/hrpI7bRa0a4PoTmjyx8UNsil+1lx1VRQf2aWDbVH1HAL0q3/ZWmQmbBWTvLPAjAlyQgyqaQVJSv4V5vpkyR9FHXFdQry96dDbKkh6hgRjCZuWOu6Q+JS7F05tJT8xDQJZt4nBwHMEIxMOCJaC8FwAJUfvAFQQhj0LgiC0D9V9epL; 4:NBb04q+FVedp2+cI2oGyP5z4naahMYZpCuzv7Rli/vLC2F/mhq8BsCQ5awg6DYKo65fmgKdf0fSaAAIdvs0DgFWM16Wz4uSogOroE6+v0FO4PqZHGNlr23qxyGGUArXHE3yoWs5b5f9j5vH+cwHxjJSwyEWSZLzfetaTrEVNHTq1ZnaXuDiLw1L6ikqvBuZ23iyV+pJcQJ/J1Y+B+3iSHf+yERJQyoQfKde5r9ekUJdSZSKGeHk8qlg8BMWtu4mD3KuWp7xsT7tXaLxk+dNzZaEdZpLQz99Hp6coAuTkRdX8xb1Uj1DJrdbJCTjTW9CoZ1Q3PF17RAXcFGB0tFoAhdDDzRz2aMbGFhxr2zdVCD0rln7NcOxbE+fbD3Y1I4ZKQebN9xa+O0jEeUo06w603/xGBWtay5fNNwvikT9f7as= 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:SN1PR12MB0446; BCL:0; PCL:0; RULEID:; SRVR:SN1PR12MB0446; X-Forefront-PRVS: 0808323E97 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(189002)(199003)(5008740100001)(19580405001)(97736004)(36756003)(66066001)(50986999)(3846002)(50466002)(586003)(6116002)(40100003)(19580395003)(229853001)(1096002)(122386002)(189998001)(47776003)(2201001)(77096005)(2950100001)(50226001)(76176999)(92566002)(86362001)(5001770100001)(42186005)(48376002)(53416004)(106356001)(575784001)(101416001)(4326007)(105586002)(5003940100001)(87976001)(5004730100002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN1PR12MB0446; 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; SN1PR12MB0446; 23:QGPhXylpfnNEglLV91Qxt6TVKS/esBrDEwl5S+jtq?= =?us-ascii?Q?+svmdFRm2nXYjCgeAvHKEvHLr/wjzuaeba+Ma2YUvO0A2gAvjveNCFvzcf2C?= =?us-ascii?Q?TPuOh27E6ZiO1FbngG2I83wnhid/ihHesee8ye8EZMI+AfwPveIEzWD5iJl4?= =?us-ascii?Q?Z4GRTRSu0GYA3U7g9xu2ApA2VAbnAbKjwt6qwn4vvOpKPon41dHztMUvSNv7?= =?us-ascii?Q?lW8+wPEXr3K6dZbJqr8KmwGi0xcO4uh456Oui9Qx/u0V23yBphE/sROsiCjN?= =?us-ascii?Q?OcYJyh4jEuzhaSNcTps5NAdDn/4SfUwDtygchA8ZqgANY+3RAsxK5Op0yDYQ?= =?us-ascii?Q?LyBxmSIgUdGo9yxgHh5gCEubhV5m6+5RIXxmYWn46kBRyvsh4xcM3Msh4oLD?= =?us-ascii?Q?7A9wd0LmEKI4tt7cwesNpDijxnubkfyYu0S+OSegcG0wcpvgj1iw5hD9Tpei?= =?us-ascii?Q?l55oLcZ0t1YdCUtfOXQwh6N/bkZnJqOhkXOdSyUh2DGI8WyJJxSSrvJW2Pcc?= =?us-ascii?Q?ofbkXWPDmIFPca8W2zqysYkM1inUXs118f5A3isEbCCnVXEfnvw+b6f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og6NVFo09rFUaz/7tyLzs7AFOA3lqsw6ITeTzuJj0jPf3UlhDn18L0DdREauanm4BhgVjrgGYqu X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jan 2016 18:24:31.0806 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR12MB0446 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 | 8 +++++++- include/linux/perf/perf_event_amd_iommu.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) -- 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..33dbf3f 100644 --- a/drivers/iommu/amd_iommu_init.c +++ b/drivers/iommu/amd_iommu_init.c @@ -1030,7 +1030,7 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h) /* Add IOMMU to internal data structures */ list_add_tail(&iommu->list, &amd_iommu_list); - iommu->index = amd_iommus_present++; + iommu->index = amd_iommus_present++; if (unlikely(iommu->index >= MAX_IOMMUS)) { WARN(1, "AMD-Vi: System has more IOMMUs than supported by this driver\n"); @@ -2244,6 +2244,12 @@ bool amd_iommu_v2_supported(void) } EXPORT_SYMBOL(amd_iommu_v2_supported); +int amd_iommu_get_num_iommus(void) +{ + return amd_iommus_present; +} +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);