All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@arm.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: artem_mygaiev@epam.com, Stefano Stabellini <stefanos@xilinx.com>,
	andrii_anisov@epam.com, xen-devel@lists.xen.org
Subject: Re: [PATCH RFC 12/15] xen/arm: generate vpl011 node on device tree for domU
Date: Fri, 15 Jun 2018 17:58:00 +0100	[thread overview]
Message-ID: <551fb6cb-2358-731d-ec04-7032b216a44f@arm.com> (raw)
In-Reply-To: <1528928118-14960-12-git-send-email-sstabellini@kernel.org>

Hi Stefano,

On 06/13/2018 11:15 PM, Stefano Stabellini wrote:
> Introduce vpl011 support to guests started from Xen: it provides a
> simple way to print output from a guest, as most guests come with a
> pl011 driver. It is also able to provide a working console with
> interrupt support.
> 
> Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>
> ---
>   xen/arch/arm/domain_build.c | 70 +++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 70 insertions(+)
> 
> diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
> index b4f560f..ff65057 100644
> --- a/xen/arch/arm/domain_build.c
> +++ b/xen/arch/arm/domain_build.c
> @@ -1470,6 +1470,70 @@ static int make_timer_domU_node(const struct domain *d, void *fdt)
>       return res;
>   }
>   
> +static void set_interrupt(gic_interrupt_t *interrupt, unsigned int irq,

The definition of interrupt looks suspicious. gic_interrupt_t is defined 
as be32[3]. Here you pass a pointer, so interrupt type would be __be32 
**, that you crudely cast to __be32* below.

Most likely you don't want to pass a pointer here and just use the type 
gic_interrupt_t. Because it is an array, then there will be no issue.

> +                          unsigned int cpumask, unsigned int level)
> +{
> +    __be32 *cells = (__be32 *) interrupt;

Explicit cast are always a bad idea. If you need one, then mostly likely 
you did something wrong :). In that case interrupt type is __be32** and 
you cast to __be32*. If you change the type as suggested above, then the 
cast will not be necessary here.

> +    int is_ppi = (irq < 32);
> +
> +    irq -= (is_ppi) ? 16: 32; /* PPIs start at 16, SPIs at 32 */
> +
> +    /* See linux Documentation/devictree/bindings/arm/gic.txt */
> +    dt_set_cell(&cells, 1, is_ppi); /* is a PPI? */
> +    dt_set_cell(&cells, 1, irq);
> +    dt_set_cell(&cells, 1, (cpumask << 8) | level);
> +}

We already have a function to generate PPI interrupt 
(set_interrupt_ppi). Would it be possible to extend it to support interrupt?

Most likely, you will want to use set_interrupt(...) everywhere and just 
drop set_interrupt_ppi.

> +
> +#ifdef CONFIG_SBSA_VUART_CONSOLE
> +static int make_vpl011_uart_node(const struct domain *d, void *fdt,
> +                                 int addrcells, int sizecells)
> +{
> +    int res;
> +    gic_interrupt_t intr;
> +    int reg_size = addrcells + sizecells;
> +    int nr_cells = reg_size;
> +    __be32 reg[nr_cells];
> +    __be32 *cells;
> +
> +    res = fdt_begin_node(fdt, "sbsa-pl011");
> +    if (res)

Coding style:

if ( ... )

> +        return res;
> +
> +    res = fdt_property_string(fdt, "compatible", "arm,sbsa-uart");

To make clear, you are exposing a SBSA compatible UART and not a PL011. 
SBSA UART is a subset of PL011 r1p5. A full PL011 implementation in Xen 
would just be too difficult, so your guest may require some changes in 
their driver.

I think this is a small price to pay, but I wanted to make sure you 
don't expect the guest to drive the UART the same way a PL011.

> +    if (res)

Coding style

> +        return res;
> +
> +    cells = &reg[0];
> +    dt_child_set_range(&cells, addrcells, sizecells, GUEST_PL011_BASE,
> +            GUEST_PL011_SIZE);

The indentation looks wrong here.

> +    if (res)

Coding style

> +        return res;
> +    res = fdt_property(fdt, "reg", reg, sizeof(reg));
> +    if (res)

Coding style

> +        return res;
> +
> +    set_interrupt(&intr, GUEST_VPL011_SPI, 0xf, DT_IRQ_TYPE_LEVEL_HIGH);
> +
> +    res = fdt_property(fdt, "interrupts", intr, sizeof (intr));
> +    if (res)

Coding style

> +        return res;
> +
> +    res = fdt_property_cell(fdt, "interrupt-parent",
> +                            PHANDLE_GIC);
> +    if (res)

Coding style

> +        return res;
> +
> +    /* Use a default baud rate of 115200. */
> +    fdt_property_u32(fdt, "current-speed", 115200);
> +
> +    res = fdt_end_node(fdt);
> +    if (res)

Coding style

> +        return res;
> +
> +    return 0;
> +}
> +#endif
> +
>   #define DOMU_DTB_SIZE 4096
>   static int prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo)
>   {
> @@ -1531,6 +1595,12 @@ static int prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo)
>       if ( ret )
>           goto err;
>   
> +#ifdef CONFIG_SBSA_VUART_CONSOLE.
> +    ret = make_vpl011_uart_node(d, kinfo->fdt, addrcells, sizecells);

I would prefer if don't expose the pl011 by default to a guest and 
provide a way to enable it for a given guest

> +    if ( ret )
> +        goto err;
> +#endif
> +
>       ret = fdt_end_node(kinfo->fdt);
>       if ( ret < 0 )
>           goto err;
> 

