All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@citrix.com>
To: vijay.kilari@gmail.com, Ian.Campbell@citrix.com,
	stefano.stabellini@eu.citrix.com, stefano.stabellini@citrix.com,
	tim@xen.org, xen-devel@lists.xen.org
Cc: Prasun.Kapoor@caviumnetworks.com,
	Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>,
	manish.jaggi@caviumnetworks.com
Subject: Re: [PATCH v6 16/31] xen/arm: ITS: Add virtual ITS commands support
Date: Thu, 3 Sep 2015 16:07:09 +0100	[thread overview]
Message-ID: <55E8621D.6090601@citrix.com> (raw)
In-Reply-To: <1441019208-2764-17-git-send-email-vijay.kilari@gmail.com>

Hi Vijay,

This patch looks good to me. Mostly coding style comment and question
about your code/comments. See below.

On 31/08/15 12:06, vijay.kilari@gmail.com wrote:
> diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c
> index 14c38b3..fabbad0 100644
> --- a/xen/arch/arm/vgic-v3-its.c
> +++ b/xen/arch/arm/vgic-v3-its.c

[...]

> +bool_t is_valid_collection(struct domain *d, uint32_t col)

You should have define the prototype of is_valid_collection within this
patch rather than in patch #13.

> +{
> +    return (col <= (d->max_vcpus + 1));

col <= (vtis_get_max_collections(d)) to avoid hardcoding the number of
collection in multiple place.

> +}
> +
> +static inline uint16_t vits_get_max_collections(struct domain *d)
> +{
> +    /*
> +     * ITS only supports upto 256 collections without

up to

> +     * provisioning external memory. As per vITS design, number of
> +     * vCPUS should not exceed max number of collections.
> +     */
> +    ASSERT(d->max_vcpus < 256);

The problem with ASSERT is it's disappearing with non-debug build. Do
you ensure somewhere that it's never possible to create a domain with
more than 256 CPUs when vITS is in use?

Otherwise, bad things would happen if we are trying to create a guest
with more than 256 vCPUs.

> +
> +    return (d->max_vcpus + 1);

As said on v5, please add a comment to explain why d->max_vcpus + 1. It
could be a reference to the public spec...

> +}
> +

[...]

> +static int vits_process_int(struct vcpu *v, struct vgic_its *vits,
> +                            its_cmd_block *virt_cmd)
> +{
> +    uint32_t event, dev_id ;

Spurious space after dev_id.

> +
> +    event = virt_cmd->int_cmd.cmd;
> +    dev_id = virt_cmd->int_cmd.devid;
> +
> +    DPRINTK("%pv: vITS: INT: Device 0x%"PRIx32" id %"PRIu32"\n",
> +            v, dev_id, event);
> +
> +    /* TODO: Inject LPI */
> +
> +    return 0;
> +}


[...]

> +static int vits_process_mapc(struct vcpu *v, struct vgic_its *vits,
> +                             its_cmd_block *virt_cmd)
> +{
> +    uint16_t vcol_id;
> +    uint64_t vta = 0;

Setting vta to 0 is not necessary as you override the value 2 lines below.

Note that you could have directly assign the value in the declaration of
the variables. It would have drop 2 lines.

> +
> +    vcol_id = virt_cmd->mapc.col;
> +    vta = virt_cmd->mapc.ta;
> +
> +    DPRINTK("%pv: vITS: MAPC: vCID %"PRIu16" vTA 0x%"PRIx64" valid %"PRIu8"\n",
> +            v, vcol_id, vta, virt_cmd->mapc.valid);
> +
> +    if ( !is_valid_collection(v->domain, vcol_id) )
> +        return -EINVAL;
> +
> +    if ( virt_cmd->mapc.valid )
> +    {
> +        if ( vta > v->domain->max_vcpus )
> +            return -EINVAL;
> +        vits->collections[vcol_id].target_address = vta;
> +    }
> +    else
> +        vits->collections[vcol_id].target_address = INVALID_PADDR;
> +
> +    return 0;
> +}

[...]

