From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751745AbdAVTxj (ORCPT ); Sun, 22 Jan 2017 14:53:39 -0500 Received: from mail.skyhub.de ([78.46.96.112]:34676 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751634AbdAVTxe (ORCPT ); Sun, 22 Jan 2017 14:53:34 -0500 Date: Sun, 22 Jan 2017 20:53:26 +0100 From: Borislav Petkov To: Suravee Suthikulpanit Cc: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, joro@8bytes.org, peterz@infradead.org, mingo@redhat.com Subject: Re: [PATCH v8 5/9] perf/amd/iommu: Modify functions to query max banks and counters Message-ID: <20170122195326.y5stvlexrobetfeq@pd.tnic> References: <1484551416-5440-1-git-send-email-Suravee.Suthikulpanit@amd.com> <1484551416-5440-6-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1484551416-5440-6-git-send-email-Suravee.Suthikulpanit@amd.com> User-Agent: NeoMutt/20161014 (1.7.1) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 16, 2017 at 01:23:32AM -0600, Suravee Suthikulpanit wrote: > Currently, amd_iommu_pc_get_max_[banks|counters]() use end-point > device ID to locate an IOMMU and check the reported max banks/counters. > The logic assumes that the IOMMU_BASE_DEVID belongs to the first IOMMU, > and uses it to acquire a reference to the first IOMMU, which does not work > on certain systems. Instead, we modify the function to take IOMMU index, ^ s/we // an > and use it to query the corresponded AMD IOMMU instance. corresponding > Note that we currently hard-code the IOMMU index to 0, since the current > AMD IOMMU perf implementation only supports single IOMMU. Subsequent patch ^ ^ a A subsequent ... > will add support for multi-IOMMU, and will use proper IOMMU index. ^ s/multi-IOMMU/multiple IOMMUs/ a/the > > This patch also removes unnecessary function declaration in > amd_iommu_proto.h. This sentence can go away: never write "what" the patch is doing - always "why" it is doing it. > > Cc: Peter Zijlstra > Cc: Borislav Petkov > Cc: Joerg Roedel > Signed-off-by: Suravee Suthikulpanit > --- > arch/x86/events/amd/iommu.c | 17 +++++++---------- > arch/x86/events/amd/iommu.h | 7 ++----- > drivers/iommu/amd_iommu_init.c | 36 ++++++++++++++++++++++-------------- > drivers/iommu/amd_iommu_proto.h | 2 -- > 4 files changed, 31 insertions(+), 31 deletions(-) > > diff --git a/arch/x86/events/amd/iommu.c b/arch/x86/events/amd/iommu.c > index 3f1c18a..ec7e873 100644 > --- a/arch/x86/events/amd/iommu.c > +++ b/arch/x86/events/amd/iommu.c > @@ -239,14 +239,6 @@ static int perf_iommu_event_init(struct perf_event *event) > return -EINVAL; > } > > - /* integrate with iommu base devid (0000), assume one iommu */ > - perf_iommu->max_banks = > - amd_iommu_pc_get_max_banks(IOMMU_BASE_DEVID); > - perf_iommu->max_counters = > - amd_iommu_pc_get_max_counters(IOMMU_BASE_DEVID); > - if ((perf_iommu->max_banks == 0) || (perf_iommu->max_counters == 0)) > - return -EINVAL; > - > /* update the hw_perf_event struct with the iommu config data */ > hwc->config = config; > hwc->extra_reg.config = config1; > @@ -453,6 +445,11 @@ static __init int _init_perf_amd_iommu( > return ret; > } > > + perf_iommu->max_banks = amd_iommu_pc_get_max_banks(0); > + perf_iommu->max_counters = amd_iommu_pc_get_max_counters(0); Align vertically on the "=". > + if (!perf_iommu->max_banks || !perf_iommu->max_counters) > + return -EINVAL; > + > perf_iommu->null_group = NULL; > perf_iommu->pmu.attr_groups = perf_iommu->attr_groups; > -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.