From patchwork Thu Jul 14 16:22:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9230137 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 B04666075D for ; Thu, 14 Jul 2016 16:24:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A113427FA4 for ; Thu, 14 Jul 2016 16:24:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95CD328285; Thu, 14 Jul 2016 16:24:58 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8C18327FA4 for ; Thu, 14 Jul 2016 16:24:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNjP5-0003ZB-SP; Thu, 14 Jul 2016 16:22:23 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bNjP4-0003Wk-B2 for xen-devel@lists.xen.org; Thu, 14 Jul 2016 16:22:22 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 55/4E-32245-D3CB7875; Thu, 14 Jul 2016 16:22:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRWlGSWpSXmKPExsVysyfVTdd2T3u 4wZtmdoslHxezODB6HN39mymAMYo1My8pvyKBNWNV0ynGgieKFV+vH2drYJwh2cXIySEksJFR outYchcjF5B9mlFi2tsVbCAJNgFNiTufPzGB2CIC0hLXPl9mBLGZBQolrp99AlYjLOAiceNGG zuIzSKgKvF2ymUWEJsXKP7v6jawuISAnMTJY5NZQWxOAVeJFbs/sUEsdpGY+/Qm8wRG7gWMDK sY1YtTi8pSi3TN9ZKKMtMzSnITM3N0DQ2M9XJTi4sT01NzEpOK9ZLzczcxAr3LAAQ7GBu/Ox1 ilORgUhLl1e5vCxfiS8pPqcxILM6ILyrNSS0+xKjBwSGwee3qC4xSLHn5ealKEryBu9vDhQSL UtNTK9Iyc4DhB1MqwcGjJMIbBZLmLS5IzC3OTIdInWJUlBLnjQNJCIAkMkrz4NpgIX+JUVZKm JcR6CghnoLUotzMElT5V4ziHIxKwrw5IFN4MvNK4Ka/AlrMBLTY2hxscUkiQkqqgXHH47c7+t e94Fxmo8DYyfj8Tfh11/S1rRODTO+5OzEYudruMnq5ZOKhJ5Pf/9VtMdsy63h1kYq92cQm+R9 /627+jFhjNn/blAW6cc+vXT/+fd3HaR2h63u6zvDZBYk+z/VREf+3QjJKIutmU7Jiou/cT7e8 fU4VF+67s+WC0OLmTOvq29xCKepKLMUZiYZazEXFiQA5sYwFdAIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-14.tower-31.messagelabs.com!1468513338!50639261!3 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests=SUBJECT_RANDOMQ X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 24617 invoked from network); 14 Jul 2016 16:22:20 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-14.tower-31.messagelabs.com with SMTP; 14 Jul 2016 16:22:20 -0000 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 1E59428; Thu, 14 Jul 2016 09:23:26 -0700 (PDT) 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 8E7F23F387; Thu, 14 Jul 2016 09:22:19 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 14 Jul 2016 17:22:04 +0100 Message-Id: <1468513325-29492-9-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468513325-29492-1-git-send-email-julien.grall@arm.com> References: <1468513325-29492-1-git-send-email-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, shankerd@codeaurora.org, steve.capper@arm.com Subject: [Xen-devel] [PATCH v2 8/9] xen/arm: acpi: route all unused IRQs to DOM0 X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP It is not possible to know which IRQs will be used by DOM0 when ACPI is inuse. The approach implemented by this patch, will route all unused IRQs to DOM0 before it has booted. The number of IRQs routed is based on the maximum SPIs supported by the hardware (up to ~1000). However, some of them might not be wired. So we would allocate resource for nothing. For each IRQ routed, Xen is allocating memory for irqaction (40 bytes) and irq_guest (16 bytes). So in the worst case scenario ~54KB of memory will be allocated. Given that ACPI will mostly be used by server, I think it is a small drawback. map_irq_to_domain is slightly reworked to remove the dependency on device-tree. So the function can be also be used for ACPI and will avoid code duplication. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Rename acpi_permit_spi_access to acpi_route_spis - Update the comment in the function acpi_route_spis --- xen/arch/arm/domain_build.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 60db9e4..5b2f8ad 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -903,11 +903,10 @@ static int make_timer_node(const struct domain *d, void *fdt, return res; } -static int map_irq_to_domain(const struct dt_device_node *dev, - struct domain *d, unsigned int irq) +static int map_irq_to_domain(struct domain *d, unsigned int irq, + bool_t need_mapping, const char *devname) { - bool_t need_mapping = !dt_device_for_passthrough(dev); int res; res = irq_permit_access(d, irq); @@ -927,7 +926,7 @@ static int map_irq_to_domain(const struct dt_device_node *dev, */ vgic_reserve_virq(d, irq); - res = route_irq_to_guest(d, irq, irq, dt_node_name(dev)); + res = route_irq_to_guest(d, irq, irq, devname); if ( res < 0 ) { printk(XENLOG_ERR "Unable to map IRQ%"PRId32" to dom%d\n", @@ -947,6 +946,7 @@ static int map_dt_irq_to_domain(const struct dt_device_node *dev, struct domain *d = data; unsigned int irq = dt_irq->irq; int res; + bool_t need_mapping = !dt_device_for_passthrough(dev); if ( irq < NR_LOCAL_IRQS ) { @@ -965,7 +965,7 @@ static int map_dt_irq_to_domain(const struct dt_device_node *dev, return res; } - res = map_irq_to_domain(dev, d, irq); + res = map_irq_to_domain(d, irq, need_mapping, dt_node_name(dev)); return 0; } @@ -1103,7 +1103,7 @@ static int handle_device(struct domain *d, struct dt_device_node *dev) return res; } - res = map_irq_to_domain(dev, d, res); + res = map_irq_to_domain(d, res, need_mapping, dt_node_name(dev)); if ( res ) return res; } @@ -1343,15 +1343,14 @@ static int acpi_iomem_deny_access(struct domain *d) return gic_iomem_deny_access(d); } -static int acpi_permit_spi_access(struct domain *d) +static int acpi_route_spis(struct domain *d) { int i, res; struct irq_desc *desc; /* - * Here just permit Dom0 to access the SPIs which Xen doesn't use. Then when - * Dom0 configures the interrupt, set the interrupt type and route it to - * Dom0. + * Route the IRQ to hardware domain and permit the access. + * The interrupt type will be set by set by the hardware domain. */ for( i = NR_LOCAL_IRQS; i < vgic_num_irqs(d); i++ ) { @@ -1362,13 +1361,10 @@ static int acpi_permit_spi_access(struct domain *d) if ( desc->action != NULL) continue; - res = irq_permit_access(d, i); + /* XXX: Shall we use a proper devname? */ + res = map_irq_to_domain(d, i, true, "ACPI"); if ( res ) - { - printk(XENLOG_ERR "Unable to permit to dom%u access to IRQ %u\n", - d->domain_id, i); return res; - } } return 0; @@ -1902,7 +1898,7 @@ static int prepare_acpi(struct domain *d, struct kernel_info *kinfo) if ( rc != 0 ) return rc; - rc = acpi_permit_spi_access(d); + rc = acpi_route_spis(d); if ( rc != 0 ) return rc;