From patchwork Thu Jun 20 10:38:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viktor Mitin X-Patchwork-Id: 11006433 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 D9B816C5 for ; Thu, 20 Jun 2019 10:41:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C520B28608 for ; Thu, 20 Jun 2019 10:41:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B27C22862A; Thu, 20 Jun 2019 10:41:18 +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 37F6B28608 for ; Thu, 20 Jun 2019 10:41:18 +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 1hduT9-0007Ci-AS; Thu, 20 Jun 2019 10:39:03 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hduT8-0007Cd-Bd for xen-devel@lists.xenproject.org; Thu, 20 Jun 2019 10:39:02 +0000 X-Inumbo-ID: 9cee8d98-9347-11e9-8980-bc764e045a96 Received: from mail-lj1-x241.google.com (unknown [2a00:1450:4864:20::241]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 9cee8d98-9347-11e9-8980-bc764e045a96; Thu, 20 Jun 2019 10:39:00 +0000 (UTC) Received: by mail-lj1-x241.google.com with SMTP id t28so2196763lje.9 for ; Thu, 20 Jun 2019 03:39:00 -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; bh=dIpauCHE8WQzh1Qq4JMUKfeLX+wuwYQBbOmknMiYfG0=; b=jedBYIQBINZwLLJix89Np7pxKSFTslPRn4tOXp9SBH5C88CuDxxYA3D1dsdvM9nm51 JOlbog1MdN8/23zy2GdC/XgrQLQTOTJCDUm8i90720M9Ahuk0sDloXSdF33pw+PW9CoN MR8W8Ql67zkvlND5JEnoCriQhGc7Aw+KBg58/3+4I91t5/jRq4beVuGAaUPzwogo6OeI 7cNe6w4cEXPtPd3WfsVUGa3rn7ClxYQrrogzzabd/bmmNIQ1xOY9ctxrvWapLKiAOfMW Wt+f4WQvuHsZaQ5VP8oF88ftYYUjtEwwDEN3m2WTaZ98lmowOb9+5ku6++zL2m4XsZs5 RKlg== 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; bh=dIpauCHE8WQzh1Qq4JMUKfeLX+wuwYQBbOmknMiYfG0=; b=a9jVkxctmKAIRpZhIdDmpBjnOWE/Xa8HGR99Nwx63TP98fNXSuTZaNWwoF9sGCrqdX p+S32F9eEwRwGf1s1uskAluR2+51ojSR+eXiY4zbY+TsCW0MCV6+RnyIbCc4jWnJm8p1 WA7HvX/8NCUWlqZrXgZ7gQbIyA3iUIik2TiwHqeqsrnOdIgo8KmBad+aFzOKFq3MyyYn fgUrnL7s+A5nE/7ZUJFOtR25+waOrKcK640H3UOrQscSr+JsYLJcIn1kGd23/4Er47vu h6DCujHUrsSsXSxO2bWwq6zTmsbd0w/HazX9P5oq7DCVxqMmhodLeLYyc/tJnD/0Srvc 8gUA== X-Gm-Message-State: APjAAAVTSgtnepAC0ifBqFD7OucH0R12PqVYoNUSeMqqcG8qF5oOv5Xn fCI3g1Yks2TP6CEF0FGwVo8BmaHl X-Google-Smtp-Source: APXvYqyQL+igFFWDsJdlx5itCEG93jz8II9xQkc6xVkdWC3YNz682gJR8wLhw6Vihqew/MCHhUg3Lg== X-Received: by 2002:a2e:6c0f:: with SMTP id h15mr5630750ljc.36.1561027138774; Thu, 20 Jun 2019 03:38:58 -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 p76sm2972146ljb.49.2019.06.20.03.38.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 20 Jun 2019 03:38:58 -0700 (PDT) From: Viktor Mitin To: xen-devel@lists.xenproject.org Date: Thu, 20 Jun 2019 13:38:05 +0300 Message-Id: <20190620103805.927-1-viktor.mitin.19@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [Xen-devel] [PATCH] 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: julien.grall@arm.com, sstabellini@kernel.org, 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. The only difference between Dom0 and DomU timer DT node is the timer interrupts used. All the rest code should be the same. So it is better to merge them to avoid discrepancy. Tested dom0 boot with rcar h3 sk board. Suggested-by: Julien Grall Signed-off-by: Viktor Mitin --- xen/arch/arm/domain_build.c | 66 ++++++++++++------------------------- 1 file changed, 21 insertions(+), 45 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 7fb828cae2..610dd3e8e7 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -976,6 +976,8 @@ static int __init make_timer_node(const struct domain *d, void *fdt) gic_interrupt_t intrs[3]; u32 clock_frequency; bool clock_valid; + bool d0 = is_hardware_domain(d); + uint32_t ip_val; dt_dprintk("Create timer node\n"); @@ -1004,22 +1006,36 @@ static int __init make_timer_node(const struct domain *d, void *fdt) /* The timer IRQ is emulated by Xen. It always exposes an active-low * level-sensitive interrupt */ - irq = timer_get_irq(TIMER_PHYS_SECURE_PPI); + irq = d0 + ? timer_get_irq(TIMER_PHYS_SECURE_PPI) + : GUEST_TIMER_PHYS_S_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); + irq = d0 + ? timer_get_irq(TIMER_PHYS_NONSECURE_PPI) + : GUEST_TIMER_PHYS_NS_PPI; dt_dprintk(" Non secure interrupt %u\n", irq); set_interrupt(intrs[1], irq, 0xf, DT_IRQ_TYPE_LEVEL_LOW); - irq = timer_get_irq(TIMER_VIRT_PPI); + irq = d0 + ? timer_get_irq(TIMER_VIRT_PPI) + : GUEST_TIMER_VIRT_PPI; dt_dprintk(" Virt interrupt %u\n", irq); set_interrupt(intrs[2], irq, 0xf, DT_IRQ_TYPE_LEVEL_LOW); - res = fdt_property_interrupts(fdt, intrs, 3); + res = fdt_property(fdt, "interrupts", intrs, sizeof (intrs[0]) * 3); if ( res ) return res; + ip_val = d0 + ? dt_interrupt_controller->phandle + : GUEST_PHANDLE_GIC; + + res = fdt_property_cell(fdt, "interrupt-parent", ip_val); + if (res) + return res; + clock_valid = dt_property_read_u32(dev, "clock-frequency", &clock_frequency); if ( clock_valid ) @@ -1581,46 +1597,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) { @@ -1726,7 +1702,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(d, kinfo->fdt); if ( ret ) goto err;