xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: vijay.kilari@gmail.com
Cc: Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com,
	Prasun.Kapoor@caviumnetworks.com,
	vijaya.kumar@caviumnetworks.com, xen-devel@lists.xen.org,
	stefano.stabellini@citrix.com,
	Andrii Tseglytskyi <andrii.tseglytskyi@globallogic.com>
Subject: Re: [RFC PATCH v1 02/10] xen/arm: register mmio handler at runtime
Date: Thu, 20 Mar 2014 13:18:01 +0000	[thread overview]
Message-ID: <532AEA89.8040801@linaro.org> (raw)
In-Reply-To: <1395238631-2024-3-git-send-email-vijay.kilari@gmail.com>

Hello Vijay,

(Adding Andrii who is working on a similar patch).

Thanks you for the patch.

On 03/19/2014 02:17 PM, vijay.kilari@gmail.com wrote:
> From: Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>
> 
> mmio handlers are registers at compile time
> for drivers like vuart and vgic.
> Make mmio handler registered at runtime by
> creating linked list of mmio handlers
> 
> Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>
> ---
>  xen/arch/arm/io.c    |   32 +++++++++++++++++---------
>  xen/arch/arm/io.h    |   16 +++++--------
>  xen/arch/arm/vgic.c  |   61 ++++++++++++++++++++++++++------------------------
>  xen/arch/arm/vuart.c |   39 ++++++++++++++++----------------
>  4 files changed, 79 insertions(+), 69 deletions(-)
> 
> diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c
> index a6db00b..d140b29 100644
> --- a/xen/arch/arm/io.c
> +++ b/xen/arch/arm/io.c
> @@ -17,31 +17,41 @@
>   */
>  
>  #include <xen/config.h>
> +#include <xen/init.h>
> +#include <xen/kernel.h>
>  #include <xen/lib.h>
> +#include <xen/spinlock.h>
>  #include <asm/current.h>
>  
>  #include "io.h"
>  
> -static const struct mmio_handler *const mmio_handlers[] =
> -{
> -    &vgic_distr_mmio_handler,
> -    &vuart_mmio_handler,
> -};
> -#define MMIO_HANDLER_NR ARRAY_SIZE(mmio_handlers)
> +LIST_HEAD(handle_head);
> +static DEFINE_SPINLOCK(handler_lock);

As you change the code, I would prefer a per domain list IO handler. So
we can easily handle GICv2 guest on GICv3 host.

This list would only contains handlers that will be effectively used for
the domain.

>  int handle_mmio(mmio_info_t *info)
>  {
>      struct vcpu *v = current;
> -    int i;
> +    struct list_head *pos;
> +    struct mmio_handler *mmio_handle;
>  
> -    for ( i = 0; i < MMIO_HANDLER_NR; i++ )
> -        if ( mmio_handlers[i]->check_handler(v, info->gpa) )
> +    list_for_each(pos, &handle_head) {
> +        mmio_handle = list_entry(pos, struct mmio_handler, handle_list);

You can use list_for_each_entry here.

> +        if ( mmio_handle->check_handler(v, info->gpa) )
>              return info->dabt.write ?
> -                mmio_handlers[i]->write_handler(v, info) :
> -                mmio_handlers[i]->read_handler(v, info);
> +                mmio_handle->write_handler(v, info) :
> +                mmio_handle->read_handler(v, info);
> +    }
>  
>      return 0;
>  }
> +
> +void register_mmio_handler(struct mmio_handler * handle)
> +{
> +    spin_lock(&handler_lock);

Why do you take the lock here and not in handle_mmio?

> +    list_add(&handle->handle_list, &handle_head);
> +    spin_unlock(&handler_lock);
> +}
> +
>  /*
>   * Local variables:
>   * mode: C
> diff --git a/xen/arch/arm/io.h b/xen/arch/arm/io.h
> index 8d252c0..99cd7c3 100644
> --- a/xen/arch/arm/io.h
> +++ b/xen/arch/arm/io.h
> @@ -22,6 +22,7 @@
>  #include <xen/lib.h>
>  #include <asm/processor.h>
>  #include <asm/regs.h>
> +#include <xen/list.h>
>  
>  typedef struct
>  {
> @@ -30,20 +31,15 @@ typedef struct
>      paddr_t gpa;
>  } mmio_info_t;
>  
> -typedef int (*mmio_read_t)(struct vcpu *v, mmio_info_t *info);
> -typedef int (*mmio_write_t)(struct vcpu *v, mmio_info_t *info);
> -typedef int (*mmio_check_t)(struct vcpu *v, paddr_t addr);
> -

Why did you remove the typedef? It was useful for the code comprehension.

>  struct mmio_handler {
> -    mmio_check_t check_handler;
> -    mmio_read_t read_handler;
> -    mmio_write_t write_handler;
> +    int (*read_handler)(struct vcpu *v, mmio_info_t *info);
> +    int (*write_handler)(struct vcpu *v, mmio_info_t *info);
> +    int (*check_handler)(struct vcpu *v, paddr_t addr);

If we are going to a per domain list IO, I would remove check_handler
and replacing by:

paddr_t addr;
paddr_t size;

> +    struct list_head handle_list;

On a previous mail (see
http://www.gossamer-threads.com/lists/xen/devel/317457#317457) I said
that a list would be better ... but after thinking we can define a fixed
array of 16 cells. It would be enough for now.

You can see an example in arch/x86/hvm/intercept.c

>  };
>  
> -extern const struct mmio_handler vgic_distr_mmio_handler;
> -extern const struct mmio_handler vuart_mmio_handler;
> -
>  extern int handle_mmio(mmio_info_t *info);
> +void register_mmio_handler(struct mmio_handler * handle);
>  
>  #endif
>  
> diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
> index 553411d..d2a13fb 100644
> --- a/xen/arch/arm/vgic.c
> +++ b/xen/arch/arm/vgic.c
> @@ -73,34 +73,6 @@ static struct vgic_irq_rank *vgic_irq_rank(struct vcpu *v, int b, int n)
>          return NULL;
>  }
>  
> -int domain_vgic_init(struct domain *d)
> -{
> -    int i;
> -
> -    d->arch.vgic.ctlr = 0;
> -
> -    /* Currently nr_lines in vgic and gic doesn't have the same meanings
> -     * Here nr_lines = number of SPIs
> -     */
> -    if ( d->domain_id == 0 )
> -        d->arch.vgic.nr_lines = gic_number_lines() - 32;
> -    else
> -        d->arch.vgic.nr_lines = 0; /* We don't need SPIs for the guest */
> -
> -    d->arch.vgic.shared_irqs =
> -        xzalloc_array(struct vgic_irq_rank, DOMAIN_NR_RANKS(d));
> -    d->arch.vgic.pending_irqs =
> -        xzalloc_array(struct pending_irq, d->arch.vgic.nr_lines);
> -    for (i=0; i<d->arch.vgic.nr_lines; i++)
> -    {
> -        INIT_LIST_HEAD(&d->arch.vgic.pending_irqs[i].inflight);
> -        INIT_LIST_HEAD(&d->arch.vgic.pending_irqs[i].lr_queue);
> -    }
> -    for (i=0; i<DOMAIN_NR_RANKS(d); i++)
> -        spin_lock_init(&d->arch.vgic.shared_irqs[i].lock);
> -    return 0;
> -}
> -

