From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752325AbcHIOa3 (ORCPT ); Tue, 9 Aug 2016 10:30:29 -0400 Received: from 8bytes.org ([81.169.241.247]:41849 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752007AbcHIOa2 (ORCPT ); Tue, 9 Aug 2016 10:30:28 -0400 Date: Tue, 9 Aug 2016 16:30:25 +0200 From: Joerg Roedel To: Suravee Suthikulpanit Cc: rkrcmar@redhat.com, pbonzini@redhat.com, alex.williamson@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, sherry.hurwitz@amd.com Subject: Re: [PART2 PATCH v5 01/12] iommu/amd: Detect and enable guest vAPIC support 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 Content-Disposition: inline In-Reply-To: <1469439131-11308-2-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 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