From patchwork Fri Oct 4 01:14:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 11173591 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 28C2E76 for ; Fri, 4 Oct 2019 01:16:25 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 034C7208E3 for ; Fri, 4 Oct 2019 01:16:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="b10DiAqD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 034C7208E3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iGCBS-0003KO-6A; Fri, 04 Oct 2019 01:15:02 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iGCBQ-0003KE-8I for xen-devel@lists.xen.org; Fri, 04 Oct 2019 01:15:00 +0000 X-Inumbo-ID: 62671ca4-e644-11e9-8c93-bc764e2007e4 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 62671ca4-e644-11e9-8c93-bc764e2007e4; Fri, 04 Oct 2019 01:14:59 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.hsd1.ca.comcast.net (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F28DD208E3; Fri, 4 Oct 2019 01:14:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570151699; bh=HaY4kOXVJcylrsj+hflyHE8r5f9X6kHzwd1zKTdDOQA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b10DiAqDQr7x3UFyM0/7lgA46AsjWWfd/1EKVlTkf+IqfwuM3tx0MH8RewUrU662b yOPZKuvEhdNxkNAxDdmJL/0Wosxrm9lDARexKLuIA8cxYCic/s1X9Ywl59d7GUs25d jTh3UdEC6JiZh2oj6upZh7kvPoLEHvgl/JvaXcg0= From: Stefano Stabellini To: julien.grall@arm.com Date: Thu, 3 Oct 2019 18:14:50 -0700 Message-Id: <20191004011457.11126-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Subject: [Xen-devel] [PATCH v9 1/8] xen/arm: introduce handle_device_interrupts X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , sstabellini@kernel.org, andrii_anisov@epam.com, Achin.Gupta@arm.com, xen-devel@lists.xen.org, Volodymyr_Babchuk@epam.com MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Move the interrupt handling code out of handle_device to a new function so that it can be reused for dom0less VMs (it will be used in later patches). Signed-off-by: Stefano Stabellini Acked-by: Julien Grall --- Changes in v4: - rename handle_interrupts to handle_device_interrupts - improve in-code comment - remove return 1 if mapping is done - use unsigned Changes in v3: - add patch The diff is hard to read but I just moved the interrupts related code from handle_devices to a new function handle_device_interrupts, and very little else. --- xen/arch/arm/domain_build.c | 100 ++++++++++++++++++++++-------------- 1 file changed, 61 insertions(+), 39 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 337a89e518..fb356603e2 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -1238,6 +1238,62 @@ static int __init map_device_children(struct domain *d, return 0; } +/* + * handle_device_interrupts retrieves the interrupts configuration from + * a device tree node and maps those interrupts to the target domain. + * + * Returns: + * < 0 error + * 0 success + */ +static int __init handle_device_interrupts(struct domain *d, + struct dt_device_node *dev, + bool need_mapping) +{ + unsigned int i, nirq; + int res; + struct dt_raw_irq rirq; + + nirq = dt_number_of_irq(dev); + + /* Give permission and map IRQs */ + for ( i = 0; i < nirq; i++ ) + { + res = dt_device_get_raw_irq(dev, i, &rirq); + if ( res ) + { + printk(XENLOG_ERR "Unable to retrieve irq %u for %s\n", + i, dt_node_full_name(dev)); + return res; + } + + /* + * Don't map IRQ that have no physical meaning + * ie: IRQ whose controller is not the GIC + */ + if ( rirq.controller != dt_interrupt_controller ) + { + dt_dprintk("irq %u not connected to primary controller. Connected to %s\n", + i, dt_node_full_name(rirq.controller)); + continue; + } + + res = platform_get_irq(dev, i); + if ( res < 0 ) + { + printk(XENLOG_ERR "Unable to get irq %u for %s\n", + i, dt_node_full_name(dev)); + return res; + } + + res = map_irq_to_domain(d, res, need_mapping, dt_node_name(dev)); + if ( res ) + return res; + } + + return 0; +} + /* * For a given device node: * - Give permission to the guest to manage IRQ and MMIO range @@ -1250,19 +1306,16 @@ static int __init map_device_children(struct domain *d, static int __init handle_device(struct domain *d, struct dt_device_node *dev, p2m_type_t p2mt) { - unsigned int nirq; unsigned int naddr; unsigned int i; int res; - struct dt_raw_irq rirq; u64 addr, size; bool need_mapping = !dt_device_for_passthrough(dev); - nirq = dt_number_of_irq(dev); naddr = dt_number_of_address(dev); - dt_dprintk("%s passthrough = %d nirq = %d naddr = %u\n", - dt_node_full_name(dev), need_mapping, nirq, naddr); + dt_dprintk("%s passthrough = %d naddr = %u\n", + dt_node_full_name(dev), need_mapping, naddr); if ( need_mapping ) { @@ -1290,40 +1343,9 @@ static int __init handle_device(struct domain *d, struct dt_device_node *dev, } } - /* Give permission and map IRQs */ - for ( i = 0; i < nirq; i++ ) - { - res = dt_device_get_raw_irq(dev, i, &rirq); - if ( res ) - { - printk(XENLOG_ERR "Unable to retrieve irq %u for %s\n", - i, dt_node_full_name(dev)); - return res; - } - - /* - * Don't map IRQ that have no physical meaning - * ie: IRQ whose controller is not the GIC - */ - if ( rirq.controller != dt_interrupt_controller ) - { - dt_dprintk("irq %u not connected to primary controller. Connected to %s\n", - i, dt_node_full_name(rirq.controller)); - continue; - } - - res = platform_get_irq(dev, i); - if ( res < 0 ) - { - printk(XENLOG_ERR "Unable to get irq %u for %s\n", - i, dt_node_full_name(dev)); - return res; - } - - res = map_irq_to_domain(d, res, need_mapping, dt_node_name(dev)); - if ( res ) - return res; - } + res = handle_device_interrupts(d, dev, need_mapping); + if ( res < 0 ) + return res; /* Give permission and map MMIOs */ for ( i = 0; i < naddr; i++ )