> +static int vits_read_virt_cmd(struct vcpu *v, struct vgic_its *vits,
> +                              its_cmd_block *virt_cmd)
> +{
> +    paddr_t maddr;
> +    struct domain *d = v->domain;
> +    int ret;
> +
> +    ASSERT(spin_is_locked(&vits->lock));
> +
> +    if ( !(vits->cmd_base & GITS_CBASER_VALID) )
> +    {
> +        dprintk(XENLOG_G_ERR, "%pv: vITS: Invalid CBASER\n", v);
> +        return 0;
> +    }
> +
> +    /* Map only the page that is required */

IHMO the "CMD Q can be more than 1 page" was valid and useful. Sorry if
I wasn't enough clear that I wanted the typo fixed on the second sentence.

> +    maddr = (vits->cmd_base & GITS_CBASER_PA_MASK) +
> +             atomic_read(&vits->cmd_read);
> +
> +    DPRINTK("%pv: vITS: Mapping CMD Q maddr 0x%"PRIx64" read 0x%"PRIx32"\n",
> +            v, maddr, atomic_read(&vits->cmd_read));
> +
> +    ret = vits_access_guest_table(d, maddr, (void *)virt_cmd,
> +                                  sizeof(its_cmd_block), 0);
> +    if ( ret )
> +    {
> +        dprintk(XENLOG_G_ERR,
> +                "%pv: vITS: Failed to get command page @page 0x%"PRIx32"\n",
> +                v, atomic_read(&vits->cmd_read));
> +        return -EINVAL;
> +    }
> +
> +    /* No command queue is created by vits to check on Q full */

I don't understand this comment. What do you mean?

> +    atomic_add(sizeof(its_cmd_block), &vits->cmd_read);
> +    if ( atomic_read(&vits->cmd_read) == vits->cmd_qsize )
> +    {
> +         DPRINTK("%pv: vITS: Reset read @ 0x%"PRIx32" qsize 0x%"PRIx64"\n",
> +                 v, atomic_read(&vits->cmd_read), vits->cmd_qsize);
> +
> +         atomic_set(&vits->cmd_read, 0);
> +    }
> +
> +    return 0;
> +}

[...]

> +int vits_domain_init(struct domain *d)
> +{
> +    struct vgic_its *vits;
> +    int i;
> +
> +    ASSERT(is_hardware_domain(d));
> +
> +    d->arch.vgic.vits = xzalloc(struct vgic_its);
> +    if ( !d->arch.vgic.vits )
> +        return -ENOMEM;
> +
> +    vits = d->arch.vgic.vits;
> +
> +    spin_lock_init(&vits->lock);
> +
> +    vits->collections = xzalloc_array(struct its_collection,
> +                                      vits_get_max_collections(d));
> +    if ( !vits->collections )
> +        return -ENOMEM;
> +
> +    for ( i = 0; i < vits_get_max_collections(d); i++ )
> +        vits->collections[i].target_address = ~0UL;

You are using 2 different values for the invalid address: ~0UL and
INVALID_PADDR.

They are not defined the same way and even though they may give the same
result for target_address by luck you should always use the same
definition everywhere.

I would prefer to see INVALID_PADDR even though a define
VITS_TARGET_INVALID (or similar) would have been nice. Although, I'm
fine if you don't add the define.

> +
> +    return 0;
> +}

[...]

> diff --git a/xen/include/asm-arm/gic-its.h b/xen/include/asm-arm/gic-its.h
> index 42f6551..4327ba2 100644
> --- a/xen/include/asm-arm/gic-its.h
> +++ b/xen/include/asm-arm/gic-its.h
> @@ -21,6 +21,7 @@
>  #include <asm/gic_v3_defs.h>
>  #include <xen/rbtree.h>
>  
> +#define MAPC_ITT_IPA_SHIFT              8

I would much prefer to see this define with the definition of the
command structure.

>  /*
>   * ITS registers, offsets from ITS_base
>   */
> @@ -59,6 +60,7 @@
>  #define GITS_CBASER_InnerShareable      (1UL << 10)
>  #define GITS_CBASER_SHAREABILITY_MASK   (3UL << 10)
>  #define GITS_CBASER_CACHEABILITY_MASK   (7UL << 59)
> +#define GITS_CBASER_PA_MASK             (0xfffffffff000UL)
>  
>  #define GITS_BASER_NR_REGS              8
>  

Regards,