I would predefine vgic_distr_mmio_handler early rather moving the whole
function. It's easier to understand the modification in this patch.

[..]

>  struct pending_irq *irq_to_pending(struct vcpu *v, unsigned int irq)
>  {
>      struct pending_irq *n;
> diff --git a/xen/arch/arm/vuart.c b/xen/arch/arm/vuart.c
> index b9d3ced..c237d71 100644
> --- a/xen/arch/arm/vuart.c
> +++ b/xen/arch/arm/vuart.c
> @@ -44,24 +44,6 @@
>  
>  #define domain_has_vuart(d) ((d)->arch.vuart.info != NULL)
>  
> -int domain_vuart_init(struct domain *d)
> -{
> -    ASSERT( !d->domain_id );
> -
> -    d->arch.vuart.info = serial_vuart_info(SERHND_DTUART);
> -    if ( !d->arch.vuart.info )
> -        return 0;
> -
> -    spin_lock_init(&d->arch.vuart.lock);
> -    d->arch.vuart.idx = 0;
> -
> -    d->arch.vuart.buf = xzalloc_array(char, VUART_BUF_SIZE);
> -    if ( !d->arch.vuart.buf )
> -        return -ENOMEM;
> -
> -    return 0;
> -}
> -

Same remark as domain_vgic_init.

Regards,

-- 
Julien Grall

  reply	other threads:[~2014-03-20 13:18 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-19 14:17 [RFC PATCH v1 00/10] xen/arm: Add GICv3 support vijay.kilari
2014-03-19 14:17 ` [RFC PATCH v1 01/10] xen/arm: make secondary gic init as notifier call vijay.kilari
2014-03-20 12:48   ` Julien Grall
2014-03-22  8:16     ` Vijay Kilari
2014-03-23 14:38       ` Julien Grall
2014-03-26 11:27         ` Vijay Kilari
2014-03-26 14:41           ` Julien Grall
2014-03-26 17:22             ` George Dunlap
2014-03-21 17:15   ` Ian Campbell
2014-03-22  8:32     ` Vijay Kilari
2014-03-22 13:54       ` Julien Grall
2014-03-24 10:53         ` Ian Campbell
2014-03-19 14:17 ` [RFC PATCH v1 02/10] xen/arm: register mmio handler at runtime vijay.kilari
2014-03-20 13:18   ` Julien Grall [this message]
2014-03-21 13:19     ` Andrii Tseglytskyi
2014-03-21 17:17   ` Ian Campbell
2014-03-21 17:23     ` Julien Grall
2014-03-26 12:29       ` Vijay Kilari
2014-03-26 14:47         ` Julien Grall
2014-03-27  5:40           ` Vijay Kilari
2014-03-27 15:02             ` Julien Grall
2014-04-01  9:34               ` Vijay Kilari
2014-04-01 11:00                 ` Julien Grall
2014-04-01 12:32                   ` Vijay Kilari
2014-04-01 12:44                     ` Ian Campbell
2014-04-01 12:51                     ` Julien Grall
2014-04-01 13:05                       ` Vijay Kilari
2014-04-01 13:56                         ` Julien Grall
2014-03-19 14:17 ` [RFC PATCH v1 03/10] xen/arm: move vgic data to vgic driver vijay.kilari
2014-03-20 13:51   ` Julien Grall
2014-03-21 17:23     ` Ian Campbell
2014-03-22  9:20       ` Vijay Kilari
2014-03-24 10:57         ` Ian Campbell
2014-03-26 11:44           ` Vijay Kilari
2014-03-26 12:00             ` Ian Campbell
2014-03-26 12:42               ` Vijay Kilari
2014-03-22  9:17     ` Vijay Kilari
2014-03-20 17:14   ` Stefano Stabellini
2014-03-20 17:56     ` Julien Grall
2014-03-20 18:11       ` Stefano Stabellini
2014-03-21  9:22         ` Ian Campbell
2014-03-19 14:17 ` [RFC PATCH v1 04/10] arm/xen: move gic save and restore registers to gic driver vijay.kilari
2014-03-20 15:22   ` Julien Grall
2014-03-21 17:26     ` Ian Campbell
2014-03-22  9:22     ` Vijay Kilari
2014-03-20 17:23   ` Stefano Stabellini
2014-03-21 17:28     ` Ian Campbell
2014-03-22  9:27     ` Vijay Kilari
2014-03-19 14:17 ` [RFC PATCH v1 05/10] xen/arm: move gic definitions to seperate file vijay.kilari
2014-03-20 15:13   ` Julien Grall
2014-03-19 14:17 ` [RFC PATCH v1 06/10] xen/arm: split gic driver into generic and gicv2 driver vijay.kilari
2014-03-20 11:55   ` Stefano Stabellini
2014-03-22  9:32     ` Vijay Kilari
2014-03-23 14:43       ` Julien Grall
2014-03-24 11:01         ` Ian Campbell
2014-03-20 16:02   ` Julien Grall
2014-03-21 17:32     ` Ian Campbell
2014-03-21 17:37       ` Julien Grall
2014-03-22  9:40     ` Vijay Kilari
2014-03-23 15:05       ` Julien Grall
2014-03-20 16:39   ` Stefano Stabellini
2014-03-21 17:38   ` Ian Campbell
2014-03-22  9:59     ` Vijay Kilari
2014-03-24 11:06       ` Ian Campbell
2014-03-19 14:17 ` [RFC PATCH v1 07/10] xen/arm: split vgic into generic and GIC v2 specific drivers vijay.kilari
2014-03-19 14:17 ` [RFC PATCH v1 08/10] xen/arm: Add support for GIC v3 vijay.kilari
2014-03-20 12:37   ` Stefano Stabellini
2014-03-22 10:07     ` Vijay Kilari
2014-03-24 11:28       ` Ian Campbell
2014-03-24 17:01       ` Stefano Stabellini
2014-03-26 13:16         ` Vijay Kilari
2014-03-26 17:22           ` Stefano Stabellini
2014-03-20 16:40   ` Julien Grall
2014-03-22 10:21     ` Vijay Kilari
2014-03-23 14:49       ` Julien Grall
2014-03-24 11:26         ` Ian Campbell
2014-03-24 11:50           ` Julien Grall
2014-03-24 17:02       ` Stefano Stabellini
2014-03-19 14:17 ` [RFC PATCH v1 09/10] xen/arm: Add vgic " vijay.kilari
2014-03-20 12:38   ` Stefano Stabellini
2014-03-19 14:17 ` [RFC PATCH v1 10/10] xen/arm: GICv3 device tree parsing vijay.kilari
2014-03-20 16:08   ` Julien Grall
2014-03-22 10:30     ` Vijay Kilari
2014-03-24 11:43       ` Ian Campbell
2014-03-24 12:03         ` Julien Grall
2014-03-24 12:07           ` Ian Campbell
2014-03-24 12:08           ` Julien Grall
2014-03-24 17:34             ` Stefano Stabellini
2014-03-24 18:00               ` Julien Grall
2014-03-25 11:04                 ` Stefano Stabellini
2014-03-25 12:33                   ` Julien Grall
2014-03-25 12:34                     ` Julien Grall
2014-04-01 12:59                     ` Ian Campbell
2014-04-01 13:07                       ` Julien Grall
2014-03-20 11:55 ` [RFC PATCH v1 00/10] xen/arm: Add GICv3 support 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=532AEA89.8040801@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=Ian.Campbell@citrix.com \
    --cc=Prasun.Kapoor@caviumnetworks.com \
    --cc=andrii.tseglytskyi@globallogic.com \
    --cc=stefano.stabellini@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=vijay.kilari@gmail.com \
    --cc=vijaya.kumar@caviumnetworks.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).