From patchwork Mon Feb 8 16:47:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 8252111 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E66E2BEEE5 for ; Mon, 8 Feb 2016 16:49:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 084D9203B7 for ; Mon, 8 Feb 2016 16:49:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0944D203AD for ; Mon, 8 Feb 2016 16:49:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755774AbcBHQs7 (ORCPT ); Mon, 8 Feb 2016 11:48:59 -0500 Received: from foss.arm.com ([217.140.101.70]:34396 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755041AbcBHQsQ (ORCPT ); Mon, 8 Feb 2016 11:48:16 -0500 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 DADC15F5; Mon, 8 Feb 2016 08:47:29 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.215.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 559A03F5D0; Mon, 8 Feb 2016 08:48:14 -0800 (PST) From: Julien Grall To: kvmarm@lists.cs.columbia.edu Cc: christoffer.dall@linaro.org, marc.zyngier@arm.com, fu.wei@linaro.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, wei@redhat.com, al.stone@linaro.org, Julien Grall , Thomas Gleixner , Jason Cooper Subject: [PATCH 4/5] irqchip/gic-v3: Parse and export virtual GIC information Date: Mon, 8 Feb 2016 16:47:28 +0000 Message-Id: <1454950049-741-5-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454950049-741-1-git-send-email-julien.grall@arm.com> References: <1454950049-741-1-git-send-email-julien.grall@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fill up the recently introduced gic_kvm_info with the virtual GIC information. Signed-off-by: Julien Grall --- Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier drivers/irqchip/irq-gic-v3.c | 43 ++++++++++++++++++++++++++++++++++ include/linux/irqchip/arm-gic-common.h | 1 + 2 files changed, 44 insertions(+) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index d7be6dd..35f11ce 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -53,6 +54,8 @@ struct gic_chip_data { static struct gic_chip_data gic_data __read_mostly; static struct static_key supports_deactivate = STATIC_KEY_INIT_TRUE; +static struct gic_kvm_info gic_v3_kvm_info; + #define gic_data_rdist() (this_cpu_ptr(gic_data.rdists.rdist)) #define gic_data_rdist_rd_base() (gic_data_rdist()->rd_base) #define gic_data_rdist_sgi_base() (gic_data_rdist_rd_base() + SZ_64K) @@ -811,6 +814,44 @@ static void gicv3_enable_quirks(void) #endif } +static void __init gic_of_setup_kvm_info(struct device_node *node) +{ + int ret; + struct resource r; + u32 gicv_idx; + unsigned int irq; + + gic_v3_kvm_info.type = GIC_V3; + + irq = irq_of_parse_and_map(node, 0); + if (!irq) + gic_v3_kvm_info.maint_irq = -1; + else + gic_v3_kvm_info.maint_irq = irq; + + if (of_property_read_u32(node, "#redistributor-regions", + &gicv_idx)) + gicv_idx = 1; + + gicv_idx += 3; /* Also skip GICD, GICC, GICH */ + ret = of_address_to_resource(node, gicv_idx, &r); + if (!ret) { + if (!PAGE_ALIGNED(r.start)) + pr_warn("GICV physical address 0x%llx not page aligned\n", + (unsigned long long)r.start); + else if (!PAGE_ALIGNED(resource_size(&r))) + pr_warn("GICV size 0x%llx not a multiple of page size 0x%lx\n", + (unsigned long long)resource_size(&r), + PAGE_SIZE); + else { + gic_v3_kvm_info.vcpu_base = r.start; + gic_v3_kvm_info.vcpu_size = resource_size(&r); + } + } + + gic_set_kvm_info(&gic_v3_kvm_info); +} + static int __init gic_of_init(struct device_node *node, struct device_node *parent) { void __iomem *dist_base; @@ -908,6 +949,8 @@ static int __init gic_of_init(struct device_node *node, struct device_node *pare gic_cpu_init(); gic_cpu_pm_init(); + gic_of_setup_kvm_info(node); + return 0; out_free: diff --git a/include/linux/irqchip/arm-gic-common.h b/include/linux/irqchip/arm-gic-common.h index 30972b1..bfb10d0 100644 --- a/include/linux/irqchip/arm-gic-common.h +++ b/include/linux/irqchip/arm-gic-common.h @@ -14,6 +14,7 @@ enum gic_type { GIC_V2, + GIC_V3, }; struct gic_kvm_info {