From patchwork Thu Feb 11 09:15:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 61705 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp77697lbl; Thu, 11 Feb 2016 01:16:30 -0800 (PST) X-Received: by 10.66.150.170 with SMTP id uj10mr20946197pab.73.1455182190391; Thu, 11 Feb 2016 01:16:30 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ll4si11349993pab.207.2016.02.11.01.16.30; Thu, 11 Feb 2016 01:16:30 -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 S1753463AbcBKJQY (ORCPT + 30 others); Thu, 11 Feb 2016 04:16:24 -0500 Received: from mail-by2on0072.outbound.protection.outlook.com ([207.46.100.72]:12056 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751915AbcBKJQR (ORCPT ); Thu, 11 Feb 2016 04:16:17 -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 (124.121.8.20) by BLUPR12MB0435.namprd12.prod.outlook.com (10.162.92.140) with Microsoft SMTP Server (TLS) id 15.1.403.16; Thu, 11 Feb 2016 09:16:12 +0000 From: Suravee Suthikulpanit To: , , , , CC: , , , Suravee Suthikulpanit Subject: [PATCH V4 3/6] iommu/amd: Introduce amd_iommu_get_num_iommus() Date: Thu, 11 Feb 2016 16:15:24 +0700 Message-ID: <1455182127-17551-4-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455182127-17551-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1455182127-17551-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-Originating-IP: [124.121.8.20] X-ClientProxiedBy: SINPR01CA0021.apcprd01.prod.exchangelabs.com (10.141.109.21) To BLUPR12MB0435.namprd12.prod.outlook.com (25.162.92.140) X-MS-Office365-Filtering-Correlation-Id: 9ced2be2-c9ff-4b63-120d-08d332c3fe3e X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0435; 2:ZNXnUNgM4lDgNvYot4l8BQPhx3rsPhRUaYpSOCdw1ARUV+sDOC+7zQD7Ew5Bg7gupE2H3HNL8MjbcyWZCF9TBHoQio/Q1cE7U8H3FcKT5fKzsBV4wniQH3QVRB5dLy6VyoRFUJLOEqmOe6SVDvBtO8mwQhR/ey8pj0997nNUz5j6tviyiJc1tAwFtGs/U/SO; 3:8a+IKwSHIhw5Y0EK3LuaA/FCRDa3XH74JTR1sl1iNk95N8YcJbQ3ZLY1ICL2XutJSj7yU/EB4KzeWoyi9nXPg02feHldxL72aiJWb+zFzhDKnKtAqGpCVTaj/EZ0+198; 25:z3cqyNRaY/lXv3ZQXlC451gsFJQTOoNrA+NlzlEggskxs1avQF7Q92VdVtFuis6Oj5fUO7xjRV5UC2cDyGraGxQ8UCQox0kvaz8CklvWH9cEkFoYM+laxSOuayy/bYA/tp3fL/k/Q5qTqfsqGLElAHWBAaz28PMveL0SDvXlhzuHN98alTI2Ku6nB/2kZjssQl/k8RWbiekC3T66UsehJ+Xu1T1xJEIqCAGJUN8TJ3ykCfTrelnk1GKstayRrjqA7S+mrt6+EdHtdCij3VQfdBhUAqhOdLyaIWa9lRuKpelPmCnCLIYmKXB8vE8pRxIV X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR12MB0435; X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0435; 20:rmJWw3yOZ8yS2mei6jhz95srrJ9chdZrPDK1nmQ1xJIjGp5a6NVE+qe1icknRj7/7xbrr2T90ekaGEikq1jHeWQpz7kNDdq9KoMMIVphvl3i+gsEf3rxUsZ8L19mdMi12rd/t6MRJLvpJJ6212ykNWZVClynk8CXTOO5Bdgo3cWFpdqZCLCPZQf4FTSUrRE21jb1HIWQev3NTYFghrKB06a3yYragj7qRibZspdQnEfrmDH3LyTV3EwQrOX5q2xlUhIUyoIXjtiuBd6w8tSqGt/TvxneQb7liUFQlTuGJlA8Lx09WHw5QaKze1OGTyq4T6PcHz+Z3BQYfx6HUzZk8FXl6ykignJ88XzCShjQ38wr+Q4vvhJk3Q0iDXTFzJUiSgIqgcNv34G5dXx8EnJU2WJZYzwLBtHJ6qxYT+ElMSsfq4YEDZ5P9+pudtEyijVO3u8dmV5ObniNuU5cKIljjXtoKzT7EaHAeKiSrluOIJQ1T6HnfSnmrUiS3ojpCVu9; 4:bzFG8DTK0RIg+7I401l6wb5xOFrjoTMpRoMKI6GCj5ag92H8D7F7ROYvJ69hcnrwO7iVWXGpundlFJ21UzynxI6fA2ZcIPNhqizvSCszAj55BAyf/EQiAIMXlCXWXE67iJP3iDARN+IeKv1asVXLfANOZuJH1htkUM0uer0q0PbLklxarjZ+DJfzDP0SYMegKqidQJBnUf7QA0ESpLqhTk9mrr3wwJy+NCl0wj1jewCBLqfa3AyYOIrvrDAyrCfnK+z39oxjC557UQZBWnkG7SDTefk8OpxH+ROqu9rlBsNQCFMQfPuTJlKq1sLMRgKx1B3rQZULsSiEzaRRUfQowz3ZxORbME7kHlOpfRiOq+xJQ3pvJhNMcSFeT+XLBf++NiZlHZG07H+XyZPVNS8DeA== 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)(10201501046)(3002001); SRVR:BLUPR12MB0435; BCL:0; PCL:0; RULEID:; SRVR:BLUPR12MB0435; X-Forefront-PRVS: 08497C3D99 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(6009001)(50986999)(42186005)(5004730100002)(122386002)(2950100001)(19580395003)(77096005)(2906002)(87976001)(40100003)(229853001)(50466002)(2201001)(36756003)(19580405001)(5008740100001)(92566002)(50226001)(47776003)(6116002)(86362001)(66066001)(4326007)(189998001)(3846002)(5001960100002)(76176999)(48376002)(5001770100001)(586003)(1096002); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR12MB0435; H:localhost.localdomain; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0435; 23:CHOD8eZim3p+WijE1k63lvJe1tF2lUPPfUtuXrUHySy3DquRYjlhcV6MYYJDO0Nvo+SeMIWL+jtIGKh+Nh0wRmbjuPH5gMc2kPZpPTA1uDq6dibztYf3R+yXMNhEXiDbTGvJ4HGR3ovQ+hpaURmMMFdKMM0IXZecsSYsAbdk2O8mOAbNGhattcVKUXpZODgvfD9mHB8LZocYfZvcuXb7/9+1RGYTDJdv19PeGMQE1j9QNGoCJwKmXaorVaQrc3jvXEq8zUwgcKBJDormKxK8f8WiSMZkTN8AXfGJvZcGMP6IkeOEJ6AEKk9N9OTXDPl8AYRUmQjT/hkzYuDgW++hCQyrOI1OuvatGeN+9FewMyOr+GSBnc+aoOLBwIZ6YqyKHsWF/Pw+/2yVQV5+JjlHGP5aEshT2dPhVToVGzFB0NIXlrbL/C2XibzsjSGIRKYc2tZfaCKhSAh2jJdW05bxCgIERXRc6F2CFsjZ/ZnRHJXmA0keOIFDCxZlBMZWw5AayQfuCm6soGX85PHCu4DuLpFoC80qj6PVlswxOqFGyLk3dhXr0Ecp9lAtWpOV5+y1R7xHJnZOqkfEatTb72qHHR30j0xzn2XGhRX3tX5C0ANGQvnR1NMIcPjoZmCEqqIOXPUtK+b4Yiu0xIAYYEnrZRSOeyHNcEdJqP2+kIDJKsaoJSIOuhNi50PVUfxDDb71GgNH1GeS5Em5wo7KDvBcCDEwA/o/Hs6aCmeSjEnCtu7eEv6kyvQa2yA6IngAh5cB1AuJ0WdYBFsI0eTBitI1bZ4DdlsNoj2LuSMrqBxWIC8fUXhUpE3lKVhSC2SuE6VGDNE2hDjJgrUQU9fNvZvN30QYMAfgPKCUZEB3tYYaKhNe9POGCT1BXQfHIY4f+ag5wju6F97M2M5cyv+QI52xXg== X-Microsoft-Exchange-Diagnostics: 1; BLUPR12MB0435; 5:zyPkWkjr+xYtuKY9ib7B8tTAA5irtQ0Tbz72mALRiz1/p9gUvpTFBYCL7fvnhKhLbSWmKRMpiRpp42Op1MsPonm0w3eo42RTML819cCCpQ8Zw8zfd0bQyUUaGFFhvfUI5nPMX0cUhZy/f3Q6ZzrrTw==; 24:rjieu7tCnzNheEP6GTPt+cAdUU+m+A+ZpZsCfN0l55tqCYHq4WG+tHvY9EjiX+0Arc00KBH1bYlsQWISpe2ZqOqFgU2otJteDI4Va65Ah/E=; 20:9ThQUT/MhLbaevLoG+h8qx7lzZOwAPzKiV8T5dyaeEBIPgaIbrBaFAjdbyjbUVsok0wOZIH24QjK2CPXvDyrZn99qYdVMbHQ5BwpTGI3NFw1rpAdZzHuaJlGnwS5BcWlj2pF+fDvCJOmq/a2EtiC8BhMhe3l+bawx+/LgqEXRtvmpxrNRtSVzXQxcjckirdx8ehCnLmnD5mXevVm64kPvDLKmxGgZvBGPcu3rzu2MiphOaF/30TrrzFbKggbCaCB X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Feb 2016 09:16:12.3925 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR12MB0435 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 --- arch/x86/include/asm/perf/amd/iommu.h | 2 ++ drivers/iommu/amd_iommu_init.c | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) -- 2.5.0 diff --git a/arch/x86/include/asm/perf/amd/iommu.h b/arch/x86/include/asm/perf/amd/iommu.h index 97e1be5..40919eb 100644 --- a/arch/x86/include/asm/perf/amd/iommu.h +++ b/arch/x86/include/asm/perf/amd/iommu.h @@ -25,6 +25,8 @@ #define PC_MAX_SPEC_CNTRS 16 /* amd_iommu_init.c external support functions */ +int amd_iommu_get_num_iommus(void); + bool amd_iommu_pc_supported(void); u8 amd_iommu_pc_get_max_banks(void); diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c index a62b5ce..ffa057e 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