From: Viktor Mitin <viktor.mitin.19@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: julien.grall@arm.com, sstabellini@kernel.org,
Viktor Mitin <viktor_mitin@epam.com>,
Viktor Mitin <viktor.mitin.19@gmail.com>
Subject: [Xen-devel] [PATCH] xen/arm: merge make_timer_node and make_timer_domU_node
Date: Thu, 20 Jun 2019 13:38:05 +0300 [thread overview]
Message-ID: <20190620103805.927-1-viktor.mitin.19@gmail.com> (raw)
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 <julien.grall@arm.com>
Signed-off-by: Viktor Mitin <viktor_mitin@epam.com>
---
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;
--
2.17.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next reply other threads:[~2019-06-20 10:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-20 10:38 Viktor Mitin [this message]
2019-07-15 18:01 ` [Xen-devel] [PATCH] xen/arm: merge make_timer_node and make_timer_domU_node Julien Grall
2019-07-16 13:56 ` Viktor Mitin
2019-07-16 16:34 ` Julien Grall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190620103805.927-1-viktor.mitin.19@gmail.com \
--to=viktor.mitin.19@gmail.com \
--cc=julien.grall@arm.com \
--cc=sstabellini@kernel.org \
--cc=viktor_mitin@epam.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.