From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joerg Roedel Subject: Re: [PART2 PATCH v5 01/12] iommu/amd: Detect and enable guest vAPIC support Date: Tue, 9 Aug 2016 16:30:25 +0200 Message-ID: <20160809143024.GB1437@8bytes.org> References: <1469439131-11308-1-git-send-email-suravee.suthikulpanit@amd.com> <1469439131-11308-2-git-send-email-suravee.suthikulpanit@amd.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: rkrcmar@redhat.com, pbonzini@redhat.com, alex.williamson@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, sherry.hurwitz@amd.com To: Suravee Suthikulpanit Return-path: Content-Disposition: inline In-Reply-To: <1469439131-11308-2-git-send-email-suravee.suthikulpanit@amd.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Mon, Jul 25, 2016 at 04:32:00AM -0500, Suthikulpanit, Suravee wrote: > @@ -2147,10 +2186,16 @@ static int __init early_amd_iommu_init(void) > * remapping tables. > */ > ret = -ENOMEM; > - amd_iommu_irq_cache = kmem_cache_create("irq_remap_cache", > - MAX_IRQS_PER_TABLE * sizeof(u32), > - IRQ_TABLE_ALIGNMENT, > - 0, NULL); > + if (!AMD_IOMMU_GUEST_IR_GA(amd_iommu_guest_ir)) > + amd_iommu_irq_cache = kmem_cache_create("irq_remap_cache", > + MAX_IRQS_PER_TABLE * sizeof(u32), > + IRQ_TABLE_ALIGNMENT, > + 0, NULL); > + else > + amd_iommu_irq_cache = kmem_cache_create("irq_remap_cache", > + MAX_IRQS_PER_TABLE * (sizeof(u64) * 2), > + IRQ_TABLE_ALIGNMENT, > + 0, NULL); Its better to calculate only the size-parameter in the if-statement and make kmem_cache_create use that one. > if (!amd_iommu_irq_cache) > goto out; > > @@ -2403,6 +2448,21 @@ static int __init parse_amd_iommu_dump(char *str) > return 1; > } > > +static int __init parse_amd_iommu_intr(char *str) > +{ > + for (; *str; ++str) { > + if (strncmp(str, "legacy", 6) == 0) { > + amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY; > + break; > + } > + if (strncmp(str, "vapic", 5) == 0) { > + amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_VAPIC; > + break; > + } > + } > + return 1; > +} > + > static int __init parse_amd_iommu_options(char *str) > { > for (; *str; ++str) { > @@ -2511,6 +2571,7 @@ static int __init parse_ivrs_acpihid(char *str) > > __setup("amd_iommu_dump", parse_amd_iommu_dump); > __setup("amd_iommu=", parse_amd_iommu_options); > +__setup("amd_iommu_intr=", parse_amd_iommu_intr); This parameter needs to be documented in Documentation/kernel-parameters.txt