From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756152AbcCBAgz (ORCPT ); Tue, 1 Mar 2016 19:36:55 -0500 Received: from foss.arm.com ([217.140.101.70]:55500 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755392AbcCBAgw (ORCPT ); Tue, 1 Mar 2016 19:36:52 -0500 Date: Wed, 2 Mar 2016 00:37:02 +0000 From: Will Deacon To: Andre Przywara Cc: Sasha Levin , Pekka Enberg , kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] irq: move IRQ routing into irq.c Message-ID: <20160302003702.GD14022@arm.com> References: <1456850978-14091-1-git-send-email-andre.przywara@arm.com> <1456850978-14091-2-git-send-email-andre.przywara@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1456850978-14091-2-git-send-email-andre.przywara@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andre, On Tue, Mar 01, 2016 at 04:49:36PM +0000, Andre Przywara wrote: > The current IRQ routing code in x86/irq.c is mostly implementing a > generic KVM interface which other architectures may use too. > Move the code to set up an MSI route into the generic irq.c file and > guard it with the KVM_CAP_IRQ_ROUTING capability to return an error > if the kernel does not support interrupt routing. > This also removes the dummy implementations for all other > architectures and only leaves the x86 specific code in x86/irq.c. > > Signed-off-by: Andre Przywara > --- > Makefile | 4 +-- > arm/irq.c | 9 ------ > hw/pci-shmem.c | 2 ++ > include/kvm/irq.h | 5 ++++ > irq.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ > mips/irq.c | 10 ------- > powerpc/irq.c | 31 --------------------- > virtio/pci.c | 18 ++++++++---- > x86/irq.c | 45 ++++-------------------------- > 9 files changed, 108 insertions(+), 99 deletions(-) > delete mode 100644 arm/irq.c > delete mode 100644 mips/irq.c > delete mode 100644 powerpc/irq.c [...] > diff --git a/x86/irq.c b/x86/irq.c > index 72177e7..49b2e90 100644 > --- a/x86/irq.c > +++ b/x86/irq.c > @@ -11,20 +11,15 @@ > #include > #include > > -#define IRQ_MAX_GSI 64 > #define IRQCHIP_MASTER 0 > #define IRQCHIP_SLAVE 1 > #define IRQCHIP_IOAPIC 2 > > -/* First 24 GSIs are routed between IRQCHIPs and IOAPICs */ > -static u32 gsi = 24; > - > -struct kvm_irq_routing *irq_routing; > - > static int irq__add_routing(u32 gsi, u32 type, u32 irqchip, u32 pin) > { > - if (gsi >= IRQ_MAX_GSI) > - return -ENOSPC; > + int r = irq__allocate_routing_entry(); > + if (r) > + return r; > > irq_routing->entries[irq_routing->nr++] = > (struct kvm_irq_routing_entry) { > @@ -41,11 +36,6 @@ int irq__init(struct kvm *kvm) > { > int i, r; > > - irq_routing = calloc(sizeof(struct kvm_irq_routing) + > - IRQ_MAX_GSI * sizeof(struct kvm_irq_routing_entry), 1); > - if (irq_routing == NULL) > - return -ENOMEM; > - > /* Hook first 8 GSIs to master IRQCHIP */ > for (i = 0; i < 8; i++) > if (i != 2) > @@ -69,33 +59,8 @@ int irq__init(struct kvm *kvm) > return errno; > } > > - return 0; > -} > -dev_base_init(irq__init); > + next_gsi = 24; Can we not just have an arch-specific initialiser that defaults to zero, like we do for wired interrupts? (e.g. KVM_MSI_OFFSET). That way, we can keep next_gsi private to the common irq routing code. Will