Cheers,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-06-15 16:58 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-13 22:15 [PATCH RFC 00/15] dom0less step1: boot multiple domains from device tree Stefano Stabellini
2018-06-13 22:15 ` [PATCH RFC 01/15] xen: allow console_io hypercalls from DomUs on ARM Stefano Stabellini
2018-06-14 15:33   ` Julien Grall
2018-06-13 22:15 ` [PATCH RFC 02/15] xen/arm: move a few guest related #defines to public/arch-arm.h Stefano Stabellini
2018-06-14 15:36   ` Julien Grall
2018-06-14 21:15     ` Stefano Stabellini
2018-06-15 16:21       ` Julien Grall
2018-07-02 20:37         ` Stefano Stabellini
2018-07-02 21:13           ` Julien Grall
2018-07-02 21:38             ` Stefano Stabellini
2018-07-03 10:22               ` Julien Grall
2018-07-03 21:30                 ` Stefano Stabellini
2018-07-04  7:20                   ` Julien Grall
2018-06-27 14:11   ` Wei Liu
2018-06-13 22:15 ` [PATCH RFC 03/15] xen/arm: extend device tree based multiboot protocol Stefano Stabellini
2018-06-14 16:07   ` Julien Grall
2018-07-02 21:31     ` Stefano Stabellini
2018-07-03  9:35       ` Edgar E. Iglesias
2018-07-03 22:23         ` Stefano Stabellini
2018-07-03 10:40       ` Julien Grall
2018-07-03 22:16         ` Stefano Stabellini
2018-07-04 16:27           ` Julien Grall
2018-06-13 22:15 ` [PATCH RFC 04/15] xen/arm: do not pass dt_host to make_memory_node and make_hypervisor_node Stefano Stabellini
2018-06-14 16:10   ` Julien Grall
2018-06-14 21:24     ` Stefano Stabellini
2018-06-13 22:15 ` [PATCH RFC 05/15] xen/arm: rename acpi_make_chosen_node to make_chosen_node Stefano Stabellini
2018-06-14 16:16   ` Julien Grall
2018-06-14 22:01     ` Stefano Stabellini
2018-06-13 22:15 ` [PATCH RFC 06/15] xen/arm: add BOOTMOD_DOMU_KERNEL/RAMDISK Stefano Stabellini
2018-06-13 22:15 ` [PATCH RFC 07/15] xen/arm: increase MAX_MODULES Stefano Stabellini
2018-07-06  2:10   ` Doug Goldstein
2018-07-06 10:17     ` Julien Grall
2018-06-13 22:15 ` [PATCH RFC 08/15] xen/arm: probe domU kernels and initrds Stefano Stabellini
2018-06-14 16:45   ` Julien Grall
2018-07-05 20:38     ` Stefano Stabellini
2018-06-13 22:15 ` [PATCH RFC 09/15] xen/arm: refactor construct_dom0 Stefano Stabellini
2018-06-14 17:16   ` Julien Grall
2018-06-14 23:35     ` Stefano Stabellini
2018-06-15 16:32       ` Julien Grall
2018-07-05 20:55         ` Stefano Stabellini
2018-07-05 21:06           ` Julien Grall
2018-07-06 23:11             ` Stefano Stabellini
2018-06-13 22:15 ` [PATCH RFC 10/15] xen/arm: introduce construct_domU Stefano Stabellini
2018-06-14 17:25   ` Julien Grall
2018-07-05 23:00     ` Stefano Stabellini
2018-06-13 22:15 ` [PATCH RFC 11/15] xen/arm: generate a simple device tree for domUs Stefano Stabellini
2018-06-14 18:13   ` Julien Grall
2018-07-05 23:59     ` Stefano Stabellini
2018-07-06 10:22       ` Julien Grall
2018-07-06 16:16         ` Stefano Stabellini
2018-06-13 22:15 ` [PATCH RFC 12/15] xen/arm: generate vpl011 node on device tree for domU Stefano Stabellini
2018-06-15 16:58   ` Julien Grall [this message]
2018-07-06 17:11     ` Stefano Stabellini
2018-06-13 22:15 ` [PATCH RFC 13/15] xen/arm: Allow vpl011 to be used by DomU Stefano Stabellini
2018-06-15 17:38   ` Julien Grall
2018-07-06 23:10     ` Stefano Stabellini
2018-06-13 22:15 ` [PATCH RFC 14/15] xen/arm: call construct_domU from start_xen and start DomU VMs Stefano Stabellini
2018-06-15 18:24   ` Julien Grall
2018-07-06 23:11     ` Stefano Stabellini
2018-07-09 12:48       ` Julien Grall
2018-07-09 20:59         ` Stefano Stabellini
2018-07-09 21:06           ` Julien Grall
2018-07-09 21:23             ` Stefano Stabellini
2018-06-13 22:15 ` [PATCH RFC 15/15] xen: support console_switching between Dom0 and DomUs on ARM Stefano Stabellini
2018-06-14 19:08 ` [PATCH RFC 00/15] dom0less step1: boot multiple domains from device tree Edgar E. Iglesias
2018-06-14 20:34   ` Stefano Stabellini

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=551fb6cb-2358-731d-ec04-7032b216a44f@arm.com \
    --to=julien.grall@arm.com \
    --cc=andrii_anisov@epam.com \
    --cc=artem_mygaiev@epam.com \
    --cc=sstabellini@kernel.org \
    --cc=stefanos@xilinx.com \
    --cc=xen-devel@lists.xen.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.