From patchwork Wed Jul 31 10:28:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viktor Mitin X-Patchwork-Id: 11067481 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 D13CE13AC for ; Wed, 31 Jul 2019 10:30:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCCD0274A3 for ; Wed, 31 Jul 2019 10:30:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0B3D28716; Wed, 31 Jul 2019 10:30: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 435CA274A3 for ; Wed, 31 Jul 2019 10:30:47 +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 1hslrC-0005Tm-GI; Wed, 31 Jul 2019 10:29:18 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hslrA-0005Th-Rq for xen-devel@lists.xenproject.org; Wed, 31 Jul 2019 10:29:16 +0000 X-Inumbo-ID: 0acd9819-b37e-11e9-8980-bc764e045a96 Received: from mail-lj1-x244.google.com (unknown [2a00:1450:4864:20::244]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 0acd9819-b37e-11e9-8980-bc764e045a96; Wed, 31 Jul 2019 10:29:14 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id v24so65186119ljg.13 for ; Wed, 31 Jul 2019 03:29: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; bh=lJ8LZcbwiz0GZGku70DjI/XsfhsXIXbFEYA02rHAFB0=; b=dsUzfXQzoO8b2ykPQV7pgKIPZ0bQt47GyffMhndmp3mhPUoMQK7Q0J3dp4w0f1TZMU h0K143nZBhXMAOubhWH9M0qrsYYlrr5eO44j04/MuD+JQIcj8odrnPtn5yIcqn1VbZdf RpfHfJEoglU45tspTKYI9Onnv0eclC6jgJgMhjZYZJMUp+pkd5xW+b1BIU5Bk0rFPCOi y5iUPStFFvDaICPXVKdeY2Re8iDEeueFY6WAm0vL5VTcf+ZZ4ZUEprn4l3QV4sKsyG81 1qaSKIu8FhZFDLLqqignhSYc8eqd97XiILm1m8azDkZDswFDV6lxWEryorBh9rbXpklN C2mA== 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=lJ8LZcbwiz0GZGku70DjI/XsfhsXIXbFEYA02rHAFB0=; b=dQZRnNemBfq9QKuxOmR71gX1XmUgjkFdq59QUEhHyT9kOY51f9dgUT3LNWo4XVdEv4 lQr07czvdAqay2cvjmaU9VZcZ7Ven6QRq2GJtEmYQTSHbdn6+pjFxvNsjQdvGJpIkqDn wkds+UGPM8no830+Ax6mhAHxmcwSTFLjugl9DoIv4iizZWOgT9gu67eDNMZVF0dPFIOQ 02FSWO/V3qlbyVGpqIHB0y3L+9mSl1t+OlR+wesn/cgDb0OLbHa1FlXPq26zTmtBeL3N XIIKvZoFnhCgypZp8upr5poU12Hk2CtBT5vsQopt0JJbdJAbo6hNotNd78mThTmdewrh k1Xw== X-Gm-Message-State: APjAAAVllG4+H6wmz/8A4u6GBRTgvyv0DbicrPhfIYLJqIcNAsaU0sop C9YKJtNsNNpJUuBs6oNE+KbaOiXL X-Google-Smtp-Source: APXvYqyD1QeyCTHsuQ5eckAQ780FMTqkrog7xrfo+BOMnAe1HUA5PtYyyEzIUQwZIqeKq9iaJf+BUQ== X-Received: by 2002:a2e:7c14:: with SMTP id x20mr39227809ljc.56.1564568953199; Wed, 31 Jul 2019 03:29: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 w1sm16014067ljm.81.2019.07.31.03.29.11 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 03:29:12 -0700 (PDT) From: Viktor Mitin To: xen-devel@lists.xenproject.org Date: Wed, 31 Jul 2019 13:28:55 +0300 Message-Id: <20190731102856.23215-1-viktor.mitin.19@gmail.com> X-Mailer: git-send-email 2.17.1 Subject: [Xen-devel] [PATCH v4 1/2] xen/arm: extend fdt_property_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: 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 Extend fdt_property_interrupts to deal with other domain than the hwdom. The prototype of fdt_property_interrupts() has been modified to support both hwdom and domU in one function. This is a preparatory for the patch "xen/arm: merge make_timer_node and make_timer_domU_node". Original goal is to merge make_timer_node and make_timer_domU_node functions. See discussion in e-mail, the Message-ID is: <20190620103805.927-1-viktor.mitin.19@gmail.com> Note: there is no functional changes introduced by this patch. Suggested-by: Julien Grall Signed-off-by: Viktor Mitin --- xen/arch/arm/domain_build.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index 4c8404155a..d04a1c3aec 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -621,17 +621,19 @@ static void __init set_interrupt(gic_interrupt_t interrupt, * "interrupts": contains the list of interrupts * "interrupt-parent": link to the GIC */ -static int __init fdt_property_interrupts(void *fdt, gic_interrupt_t *intr, - unsigned num_irq) +static int __init fdt_property_interrupts(const struct kernel_info *kinfo, + gic_interrupt_t *intr, unsigned num_irq) { int res; + uint32_t phandle = is_hardware_domain(kinfo->d) ? + dt_interrupt_controller->phandle : GUEST_PHANDLE_GIC; - res = fdt_property(fdt, "interrupts", intr, sizeof (intr[0]) * num_irq); + res = fdt_property(kinfo->fdt, "interrupts", + intr, sizeof (intr[0]) * num_irq); if ( res ) return res; - res = fdt_property_cell(fdt, "interrupt-parent", - dt_interrupt_controller->phandle); + res = fdt_property_cell(kinfo->fdt, "interrupt-parent", phandle); return res; } @@ -733,7 +735,7 @@ static int __init make_hypervisor_node(struct domain *d, * TODO: Handle properly the cpumask; */ set_interrupt(intr, d->arch.evtchn_irq, 0xf, DT_IRQ_TYPE_LEVEL_LOW); - res = fdt_property_interrupts(fdt, &intr, 1); + res = fdt_property_interrupts(kinfo, &intr, 1); if ( res ) return res; @@ -960,8 +962,10 @@ static int __init make_gic_node(const struct domain *d, void *fdt, return res; } -static int __init make_timer_node(const struct domain *d, void *fdt) +static int __init make_timer_node(const struct kernel_info *kinfo) { + void *fdt = kinfo->fdt; + static const struct dt_device_match timer_ids[] __initconst = { DT_MATCH_COMPATIBLE("arm,armv7-timer"), @@ -1016,7 +1020,7 @@ static int __init make_timer_node(const struct domain *d, void *fdt) 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_interrupts(kinfo, intrs, 3); if ( res ) return res; @@ -1377,7 +1381,7 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo, if ( device_get_class(node) == DEVICE_GIC ) return make_gic_node(d, kinfo->fdt, node); if ( dt_match_node(timer_matches, node) ) - return make_timer_node(d, kinfo->fdt); + return make_timer_node(kinfo); /* Skip nodes used by Xen */ if ( dt_device_used_by(node) == DOMID_XEN ) From patchwork Wed Jul 31 10:28:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viktor Mitin X-Patchwork-Id: 11067483 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 4B91E746 for ; Wed, 31 Jul 2019 10:31:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35D662870F for ; Wed, 31 Jul 2019 10:31:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20A90288FD; Wed, 31 Jul 2019 10:31:16 +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 9057D288EF for ; Wed, 31 Jul 2019 10:31:15 +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 1hslrD-0005Ty-Q6; Wed, 31 Jul 2019 10:29:19 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hslrD-0005Ts-5x for xen-devel@lists.xenproject.org; Wed, 31 Jul 2019 10:29:19 +0000 X-Inumbo-ID: 0c7227e2-b37e-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 0c7227e2-b37e-11e9-8980-bc764e045a96; Wed, 31 Jul 2019 10:29:17 +0000 (UTC) Received: by mail-lf1-x143.google.com with SMTP id z15so42792061lfh.13 for ; Wed, 31 Jul 2019 03:29:17 -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=PGTJVcpfWdjXnx6ZIQpf0SmfaJ/KpR5NHHTsYiaDPrE=; b=bKBrjDWqRa5DNe7ydy1Of2vt79hQ9jNpVhchw/5B5TYH0UUL0u25NXjafIpFPB4664 eb4+2rUyeC3oJYk3wmwyUoG/3k1mRxnoxyjVt/Q29N0ZYTwVsOp3t64fzNM71HZbTvMh CirSDawMVPvl0Tnu+DNvOlFzVPBhSse3yn1W7+ls2OGRCFA3D1DQecRiXacJoCn0zNkb VBj5cITQUedG2U3y/PFZCaLeqH8maZnzKD9FQG9EIEH6W3pyYWrE3W7s0ihlNZD3kWzh qsUryQoglViHb6NmyhnW692HK8iuJo4Pb7toc48f0kdmHkjOW9YeK8K05YXhjd1TVFKN wO6w== 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=PGTJVcpfWdjXnx6ZIQpf0SmfaJ/KpR5NHHTsYiaDPrE=; b=iv/8RH9gundScqPrBJYXFzk6O5Wd/ev8W82JzPHRKvIbgHsakgYmXi3sswxsZNnpLB X+MRXLA7DrNWIOtuLLu2rAx3F8a+iT6qtIATOKdXumftdjo7nOX/X/t3Jp9rjlL9Io2f mj7wPOsJxVVJWXD8EypLu1q6oh0J9kmpv36V3KLLT0PzViGtgPzkARGcRPJr8M6gZG6W 4s1sdB409HcpFvmlyxmBifyrAbzRNnDp7MKsJmXre9SAnxLeq1D5uewlxPfNrl6HwfeE myPmOscj9aUaAaL23cn3WA0bgiWj8x/N9sQyAD1iX+MGb4UQItGOU2T/V8Bs0gWUCnTA CqyA== X-Gm-Message-State: APjAAAW34VMmPs/xCCOHOwPlkaNDDam7Dj3o1YrQYrfamw5pQd9/R9QF mI2NiL7AsliUJJ5QCpjt2dm93YvP X-Google-Smtp-Source: APXvYqwjDJtX7uBJ4NIi+vCvHp+nAWSX6jHKUJ5+bGn+kK5JBU6WEPdBzvtZp5iX+uqMS13PJu40Ug== X-Received: by 2002:a19:234c:: with SMTP id j73mr14255578lfj.96.1564568956042; Wed, 31 Jul 2019 03:29:16 -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 w1sm16014067ljm.81.2019.07.31.03.29.14 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 03:29:15 -0700 (PDT) From: Viktor Mitin To: xen-devel@lists.xenproject.org Date: Wed, 31 Jul 2019 13:28:56 +0300 Message-Id: <20190731102856.23215-2-viktor.mitin.19@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731102856.23215-1-viktor.mitin.19@gmail.com> References: <20190731102856.23215-1-viktor.mitin.19@gmail.com> Subject: [Xen-devel] [PATCH v4 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 Merged make_timer_node and make_timer_domU_node into one function make_timer_node. 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. Suggested-by: Julien Grall Signed-off-by: Viktor Mitin --- v4 updates: updated "Kept the domU version for the compatible as it is simpler" xen/arch/arm/domain_build.c | 109 +++++++++++++----------------------- 1 file changed, 39 insertions(+), 70 deletions(-) diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c index d04a1c3aec..4d7c3411a6 100644 --- a/xen/arch/arm/domain_build.c +++ b/xen/arch/arm/domain_build.c @@ -964,8 +964,12 @@ 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]; + u32 clock_frequency; + bool clock_valid; static const struct dt_device_match timer_ids[] __initconst = { DT_MATCH_COMPATIBLE("arm,armv7-timer"), @@ -973,15 +977,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,35 +985,49 @@ 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 ( res ) - return res; + if ( !is_64bit_domain(kinfo->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; + } /* 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;