From patchwork Wed Jul 20 17:04:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 9240031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E0D1260867 for ; Wed, 20 Jul 2016 17:04:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA42827D76 for ; Wed, 20 Jul 2016 17:04:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF5B127D85; Wed, 20 Jul 2016 17:04:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5525927D5D for ; Wed, 20 Jul 2016 17:04:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754869AbcGTREb (ORCPT ); Wed, 20 Jul 2016 13:04:31 -0400 Received: from foss.arm.com ([217.140.101.70]:43651 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753969AbcGTREG (ORCPT ); Wed, 20 Jul 2016 13:04:06 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8E4B0BF1; Wed, 20 Jul 2016 10:05:16 -0700 (PDT) Received: from e104803-lin.lan (unknown [10.1.207.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DA26C3F387; Wed, 20 Jul 2016 10:04:04 -0700 (PDT) From: Andre Przywara To: Will Deacon , Marc Zyngier Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 12/15] arm: setup SPI IRQ routing tables Date: Wed, 20 Jul 2016 18:04:32 +0100 Message-Id: <20160720170435.28090-13-andre.przywara@arm.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160720170435.28090-1-andre.przywara@arm.com> References: <20160720170435.28090-1-andre.przywara@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since we soon start using GSI routing on ARM platforms too, we have to setup the initial SPI routing table. Before the first call to KVM_SET_GSI_ROUTING, the kernel holds this table internally, but this is overwritten with the ioctl, so we have to explicitly set it up here. The routing is actually not used for IRQs triggered by KVM_IRQ_LINE, but it needs to be here anyway. We use a simple 1:1 mapping. Signed-off-by: Andre Przywara --- arm/gic.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/arm/gic.c b/arm/gic.c index 12139fe..a0b392e 100644 --- a/arm/gic.c +++ b/arm/gic.c @@ -19,6 +19,8 @@ #define KVM_VGIC_V3_ADDR_TYPE_REDIST 3 #endif +#define IRQCHIP_GIC 0 + static int gic_fd = -1; static u64 gic_redists_base; static u64 gic_redists_size; @@ -41,6 +43,34 @@ int irqchip_parser(const struct option *opt, const char *arg, int unset) return 0; } +static int irq__routing_init(struct kvm *kvm) +{ + int r; + int irqlines = ALIGN(irq__get_nr_allocated_lines(), 32); + + /* + * This describes the default routing that the kernel uses without + * any routing explicitly set up via KVM_SET_GSI_ROUTING. So we + * don't need to commit these setting right now. The first actual + * user (MSI routing) will engage these mappings then. + */ + for (next_gsi = 0; next_gsi < irqlines; next_gsi++) { + r = irq__allocate_routing_entry(); + if (r) + return r; + + irq_routing->entries[irq_routing->nr++] = + (struct kvm_irq_routing_entry) { + .gsi = next_gsi, + .type = KVM_IRQ_ROUTING_IRQCHIP, + .u.irqchip.irqchip = IRQCHIP_GIC, + .u.irqchip.pin = next_gsi, + }; + } + + return 0; +} + static int gic__create_its_frame(struct kvm *kvm, u64 its_frame_addr) { struct kvm_create_device its_device = { @@ -247,6 +277,8 @@ static int gic__init_gic(struct kvm *kvm) return ret; } + irq__routing_init(kvm); + if (!ioctl(gic_fd, KVM_HAS_DEVICE_ATTR, &vgic_init_attr)) { ret = ioctl(gic_fd, KVM_SET_DEVICE_ATTR, &vgic_init_attr); if (ret)