From patchwork Wed Jul 31 09:34:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viktor Mitin X-Patchwork-Id: 11067411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A765613A0 for ; Wed, 31 Jul 2019 09:36:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9017E28758 for ; Wed, 31 Jul 2019 09:36:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8399328775; Wed, 31 Jul 2019 09:36: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=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,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 AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EB16C28758 for ; Wed, 31 Jul 2019 09:36:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hsl0v-0001FU-4k; Wed, 31 Jul 2019 09:35:17 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hsl0t-0001FE-Ry for xen-devel@lists.xenproject.org; Wed, 31 Jul 2019 09:35:15 +0000 X-Inumbo-ID: 7f9eef38-b376-11e9-8980-bc764e045a96 Received: from mail-lf1-x141.google.com (unknown [2a00:1450:4864:20::141]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 7f9eef38-b376-11e9-8980-bc764e045a96; Wed, 31 Jul 2019 09:35:14 +0000 (UTC) Received: by mail-lf1-x141.google.com with SMTP id u10so8196676lfm.12 for ; Wed, 31 Jul 2019 02:35:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xlMx3hw0T2T90NvBukcLZ5GqiQ2OqJhBqyw+D6rzSzs=; b=OKC+eNd1e3gxnSU0UC9D2MS+QQz+ND+IMWb5Trg3jNW2UO4U1ea6U6uIJY/55gdpBU zUgCS6tm+yiRcrdxBBSkQFPJoXpoSt4yYdv1HOdHSyqKYxV7oYL4paIBO8JID7awbxkN v9/Zn8I77KofTD+CUaNUILa3wk54XUxzj2nBaX1VTTAibTXZC2bXgDIEWsGHAWlUhnKG shsS/mlEu8m75BNc4HyvB/EE/1QZyBvjGZZUhhINJ6YC+ImBVCaepEvNonqNN9L0rhQJ fjUWbqBe29PH8X7bt7ncX+E5/5JvcHgBhq/OG3DEE6kbopzolmy/oo+illNjqaT12YaT yd4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xlMx3hw0T2T90NvBukcLZ5GqiQ2OqJhBqyw+D6rzSzs=; b=DRaRxkptxQMsgUQ9TF4eMjhwQH6X5tjIgrigOLxl49umBaHDkrcxfJKEOO5t34AY7j Ih1yepUpoE05FAuQov1MnhBunqm89+/nK8MAuWKhsJSzIXJ04sWxdo4vDKM7sVdcidqN H1859/kFUNMifoN820JccgRWvxkILxoRpd8167+kFe5+I9yG7HVNs6P6XFRghR4wqkhO lMLt0p8q7hRRTt80DM55wXwx51xsIp40rbSW4ID4BwV+tLeyOf5Gyg/9GDyE3gaNlFhT UPe90+qLuWqNJM3yaLjXdS83x4DK9d/r74u6sgLTNY2shinHbrS3nGTBBnDnidPlY/IG CdXA== X-Gm-Message-State: APjAAAUxH8Qn6HpzmBbDHhdmFiOxXsOvgs1VlRv8C7IFtcVh0am+DL10 xdTbf0sFQg3IKtbFTbNbDllwTQCi X-Google-Smtp-Source: APXvYqzK9EDaDjBd/dxUFBCzU6ZZCSooy/wQ5yTXyi+gbv8mHSblxvdmz+5xhirpcV9jmSS5/fF1vA== X-Received: by 2002:a05:6512:1d2:: with SMTP id f18mr17596761lfp.173.1564565713263; Wed, 31 Jul 2019 02:35:13 -0700 (PDT) Received: from 3489.kyiv.epam.com (ll-22.209.223.85.sovam.net.ua. [85.223.209.22]) by smtp.gmail.com with ESMTPSA id k23sm9966499ljg.90.2019.07.31.02.35.11 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 02:35:12 -0700 (PDT) From: Viktor Mitin To: xen-devel@lists.xenproject.org Date: Wed, 31 Jul 2019 12:34:30 +0300 Message-Id: <20190731093430.20726-2-viktor.mitin.19@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731093430.20726-1-viktor.mitin.19@gmail.com> References: <20190731093430.20726-1-viktor.mitin.19@gmail.com> Subject: [Xen-devel] [PATCH v3 2/2] xen/arm: merge make_timer_node and make_timer_domU_node 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: Volodymyr Babchuk , Julien Grall , Stefano Stabellini , Viktor Mitin , Viktor Mitin MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Functions make_timer_node and make_timer_domU_node are quite similar. So it is better to merge them to avoid discrepancy. The main difference between the functions is the timer interrupts used. Kept the domU version for the compatible as it is simpler. Kept the hw version for the clock as it is relevant for the both cases. It has been merged into one function - make_timer_node. Suggested-by: Julien Grall Signed-off-by: Viktor Mitin --- Tested dom0 and dom0less domU boot and that clock frequency property set in both device trees. xen/arch/arm/domain_build.c | 97 +++++++++++++------------------------ 1 file changed, 33 insertions(+), 64 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index d04a1c3aec..3efb651006 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -964,8 +964,14 @@ static int __init make_gic_node(const struct domain *d, void *fdt, static int __init make_timer_node(const struct kernel_info *kinfo) { + int res; void *fdt = kinfo->fdt; - + unsigned int irq[MAX_TIMER_PPI]; + gic_interrupt_t intrs[3]; + const void *compatible; + u32 len; + u32 clock_frequency; + bool clock_valid; static const struct dt_device_match timer_ids[] __initconst = { DT_MATCH_COMPATIBLE("arm,armv7-timer"), @@ -973,15 +979,6 @@ static int __init make_timer_node(const struct kernel_info *kinfo) { /* sentinel */ }, }; struct dt_device_node *dev; - u32 len; - const void *compatible; - int res; - unsigned int irq; - gic_interrupt_t intrs[3]; - u32 clock_frequency; - bool clock_valid; - - dt_dprintk("Create timer node\n"); dev = dt_find_matching_node(NULL, timer_ids); if ( !dev ) @@ -990,6 +987,10 @@ static int __init make_timer_node(const struct kernel_info *kinfo) return -FDT_ERR_XEN(ENOENT); } + res = fdt_begin_node(fdt, "timer"); + if ( res ) + return res; + compatible = dt_get_property(dev, "compatible", &len); if ( !compatible ) { @@ -997,28 +998,36 @@ static int __init make_timer_node(const struct kernel_info *kinfo) return -FDT_ERR_XEN(ENOENT); } - res = fdt_begin_node(fdt, "timer"); - if ( res ) - return res; - res = fdt_property(fdt, "compatible", compatible, len); if ( res ) return res; /* The timer IRQ is emulated by Xen. It always exposes an active-low * level-sensitive interrupt */ + if ( is_hardware_domain(kinfo->d) ) + { + irq[TIMER_PHYS_SECURE_PPI] = timer_get_irq(TIMER_PHYS_SECURE_PPI); + irq[TIMER_PHYS_NONSECURE_PPI] = + timer_get_irq(TIMER_PHYS_NONSECURE_PPI); + irq[TIMER_VIRT_PPI] = timer_get_irq(TIMER_VIRT_PPI); + } + else + { + irq[TIMER_PHYS_SECURE_PPI] = GUEST_TIMER_PHYS_S_PPI; + irq[TIMER_PHYS_NONSECURE_PPI] = GUEST_TIMER_PHYS_NS_PPI; + irq[TIMER_VIRT_PPI] = GUEST_TIMER_VIRT_PPI; + } - irq = timer_get_irq(TIMER_PHYS_SECURE_PPI); - dt_dprintk(" Secure interrupt %u\n", irq); - set_interrupt(intrs[0], irq, 0xf, DT_IRQ_TYPE_LEVEL_LOW); + dt_dprintk(" Secure interrupt %u\n", irq[TIMER_PHYS_SECURE_PPI]); + set_interrupt(intrs[0], irq[TIMER_PHYS_SECURE_PPI], + 0xf, DT_IRQ_TYPE_LEVEL_LOW); - irq = timer_get_irq(TIMER_PHYS_NONSECURE_PPI); - dt_dprintk(" Non secure interrupt %u\n", irq); - set_interrupt(intrs[1], irq, 0xf, DT_IRQ_TYPE_LEVEL_LOW); + dt_dprintk(" Non secure interrupt %u\n", irq[TIMER_PHYS_NONSECURE_PPI]); + set_interrupt(intrs[1], irq[TIMER_PHYS_NONSECURE_PPI], + 0xf, DT_IRQ_TYPE_LEVEL_LOW); - irq = timer_get_irq(TIMER_VIRT_PPI); - dt_dprintk(" Virt interrupt %u\n", irq); - set_interrupt(intrs[2], irq, 0xf, DT_IRQ_TYPE_LEVEL_LOW); + dt_dprintk(" Virt interrupt %u\n", irq[TIMER_VIRT_PPI]); + set_interrupt(intrs[2], irq[TIMER_VIRT_PPI], 0xf, DT_IRQ_TYPE_LEVEL_LOW); res = fdt_property_interrupts(kinfo, intrs, 3); if ( res ) @@ -1603,46 +1612,6 @@ static int __init make_gic_domU_node(const struct domain *d, void *fdt) } } -static int __init make_timer_domU_node(const struct domain *d, void *fdt) -{ - int res; - gic_interrupt_t intrs[3]; - - res = fdt_begin_node(fdt, "timer"); - if ( res ) - return res; - - if ( !is_64bit_domain(d) ) - { - res = fdt_property_string(fdt, "compatible", "arm,armv7-timer"); - if ( res ) - return res; - } - else - { - res = fdt_property_string(fdt, "compatible", "arm,armv8-timer"); - if ( res ) - return res; - } - - set_interrupt(intrs[0], GUEST_TIMER_PHYS_S_PPI, 0xf, DT_IRQ_TYPE_LEVEL_LOW); - set_interrupt(intrs[1], GUEST_TIMER_PHYS_NS_PPI, 0xf, DT_IRQ_TYPE_LEVEL_LOW); - set_interrupt(intrs[2], GUEST_TIMER_VIRT_PPI, 0xf, DT_IRQ_TYPE_LEVEL_LOW); - - res = fdt_property(fdt, "interrupts", intrs, sizeof (intrs[0]) * 3); - if ( res ) - return res; - - res = fdt_property_cell(fdt, "interrupt-parent", - GUEST_PHANDLE_GIC); - if (res) - return res; - - res = fdt_end_node(fdt); - - return res; -} - #ifdef CONFIG_SBSA_VUART_CONSOLE static int __init make_vpl011_uart_node(const struct domain *d, void *fdt) { @@ -1748,7 +1717,7 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo) if ( ret ) goto err; - ret = make_timer_domU_node(d, kinfo->fdt); + ret = make_timer_node(kinfo); if ( ret ) goto err;