From: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
To: Viktor Mitin <viktor.mitin.19@gmail.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Julien Grall <julien.grall@arm.com>,
Stefano Stabellini <sstabellini@kernel.org>,
Viktor Mitin <Viktor_Mitin@epam.com>,
Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [Xen-devel] [PATCH v5 2/2] xen/arm: consolidate make_timer_node and make_timer_domU_node
Date: Thu, 1 Aug 2019 13:49:23 +0000 [thread overview]
Message-ID: <87zhktgfml.fsf@epam.com> (raw)
In-Reply-To: <20190801120452.6814-3-viktor.mitin.19@gmail.com>
Viktor Mitin writes:
> 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.
> Mean 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.
It is hard to parse the last sentence. What about "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.
>
> The new function has changed prototype due to fdt_property_interrupts
> make_timer_node(const struct kernel_info *kinfo)
>
> Suggested-by: Julien Grall <julien.grall@arm.com>
> Signed-off-by: Viktor Mitin <viktor_mitin@epam.com>
> ---
> 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
> ---
> xen/arch/arm/domain_build.c | 106 +++++++++++++-----------------------
> 1 file changed, 39 insertions(+), 67 deletions(-)
>
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index bc7d17dd2c..58542130ca 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];
As I said in the previous version, you are wasting stack space
there. Also, this is misleading. When I see array of 4 items, I expect
that all 4 items will be used. But you are using only 3, so it leads to
two conclusions: either you made a mistake, or I don't understand what
it happening. Either option is bad.
> gic_interrupt_t intrs[3];
> u32 clock_frequency;
> bool clock_valid;
> @@ -990,35 +988,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;
> -
> - /* 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);
> + 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;
> + }
Both cases bear the same piece of code:
if ( res )
return res;
You can move it out of outer "if". This will make code shorter and
simpler.
>
> - 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
> + */
Missing full stop at the end of the last sentence.
>
> - 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);
Why are you using plain indexes for intrs[] and enums for irq[]?
>
> res = fdt_property_interrupts(kinfo, intrs, 3);
> if ( res )
> @@ -1603,46 +1615,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 +1720,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;
--
Volodymyr Babchuk at EPAM
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-08-01 13:49 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-01 12:04 [Xen-devel] [PATCH v5 0/2] xen/arm: Consolidate make_timer_node and make_timer_domU_node Viktor Mitin
2019-08-01 12:04 ` [Xen-devel] [PATCH v5 1/2] xen/arm: extend fdt_property_interrupts to support DomU Viktor Mitin
2019-08-01 13:33 ` Volodymyr Babchuk
2019-08-01 13:54 ` Andrew Cooper
2019-08-01 12:04 ` [Xen-devel] [PATCH v5 2/2] xen/arm: consolidate make_timer_node and make_timer_domU_node Viktor Mitin
2019-08-01 13:49 ` Volodymyr Babchuk [this message]
2019-08-01 13:57 ` Julien Grall
2019-08-01 13:58 ` Julien Grall
2019-08-01 16:46 ` Viktor Mitin
2019-08-02 9:41 ` Julien Grall
2019-08-02 11:30 ` Viktor Mitin
2019-08-01 14:07 ` Volodymyr Babchuk
2019-08-01 14:22 ` Julien Grall
2019-08-01 14:50 ` Volodymyr Babchuk
2019-08-01 16:56 ` Viktor Mitin
2019-08-02 9:36 ` 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=87zhktgfml.fsf@epam.com \
--to=volodymyr_babchuk@epam.com \
--cc=Viktor_Mitin@epam.com \
--cc=julien.grall@arm.com \
--cc=sstabellini@kernel.org \
--cc=viktor.mitin.19@gmail.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.