Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752576AbbL1PnG (ORCPT ); Mon, 28 Dec 2015 10:43:06 -0500 Received: from 8bytes.org ([81.169.241.247]:35681 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751548AbbL1PnD (ORCPT ); Mon, 28 Dec 2015 10:43:03 -0500 Date: Mon, 28 Dec 2015 16:43:00 +0100 From: Joerg Roedel To: Suravee Suthikulpanit Cc: bp@alien8.de, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org Subject: Re: [PATCH 3/6] iommu/amd: Introduce amd_iommu_get_num_iommus() Message-ID: <20151228154300.GK18805@8bytes.org> References: <1450811957-1511-1-git-send-email-Suravee.Suthikulpanit@amd.com> <1450811957-1511-4-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1450811957-1511-4-git-send-email-Suravee.Suthikulpanit@amd.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1327 Lines: 42 On Tue, Dec 22, 2015 at 01:19:14PM -0600, Suthikulpanit, Suravee wrote: > 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 | 16 ++++++++++++++++ > include/linux/perf/perf_event_amd_iommu.h | 2 ++ > 2 files changed, 18 insertions(+) > > diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c > index 275c0f5..9c62613 100644 > --- a/drivers/iommu/amd_iommu_init.c > +++ b/drivers/iommu/amd_iommu_init.c > @@ -2244,6 +2244,22 @@ bool amd_iommu_v2_supported(void) > } > EXPORT_SYMBOL(amd_iommu_v2_supported); > > +static int amd_iommu_cnt; > + > +int amd_iommu_get_num_iommus(void) > +{ > + struct amd_iommu *iommu; > + > + if (amd_iommu_cnt) > + return amd_iommu_cnt; > + > + for_each_iommu(iommu) > + amd_iommu_cnt++; It is better to set amd_iommu_cnt during IOMMU initialization. You can just increment this value after an IOMMU has been set up. Joerg -- 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/