From patchwork Fri Jan 1 18:13:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Suthikulpanit, Suravee" X-Patchwork-Id: 59100 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp4081160lbb; Fri, 1 Jan 2016 10:25:00 -0800 (PST) X-Received: by 10.66.156.134 with SMTP id we6mr38913723pab.92.1451672699657; Fri, 01 Jan 2016 10:24:59 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oj5si26991935pab.211.2016.01.01.10.24.59; Fri, 01 Jan 2016 10:24:59 -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 S1752486AbcAASYs (ORCPT + 29 others); Fri, 1 Jan 2016 13:24:48 -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 S1752387AbcAASYh (ORCPT ); Fri, 1 Jan 2016 13:24:37 -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:33 +0000 From: Suravee Suthikulpanit To: , , , , CC: , , Suravee Suthikulpanit Subject: [PATCH v2 5/6] perf/amd/iommu: Introduce get_iommu_bnk_cnt_evt_idx Date: Fri, 1 Jan 2016 12:13:39 -0600 Message-ID: <1451672020-2150-6-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:ETEOb/1NDk09kjX34rzr5gDqGpKkxHITKAS8YQJXA2FvfsT/qdj68oyiTIzun99GDJR5UkrM3GqzqzzcIesGYHkjhncB7AUMtU+huXXVC6S1O8aB4VTyqLrATJ0pfXnmIrBzYlmsTagfIpgHwigX0g==; 3:KClEb/KjtkM9Xm1FqqwlZS0gf34k58m4b4PI5B/ImgvfJIkczsJ+1b5hftoXSjEnaHIyN1WFKIhqV4VScwYtxGfjcoL3ssAhyYD+RGng9UDc67pw/FQCHqhqybXKlY0u; 25:QJekLGaRNAkTp5mjFGER/Lm+Ajpn6P4BCWzbcdPvHoQd1NbTZf3Kv8AdBvbgjZS2R0clEO8Ff/G8vFGez18gLTsxA4QCeo/UQGeZLKcY8vfYQUlaw0EdVdn897vdntV0MoCDaAQzvSmSmSt2Qpo7aZc+ciZnIhcZsALLZ+JoU9QwETVqmTMy867otHqiL4yzLaV5yqUm+mc+jZN6BTrz4JpYEksoGxZTz++Fe2NaNPplCYWwQQvLKjZFhieeHs27sVqCuHDG/7lH1yHTezjJmQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR12MB0446; X-Microsoft-Exchange-Diagnostics: 1; SN1PR12MB0446; 20:b18r+nHxNIEEfARYYjEvyAAfk2yHwp82UFJ4x7QPh+WPY+HNeEUbVSbt0vCJ2NTegB6Ob8U7qsGI8OmgVRYGcyxlvdwwUCD64frfv+yMxwMlPSxgIqZYkqfyw55U8qN6pbKGoZvllu5a/IoaC48rCBSw08l7gwsiWtB5V/gfXtJAEjF3Uga1/APgTJmaaniZk/ilMIDKdlIXBDTgVQOfDZpVG5Kd/YA+O+zL49F3IsYUure0jHYtMN/Yx37mYIvMyPuVb1IYojSN3plKDXlpX8xzYqVCgNpQVGZyyCvoASFX5p16KJpt0FJLamj0lm05lvrG3Z1PadQt34myGE8KI0H3lZu2gVYUwNCws0hO+hs0+k30PiXmIUTGjfncjeUzZaEQ1sX1OQCHBQgenOvdi5TEdqJT9G81cL+5sRaCzKGwjZyjAPIq9X6N5D8fC1JGyvDp/JzC1pjmU11ec62brU5MAbA8yZipBV49cABSgW2z4UTBOlPw9uJmmq+ZOogC; 4:2A5ot09mxt2U2P3ccx4u12vo2RoKV7BXNR39rtD+cNAxpXeZMRbcGHlrn3IBLWNbeULTrUyMod3V46ihD8CzcaS1CXND/yfcTk9NrT7waHiOgW/ZJTUl2e/jdabkozlfUsPcJ7eLmDFcVYX1fp576GF2fNntYisKVfuW+EytB1oAmmwVZMfnIpPXWDxYLBuGePS2svz6FhDqXHHk48N4rCSX3cY9fD1mUzdgLcJh1OnK7W86RFyNdQSzSL9/ETJxC6U9S6tunvE7DpCjfTQeCqym72whreVXZHzEKxq3BsWzy1NqRS4rrRHuV63I72arbahua5CoqgFvQzpNmcUIExuzJfhQdRXhbk028E5/bxXNzXdsyEn9dyEBiQDPm7BQD+wbF/7vwcsNKA2R5p6tfzOiwRmi5aI9dwgIbGUgK5A= 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)(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:lp5embI95+KO8/5/TFzfR2cJLZEgmeTtZbZDR1Atz?= =?us-ascii?Q?PipefC8c6HKMoNYZLlzWUA1hIqZrr7Ipj7fFUmziPDjXj4v3VM/3jwJaUpjt?= =?us-ascii?Q?j2k5O/czn++lgMq25BUZhnvbFtTqxefAC6yLdqSSQ1my9jc5U3J6G8xdfhzi?= =?us-ascii?Q?6aQcSLQE4LDj+hJD39G/8b56HyM2w03SrurgnJZdbonqPqcUArxYDqTxd8O+?= =?us-ascii?Q?XyqwBP3e0BcAemdtPGIDjD8WN5y6lDJER+aqVMa8ttuxidoBW6TOJcMfOp4x?= =?us-ascii?Q?3Q7hefztXjKr/PeXxA6D7OxMx7JQy3tgobfANOVSLXz2g9ApH6mS1BpUBTOh?= =?us-ascii?Q?pV7QSoAa1FckzTz0T5AQaueB3i8K7NIW5auZ/5Zl8jTBuCqQDPzLFaXEJz9M?= =?us-ascii?Q?JBhWcCYvUUWNRUBDxJ6369swA2RJYN3S+yE5jphDIVF0wmQmDazLyDDPKq3D?= =?us-ascii?Q?kcpWNaDFP7zyL4hGGXz3EK5zFbDgknSYbWULlW7pb0PZMWMM4UqFeD1WhZ5h?= =?us-ascii?Q?ck0n9EWkrSIeHeUUls0z1Jx1ZMLzMVhsVjMxWMd9Ct03P0XT1U5PQyXN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r02NxxlNpGulYnkiitEfSdeI2bNwb6vm15obK0Uxp X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jan 2016 18:24:33.3307 (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 Introduce a helper function to calculate bit-index for assigning performance counter assignment. Signed-off-by: Suravee Suthikulpanit --- arch/x86/kernel/cpu/perf_event_amd_iommu.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) -- 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/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c index 99fcd10..8af7149 100644 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c @@ -153,18 +153,28 @@ static struct attribute_group amd_iommu_cpumask_group = { /*---------------------------------------------*/ +static inline +int get_iommu_bnk_cnt_evt_idx(struct perf_amd_iommu *perf_iommu, + int iommu_index, int bank_index, + int cntr_index) +{ + int cntrs_per_iommu = perf_iommu->max_banks * perf_iommu->max_counters; + int index = (perf_iommu->max_counters * bank_index) + cntr_index; + + return (cntrs_per_iommu * iommu_index) + index; +} + static int get_next_avail_iommu_bnk_cntr(struct perf_amd_iommu *perf_iommu) { unsigned long flags; int shift, bank, cntr, retval; - int max_banks = perf_iommu->max_banks; - int max_cntrs = perf_iommu->max_counters; raw_spin_lock_irqsave(&perf_iommu->lock, flags); - for (bank = 0, shift = 0; bank < max_banks; bank++) { - for (cntr = 0; cntr < max_cntrs; cntr++) { - shift = bank + (bank*3) + cntr; + for (bank = 0, shift = 0; bank < perf_iommu->max_banks; bank++) { + for (cntr = 0; cntr < perf_iommu->max_counters; cntr++) { + shift = get_iommu_bnk_cnt_evt_idx(perf_iommu, + 0, bank, cntr); if (perf_iommu->cntr_assign_mask & (1ULL<