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
Subject: Re: [PATCH v3 02/16] xen/arm: make mmio handlers domain specific
Date: Tue, 15 Apr 2014 18:07:39 +0100 [thread overview]
Message-ID: <534D675B.2070509@linaro.org> (raw)
In-Reply-To: <1397560675-29861-3-git-send-email-vijay.kilari@gmail.com>
Hello Vijaya,
Thank your for the patch.
On 04/15/2014 12:17 PM, vijay.kilari@gmail.com wrote:
> diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c
> index ada1918..1a0be89 100644
> --- a/xen/arch/arm/io.c
> +++ b/xen/arch/arm/io.c
> @@ -18,29 +18,47 @@
>
> #include <xen/config.h>
> #include <xen/lib.h>
> +#include <xen/spinlock.h>
> +#include <xen/sched.h>
> #include <asm/current.h>
> #include <asm/mmio.h>
>
> -static const struct mmio_handler *const mmio_handlers[] =
> -{
> - &vgic_distr_mmio_handler,
> - &vuart_mmio_handler,
> -};
> -#define MMIO_HANDLER_NR ARRAY_SIZE(mmio_handlers)
> -
> int handle_mmio(mmio_info_t *info)
> {
> struct vcpu *v = current;
> int i;
> + struct io_handler *mmio_handle = &v->domain->arch.io_handlers;
>
> - for ( i = 0; i < MMIO_HANDLER_NR; i++ )
> - if ( mmio_handlers[i]->check_handler(v, info->gpa) )
> + for ( i = 0; i < mmio_handle->num_entries; i++ )
> + {
> + if ( (info->gpa >= mmio_handle->mmio_handlers[i]->addr) &&
> + info->gpa < (mmio_handle->mmio_handlers[i]->addr + mmio_handle->mmio_handlers[i]->size) )
The coding style request line length below 80 characters.
> return info->dabt.write ?
> - mmio_handlers[i]->write_handler(v, info) :
> - mmio_handlers[i]->read_handler(v, info);
> -
> + mmio_handle->mmio_handlers[i]->write_handler(v, info) :
> + mmio_handle->mmio_handlers[i]->read_handler(v, info);
> + }
Newline here for clarity.
> return 0;
> }
> +
> +void register_mmio_handler(struct domain *d, struct mmio_handler * handle)
> +{
> + struct io_handler *handler = &d->arch.io_handlers;
> +
> + BUG_ON(handler->num_entries >= MAX_IO_HANDLER);
> +
> + spin_lock(&handler->lock);
> + handler->mmio_handlers[handler->num_entries] = handle;
> + handler->num_entries++;
If you plan to use spinlock only when a new entry is added, you need a
dsb(is) before increment num_entries. Smth like
handler->mmio_handlers[handler->num_entries] = handle;
dbs(sy);
handler->num_entries++;
> + spin_unlock(&handler->lock);
> +}
> +
> +int domain_io_init(struct domain *d)
> +{
> + spin_lock_init(&d->arch.io_handlers.lock);
> + d->arch.io_handlers.num_entries = 0;
Newline here for clarity.
> + return 0;
> +}
> +
> /*
> * Local variables:
> * mode: C
> diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
> index 9c404fe..d36058a 100644
> --- a/xen/arch/arm/vgic.c
> +++ b/xen/arch/arm/vgic.c
> @@ -35,6 +35,8 @@
> /* Number of ranks of interrupt registers for a domain */
> #define DOMAIN_NR_RANKS(d) (((d)->arch.vgic.nr_lines+31)/32)
>
> +static struct mmio_handler vgic_distr_mmio_handler;
> +
> /*
> * Rank containing GICD_<FOO><n> for GICD_<FOO> with
> * <b>-bits-per-interrupt
> @@ -98,6 +100,10 @@ int domain_vgic_init(struct domain *d)
> }
> for (i=0; i<DOMAIN_NR_RANKS(d); i++)
> spin_lock_init(&d->arch.vgic.shared_irqs[i].lock);
> +
> + vgic_distr_mmio_handler.addr = d->arch.vgic.dbase;
> + vgic_distr_mmio_handler.size = PAGE_SIZE;
> + register_mmio_handler(d, &vgic_distr_mmio_handler);
This is wrong. register_mmio_handler is directly copying the MMIO
handler. So updating addr will breaks other domains as the vgic.dbase
may differ.
I think my solution on V1 was correct. I.e smth like
register_mmio_handler(d, &vgic_distr_mmio_handler, address, size);
And your internal structure looks like:
struct io_handler
{
....
struct
{
const struct mmio_handler *handler;
paddr_t addr, size;
} iohandlers[MAX_SIZE];
};
[..]
> diff --git a/xen/arch/arm/vuart.c b/xen/arch/arm/vuart.c
> index 895e5cd..f43f2e5 100644
> --- a/xen/arch/arm/vuart.c
> +++ b/xen/arch/arm/vuart.c
> @@ -44,6 +44,8 @@
>
> #define domain_has_vuart(d) ((d)->arch.vuart.info != NULL)
>
> +static struct mmio_handler vuart_mmio_handler;
> +
> int domain_vuart_init(struct domain *d)
> {
> ASSERT( !d->domain_id );
> @@ -59,6 +61,10 @@ int domain_vuart_init(struct domain *d)
> if ( !d->arch.vuart.buf )
> return -ENOMEM;
>
> + vuart_mmio_handler.addr = d->arch.vuart.info->base_addr;
> + vuart_mmio_handler.size = d->arch.vuart.info->size;
> + register_mmio_handler(d, &vuart_mmio_handler);
> +
Same here...
[..]
> --- a/xen/include/asm-arm/mmio.h
> +++ b/xen/include/asm-arm/mmio.h
> @@ -35,15 +35,22 @@ typedef int (*mmio_write_t)(struct vcpu *v, mmio_info_t *info);
> typedef int (*mmio_check_t)(struct vcpu *v, paddr_t addr);
>
> struct mmio_handler {
> - mmio_check_t check_handler;
> + paddr_t addr;
> + unsigned long size;
size should be paddr_t.
> mmio_read_t read_handler;
> mmio_write_t write_handler;
> };
>
> -extern const struct mmio_handler vgic_distr_mmio_handler;
> -extern const struct mmio_handler vuart_mmio_handler;
> +#define MAX_IO_HANDLER 16
> +struct io_handler {
> + int num_entries;
> + spinlock_t lock;
> + struct mmio_handler *mmio_handlers[MAX_IO_HANDLER];
> +};
>
> extern int handle_mmio(mmio_info_t *info);
> +void register_mmio_handler(struct domain *d, struct mmio_handler * handle);
The IO handler will never be modified so it should be:
const struct mmio_handler *handler
> +int domain_io_init(struct domain *d);
>
> #endif
>
>
Regards,
--
Julien Grall
next prev parent reply other threads:[~2014-04-15 17:07 UTC|newest]
Thread overview: 107+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-15 11:17 [PATCH v3 00/16] xen/arm: Add GICv3 support vijay.kilari
2014-04-15 11:17 ` [PATCH v3 01/16] xen/arm: move io.h as mmio.h to include folder vijay.kilari
2014-04-15 16:36 ` Julien Grall
2014-04-23 14:16 ` Ian Campbell
2014-04-15 11:17 ` [PATCH v3 02/16] xen/arm: make mmio handlers domain specific vijay.kilari
2014-04-15 17:07 ` Julien Grall [this message]
2014-04-23 14:27 ` Ian Campbell
2014-04-15 11:17 ` [PATCH v3 03/16] xen/arm: make sgi handling generic vijay.kilari
2014-04-15 17:51 ` Julien Grall
2014-04-15 17:57 ` Julien Grall
2014-04-23 14:31 ` Ian Campbell
2014-04-15 11:17 ` [PATCH v3 04/16] xen/arm: remove unused parameter in do_sgi call vijay.kilari
2014-04-15 17:52 ` Julien Grall
2014-04-23 14:32 ` Ian Campbell
2014-04-25 9:28 ` Vijay Kilari
2014-04-15 11:17 ` [PATCH v3 05/16] xen/arm: move gic definitions to seperate file vijay.kilari
2014-04-23 14:34 ` Ian Campbell
2014-04-15 11:17 ` [PATCH v3 06/16] xen/arm: move gic lock out of gic data structure vijay.kilari
2014-04-23 14:35 ` Ian Campbell
2014-05-12 13:49 ` Julien Grall
2014-04-15 11:17 ` [PATCH v3 07/16] xen/arm: segregate and split GIC low level functionality vijay.kilari
2014-04-15 18:35 ` Julien Grall
2014-04-23 14:55 ` Ian Campbell
2014-04-23 15:01 ` Julien Grall
2014-04-23 16:47 ` Julien Grall
2014-04-23 17:03 ` Ian Campbell
2014-04-23 17:09 ` Julien Grall
2014-04-24 8:58 ` Ian Campbell
2014-04-24 8:19 ` Ian Campbell
2014-04-28 11:48 ` Vijay Kilari
2014-04-28 12:06 ` Julien Grall
2014-04-28 13:10 ` Vijay Kilari
2014-04-28 13:12 ` Julien Grall
2014-04-15 21:00 ` Julien Grall
2014-04-23 14:52 ` Ian Campbell
2014-04-28 14:41 ` Vijay Kilari
2014-04-28 14:58 ` Ian Campbell
2014-04-28 15:10 ` Julien Grall
2014-04-15 11:17 ` [PATCH v3 08/16] arm/xen: move GIC context data structure to gic driver vijay.kilari
2014-04-15 18:41 ` Julien Grall
2014-04-23 14:57 ` Ian Campbell
2014-04-23 14:58 ` Ian Campbell
2014-04-15 11:17 ` [PATCH v3 09/16] xen/arm: use device api to detect GIC version vijay.kilari
2014-04-15 18:49 ` Julien Grall
2014-04-23 15:01 ` Ian Campbell
2014-04-29 7:07 ` Vijay Kilari
2014-04-29 8:55 ` Ian Campbell
2014-04-29 10:13 ` Julien Grall
2014-04-15 11:17 ` [PATCH v3 10/16] xen/arm: move vgic rank data to gic header file vijay.kilari
2014-04-15 19:10 ` Julien Grall
2014-04-17 6:48 ` Vijay Kilari
2014-05-07 15:03 ` Julien Grall
2014-04-15 11:17 ` [PATCH v3 11/16] xen/arm: move vgic defines to vgic " vijay.kilari
2014-04-16 17:01 ` Julien Grall
2014-04-23 15:07 ` Ian Campbell
2014-04-23 15:11 ` Julien Grall
2014-04-23 15:15 ` Ian Campbell
2014-04-15 11:17 ` [PATCH v3 12/16] xen/arm: split vgic driver into generic and vgic-v2 driver vijay.kilari
2014-04-15 20:05 ` Julien Grall
2014-04-23 15:12 ` Ian Campbell
2014-04-15 11:17 ` [PATCH v3 13/16] xen/arm: Add support for GIC v3 vijay.kilari
2014-04-15 20:43 ` Julien Grall
2014-04-17 7:09 ` Vijay Kilari
2014-04-17 8:58 ` Ian Campbell
2014-04-17 9:02 ` Julien Grall
2014-04-17 9:57 ` Julien Grall
2014-04-17 11:00 ` Vijay Kilari
2014-04-17 11:17 ` Julien Grall
2014-04-17 14:54 ` Vijay Kilari
2014-04-17 15:12 ` Julien Grall
2014-04-23 17:01 ` Ian Campbell
2014-04-23 17:24 ` Julien Grall
2014-04-29 12:35 ` Vijay Kilari
2014-05-05 12:08 ` Vijay Kilari
2014-05-06 8:55 ` Ian Campbell
2014-05-06 14:11 ` Vijay Kilari
2014-05-06 14:18 ` Julien Grall
2014-05-06 15:47 ` Julien Grall
2014-05-22 5:58 ` Vijay Kilari
2014-05-22 9:26 ` Julien Grall
2014-05-22 12:36 ` Stefano Stabellini
2014-05-07 16:30 ` Ian Campbell
2014-05-27 18:17 ` Julien Grall
2014-04-15 11:17 ` [PATCH v3 14/16] xen/arm: Add virtual GICv3 support vijay.kilari
2014-04-17 9:27 ` Julien Grall
2014-04-24 10:37 ` Ian Campbell
2014-04-24 11:39 ` Julien Grall
2014-04-24 10:30 ` Ian Campbell
2014-05-02 9:43 ` Vijay Kilari
2014-05-02 9:56 ` Ian Campbell
2014-04-15 11:17 ` [PATCH v3 15/16] xen/arm: Update Dom0 GIC dt node with GICv3 information vijay.kilari
2014-04-18 19:57 ` Julien Grall
2014-04-24 10:46 ` Ian Campbell
2014-04-15 11:17 ` [PATCH v3 16/16] xen/arm: add SGI handling for GICv3 vijay.kilari
2014-04-18 20:20 ` Julien Grall
2014-05-02 12:57 ` Vijay Kilari
2014-05-02 14:26 ` Julien Grall
2014-05-02 15:18 ` Ian Campbell
2014-05-02 15:24 ` Julien Grall
2014-05-05 6:53 ` Vijay Kilari
2014-05-05 18:40 ` Julien Grall
2014-05-06 8:58 ` Ian Campbell
2014-05-06 9:42 ` Julien Grall
2014-05-06 10:10 ` Ian Campbell
2014-05-06 16:06 ` Julien Grall
2014-04-24 10:57 ` Ian Campbell
2014-04-24 11:43 ` 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=534D675B.2070509@linaro.org \
--to=julien.grall@linaro.org \
--cc=Ian.Campbell@citrix.com \
--cc=Prasun.Kapoor@caviumnetworks.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 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.