From patchwork Tue Jun 7 16:48:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 69560 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2075586qgf; Tue, 7 Jun 2016 09:50:35 -0700 (PDT) X-Received: by 10.31.167.84 with SMTP id q81mr177289vke.51.1465318219626; Tue, 07 Jun 2016 09:50:19 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id b93si5088856uab.11.2016.06.07.09.50.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Jun 2016 09:50:19 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAKBf-0000Uo-Qc; Tue, 07 Jun 2016 16:49:07 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bAKBe-0000SC-CD for xen-devel@lists.xen.org; Tue, 07 Jun 2016 16:49:06 +0000 Received: from [85.158.139.211] by server-3.bemta-5.messagelabs.com id DC/DE-15735-10BF6575; Tue, 07 Jun 2016 16:49:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRWlGSWpSXmKPExsVysyfVTZfxd1i 4wZYtLBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0bXpE72gpOSFVOv/GdsYOwX7mLk5BAS2Mgo MeNSYhcjF5B9mlHixqq3zCAJNgFNiTufPzGB2CIC0hLXPl9mBCliFpjHKHFm4U72LkYODmEBe 4krD0JBTBYBVYmmpSUg5bwCzhKbes6CtUoIyEmcPDaZFcTmFHCRePn8JQvEXmeJBw27mCcwci 9gZFjFqF6cWlSWWqRrpJdUlJmeUZKbmJmja2hgqpebWlycmJ6ak5hUrJecn7uJEehbBiDYwfj 9j9MhRkkOJiVR3qffwsKF+JLyUyozEosz4otKc1KLDzFqcHAIbF67+gKjFEtefl6qkgRv1A+g OsGi1PTUirTMHGDwwZRKcPAoifBmvQNK8xYXJOYWZ6ZDpE4xKkqJ8+qAJARAEhmleXBtsIC/x CgrJczLCHSUEE9BalFuZgmq/CtGcQ5GJWFem+9AU3gy80rgpr8CWswEtJjlK9jikkSElFQDo/ I8h4j3p6+ovmp798Fs44SQK4cDK8NyX/ZWsbx+eizh7PystBsfT2uszjLfduQLT5Xr2tNVPSd jn7283bH1gdla88Zl7bcfP/xyZN4KlW9XcsRYlN+IxKhpz2HpUt3xb9ZmmVt76tgO90wVM3/g kCL5ok53WVPa66z1+198NXklrvv63byKB1OUWIozEg21mIuKEwFcLeB+cwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-8.tower-206.messagelabs.com!1465318144!43482792!1 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.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 45120 invoked from network); 7 Jun 2016 16:49:04 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-8.tower-206.messagelabs.com with SMTP; 7 Jun 2016 16:49:04 -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 9E6852F; Tue, 7 Jun 2016 09:49:38 -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 E67B63F246; Tue, 7 Jun 2016 09:49:02 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 7 Jun 2016 17:48:43 +0100 Message-Id: <1465318123-3090-9-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1465318123-3090-1-git-send-email-julien.grall@arm.com> References: <1465318123-3090-1-git-send-email-julien.grall@arm.com> Cc: sstabellini@kernel.org, wei.chen@arm.com, steve.capper@arm.com, Julien Grall , shannon.zhao@linaro.org, shankerd@codeaurora.org Subject: [Xen-devel] [RFC 8/8] 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" 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 --- xen/arch/arm/domain_build.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 00dc07a..76d503d 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -953,11 +953,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); @@ -977,7 +976,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", @@ -997,6 +996,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 ) { @@ -1015,7 +1015,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; } @@ -1152,7 +1152,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; } @@ -1411,13 +1411,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;