-- 
Julien Grall

  reply	other threads:[~2015-09-03 15:07 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-31 11:06 [PATCH v6 00/31] Add ITS support vijay.kilari
2015-08-31 11:06 ` [PATCH v6 01/31] xen/dt: Handle correctly node with interrupt-map in dt_for_each_irq_map vijay.kilari
2015-08-31 14:20   ` Julien Grall
2015-09-02 15:28     ` Ian Campbell
2015-09-02 15:30       ` Wei Liu
2015-09-02 15:45       ` Julien Grall
2015-09-02 15:52         ` Ian Campbell
2015-09-04 14:41         ` Ian Campbell
2015-08-31 11:06 ` [PATCH v6 02/31] xen/arm: Add bitmap_find_next_zero_area helper function vijay.kilari
2015-08-31 11:06 ` [PATCH v6 03/31] xen: Add log2 functionality vijay.kilari
2015-08-31 11:21   ` Jan Beulich
2015-08-31 11:06 ` [PATCH v6 04/31] xen/arm: Set nr_cpu_ids to available number of cpus vijay.kilari
2015-08-31 14:25   ` Julien Grall
2015-09-09 12:48     ` Ian Campbell
2015-08-31 11:06 ` [PATCH v6 05/31] xen/arm: Rename NR_IRQs and vgic_num_irqs helper function vijay.kilari
2015-08-31 14:40   ` Julien Grall
2015-09-09 13:08     ` Ian Campbell
2015-09-09 13:23       ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 06/31] xen/arm: ITS: Port ITS driver to Xen vijay.kilari
2015-08-31 15:41   ` Julien Grall
2015-09-03 17:02   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 07/31] xen/arm: ITS: Add helper functions to manage its_devices vijay.kilari
2015-08-31 11:06 ` [PATCH v6 08/31] xen/arm: ITS: Introduce msi_desc for LPIs vijay.kilari
2015-08-31 16:20   ` Julien Grall
2015-09-09 13:16   ` Ian Campbell
2015-09-09 13:28     ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 09/31] xen/arm: ITS: Add APIs to add and assign device vijay.kilari
2015-09-03 17:34   ` Julien Grall
2015-09-09 13:28     ` Ian Campbell
2015-09-09 13:44       ` Julien Grall
2015-09-09 15:07         ` Ian Campbell
2015-09-09 16:19           ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 10/31] xen/arm: ITS: Introduce gic_is_lpi helper function vijay.kilari
2015-08-31 16:49   ` Julien Grall
2015-09-01  9:02     ` Vijay Kilari
2015-09-01 11:40       ` Julien Grall
2015-09-01 11:56         ` Vijay Kilari
2015-09-01 13:02           ` Julien Grall
2015-09-03  6:32             ` Vijay Kilari
2015-09-03  9:48               ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 11/31] xen/arm: ITS: Enable compilation of physical ITS driver vijay.kilari
2015-08-31 11:06 ` [PATCH v6 12/31] xen/arm: Move vgic locking inside get_irq_priority callback vijay.kilari
2015-08-31 16:34   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 13/31] xen/arm: ITS: implement hw_irq_controller for LPIs vijay.kilari
2015-08-31 17:53   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 14/31] xen/arm: ITS: Initialize physical ITS and export lpi support vijay.kilari
2015-08-31 18:35   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 15/31] xen/arm: ITS: Add virtual ITS driver vijay.kilari
2015-09-02 17:20   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 16/31] xen/arm: ITS: Add virtual ITS commands support vijay.kilari
2015-09-03 15:07   ` Julien Grall [this message]
2015-08-31 11:06 ` [PATCH v6 17/31] xen/arm: ITS: Store LPIs allocated and IRQ ID bits per domain vijay.kilari
2015-09-03 16:25   ` Julien Grall
2015-09-07  6:59     ` Vijay Kilari
2015-09-07 10:56       ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 18/31] xen/arm: ITS: Enable virtual ITS driver vijay.kilari
2015-08-31 11:06 ` [PATCH v6 19/31] xen/arm: ITS: Export ITS info to Virtual ITS vijay.kilari
2015-09-03 16:48   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 20/31] xen/arm: ITS: Introduce helper to get number of event IDs vijay.kilari
2015-09-03 17:51   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 21/31] xen/arm: ITS: Add GITS registers emulation vijay.kilari
2015-09-07 13:14   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 22/31] xen/arm: ITS: Add virtual ITS availability check helper vijay.kilari
2015-09-07 13:41   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 23/31] xen/arm: ITS: Add 32-bit access to GICR_TYPER vijay.kilari
2015-08-31 16:06   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 24/31] xen/arm: ITS: Add GICR register emulation vijay.kilari
2015-09-07 14:20   ` Julien Grall
2015-09-07 15:26     ` Vijay Kilari
2015-09-09 13:55       ` Ian Campbell
2015-09-09 16:11         ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 25/31] xen/arm: ITS: Allocate irq descriptors for LPIs vijay.kilari
2015-08-31 11:06 ` [PATCH v6 26/31] xen/arm: ITS: Allocate pending_lpi " vijay.kilari
2015-08-31 11:06 ` [PATCH v6 27/31] xen/arm: ITS: Route LPIs vijay.kilari
2015-08-31 11:06 ` [PATCH v6 28/31] xen/arm: ITS: Add domain specific ITS initialization vijay.kilari
2015-08-31 11:06 ` [PATCH v6 29/31] xen/arm: ITS: Map ITS translation space vijay.kilari
2015-08-31 19:07   ` Julien Grall
2015-08-31 11:06 ` [PATCH v6 30/31] xen/arm: ITS: Generate ITS node for Dom0 vijay.kilari
2015-08-31 11:06 ` [PATCH v6 31/31] xen/arm: ITS: Add pci devices in ThunderX vijay.kilari
2015-09-09 15:22   ` Ian Campbell
2015-09-02 15:38 ` [PATCH v6 00/31] Add ITS support Ian Campbell
2015-09-02 15:52   ` Ian Campbell
2015-09-03 16:45 ` Julien Grall
2015-09-09 15:29 ` Ian Campbell
2015-09-14 11:00   ` Vijay Kilari
2015-09-14 11:09     ` Julien Grall
2015-09-14 13:04       ` Vijay Kilari

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=55E8621D.6090601@citrix.com \
    --to=julien.grall@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Prasun.Kapoor@caviumnetworks.com \
    --cc=Vijaya.Kumar@caviumnetworks.com \
    --cc=manish.jaggi@caviumnetworks.com \
    --cc=stefano.stabellini@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --cc=vijay.kilari@gmail.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.