From patchwork Tue Feb 9 22:53:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 61600 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp2316784lbl; Tue, 9 Feb 2016 14:55:00 -0800 (PST) X-Received: by 10.66.141.229 with SMTP id rr5mr54561120pab.123.1455058498386; Tue, 09 Feb 2016 14:54:58 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id aj1si335308pad.244.2016.02.09.14.54.58; Tue, 09 Feb 2016 14:54:58 -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 S965061AbcBIWyr (ORCPT + 30 others); Tue, 9 Feb 2016 17:54:47 -0500 Received: from mail-bn1on0078.outbound.protection.outlook.com ([157.56.110.78]:32600 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965012AbcBIWyi (ORCPT ); Tue, 9 Feb 2016 17:54:38 -0500 Authentication-Results: 8bytes.org; dkim=none (message not signed) header.d=none; 8bytes.org; dmarc=none action=none header.from=amd.com; Received: from localhost.localdomain (58.10.104.205) by BLUPR12MB0434.namprd12.prod.outlook.com (10.162.92.14) with Microsoft SMTP Server (TLS) id 15.1.403.16; Tue, 9 Feb 2016 22:54:30 +0000 From: Suravee Suthikulpanit To: , , , , CC: , , , Suravee Suthikulpanit Subject: [PATCH V3 3/5] iommu/amd: Introduce amd_iommu_get_num_iommus() Date: Tue, 9 Feb 2016 16:53:53 -0600 Message-ID: <1455058435-8716-4-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455058435-8716-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1455058435-8716-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [58.10.104.205] X-ClientProxiedBy: SG2PR03CA0004.apcprd03.prod.outlook.com (25.160.233.14) To BLUPR12MB0434.namprd12.prod.outlook.com (25.162.92.14) X-MS-Office365-Filtering-Correlation-Id: a7d6c2e3-b287-4dcd-9383-08d331a3fa6a X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0434; 2:2R/ccf1gNvEOYSgzzhT8A8BZvQDcotjcgRnbEgl/kL32++mlub8UDwTsPtAyfiVnARXLAWF9QcAP3tHGPPsAFgJ/bxUeHs/vMW7yzHfOprF8fL/snUFYKN/CnRNjxVU4yALiYoz5ZV91MRPKDLc7OlZQfJXEg9FofdVJ0BUo6HDPX61+JBq42MEr03+zx0L3; 3:tTUvIxFelHb8xYnBavGPuI9BAmgeK0O+o7JtJT0kmWB4pTvmHgnNiChi0hY9SXSLwd0sd3fDpcO+Dq0NFyoGfiJwqEa9MLKskBOZLeSjeO8UNGYCfCmj47p9D6BIFYJd; 25:hcS9v3gfjmoO0ho6lsAg9zlJMsfjYvyglrGgA40kHGlHA3Ta59zQ6z0qJ4yLD20D01SSA0M2oLY1wblCxHDo8c81xOv2rG8jyzROtBWvk1vJWJy2cMokjAoTyzrgMUMUfZ7bqArpQgrrJhEx/Q4XgDIDedbL6PhbCMubLIobezmcGxTtSnkUyb1uv1gHyg1/6He2sd8IGg8PuETR7II3oh3byNj0ecNNPzoFURkF1yASsYYilT3DiBmn1zE7Ym6LVvIsy7WrDXuryOPj1ql47k+R08XhetB0RwWMaH8kyG1voans5XTb/SNLCrx9GwqI X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR12MB0434; X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0434; 20:GXH6zlWhVCyE3drqNS7Pi4da1E4UyglH3Ktt+KiwXyIfLMn7LWlUKRGV91XEpwR6SJSWoHc1dEuU5xeMm1E2kiRvYoRu+LwQISynVzJs5febYXGnEzdogoF+nffokpbKD/a5CuyDtnwECTD08DdzEula90LdmQeR2pIUPAjFqiN8+IExNAnyiaitWb4cbeOhXCh0P8Si89IaT1DTPAfXEVsdfcGT0wWjigQqqb4dby0N3BDNnAZFnLXV2CoGWNKT1svOmVq+iO3FCAN0nb7asfk/x9ylow+o9Lv50erEXkRMSfX7I9V60NzA50fWeLp/QS8mupNuGAOA8OUR+mxmBCwyG50lSlohHlxHu5PItD4H2SuJOfIC1m6+ItmNQCTbAZo/7YI22QwMWsCWU1CPz09UpiBmSR6mdYyKSvxHGkhAYI76VA89pt89phTnhK4eLHV83xxsAm5m/unNfyL8qlxNrUXl1OsnF78Ep0MfL5TkOqw2W7elngh9oFkeSj8u; 4:L8qk8XiG13zXuQ0Jg2R+ns6SgPBr3KVklh9SRZMZHl64zzdq/HGTuirTegRLeWhP4i2DXMYvXoiifLAiuspBdrxHKiTSTBjXRAP5pWrxgm8EUkWtLzKO6SmripZXZZOkf6MXPudrVdrwnkJwRTnC6RyuayzAG1ih3HN9tsNdqE1RX4ApEDdE3DPkfBWhLq0S8yFdYknqXoDyaP/4XsEi8tNz/5kINjYpFMyTQoMycAt5bvx6jTOolEh3uvFrT+iKvNP32A0ZRX81nlfEHZd4zsApKCBBkQPAGTlnb1SZJ9OuwFifQwySbrJPPSGSqyJMn1xXgkjwGbYiKVvqW5Wt+Aeq58pQrwz1puk/DCJu1oixLRguSGtJGhPxkbLT7j4RKgMPIexzh2W555wSCvp9wElJas1yqWE/hoHY4wAauS4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:BLUPR12MB0434; BCL:0; PCL:0; RULEID:; SRVR:BLUPR12MB0434; X-Forefront-PRVS: 08476BC6EF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(19580405001)(19580395003)(48376002)(122386002)(36756003)(77096005)(5001960100002)(5003940100001)(92566002)(86362001)(575784001)(50986999)(42186005)(76176999)(2906002)(87976001)(40100003)(5008740100001)(189998001)(4326007)(5004730100002)(50466002)(47776003)(66066001)(229853001)(50226001)(5001770100001)(3846002)(6116002)(1096002)(2950100001)(2201001)(586003); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR12MB0434; H:localhost.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR12MB0434; 23:sgGU8jQrHh6fXtx0XwT/Ib61pEH7BLK8OcOmAxwxw?= =?us-ascii?Q?fQCodCDcHd5/tSVyfA7IACchKdK0EPaIyVmqXqVr2k1rLHU8/tdSIm6/MEKE?= =?us-ascii?Q?rLtIoBom5EXtdh/N8ieX318adp0AlpU+gantp9nGJ/+pSqv7tK5WK966ryso?= =?us-ascii?Q?vzT0iVlaET5m1D69RQIiPA0lCV6s7Rb31jj9VEoOdV+e3dZJ5QxKKmh9O3E0?= =?us-ascii?Q?k1VK59uzLBcbVUZleJyNO4FnOU1GWuQWEZ+18KuLev1HCnwLFHFID4aMRBn7?= =?us-ascii?Q?tDNGo8Qi7KK7Qz+uScsvgq3/zETpIABaUolY77OhYMxW/MRRJCttdEnQdrEC?= =?us-ascii?Q?q58Amz9ebxGvEBJZsvjmyWtV+x2Cz8+mN1g3WHKciM85cDcJ6i23rKyRQm3O?= =?us-ascii?Q?KlYpEY9WNnSkPlTPoeLnthlwqziQ8JuyRnERsX3Le785CAOH1wW2TRYyfK+3?= =?us-ascii?Q?EaFG+CXbQBD+Kz27YWkMkcNgBHeE62IFal8MDsVcWJK4nMngC8pUApOQylPS?= =?us-ascii?Q?ttl9Eyigy1wCoX5MVv/Eyb6EKUsKcBgl6PqXkIFJsUsXwyXLISHr8UpnWwSu?= =?us-ascii?Q?APPAzyejTXcT1vZwwycf9gqvan86GXXUHZI9KB+Q4BQnocJdwK0EWFWXUeMy?= =?us-ascii?Q?/VwmH+RNE6waf3+uCB579q2Oqunjh/CqJapM8VDK5Gui/IGisAeE2pyguke6?= =?us-ascii?Q?9ONNr3miWwMcLENWUwJMuatsLp440VnmBAADTSzBW2LypsXb0iSt8SxCP8sq?= =?us-ascii?Q?lf5VsJX0X5gtAs/nMYgp/1cQBZ0kRx9bU0ZkV33VvAmfpHmqnbGugFVEIE94?= =?us-ascii?Q?diPsxvIGjrcDGWDGHqZC8uFJQpg9HCplos3FcKZZczCcUGm1LgFB75TqIKQ3?= =?us-ascii?Q?qvTYIcbI7Eu0AiKoYY001EBVR0mxzArMV9HRGfclie5asDvzerAvcmHV3Ycu?= =?us-ascii?Q?glLw0R3XC1hSASHYJVgThhvIMvirhk+w8zJx9DVWQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0434; 5:bjLnaI5FHOm9CLQY5JEUKisRcbUx0ArhoLCcANJfuRVLXCz/dp4ZN3Hrn1P47txcG1uCbs+kWSEQxBzvUHakymAjqndqtu0yNWPYHVuEFmMJHrLNZ7GWy0mYP952w2KnJIOOqY+g45D8Fsnl2Z5kGQ==; 24:Z7dmumA3jKdoWjm8bo0OzA0jaaZkhp6KHumN11C3bmxVfWYhdv7VcX97PABm6KlBFRIz6cN6NjuM3eKNsz6g08IhTMBFdA8zJepn2MztVLg=; 20:tw93s82oxbfDZQ8c750d6k8KFxWPyhncDC64bujcfzuTe4Fgz8JyvInnVxPZH4rol7s+ROzL8cZrXW2309RXGKTsN2Npy4C9yld180zxmBu1Sgt3DUqEqcSOduMbBjKxZ1bw+ymw6+qa5kAlxHriSWvrk6SZMjeKojtehioAkb87zrcDGlzhHjoEaY67wj58Nyz3EQLjO7H8ERMgh50w5ZwJFMRtRpG67nz2dDCV3jQfg39H+D139y+k8WpQ5ot7 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2016 22:54:30.7589 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR12MB0434 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 | 7 ++++++- include/linux/perf/perf_event_amd_iommu.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) -- 2.5.0 diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index 275c0f5..531b2e1 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,11 @@ bool amd_iommu_v2_supported(void) } EXPORT_SYMBOL(amd_iommu_v2_supported); +int amd_iommu_get_num_iommus(void) +{ + return amd_iommus_present; +} + /**************************************************************************** * * 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);