From patchwork Mon Aug 5 11:43:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viktor Mitin X-Patchwork-Id: 11076581 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 201EA112C for ; Mon, 5 Aug 2019 11:45:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 094F6285B9 for ; Mon, 5 Aug 2019 11:45:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDAA8285ED; Mon, 5 Aug 2019 11:45:40 +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 6DD98285B9 for ; Mon, 5 Aug 2019 11:45:40 +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 1hubP7-0003ri-OP; Mon, 05 Aug 2019 11:43:53 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hubP6-0003rB-60 for xen-devel@lists.xenproject.org; Mon, 05 Aug 2019 11:43:52 +0000 X-Inumbo-ID: 4aec2633-b776-11e9-8980-bc764e045a96 Received: from mail-lf1-x143.google.com (unknown [2a00:1450:4864:20::143]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 4aec2633-b776-11e9-8980-bc764e045a96; Mon, 05 Aug 2019 11:43:51 +0000 (UTC) Received: by mail-lf1-x143.google.com with SMTP id c19so57681813lfm.10 for ; Mon, 05 Aug 2019 04:43:51 -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=mq/9kgjMosUAIprB5ywg2Au7PHOWEW2H+vbX8ljPcm0=; b=rnfDX7DI8yc453cKCeLRdWtZ1FQ8je9zUz+tq92fqQ8lTI/MRfzrbp5HjhgmLHjJo1 7dTQXd3fl8ZucnJZhd0ydTaGCBoFHAdtMVLqz8CxZzzZ+/82VrFBfzqgUGinXMX1/q3i oMieOCtX4oFlCgEsID1xir/qicgvnOGdLEJx36D3Beiy0oeWNhQjoqQYO6vM6HtRpoGT 68I893+Fgt62mIKmt8jDIJj3Z3auDofuCQGagdemPnJ9Ob7gY0ER+6e0R5ArtVVOomqh XtrsUl4IG3QMwHNf9B/zeeCNYtjvwuytxs0ol/2HwQ9TMUI44TeHMNm/y5yOPPadxSZv uIVQ== 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=mq/9kgjMosUAIprB5ywg2Au7PHOWEW2H+vbX8ljPcm0=; b=Cx7qus+9rMrAkv3WMtMcxTiiY8x0YL33kbMpvjF9dRQOja5sf3Zm6SweU7YQbXbtbu EMlbjaqlwrS2VbrhuxFMfuBQbfdN3Ctd6CiCrz3YgJ2rjaFrr09IJ5eeCU+BWDd7gQOP OK9u6XdIcnErftNqkkHvR0BbJtGS8mZyPxACxYWUt6Zs9t8z3lZMypeRTy4Nb72Z2YJH 9jCNfwS9liAgPfxn+edb+Ulb23rLZ9PYe+6UnQXu++24fxGcw1zjMMoYf0zA+Lj86Kq9 F5wNJA3+WHOJjIEbfX38fv7HICsyXywFOAhgSzE1evsS9+kba7YzI0SodJHMrsstYJw/ 4rZw== X-Gm-Message-State: APjAAAVZCJnEk5bDqsCmrc4Jg575AN5MfEHqxGnxPqKshgc4ra7uaCd8 btUvZ7teuts7fQIeMT50Gk+ChoYZ X-Google-Smtp-Source: APXvYqwMGmMPKmUF7WivY2WtV8fQLYy50u3UmcyPRMp2UOmbjfxATC/fTTvoFdvzQNBiqrn2HhG9SA== X-Received: by 2002:a19:7006:: with SMTP id h6mr70138989lfc.5.1565005429279; Mon, 05 Aug 2019 04:43:49 -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 b1sm17285057ljj.26.2019.08.05.04.43.48 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 05 Aug 2019 04:43:48 -0700 (PDT) From: Viktor Mitin To: xen-devel@lists.xenproject.org Date: Mon, 5 Aug 2019 14:43:31 +0300 Message-Id: <20190805114332.15329-3-viktor.mitin.19@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190805114332.15329-1-viktor.mitin.19@gmail.com> References: <20190805114332.15329-1-viktor.mitin.19@gmail.com> Subject: [Xen-devel] [PATCH v6 2/2] xen/arm: consolidate 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 consolidate them to avoid discrepancy. The main difference between the functions is the timer interrupts used. Keep the domU version for the compatible as it is simpler: do not copy platform's 'compatible' property into hwdom device tree, instead set either arm,armv7-timer or arm,armv8-timer, depending on the platform type. Keep the hw version for the clock as it is relevant for the both cases. Suggested-by: Julien Grall Signed-off-by: Viktor Mitin --- v4 updates: updated "Keep the domU version for the compatible as it is simpler" v5 updates: - changed 'kept' to 'keep', etc. - removed empty line - updated indentation of parameters in functions calls - fixed NITs - updated commit message v6 updates: - move if out of outer "if" - add full stop at the end of the last sentence - minor rephrase of commit message --- xen/arch/arm/domain_build.c | 100 +++++++++++++----------------------- 1 file changed, 35 insertions(+), 65 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index bc7d17dd2c..b9954d2c3c 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -973,10 +973,8 @@ 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; + unsigned int irq[MAX_TIMER_PPI]; gic_interrupt_t intrs[3]; u32 clock_frequency; bool clock_valid; @@ -990,35 +988,47 @@ static int __init make_timer_node(const struct kernel_info *kinfo) return -FDT_ERR_XEN(ENOENT); } - compatible = dt_get_property(dev, "compatible", &len); - if ( !compatible ) - { - dprintk(XENLOG_ERR, "Can't find compatible property for timer node\n"); - return -FDT_ERR_XEN(ENOENT); - } - res = fdt_begin_node(fdt, "timer"); if ( res ) return res; - res = fdt_property(fdt, "compatible", compatible, len); + if ( !is_64bit_domain(kinfo->d) ) + { + res = fdt_property_string(fdt, "compatible", "arm,armv7-timer"); + } + else + { + res = fdt_property_string(fdt, "compatible", "arm,armv8-timer"); + } if ( res ) return res; - /* The timer IRQ is emulated by Xen. It always exposes an active-low - * level-sensitive interrupt */ - - 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); - - 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); + /* + * The timer IRQ is emulated by Xen. + * It always exposes an active-low level-sensitive interrupt. + */ - 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); + 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; + } + 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); + 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); + 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 +1613,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 +1718,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;