xen/arm: Add GICv3 support
v2 cover xen/arm: Add GICv3 support
From: Vijaya Kumar K <[email protected]>
Made changes to existing gic and vgic drivers
to make it generic and added support for GIC v3
hw version
Tested with ARM64 simulator with single core
Major Changes in v2:
- Added per domain io handler
- Use device api to initialize gic driver
- Avoid use of void pointer to access common data
- Moved vgic address information data from domain.h
- Coding style
Vijaya Kumar K (15):
xen/arm: register mmio handler at runtime xen/arm: move vgic rank data to gic header file arm/xen: move gic save and restore registers to gic driver xen/arm: move gic definitions to seperate file xen/arm: segregate GIC low level functionality xen/arm: move gic lock out of gic data structure xen/arm: split gic driver into generic and gic-v2 driver xen/arm: use device api to detect GIC version xen/arm: segregate VGIC low level functionality xen/arm: split vgic driver into generic and vgic-v2 driver xen/arm: make GIC context data version specific xen/arm: move GIC data to driver from domain structure xen/arm: Add support for GIC v3
xen/arm: Add vgic support for GIC v3
xen/arm: update GIC dt node with GIC v3 information
xen/arch/arm/Makefile | 4 + xen/arch/arm/domain.c | 8 + xen/arch/arm/domain_build.c | 41 +- xen/arch/arm/gic-v2.c | 559 ++++++++++++++++++++++ xen/arch/arm/gic-v3.c | 927 +++++++++++++++++++++++++++++++++++++ xen/arch/arm/gic.c | 463 ++++-------------- xen/arch/arm/io.c | 34 +- xen/arch/arm/io.h | 8 +- xen/arch/arm/smp.c | 1 + xen/arch/arm/vgic-v2.c | 639 +++++++++++++++++++++++++ xen/arch/arm/vgic-v3.c | 927 +++++++++++++++++++++++++++++++++++++ xen/arch/arm/vgic.c | 577 ++--------------------- xen/arch/arm/vuart.c | 6 +- xen/include/asm-arm/device.h | 4 +- xen/include/asm-arm/domain.h | 22 +- xen/include/asm-arm/gic.h | 219 +++++---- xen/include/asm-arm/gic_v2_defs.h | 133 ++++++ xen/include/asm-arm/gic_v3_defs.h | 187 ++++++++ 18 files changed, 3691 insertions(+), 1068 deletions(-) create mode 100644 xen/arch/arm/gic-v2.c create mode 100644 xen/arch/arm/gic-v3.c create mode 100644 xen/arch/arm/vgic-v2.c create mode 100644 xen/arch/arm/vgic-v3.c create mode 100644 xen/include/asm-arm/gic_v2_defs.h create mode 100644 xen/include/asm-arm/gic_v3_defs.h
Signature · 1 line
1.7.9.5
PATCH v2 1/15 xen/arm: register mmio handler at runtime
From: Vijaya Kumar K <[email protected]>
register mmio handlers at runtime and make
mmio handlers domain specific.
--- xen/arch/arm/domain.c | 4 ++++ xen/arch/arm/io.c | 34 +++++++++++++++++++++++----------- xen/arch/arm/io.h | 8 ++++++-- xen/arch/arm/vgic.c | 4 +++- xen/arch/arm/vuart.c | 6 +++++- xen/include/asm-arm/domain.h | 1 + 6 files changed, 42 insertions(+), 15 deletions(-)
xen/arch/arm/domain.c +4 -0
@@ -34,6 +34,7 @@#include <asm/platform.h> #include "vtimer.h" #include "vuart.h" +#include "io.h" DEFINE_PER_CPU(struct vcpu *, curr_vcpu);
@@ -521,6 +522,9 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags)share_xen_page_with_guest (virt_to_page (d->shared_info), d, XENSHARE_writable); + if ( (d->arch.io_handlers = xmalloc(struct io_handler)) == NULL ) + goto fail; +if ( (rc =p2m_alloc_table (d)) !=0 ) goto fail;
xen/arch/arm/io.c +23 -11
@@ -17,31 +17,43 @@*/ #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 <xen/sched.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) +static DEFINE_SPINLOCK (handler_lock);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 ( mmio_handle->mmio_handlers[i]->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->mmio_handlers[i]->write_handler (v, info) : + mmio_handle->mmio_handlers[i]->read_handler (v, info); + }return 0 ; } + +void register_mmio_handler (struct domain *d,struct mmio_handler * handle) +{ +unsigned long flags; +struct io_handler *handler = d->arch.io_handlers; +BUG_ON (handler->num_entries >=MAX_IO_HANDLER ); + +spin_lock_irqsave (&handler_lock, flags); + handler->mmio_handlers[handler->num_entries++] = handle; +spin_unlock_irqrestore (&handler_lock, flags); +}/* * Local variables: * mode: C
xen/arch/arm/io.h +6 -2
@@ -40,10 +40,14 @@ struct mmio_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; +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);#endif
xen/arch/arm/vgic.c +3 -1
@@ -35,6 +35,7 @@/* 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
@@ -107,6 +108,7 @@ 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); +register_mmio_handler (d, &vgic_distr_mmio_handler);return 0 ; }
@@ -673,7 +675,7 @@ static int vgic_distr_mmio_check(struct vcpu *v, paddr_t addr)return (addr >= (d->arch.vgic.dbase)) && (addr < (d->arch.vgic.dbase +PAGE_SIZE )); } -const struct mmio_handler vgic_distr_mmio_handler = { +static struct mmio_handler vgic_distr_mmio_handler = { .check_handler = vgic_distr_mmio_check, .read_handler = vgic_distr_mmio_read, .write_handler = vgic_distr_mmio_write,
xen/arch/arm/vuart.c +5 -1
@@ -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,8 @@ int domain_vuart_init(struct domain *d)if ( !d->arch.vuart.buf )return -ENOMEM ; +register_mmio_handler (d, &vuart_mmio_handler); +return 0 ; }
@@ -133,7 +137,7 @@ static int vuart_mmio_write(struct vcpu *v, mmio_info_t *info)return 1 ; } -const struct mmio_handler vuart_mmio_handler = { +static struct mmio_handler vuart_mmio_handler = { .check_handler = vuart_mmio_check, .read_handler = vuart_mmio_read, .write_handler = vuart_mmio_write,
xen/include/asm-arm/domain.h +1 -0
@@ -116,6 +116,7 @@ struct arch_domainstruct hvm_domain hvm_domain;xen_pfn_t *grant_table_gpfn; +struct io_handler *io_handlers;/* Continuable domain_relinquish_resources(). */ enum { RELMEM_not_started,
Signature · 1 line
1.7.9.5
Re: [PATCH v2 01/15] xen/arm: register mmio handler at runtime
Hello vijay,
Thank your for the patch.
On 04/04/2014 12:56 PM, [email protected] wrote:
[..]
xen/arch/arm/io.c line 29
Quoted 2 lines
xen/arch/arm/io.c +1
-1-#define MMIO_HANDLER_NR ARRAY_SIZE(mmio_handlers) +static DEFINE_SPINLOCK (handler_lock);
Why a global lock rather than a domain lock?
[..]
xen/arch/arm/io.c line 53
Quoted 8 lines
xen/arch/arm/io.c +8
-0+ +void register_mmio_handler (struct domain *d,struct mmio_handler * handle) +{ +unsigned long flags; +struct io_handler *handler = d->arch.io_handlers; +BUG_ON (handler->num_entries >=MAX_IO_HANDLER ); + +spin_lock_irqsave (&handler_lock, flags);
You don't need to disable the IRQ here.
xen/arch/arm/io.h
Quoted 10 lines
xen/arch/arm/io.c +3
-0+ handler->mmio_handlers[handler->num_entries++] = handle; +spin_unlock_irqrestore (&handler_lock, flags); +}/* * Local variables: * mode: C xen/arch/arm/io.h +0
-0
As you are modifying this header. Can you move it in include/asm-arm?
Quoted 4 lines
xen/arch/arm/io.h +0
-0@@ -40,10 +40,14 @@ struct mmio_handler {mmio_write_t write_handler; };
xen/arch/arm/io.h struct mmio_handler { · line 50
Quoted 10 lines
xen/arch/arm/io.h +6
-2-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; +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);
As I said on the previous version, it would be nice to remove check callback in the mmio_handler and replace it by addr/size. It's better if we might want to change the place in the memory following the guest.
So the result function would be:
register_mmio_handler(struct domain *d, read_t read, write_t write, addr, size);
Quoted 24 lines
xen/arch/arm/io.h +0
-0#endif xen/arch/arm/vgic.c +2
-0@@ -35,6 +35,7 @@/* 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 @@ -107,6 +108,7 @@ 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); +register_mmio_handler (d, &vgic_distr_mmio_handler);return 0 ; }
xen/arch/arm/vgic.c static int vgic_distr_mmio_check(struct vcpu *v, paddr_t addr) · line 678
Quoted 5 lines
xen/arch/arm/vgic.c +1
-1@@ -673,7 +675,7 @@ static int vgic_distr_mmio_check(struct vcpu *v, paddr_t addr)return (addr >= (d->arch.vgic.dbase)) && (addr < (d->arch.vgic.dbase +PAGE_SIZE )); } -const struct mmio_handler vgic_distr_mmio_handler = { +static struct mmio_handler vgic_distr_mmio_handler = {
Why did you remove the const?
[..]
xen/include/asm-arm/domain.h struct arch_domain · line 119
Quoted 9 lines
xen/include/asm-arm/domain.h +1
-0@@ -116,6 +116,7 @@ struct arch_domainstruct hvm_domain hvm_domain;xen_pfn_t *grant_table_gpfn; +struct io_handler *io_handlers;
Why do you need a pointer here? I think can can directly use struct io_handler iohandlers.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 01/15] xen/arm: register mmio handler at runtime
Quoted 4 lines · Julien Grall
Hello vijay,
Thank your for the patch.
Quoted 9 lines
On 04/04/2014 12:56 PM, [email protected] wrote:
[..]
xen/arch/arm/io.c line 29
Quoted 2 lines
xen/arch/arm/io.c +1
-1-#define MMIO_HANDLER_NR ARRAY_SIZE(mmio_handlers) +static DEFINE_SPINLOCK (handler_lock);Why a global lock rather than a domain lock?
OK can move into domain io_handler structure
Quoted 12 lines
[..]
xen/arch/arm/io.c line 53
Quoted 8 lines
xen/arch/arm/io.c +8
-0+ +void register_mmio_handler (struct domain *d,struct mmio_handler * handle) +{ +unsigned long flags; +struct io_handler *handler = d->arch.io_handlers; +BUG_ON (handler->num_entries >=MAX_IO_HANDLER ); + +spin_lock_irqsave (&handler_lock, flags);You don't need to disable the IRQ here.
My first version is without IRQ disable. I remember Andrii suggested it
Quoted 13 lines
xen/arch/arm/io.h
Quoted 11 lines
xen/arch/arm/io.c +3
-0+ handler->mmio_handlers[handler->num_entries++] = handle; +spin_unlock_irqrestore (&handler_lock, flags); +}/* * Local variables: * mode: C xen/arch/arm/io.h +0
-0As you are modifying this header. Can you move it in
include/asm-arm?
OK.
Quoted 20 lines
Quoted 5 lines
xen/arch/arm/io.h +0
-0@@ -40,10 +40,14 @@ struct mmio_handler {mmio_write_t write_handler; };xen/arch/arm/io.h struct mmio_handler { · line 50
Quoted 10 lines
xen/arch/arm/io.h +6
-2-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; +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);As I said on the previous version, it would be nice to remove check callback in the
mmio_handlerand replace it by addr/size. It's better if we might want to change the place in the memory following the guest.
Quoted 5 lines
So the result function would be:
register_mmio_handler(struct domain *d, read_t read, write_t write, addr, size);
OK.
Quoted 23 lines
Quoted 23 lines
xen/arch/arm/io.h +0
-0#endif xen/arch/arm/vgic.c +2
-0@@ -35,6 +35,7 @@/* 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 @@ -107,6 +108,7 @@ 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); +register_mmio_handler (d, &vgic_distr_mmio_handler);return 0 ; }
Quoted 8 lines
xen/arch/arm/vgic.c static int vgic_distr_mmio_check(struct vcpu *v, paddr_t addr) · line 678
Quoted 6 lines
xen/arch/arm/vgic.c +1
-1@@ -673,7 +675,7 @@ static int vgic_distr_mmio_check(struct vcpu *v, paddr_t addr)return (addr >= (d->arch.vgic.dbase)) && (addr < (d->arch.vgic.dbase +PAGE_SIZE )); } -const struct mmio_handler vgic_distr_mmio_handler = { +static struct mmio_handler vgic_distr_mmio_handler = {Why did you remove the const?
I think, compiler is allowing forward declaration with const
Quoted 11 lines
[..]
Quoted 8 lines
xen/include/asm-arm/domain.h +0
-0@@ -116,6 +116,7 @@ struct arch_domainstruct hvm_domain hvm_domain;xen_pfn_t *grant_table_gpfn;
Quoted 5 lines
xen/include/asm-arm/domain.h struct arch_domain · line 119
Quoted 1 line
xen/include/asm-arm/domain.h +1
-0+struct io_handler *io_handlers;Why do you need a pointer here? I think can can directly use struct
io_handleriohandlers.
I just adds to increase the size of this arch_domain struct.
so allocated memory at runtime.
Quoted 4 lines
Regards,
--
Julien Grall
Re: [PATCH v2 01/15] xen/arm: register mmio handler at runtime
Quoted 12 lines · Vijay Kilari
Quoted 4 lines
Quoted 4 lines
xen/arch/arm/io.c +3
-0+ handler->mmio_handlers[handler->num_entries++] = handle; +spin_unlock_irqrestore (&handler_lock, flags); +}/* Quoted 8 lines
xen/arch/arm/io.h
Quoted 6 lines
* Local variables:
* mode: Cxen/arch/arm/io.h +0
-0As you are modifying this header. Can you move it in
Quoted 2 lines
include/asm-arm?
OK.
Please don't mix movement and modifications. Unless you are adding uses from outside xen/arch/arm requiring ugly relative includes there is no need to move this IMHO.
There is already asm/io.h which relates to readl/writel and friends. If this were to move then it would need to be to asm/mmio.h or vmmio.h something.
Ian.
Re: [PATCH v2 01/15] xen/arm: register mmio handler at runtime
Quoted 13 lines · Ian Campbell
Quoted 12 lines · Vijay Kilari
Quoted 12 lines
xen/arch/arm/io.h
Quoted 10 lines
xen/arch/arm/io.c +3
-0+ handler->mmio_handlers[handler->num_entries++] = handle; +spin_unlock_irqrestore (&handler_lock, flags); +}/* * Local variables: * mode: C xen/arch/arm/io.h +0
-0As you are modifying this header. Can you move it in
Quoted 6 lines
Quoted 2 lines
include/asm-arm?
OK.Please don't mix movement and modifications. Unless you are adding uses from outside xen/arch/arm requiring ugly relative includes there is no need to move this IMHO.
My point was to clean up and having a single place for every headers.
Quoted 3 lines
There is already
asm/io.hwhich relates to readl/writel and friends. If this were to move then it would need to be toasm/mmio.horvmmio.hsomething.
Signature · 1 line
Julien Grall
Re: [PATCH v2 01/15] xen/arm: register mmio handler at runtime
Quoted 14 lines · Julien Grall
Quoted 13 lines · Ian Campbell
Quoted 12 lines · Vijay Kilari
Quoted 12 lines
xen/arch/arm/io.h
Quoted 10 lines
xen/arch/arm/io.c +3
-0+ handler->mmio_handlers[handler->num_entries++] = handle; +spin_unlock_irqrestore (&handler_lock, flags); +}/* * Local variables: * mode: C xen/arch/arm/io.h +0
-0As you are modifying this header. Can you move it in
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
include/asm-arm?
OK.Please don't mix movement and modifications. Unless you are adding uses from outside xen/arch/arm requiring ugly relative includes there is no need to move this IMHO.
My point was to clean up and having a single place for every headers.
Why? What your goal with this "clean up"?
If a header is only used by .c files in the same directory then it is absolutely fine for the header to live in that directory and be included with
#include "foo.h"
Ian.
Re: [PATCH v2 01/15] xen/arm: register mmio handler at runtime
Quoted 18 lines · Ian Campbell
Quoted 17 lines · Julien Grall
Quoted 16 lines · Ian Campbell
Quoted 14 lines · Vijay Kilari
Quoted 4 lines
Quoted 4 lines
xen/arch/arm/io.c +3
-0+ handler->mmio_handlers[handler->num_entries++] = handle; +spin_unlock_irqrestore (&handler_lock, flags); +}/* Quoted 8 lines
xen/arch/arm/io.h
Quoted 6 lines
* Local variables:
* mode: Cxen/arch/arm/io.h +0
-0As you are modifying this header. Can you move it in
include/asm-arm?
OK.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Please don't mix movement and modifications. Unless you are adding uses from outside xen/arch/arm requiring ugly relative includes there is no need to move this IMHO.
My point was to clean up and having a single place for every headers.
Why? What your goal with this "clean up"?
His changes will basically rewrite 80% of the header. So it was a good time to move it.
Quoted 4 lines
If a header is only used by .c files in the same directory then it is absolutely fine for the header to live in that directory and be included with
#include "foo.h"
We have many headers in include/asm-arm which are only used on arch/arm.
Anyway it was a suggestion... nothing else.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 01/15] xen/arm: register mmio handler at runtime
In reply to Vijay KilariQuoted 28 lines · Vijay Kilari
Quoted 4 lines · Julien Grall
Hello vijay,
Thank your for the patch.
Quoted 9 lines
On 04/04/2014 12:56 PM, [email protected] wrote:
[..]
xen/arch/arm/io.c line 29
Quoted 2 lines
xen/arch/arm/io.c +1
-1-#define MMIO_HANDLER_NR ARRAY_SIZE(mmio_handlers) +static DEFINE_SPINLOCK (handler_lock);Why a global lock rather than a domain lock?
OK can move into domain
io_handlerstructureQuoted 12 lines
[..]
xen/arch/arm/io.c line 53
Quoted 8 lines
xen/arch/arm/io.c +8
-0+ +void register_mmio_handler (struct domain *d,struct mmio_handler * handle) +{ +unsigned long flags; +struct io_handler *handler = d->arch.io_handlers; +BUG_ON (handler->num_entries >=MAX_IO_HANDLER ); + +spin_lock_irqsave (&handler_lock, flags);You don't need to disable the IRQ here.
Quoted 1 line
My first version is without IRQ disable. I remember Andrii suggested it
(Adding Andrii in the mail).
Unless you are planning to use it in interrupt context, IHMO irqsave is not needed.
Quoted 68 lines
Quoted 13 lines
xen/arch/arm/io.h
Quoted 11 lines
xen/arch/arm/io.c +3
-0+ handler->mmio_handlers[handler->num_entries++] = handle; +spin_unlock_irqrestore (&handler_lock, flags); +}/* * Local variables: * mode: C xen/arch/arm/io.h +0
-0As you are modifying this header. Can you move it in
include/asm-arm?OK.
Quoted 20 lines
Quoted 5 lines
xen/arch/arm/io.h +0
-0@@ -40,10 +40,14 @@ struct mmio_handler {mmio_write_t write_handler; };xen/arch/arm/io.h struct mmio_handler { · line 50
Quoted 10 lines
xen/arch/arm/io.h +6
-2-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; +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);As I said on the previous version, it would be nice to remove check callback in the
mmio_handlerand replace it by addr/size. It's better if we might want to change the place in the memory following the guest.Quoted 5 lines
So the result function would be:
register_mmio_handler(struct domain *d, read_t read, write_t write, addr, size);OK.
Quoted 27 lines
Quoted 27 lines
xen/arch/arm/io.h +0
-0#endif xen/arch/arm/vgic.c +2
-0@@ -35,6 +35,7 @@/* 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 @@ -107,6 +108,7 @@ 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); +register_mmio_handler (d, &vgic_distr_mmio_handler);return 0 ; }@@ -673,7 +675,7 @@ static int vgic_distr_mmio_check(struct vcpu *v, paddr_t addr)return (addr >= (d->arch.vgic.dbase)) && (addr < (d->arch.vgic.dbase +PAGE_SIZE )); }
Quoted 6 lines
Quoted 4 lines
xen/arch/arm/vgic.c static int vgic_distr_mmio_check(struct vcpu *v, paddr_t addr) · line 678
Quoted 2 lines
xen/arch/arm/vgic.c +1
-1-const struct mmio_handler vgic_distr_mmio_handler = { +static struct mmio_handler vgic_distr_mmio_handler = {Why did you remove the const?
I think, compiler is allowing forward declaration with const
You meant doesn't allow? If so, please move the whole structure. I'd prefer code movement rather than removing a const because of compiler issue.
Quoted 12 lines
Quoted 12 lines
[..]
Quoted 8 lines
xen/include/asm-arm/domain.h +0
-0@@ -116,6 +116,7 @@ struct arch_domainstruct hvm_domain hvm_domain;xen_pfn_t *grant_table_gpfn;
Quoted 7 lines
Quoted 5 lines
xen/include/asm-arm/domain.h struct arch_domain · line 119
Quoted 1 line
xen/include/asm-arm/domain.h +1
-0+struct io_handler *io_handlers;Why do you need a pointer here? I think can can directly use struct
io_handleriohandlers.I just adds to increase the size of this
arch_domainstruct.
so allocated memory at runtime.
Do you hit the page size?
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 01/15] xen/arm: register mmio handler at runtime
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
xen/arch/arm/vgic.c static int vgic_distr_mmio_check(struct vcpu *v, paddr_t addr) · line 678
Quoted 4 lines
xen/arch/arm/vgic.c +1
-1-const struct mmio_handler vgic_distr_mmio_handler = { +static struct mmio_handler vgic_distr_mmio_handler = {Why did you remove the const?
Quoted 5 lines
Quoted 1 line
I think, compiler is allowing forward declaration with const
You meant doesn't allow? If so, please move the whole structure. I'd prefer code movement rather than removing a const because of compiler issue.
Yes, compiler does not allow. I will move the code
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
[..]
xen/include/asm-arm/domain.h struct arch_domain · line 119
Quoted 9 lines
xen/include/asm-arm/domain.h +1
-0@@ -116,6 +116,7 @@ struct arch_domainstruct hvm_domain hvm_domain;xen_pfn_t *grant_table_gpfn; +struct io_handler *io_handlers;Why do you need a pointer here? I think can can directly use struct
io_handleriohandlers.
Quoted 4 lines
Quoted 2 lines
I just adds to increase the size of this
arch_domainstruct.
so allocated memory at runtime.Do you hit the page size?
Yes, I have faced page size exhausted issue which I have reported earlier
Quoted 5 lines
Regards,
--
Julien Grall
Re: [PATCH v2 01/15] xen/arm: register mmio handler at runtime
Quoted 7 lines · Vijay Kilari
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
xen/arch/arm/vgic.c static int vgic_distr_mmio_check(struct vcpu *v, paddr_t addr) · line 678
Quoted 4 lines
xen/arch/arm/vgic.c +1
-1-const struct mmio_handler vgic_distr_mmio_handler = { +static struct mmio_handler vgic_distr_mmio_handler = {Why did you remove the const?
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
I think, compiler is allowing forward declaration with const
You meant doesn't allow? If so, please move the whole structure. I'd prefer code movement rather than removing a const because of compiler issue.
Yes, compiler does not allow. I will move the code
This is from the specification... if you declare something const you have to assign the value directly.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
[..]
xen/include/asm-arm/domain.h struct arch_domain · line 119
Quoted 9 lines
xen/include/asm-arm/domain.h +1
-0@@ -116,6 +116,7 @@ struct arch_domainstruct hvm_domain hvm_domain;xen_pfn_t *grant_table_gpfn; +struct io_handler *io_handlers;Why do you need a pointer here? I think can can directly use struct
io_handleriohandlers.
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
I just adds to increase the size of this
arch_domainstruct.
so allocated memory at runtime.Do you hit the page size?
Yes, I have faced page size exhausted issue which I have reported earlier
Did you still have the issue when you moved out GICv stuff outside?
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 01/15] xen/arm: register mmio handler at runtime
Quoted 10 lines · Julien Grall
Quoted 9 lines · Vijay Kilari
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
xen/arch/arm/vgic.c static int vgic_distr_mmio_check(struct vcpu *v, paddr_t addr) · line 678
Quoted 4 lines
xen/arch/arm/vgic.c +1
-1-const struct mmio_handler vgic_distr_mmio_handler = { +static struct mmio_handler vgic_distr_mmio_handler = {Why did you remove the const?
I think, compiler is allowing forward declaration with const
Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
You meant doesn't allow? If so, please move the whole structure. I'd prefer code movement rather than removing a const because of compiler issue.
Yes, compiler does not allow. I will move the code
This is from the specification... if you declare something const you have to assign the value directly.
Also we cannot keep it as const for the reason that register_mmio_handler fails to
assign this const pointer to handler list.
Anyway we will get rid of this structure completely after implementing check handler where read & write handler are passed as parameter to register_mmio_handler()
call.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
[..]
xen/include/asm-arm/domain.h struct arch_domain · line 119
Quoted 9 lines
xen/include/asm-arm/domain.h +1
-0@@ -116,6 +116,7 @@ struct arch_domainstruct hvm_domain hvm_domain;xen_pfn_t *grant_table_gpfn; +struct io_handler *io_handlers;Why do you need a pointer here? I think can can directly use struct
io_handleriohandlers.
Quoted 7 lines
Quoted 5 lines
Quoted 4 lines
Quoted 2 lines
I just adds to increase the size of this
arch_domainstruct.
so allocated memory at runtime.Do you hit the page size?
Yes, I have faced page size exhausted issue which I have reported earlier
Did you still have the issue when you moved out GICv stuff outside?
Now I am not getting this issue. But I feel we are on the edge. So it is always better
to allocate runtime.
Quoted 5 lines
Regards,
--
Julien Grall
Re: [PATCH v2 01/15] xen/arm: register mmio handler at runtime
Quoted 20 lines · Vijay Kilari
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 12 lines
[..]
Quoted 8 lines
xen/include/asm-arm/domain.h +0
-0@@ -116,6 +116,7 @@ struct arch_domainstruct hvm_domain hvm_domain;xen_pfn_t *grant_table_gpfn;Quoted 5 lines
xen/include/asm-arm/domain.h struct arch_domain · line 119
Quoted 1 line
xen/include/asm-arm/domain.h +1
-0+struct io_handler *io_handlers;Why do you need a pointer here? I think can can directly use struct
io_handleriohandlers.I just adds to increase the size of this
arch_domainstruct.
so allocated memory at runtime.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line
Do you hit the page size?
Yes, I have faced page size exhausted issue which I have reported earlier
Did you still have the issue when you moved out GICv stuff outside?
Now I am not getting this issue. But I feel we are on the edge. So it is always better
to allocate runtime.
Hmmmm... we are not on the edge with the current Xen:
- arm32: sizeof(struct domain) = 1024
- arm64: sizeof(struct domain) = 1408
Unless if you have added lots of fields in the structure, there is no reason to use a pointer here.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 01/15] xen/arm: register mmio handler at runtime
Quoted 29 lines · Julien Grall
Quoted 20 lines · Vijay Kilari
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 12 lines
[..]
Quoted 8 lines
xen/include/asm-arm/domain.h +0
-0@@ -116,6 +116,7 @@ struct arch_domainstruct hvm_domain hvm_domain;xen_pfn_t *grant_table_gpfn;Quoted 5 lines
xen/include/asm-arm/domain.h struct arch_domain · line 119
Quoted 1 line
xen/include/asm-arm/domain.h +1
-0+struct io_handler *io_handlers;Why do you need a pointer here? I think can can directly use struct
io_handleriohandlers.I just adds to increase the size of this
arch_domainstruct.
so allocated memory at runtime.Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line
Do you hit the page size?
Yes, I have faced page size exhausted issue which I have reported earlier
Did you still have the issue when you moved out GICv stuff outside?
Now I am not getting this issue. But I feel we are on the edge. So it is always better
to allocate runtime.
Quoted 7 lines
Hmmmm... we are not on the edge with the current Xen:
- arm32: sizeof(struct domain) = 1024
- arm64: sizeof(struct domain) = 1408Unless if you have added lots of fields in the structure, there is no reason to use a pointer here.
OK, I can remove this pointer. When I make static allocation as below
struct io_handler iohandlers;
Now all the files that includes domain.h now expects io.h defined in arch/arm to include this file for io_handler definition. So I plan to move io.h to include directory under different name as pio.h file or device_io.h?
Quoted 4 lines
Regards,
--
Julien Grall
Re: [PATCH v2 01/15] xen/arm: register mmio handler at runtime
Quoted 37 lines · Vijay Kilari
Quoted 29 lines · Julien Grall
Quoted 20 lines · Vijay Kilari
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 12 lines
[..]
Quoted 8 lines
xen/include/asm-arm/domain.h +0
-0@@ -116,6 +116,7 @@ struct arch_domainstruct hvm_domain hvm_domain;xen_pfn_t *grant_table_gpfn;Quoted 5 lines
xen/include/asm-arm/domain.h struct arch_domain · line 119
Quoted 1 line
xen/include/asm-arm/domain.h +1
-0+struct io_handler *io_handlers;Why do you need a pointer here? I think can can directly use struct
io_handleriohandlers.I just adds to increase the size of this
arch_domainstruct.
so allocated memory at runtime.Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line
Do you hit the page size?
Yes, I have faced page size exhausted issue which I have reported earlier
Did you still have the issue when you moved out GICv stuff outside?
Now I am not getting this issue. But I feel we are on the edge. So it is always better
to allocate runtime.Quoted 7 lines
Hmmmm... we are not on the edge with the current Xen:
- arm32: sizeof(struct domain) = 1024
- arm64: sizeof(struct domain) = 1408Unless if you have added lots of fields in the structure, there is no reason to use a pointer here.
Quoted 8 lines
OK, I can remove this pointer. When I make static allocation as below
struct
io_handleriohandlers;Now all the files that includes
domain.hnow expectsio.hdefined inarch/armto include this file forio_handlerdefinition. So I plan to moveio.hto include directory under different name aspio.hfile ordevice_io.h?
mmio.h I think fits the bill.
Re: [PATCH v2 01/15] xen/arm: register mmio handler at runtime
In reply to Vijay KilariHi Julien,
Quoted 64 lines · Vijay Kilari
Quoted 4 lines · Julien Grall
Hello vijay,
Thank your for the patch.
Quoted 9 lines
On 04/04/2014 12:56 PM, [email protected] wrote:
[..]
xen/arch/arm/io.c line 29
Quoted 2 lines
xen/arch/arm/io.c +1
-1-#define MMIO_HANDLER_NR ARRAY_SIZE(mmio_handlers) +static DEFINE_SPINLOCK (handler_lock);Why a global lock rather than a domain lock?
OK can move into domain
io_handlerstructureQuoted 12 lines
[..]
xen/arch/arm/io.c line 53
Quoted 8 lines
xen/arch/arm/io.c +8
-0+ +void register_mmio_handler (struct domain *d,struct mmio_handler * handle) +{ +unsigned long flags; +struct io_handler *handler = d->arch.io_handlers; +BUG_ON (handler->num_entries >=MAX_IO_HANDLER ); + +spin_lock_irqsave (&handler_lock, flags);You don't need to disable the IRQ here.
My first version is without IRQ disable. I remember Andrii suggested it
Quoted 13 lines
xen/arch/arm/io.h
Quoted 11 lines
xen/arch/arm/io.c +3
-0+ handler->mmio_handlers[handler->num_entries++] = handle; +spin_unlock_irqrestore (&handler_lock, flags); +}/* * Local variables: * mode: C xen/arch/arm/io.h +0
-0As you are modifying this header. Can you move it in
include/asm-arm?OK.
Quoted 20 lines
Quoted 5 lines
xen/arch/arm/io.h +0
-0@@ -40,10 +40,14 @@ struct mmio_handler {mmio_write_t write_handler; };xen/arch/arm/io.h struct mmio_handler { · line 50
Quoted 10 lines
xen/arch/arm/io.h +6
-2-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; +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);As I said on the previous version, it would be nice to remove check callback in the
mmio_handlerand replace it by addr/size. It's better if we might want to change the place in the memory following the guest.
Quoted 6 lines
Quoted 5 lines
So the result function would be:
register_mmio_handler(struct domain *d, read_t read, write_t write, addr, size);OK.
Though you suggested, I kept this check handler because it gives flexibility
for driver to make additional checks if required apart from just checking for address range.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
xen/arch/arm/io.h +0
-0#endif
Re: [PATCH v2 01/15] xen/arm: register mmio handler at runtime
Quoted 6 lines · Vijay Kilari
Quoted 6 lines
Quoted 6 lines
As I said on the previous version, it would be nice to remove check callback in the
mmio_handlerand replace it by addr/size. It's better if we might want to change the place in the memory following the guest.So the result function would be:
Quoted 7 lines
Quoted 4 lines
Quoted 3 lines
register_mmio_handler(struct domain *d, read_t read, write_t write, addr, size);OK.
Though you suggested, I kept this check handler because it gives flexibility
for driver to make additional checks if required apart from just checking for address range.
What kind of checks? If the handler is registered to a domain that means we want to use it, right? It would seem strange to trap once a while.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 01/15] xen/arm: register mmio handler at runtime
Quoted 11 lines · Julien Grall
Quoted 9 lines · Vijay Kilari
Quoted 9 lines
Quoted 9 lines
As I said on the previous version, it would be nice to remove check callback in the
mmio_handlerand replace it by addr/size. It's better if we might want to change the place in the memory following the guest.So the result function would be:
register_mmio_handler(struct domain *d, read_t read, write_t write, addr, size);
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
OK.
Though you suggested, I kept this check handler because it gives flexibility
for driver to make additional checks if required apart from just checking for address range.What kind of checks? If the handler is registered to a domain that means we want to use it, right? It would seem strange to trap once a while.
IMO, with check handler it will give more flexibility for driver to
various kinds of checks.
Ex: Driver wants to check for multiple addr ranges etc.,
Quoted 5 lines
Regards,
--
Julien Grall
Re: [PATCH v2 01/15] xen/arm: register mmio handler at runtime
Quoted 17 lines · Vijay Kilari
Quoted 16 lines · Julien Grall
Quoted 13 lines · Vijay Kilari
Quoted 10 lines
Quoted 9 lines
As I said on the previous version, it would be nice to remove check callback in the
mmio_handlerand replace it by addr/size. It's better if we might want to change the place in the memory following the guest.So the result function would be:
register_mmio_handler(struct domain *d, read_t read, write_t write, addr, size);OK.
Though you suggested, I kept this check handler because it gives flexibility
for driver to make additional checks if required apart from just checking for address range.
Quoted 8 lines
Quoted 2 lines
What kind of checks? If the handler is registered to a domain that means we want to use it, right? It would seem strange to trap once a while.
IMO, with check handler it will give more flexibility for driver to
various kinds of checks.
Ex: Driver wants to check for multiple addr ranges etc.,From driver POV it's easier to have one range by set of callbacks rather
than multiple range.
Because you will end up to check in 2 place the address (once in check and once in read/write callback).
You don't use this feature in your code and I don't think it will be use, so I would prefer to get a rid of check and let handle_mmio do the job for us.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 01/15] xen/arm: register mmio handler at runtime
In reply to Vijay KilariQuoted 6 lines · Vijay Kilari
Quoted 6 lines
Quoted 1 line
+void
register_mmio_handler(struct domain *d, struct mmio_handler * handle);As I said on the previous version, it would be nice to remove check callback in the
mmio_handlerand replace it by addr/size. It's better if we might want to change the place in the memory following the guest.
Quoted 6 lines
Quoted 5 lines
So the result function would be:
register_mmio_handler(struct domain *d, read_t read, write_t write, addr, size);OK.
Regardless of addr+size vs check() I don't think it is necessary to explode struct mmio_handler into separate arguments here, passing a pointer to the static struct in each driver seems much nicer.
Ian.
PATCH v2 2/15 xen/arm: move vgic rank data to gic header file
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
vgic_irq_rank structure contains gic specific
data elements. Move this out of domain.h and
allocate memory dynamically in vgic driver.
--- xen/arch/arm/domain.c | 1 + xen/arch/arm/smp.c | 1 + xen/arch/arm/vgic.c | 17 ++++++++++++++--- xen/include/asm-arm/domain.h | 13 +++---------- xen/include/asm-arm/gic.h | 10 ++++++++++ 5 files changed, 29 insertions(+), 13 deletions(-)
xen/arch/arm/domain.c +1 -0
@@ -495,6 +495,7 @@ int vcpu_initialise(struct vcpu *v)void vcpu_destroy (struct vcpu *v) {vcpu_timer_destroy (v); +vcpu_vgic_free (v);free_xenheap_pages (v->arch.stack,STACK_ORDER ); }
xen/arch/arm/smp.c +1 -0
@@ -3,6 +3,7 @@#include <asm/smp.h> #include <asm/cpregs.h> #include <asm/page.h> +#include <xen/irq.h> #include <asm/gic.h> #include <asm/flushtlb.h>
xen/arch/arm/vgic.c +14 -3
@@ -67,7 +67,7 @@ static struct vgic_irq_rank *vgic_irq_rank(struct vcpu *v, int b, int n)int rank =REG_RANK_NR (b, n);if ( rank ==0 ) -return &v->arch.vgic.private_irqs; +return v->arch.vgic.private_irqs;else if ( rank <=DOMAIN_NR_RANKS (v->domain) )return &v->domain->arch.vgic.shared_irqs[rank -1 ];else
@@ -121,9 +121,14 @@ void domain_vgic_free(struct domain *d)int vcpu_vgic_init (struct vcpu *v) {int i; + + v->arch.vgic.private_irqs = xzalloc(struct vgic_irq_rank); +if ( v->arch.vgic.private_irqs ==NULL ) +return -ENOMEM ; +memset (&v->arch.vgic.private_irqs,0 ,sizeof (v->arch.vgic.private_irqs)); -spin_lock_init (&v->arch.vgic.private_irqs.lock); +spin_lock_init (&v->arch.vgic.private_irqs->lock);memset (&v->arch.vgic.pending_irqs,0 ,sizeof (v->arch.vgic.pending_irqs));for (i =0 ; i <32 ; i++)
@@ -134,7 +139,7 @@ int vcpu_vgic_init(struct vcpu *v)/* For SGI and PPI the target is always this CPU */ for ( i =0 ; i <8 ; i++ ) - v->arch.vgic.private_irqs.itargets[i] = + v->arch.vgic.private_irqs->itargets[i] = (1 <<(v->vcpu_id+0 )) | (1 <<(v->vcpu_id+8 )) | (1 <<(v->vcpu_id+16 ))
@@ -146,6 +151,12 @@ int vcpu_vgic_init(struct vcpu *v)return 0 ; } +int vcpu_vgic_free (struct vcpu *v) +{ +xfree (v->arch.vgic.private_irqs); +return 0 ; +} +#define vgic_lock (v) spin_lock_irq(&(v)->domain->arch.vgic.lock)#define vgic_unlock (v) spin_unlock_irq(&(v)->domain->arch.vgic.lock)
xen/include/asm-arm/domain.h +3 -10
@@ -9,15 +9,8 @@#include <asm/vfp.h> #include <public/hvm/params.h> #include <xen/serial.h> - -/* Represents state corresponding to a block of 32 interrupts */ -struct vgic_irq_rank { -spinlock_t lock;/* Covers access to all other members of this struct */ -uint32_t ienable, iactive, ipend, pendsgi; -uint32_t icfg[2 ]; -uint32_t ipriority[8 ]; -uint32_t itargets[8 ]; -}; +#include <xen/irq.h> +#include <asm/gic.h> struct pending_irq {
@@ -270,7 +263,7 @@ struct arch_vcpu* struct arch_domain. */ struct pending_irq pending_irqs[32 ]; -struct vgic_irq_rank private_irqs; +struct vgic_irq_rank *private_irqs;/* This list is ordered by IRQ priority and it is used to keep * track of the IRQs that the VGIC injected into the guest.
xen/include/asm-arm/gic.h +10 -0
@@ -160,10 +160,20 @@#define DT_MATCH_GIC DT_MATCH_COMPATIBLE("arm,cortex-a15-gic"), \ DT_MATCH_COMPATIBLE("arm,cortex-a7-gic") +/* Represents state corresponding to a block of 32 interrupts */ +struct vgic_irq_rank { +spinlock_t lock;/* Covers access to all other members of this struct */ +uint32_t ienable, iactive, ipend, pendsgi; +uint32_t icfg[2 ]; +uint32_t ipriority[8 ]; +uint32_t itargets[8 ]; +}; +extern int domain_vgic_init (struct domain *d);extern void domain_vgic_free (struct domain *d);extern int vcpu_vgic_init (struct vcpu *v); +extern int vcpu_vgic_free (struct vcpu *v);extern void vgic_vcpu_inject_irq (struct vcpu *v,unsigned int irq);extern void vgic_clear_pending_irqs (struct vcpu *v);
Signature · 1 line
1.7.9.5
Re: [PATCH v2 02/15] xen/arm: move vgic rank data to gic header file
Hello Vijay,
Thank you for the patch.
Quoted 5 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
vgic_irq_rankstructure contains gic specific
data elements. Move this out ofdomain.hand
allocate memory dynamically in vgic driver.
I guess it's because you hit the maximum size of vgic structure, right? If so can you specify it in the commit message?
[..]
Quoted 14 lines
xen/arch/arm/vgic.c +1
-1@@ -67,7 +67,7 @@ static struct vgic_irq_rank *vgic_irq_rank(struct vcpu *v, int b, int n)int rank =REG_RANK_NR (b, n);if ( rank ==0 ) -return &v->arch.vgic.private_irqs; +return v->arch.vgic.private_irqs;else if ( rank <=DOMAIN_NR_RANKS (v->domain) )return &v->domain->arch.vgic.shared_irqs[rank -1 ];else
xen/arch/arm/vgic.c void domain_vgic_free(struct domain *d) · line 129
Quoted 9 lines
xen/arch/arm/vgic.c +5
-0@@ -121,9 +121,14 @@ void domain_vgic_free(struct domain *d)int vcpu_vgic_init (struct vcpu *v) {int i; + + v->arch.vgic.private_irqs = xzalloc(struct vgic_irq_rank); +if ( v->arch.vgic.private_irqs ==NULL ) +return -ENOMEM ; +memset (&v->arch.vgic.private_irqs,0 ,sizeof (v->arch.vgic.private_irqs));
You forgot to remove & in front of v->arch.vgic.private_irqs.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 02/15] xen/arm: move vgic rank data to gic header file
Quoted 5 lines · Julien Grall
Hello Vijay,
Thank you for the patch.
On 04/04/2014 12:56 PM, [email protected] wrote:
Quoted 9 lines
Quoted 5 lines
From: Vijaya Kumar K <[email protected]>
vgic_irq_rankstructure contains gic specific
data elements. Move this out ofdomain.hand
allocate memory dynamically in vgic driver.I guess it's because you hit the maximum size of vgic structure, right? If so can you specify it in the commit message?
That was one reason. Also it has GIC hw version specific variables.
So I moved it. I will take care in next revision
Quoted 19 lines
[..]
Quoted 17 lines
xen/arch/arm/vgic.c +1
-1@@ -67,7 +67,7 @@ static struct vgic_irq_rank *vgic_irq_rank(struct vcpu *v, int b, int n)int rank =REG_RANK_NR (b, n);if ( rank ==0 ) -return &v->arch.vgic.private_irqs; +return v->arch.vgic.private_irqs;else if ( rank <=DOMAIN_NR_RANKS (v->domain) )return &v->domain->arch.vgic.shared_irqs[rank -1 ];else @@ -121,9 +121,14 @@ void domain_vgic_free(struct domain *d)int vcpu_vgic_init (struct vcpu *v) {int i;
Quoted 8 lines
xen/arch/arm/vgic.c void domain_vgic_free(struct domain *d) · line 129
Quoted 6 lines
xen/arch/arm/vgic.c +5
-0+ + v->arch.vgic.private_irqs = xzalloc(struct vgic_irq_rank); +if ( v->arch.vgic.private_irqs ==NULL ) +return -ENOMEM ; +memset (&v->arch.vgic.private_irqs,0 ,sizeof (v->arch.vgic.private_irqs));You forgot to remove & in front of
v->arch.vgic.private_irqs.
OK
Quoted 4 lines
Regards,
--
Julien Grall
PATCH v2 3/15 arm/xen: move gic save and restore registers to gic driver
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
gic saved registers are moved to gic driver.
This required structure is allocated at runtime
and is saved & restored.
--- xen/arch/arm/domain.c | 3 +++ xen/arch/arm/gic.c | 26 +++++++++++++++++--------- xen/include/asm-arm/domain.h | 3 +-- xen/include/asm-arm/gic.h | 8 ++++++++ 4 files changed, 29 insertions(+), 11 deletions(-)
xen/arch/arm/domain.c +3 -0
@@ -467,6 +467,9 @@ int vcpu_initialise(struct vcpu *v) v->arch.saved_context.sp = (register_t )v->arch.cpu_info; v->arch.saved_context.pc = (register_t )continue_new_vcpu; +if ( (rc =vcpu_gic_init (v)) !=0 ) +return rc; +/* Idle VCPUs don't need the rest of this setup */ if (is_idle_vcpu (v) )return rc;
xen/arch/arm/gic.c +17 -9
@@ -106,11 +106,11 @@ void gic_save_state(struct vcpu *v)* this call and it only accesses struct vcpu fields that cannot be * accessed simultaneously by another pCPU. */ -for ( i=0 ; i<nr_lrs; i++) - v->arch.gic_lr[i] =GICH [GICH_LR + i]; +for ( i =0 ; i < nr_lrs; i++ ) + v->arch.gic_state->gic_lr[i] =GICH [GICH_LR + i]; v->arch.lr_mask =this_cpu (lr_mask); - v->arch.gic_apr =GICH [GICH_APR ]; - v->arch.gic_vmcr =GICH [GICH_VMCR ]; + v->arch.gic_state->gic_apr =GICH [GICH_APR ]; + v->arch.gic_state->gic_vmcr =GICH [GICH_VMCR ];/* Disable until next VCPU scheduled */ GICH [GICH_HCR ] =0 ;isb ();
@@ -125,10 +125,10 @@ void gic_restore_state(struct vcpu *v)return ;this_cpu (lr_mask) = v->arch.lr_mask; -for ( i=0 ; i<nr_lrs; i++) -GICH [GICH_LR + i] = v->arch.gic_lr[i]; -GICH [GICH_APR ] = v->arch.gic_apr; -GICH [GICH_VMCR ] = v->arch.gic_vmcr; +for ( i =0 ; i < nr_lrs; i++ ) +GICH [GICH_LR + i] = v->arch.gic_state->gic_lr[i]; +GICH [GICH_APR ] = v->arch.gic_state->gic_apr; +GICH [GICH_VMCR ] = v->arch.gic_state->gic_vmcr;GICH [GICH_HCR ] =GICH_HCR_EN ;isb ();
@@ -975,6 +975,14 @@ void gic_interrupt(struct cpu_user_regs *regs, int is_fiq) }while (1 ); } +int vcpu_gic_init (struct vcpu *v) +{ + v->arch.gic_state = xzalloc(struct gic_state_data); +if (!v->arch.gic_state) +return -ENOMEM ; +return 0 ; +} +int gicv_setup (struct domain *d) {int ret;
@@ -1044,7 +1052,7 @@ void gic_dump_info(struct vcpu *v)printk (" HW_LR[%d]=%x\n" , i,GICH [GICH_LR + i]); }else {for ( i =0 ; i < nr_lrs; i++ ) -printk (" VCPU_LR[%d]=%x\n" , i, v->arch.gic_lr[i]); +printk (" VCPU_LR[%d]=%x\n" , i, v->arch.gic_state->gic_lr[i]); }list_for_each_entry ( p, &v->arch.vgic.inflight_irqs, inflight )
xen/include/asm-arm/domain.h +1 -2
@@ -252,8 +252,7 @@ struct arch_vcpuuint32_t csselr;register_t vmpidr; -uint32_t gic_hcr, gic_vmcr, gic_apr; -uint32_t gic_lr[64 ]; +struct gic_state_data *gic_state;uint64_t event_mask;uint64_t lr_mask;
xen/include/asm-arm/gic.h +8 -0
@@ -169,12 +169,20 @@ struct vgic_irq_rank {uint32_t itargets[8 ]; }; +struct gic_state_data { +uint32_t gic_hcr, gic_vmcr; +uint32_t gic_apr; +uint32_t gic_lr[64 ]; +}; +extern int domain_vgic_init (struct domain *d);extern void domain_vgic_free (struct domain *d);extern int vcpu_vgic_init (struct vcpu *v);extern int vcpu_vgic_free (struct vcpu *v); +extern int vcpu_gic_init (struct vcpu *v); +extern void vgic_vcpu_inject_irq (struct vcpu *v,unsigned int irq);extern void vgic_clear_pending_irqs (struct vcpu *v);extern struct pending_irq *irq_to_pending (struct vcpu *v,unsigned int irq);
Signature · 1 line
1.7.9.5
Re: [PATCH v2 03/15] arm/xen: move gic save and restore registers to gic driver
Hello Vijay,
Thank your for the patch.
Quoted 19 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
gic saved registers are moved to gic driver.
This required structure is allocated at runtime
and is saved & restored.Signed-off-by Vijaya Kumar K <[email protected]>--- xen/arch/arm/domain.c | 3 +++ xen/arch/arm/gic.c | 26 +++++++++++++++++--------- xen/include/asm-arm/domain.h | 3 +-- xen/include/asm-arm/gic.h | 8 ++++++++ 4 files changed, 29 insertions(+), 11 deletions(-)xen/arch/arm/domain.c +0
-0
xen/arch/arm/domain.c int vcpu_initialise(struct vcpu *v) · line 472
Quoted 6 lines
xen/arch/arm/domain.c +3
-0@@ -467,6 +467,9 @@ int vcpu_initialise(struct vcpu *v) v->arch.saved_context.sp = (register_t )v->arch.cpu_info; v->arch.saved_context.pc = (register_t )continue_new_vcpu; +if ( (rc =vcpu_gic_init (v)) !=0 ) +return rc; +
You don't need to allocate it for idle VCPU. Can you move it after the if ( is_idle_vcpu(v)) ?
xen/arch/arm/domain.c int vcpu_initialise(struct vcpu *v) · line 475
Quoted 3 lines
xen/arch/arm/domain.c +0
-0/* Idle VCPUs don't need the rest of this setup */ if (is_idle_vcpu (v) )return rc;
Somewhere here.
xen/arch/arm/gic.c void gic_save_state(struct vcpu *v) · line 108
Quoted 8 lines
xen/arch/arm/gic.c +0
-0@@ -106,11 +106,11 @@ void gic_save_state(struct vcpu *v)* this call and it only accesses struct vcpu fields that cannot be * accessed simultaneously by another pCPU. */
I'm surprised that we save theses registers for idle VCPU but not restored...
With my request, you will have to add an if ( is_idle_vcpu(v) ) return in gic_save_state.
Quoted 28 lines
xen/arch/arm/gic.c +8
-8-for ( i=0 ; i<nr_lrs; i++) - v->arch.gic_lr[i] =GICH [GICH_LR + i]; +for ( i =0 ; i < nr_lrs; i++ ) + v->arch.gic_state->gic_lr[i] =GICH [GICH_LR + i]; v->arch.lr_mask =this_cpu (lr_mask); - v->arch.gic_apr =GICH [GICH_APR ]; - v->arch.gic_vmcr =GICH [GICH_VMCR ]; + v->arch.gic_state->gic_apr =GICH [GICH_APR ]; + v->arch.gic_state->gic_vmcr =GICH [GICH_VMCR ];/* Disable until next VCPU scheduled */ GICH [GICH_HCR ] =0 ;isb ();@@ -125,10 +125,10 @@ void gic_restore_state(struct vcpu *v)return ;this_cpu (lr_mask) = v->arch.lr_mask; -for ( i=0 ; i<nr_lrs; i++) -GICH [GICH_LR + i] = v->arch.gic_lr[i]; -GICH [GICH_APR ] = v->arch.gic_apr; -GICH [GICH_VMCR ] = v->arch.gic_vmcr; +for ( i =0 ; i < nr_lrs; i++ ) +GICH [GICH_LR + i] = v->arch.gic_state->gic_lr[i]; +GICH [GICH_APR ] = v->arch.gic_state->gic_apr; +GICH [GICH_VMCR ] = v->arch.gic_state->gic_vmcr;GICH [GICH_HCR ] =GICH_HCR_EN ;isb ();
xen/arch/arm/gic.c void gic_interrupt(struct cpu_user_regs *regs, int is_fiq) · line 981
Quoted 7 lines
xen/arch/arm/gic.c +4
-0@@ -975,6 +975,14 @@ void gic_interrupt(struct cpu_user_regs *regs, int is_fiq) }while (1 ); } +int vcpu_gic_init (struct vcpu *v) +{ + v->arch.gic_state = xzalloc(struct gic_state_data); +if (!v->arch.gic_state)
if ( !v->arch.gic_state )
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 03/15] arm/xen: move gic save and restore registers to gic driver
In reply to [email protected]Quoted 3 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
gic saved registers are moved to gic driver.
This required structure is allocated at runtime
and is saved & restored.
I don't follow why this change required switch to allocating them dynamically. If it is a v2 vs v3 thing then I think a union in struct arch_vcpu would be fine, unless the v3 stuff is relatively enormous.
xen/arch/arm/gic.c void gic_save_state(struct vcpu *v) · line 113
Quoted 4 lines
xen/arch/arm/gic.c +2
-2- v->arch.gic_apr =GICH [GICH_APR ]; - v->arch.gic_vmcr =GICH [GICH_VMCR ]; + v->arch.gic_state->gic_apr =GICH [GICH_APR ]; + v->arch.gic_state->gic_vmcr =GICH [GICH_VMCR ];
I think the gic on the field name is now redundant, at I reckon you can drop _state too.
IOW v->arch.gic->apr, v->arch.gic->vmcr, etc.
(or v->arch.gic.v2.apr / v->arch.gic_v2.apr based on the first comment)
Ian.
Re: [PATCH v2 03/15] arm/xen: move gic save and restore registers to gic driver
Quoted 10 lines · Ian Campbell
Quoted 3 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
gic saved registers are moved to gic driver.
This required structure is allocated at runtime
and is saved & restored.I don't follow why this change required switch to allocating them dynamically. If it is a v2 vs v3 thing then I think a union in struct
arch_vcpuwould be fine, unless the v3 stuff is relatively enormous.
v2:
struct gic_state_data {
uint32_t gic_hcr, gic_vmcr;
uint32_t gic_apr;
uint32_t gic_lr[64];
};v3:
struct gic_state_data {
uint32_t gic_hcr, gic_vmcr;
uint32_t gic_apr0[4];
uint32_t gic_apr1[4];
uint64_t gic_lr[16];};
Except hcr & vmcr registers, v2 & v3 are different. Does static allocation helps in caching the domain struct and is this the reason for not choosing dynamic allocation? If so, I would suggest to move this structure to gic.h without dynamic allocation?
Quoted 14 lines
xen/arch/arm/gic.c void gic_save_state(struct vcpu *v) · line 113
Quoted 4 lines
xen/arch/arm/gic.c +2
-2- v->arch.gic_apr =GICH [GICH_APR ]; - v->arch.gic_vmcr =GICH [GICH_VMCR ]; + v->arch.gic_state->gic_apr =GICH [GICH_APR ]; + v->arch.gic_state->gic_vmcr =GICH [GICH_VMCR ];I think the gic on the field name is now redundant, at I reckon you can drop
_statetoo.IOW
v->arch.gic->apr,v->arch.gic->vmcr, etc.(or
v->arch.gic.v2.apr/v->arch.gic_v2.aprbased on the first comment)Ian.
Re: [PATCH v2 03/15] arm/xen: move gic save and restore registers to gic driver
Quoted 19 lines · Vijay Kilari
Quoted 10 lines · Ian Campbell
Quoted 3 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
gic saved registers are moved to gic driver.
This required structure is allocated at runtime
and is saved & restored.I don't follow why this change required switch to allocating them dynamically. If it is a v2 vs v3 thing then I think a union in struct
arch_vcpuwould be fine, unless the v3 stuff is relatively enormous.v2:
struct gic_state_data { uint32_t gic_hcr, gic_vmcr; uint32_t gic_apr; uint32_t gic_lr[64]; };v3:
Quoted 8 lines
struct gic_state_data { uint32_t gic_hcr, gic_vmcr; uint32_t gic_apr0[4]; uint32_t gic_apr1[4]; uint64_t gic_lr[16];};
Except hcr & vmcr registers, v2 & v3 are different.
looks like it is 268 bytes for v2 and 168 for v3 (surprised it gets smaller! Fewer LRs I suppose)
Quoted 2 lines
Does static allocation helps in caching the domain struct and is this the reason for not choosing dynamic allocation?
Right plus it avoids a pointer indirection. Maybe that's not so important, but it also reduces code complexity a bit and we can defer that complexity until the size of the vcpu struct gets too big.
Quoted 2 lines
If so, I would suggest to move this structure to
gic.hwithout dynamic allocation?
Shouldn't they be in gic_v2_defs.h and gic_v3_defs.h respectively, adn with a distinct name? Then in struct arch_vcpu:
union {
struct gic_v2_state v2;
struct gic_v3_state v3;
} gic;PATCH v2 4/15 xen/arm: move gic definitions to seperate file
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Move gic v2 register definitions to separate file
so that gic.h will hold only common definitions
and helps to define gic v3 definitions.
--- xen/arch/arm/gic.c | 1 + xen/arch/arm/vgic.c | 1 + xen/include/asm-arm/gic.h | 114 ------------------------------ xen/include/asm-arm/gic_v2_defs.h | 139 +++++++++++++++++++++++++++++++++++++ 4 files changed, 141 insertions(+), 114 deletions(-)
xen/arch/arm/gic.c +1 -0
@@ -32,6 +32,7 @@#include <asm/domain.h> #include <asm/platform.h> +#include <asm/gic_v2_defs.h> #include <asm/gic.h> /* Access to the GIC Distributor registers through the fixmap */
xen/arch/arm/vgic.c +1 -0
@@ -28,6 +28,7 @@#include <asm/current.h> #include "io.h" +#include <asm/gic_v2_defs.h> #include <asm/gic.h> #define REG (n) (n/4)
xen/include/asm-arm/gic.h +0 -114
120 lines not on this page · raw message
xen/include/asm-arm/gic_v2_defs.h new file +139 -0
139 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH v2 04/15] xen/arm: move gic definitions to seperate file
Hi Vijaya,
Thank you for the patch.
xen/include/asm-arm/gic_v2_defs.h line 5
Quoted 11 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
xen/include/asm-arm/gic_v2_defs.h new file +5
-0@@ -0,0 +1,139 @@ +/* +* ARM Generic Interrupt Controller support v2 +* +* Vijaya Kumar K <[email protected]> +* Copyright (c) 2014 Cavium Inc.
I'm not very familiar with copyright in general... but as this is code movement, should not you keep the copyright of Tim?
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 04/15] xen/arm: move gic definitions to seperate file
Quoted 5 lines · Julien Grall
Hi Vijaya,
Thank you for the patch.
On 04/04/2014 12:56 PM, [email protected] wrote:
Quoted 15 lines
xen/include/asm-arm/gic_v2_defs.h line 5
Quoted 11 lines
xen/include/asm-arm/gic_v2_defs.h new file +5
-0@@ -0,0 +1,139 @@ +/* +* ARM Generic Interrupt Controller support v2 +* +* Vijaya Kumar K <[email protected]> +* Copyright (c) 2014 Cavium Inc. I'm not very familiar with copyright in general... but as this is code movement, should not you keep the copyright of Tim?
I am also not aware it. I kept as it in V1. You have asked me to change it so I did. Anyways, I will put copyright of Tim
Quoted 4 lines
Regards,
--
Julien Grall
Re: [PATCH v2 04/15] xen/arm: move gic definitions to seperate file
Quoted 21 lines · Vijay Kilari
Quoted 5 lines · Julien Grall
Hi Vijaya,
Thank you for the patch.
On 04/04/2014 12:56 PM, [email protected] wrote:
Quoted 15 lines
xen/include/asm-arm/gic_v2_defs.h line 5
Quoted 11 lines
xen/include/asm-arm/gic_v2_defs.h new file +5
-0@@ -0,0 +1,139 @@ +/* +* ARM Generic Interrupt Controller support v2 +* +* Vijaya Kumar K <[email protected]> +* Copyright (c) 2014 Cavium Inc. I'm not very familiar with copyright in general... but as this is code movement, should not you keep the copyright of Tim?
Quoted 2 lines
I am also not aware it. I kept as it in V1. You have asked me to change it so I did. Anyways, I will put copyright of Tim
Hrm, I read my mail and I didn't ask to modify the copyright... by guard I meant include guard:
#ifndef __ASM_ARM_GIC_V2_DEFS_H__
#define __ASM_ARM_GIC_V2_DEFS_H__
your content
#endif /* __ASM_ARM_GIC_V2_DEFS_H__
Without this the header is not protected against multiple inclusion.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 04/15] xen/arm: move gic definitions to seperate file
In reply to Vijay KilariQuoted 21 lines · Vijay Kilari
Quoted 5 lines · Julien Grall
Hi Vijaya,
Thank you for the patch.
On 04/04/2014 12:56 PM, [email protected] wrote:
Quoted 15 lines
xen/include/asm-arm/gic_v2_defs.h line 5
Quoted 11 lines
xen/include/asm-arm/gic_v2_defs.h new file +5
-0@@ -0,0 +1,139 @@ +/* +* ARM Generic Interrupt Controller support v2 +* +* Vijaya Kumar K <[email protected]> +* Copyright (c) 2014 Cavium Inc. I'm not very familiar with copyright in general... but as this is code movement, should not you keep the copyright of Tim?
Quoted 2 lines
I am also not aware it. I kept as it in V1. You have asked me to change it so I did. Anyways, I will put copyright of Tim
Yes, you need to keep the copyrights in place for sure.
Ian.
PATCH v2 5/15 xen/arm: segregate GIC low level functionality
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
GIC low level functionality is segregated into separate functions and are called using registered callback wherever required.
This helps to separate generic and hardware functionality later
--- xen/arch/arm/gic.c | 362 ++++++++++++++++++++++++++++--------- xen/include/asm-arm/gic.h | 50 +++++ xen/include/asm-arm/gic_v2_defs.h | 16 +- 3 files changed, 328 insertions(+), 100 deletions(-)
xen/arch/arm/gic.c +273 -89
@@ -57,8 +57,21 @@ static irq_desc_t irq_desc[NR_IRQS]; static DEFINE_PER_CPU(irq_desc_t[NR_LOCAL_IRQS], local_irq_desc); static DEFINE_PER_CPU(uint64_t, lr_mask); +static struct gic_hw_operations *gic_hw_ops; +static struct gic_hw_operations gic_ops; + +void register_gic_ops (struct gic_hw_operations *ops) +{ + gic_hw_ops = ops; +} + +void update_cpu_lr_mask (void ) +{ +this_cpu (lr_mask) =0ULL ; +} +static uint8_t nr_lrs; -#define lr_all_full () (this_cpu(lr_mask) == ((1 << nr_lrs) - 1)) +#define lr_all_full () (this_cpu(lr_mask) == ((1 << gic_hw_ops->nr_lrs()) - 1))/* The GIC mapping of CPU interfaces does not necessarily match the * logical CPU numbering. Let's use mapping as returned by the GIC
@@ -89,48 +102,124 @@ static unsigned int gic_cpu_mask(const cpumask_t *cpumask)unsigned int gic_number_lines (void ) { +return gic_hw_ops->nr_lines (); +} + +static unsigned int gic_nr_lines (void ) +{return gic.lines; } -irq_desc_t *__irq_to_desc (int irq) +static unsigned int gic_nr_lrs (void ) { -if (irq <NR_LOCAL_IRQS )return &this_cpu (local_irq_desc)[irq]; -return &irq_desc[irq-NR_LOCAL_IRQS ]; +return nr_lrs; } -void gic_save_state (struct vcpu *v) +static int gic_state_init (struct vcpu *v) +{ + v->arch.gic_state = xzalloc(struct gic_state_data); +if (!v->arch.gic_state) +return -ENOMEM ; +return 0 ; +} + +static void save_state (struct vcpu *v) {int i; -ASSERT (!local_irq_is_enabled ());/* No need for spinlocks here because interrupts are disabled around * this call and it only accesses struct vcpu fields that cannot be * accessed simultaneously by another pCPU. */ -for ( i =0 ; i < nr_lrs; i++ ) +for ( i =0 ; i < nr_lrs; i++) v->arch.gic_state->gic_lr[i] =GICH [GICH_LR + i]; - v->arch.lr_mask =this_cpu (lr_mask); v->arch.gic_state->gic_apr =GICH [GICH_APR ]; v->arch.gic_state->gic_vmcr =GICH [GICH_VMCR ];/* Disable until next VCPU scheduled */ GICH [GICH_HCR ] =0 ; +} + +static void restore_state (struct vcpu *v) +{ +int i; + +for ( i =0 ; i < nr_lrs; i++ ) +GICH [GICH_LR + i] = v->arch.gic_state->gic_lr[i]; +GICH [GICH_APR ] = v->arch.gic_state->gic_apr; +GICH [GICH_VMCR ] = v->arch.gic_state->gic_vmcr; +GICH [GICH_HCR ] =GICH_HCR_EN ; +} + +static void gic_dump_state (struct vcpu *v) +{ +int i; +if ( v == current ) + { +for ( i =0 ; i < nr_lrs; i++ ) +printk (" HW_LR[%d]=%x\n" , i,GICH [GICH_LR + i]); + }else { +for ( i =0 ; i < nr_lrs; i++ ) +printk (" VCPU_LR[%d]=%x\n" , i, v->arch.gic_state->gic_lr[i]); + } +} + +static void gic_enable_irq (int irq) +{ +/* Enable routing */ +GICD [GICD_ISENABLER + irq /32 ] = (1u << (irq %32 )); +} + +static void gic_disable_irq (int irq) +{ +/* Disable routing */ +GICD [GICD_ICENABLER + irq /32 ] = (1u << (irq %32 )); +} + +static void gic_eoi_irq (int irq) +{ +/* Lower the priority */ +GICC [GICC_EOIR ] = irq; +} + +static void gic_dir_irq (int irq) +{ +/* Deactivate */ +GICC [GICC_DIR ] = irq; +} + +static unsigned int gic_ack_irq (void ) +{ +return (GICC [GICC_IAR ] &GICC_IA_IRQ ); +} + +irq_desc_t *__irq_to_desc (int irq) +{ +if (irq <NR_LOCAL_IRQS )return &this_cpu (local_irq_desc)[irq]; +return &irq_desc[irq-NR_LOCAL_IRQS ]; +} + +void gic_save_state (struct vcpu *v) +{ +ASSERT (!local_irq_is_enabled ()); + +/* No need for spinlocks here because interrupts are disabled around +* this call and it only accesses struct vcpu fields that cannot be +* accessed simultaneously by another pCPU. +*/ + v->arch.lr_mask =this_cpu (lr_mask); + gic_hw_ops->save_state (v);isb (); }void gic_restore_state (struct vcpu *v) { -int i;ASSERT (!local_irq_is_enabled ());if (is_idle_vcpu (v) )return ;this_cpu (lr_mask) = v->arch.lr_mask; -for ( i =0 ; i < nr_lrs; i++ ) -GICH [GICH_LR + i] = v->arch.gic_state->gic_lr[i]; -GICH [GICH_APR ] = v->arch.gic_state->gic_apr; -GICH [GICH_VMCR ] = v->arch.gic_state->gic_vmcr; -GICH [GICH_HCR ] =GICH_HCR_EN ; + gic_hw_ops->restore_state (v);isb ();gic_restore_pending_irqs (v);
@@ -146,7 +235,7 @@ static void gic_irq_enable(struct irq_desc *desc) desc->status &= ~IRQ_DISABLED ;dsb (sy);/* Enable routing */ -GICD [GICD_ISENABLER + irq /32 ] = (1u << (irq %32 )); + gic_hw_ops->enable_irq (irq);spin_unlock (&gic.lock);spin_unlock_irqrestore (&desc->lock, flags); }
@@ -159,7 +248,7 @@ static void gic_irq_disable(struct irq_desc *desc)spin_lock_irqsave (&desc->lock, flags);spin_lock (&gic.lock);/* Disable routing */ -GICD [GICD_ICENABLER + irq /32 ] = (1u << (irq %32 )); + gic_hw_ops->disable_irq (irq); desc->status |=IRQ_DISABLED ;spin_unlock (&gic.lock);spin_unlock_irqrestore (&desc->lock, flags);
@@ -185,16 +274,16 @@ static void gic_host_irq_end(struct irq_desc *desc) {int irq = desc->irq;/* Lower the priority */ -GICC [GICC_EOIR ] = irq; + gic_hw_ops->eoi_irq (irq);/* Deactivate */ -GICC [GICC_DIR ] = irq; + gic_hw_ops->deactivate_irq (irq); }static void gic_guest_irq_end (struct irq_desc *desc) {int irq = desc->irq;/* Lower the priority of the IRQ */ -GICC [GICC_EOIR ] = irq; + gic_hw_ops->eoi_irq (irq);/* Deactivation happens in maintenance interrupt / via GICV */ }
@@ -230,7 +319,7 @@ static hw_irq_controller gic_guest_irq_type = {* - needs to be called with a valid cpu_mask, ie each cpu in the mask has * already called gic_cpu_init */ -static void gic_set_irq_properties (unsigned int irq,bool_t level, +static void gic_set_irq_property (unsigned int irq,bool_t level,const cpumask_t *cpu_mask,unsigned int priority) {
@@ -257,6 +346,13 @@ static void gic_set_irq_properties(unsigned int irq, bool_t level, } +static void gic_set_irq_properties (unsigned int irq,bool_t level, +const cpumask_t *cpu_mask, +unsigned int priority) +{ +return gic_hw_ops->set_irq_property (irq, level, cpu_mask, priority); +} +/* Program the GIC to route an interrupt */ static int gic_route_irq (unsigned int irq,bool_t level,const cpumask_t *cpu_mask,unsigned int priority)
@@ -377,7 +473,7 @@ static void __cpuinit gic_hyp_init(void) nr_lrs = (vtr &GICH_VTR_NRLRGS ) +1 ;GICH [GICH_MISR ] =GICH_MISR_EOI ; -this_cpu (lr_mask) =0ULL ; +update_cpu_lr_mask (); }static void __cpuinit gic_hyp_disable (void )
@@ -478,10 +574,22 @@ void __init gic_init(void)gic_cpu_init ();gic_hyp_init (); +register_gic_ops (&gic_ops);spin_unlock (&gic.lock); } -void send_SGI_mask (const cpumask_t *cpumask,enum gic_sgi sgi) +static void gic_secondary_cpu_init (void ) +{ +gic_cpu_init (); +gic_hyp_init (); +} + +static struct dt_irq *gic_maintenance_irq (void ) +{ +return &gic.maintenance; +} + +static void gic_send_sgi (const cpumask_t *cpumask,enum gic_sgi sgi) {unsigned int mask =0 ;cpumask_t online_mask;
@@ -498,30 +606,26 @@ void send_SGI_mask(const cpumask_t *cpumask, enum gic_sgi sgi) | sgi; } -void send_SGI_one (unsigned int cpu,enum gic_sgi sgi) +void send_SGI_mask (const cpumask_t *cpumask,enum gic_sgi sgi) { -ASSERT (cpu <NR_GIC_CPU_IF );/* Targets bitmap only supports 8 CPUs */ -send_SGI_mask (cpumask_of (cpu), sgi); + gic_hw_ops->send_sgi (cpumask, sgi); } -void send_SGI_self (enum gic_sgi sgi) +void send_SGI_one (unsigned int cpu,enum gic_sgi sgi) { -ASSERT (sgi <16 );/* There are only 16 SGIs */ - -dsb (sy); - -GICD [GICD_SGIR ] =GICD_SGI_TARGET_SELF - | sgi; +ASSERT (cpu <NR_GIC_CPU_IF );/* Targets bitmap only supports 8 CPUs */ +send_SGI_mask (cpumask_of (cpu), sgi); }void send_SGI_allbutself (enum gic_sgi sgi) { -ASSERT (sgi <16 );/* There are only 16 SGIs */ +cpumask_t all_others_mask; +ASSERT (sgi <16 );/* There are only 16 SGIs */ -dsb (sy); +cpumask_andnot (&all_others_mask, &cpu_possible_map,cpumask_of (smp_processor_id ())); -GICD [GICD_SGIR ] =GICD_SGI_TARGET_OTHERS - | sgi; +dsb (sy); +send_SGI_mask (&all_others_mask, sgi); }void smp_send_state_dump (unsigned int cpu)
@@ -533,26 +637,30 @@ void smp_send_state_dump(unsigned int cpu)void __cpuinit gic_init_secondary_cpu (void ) {spin_lock (&gic.lock); -gic_cpu_init (); -gic_hyp_init (); + gic_hw_ops->secondary_init ();spin_unlock (&gic.lock); }/* Shut down the per-CPU GIC interface */ +static void gic_disable_interface (void ) +{ +gic_cpu_disable (); +gic_hyp_disable (); +} +void gic_disable_cpu (void ) {ASSERT (!local_irq_is_enabled ());spin_lock (&gic.lock); -gic_cpu_disable (); -gic_hyp_disable (); + gic_hw_ops->disable_interface ();spin_unlock (&gic.lock); }void gic_route_ppis (void ) {/* GIC maintenance */ -gic_route_dt_irq (&gic.maintenance,cpumask_of (smp_processor_id ()), +gic_route_dt_irq (gic_hw_ops->get_maintenance_irq (),cpumask_of (smp_processor_id ()),GIC_PRI_IRQ );/* Route timer interrupt */ route_timer_interrupt ();
@@ -627,23 +735,31 @@ int __init setup_dt_irq(const struct dt_irq *irq, struct irqaction *new)return rc; } -static inline void gic_set_lr (int lr,struct pending_irq *p, -unsigned int state) +static void gic_update_lr (int lr,struct pending_irq *p,unsigned int state) { -uint32_t lr_reg; +int maintenance_int =GICH_LR_MAINTENANCE_IRQ ; -ASSERT (!local_irq_is_enabled ());BUG_ON (lr >= nr_lrs);BUG_ON (lr <0 );BUG_ON (state & ~(GICH_LR_STATE_MASK <<GICH_LR_STATE_SHIFT )); - lr_reg = state | ((p->priority >>3 ) <<GICH_LR_PRIORITY_SHIFT ) | +GICH [GICH_LR + lr] = ((state &0x3 ) <<GICH_LR_STATE_SHIFT ) | + maintenance_int | + ((p->priority >>3 ) <<GICH_LR_PRIORITY_SHIFT ) | ((p->irq &GICH_LR_VIRTUAL_MASK ) <<GICH_LR_VIRTUAL_SHIFT ); -if ( p->desc !=NULL ) - lr_reg |=GICH_LR_HW | (p->desc->irq <<GICH_LR_PHYSICAL_SHIFT ); +} -GICH [GICH_LR + lr] = lr_reg; +static void gic_clear_lr (int lr) +{ +GICH [GICH_LR + lr] =0 ; +} + +static inline void gic_set_lr (int lr,struct pending_irq *p, +unsigned int state) +{ +ASSERT (!local_irq_is_enabled ()); + gic_hw_ops->update_lr (lr, p, state);set_bit (GIC_IRQ_GUEST_VISIBLE , &p->status);clear_bit (GIC_IRQ_GUEST_PENDING , &p->status); p->lr = lr;
@@ -685,6 +801,7 @@ void gic_raise_guest_irq(struct vcpu *v, unsigned int virtual_irq, {int i;struct pending_irq *n =irq_to_pending (v, virtual_irq); +unsigned int nr_lrs = gic_hw_ops->nr_lrs ();ASSERT (spin_is_locked (&v->arch.vgic.lock));
@@ -711,29 +828,32 @@ void gic_raise_guest_irq(struct vcpu *v, unsigned int virtual_irq,static void gic_clear_one_lr (struct vcpu *v,int i) {struct pending_irq *p; -uint32_t lr;int irq; +struct gic_lr lr_val;ASSERT (!local_irq_is_enabled ());ASSERT (spin_is_locked (&v->arch.vgic.lock));ASSERT (!local_irq_is_enabled ()); - lr =GICH [GICH_LR + i]; - irq = (lr >>GICH_LR_VIRTUAL_SHIFT ) &GICH_LR_VIRTUAL_MASK ; + gic_hw_ops->read_lr (i, &lr_val); + irq = lr_val.virq; p =irq_to_pending (v, irq); -if ( lr &GICH_LR_ACTIVE ) +if ( lr_val.state &GICH_LR_ACTIVE ) {set_bit (GIC_IRQ_GUEST_ACTIVE , &p->status);/* HW interrupts cannot be ACTIVE and PENDING */ if ( p->desc ==NULL &&test_bit (GIC_IRQ_GUEST_ENABLED , &p->status) &&test_and_clear_bit (GIC_IRQ_GUEST_PENDING , &p->status) ) -GICH [GICH_LR + i] = lr |GICH_LR_PENDING ; - }else if ( lr &GICH_LR_PENDING ) { + { + lr_val.state |=GICH_LR_PENDING ; + gic_hw_ops->write_lr (i, &lr_val); + } + }else if ( lr_val.state &GICH_LR_PENDING ) {clear_bit (GIC_IRQ_GUEST_PENDING , &p->status); }else { -GICH [GICH_LR + i] =0 ; + gic_hw_ops->clear_lr (i);clear_bit (i, &this_cpu (lr_mask));if ( p->desc !=NULL )
@@ -754,6 +874,7 @@ void gic_clear_lrs(struct vcpu *v) {int i =0 ;unsigned long flags; +unsigned int nr_lrs = gic_hw_ops->nr_lrs ();spin_lock_irqsave (&v->arch.vgic.lock, flags);
@@ -768,10 +889,12 @@ void gic_clear_lrs(struct vcpu *v)static void gic_restore_pending_irqs (struct vcpu *v) { -int i =0 , lrs = nr_lrs; +int i =0 , lrs;struct pending_irq *p, *t, *p_r;unsigned long flags; +unsigned int nr_lrs = gic_hw_ops->nr_lrs (); + lrs = nr_lrs;if (list_empty (&v->arch.vgic.lr_pending) )return ;
@@ -828,13 +951,15 @@ void gic_clear_pending_irqs(struct vcpu *v)int gic_events_need_delivery (void ) { -int mask_priority, lrs = nr_lrs; +int mask_priority, lrs;int max_priority =0xff , active_priority =0xff ;struct vcpu *v = current;struct pending_irq *p;unsigned long flags; +unsigned int nr_lrs = gic_hw_ops->nr_lrs (); + lrs = nr_lrs; - mask_priority = (GICH [GICH_VMCR ] >>GICH_VMCR_PRIORITY_SHIFT ) &GICH_VMCR_PRIORITY_MASK ; + mask_priority = gic_hw_ops->read_vmcr_priority ();spin_lock_irqsave (&v->arch.vgic.lock, flags);
@@ -871,9 +996,9 @@ void gic_inject(void)gic_restore_pending_irqs (current);if ( !list_empty (¤t->arch.vgic.lr_pending) &&lr_all_full () ) -GICH [GICH_HCR ] |=GICH_HCR_UIE ; + gic_hw_ops->update_hcr_status (GICH_HCR_UIE ,1 );else -GICH [GICH_HCR ] &= ~GICH_HCR_UIE ; + gic_hw_ops->update_hcr_status (GICH_HCR_UIE ,0 ); } int gic_route_irq_to_guest(struct domain *d, const struct dt_irq *irq,
@@ -921,10 +1046,10 @@ out:return retval; } -static void do_sgi (struct cpu_user_regs *regs,int othercpu,enum gic_sgi sgi) +static void do_sgi (struct cpu_user_regs *regs,enum gic_sgi sgi) {/* Lower the priority */ -GICC [GICC_EOIR ] = sgi; + gic_hw_ops->eoi_irq (sgi);switch (sgi) {
@@ -943,19 +1068,16 @@ static void do_sgi(struct cpu_user_regs *regs, int othercpu, enum gic_sgi sgi) }/* Deactivate */ -GICC [GICC_DIR ] = sgi; + gic_hw_ops->deactivate_irq (sgi); }/* Accept an interrupt from the GIC and dispatch its handler */ void gic_interrupt (struct cpu_user_regs *regs,int is_fiq) { -uint32_t intack;unsigned int irq; - do { - intack = GICC[GICC_IAR]; - irq = intack & GICC_IA_IRQ; + irq = gic_hw_ops->ack_irq(); if ( likely(irq >= 16 && irq < 1021) ) {
@@ -965,8 +1087,7 @@ void gic_interrupt(struct cpu_user_regs *regs, int is_fiq) }else if (unlikely (irq <16 )) { -unsigned int cpu = (intack &GICC_IA_CPU_MASK ) >>GICC_IA_CPU_SHIFT ; -do_sgi (regs, cpu, irq); +do_sgi (regs, irq); }else {
@@ -976,15 +1097,7 @@ void gic_interrupt(struct cpu_user_regs *regs, int is_fiq) }while (1 ); } -int vcpu_gic_init (struct vcpu *v) -{ - v->arch.gic_state = xzalloc(struct gic_state_data); -if (!v->arch.gic_state) -return -ENOMEM ; -return 0 ; -} - -int gicv_setup (struct domain *d) +static int gicv_init (struct domain *d) {int ret;
@@ -1031,6 +1144,85 @@ int gicv_setup(struct domain *d) } +int vcpu_gic_init (struct vcpu *v) +{ +return gic_hw_ops->state_init (v); +} + +int gicv_setup (struct domain *d) +{ +int ret; + + ret = gic_hw_ops->gicv_setup (d); +return ret; + +} + +static void gic_read_lr (int lr,struct gic_lr *lr_reg) +{ +uint32_t lrv; + + lrv =GICH [GICH_LR + lr]; + lr_reg->pirq = (lrv >>GICH_LR_PHYSICAL_SHIFT ) &GICH_LR_PHYSICAL_MASK ; + lr_reg->virq = (lrv >>GICH_LR_VIRTUAL_SHIFT ) &GICH_LR_VIRTUAL_MASK ; + lr_reg->priority = (lrv >>GICH_LR_PRIORITY_SHIFT ) &GICH_LR_PRIORITY_MASK ; + lr_reg->state = (lrv >>GICH_LR_STATE_SHIFT ) &GICH_LR_STATE_MASK ; + lr_reg->hw_status = (lrv >>GICH_LR_HW_SHIFT ) &GICH_LR_HW_MASK ; + lr_reg->grp = (lrv >>GICH_LR_GRP_SHIFT ) &GICH_LR_GRP_MASK ; +} + +static void gic_write_lr (int lr,struct gic_lr *lr_reg) +{ +uint32_t lrv =0 ; + lrv = ( ((lr_reg->pirq &GICH_LR_PHYSICAL_MASK ) <<GICH_LR_PHYSICAL_SHIFT ) | + ((lr_reg->virq &GICH_LR_VIRTUAL_MASK ) <<GICH_LR_VIRTUAL_SHIFT ) | + ((uint32_t )(lr_reg->priority &GICH_LR_PRIORITY_MASK ) <<GICH_LR_PRIORITY_SHIFT ) | + ((uint32_t )(lr_reg->state &GICH_LR_STATE_MASK ) <<GICH_LR_STATE_SHIFT ) | + ((uint32_t )(lr_reg->hw_status &GICH_LR_HW_MASK ) <<GICH_LR_HW_SHIFT ) | + ((uint32_t )(lr_reg->grp &GICH_LR_GRP_MASK ) <<GICH_LR_GRP_SHIFT ) ); + +GICH [GICH_LR + lr] = lrv; +} + +static void gic_hcr_status (uint32_t flag,uint8_t status) +{ +if ( status ) +GICH [GICH_HCR ] |= flag; +else +GICH [GICH_HCR ] &= ~flag; +} + +static unsigned int gic_read_vmcr_priority (void ) +{ +return (GICH [GICH_VMCR ] >>GICH_VMCR_PRIORITY_SHIFT ) &GICH_VMCR_PRIORITY_MASK ; +} + +static struct gic_hw_operations gic_ops = { + .nr_lines = gic_nr_lines, + .nr_lrs = gic_nr_lrs, + .secondary_init = gic_secondary_cpu_init, + .get_maintenance_irq = gic_maintenance_irq, + .state_init = gic_state_init, + .save_state = save_state, + .restore_state = restore_state, + .dump_state = gic_dump_state, + .gicv_setup = gicv_init, + .enable_irq = gic_enable_irq, + .disable_irq = gic_disable_irq, + .eoi_irq = gic_eoi_irq, + .deactivate_irq = gic_dir_irq, + .ack_irq = gic_ack_irq, + .set_irq_property = gic_set_irq_property, + .send_sgi = gic_send_sgi, + .disable_interface = gic_disable_interface, + .update_lr = gic_update_lr, + .update_hcr_status = gic_hcr_status, + .clear_lr = gic_clear_lr, + .read_lr = gic_read_lr, + .write_lr = gic_write_lr, + .read_vmcr_priority = gic_read_vmcr_priority, +}; +static void maintenance_interrupt (int irq,void *dev_id,struct cpu_user_regs *regs) {/*
@@ -1043,18 +1235,10 @@ static void maintenance_interrupt(int irq, void *dev_id, struct cpu_user_regs *rvoid gic_dump_info (struct vcpu *v) { -int i;struct pending_irq *p;printk ("GICH_LRs (vcpu %d) mask=%" PRIx64"\n" , v->vcpu_id, v->arch.lr_mask); -if ( v == current ) - { -for ( i =0 ; i < nr_lrs; i++ ) -printk (" HW_LR[%d]=%x\n" , i,GICH [GICH_LR + i]); - }else { -for ( i =0 ; i < nr_lrs; i++ ) -printk (" VCPU_LR[%d]=%x\n" , i, v->arch.gic_state->gic_lr[i]); - } + gic_hw_ops->dump_state (v); list_for_each_entry ( p, &v->arch.vgic.inflight_irqs, inflight ) {
@@ -1070,7 +1254,7 @@ void gic_dump_info(struct vcpu *v)void __cpuinit init_maintenance_interrupt (void ) { -request_dt_irq (&gic.maintenance, maintenance_interrupt, +request_dt_irq (gic_hw_ops->get_maintenance_irq (), maintenance_interrupt,"irq-maintenance" ,NULL ); }
xen/include/asm-arm/gic.h +50 -0
68 lines not on this page · raw message
xen/include/asm-arm/gic_v2_defs.h +5 -11
@@ -93,15 +93,6 @@#define GICC_IA_CPU_MASK 0x1c00#define GICC_IA_CPU_SHIFT 10 -#define GICH_HCR_EN (1 << 0) -#define GICH_HCR_UIE (1 << 1) -#define GICH_HCR_LRENPIE (1 << 2) -#define GICH_HCR_NPIE (1 << 3) -#define GICH_HCR_VGRP0EIE (1 << 4) -#define GICH_HCR_VGRP0DIE (1 << 5) -#define GICH_HCR_VGRP1EIE (1 << 6) -#define GICH_HCR_VGRP1DIE (1 << 7) -#define GICH_MISR_EOI (1 << 0)#define GICH_MISR_U (1 << 1)#define GICH_MISR_LRENP (1 << 2)
@@ -118,9 +109,12 @@#define GICH_LR_STATE_MASK 0x3#define GICH_LR_STATE_SHIFT 28#define GICH_LR_PRIORITY_SHIFT 23 +#define GICH_LR_PRIORITY_MASK 0x1f +#define GICH_LR_HW_SHIFT 31 +#define GICH_LR_HW_MASK 0x1 +#define GICH_LR_GRP_SHIFT 30 +#define GICH_LR_GRP_MASK 0x1#define GICH_LR_MAINTENANCE_IRQ (1<<19) -#define GICH_LR_PENDING (1<<28) -#define GICH_LR_ACTIVE (1<<29)#define GICH_LR_GRP1 (1<<30)#define GICH_LR_HW (1<<31)#define GICH_LR_CPUID_SHIFT 9
Signature · 1 line
1.7.9.5
Re: [PATCH v2 05/15] xen/arm: segregate GIC low level functionality
Hi Vijaya,
Thank you for the patch.
Quoted 8 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
GIC low level functionality is segregated into separate functions and are called using registered callback wherever required.
This helps to separate generic and hardware functionality later
Honestly, your patch on V1 was far better to read. As you are nearly modify every functions, you should directly move it to a new file (e.g merge with patch #9).
Quoted 12 lines
Signed-off-by Vijaya Kumar K <[email protected]>--- xen/arch/arm/gic.c | 362 ++++++++++++++++++++++++++++--------- xen/include/asm-arm/gic.h | 50 +++++ xen/include/asm-arm/gic_v2_defs.h | 16 +- 3 files changed, 328 insertions(+), 100 deletions(-)xen/arch/arm/gic.c +0
-0
xen/arch/arm/gic.c static irq_desc_t irq_desc[NR_IRQS]; · line 63
Quoted 7 lines
xen/arch/arm/gic.c +4
-0@@ -57,8 +57,21 @@ static irq_desc_t irq_desc[NR_IRQS]; static DEFINE_PER_CPU(irq_desc_t[NR_LOCAL_IRQS], local_irq_desc); static DEFINE_PER_CPU(uint64_t, lr_mask); +static struct gic_hw_operations *gic_hw_ops; +static struct gic_hw_operations gic_ops; + +void register_gic_ops (struct gic_hw_operations *ops)
the callback should not change during runtime. Should the prototype should be:
void register_gic_ops(const struct gic_hw_operations *ops);
Quoted 16 lines
xen/arch/arm/gic.c +10
-1+{ + gic_hw_ops = ops; +} + +void update_cpu_lr_mask (void ) +{ +this_cpu (lr_mask) =0ULL ; +} +static uint8_t nr_lrs; -#define lr_all_full () (this_cpu(lr_mask) == ((1 << nr_lrs) - 1)) +#define lr_all_full () (this_cpu(lr_mask) == ((1 << gic_hw_ops->nr_lrs()) - 1))/* The GIC mapping of CPU interfaces does not necessarily match the * logical CPU numbering. Let's use mapping as returned by the GIC
xen/arch/arm/gic.c static unsigned int gic_cpu_mask(const cpumask_t *cpumask) · line 111
Quoted 10 lines
xen/arch/arm/gic.c +5
-0@@ -89,48 +102,124 @@ static unsigned int gic_cpu_mask(const cpumask_t *cpumask)unsigned int gic_number_lines (void ) { +return gic_hw_ops->nr_lines (); +} + +static unsigned int gic_nr_lines (void ) +{return gic.lines; }
If you had directly move the code to another files you would avoid this kind of non sense name...
xen/arch/arm/gic.c static unsigned int gic_cpu_mask(const cpumask_t *cpumask) · line 98
Quoted 6 lines
xen/arch/arm/gic.c +1
-3-irq_desc_t *__irq_to_desc (int irq) +static unsigned int gic_nr_lrs (void ) { -if (irq <NR_LOCAL_IRQS )return &this_cpu (local_irq_desc)[irq]; -return &irq_desc[irq-NR_LOCAL_IRQS ];
Why did you had to modify __irq_to_desc?
xen/arch/arm/gic.c static unsigned int gic_cpu_mask(const cpumask_t *cpumask) · line 121
Quoted 8 lines
xen/arch/arm/gic.c +5
-1+return nr_lrs; } -void gic_save_state (struct vcpu *v) +static int gic_state_init (struct vcpu *v) +{ + v->arch.gic_state = xzalloc(struct gic_state_data); +if (!v->arch.gic_state)
if ( !v->arch.gic_state )
Quoted 5 lines
xen/arch/arm/gic.c +5
-0+return -ENOMEM ; +return 0 ; +} + +static void save_state (struct vcpu *v)
xen/arch/arm/gic.c static unsigned int gic_cpu_mask(const cpumask_t *cpumask) · line 134
Quoted 10 lines
xen/arch/arm/gic.c +1
-2{int i; -ASSERT (!local_irq_is_enabled ());/* No need for spinlocks here because interrupts are disabled around * this call and it only accesses struct vcpu fields that cannot be * accessed simultaneously by another pCPU. */ -for ( i =0 ; i < nr_lrs; i++ ) +for ( i =0 ; i < nr_lrs; i++)
Spurious change
[..]
xen/arch/arm/gic.c int gic_irq_xlate(const u32 *intspec, unsigned int intsize, · line 152
Quoted 5 lines
xen/arch/arm/gic.c +1
-0@@ -129,6 +149,36 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize, unsigned int *out_hwirq, unsigned int *out_type);void gic_clear_lrs (struct vcpu *v); +struct gic_hw_operations {
I made some remarks on v1, that you completely forgot to address on this structure.
Can you document every callbacks (see asm-arm/platform.h for an example)? Why do you need them...
xen/arch/arm/gic.c int gic_irq_xlate(const u32 *intspec, unsigned int intsize, · line 153
Quoted 1 line
xen/arch/arm/gic.c +1
-0+struct dt_irq * (*get_maintenance_irq)(void );
With my interrupts patch series dt_irq will be removed soon.
xen/arch/arm/gic.c int gic_irq_xlate(const u32 *intspec, unsigned int intsize, · line 155
Quoted 2 lines
xen/arch/arm/gic.c +2
-0+unsigned int (*nr_lines)(void ); +unsigned int (*nr_lrs)(void );
I don't think we need a callbacks for both of them. 2 unsigned int are fine.
[..]
xen/arch/arm/gic.c int gic_irq_xlate(const u32 *intspec, unsigned int intsize, · line 160
Quoted 5 lines
xen/arch/arm/gic.c +5
-0+void (*enable_irq)(int ); +void (*disable_irq)(int ); +void (*eoi_irq)(int ); +void (*deactivate_irq)(int ); +unsigned int (*ack_irq)(void );
I would prefer to introduce a new hw_irq_controller here rather than adding another abstraction.
xen/arch/arm/gic.c int gic_irq_xlate(const u32 *intspec, unsigned int intsize, · line 163
Quoted 3 lines
xen/arch/arm/gic.c +3
-0+void (*set_irq_property)(unsigned int irq,bool_t level, +const cpumask_t *cpu_mask, +unsigned int priority);
I would rename the function into set_irq_properties.
[..]
Quoted 25 lines
xen/include/asm-arm/gic_v2_defs.h +1
-9@@ -93,15 +93,6 @@#define GICC_IA_CPU_MASK 0x1c00#define GICC_IA_CPU_SHIFT 10 -#define GICH_HCR_EN (1 << 0) -#define GICH_HCR_UIE (1 << 1) -#define GICH_HCR_LRENPIE (1 << 2) -#define GICH_HCR_NPIE (1 << 3) -#define GICH_HCR_VGRP0EIE (1 << 4) -#define GICH_HCR_VGRP0DIE (1 << 5) -#define GICH_HCR_VGRP1EIE (1 << 6) -#define GICH_HCR_VGRP1DIE (1 << 7) -#define GICH_MISR_EOI (1 << 0)#define GICH_MISR_U (1 << 1)#define GICH_MISR_LRENP (1 << 2)@@ -118,9 +109,12 @@#define GICH_LR_STATE_MASK 0x3#define GICH_LR_STATE_SHIFT 28#define GICH_LR_PRIORITY_SHIFT 23 +#define GICH_LR_PRIORITY_MASK 0x1f
xen/include/asm-arm/gic_v2_defs.h line 120
Quoted 10 lines
xen/include/asm-arm/gic_v2_defs.h +4
-2+#define GICH_LR_HW_SHIFT 31 +#define GICH_LR_HW_MASK 0x1 +#define GICH_LR_GRP_SHIFT 30 +#define GICH_LR_GRP_MASK 0x1#define GICH_LR_MAINTENANCE_IRQ (1<<19) -#define GICH_LR_PENDING (1<<28) -#define GICH_LR_ACTIVE (1<<29)#define GICH_LR_GRP1 (1<<30)#define GICH_LR_HW (1<<31)#define GICH_LR_CPUID_SHIFT 9
Why did you move all theses define on gic_v2_defs.h, and move back to gic.h again?
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 05/15] xen/arm: segregate GIC low level functionality
Quoted 4 lines
xen/include/asm-arm/gic.h int gic_irq_xlate(const u32 *intspec, unsigned int intsize, · line 155
Quoted 2 lines
xen/include/asm-arm/gic.h +2
-0+unsigned int (*nr_lines)(void ); +unsigned int (*nr_lrs)(void );I don't think we need a callbacks for both of them. 2 unsigned int are fine.
nr_lines returns number of gic lines supported. nr_lrs returns number of LR registers supported.
Quoted 12 lines
[..]
xen/include/asm-arm/gic.h int gic_irq_xlate(const u32 *intspec, unsigned int intsize, · line 165
Quoted 5 lines
xen/include/asm-arm/gic.h +5
-0+void (*enable_irq)(int ); +void (*disable_irq)(int ); +void (*eoi_irq)(int ); +void (*deactivate_irq)(int ); +unsigned int (*ack_irq)(void );I would prefer to introduce a new
hw_irq_controllerhere rather than adding another abstraction.
hw_irq_controller can be used only for enable_irq, disable_irq & eoi_irq.
other callbacks in hw_irq_controller cannot be used.
Ex: ack_irq in our case returns the irq where as 'ack' callback in hw_irq_controller
does not return a value. So not suitable here.
Quoted 3 lines
--
Julien Grall
Re: [PATCH v2 05/15] xen/arm: segregate GIC low level functionality
Quoted 6 lines · Vijay Kilari
Quoted 4 lines
xen/include/asm-arm/gic.h int gic_irq_xlate(const u32 *intspec, unsigned int intsize, · line 155
Quoted 2 lines
xen/include/asm-arm/gic.h +2
-0+unsigned int (*nr_lines)(void ); +unsigned int (*nr_lrs)(void );I don't think we need a callbacks for both of them. 2 unsigned int are fine.
nr_linesreturns number of gic lines supported.nr_lrsreturns number of LR registers supported.
I know it ... my point is to replace the both callbacks by:
unsigned nr_lines;
unsigned nr_lrs;
We don't have to use functions as it won't change after boot setup.
Quoted 13 lines
Quoted 4 lines
[..]
Quoted 9 lines
xen/include/asm-arm/gic.h int gic_irq_xlate(const u32 *intspec, unsigned int intsize, · line 165
Quoted 5 lines
xen/include/asm-arm/gic.h +5
-0+void (*enable_irq)(int ); +void (*disable_irq)(int ); +void (*eoi_irq)(int ); +void (*deactivate_irq)(int ); +unsigned int (*ack_irq)(void );I would prefer to introduce a new
hw_irq_controllerhere rather than adding another abstraction.
Quoted 6 lines
hw_irq_controllercan be used only forenable_irq,disable_irq&eoi_irq.
other callbacks inhw_irq_controllercannot be used.Ex:
ack_irqin our case returns the irq where as 'ack' callback inhw_irq_controller
does not return a value. So not suitable here.
Hmmm... rigth for deactivate_irq and ack_irq. For the others you can definitely use the hw_irq_controller.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 05/15] xen/arm: segregate GIC low level functionality
Quoted 14 lines · Julien Grall
Quoted 14 lines
Quoted 11 lines
[..]
xen/include/asm-arm/gic.h int gic_irq_xlate(const u32 *intspec, unsigned int intsize, · line 165
Quoted 5 lines
xen/include/asm-arm/gic.h +5
-0+void (*enable_irq)(int ); +void (*disable_irq)(int ); +void (*eoi_irq)(int ); +void (*deactivate_irq)(int ); +unsigned int (*ack_irq)(void );I would prefer to introduce a new
hw_irq_controllerhere rather than adding another abstraction.
hw_irq_controllercan be used only forenable_irq,disable_irq&eoi_irq.
other callbacks inhw_irq_controllercannot be used.
Quoted 6 lines
Quoted 3 lines
Ex:
ack_irqin our case returns the irq where as 'ack' callback inhw_irq_controller
does not return a value. So not suitable here.Hmmm... rigth for
deactivate_irqandack_irq. For the others you can definitely use thehw_irq_controller.
Perhaps
struct gic_irq_controller {
struct hw_irq_controller hw_irq;
unsigned int (*ack_irq)(void)
}And use container_of to go fom a hw_Irq to a gic_irq_controller when needed?
Ian.
Re: [PATCH v2 05/15] xen/arm: segregate GIC low level functionality
In reply to Julien GrallQuoted 11 lines · Julien Grall
Hi Vijaya,
Thank you for the patch.
Quoted 6 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
GIC low level functionality is segregated into separate functions and are called using registered callback wherever required.
Quoted 6 lines
Quoted 2 lines
This helps to separate generic and hardware functionality later
Honestly, your patch on V1 was far better to read. As you are nearly modify every functions, you should directly move it to a new file (e.g merge with patch #9).
This is a tricky judgement call, if there is to be mass code motion it should be done strictly separately from any functional changes. If that can be done all at once in a way which is reviewable then fine, but if not then I would much rather err on the side of refactoring and then moving as two steps even if the interim version looks a bit odd.
v1 of this patch certainly did mix the motion with functional changes and so separating things out was the correct thing to do. Perhaps the functional changes are now done elsewhere and it would be possible to revert to a single patch which moved blocks of code out into callbacks, but I wouldn't require it.
Ian.
Re: [PATCH v2 05/15] xen/arm: segregate GIC low level functionality
Quoted 25 lines · Ian Campbell
Quoted 11 lines · Julien Grall
Hi Vijaya,
Thank you for the patch.
Quoted 6 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
GIC low level functionality is segregated into separate functions and are called using registered callback wherever required.
Quoted 6 lines
Quoted 2 lines
This helps to separate generic and hardware functionality later
Honestly, your patch on V1 was far better to read. As you are nearly modify every functions, you should directly move it to a new file (e.g merge with patch #9).
This is a tricky judgement call, if there is to be mass code motion it should be done strictly separately from any functional changes. If that can be done all at once in a way which is reviewable then fine, but if not then I would much rather err on the side of refactoring and then moving as two steps even if the interim version looks a bit odd.
Quoted 5 lines
v1 of this patch certainly did mix the motion with functional changes and so separating things out was the correct thing to do. Perhaps the functional changes are now done elsewhere and it would be possible to revert to a single patch which moved blocks of code out into callbacks, but I wouldn't require it.
IHMO, I think everything that is more than splitting the function in 2 (e.g, prototype change, merging functions...) should not be part of this patch.
Keeping one patch (i'm not taking into account my previous comment) for code movement and function splitting will avoid strange renaming that is very confusing in this patch.
If we keep two patch, perhaps the gicv2 callbacks should be prefix by gicv2_...
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 05/15] xen/arm: segregate GIC low level functionality
Hi Julien & Ian,
Quoted 36 lines · Julien Grall
Quoted 25 lines · Ian Campbell
Quoted 11 lines · Julien Grall
Hi Vijaya,
Thank you for the patch.
Quoted 6 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
GIC low level functionality is segregated into separate functions and are called using registered callback wherever required.
Quoted 6 lines
Quoted 2 lines
This helps to separate generic and hardware functionality later
Honestly, your patch on V1 was far better to read. As you are nearly modify every functions, you should directly move it to a new file (e.g merge with patch #9).
This is a tricky judgement call, if there is to be mass code motion it should be done strictly separately from any functional changes. If that can be done all at once in a way which is reviewable then fine, but if not then I would much rather err on the side of refactoring and then moving as two steps even if the interim version looks a bit odd.
Quoted 5 lines
v1 of this patch certainly did mix the motion with functional changes and so separating things out was the correct thing to do. Perhaps the functional changes are now done elsewhere and it would be possible to revert to a single patch which moved blocks of code out into callbacks, but I wouldn't require it.
IHMO, I think everything that is more than splitting the function in 2 (e.g, prototype change, merging functions...) should not be part of this patch.
Quoted 7 lines
Keeping one patch (i'm not taking into account my previous comment) for code movement and function splitting will avoid strange renaming that is very confusing in this patch.
If we keep two patch, perhaps the gicv2 callbacks should be prefix by
gicv2_...
Having 2 patches one for with code changes and
other with pure code movement is fine. but first patch is always confusing to make this changes.
I prefer to have single patch with changes and code movement as in V1 and this makes job simple and I think we should bear with this.
Quoted 4 lines
Regards,
--
Julien Grall
Re: [PATCH v2 05/15] xen/arm: segregate GIC low level functionality
In reply to Julien GrallQuoted 2 lines · Julien Grall
If we keep two patch, perhaps the gicv2 callbacks should be prefix by
gicv2_...
I think this should be done regardless of everything else. Although it doesn't matter much once the functions are in gic-v2.c it will make it obvious in stack traces etc which driver is in use.
Ian.
Re: [PATCH v2 05/15] xen/arm: segregate GIC low level functionality
In reply to [email protected]Hello Vijaya,
Quoted 33 lines · On 04/04/14 12:56, [email protected] wrote:
xen/arch/arm/gic.c +7
-11+static void gic_send_sgi (const cpumask_t *cpumask,enum gic_sgi sgi) {unsigned int mask =0 ;cpumask_t online_mask;@@ -498,30 +606,26 @@ void send_SGI_mask(const cpumask_t *cpumask, enum gic_sgi sgi) | sgi; } -void send_SGI_one (unsigned int cpu,enum gic_sgi sgi) +void send_SGI_mask (const cpumask_t *cpumask,enum gic_sgi sgi) { -ASSERT (cpu <NR_GIC_CPU_IF );/* Targets bitmap only supports 8 CPUs */ -send_SGI_mask (cpumask_of (cpu), sgi); + gic_hw_ops->send_sgi (cpumask, sgi); } -void send_SGI_self (enum gic_sgi sgi) +void send_SGI_one (unsigned int cpu,enum gic_sgi sgi) { -ASSERT (sgi <16 );/* There are only 16 SGIs */ - -dsb (sy); - -GICD [GICD_SGIR ] =GICD_SGI_TARGET_SELF - | sgi; +ASSERT (cpu <NR_GIC_CPU_IF );/* Targets bitmap only supports 8 CPUs */ +send_SGI_mask (cpumask_of (cpu), sgi); }void send_SGI_allbutself (enum gic_sgi sgi) { -ASSERT (sgi <16 );/* There are only 16 SGIs */ +cpumask_t all_others_mask;
xen/arch/arm/gic.c void send_SGI_mask(const cpumask_t *cpumask, enum gic_sgi sgi) · line 629
Quoted 10 lines
xen/arch/arm/gic.c +4
-3+ASSERT (sgi <16 );/* There are only 16 SGIs */ -dsb (sy); +cpumask_andnot (&all_others_mask, &cpu_possible_map,cpumask_of (smp_processor_id ())); -GICD [GICD_SGIR ] =GICD_SGI_TARGET_OTHERS - | sgi; +dsb (sy); +send_SGI_mask (&all_others_mask, sgi); }
As I said in V1, this change breaks SMP boot with GICv2...
GICD_SGI_TARGERT_OTHERS will send an SGI to every CPUs even if the CPU is not yet online (i.e. not registered by Xen). It's used during secondary boot (cpu_up_send_sgi).
Your solution won't work because send_SGI_mask only deal with online CPU.
All the changes of send_sgi is more than splitting functions... this should be moved on another patch and you should justify the modifications.
[..]
xen/arch/arm/gic.c out: · line 1049
Quoted 7 lines
xen/arch/arm/gic.c +1
-1int gic_route_irq_to_guest(struct domain *d, const struct dt_irq *irq,@@ -921,10 +1046,10 @@ out:return retval; } -static void do_sgi (struct cpu_user_regs *regs,int othercpu,enum gic_sgi sgi) +static void do_sgi (struct cpu_user_regs *regs,enum gic_sgi sgi)
Why did you drop the othercpu here?
Again, please justify every change on the prototype of every functions. If it's not trivial, split in small patches...
Signature · 1 line
Julien Grall
Re: [PATCH v2 05/15] xen/arm: segregate GIC low level functionality
Quoted 57 lines · Julien Grall
Hello Vijaya,
Quoted 38 lines · On 04/04/14 12:56, [email protected] wrote:
xen/arch/arm/gic.c +8
-11+static void gic_send_sgi (const cpumask_t *cpumask,enum gic_sgi sgi) {unsigned int mask =0 ;cpumask_t online_mask;@@ -498,30 +606,26 @@ void send_SGI_mask(const cpumask_t *cpumask, enumgic_sgi sgi) | sgi; } -void send_SGI_one(unsigned int cpu, enum gic_sgi sgi) +void send_SGI_mask(const cpumask_t *cpumask, enum gic_sgi sgi) { -ASSERT(cpu < NR_GIC_CPU_IF); /* Targets bitmap only supports 8 CPUs */ -send_SGI_mask (cpumask_of (cpu), sgi); + gic_hw_ops->send_sgi (cpumask, sgi); } -void send_SGI_self (enum gic_sgi sgi) +void send_SGI_one (unsigned int cpu,enum gic_sgi sgi) { -ASSERT (sgi <16 );/* There are only 16 SGIs */ - -dsb (sy); - -GICD [GICD_SGIR ] =GICD_SGI_TARGET_SELF - | sgi; +ASSERT (cpu <NR_GIC_CPU_IF );/* Targets bitmap only supports 8 CPUs */ +send_SGI_mask (cpumask_of (cpu), sgi); }void send_SGI_allbutself (enum gic_sgi sgi) { -ASSERT (sgi <16 );/* There are only 16 SGIs */ +cpumask_t all_others_mask; +ASSERT (sgi <16 );/* There are only 16 SGIs */ xen/arch/arm/gic.c void send_SGI_mask(const cpumask_t *cpumask, enum · line 629
Quoted 10 lines
xen/arch/arm/gic.c +3
-3-dsb (sy); +cpumask_andnot (&all_others_mask, &cpu_possible_map,cpumask_of (smp_processor_id ())); -GICD [GICD_SGIR ] =GICD_SGI_TARGET_OTHERS - | sgi; +dsb (sy); +send_SGI_mask (&all_others_mask, sgi); }As I said in V1, this change breaks SMP boot with GICv2...
Quoted 3 lines
GICD_SGI_TARGERT_OTHERSwill send an SGI to every CPUs even if the CPU is not yet online (i.e. not registered by Xen). It's used during secondary boot (cpu_up_send_sgi).
cpumask_andnot(&all_others_mask, &cpu_possible_map,cpumask_of(smp_processor_id()));
In my understanding, with the above statement, I am using cpu_possible_map (all possible cpu's) which should contains all the cpu possible cpu masks. so this is fine.
The issue could be in gic_send_sgi() call which is always "and" with cpu_online_map
static void gic_send_sgi(const cpumask_t *cpumask, enum gic_sgi sgi)
{
unsigned int mask = 0;
cpumask_t online_mask;
ASSERT(sgi < 16); /* There are only 16 SGIs */
cpumask_and(&online_mask, cpumask, &cpu_online_map);
mask = gic_cpu_mask(&online_mask);
dsb(sy);
GICD[GICD_SGIR] = GICD_SGI_TARGET_LIST
| (mask<<GICD_SGI_TARGET_SHIFT)
| sgi;
}I think gic_send_sgi should be passed with absolute mask value and get rid of and'ing with cpu_online_map
Quoted 5 lines
Your solution won't work because
send_SGI_maskonly deal with online CPU.All the changes of
send_sgiis more than splitting functions... this should be moved on another patch and you should justify the modifications.
I will check if I could make this fix in a separate patch.
Quoted 8 lines
[..]
Quoted 5 lines
int gic_route_irq_to_guest(struct domain *d, const struct
dt_irq*irq,xen/arch/arm/gic.c +0
-0@@ -921,10 +1046,10 @@ out:return retval; }
Quoted 7 lines
Review out: · line 1050
Quoted 3 lines
(quoted diff) +1
-1-static void do_sgi(struct cpu_user_regs *regs, int othercpu, enum gic_sgi sgi) +static void do_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi)Why did you drop the othercpu here?
othercpu is not used at all. and also othercpu is computed with IAR fields #defines which is not required in this generic code.
Quoted 5 lines
Again, please justify every change on the prototype of every functions. If it's not trivial, split in small patches...
--
Julien Grall
Re: [PATCH v2 05/15] xen/arm: segregate GIC low level functionality
Quoted 32 lines · Vijay Kilari
Quoted 3 lines
GICD_SGI_TARGERT_OTHERSwill send an SGI to every CPUs even if the CPU is not yet online (i.e. not registered by Xen). It's used during secondary boot (cpu_up_send_sgi).
cpumask_andnot(&all_others_mask, &cpu_possible_map,cpumask_of(smp_processor_id()));In my understanding, with the above statement, I am using
cpu_possible_map(all possible cpu's) which should contains all the cpu possible cpu masks. so this is fine.The issue could be in
gic_send_sgi()call which is always "and" withcpu_online_mapstatic void
gic_send_sgi(const cpumask_t *cpumask, enum gic_sgi sgi){ unsigned int mask = 0; cpumask_t online_mask; ASSERT(sgi < 16); /* There are only 16 SGIs */ cpumask_and(&online_mask, cpumask, &cpu_online_map); mask = gic_cpu_mask(&online_mask); dsb(sy); GICD[GICD_SGIR] = GICD_SGI_TARGET_LIST | (mask<<GICD_SGI_TARGET_SHIFT) | sgi; }
Quoted 2 lines
I think
gic_send_sgishould be passed with absolute mask value and get rid of and'ing withcpu_online_map
It won't work... gic_cpu_mask will translate the set of CPU ID into a set of GIC CPU ID.
The mapping is initialized by gic_cpu_init. This function is only called when the CPU is booting. So the mask is invalid for offline CPU...
Quoted 9 lines
Quoted 7 lines
Quoted 3 lines
-static void
do_sgi(struct cpu_user_regs *regs, int othercpu, enum gic_sgi sgi)
+static voiddo_sgi(struct cpu_user_regs *regs, enum gic_sgi sgi)Why did you drop the othercpu here?
othercpu is not used at all. and also othercpu is computed with IAR fields #defines which is not required in this generic code.
It should not be part of this patch. Please send a separate patch for this change.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 05/15] xen/arm: segregate GIC low level functionality
In reply to [email protected]Quoted 21 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
GIC low level functionality is segregated into separate functions and are called using registered callback wherever required.
This helps to separate generic and hardware functionality later
Signed-off-by Vijaya Kumar K <[email protected]>--- xen/arch/arm/gic.c | 362 ++++++++++++++++++++++++++++--------- xen/include/asm-arm/gic.h | 50 +++++ xen/include/asm-arm/gic_v2_defs.h | 16 +- 3 files changed, 328 insertions(+), 100 deletions(-)xen/arch/arm/gic.c +0
-0
xen/arch/arm/gic.c static irq_desc_t irq_desc[NR_IRQS]; · line 61
Quoted 5 lines
xen/arch/arm/gic.c +2
-0@@ -57,8 +57,21 @@ static irq_desc_t irq_desc[NR_IRQS]; static DEFINE_PER_CPU(irq_desc_t[NR_LOCAL_IRQS], local_irq_desc); static DEFINE_PER_CPU(uint64_t, lr_mask); +static struct gic_hw_operations *gic_hw_ops; +static struct gic_hw_operations gic_ops;
Why two? Is the second one actually gic_v2_ops?
xen/arch/arm/gic.c static irq_desc_t irq_desc[NR_IRQS]; · line 71
Quoted 9 lines
xen/arch/arm/gic.c +9
-0+void register_gic_ops (struct gic_hw_operations *ops) +{ + gic_hw_ops = ops; +} + +void update_cpu_lr_mask (void ) +{ +this_cpu (lr_mask) =0ULL ; +}
This looks more like init_cpu_lr_mask.
xen/arch/arm/gic.c static irq_desc_t irq_desc[NR_IRQS]; · line 72
Quoted 2 lines
xen/arch/arm/gic.c +1
-0+static uint8_t nr_lrs;
Shouldn't everywhere be using gic_hw_ops->nr_lrs() rendering this unused?
xen/arch/arm/gic.c static irq_desc_t irq_desc[NR_IRQS]; · line 74
Quoted 2 lines
xen/arch/arm/gic.c +1
-1-#define lr_all_full () (this_cpu(lr_mask) == ((1 << nr_lrs) - 1)) +#define lr_all_full () (this_cpu(lr_mask) == ((1 << gic_hw_ops->nr_lrs()) - 1))
I think nr_lrs can just be an integer field of gic_hw_ops, rather than using a function to return it, or perhaps a global in gic. set by the lower level driver somehow. Unless nr_lrs is somehow for gicv3?
xen/arch/arm/gic.c static unsigned int gic_cpu_mask(const cpumask_t *cpumask) · line 142
Quoted 1 line
xen/arch/arm/gic.c +1
-0+static void restore_state (struct vcpu *v)
I suspect that all of these callbacks shoujld actually be gic_v2_restore_state or some such?
xen/arch/arm/gic.c static hw_irq_controller gic_guest_irq_type = { · line 324
Quoted 8 lines
xen/arch/arm/gic.c +1
-1@@ -230,7 +319,7 @@ static hw_irq_controller gic_guest_irq_type = {* - needs to be called with a valid cpu_mask, ie each cpu in the mask has * already called gic_cpu_init */ -static void gic_set_irq_properties (unsigned int irq,bool_t level, +static void gic_set_irq_property (unsigned int irq,bool_t level,const cpumask_t *cpu_mask,unsigned int priority)
Why did this need to become singular?
xen/arch/arm/gic.c void __init gic_init(void) · line 590
Quoted 4 lines
xen/arch/arm/gic.c +4
-0+static struct dt_irq *gic_maintenance_irq (void ) +{ +return &gic.maintenance; +}
This isn't using gic_hw_ops, so what is it for?
Ian.
PATCH v2 6/15 xen/arm: move gic lock out of gic data structure
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
spinlock is used across generic and GIC low level functions. Move this lock out of gic data. This helps to separate generic and low level functions later.
--- xen/arch/arm/gic.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
xen/arch/arm/gic.c +17 -17
@@ -50,9 +50,9 @@ static struct {unsigned int lines;/* Number of interrupts (SPIs + PPIs + SGIs) */ struct dt_irq maintenance;/* IRQ maintenance */ unsigned int cpus; -spinlock_t lock; } gic; +static spinlock_t gic_lock;static irq_desc_t irq_desc[NR_IRQS ]; static DEFINE_PER_CPU(irq_desc_t[NR_LOCAL_IRQS], local_irq_desc); static DEFINE_PER_CPU(uint64_t, lr_mask);
@@ -231,12 +231,12 @@ static void gic_irq_enable(struct irq_desc *desc)unsigned long flags;spin_lock_irqsave (&desc->lock, flags); -spin_lock (&gic.lock); +spin_lock (&gic_lock); desc->status &= ~IRQ_DISABLED ;dsb (sy);/* Enable routing */ gic_hw_ops->enable_irq (irq); -spin_unlock (&gic.lock); +spin_unlock (&gic_lock);spin_unlock_irqrestore (&desc->lock, flags); }
@@ -246,11 +246,11 @@ static void gic_irq_disable(struct irq_desc *desc)unsigned long flags;spin_lock_irqsave (&desc->lock, flags); -spin_lock (&gic.lock); +spin_lock (&gic_lock);/* Disable routing */ gic_hw_ops->disable_irq (irq); desc->status |=IRQ_DISABLED ; -spin_unlock (&gic.lock); +spin_unlock (&gic_lock);spin_unlock_irqrestore (&desc->lock, flags); }
@@ -315,7 +315,7 @@ static hw_irq_controller gic_guest_irq_type = { };/* -* - needs to be called with gic.lock held +* - needs to be called with gic_lock held * - needs to be called with a valid cpu_mask, ie each cpu in the mask has * already called gic_cpu_init */
@@ -373,9 +373,9 @@ static int gic_route_irq(unsigned int irq, bool_t level, desc->handler = &gic_host_irq_type; -spin_lock (&gic.lock); +spin_lock (&gic_lock);gic_set_irq_properties (irq, level, cpu_mask, priority); -spin_unlock (&gic.lock); +spin_unlock (&gic_lock);spin_unlock_irqrestore (&desc->lock, flags);return 0 ;
@@ -567,15 +567,15 @@ void __init gic_init(void)set_fixmap (FIXMAP_GICH , gic.hbase >>PAGE_SHIFT ,DEV_SHARED );/* Global settings: interrupt distributor */ -spin_lock_init (&gic.lock); -spin_lock (&gic.lock); +spin_lock_init (&gic_lock); +spin_lock (&gic_lock);gic_dist_init ();gic_cpu_init ();gic_hyp_init ();register_gic_ops (&gic_ops); -spin_unlock (&gic.lock); +spin_unlock (&gic_lock); }static void gic_secondary_cpu_init (void )
@@ -636,9 +636,9 @@ void smp_send_state_dump(unsigned int cpu)/* Set up the per-CPU parts of the GIC for a secondary CPU */ void __cpuinit gic_init_secondary_cpu (void ) { -spin_lock (&gic.lock); +spin_lock (&gic_lock); gic_hw_ops->secondary_init (); -spin_unlock (&gic.lock); +spin_unlock (&gic_lock); }/* Shut down the per-CPU GIC interface */
@@ -652,9 +652,9 @@ void gic_disable_cpu(void) {ASSERT (!local_irq_is_enabled ()); -spin_lock (&gic.lock); +spin_lock (&gic_lock); gic_hw_ops->disable_interface (); -spin_unlock (&gic.lock); +spin_unlock (&gic_lock); }void gic_route_ppis (void )
@@ -1020,7 +1020,7 @@ int gic_route_irq_to_guest(struct domain *d, const struct dt_irq *irq, action->free_on_release =1 ;spin_lock_irqsave (&desc->lock, flags); -spin_lock (&gic.lock); +spin_lock (&gic_lock); desc->handler = &gic_guest_irq_type; desc->status |=IRQ_GUEST ;
@@ -1041,7 +1041,7 @@ int gic_route_irq_to_guest(struct domain *d, const struct dt_irq *irq, p->desc = desc; out: -spin_unlock (&gic.lock); +spin_unlock (&gic_lock);spin_unlock_irqrestore (&desc->lock, flags);return retval; }
Signature · 1 line
1.7.9.5
Re: [PATCH v2 06/15] xen/arm: move gic lock out of gic data structure
Quoted 6 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
spinlock is used across generic and GIC low level functions. Move this lock out of gic data. This helps to separate generic and low level functions later.
Is there a subsequent patch which exposes this lock to gic-{v2,v3}.c? I grepped but couldn't find it. AFAIK the pattern is always:
common: take lock
common: call per gic callback
per gic callback: do stuff assuming lock held
common: release lock
IOW the lock is only used from the common code?
Ian.
Re: [PATCH v2 06/15] xen/arm: move gic lock out of gic data structure
Quoted 8 lines · Ian Campbell
Quoted 6 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
spinlock is used across generic and GIC low level functions. Move this lock out of gic data. This helps to separate generic and low level functions later.
Quoted 9 lines
Is there a subsequent patch which exposes this lock to gic-{v2,v3}.c? I grepped but couldn't find it. AFAIK the pattern is always:
common: take lock
common: call per gic callback
per gic callback: do stuff assuming lock held
common: release lockIOW the lock is only used from the common code?
Yes, lock is only used in common code and your pattern is correct. I made it separate patch as this is not trivial change
Quoted 2 lines
Ian.
Re: [PATCH v2 06/15] xen/arm: move gic lock out of gic data structure
Quoted 16 lines · Vijay Kilari
Quoted 15 lines · Ian Campbell
Quoted 6 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
spinlock is used across generic and GIC low level functions. Move this lock out of gic data. This helps to separate generic and low level functions later.
Is there a subsequent patch which exposes this lock to gic-{v2,v3}.c? I grepped but couldn't find it. AFAIK the pattern is always:
common: take lock
common: call per gic callback
per gic callback: do stuff assuming lock held
common: release lock
Quoted 3 lines
Quoted 2 lines
IOW the lock is only used from the common code?
Yes, lock is only used in common code and your pattern is correct.
Why is gic.lock not alright?
Quoted 4 lines
I made it separate patch as this is not trivial change
Quoted 2 lines
Ian.
Re: [PATCH v2 06/15] xen/arm: move gic lock out of gic data structure
Quoted 17 lines · Ian Campbell
Quoted 16 lines · Vijay Kilari
Quoted 15 lines · Ian Campbell
Quoted 6 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
spinlock is used across generic and GIC low level functions. Move this lock out of gic data. This helps to separate generic and low level functions later.
Is there a subsequent patch which exposes this lock to gic-{v2,v3}.c? I grepped but couldn't find it. AFAIK the pattern is always:
common: take lock
common: call per gic callback
per gic callback: do stuff assuming lock held
common: release lock
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
IOW the lock is only used from the common code?
Yes, lock is only used in common code and your pattern is correct.
Why is gic.lock not alright?
gic.lock also protects some common code as well in the existing v2 driver. So it is retained in common code and locking mechanism is not changed.
Quoted 6 lines
Quoted 4 lines
I made it separate patch as this is not trivial change
Quoted 2 lines
Ian.
Re: [PATCH v2 06/15] xen/arm: move gic lock out of gic data structure
Quoted 18 lines · Vijay Kilari
Quoted 17 lines · Ian Campbell
Quoted 16 lines · Vijay Kilari
Quoted 15 lines · Ian Campbell
Quoted 6 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
spinlock is used across generic and GIC low level functions. Move this lock out of gic data. This helps to separate generic and low level functions later.
Is there a subsequent patch which exposes this lock to gic-{v2,v3}.c? I grepped but couldn't find it. AFAIK the pattern is always:
common: take lock
common: call per gic callback
per gic callback: do stuff assuming lock held
common: release lock
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
IOW the lock is only used from the common code?
Yes, lock is only used in common code and your pattern is correct.
Why is gic.lock not alright?
gic.lock also protects some common code as well in the existing v2 driver. So it is retained in common code and locking mechanism is not changed.
Ah. I was missing that the struct gic was going to become v2 specific and move to gic-v2.c, but this field needs to stay behind in the common code.
Can you make that explicit in your commit log please.
Ian,
PATCH v2 7/15 xen/arm: split gic driver into generic and gic-v2 driver
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Existing GIC driver has both generic code and hw specific code. Segregate GIC low level driver into gic-v2.c and keep generic code in existing gic.c file
GIC v2 driver registers required functions
to generic GIC driver. This helps to plug in next version of GIC drivers like GIC v3.
--- xen/arch/arm/Makefile | 2 +- xen/arch/arm/gic-v2.c | 538 +++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/gic.c | 492 +---------------------------------------- xen/include/asm-arm/gic.h | 1 + 4 files changed, 542 insertions(+), 491 deletions(-)
xen/arch/arm/Makefile +1 -1
@@ -10,7 +10,7 @@ obj-y += vpsci.o obj-y += domctl.o obj-y += sysctl.o obj-y += domain_build.o -obj-y += gic.o +obj-y += gic.o gic-v2.o obj-y += io.o obj-y += irq.o obj-y += kernel.o
xen/arch/arm/gic-v2.c new file +538 -0
538 lines not on this page · raw message
xen/arch/arm/gic.c +2 -490
578 lines not on this page · raw message
xen/include/asm-arm/gic.h +1 -0
@@ -116,6 +116,7 @@ extern int gic_route_irq_to_guest(struct domain *d,extern void gic_interrupt (struct cpu_user_regs *regs,int is_fiq);/* Bring up the interrupt controller, and report # cpus attached */ extern void gic_init (void ); +extern void gicv2_init (void );/* Bring up a secondary CPU's per-CPU GIC interface */ extern void gic_init_secondary_cpu (void );/* Take down a CPU's per-CPU GIC interface */
Signature · 1 line
1.7.9.5
Re: [PATCH v2 07/15] xen/arm: split gic driver into generic and gic-v2 driver
Quoted 5 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Existing GIC driver has both generic code and hw specific code. Segregate GIC low level driver into
gic-v2.cand keep generic code in existinggic.cfile
This is substantially just code motion, correct?
I notice that gicv2_init does not hold the gic lock while calling + gic_{dist,cpu,hyp}_init(), is that intentional?
Quoted 1 line
+static struct
gic_hw_operationsgic_ops;
If you order this file:
callbacks
gic_hw_ops
gicv2_init
Then you can avoid this forward declaration and more importantly you can probably mark the struct as const.
Ian.
Re: [PATCH v2 07/15] xen/arm: split gic driver into generic and gic-v2 driver
Quoted 9 lines · Ian Campbell
Quoted 5 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Existing GIC driver has both generic code and hw specific code. Segregate GIC low level driver into
gic-v2.cand keep generic code in existinggic.cfileThis is substantially just code motion, correct?
Yes, but now I think to avoid confusion I will make single
patch for spliting v2 driver & code movement as in V1
Quoted 10 lines
I notice that
gicv2_initdoes not hold the gic lock while calling + gic_{dist,cpu,hyp}_init(), is that intentional?Quoted 1 line
+static struct
gic_hw_operationsgic_ops;If you order this file:
callbacks
gic_hw_ops
gicv2_init
Yes, this is called only during init by boot cpu and is not called by any other cpu
So, I have not taken the lock.
Quoted 5 lines
Then you can avoid this forward declaration and more importantly you can probably mark the struct as const.
Ian.
PATCH v2 8/15 xen/arm: use device api to detect GIC version
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Run through the device tree to detect
compatible GIC version and initialize GIC driver.
--- xen/arch/arm/gic-v2.c | 26 +++++++++++++++----------- xen/arch/arm/gic.c | 17 ++++++++++++++++- xen/include/asm-arm/device.h | 3 ++- xen/include/asm-arm/gic.h | 1 - 4 files changed, 33 insertions(+), 14 deletions(-)
xen/arch/arm/gic-v2.c +15 -11
@@ -31,6 +31,7 @@#include <asm/p2m.h> #include <asm/domain.h> #include <asm/platform.h> +#include <asm/device.h> #include <asm/gic_v2_defs.h> #include <asm/gic.h>
@@ -289,20 +290,10 @@ static void __cpuinit gic_hyp_disable(void) }/* Set up the GIC */ -void __init gicv2_init (void ) +int __init gicv2_init (struct dt_device_node *node,const void *data) { -static const struct dt_device_match gic_ids[]__initconst = - { -DT_MATCH_GIC , - {/* sentinel */ }, - }; -struct dt_device_node *node;int res; - node =dt_find_interrupt_controller (gic_ids); -if ( !node ) -panic ("Unable to find compatible GIC in the device tree" ); -dt_device_set_used_by (node,DOMID_XEN ); res =dt_device_get_address (node,0 , &gic.dbase,NULL );
@@ -360,6 +351,7 @@ void __init gicv2_init(void)gic_hyp_init ();register_gic_ops (&gic_ops); +return 0 ; }static void gic_secondary_cpu_init (void )
@@ -528,6 +520,18 @@ static struct gic_hw_operations gic_ops = { .read_vmcr_priority = gic_read_vmcr_priority, }; +static const char *const gicv2_dt_compat[]__initconst = +{ +"arm,cortex-a15-gic" , +"arm,cortex-a9-gic" , +NULL +}; + +DT_DEVICE_START (gicv2,"GIC" ,DEVICE_GIC ) + .compatible = gicv2_dt_compat, + .init = gicv2_init, +DT_DEVICE_END +/* * Local variables: * mode: C
xen/arch/arm/gic.c +16 -1
@@ -31,6 +31,7 @@#include <asm/p2m.h> #include <asm/domain.h> #include <asm/platform.h> +#include <asm/device.h> #include <asm/gic.h>
@@ -253,8 +254,22 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize,/* Set up the GIC */ void __init gic_init (void ) { -gicv2_init (); +int rc; +struct dt_device_node *node; +unsigned int num_gics =0 ; +spin_lock_init (&gic_lock); +spin_lock (&gic_lock); + +dt_for_each_device_node (dt_host, node) + { + rc =device_init (node,DEVICE_GIC ,NULL ); +if ( !rc ) + num_gics++; + } +spin_unlock (&gic_lock); +if ( !num_gics ) +panic ("Unable to find compatible GIC in the device tree" ); }void send_SGI_mask (const cpumask_t *cpumask,enum gic_sgi sgi)
xen/include/asm-arm/device.h +2 -1
@@ -6,7 +6,8 @@enum device_type { -DEVICE_SERIAL +DEVICE_SERIAL , +DEVICE_GIC };struct device_desc {
xen/include/asm-arm/gic.h +0 -1
@@ -116,7 +116,6 @@ extern int gic_route_irq_to_guest(struct domain *d,extern void gic_interrupt (struct cpu_user_regs *regs,int is_fiq);/* Bring up the interrupt controller, and report # cpus attached */ extern void gic_init (void ); -extern void gicv2_init (void );/* Bring up a secondary CPU's per-CPU GIC interface */ extern void gic_init_secondary_cpu (void );/* Take down a CPU's per-CPU GIC interface */
Signature · 1 line
1.7.9.5
Re: [PATCH v2 08/15] xen/arm: use device api to detect GIC version
Hi Vijaya,
Thank you for the patch.
xen/arch/arm/gic.c int gic_irq_xlate(const u32 *intspec, unsigned int intsize, · line 262
Quoted 11 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
xen/arch/arm/gic.c +5
-1@@ -253,8 +254,22 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize,/* Set up the GIC */ void __init gic_init (void ) { -gicv2_init (); +int rc; +struct dt_device_node *node; +unsigned int num_gics =0 ; +spin_lock_init (&gic_lock); +spin_lock (&gic_lock);
Why do you take the lock here?
xen/arch/arm/gic.c int gic_irq_xlate(const u32 *intspec, unsigned int intsize, · line 268
Quoted 6 lines
xen/arch/arm/gic.c +6
-0+ +dt_for_each_device_node (dt_host, node) + { + rc =device_init (node,DEVICE_GIC ,NULL ); +if ( !rc ) + num_gics++;
Xen only supports a single GIC for now. You have to initialized the correct one (see dt_find_interrupt_controller).
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 08/15] xen/arm: use device api to detect GIC version
Hi Julien,
Quoted 10 lines
xen/arch/arm/gic.c int gic_irq_xlate(const u32 *intspec, unsigned int intsize, · line 268
Quoted 7 lines
xen/arch/arm/gic.c +6
-0+ +dt_for_each_device_node (dt_host, node) + { + rc =device_init (node,DEVICE_GIC ,NULL ); +if ( !rc ) + num_gics++;Xen only supports a single GIC for now. You have to initialized the correct one (see
dt_find_interrupt_controller).
dt_find_interrupt_controller expects compatibility string as below to fetch the gic node which can be passed to device_init().
static const struct dt_device_match gic_ids[] __initconst =
{
DT_MATCH_GIC,
{ /* sentinel */ },
};In such case, generic driver has to pass compatibility strings of both GIC v3 & GIC v2 to find the node in dt. Is this ok?
Other way is to break when num_gics = 1 when it finds the first gic node.
Quoted 5 lines
Regards,
--
Julien Grall
Re: [PATCH v2 08/15] xen/arm: use device api to detect GIC version
Quoted 19 lines · Vijay Kilari
Quoted 9 lines
xen/arch/arm/gic.c int gic_irq_xlate(const u32 *intspec, unsigned int intsize, · line 268
Quoted 6 lines
xen/arch/arm/gic.c +6
-0+ +dt_for_each_device_node (dt_host, node) + { + rc =device_init (node,DEVICE_GIC ,NULL ); +if ( !rc ) + num_gics++;Xen only supports a single GIC for now. You have to initialized the correct one (see
dt_find_interrupt_controller).
dt_find_interrupt_controllerexpects compatibility string as below to fetch the gic node which can be passed todevice_init().static const struct
dt_device_matchgic_ids[]__initconst={ DT_MATCH_GIC, { /* sentinel */ }, };
Quoted 4 lines
In such case, generic driver has to pass compatibility strings of both GIC v3 & GIC v2 to find the node in dt. Is this ok?
Other way is to break when
num_gics= 1 when it finds the first gic node.
Why can't you modify dt_find_interrupt_controller? Or even better, take the code from it and use it directly in your function...
Signature · 1 line
Julien Grall
Re: [PATCH v2 08/15] xen/arm: use device api to detect GIC version
Quoted 20 lines · Julien Grall
Quoted 19 lines · Vijay Kilari
Quoted 9 lines
xen/arch/arm/gic.c int gic_irq_xlate(const u32 *intspec, unsigned int intsize, · line 268
Quoted 6 lines
xen/arch/arm/gic.c +6
-0+ +dt_for_each_device_node (dt_host, node) + { + rc =device_init (node,DEVICE_GIC ,NULL ); +if ( !rc ) + num_gics++;Xen only supports a single GIC for now. You have to initialized the correct one (see
dt_find_interrupt_controller).
dt_find_interrupt_controllerexpects compatibility string as below to fetch the gic node which can be passed todevice_init().static const struct
dt_device_matchgic_ids[]__initconst={ DT_MATCH_GIC, { /* sentinel */ }, };
Quoted 7 lines
Quoted 4 lines
In such case, generic driver has to pass compatibility strings of both GIC v3 & GIC v2 to find the node in dt. Is this ok?
Other way is to break when
num_gics= 1 when it finds the first gic node.Why can't you modify
dt_find_interrupt_controller? Or even better, take the code from it and use it directly in your function...
The patch here looks like a pretty natural use of the DT device API to me, I think all that is needed is for gicv2_init to call dt_get_parent(np) and skip any non-root gic with a warning message and return error.
Something should also check for the "interrupt-controller" property, either the inner or outer init function.
Ian.
PATCH v2 9/15 xen/arm: segregate VGIC low level functionality
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
VGIC low level functionality is segregated into separate functions and are called using registered callback wherever required.
This helps to separate generic and hardware functionality later
--- xen/arch/arm/vgic.c | 120 ++++++++++++++++++++++++++++++++---------- xen/include/asm-arm/device.h | 3 +- xen/include/asm-arm/gic.h | 7 +++ 3 files changed, 101 insertions(+), 29 deletions(-)
xen/arch/arm/vgic.c +92 -28
@@ -26,6 +26,7 @@#include <xen/sched.h> #include <asm/current.h> +#include <asm/device.h> #include "io.h" #include <asm/gic_v2_defs.h>
@@ -36,6 +37,8 @@/* Number of ranks of interrupt registers for a domain */ #define DOMAIN_NR_RANKS (d) (((d)->arch.vgic.nr_lines+31)/32) +static struct vgic_ops *vgic_ops; +static struct mmio_handler vgic_distr_mmio_handler;/* * Rank containing GICD_<FOO><n> for GICD_<FOO> with
@@ -53,6 +56,11 @@ static inline int REG_RANK_NR(int b, uint32_t n) } } +void register_vgic_ops (struct vgic_ops *ops) +{ + vgic_ops = ops; +} +/* * Offset of GICD_<FOO><n> with its rank, for GICD_<FOO> with * <b>-bits-per-interrupt.
@@ -78,6 +86,9 @@ static struct vgic_irq_rank *vgic_irq_rank(struct vcpu *v, int b, int n)int domain_vgic_init (struct domain *d) {int i; +int rc; +struct dt_device_node *node; +unsigned int num_vgics =0 ; d->arch.vgic.ctlr =0 ;
@@ -89,27 +100,28 @@ int domain_vgic_init(struct domain *d)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)); -if ( d->arch.vgic.shared_irqs ==NULL ) -return -ENOMEM ; +dt_for_each_device_node (dt_host, node) + { + rc =device_init (node,DEVICE_VGIC ,NULL ); +if ( !rc ) + num_vgics++; + } + +if ( !num_vgics ) +panic ("No compatible vgic found\n" ); + + vgic_ops->vgic_domain_init (d); d->arch.vgic.pending_irqs = xzalloc_array(struct pending_irq, d->arch.vgic.nr_lines);if ( d->arch.vgic.pending_irqs ==NULL ) - { -xfree (d->arch.vgic.shared_irqs);return -ENOMEM ; - } -for (i=0 ; i<d->arch.vgic.nr_lines; i++) +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); -register_mmio_handler (d, &vgic_distr_mmio_handler);return 0 ; }
@@ -123,13 +135,10 @@ int vcpu_vgic_init(struct vcpu *v) {int i; - v->arch.vgic.private_irqs = xzalloc(struct vgic_irq_rank); -if ( v->arch.vgic.private_irqs ==NULL ) -return -ENOMEM ; - -memset (&v->arch.vgic.private_irqs,0 ,sizeof (v->arch.vgic.private_irqs)); - -spin_lock_init (&v->arch.vgic.private_irqs->lock); +if ( vgic_ops ) + vgic_ops->vgic_vcpu_init (v); +else +panic ("No VGIC ops found\n" );memset (&v->arch.vgic.pending_irqs,0 ,sizeof (v->arch.vgic.pending_irqs));for (i =0 ; i <32 ; i++)
@@ -138,13 +147,6 @@ int vcpu_vgic_init(struct vcpu *v)INIT_LIST_HEAD (&v->arch.vgic.pending_irqs[i].lr_queue); } -/* For SGI and PPI the target is always this CPU */ -for ( i =0 ; i <8 ; i++ ) - v->arch.vgic.private_irqs->itargets[i] = - (1 <<(v->vcpu_id+0 )) - | (1 <<(v->vcpu_id+8 )) - | (1 <<(v->vcpu_id+16 )) - | (1 <<(v->vcpu_id+24 ));INIT_LIST_HEAD (&v->arch.vgic.inflight_irqs);INIT_LIST_HEAD (&v->arch.vgic.lr_pending);spin_lock_init (&v->arch.vgic.lock);
@@ -186,6 +188,13 @@ static void byte_write(uint32_t *reg, uint32_t var, int offset) *reg |= var; } +static int vgic_read_priority (struct vcpu *v,int irq) +{ +int idx = irq >>2 ; +struct vgic_irq_rank *rank =vgic_irq_rank (v,8 , idx); +return byte_read (rank->ipriority[REG_RANK_INDEX (8 , idx)],0 , irq &0x3 ); +} +static int vgic_distr_mmio_read (struct vcpu *v,mmio_info_t *info) {struct hsr_dabt dabt = info->dabt;
@@ -719,9 +728,7 @@ void vgic_clear_pending_irqs(struct vcpu *v)void vgic_vcpu_inject_irq (struct vcpu *v,unsigned int irq) { -int idx = irq >>2 , byte = irq &0x3 ;uint8_t priority; -struct vgic_irq_rank *rank =vgic_irq_rank (v,8 , idx);struct pending_irq *iter, *n =irq_to_pending (v, irq);unsigned long flags;bool_t running;
@@ -735,7 +742,7 @@ void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int irq)return ; } - priority =byte_read (rank->ipriority[REG_RANK_INDEX (8 , idx)],0 , byte); + priority = vgic_ops->read_priority (v, irq); n->irq = irq;set_bit (GIC_IRQ_GUEST_PENDING , &n->status);
@@ -768,6 +775,63 @@ out:smp_send_event_check_mask (cpumask_of (v->processor)); } +static int vgic_vcpu_init (struct vcpu *v) +{ +int i; + + v->arch.vgic.private_irqs = xzalloc(struct vgic_irq_rank); +memset (v->arch.vgic.private_irqs,0 ,sizeof (struct vgic_irq_rank )); + +spin_lock_init (&v->arch.vgic.private_irqs->lock); +/* For SGI and PPI the target is always this CPU */ +for ( i =0 ; i <8 ; i++ ) + v->arch.vgic.private_irqs->itargets[i] = + (1 <<(v->vcpu_id+0 )) + | (1 <<(v->vcpu_id+8 )) + | (1 <<(v->vcpu_id+16 )) + | (1 <<(v->vcpu_id+24 )); +return 0 ; +} + +static int vgic_domain_init (struct domain *d) +{ +int i; + + d->arch.vgic.shared_irqs = + xzalloc_array(struct vgic_irq_rank, DOMAIN_NR_RANKS(d)); + +for ( i =0 ; i <DOMAIN_NR_RANKS (d); i++ ) +spin_lock_init (&d->arch.vgic.shared_irqs[i].lock); + +register_mmio_handler (d, &vgic_distr_mmio_handler); +return 0 ; +} + +static struct vgic_ops ops = { + .vgic_vcpu_init = vgic_vcpu_init, + .vgic_domain_init = vgic_domain_init, + .read_priority = vgic_read_priority, +}; + +static int __init vgic_v2_init (struct dt_device_node *dev,const void *data) + +{ +register_vgic_ops (&ops); +return 0 ; +} + +static const char *const vgicv2_dt_compat[]__initconst = +{ +"arm,cortex-a15-gic" , +"arm,cortex-a9-gic" , +NULL +}; + +DT_DEVICE_START (gicv2,"VGIC" ,DEVICE_VGIC ) + .compatible = vgicv2_dt_compat, + .init = vgic_v2_init, +DT_DEVICE_END +/* * Local variables: * mode: C
xen/include/asm-arm/device.h +2 -1
@@ -7,7 +7,8 @@enum device_type {DEVICE_SERIAL , -DEVICE_GIC +DEVICE_GIC , +DEVICE_VGIC };struct device_desc {
xen/include/asm-arm/gic.h +7 -0
@@ -177,6 +177,13 @@ struct gic_hw_operations { void (*secondary_init)(void); }; +struct vgic_ops { +int (*vgic_vcpu_init)(struct vcpu *v); +int (*vgic_domain_init)(struct domain *d); +int (*read_priority)(struct vcpu *v,int irq); +}; + +void register_vgic_ops (struct vgic_ops *ops);void register_gic_ops (struct gic_hw_operations *ops);extern void update_cpu_lr_mask (void );#endif /* __ASSEMBLY__ */
Signature · 1 line
1.7.9.5
Re: [PATCH v2 09/15] xen/arm: segregate VGIC low level functionality
Hello Vijay,
Thank you for the patch.
Quoted 8 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
VGIC low level functionality is segregated into separate functions and are called using registered callback wherever required.
This helps to separate generic and hardware functionality later
Same remark as patch #5, is less clear to have 2 separate patches.
[..]
xen/arch/arm/vgic.c out: · line 834
Quoted 5 lines
xen/arch/arm/vgic.c +5
-0+DT_DEVICE_START (gicv2,"VGIC" ,DEVICE_VGIC ) + .compatible = vgicv2_dt_compat, + .init = vgic_v2_init, +DT_DEVICE_END +
hrm ... VGIC is not a device, if you don't plan to support different VGIC per domain then you can directly return the vgic callbacks for the gic drivers.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 09/15] xen/arm: segregate VGIC low level functionality
Quoted 9 lines · Julien Grall
xen/arch/arm/vgic.c out: · line 834
Quoted 5 lines
xen/arch/arm/vgic.c +5
-0+DT_DEVICE_START (gicv2,"VGIC" ,DEVICE_VGIC ) + .compatible = vgicv2_dt_compat, + .init = vgic_v2_init, +DT_DEVICE_END +hrm ... VGIC is not a device, if you don't plan to support different VGIC per domain then you can directly return the vgic callbacks for the gic drivers.
Agreed, and if we were to support different VGIC per domain then it would have to be driven by some sort of toolstack config option, domctl etc, and not by the compat strings in the host DT.
So best to just register the vgic v2 ops when initialising gic v2 and similar for v3 I think.
Ian.
PATCH v2 10/15 xen/arm: split vgic driver into generic and vgic-v2 driver
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Existing vGIC driver has both generic code and hw specific code. Segregate vGIC low level driver into vgic-v2.c and keep generic code in existing vgic.c file
vGIC v2 driver registers required functions
to generic vGIC driver. This helps to plug in next version of vGIC drivers like vGIC v3.
--- xen/arch/arm/Makefile | 2 +- xen/arch/arm/vgic-v2.c | 639 +++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/vgic.c | 601 +----------------------------------------- xen/include/asm-arm/gic.h | 2 + 4 files changed, 644 insertions(+), 600 deletions(-)
xen/arch/arm/Makefile +1 -1
@@ -26,7 +26,7 @@ obj-y += smpboot.o obj-y += smp.o obj-y += shutdown.o obj-y += traps.o -obj-y += vgic.o +obj-y += vgic.o vgic-v2.o obj-y += vtimer.o obj-y += vuart.o obj-y += hvm.o
xen/arch/arm/vgic-v2.c new file +639 -0
639 lines not on this page · raw message
xen/arch/arm/vgic.c +2 -599
641 lines not on this page · raw message
xen/include/asm-arm/gic.h +2 -0
@@ -86,6 +86,8 @@ extern void domain_vgic_free(struct domain *d);extern int vcpu_vgic_init (struct vcpu *v);extern int vcpu_vgic_free (struct vcpu *v); +extern void vgic_disable_irqs (struct vcpu *v,uint32_t r,int n); +extern void vgic_enable_irqs (struct vcpu *v,uint32_t r,int n);extern int vcpu_gic_init (struct vcpu *v);
Signature · 1 line
1.7.9.5
Re: [PATCH v2 10/15] xen/arm: split vgic driver into generic and vgic-v2 driver
Quoted 5 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Existing vGIC driver has both generic code and hw specific code. Segregate vGIC low level driver into
vgic-v2.cand keep generic code in existingvgic.cfile
Just code motion? Please mention this in your commit logs so we know what to expect (not just for this patch, but generally). If it is mostly code motion and small small tweaks then it would be really helpful if you could enumerate then. e.g.:
This is all code motion except:
* vgic_{enable,disable}_irqs become non-static so they can be called from the vgic-v2 driver
* somew other change.
That would really help with review, since I can avoid looking too closely at the code motion bits if I am confident they are really just motion. (and I have scripts which can help automate it).
Ian.
PATCH v2 11/15 xen/arm: make GIC context data version specific
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
GIC context data is dependent on hardware version
make the contents of gic context data structure
as version specific and access accordingly
--- xen/arch/arm/gic-v2.c | 15 ++++++++------- xen/include/asm-arm/gic.h | 11 ++++++++--- 2 files changed, 16 insertions(+), 10 deletions(-)
xen/arch/arm/gic-v2.c +8 -7
@@ -96,6 +96,7 @@ static int gic_state_init(struct vcpu *v) v->arch.gic_state = xzalloc(struct gic_state_data);if ( !v->arch.gic_state )return -ENOMEM ; + v->arch.gic_state->version =2 ;return 0 ; }
@@ -108,9 +109,9 @@ static void save_state(struct vcpu *v)* accessed simultaneously by another pCPU. */ for ( i =0 ; i < nr_lrs; i++ ) - v->arch.gic_state->gic_lr[i] =GICH [GICH_LR + i]; - v->arch.gic_state->gic_apr =GICH [GICH_APR ]; - v->arch.gic_state->gic_vmcr =GICH [GICH_VMCR ]; + v->arch.gic_state->v2.gic_lr[i] =GICH [GICH_LR + i]; + v->arch.gic_state->v2.gic_apr =GICH [GICH_APR ]; + v->arch.gic_state->v2.gic_vmcr =GICH [GICH_VMCR ];/* Disable until next VCPU scheduled */ GICH [GICH_HCR ] =0 ; }
@@ -120,9 +121,9 @@ static void restore_state(struct vcpu *v)int i;for ( i =0 ; i < nr_lrs; i++ ) -GICH [GICH_LR + i] = v->arch.gic_state->gic_lr[i]; -GICH [GICH_APR ] = v->arch.gic_state->gic_apr; -GICH [GICH_VMCR ] = v->arch.gic_state->gic_vmcr; +GICH [GICH_LR + i] = v->arch.gic_state->v2.gic_lr[i]; +GICH [GICH_APR ] = v->arch.gic_state->v2.gic_apr; +GICH [GICH_VMCR ] = v->arch.gic_state->v2.gic_vmcr;GICH [GICH_HCR ] =GICH_HCR_EN ; }
@@ -135,7 +136,7 @@ static void gic_dump_state(struct vcpu *v)printk (" HW_LR[%d]=%x\n" , i,GICH [GICH_LR + i]); }else {for ( i =0 ; i < nr_lrs; i++ ) -printk (" VCPU_LR[%d]=%x\n" , i, v->arch.gic_state->gic_lr[i]); +printk (" VCPU_LR[%d]=%x\n" , i, v->arch.gic_state->v2.gic_lr[i]); } }
xen/include/asm-arm/gic.h +8 -3
@@ -67,9 +67,14 @@ struct vgic_irq_rank { };struct gic_state_data { -uint32_t gic_hcr, gic_vmcr; -uint32_t gic_apr; -uint32_t gic_lr[64 ]; +uint8_t version; +union { +struct gic_v2 { +uint32_t gic_hcr, gic_vmcr; +uint32_t gic_apr; +uint32_t gic_lr[64 ]; + }v2; + }; };struct gic_lr {
Signature · 1 line
1.7.9.5
Re: [PATCH v2 11/15] xen/arm: make GIC context data version specific
Hello Vijaya,
Thank you for the patch.
Quoted 17 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
GIC context data is dependent on hardware version
make the contents of gic context data structure
as version specific and access accordinglySigned-off-by Vijaya Kumar K <[email protected]>--- xen/arch/arm/gic-v2.c | 15 ++++++++------- xen/include/asm-arm/gic.h | 11 ++++++++--- 2 files changed, 16 insertions(+), 10 deletions(-)xen/arch/arm/gic-v2.c +0
-0
xen/arch/arm/gic-v2.c static int gic_state_init(struct vcpu *v) · line 99
Quoted 4 lines
xen/arch/arm/gic-v2.c +1
-0@@ -96,6 +96,7 @@ static int gic_state_init(struct vcpu *v) v->arch.gic_state = xzalloc(struct gic_state_data);if ( !v->arch.gic_state )return -ENOMEM ; + v->arch.gic_state->version =2 ;
I would prefer an enum rather than a fixed number.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 11/15] xen/arm: make GIC context data version specific
Quoted 17 lines · Julien Grall
Hello Vijaya,
Thank you for the patch.
Quoted 12 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
GIC context data is dependent on hardware version
make the contents of gic context data structure
as version specific and access accordinglySigned-off-by Vijaya Kumar K <[email protected]>--- xen/arch/arm/gic-v2.c | 15 ++++++++------- xen/include/asm-arm/gic.h | 11 ++++++++--- 2 files changed, 16 insertions(+), 10 deletions(-)
Quoted 11 lines
xen/arch/arm/gic-v2.c static int gic_state_init(struct vcpu *v) · line 99
Quoted 9 lines
xen/arch/arm/gic-v2.c +1
-0@@ -96,6 +96,7 @@ static int gic_state_init(struct vcpu *v) v->arch.gic_state = xzalloc(struct gic_state_data);if ( !v->arch.gic_state )return -ENOMEM ; + v->arch.gic_state->version =2 ;I would prefer an enum rather than a fixed number.
How is this field actually used? I'd have thought the v2 and v3 specific callbacks would just know which member of the union was "theirs" and nothing outside of that should be poking at it anyway.
Quoted 1 line
+
printk(" VCPU_LR[%d]=%x\n", i, v->arch.gic_state->v2.gic_lr[i]);
Too many gic prefixes here, and the _state is redundant.
v->arch.gic.v2.lr[i]
would be find IMHO.
Ian.
PATCH v2 12/15 xen/arm: move GIC data to driver from domain structure
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Move driver specific GIC address information to driver header file gic.h from domain.h.
--- xen/arch/arm/domain_build.c | 8 ++++---- xen/arch/arm/gic-v2.c | 28 ++++++++++++++++++---------- xen/arch/arm/vgic-v2.c | 6 +++--- xen/include/asm-arm/domain.h | 5 ++--- xen/include/asm-arm/gic.h | 5 +++++ 5 files changed, 32 insertions(+), 20 deletions(-)
xen/arch/arm/domain_build.c +4 -4
@@ -577,12 +577,12 @@ static int make_gic_node(const struct domain *d, void *fdt, tmp = new_cells;DPRINT (" Set Distributor Base 0x%" PRIpaddr"-0x%" PRIpaddr"\n" , - d->arch.vgic.dbase, d->arch.vgic.dbase +PAGE_SIZE -1 ); -dt_set_range (&tmp, node, d->arch.vgic.dbase,PAGE_SIZE ); + d->arch.vgic.info->dbase, d->arch.vgic.info->dbase +PAGE_SIZE -1 ); +dt_set_range (&tmp, node, d->arch.vgic.info->dbase,PAGE_SIZE );DPRINT (" Set Cpu Base 0x%" PRIpaddr"-0x%" PRIpaddr"\n" , - d->arch.vgic.cbase, d->arch.vgic.cbase + (PAGE_SIZE *2 ) -1 ); -dt_set_range (&tmp, node, d->arch.vgic.cbase,PAGE_SIZE *2 ); + d->arch.vgic.info->cbase, d->arch.vgic.info->cbase + (PAGE_SIZE *2 ) -1 ); +dt_set_range (&tmp, node, d->arch.vgic.info->cbase,PAGE_SIZE *2 ); res =fdt_property (fdt,"reg" , new_cells, len);xfree (new_cells);
xen/arch/arm/gic-v2.c +18 -10
@@ -413,19 +413,27 @@ static int gicv_init(struct domain *d) {int ret; + d->arch.vgic.info = xzalloc(struct vgic_info); +if ( !d->arch.vgic.info ) + { +dprintk (XENLOG_ERR ,"Failed to allocate memory for vgic_info\n" ); +return -ENOMEM ; + } +memset (d->arch.vgic.info,0 ,sizeof (d->arch.vgic.info)); +/* * Domain 0 gets the hardware address. * Guests get the virtual platform layout. */ if ( d->domain_id ==0 ) { - d->arch.vgic.dbase = gic.dbase; - d->arch.vgic.cbase = gic.cbase; + d->arch.vgic.info->dbase = gic.dbase; + d->arch.vgic.info->cbase = gic.cbase; }else { - d->arch.vgic.dbase =GUEST_GICD_BASE ; - d->arch.vgic.cbase =GUEST_GICC_BASE ; + d->arch.vgic.info->dbase =GUEST_GICD_BASE ; + d->arch.vgic.info->cbase =GUEST_GICC_BASE ; } d->arch.vgic.nr_lines =0 ;
@@ -437,19 +445,19 @@ static int gicv_init(struct domain *d)* The second page is always mapped at +4K irrespective of the * GIC_64K_STRIDE quirk. The DTB passed to the guest reflects this. */ - ret =map_mmio_regions (d, d->arch.vgic.cbase, - d->arch.vgic.cbase +PAGE_SIZE -1 , + ret =map_mmio_regions (d, d->arch.vgic.info->cbase, + d->arch.vgic.info->cbase +PAGE_SIZE -1 , gic.vbase);if ( ret )return ret;if ( !platform_has_quirk (PLATFORM_QUIRK_GIC_64K_STRIDE ) ) - ret =map_mmio_regions (d, d->arch.vgic.cbase +PAGE_SIZE , - d->arch.vgic.cbase + (2 *PAGE_SIZE ) -1 , + ret =map_mmio_regions (d, d->arch.vgic.info->cbase +PAGE_SIZE , + d->arch.vgic.info->cbase + (2 *PAGE_SIZE ) -1 , gic.vbase +PAGE_SIZE );else - ret =map_mmio_regions (d, d->arch.vgic.cbase +PAGE_SIZE , - d->arch.vgic.cbase + (2 *PAGE_SIZE ) -1 , + ret =map_mmio_regions (d, d->arch.vgic.info->cbase +PAGE_SIZE , + d->arch.vgic.info->cbase + (2 *PAGE_SIZE ) -1 , gic.vbase +16 *PAGE_SIZE );return ret;
xen/arch/arm/vgic-v2.c +3 -3
@@ -116,7 +116,7 @@ static int vgic_distr_mmio_read(struct vcpu *v, mmio_info_t *info)struct cpu_user_regs *regs =guest_cpu_user_regs ();register_t *r =select_user_reg (regs, dabt.reg);struct vgic_irq_rank *rank; -int offset = (int )(info->gpa - v->domain->arch.vgic.dbase); +int offset = (int )(info->gpa - v->domain->arch.vgic.info->dbase);int gicd_reg =REG (offset); switch ( gicd_reg )
@@ -378,7 +378,7 @@ static int vgic_distr_mmio_write(struct vcpu *v, mmio_info_t *info)struct cpu_user_regs *regs =guest_cpu_user_regs ();register_t *r =select_user_reg (regs, dabt.reg);struct vgic_irq_rank *rank; -int offset = (int )(info->gpa - v->domain->arch.vgic.dbase); +int offset = (int )(info->gpa - v->domain->arch.vgic.info->dbase);int gicd_reg =REG (offset);uint32_t tr;
@@ -562,7 +562,7 @@ static int vgic_distr_mmio_check(struct vcpu *v, paddr_t addr) {struct domain *d = v->domain; -return (addr >= (d->arch.vgic.dbase)) && (addr < (d->arch.vgic.dbase +PAGE_SIZE )); +return (addr >= (d->arch.vgic.info->dbase)) && (addr < (d->arch.vgic.info->dbase +PAGE_SIZE )); }static struct mmio_handler vgic_distr_mmio_handler = {
xen/include/asm-arm/domain.h +2 -3
@@ -148,9 +148,8 @@ struct arch_domain* struct arch_vcpu. */ struct pending_irq *pending_irqs; -/* Base address for guest GIC */ -paddr_t dbase;/* Distributor base address */ -paddr_t cbase;/* CPU base address */ +/* holds gic address information */ +struct vgic_info *info; } vgic;struct vuart {
xen/include/asm-arm/gic.h +5 -0
@@ -66,6 +66,11 @@ struct vgic_irq_rank {uint32_t itargets[8 ]; }; +struct vgic_info { +paddr_t dbase;/* Distributor base address */ +paddr_t cbase;/* CPU base address */ +}; +struct gic_state_data {uint8_t version;union {
Signature · 1 line
1.7.9.5
Re: [PATCH v2 12/15] xen/arm: move GIC data to driver from domain structure
Quoted 4 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Move driver specific GIC address information to driver header file
gic.hfromdomain.h.
Like with the other gic state I think you can avoid dynamic allocation, at least for now. (OTOH if you find the vcpu struct is getting too big, please say)
Does the v3 gic have a different set of addresses? Actually I see that you just add dbase_size and rbase to the struct so I'm not sure it really needs refactoring like this. Either a union or just
struct ... {
/* common */
... pending_irq
... dbase
/* vgic v2 only */
... cbase
/* vgic v3 only */
... rbase
} vgicwould be fine here IMHO...
PATCH v2 13/15 xen/arm: Add support for GIC v3
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Add support for GIC v3 specification
System register access(SRE) is enabled
to access cpu and virtual interface regiseters
This patch adds only basic v3 support.
Does not support Interrupt Translation support (ITS)
--- xen/arch/arm/Makefile | 7 +- xen/arch/arm/gic-v3.c | 919 +++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/gic.h | 10 + xen/include/asm-arm/gic_v3_defs.h | 187 ++++++++ 4 files changed, 1121 insertions(+), 2 deletions(-)
xen/arch/arm/Makefile +5 -2
@@ -10,7 +10,9 @@ obj-y += vpsci.o obj-y += domctl.o obj-y += sysctl.o obj-y += domain_build.o -obj-y += gic.o gic-v2.o +obj-y += gic.o +obj-y += gic-v3.o +obj-y += gic-v2.o obj-y += io.o obj-y += irq.o obj-y += kernel.o
@@ -26,7 +28,8 @@ obj-y += smpboot.o obj-y += smp.o obj-y += shutdown.o obj-y += traps.o -obj-y += vgic.o vgic-v2.o +obj-y += vgic.o +obj-y += vgic-v2.o obj-y += vtimer.o obj-y += vuart.o obj-y += hvm.o
xen/arch/arm/gic-v3.c new file +919 -0
919 lines not on this page · raw message
xen/include/asm-arm/gic.h +10 -0
@@ -69,11 +69,21 @@ struct vgic_irq_rank {struct vgic_info {paddr_t dbase;/* Distributor base address */ paddr_t cbase;/* CPU base address */ +paddr_t dbase_size;/* Distributor base size */ +paddr_t rbase;/* Re-Distributor base address */ +paddr_t rbase_size;/* Re-Distributor size */ +uint32_t rdist_stride; }; struct gic_state_data { uint8_t version; union { + struct gic_v3 { + uint32_t gic_hcr, gic_vmcr; + uint32_t gic_apr0[4]; + uint32_t gic_apr1[4]; + uint64_t gic_lr[16]; + }v3; struct gic_v2 { uint32_t gic_hcr, gic_vmcr; uint32_t gic_apr;
xen/include/asm-arm/gic_v3_defs.h new file +187 -0
187 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH v2 13/15] xen/arm: Add support for GIC v3
xen/include/asm-arm/gic_v3_defs.h line 22
Quoted 4 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
xen/include/asm-arm/gic_v3_defs.h new file +4
-0+#define GICD_CTLR (0x000) +#define GICD_TYPER (0x004) +#define GICD_IIDR (0x008) +#define GICD_STATUSR (0x010)
A lot of these are identical to the GIV v2 definitions. Is a separate set of #defines *really* necessary?
I'd be happy with:
#define GICD_CTLR (0x000)
#define GICD_TYPER (0x004)
#define GICD_IIDR (0x008)
#define GICD_STATUSR (0x010) /* GICv3 only */
#define GICD_BLARGLE (0x...) /* GICv2 only */etc.
Or if you really feel that separate defines are needed then at the least they should incorporate v2 and v3 into their names.
Ian.
Re: [PATCH v2 13/15] xen/arm: Add support for GIC v3
In reply to [email protected]xen/arch/arm/gic-v3.c line 75
Quoted 2 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
xen/arch/arm/gic-v3.c new file +2
-0+#define gic_data_rdist_rd_base () (this_cpu(rbase)) +#define gic_data_rdist_sgi_base () (gic_data_rdist_rd_base() + SZ_64K)
Macros should be SHOUTY and ideally a lot shorter.
Since we have GICD[...] etc how about GICR[...]? And for the SGI bit just use GICR[GICR_SGI_...] (where GICR_SGI_ is 64K).
xen/arch/arm/gic-v3.c line 80
Quoted 5 lines
xen/arch/arm/gic-v3.c new file +5
-0+ +static inline u64 read_cpuid_mpidr (void ) +{ +return READ_SYSREG (MPIDR_EL1 ); +}
No need for this trivial wrapper.
xen/arch/arm/gic-v3.c line 211
Quoted 2 lines
xen/arch/arm/gic-v3.c new file +2
-0+/* Wait for completion of a distributor change */ +static void gic_do_wait_for_rwp (paddr_t base)
base here is a virtual address not a physical one, no? Hence the cast you have below.
xen/arch/arm/gic-v3.c line 216
Quoted 5 lines
xen/arch/arm/gic-v3.c new file +5
-0+{ +u32 val; + do { + val = readl_relaxed((void *)base + GICD_CTLR); + val = readl_relaxed(GICD + GICD_CTLR);
???
Quoted 1 line
+
cpu_relax();
This doesn't currently yield, but in principal it could, which would mean a delay even if the termination condition was true.
Perhaps
for(;;)
{
val = readl...
if (val & ... )
break;
cpu_relax();
}???
xen/arch/arm/gic-v3.c line 223
Quoted 6 lines
xen/arch/arm/gic-v3.c new file +6
-0+ }while ( val &GICD_CTLR_RWP ); +} + +static void gic_dist_wait_for_rwp (void ) +{ +gic_do_wait_for_rwp ((paddr_t )GICD );
Ugly and seemingly unnecessary cast.
xen/arch/arm/gic-v3.c line 233
Quoted 10 lines
xen/arch/arm/gic-v3.c new file +10
-0+} + +static void gic_redist_wait_for_rwp (void ) +{ +gic_do_wait_for_rwp (gic_data_rdist_rd_base ()); +} + +static void gic_wait_for_rwp (int irq) +{ +if ( irq <32 )
Either NR_LOCAL_IRQS or suitable gic v3 specific #define please (and rename NR_LOCAL_IRQS to a v2 name)
xen/arch/arm/gic-v3.c line 265
Quoted 13 lines
xen/arch/arm/gic-v3.c new file +13
-0+gic_redist_wait_for_rwp (); + else +gic_dist_wait_for_rwp (); +} + + +static void write_aprn_regs (struct gic_state_data *d) +{ +switch ( nr_priorities ) + { +case 7 : +WRITE_SYSREG32 (d->v3.gic_apr0[2 ],ICH_AP0R2_EL2 ); +WRITE_SYSREG32 (d->v3.gic_apr1[2 ],ICH_AP1R2_EL2 );
+ /* Fall-thru */
when doing so deliberately please.
Is it harmful/illegal to write to AP0R2 etc if priorities < 7?
xen/arch/arm/gic-v3.c line 274
Quoted 9 lines
xen/arch/arm/gic-v3.c new file +9
-0+case 6 : +WRITE_SYSREG32 (d->v3.gic_apr0[1 ],ICH_AP0R1_EL2 ); +WRITE_SYSREG32 (d->v3.gic_apr1[1 ],ICH_AP1R1_EL2 ); +case 5 : +WRITE_SYSREG32 (d->v3.gic_apr0[0 ],ICH_AP0R0_EL2 ); +WRITE_SYSREG32 (d->v3.gic_apr1[0 ],ICH_AP1R0_EL2 ); +break ; +default : +panic ("Write Undefined active priorities \n" );
I think these limits should be checked at init time with a panic there and this should be come an assertion.
xen/arch/arm/gic-v3.c line 279
Quoted 5 lines
xen/arch/arm/gic-v3.c new file +5
-0+ } +} + +static void read_aprn_regs (struct gic_state_data *d) +{
Same comments here as for write.
xen/arch/arm/gic-v3.c line 354
Quoted 9 lines
xen/arch/arm/gic-v3.c new file +9
-0+static void gic_enable_irq (int irq) +{ +uint32_t enabler; + +/* Enable routing */ +if ( irq >31 ) + { + enabler =readl_relaxed (GICD +GICD_ISENABLER + (irq /32 ) *4 ); +writel_relaxed (enabler | (1u << (irq %32 )),GICD +GICD_ISENABLER + (irq /32 ) *4 );
&GICD[GICD_IS_ENABLER +...] ?
xen/arch/arm/gic-v3.c line 359
Quoted 5 lines
xen/arch/arm/gic-v3.c new file +5
-0+ } +else + { + enabler =readl_relaxed ((void *)gic_data_rdist_sgi_base () +GICR_ISENABLER0 ); +writel_relaxed (enabler | (1u << irq), (void *)gic_data_rdist_sgi_base () +GICR_ISENABLER0 );
No casts please, just get the type right to start with.
Per the comments at the macro definition this could be &GIRC[GICR_SGI_ISENABLR0].
I think both halves of this if would benefit from using some temporary variables for clarity, or at least
enabler = read... enabler |= thing writel(enabler, ...)
Quoted 9 lines
xen/arch/arm/gic-v3.c new file +9
-0+/* +* - needs to be called with gic.lock held +* - needs to be called with a valid cpu_mask, ie each cpu in the mask has +* already called gic_cpu_init +*/ +static void gic_set_irq_property (unsigned int irq,bool_t level, +const cpumask_t *cpu_mask, +unsigned int priority) +{
xen/arch/arm/gic-v3.c line 414
Quoted 10 lines
xen/arch/arm/gic-v3.c new file +10
-0+uint32_t cfg, edgebit; +u64 affinity; +unsigned int cpu =gic_mask_cpu (cpu_mask); +paddr_t rebase; + + +/* Set edge / level */ +if ( irq <16 ) +/* SGI's are always edge-triggered not need to call GICD_ICFGR0 */ + cfg =readl_relaxed ((void *)gic_data_rdist_sgi_base () +GICR_ICFGR0 );
casts and names throughout this function.
[...]
xen/arch/arm/gic-v3.c line 454
Quoted 8 lines
xen/arch/arm/gic-v3.c new file +8
-0+static void __init gic_dist_init (void ) +{ +uint32_t type; +u64 affinity; +int i; + +/* Disable the distributor */ +writel_relaxed (0 ,GICD +GICD_CTLR );
Does using readl/writel_relaxed buy you anything over using a GICD macro with a volatile in it like the v2 code does?
Quoted 4 lines
xen/arch/arm/gic-v3.c new file +4
-0+ + type =readl_relaxed (GICD +GICD_TYPER ); + gic.lines =32 * ((type &GICD_TYPE_LINES ) +1 ); +
xen/arch/arm/gic-v3.c line 468
Quoted 10 lines
xen/arch/arm/gic-v3.c new file +10
-0+printk ("GIC: %d lines, (IID %8.8x).\n" , + gic.lines,readl_relaxed (GICD +GICD_IIDR )); + +/* Default all global IRQs to level, active low */ +for ( i =32 ; i < gic.lines; i +=16 ) +writel_relaxed (0 ,GICD +GICD_ICFGR + (i /16 ) *4 ); + +/* Default priority for global interrupts */ +for ( i =32 ; i < gic.lines; i +=4 ) +writel_relaxed ((GIC_PRI_IRQ <<24 |GIC_PRI_IRQ <<16 |GIC_PRI_IRQ <<8 |GIC_PRI_IRQ ),GICD +GICD_IPRIORITYR + (i /4 ) *4 );
Watch out for long lines please, try and keep to 80 columns.
Quoted 42 lines
xen/arch/arm/gic-v3.c new file +42
-0+ +/* Disable all global interrupts */ +for ( i =32 ; i < gic.lines; i +=32 ) +writel_relaxed (0xffffffff ,GICD +GICD_ICENABLER + (i /32 ) *4 ); + +gic_dist_wait_for_rwp (); + +/* Turn on the distributor */ +writel_relaxed (GICD_CTL_ENABLE |GICD_CTLR_ARE_NS |GICD_CTLR_ENABLE_G1A |GICD_CTLR_ENABLE_G1 ,GICD +GICD_CTLR ); + +/* Route all global IRQs to this CPU */ + affinity =gic_mpidr_to_affinity (read_cpuid_mpidr ()); +for ( i =32 ; i < gic.lines; i++ ) +writeq_relaxed (affinity,GICD +GICD_IROUTER + i *8 ); +} + +static void gic_enable_redist (void ) +{ +paddr_t rbase; +u32 val; + + rbase =this_cpu (rbase); + +/* Wake up this CPU redistributor */ + val =readl_relaxed ((void *)rbase +GICR_WAKER ); + val &= ~GICR_WAKER_ProcessorSleep; +writel_relaxed (val, (void *)rbase +GICR_WAKER ); + +do { + val =readl_relaxed ((void *)rbase +GICR_WAKER ); +cpu_relax (); + }while ( val & GICR_WAKER_ChildrenAsleep ); +} + +static int __init gic_populate_rdist (void ) +{ +u64 mpidr =cpu_logical_map (smp_processor_id ()); +u64 typer; +u64 aff; +int i; +uint32_t reg; +
xen/arch/arm/gic-v3.c line 520
Quoted 10 lines
xen/arch/arm/gic-v3.c new file +10
-0+ aff = mpidr & ((1 <<24 ) -1 ); + aff |= (mpidr >>8 ) & (0xffUL <<24 ); + +for ( i =0 ; i < gic.rdist_count; i++ ) + { +uint32_t ptr =0 ; + + reg =readl_relaxed (GICR + ptr +GICR_PIDR0 ); +if ( (reg &0xff ) != GICR_PIDR0_GICv3 ) { +printk ("No redistributor present @%x\n" , ptr);
Debug message?
xen/arch/arm/gic-v3.c line 528
Quoted 8 lines
xen/arch/arm/gic-v3.c new file +8
-0+break ; + } + + do { + typer = readq_relaxed(GICR + ptr + GICR_TYPER); + if ( (typer >> 32) == aff ) + { + this_cpu(rbase) = (u64)GICR + ptr;
Cast?
xen/arch/arm/gic-v3.c line 537
Quoted 9 lines
xen/arch/arm/gic-v3.c new file +9
-0+printk ("CPU%d: found redistributor %llx region %d\n" , +smp_processor_id (), (unsigned long long ) mpidr, i); +return 0 ; + } + +if ( gic.rdist_stride ) { + ptr += gic.rdist_stride; + }else { + ptr +=SZ_64K *2 ;/* Skip RD_base + SGI_base */
Whatever initialises rdist_stride should default it to SZ_64K if that is indeed the default.
xen/arch/arm/gic-v3.c line 546
Quoted 9 lines
xen/arch/arm/gic-v3.c new file +9
-0+if ( typer &GICR_TYPER_VLPIS ) + ptr +=SZ_64K *2 ;/* Skip VLPI_base + reserved page */ + } + }while ( !(typer &GICR_TYPER_LAST ) ); + } + +/* We couldn't even deal with ourselves... */ +printk ("CPU%d: mpidr %lx has no re-distributor!\n" , +smp_processor_id (), (unsigned long )mpidr);
No casts, either use PRIx64 or make the type correct.
(I'm going to stop mentioning casts, please eliminate them all or explain why they are needed).
xen/arch/arm/gic-v3.c line 567
Quoted 5 lines
xen/arch/arm/gic-v3.c new file +5
-0+/* +* Set priority on PPI and SGI interrupts +*/ +for (i =0 ; i <16 ; i +=4 ) +writel_relaxed ((GIC_PRI_IPI <<24 |GIC_PRI_IPI <<16 |GIC_PRI_IPI <<8 |GIC_PRI_IPI ), (void *)rbase_sgi +GICR_IPRIORITYR0 + (i /4 ) *4 );
Long lines.
xen/arch/arm/gic-v3.c line 640
Quoted 13 lines
xen/arch/arm/gic-v3.c new file +13
-0+ +static u16 gic_compute_target_list (int *base_cpu,const struct cpumask *mask, +u64 cluster_id) +{ +int cpu = *base_cpu; +u64 mpidr =cpu_logical_map (cpu); +u16 tlist =0 ; + +while ( cpu < nr_cpu_ids ) + { +/* +* If we ever get a cluster of more than 16 CPUs, just +* scream and skip that CPU.
I don't see any screaming. We would want to know if this was happening, wouldn't we?
Quoted 14 lines
xen/arch/arm/gic-v3.c new file +14
-0+static void gic_update_lr (int lr,struct pending_irq *p,unsigned int state) +{ +u64 grp =GICH_LR_GRP1 ; +u64 val =0 ; + +BUG_ON (lr >= nr_lrs); +BUG_ON (lr <0 ); + + val = ((((u64 )state) &0x3 ) <<GICH_LR_STATE_SHIFT ) | grp | + ((((u64 )p->priority) &0xff ) <<GICH_LR_PRIORITY_SHIFT ) | + (((u64 )p->irq &GICH_LR_VIRTUAL_MASK ) <<GICH_LR_VIRTUAL_SHIFT ); + +if ( p->desc !=NULL ) + val |=GICH_LR_HW |(((u64 ) p->desc->irq &GICH_LR_PHYSICAL_MASK ) <<GICH_LR_PHYSICAL_SHIFT );
xen/arch/arm/gic-v3.c line 715
Quoted 10 lines
xen/arch/arm/gic-v3.c new file +10
-0+ +gich_write_lr (lr, val); +} + +static void gic_clear_lr (int lr) +{ +gich_write_lr (lr,0 ); +} + +static void gic_read_lr (int lr,struct gic_lr *lr_reg)
I can't find struct gic_lr anywhere.
xen/arch/arm/gic-v3.c line 724
Quoted 9 lines
xen/arch/arm/gic-v3.c new file +9
-0+{ +u64 lrv; + lrv =gich_read_lr (lr); + lr_reg->pirq = (lrv >>GICH_LR_PHYSICAL_SHIFT ) &GICH_LR_PHYSICAL_MASK ; + lr_reg->virq = (lrv >>GICH_LR_VIRTUAL_SHIFT ) &GICH_LR_VIRTUAL_MASK ; + lr_reg->priority = (lrv >>GICH_LR_PRIORITY_SHIFT ) &GICH_LR_PRIORITY_MASK ; + lr_reg->state = (lrv >>GICH_LR_STATE_SHIFT ) &GICH_LR_STATE_MASK ; + lr_reg->hw_status = (lrv >>GICH_LR_HW_SHIFT ) &GICH_LR_HW_MASK ; + lr_reg->grp = (lrv >>GICH_LR_GRP_SHIFT ) &GICH_LR_GRP_MASK ;
If you want to be able to do field-by-field accesses then please do what the page table code does and use a union and bit fields. See lpae_pt_t.
typedef union __packed {
uint64_t bits;
struct {
unsigned long pirq:4;
unsugned long virq:4;
etc, including explicit padding
};
} gicv3_lr;Then:
gicv3 lrv = {.bits = gich_read_lr(lr)};xen/arch/arm/gic-v3.c line 776
Quoted 8 lines
xen/arch/arm/gic-v3.c new file +8
-0+static struct dt_irq *gic_maintenance_irq (void ) +{ +return &gic.maintenance; +} + +static void gic_hcr_status (uint32_t flag,uint8_t status) +{ +if ( status )
status is actually "bool_t set" ?
xen/arch/arm/gic-v3.c line 841
Quoted 6 lines
xen/arch/arm/gic-v3.c new file +6
-0+WRITE_SYSREG32 ((READ_SYSREG32 (ICH_HCR_EL2 ) | flag),ICH_HCR_EL2 ); + else + WRITE_SYSREG32((READ_SYSREG32(ICH_HCR_EL2) & (~flag)), ICH_HCR_EL2); +} + + rdist_regs = xzalloc_array(struct rdist_region, gic.rdist_count);
I thought I saw a comment at the top saying that only a single region was supported? Shouldn't this be checked somewhere, or even better fixed.
Is there a limit on gic.rdist_count? How large is it? Can rdist_regs be a static array?
Ian.
Re: [PATCH v2 13/15] xen/arm: Add support for GIC v3
Quoted 10 lines · Ian Campbell
xen/arch/arm/gic-v3.c line 75
Quoted 2 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
xen/arch/arm/gic-v3.c new file +2
-0+#define gic_data_rdist_rd_base () (this_cpu(rbase)) +#define gic_data_rdist_sgi_base () (gic_data_rdist_rd_base() + SZ_64K)Macros should be SHOUTY and ideally a lot shorter.
Since we have GICD[...] etc how about GICR[...]? And for the SGI bit just use GICR[GICR_SGI_...] (where
GICR_SGI_is 64K).
Quoted 7 lines
xen/arch/arm/gic-v3.c line 80
Quoted 5 lines
xen/arch/arm/gic-v3.c new file +5
-0+ +static inline u64 read_cpuid_mpidr (void ) +{ +return READ_SYSREG (MPIDR_EL1 ); +}No need for this trivial wrapper.
As said on V1:MPDIR_EL1 is already replicated in current_cpu_data.mpidr.bits
Quoted 11 lines
xen/arch/arm/gic-v3.c line 454
Quoted 8 lines
xen/arch/arm/gic-v3.c new file +8
-0+static void __init gic_dist_init (void ) +{ +uint32_t type; +u64 affinity; +int i; + +/* Disable the distributor */ +writel_relaxed (0 ,GICD +GICD_CTLR );Does using readl/writel_relaxed buy you anything over using a GICD macro with a volatile in it like the v2 code does?
As ioremap is used to map the GIC MMIO, IHMO it's better to use readl/writel_relaxed to be consistent.
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 13/15] xen/arm: Add support for GIC v3
Quoted 19 lines · Julien Grall
Quoted 10 lines · Ian Campbell
xen/arch/arm/gic-v3.c line 75
Quoted 2 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
xen/arch/arm/gic-v3.c new file +2
-0+#define gic_data_rdist_rd_base () (this_cpu(rbase)) +#define gic_data_rdist_sgi_base () (gic_data_rdist_rd_base() + SZ_64K)Macros should be SHOUTY and ideally a lot shorter.
Since we have GICD[...] etc how about GICR[...]? And for the SGI bit just use GICR[GICR_SGI_...] (where
GICR_SGI_is 64K).Quoted 7 lines
xen/arch/arm/gic-v3.c line 80
Quoted 5 lines
xen/arch/arm/gic-v3.c new file +5
-0+ +static inline u64 read_cpuid_mpidr (void ) +{ +return READ_SYSREG (MPIDR_EL1 ); +}No need for this trivial wrapper.
Quoted 3 lines
As said on V1:
MPDIR_EL1is already replicated in current_cpu_data.mpidr.bits
I find only MIDR register contents in current_cpu_data.midr.bits
but not MPIDR
Re: [PATCH v2 13/15] xen/arm: Add support for GIC v3
Quoted 20 lines · Vijay Kilari
Quoted 19 lines · Julien Grall
Quoted 17 lines · Ian Campbell
xen/arch/arm/gic-v3.c line 75
Quoted 2 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
xen/arch/arm/gic-v3.c new file +2
-0+#define gic_data_rdist_rd_base () (this_cpu(rbase)) +#define gic_data_rdist_sgi_base () (gic_data_rdist_rd_base() + SZ_64K)Macros should be SHOUTY and ideally a lot shorter.
Since we have GICD[...] etc how about GICR[...]? And for the SGI bit just use GICR[GICR_SGI_...] (where
GICR_SGI_is 64K).xen/arch/arm/gic-v3.c line 80
Quoted 5 lines
xen/arch/arm/gic-v3.c new file +5
-0+ +static inline u64 read_cpuid_mpidr (void ) +{ +return READ_SYSREG (MPIDR_EL1 ); +}No need for this trivial wrapper.
Quoted 5 lines
Quoted 3 lines
As said on V1:
MPDIR_EL1is already replicated in current_cpu_data.mpidr.bitsI find only MIDR register contents in current_cpu_data.midr.bits
but not MPIDR
Second field of the structure...
Or even better cpu_logical_map(mycpu) as you already use in gic_set_irq_property.
That made me think about your function gic_mpidir_to_affinity (see below). Why do you mask with GICD_IROUTER_SPI_MODE_ANY? It should be valid anywhere.
If not you may send the SGI to a wrong CPU.
+static u64 gic_mpidr_to_affinity(u64 mpidr)
+{
+ /* Make sure we don't broadcast the interrupt */
+ return mpidr & ~GICD_IROUTER_SPI_MODE_ANY;
+}
+
Signature · 1 line
Julien Grall
Re: [PATCH v2 13/15] xen/arm: Add support for GIC v3
In reply to Ian CampbellQuoted 8 lines · Ian Campbell
Quoted 8 lines
xen/arch/arm/gic-v3.c new file +8
-0+ +static u16 gic_compute_target_list (int *base_cpu,const struct cpumask *mask, +u64 cluster_id) +{ +int cpu = *base_cpu; +u64 mpidr =cpu_logical_map (cpu); +u16 tlist =0 ; +
Quoted 8 lines
xen/arch/arm/gic-v3.c line 640
Quoted 5 lines
xen/arch/arm/gic-v3.c new file +5
-0+while ( cpu < nr_cpu_ids ) + { +/* +* If we ever get a cluster of more than 16 CPUs, just +* scream and skip that CPU. I don't see any screaming. We would want to know if this was happening, wouldn't we?
It seems the code of GICv3 has been half-copied for Linux code :). I've just found this function in Mark's series.
Signature · 1 line
Julien Grall
Re: [PATCH v2 13/15] xen/arm: Add support for GIC v3
In reply to Ian CampbellQuoted 11 lines · Ian Campbell
xen/arch/arm/gic-v3.c line 265
Quoted 7 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
xen/arch/arm/gic-v3.c new file +7
-0+static void write_aprn_regs (struct gic_state_data *d) +{ +switch ( nr_priorities ) + { +case 7 : +WRITE_SYSREG32 (d->v3.gic_apr0[2 ],ICH_AP0R2_EL2 ); +WRITE_SYSREG32 (d->v3.gic_apr1[2 ],ICH_AP1R2_EL2 );+ /* Fall-thru */
Quoted 3 lines
when doing so deliberately please.
Is it harmful/illegal to write to AP0R2 etc if priorities < 7?
The APR register is implementation defined. It is upto the platform to support number of APR registers. So based on nr_priorities value we read save and restore only platform supported registers
Quoted 9 lines
xen/arch/arm/gic-v3.c line 715
Quoted 7 lines
xen/arch/arm/gic-v3.c new file +7
-0+ +static void gic_clear_lr (int lr) +{ +gich_write_lr (lr,0 ); +} + +static void gic_read_lr (int lr,struct gic_lr *lr_reg)I can't find struct
gic_lranywhere.
Already defined in previous patch
Quoted 23 lines
xen/arch/arm/gic-v3.c line 724
Quoted 10 lines
xen/arch/arm/gic-v3.c new file +9
-0+{ +u64 lrv; + lrv =gich_read_lr (lr); + lr_reg->pirq = (lrv >>GICH_LR_PHYSICAL_SHIFT ) &GICH_LR_PHYSICAL_MASK ; + lr_reg->virq = (lrv >>GICH_LR_VIRTUAL_SHIFT ) &GICH_LR_VIRTUAL_MASK ; + lr_reg->priority = (lrv >>GICH_LR_PRIORITY_SHIFT ) &GICH_LR_PRIORITY_MASK ; + lr_reg->state = (lrv >>GICH_LR_STATE_SHIFT ) &GICH_LR_STATE_MASK ; + lr_reg->hw_status = (lrv >>GICH_LR_HW_SHIFT ) &GICH_LR_HW_MASK ; + lr_reg->grp = (lrv >>GICH_LR_GRP_SHIFT ) &GICH_LR_GRP_MASK ;If you want to be able to do field-by-field accesses then please do what the page table code does and use a union and bit fields. See
lpae_pt_t.typedef union __packed { uint64_t bits; struct { unsigned long pirq:4; unsugned long virq:4; etc, including explicit padding }; } gicv3_lr;
Quoted 3 lines
Then:
gicv3 lrv = {.bits = gich_read_lr(lr)};
The complexity is LR register is 64 bit in v3 and 32 bit v2. Though I define this like above for v2 & v3, generic code still need to access based on hw version. So I have make it without bit-fields
Quoted 12 lines
xen/arch/arm/gic-v3.c line 776
Quoted 9 lines
xen/arch/arm/gic-v3.c new file +8
-0+static struct dt_irq *gic_maintenance_irq (void ) +{ +return &gic.maintenance; +} + +static void gic_hcr_status (uint32_t flag,uint8_t status) +{ +if ( status )status is actually "
bool_tset" ?
Quoted 10 lines
xen/arch/arm/gic-v3.c line 841
Quoted 6 lines
xen/arch/arm/gic-v3.c new file +6
-0+WRITE_SYSREG32 ((READ_SYSREG32 (ICH_HCR_EL2 ) | flag),ICH_HCR_EL2 ); + else + WRITE_SYSREG32((READ_SYSREG32(ICH_HCR_EL2) & (~flag)), ICH_HCR_EL2); +} + + rdist_regs = xzalloc_array(struct rdist_region, gic.rdist_count);I thought I saw a comment at the top saying that only a single region was supported? Shouldn't this be checked somewhere, or even better fixed.
Yes, only rdist_region[0] is read from dt, which supports upto 32 cores. So one can add if more than 32 cores is required.
Quoted 3 lines
Is there a limit on gic.rdist_count? How large is it? Can
rdist_regsbe a static array?
The rdist count is read from dt. so it is implementation defined
Quoted 4 lines
Ian.
Re: [PATCH v2 13/15] xen/arm: Add support for GIC v3
Quoted 11 lines · Vijay Kilari
Quoted 9 lines · Ian Campbell
xen/arch/arm/gic-v3.c line 715
Quoted 7 lines
xen/arch/arm/gic-v3.c new file +7
-0+ +static void gic_clear_lr (int lr) +{ +gich_write_lr (lr,0 ); +} + +static void gic_read_lr (int lr,struct gic_lr *lr_reg)I can't find struct
gic_lranywhere.Already defined in previous patch
Which? I looked at the time and couldn't find it.
Quoted 23 lines
Quoted 23 lines
xen/arch/arm/gic-v3.c line 724
Quoted 10 lines
xen/arch/arm/gic-v3.c new file +9
-0+{ +u64 lrv; + lrv =gich_read_lr (lr); + lr_reg->pirq = (lrv >>GICH_LR_PHYSICAL_SHIFT ) &GICH_LR_PHYSICAL_MASK ; + lr_reg->virq = (lrv >>GICH_LR_VIRTUAL_SHIFT ) &GICH_LR_VIRTUAL_MASK ; + lr_reg->priority = (lrv >>GICH_LR_PRIORITY_SHIFT ) &GICH_LR_PRIORITY_MASK ; + lr_reg->state = (lrv >>GICH_LR_STATE_SHIFT ) &GICH_LR_STATE_MASK ; + lr_reg->hw_status = (lrv >>GICH_LR_HW_SHIFT ) &GICH_LR_HW_MASK ; + lr_reg->grp = (lrv >>GICH_LR_GRP_SHIFT ) &GICH_LR_GRP_MASK ;If you want to be able to do field-by-field accesses then please do what the page table code does and use a union and bit fields. See
lpae_pt_t.typedef union __packed { uint64_t bits; struct { unsigned long pirq:4; unsugned long virq:4; etc, including explicit padding }; } gicv3_lr;
Quoted 6 lines
Quoted 3 lines
Then:
gicv3 lrv = {.bits = gich_read_lr(lr)};The complexity is LR register is 64 bit in v3 and 32 bit v2. Though I define this like above for v2 & v3, generic code still need to access based on hw version. So I have make it without bit-fields
How does the generic code access without knowing the size? And if it knows the size it can equally choose between gicv3_lr and gicv2_lr at the appropriate point.
Quoted 10 lines
Quoted 10 lines
xen/arch/arm/gic-v3.c line 841
Quoted 6 lines
xen/arch/arm/gic-v3.c new file +6
-0+WRITE_SYSREG32 ((READ_SYSREG32 (ICH_HCR_EL2 ) | flag),ICH_HCR_EL2 ); + else + WRITE_SYSREG32((READ_SYSREG32(ICH_HCR_EL2) & (~flag)), ICH_HCR_EL2); +} + + rdist_regs = xzalloc_array(struct rdist_region, gic.rdist_count);I thought I saw a comment at the top saying that only a single region was supported? Shouldn't this be checked somewhere, or even better fixed.
Quoted 2 lines
Yes, only rdist_region[0] is read from dt, which supports upto 32 cores. So one can add if more than 32 cores is required.
Something should error out if more than 32 cores are present then. Does it?
Quoted 3 lines
Quoted 2 lines
Is there a limit on gic.rdist_count? How large is it? Can
rdist_regsbe a static array?The rdist count is read from dt. so it is implementation defined
Surely there must be some architectural limit which sets the maximum size an implementation can use?
Ian.
Re: [PATCH v2 13/15] xen/arm: Add support for GIC v3
Quoted 41 lines · Ian Campbell
Quoted 11 lines · Vijay Kilari
Quoted 9 lines · Ian Campbell
xen/arch/arm/gic-v3.c line 715
Quoted 7 lines
xen/arch/arm/gic-v3.c new file +7
-0+ +static void gic_clear_lr (int lr) +{ +gich_write_lr (lr,0 ); +} + +static void gic_read_lr (int lr,struct gic_lr *lr_reg)I can't find struct
gic_lranywhere.Already defined in previous patch
Which? I looked at the time and couldn't find it.
Quoted 26 lines
Quoted 26 lines
xen/arch/arm/gic-v3.c line 724
Quoted 10 lines
xen/arch/arm/gic-v3.c new file +9
-0+{ +u64 lrv; + lrv =gich_read_lr (lr); + lr_reg->pirq = (lrv >>GICH_LR_PHYSICAL_SHIFT ) &GICH_LR_PHYSICAL_MASK ; + lr_reg->virq = (lrv >>GICH_LR_VIRTUAL_SHIFT ) &GICH_LR_VIRTUAL_MASK ; + lr_reg->priority = (lrv >>GICH_LR_PRIORITY_SHIFT ) &GICH_LR_PRIORITY_MASK ; + lr_reg->state = (lrv >>GICH_LR_STATE_SHIFT ) &GICH_LR_STATE_MASK ; + lr_reg->hw_status = (lrv >>GICH_LR_HW_SHIFT ) &GICH_LR_HW_MASK ; + lr_reg->grp = (lrv >>GICH_LR_GRP_SHIFT ) &GICH_LR_GRP_MASK ;If you want to be able to do field-by-field accesses then please do what the page table code does and use a union and bit fields. See
lpae_pt_t.typedef union __packed { uint64_t bits; struct { unsigned long pirq:4; unsugned long virq:4; etc, including explicit padding }; } gicv3_lr;Then:
gicv3 lrv = {.bits = gich_read_lr(lr)};
Quoted 7 lines
Quoted 3 lines
The complexity is LR register is 64 bit in v3 and 32 bit v2. Though I define this like above for v2 & v3, generic code still need to access based on hw version. So I have make it without bit-fields
How does the generic code access without knowing the size? And if it knows the size it can equally choose between
gicv3_lrandgicv2_lrat the appropriate point.
There is one common gic_lr as below where respective GIC {v2/v3} will decode in the callback and generic code just access by its fields.
struct gic_lr {
uint32_t pirq;
uint32_t virq;
uint8_t priority;
uint8_t state;
uint8_t hw_status;
uint8_t grp;
};
Quoted 17 lines
Quoted 11 lines
Quoted 11 lines
xen/arch/arm/gic-v3.c line 841
Quoted 7 lines
xen/arch/arm/gic-v3.c new file +6
-0+WRITE_SYSREG32 ((READ_SYSREG32 (ICH_HCR_EL2 ) | flag),ICH_HCR_EL2 ); + else + WRITE_SYSREG32((READ_SYSREG32(ICH_HCR_EL2) & (~flag)), ICH_HCR_EL2); +} + + rdist_regs = xzalloc_array(struct rdist_region, gic.rdist_count);I thought I saw a comment at the top saying that only a single region was supported? Shouldn't this be checked somewhere, or even better fixed.
Quoted 2 lines
Yes, only rdist_region[0] is read from dt, which supports upto 32 cores. So one can add if more than 32 cores is required.
Something should error out if more than 32 cores are present then. Does it?
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Is there a limit on gic.rdist_count? How large is it? Can
rdist_regsbe a static array?The rdist count is read from dt. so it is implementation defined
Surely there must be some architectural limit which sets the maximum size an implementation can use?
I fixed this in next version. GIC v3 driver will read all the re-distributor regions
from dt. However, I set MAX_RDIST_COUNT to 4 because
of static allocation in domain struct to hold these addresses. Check is made in GICv3 driver if number of regions in dt is more than 4. If we go for dynamic allocation we can remove this constraint as well.
paddr_t cbase; /* CPU base address */
+ /* GIC V3 addressing */
+ paddr_t dbase_size; /* Distributor base size */
+ paddr_t rbase[MAX_RDIST_COUNT]; /* Re-Distributor base address */
+ paddr_t rbase_size[MAX_RDIST_COUNT]; /* Re-Distributor size */
+ uint32_t rdist_stride; /* Re-Distributor stride */
+ int rdist_count; /* No. of Re-Distributors */
} vgic;Quoted 3 lines
Ian.
PATCH v2 14/15 xen/arm: Add vgic support for GIC v3
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Add vgic driver support for GIC v3 version.
--- xen/arch/arm/Makefile | 1 + xen/arch/arm/vgic-v3.c | 927 +++++++++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/gic.h | 5 +- 3 files changed, 932 insertions(+), 1 deletion(-)
xen/arch/arm/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-y += smp.o obj-y += shutdown.o obj-y += traps.o obj-y += vgic.o +obj-y += vgic-v3.o obj-y += vgic-v2.o obj-y += vtimer.o obj-y += vuart.o
xen/arch/arm/vgic-v3.c new file +927 -0
927 lines not on this page · raw message
xen/include/asm-arm/gic.h +4 -1
@@ -63,7 +63,10 @@ struct vgic_irq_rank {uint32_t ienable, iactive, ipend, pendsgi;uint32_t icfg[2 ];uint32_t ipriority[8 ]; -uint32_t itargets[8 ]; +union { +uint32_t itargets[8 ]; +uint64_t irouter[32 ]; + }; };struct vgic_info {
Signature · 1 line
1.7.9.5
Re: [PATCH v2 14/15] xen/arm: Add vgic support for GIC v3
Quoted 3 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Add vgic driver support for GIC v3 version.
There is an awful lot of code duplication with the v2 stuff here, especially with the distributor, but even the redistrubotr stuff looks like it could share common implementation with the v2 distro for at least some functionality.
I think we should investigate a sinlge driver here, or at least refactoring anything which is common into a library of helper functions which both can use.
xen/arch/arm/vgic-v3.c line 156
Quoted 4 lines
xen/arch/arm/vgic-v3.c new file +4
-0+case GICR_SETLPIR : +case GICR_CLRLPIR : +/* WO */ +return 0 ;
Would the real hardware fault here? Or would it read unknown or zero or os "WO" short for "write ignore"? (in which case goto write_ignore)
Quoted 5 lines
xen/arch/arm/vgic-v3.c new file +5
-0+case GICR_PROPBASER : +/* LPI's not implemented */ + goto read_as_zero; +case GICR_PENDBASER : +/* LPI's not implemented */
xen/arch/arm/vgic-v3.c line 171
Quoted 10 lines
xen/arch/arm/vgic-v3.c new file +10
-0+ goto read_as_zero; +case GICR_INVLPIR : +case GICR_INVALLR : +/* WO */ +return 0 ; +case GICR_SYNCR : +if ( dabt.size !=2 ) goto bad_width; +/* RO */ +/* Return as not busy */ + *r =1 ;
#define for the 1 please.
xen/arch/arm/vgic-v3.c line 178
Quoted 7 lines
xen/arch/arm/vgic-v3.c new file +7
-0+return 1 ; +case GICR_MOVLPIR : +case GICR_MOVALLR : +/* WO */ +return 0 ; + case GICR_PIDR7... GICR_PIDR0: + *r =0x93 ;
Magic number?
xen/arch/arm/vgic-v3.c line 181
Quoted 3 lines
xen/arch/arm/vgic-v3.c new file +3
-0+return 1 ; +default : +printk ("vGICR: read r%d offset %#08x\n not found" , dabt.reg, offset);
missing return 0.
Quoted 14 lines
xen/arch/arm/vgic-v3.c new file +14
-0+ +static int __vgic_rdistr_mmio_write (struct vcpu *v,mmio_info_t *info,uint32_t offset) +{ +struct hsr_dabt dabt = info->dabt; +struct cpu_user_regs *regs =guest_cpu_user_regs (); +register_t *r =select_user_reg (regs, dabt.reg); +int gicr_reg =REG (offset); + +switch ( gicr_reg ) + { +case GICR_CTLR : +/* We do not implement LPI's, read zero */ + goto write_ignore; +case GICR_IIDR :
xen/arch/arm/vgic-v3.c line 218
Quoted 10 lines
xen/arch/arm/vgic-v3.c new file +10
-0+case GICR_TYPER : +/* RO */ + goto write_ignore; +case GICR_STATUSR : +/* Not implemented */ + goto write_ignore; +case GICR_WAKER : +/* Not implemented */ + goto write_ignore; +case GICR_SETLPIR :
Missing a comment? (Not implemented? Write ignore?) (several others here)
Quoted 15 lines
xen/arch/arm/vgic-v3.c new file +15
-0+return 1 ; +case GICR_CLRLPIR : +return 1 ; +case GICR_PROPBASER : +/* LPI is not implemented */ + goto write_ignore; +case GICR_PENDBASER : +/* LPI is not implemented */ + goto write_ignore; +case GICR_INVLPIR : +return 1 ; +case GICR_INVALLR : +return 1 ; +case GICR_SYNCR : +/* RO */
xen/arch/arm/vgic-v3.c line 243
Quoted 10 lines
xen/arch/arm/vgic-v3.c new file +10
-0+ goto write_ignore; +case GICR_MOVLPIR : +return 1 ; +case GICR_MOVALLR : +return 1 ; + case GICR_PIDR7... GICR_PIDR0: +/* RO */ + goto write_ignore; +default : +printk ("vGICR: write r%d offset %#08x\n not found" , dabt.reg, offset);
missing return.
Quoted 16 lines
xen/arch/arm/vgic-v3.c new file +16
-0+ } +bad_width: +printk ("vGICD: bad write width %d r%d=%" PRIregister" offset %#08x\n" , + dabt.size, dabt.reg, *r, offset); +domain_crash_synchronous (); +return 0 ; + +write_ignore: +if ( dabt.size !=2 ) goto bad_width; +return 1 ; +} + + +static int vgic_rdistr_mmio_read (struct vcpu *v,mmio_info_t *info) +{ +uint32_t offset;
xen/arch/arm/vgic-v3.c line 460
Quoted 10 lines
xen/arch/arm/vgic-v3.c new file +10
-0+ +if ( !v->domain->arch.vgic.info->rdist_stride ) + offset = info->gpa & (v->domain->arch.vgic.info->rdist_stride -1 ); +else + offset = info->gpa &0x1FFFF ; + +if ( offset <SZ_64K ) +return __vgic_rdistr_mmio_read (v, info, offset); +else if ( (offset -SZ_64K ) <SZ_64K ) +return vgic_rdistr_sgi_mmio_read (v, info, (offset -SZ_64K ));
I think you should either register two mmio handlers or maybe just handle this all at once in a single callback.
I didn't see any system register handling, I suppose that is all handled by the hardware GICV stuff?
Re: [PATCH v2 14/15] xen/arm: Add vgic support for GIC v3
Quoted 5 lines · Ian Campbell
Quoted 3 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Add vgic driver support for GIC v3 version.
Quoted 8 lines
There is an awful lot of code duplication with the v2 stuff here, especially with the distributor, but even the redistrubotr stuff looks like it could share common implementation with the v2 distro for at least some functionality.
I think we should investigate a sinlge driver here, or at least refactoring anything which is common into a library of helper functions which both can use.
Yes, only distributor code is common which is just 2 functions i.e read & write functions.
But the whole complexity is v2 gic & vgic driver is it runs with byte offset that is the reason
why in gic_v2_defs all the register addresses definitions are divided by 4. So this make it quite difficult to make common code.
With GICv2 HW constraint, I could not take it up. May be we can take this as separate task.
Quoted 4 lines
Quoted 1 line
+ case
GICR_SETLPIR:I think you should either register two mmio handlers or maybe just handle this all at once in a single callback.
There is only one address rdistributore base and size extracted from dt.
So we register one handle for this entire region and this single callback will take access either GICR or SGI's GICR region.
Quoted 2 lines
I didn't see any system register handling, I suppose that is all handled by the hardware GICV stuff?
For all system register accesses in Dom's, HW treats are virtual access.
The memory mapped GICD & GICR registers are virtualized by VGIC
Quoted 1 line
Re: [PATCH v2 14/15] xen/arm: Add vgic support for GIC v3
Quoted 15 lines · Vijay Kilari
Quoted 5 lines · Ian Campbell
Quoted 3 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Add vgic driver support for GIC v3 version.
Quoted 8 lines
There is an awful lot of code duplication with the v2 stuff here, especially with the distributor, but even the redistrubotr stuff looks like it could share common implementation with the v2 distro for at least some functionality.
I think we should investigate a sinlge driver here, or at least refactoring anything which is common into a library of helper functions which both can use.
Quoted 6 lines
Yes, only distributor code is common which is just 2 functions i.e read & write functions.
But the whole complexity is v2 gic & vgic driver is it runs with byte offset that is the reason
why ingic_v2_defsall the register addresses definitions are divided by 4. So this make it quite difficult to make common code.
It sounds trivial to make this work with appropriate accessor macros to me.
In fact I'm not sure why readl(&GICD[GICD_FOO]) won't work for you just as it does for v2 (e.g. type of GICD is uint32_t and GICD_FOO is /4).
Quoted 2 lines
With GICv2 HW constraint, I could not take it up. May be we can take this as separate task.
What do you mean?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
+ case
GICR_SETLPIR:I think you should either register two mmio handlers or maybe just handle this all at once in a single callback.
There is only one address rdistributore base and size extracted from dt.
So we register one handle for this entire region and this single callback will take access either GICR or SGI's GICR region.
Having a single region in DT doesn't stop you from doing the same calculation you do now in the callback at init time and registering two regions.
Quoted 4 lines
Quoted 2 lines
I didn't see any system register handling, I suppose that is all handled by the hardware GICV stuff?
For all system register accesses in Dom's, HW treats are virtual access.
The memory mapped GICD & GICR registers are virtualized by VGIC
I was looking for some register configuration which causes EL1 accesses to the system registers to go to the "GICV" equivalent, but I didn't see it. Can you point me to it please?
Ian.
Re: [PATCH v2 14/15] xen/arm: Add vgic support for GIC v3
Quoted 26 lines · Ian Campbell
Quoted 15 lines · Vijay Kilari
Quoted 5 lines · Ian Campbell
Quoted 3 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Add vgic driver support for GIC v3 version.
Quoted 8 lines
There is an awful lot of code duplication with the v2 stuff here, especially with the distributor, but even the redistrubotr stuff looks like it could share common implementation with the v2 distro for at least some functionality.
I think we should investigate a sinlge driver here, or at least refactoring anything which is common into a library of helper functions which both can use.
Quoted 6 lines
Yes, only distributor code is common which is just 2 functions i.e read & write functions.
But the whole complexity is v2 gic & vgic driver is it runs with byte offset that is the reason
why ingic_v2_defsall the register addresses definitions are divided by 4. So this make it quite difficult to make common code.It sounds trivial to make this work with appropriate accessor macros to me.
Quoted 8 lines
In fact I'm not sure why
readl(&GICD[GICD_FOO])won't work for you just as it does for v2 (e.g. type of GICD isuint32_tandGICD_FOOis /4).Quoted 2 lines
With GICv2 HW constraint, I could not take it up. May be we can take this as separate task.
What do you mean?
I mean, I don't have V2 hardware to test any trivial changes that I do to GIC v2. In all my patches, I am not making any changes to functionality of v2 except code movement and changing names
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
+ case
GICR_SETLPIR:I think you should either register two mmio handlers or maybe just handle this all at once in a single callback.
Quoted 8 lines
Quoted 3 lines
There is only one address rdistributore base and size extracted from dt.
So we register one handle for this entire region and this single callback will take access either GICR or SGI's GICR region.Having a single region in DT doesn't stop you from doing the same calculation you do now in the callback at init time and registering two regions.
SGI GICR region is per cpu, there is no single address with which we can register a callback. So we register one callback for entire re-distributor region and if it falls in that region we consider it re-distributor
access.
This callback will take re-distributor stride offset and finds offset.
Also, this reduces the additional check for sgi re-distributor region
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
I didn't see any system register handling, I suppose that is all handled by the hardware GICV stuff?
For all system register accesses in Dom's, HW treats are virtual access.
The memory mapped GICD & GICR registers are virtualized by VGICI was looking for some register configuration which causes EL1 accesses to the system registers to go to the "GICV" equivalent, but I didn't see it. Can you point me to it please?
You mean ICC_SRE_EL2 register. GICv3 by default enables SRE bit.
Quoted 3 lines
Ian.
Re: [PATCH v2 14/15] xen/arm: Add vgic support for GIC v3
Quoted 3 lines · Vijay Kilari
I mean, I don't have V2 hardware to test any trivial changes that I do to GIC v2. In all my patches, I am not making any changes to functionality of v2 except code movement and changing names
I can test it if necessary. Do you have access to fast models or anything similar?
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
+ case
GICR_SETLPIR:I think you should either register two mmio handlers or maybe just handle this all at once in a single callback.
Quoted 8 lines
Quoted 3 lines
There is only one address rdistributore base and size extracted from dt.
So we register one handle for this entire region and this single callback will take access either GICR or SGI's GICR region.Having a single region in DT doesn't stop you from doing the same calculation you do now in the callback at init time and registering two regions.
Quoted 5 lines
SGI GICR region is per cpu, there is no single address with which we can register a callback. So we register one callback for entire re-distributor region and if it falls in that region we consider it re-distributor
access.
Ah ok, that makes sense. Thanks.
Quoted 6 lines
This callback will take re-distributor stride offset and finds offset.
Also, this reduces the additional check for sgi re-distributor region
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
I didn't see any system register handling, I suppose that is all handled by the hardware GICV stuff?
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
For all system register accesses in Dom's, HW treats are virtual access.
The memory mapped GICD & GICR registers are virtualized by VGICI was looking for some register configuration which causes EL1 accesses to the system registers to go to the "GICV" equivalent, but I didn't see it. Can you point me to it please?
You mean
ICC_SRE_EL2register. GICv3 by default enables SRE bit.
Excellent, thanks.
Re: [PATCH v2 14/15] xen/arm: Add vgic support for GIC v3
Quoted 8 lines · Ian Campbell
Quoted 3 lines · Vijay Kilari
I mean, I don't have V2 hardware to test any trivial changes that I do to GIC v2. In all my patches, I am not making any changes to functionality of v2 except code movement and changing names
I can test it if necessary. Do you have access to fast models or anything similar?
Currently I don't have one. I can setup.
Is it ok if I investigate on this later separately?
Re: [PATCH v2 14/15] xen/arm: Add vgic support for GIC v3
Quoted 7 lines · Vijay Kilari
Quoted 6 lines · Ian Campbell
Quoted 3 lines · Vijay Kilari
I mean, I don't have V2 hardware to test any trivial changes that I do to GIC v2. In all my patches, I am not making any changes to functionality of v2 except code movement and changing names
Quoted 5 lines
Quoted 2 lines
I can test it if necessary. Do you have access to fast models or anything similar?
Currently I don't have one. I can setup.
Is it ok if I investigate on this later separately?
I'm afraid that I don't want to add duplicated code to be cleaned up later. If this stuff can be shared then it should be done from the start. (These things have a habit of not happening otherwise).
Ian.
Re: [PATCH v2 14/15] xen/arm: Add vgic support for GIC v3
Quoted 11 lines · Ian Campbell
Quoted 10 lines · Vijay Kilari
Quoted 8 lines · Ian Campbell
Quoted 3 lines · Vijay Kilari
I mean, I don't have V2 hardware to test any trivial changes that I do to GIC v2. In all my patches, I am not making any changes to functionality of v2 except code movement and changing names
I can test it if necessary. Do you have access to fast models or anything similar?
Quoted 7 lines
Quoted 2 lines
Currently I don't have one. I can setup.
Is it ok if I investigate on this later separately?I'm afraid that I don't want to add duplicated code to be cleaned up later. If this stuff can be shared then it should be done from the start. (These things have a habit of not happening otherwise).
Let me attempt and send a patch.
However I feel except vgic_distr_mmio_read & vgic_distr_mmio_write of gicv2 code,
we can move all other functions to either header file (new file vgic.h) or common code file (vgic.c)
which can be shared with gicv3.This is the simplest approach I think.
Also, in GICD, few register are changed between v2 & v3 ex: GICD_IROUTER
Quoted 2 lines
Ian.
PATCH v2 15/15 xen/arm: update GIC dt node with GIC v3 information
In reply to [email protected]From: Vijaya Kumar K <[email protected]>
Update GIC device tree node for DOM0 with GICv3
information.
--- xen/arch/arm/domain_build.c | 41 ++++++++++++++++++++++++++++++++++------- xen/arch/arm/gic-v2.c | 8 ++++++++ xen/arch/arm/gic-v3.c | 8 ++++++++ xen/arch/arm/gic.c | 5 +++++ xen/include/asm-arm/gic.h | 5 +++++ 5 files changed, 60 insertions(+), 7 deletions(-)
xen/arch/arm/domain_build.c +34 -7
@@ -532,6 +532,8 @@ static int make_gic_node(const struct domain *d, void *fdt,u32 len;__be32 *new_cells, *tmp;int res =0 ; +int hw_type =GIC_VERSION_V2 ; +u32 rd_stride =0 ;/* * Xen currently supports only a single GIC. Discard any secondary
@@ -545,6 +547,8 @@ static int make_gic_node(const struct domain *d, void *fdt,DPRINT ("Create gic node\n" ); + hw_type =gic_hw_version (); + compatible =dt_get_property (gic,"compatible" , &len);if ( !compatible ) {
@@ -552,6 +556,12 @@ static int make_gic_node(const struct domain *d, void *fdt,return -FDT_ERR_XEN (ENOENT ); } +if ( hw_type ==GIC_VERSION_V3 ) + { + res =dt_property_read_u32 (gic,"redistributor-stride" , &rd_stride); +if ( !res ) + rd_stride =0 ; + } res =fdt_begin_node (fdt,"interrupt-controller" );if ( res )return res;
@@ -576,14 +586,31 @@ static int make_gic_node(const struct domain *d, void *fdt,return -FDT_ERR_XEN (ENOMEM ); tmp = new_cells; -DPRINT (" Set Distributor Base 0x%" PRIpaddr"-0x%" PRIpaddr"\n" , - d->arch.vgic.info->dbase, d->arch.vgic.info->dbase +PAGE_SIZE -1 ); -dt_set_range (&tmp, node, d->arch.vgic.info->dbase,PAGE_SIZE ); - -DPRINT (" Set Cpu Base 0x%" PRIpaddr"-0x%" PRIpaddr"\n" , - d->arch.vgic.info->cbase, d->arch.vgic.info->cbase + (PAGE_SIZE *2 ) -1 ); -dt_set_range (&tmp, node, d->arch.vgic.info->cbase,PAGE_SIZE *2 ); +if ( hw_type ==GIC_VERSION_V3 ) + { + res =fdt_property_cell (fdt,"redistributor-stride" , rd_stride); +if ( res ) +return res; +DPRINT (" gicv3 rd stride 0x%x\n" , rd_stride); + +DPRINT (" Set Distributor Base 0x%" PRIpaddr"-0x%" PRIpaddr"\n" , + d->arch.vgic.info->dbase, d->arch.vgic.info->dbase + d->arch.vgic.info->dbase_size -1 ); +dt_set_range (&tmp, node, d->arch.vgic.info->dbase, d->arch.vgic.info->dbase_size); + +DPRINT (" Set Re-distributor Base 0x%" PRIpaddr"-0x%" PRIpaddr"\n" , + d->arch.vgic.info->rbase, d->arch.vgic.info->rbase + d->arch.vgic.info->rbase_size -1 ); +dt_set_range (&tmp, node, d->arch.vgic.info->rbase, d->arch.vgic.info->rbase_size); + } +else + { +DPRINT (" Set Distributor Base 0x%" PRIpaddr"-0x%" PRIpaddr"\n" , + d->arch.vgic.info->dbase, d->arch.vgic.info->dbase +PAGE_SIZE -1 ); +dt_set_range (&tmp, node, d->arch.vgic.info->dbase,PAGE_SIZE ); +DPRINT (" Set Cpu Base 0x%" PRIpaddr"-0x%" PRIpaddr"\n" , + d->arch.vgic.info->cbase, d->arch.vgic.info->cbase + (PAGE_SIZE *2 ) -1 ); +dt_set_range (&tmp, node, d->arch.vgic.info->cbase,PAGE_SIZE *2 ); + } res =fdt_property (fdt,"reg" , new_cells, len);xfree (new_cells);
xen/arch/arm/gic-v2.c +8 -0
@@ -43,6 +43,7 @@/* Global state */ static struct { + int hw_version; paddr_t dbase; /* Address of distributor registers */ paddr_t cbase; /* Address of CPU interface registers */ paddr_t hbase; /* Address of virtual interface registers */
@@ -351,6 +352,7 @@ int __init gicv2_init(struct dt_device_node *node, const void *data)gic_cpu_init ();gic_hyp_init (); + gic.hw_version =GIC_VERSION_V2 ;register_gic_ops (&gic_ops);return 0 ; }
@@ -361,6 +363,11 @@ static void gic_secondary_cpu_init(void)gic_hyp_init (); } +static int gic_hw_type (void ) +{ +return gic.hw_version; +} +static struct dt_irq *gic_maintenance_irq (void ) {return &gic.maintenance;
@@ -504,6 +511,7 @@ static unsigned int gic_read_vmcr_priority(void) }static struct gic_hw_operations gic_ops = { + .gic_type = gic_hw_type, .nr_lines = gic_nr_lines, .nr_lrs = gic_nr_lrs, .secondary_init = gic_secondary_cpu_init,
xen/arch/arm/gic-v3.c +8 -0
@@ -49,6 +49,7 @@ struct rdist_region {/* Global state */ static struct { + int hw_version; paddr_t dbase; /* Address of distributor registers */ paddr_t dbase_size; void __iomem *map_dbase; /* Mapped address of distributor registers */
@@ -766,6 +767,11 @@ int gicv_init(struct domain *d)return 0 ; } +static int gic_hw_type (void ) +{ +return gic.hw_version; +} +static struct dt_irq *gic_maintenance_irq (void ) {return &gic.maintenance;
@@ -786,6 +792,7 @@ static unsigned int gic_read_vmcr_priority(void) }static struct gic_hw_operations gic_ops = { + .gic_type = gic_hw_type, .nr_lines = gic_nr_lines, .nr_lrs = gic_nr_lrs, .get_maintenance_irq = gic_maintenance_irq,
@@ -893,6 +900,7 @@ static int __init gicv3_init(struct dt_device_node *node, const void *data)gic_cpu_init ();gic_hyp_init (); + gic.hw_version =GIC_VERSION_V3 ;/* Register hw ops*/ register_gic_ops (&gic_ops);return 0 ;
xen/arch/arm/gic.c +5 -0
@@ -58,6 +58,11 @@ void update_cpu_lr_mask(void)static void gic_clear_one_lr (struct vcpu *v,int i); +int gic_hw_version (void ) +{ +return gic_hw_ops->gic_type (); +} +unsigned int gic_number_lines (void ) {return gic_hw_ops->nr_lines ();
xen/include/asm-arm/gic.h +5 -0
@@ -51,6 +51,9 @@#define GICH_HCR_VGRP1EIE (1 << 6)#define GICH_HCR_VGRP1DIE (1 << 7) +#define GIC_VERSION_V3 0x3 +#define GIC_VERSION_V2 0x2 +#ifndef __ASSEMBLY__#include <xen/device_tree.h>
@@ -175,6 +178,7 @@ int gic_irq_xlate(const u32 *intspec, unsigned int intsize,void gic_clear_lrs (struct vcpu *v);struct gic_hw_operations { +int (*gic_type)(void );struct dt_irq * (*get_maintenance_irq)(void );unsigned int (*nr_lines)(void );unsigned int (*nr_lrs)(void );
@@ -211,6 +215,7 @@ struct vgic_ops {void register_vgic_ops (struct vgic_ops *ops);void register_gic_ops (struct gic_hw_operations *ops);extern void update_cpu_lr_mask (void ); +extern int gic_hw_version (void );#endif /* __ASSEMBLY__ */ #endif
Signature · 1 line
1.7.9.5
Re: [PATCH v2 15/15] xen/arm: update GIC dt node with GIC v3 information
Hello Vijaya,
Thank you for the patch.
The name of this patch is still wrong. Which GIC DT node are you updating?
xen/arch/arm/domain_build.c static int make_gic_node(const struct domain *d, void *fdt, · line 564
Quoted 6 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
xen/arch/arm/domain_build.c +6
-0+if ( hw_type ==GIC_VERSION_V3 ) + { + res =dt_property_read_u32 (gic,"redistributor-stride" , &rd_stride); +if ( !res ) + rd_stride =0 ; + }
You have skipped some of my remarks on V1. I would definitely prefer to have a callback in your {v,}GIC structure which add the specific GIC properties following the version supported by DOM0.
[..]
xen/arch/arm/gic-v2.c static unsigned int gic_read_vmcr_priority(void) · line 795
Quoted 8 lines
static struct
dt_irq*gic_maintenance_irq(void){ return &gic.maintenance;xen/arch/arm/gic-v2.c +1
-0@@ -786,6 +792,7 @@ static unsigned int gic_read_vmcr_priority(void) }static struct gic_hw_operations gic_ops = { + .gic_type = gic_hw_type,
This should go in patch #5. As I said on V1, you don't need a callback for return a fixed number (that you've initialized in gicv3_init). You can store a number in this structure.
At the same time what is the difference between this number and the one in GIC state?
Quoted 32 lines
xen/arch/arm/gic-v3.c +1
-0.nr_lines = gic_nr_lines, .nr_lrs = gic_nr_lrs, .get_maintenance_irq = gic_maintenance_irq,@@ -893,6 +900,7 @@ static int __init gicv3_init(struct dt_device_node *node, const void *data)gic_cpu_init ();gic_hyp_init (); + gic.hw_version =GIC_VERSION_V3 ;/* Register hw ops*/ register_gic_ops (&gic_ops);return 0 ;xen/arch/arm/gic.c +5
-0@@ -58,6 +58,11 @@ void update_cpu_lr_mask(void)static void gic_clear_one_lr (struct vcpu *v,int i); +int gic_hw_version (void ) +{ +return gic_hw_ops->gic_type (); +} +unsigned int gic_number_lines (void ) {return gic_hw_ops->nr_lines ();xen/include/asm-arm/gic.h +0
-0
xen/include/asm-arm/gic.h line 56
Quoted 6 lines
xen/include/asm-arm/gic.h +3
-0@@ -51,6 +51,9 @@#define GICH_HCR_VGRP1EIE (1 << 6)#define GICH_HCR_VGRP1DIE (1 << 7) +#define GIC_VERSION_V3 0x3 +#define GIC_VERSION_V2 0x2 +
Should not be defined earlier?
Signature · 1 line
Julien Grall
Re: [PATCH v2 15/15] xen/arm: update GIC dt node with GIC v3 information
Quoted 15 lines · Julien Grall
Hello Vijaya,
Thank you for the patch.
The name of this patch is still wrong. Which GIC DT node are you updating?
xen/arch/arm/domain_build.c static int make_gic_node(const struct domain *d, void *fdt, · line 564
Quoted 6 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
xen/arch/arm/domain_build.c +6
-0+if ( hw_type ==GIC_VERSION_V3 ) + { + res =dt_property_read_u32 (gic,"redistributor-stride" , &rd_stride); +if ( !res ) + rd_stride =0 ; + }
Quoted 4 lines
You have skipped some of my remarks on V1. I would definitely prefer to have a callback in your {v,}GIC structure which add the specific GIC properties following the version supported by DOM0.
Yes, I recognized your comment. My understanding is that while creating this gic node for
dom0, we should follow the order in creating cells.
Also, the cells are allocated here and these should be passed to gic driver to fill it.
So looks ugly.
I prefer completely move this code to gic.c and from gic.c based on registered callback, let gic-{v2/v3}.c manage version specific dt cells update. Is this OK?
+
Quoted 2 lines
--
Julien Grall
Re: [PATCH v2 15/15] xen/arm: update GIC dt node with GIC v3 information
Hello Vijaya,
Quoted 14 lines · Vijay Kilari
Quoted 9 lines · Julien Grall
xen/arch/arm/domain_build.c static int make_gic_node(const struct domain *d, void *fdt, · line 564
Quoted 6 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
xen/arch/arm/domain_build.c +6
-0+if ( hw_type ==GIC_VERSION_V3 ) + { + res =dt_property_read_u32 (gic,"redistributor-stride" , &rd_stride); +if ( !res ) + rd_stride =0 ; + }Quoted 4 lines
You have skipped some of my remarks on V1. I would definitely prefer to have a callback in your {v,}GIC structure which add the specific GIC properties following the version supported by DOM0.
Quoted 6 lines
Yes, I recognized your comment. My understanding is that while creating this gic node for
dom0, we should follow the order in creating cells.
Also, the cells are allocated here and these should be passed to gic driver to fill it.
So looks ugly.
I don't understand the issue with the order and the allocation...
You have bunch of code in if (hw_type == GICV3) than can be easily move to the GIC driver.
You could have something like:
fdt_set_property(fdt, "mycommonprop1",..)fdt_set_property(fdt, "mycommonprop2",..)gic_node_specific_properties();fdt_end();
Quoted 3 lines
I prefer completely move this code to
gic.cand fromgic.cbased on registered callback, letgic-{v2/v3}.cmanage version specific dt cells update. Is this OK?
What do you mean?
Regards,
Signature · 1 line
Julien Grall
Re: [PATCH v2 15/15] xen/arm: update GIC dt node with GIC v3 information
Quoted 17 lines · Julien Grall
Hello Vijaya,
Quoted 14 lines · Vijay Kilari
Quoted 13 lines · Julien Grall
xen/arch/arm/domain_build.c static int make_gic_node(const struct domain *d, void *fdt, · line 564
Quoted 6 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
xen/arch/arm/domain_build.c +6
-0+if ( hw_type ==GIC_VERSION_V3 ) + { + res =dt_property_read_u32 (gic,"redistributor-stride" , &rd_stride); +if ( !res ) + rd_stride =0 ; + }You have skipped some of my remarks on V1. I would definitely prefer to have a callback in your {v,}GIC structure which add the specific GIC properties following the version supported by DOM0.
Quoted 9 lines
Quoted 6 lines
Yes, I recognized your comment. My understanding is that while creating this gic node for
dom0, we should follow the order in creating cells.
Also, the cells are allocated here and these should be passed to gic driver to fill it.
So looks ugly.I don't understand the issue with the order and the allocation...
I mean if we change the order of calling fdt_set_property for
various properties, the node creation goes wrong. something like this
fdt_set_property(fdt, "mycommonprop2",..)
fdt_set_property(fdt, "mycommonprop1",..)
I have given a try and dom0 fails to boot.
Quoted 10 lines
You have bunch of code in if (
hw_type== GICV3) than can be easily move to the GIC driver.You could have something like:
fdt_set_property(fdt, "mycommonprop1",..)fdt_set_property(fdt, "mycommonprop2",..)gic_node_specific_properties();fdt_end();
Quoted 6 lines
Quoted 3 lines
I prefer completely move this code to
gic.cand fromgic.cbased on registered callback, letgic-{v2/v3}.cmanage version specific dt cells update. Is this OK?What do you mean?
I mean why can't we move, why can't we move complete make_gic_node
to gic.c? as below and let it handle hw specific things?
fdt_set_property(fdt, "mycommonprop1",..)fdt_set_property(fdt, "mycommonprop2",..)gic_node_specific_properties();fdt_end();
Anyways, I will relook and see if I can simplify as you suggested
Quoted 4 lines
Regards,
--
Julien Grall
Re: [PATCH v2 15/15] xen/arm: update GIC dt node with GIC v3 information
Quoted 27 lines · Vijay Kilari
Quoted 17 lines · Julien Grall
Hello Vijaya,
Quoted 14 lines · Vijay Kilari
Quoted 13 lines · Julien Grall
xen/arch/arm/domain_build.c static int make_gic_node(const struct domain *d, void *fdt, · line 564
Quoted 6 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
xen/arch/arm/domain_build.c +6
-0+if ( hw_type ==GIC_VERSION_V3 ) + { + res =dt_property_read_u32 (gic,"redistributor-stride" , &rd_stride); +if ( !res ) + rd_stride =0 ; + }You have skipped some of my remarks on V1. I would definitely prefer to have a callback in your {v,}GIC structure which add the specific GIC properties following the version supported by DOM0.
Quoted 9 lines
Quoted 6 lines
Yes, I recognized your comment. My understanding is that while creating this gic node for
dom0, we should follow the order in creating cells.
Also, the cells are allocated here and these should be passed to gic driver to fill it.
So looks ugly.I don't understand the issue with the order and the allocation...
Quoted 7 lines
I mean if we change the order of calling
fdt_set_propertyfor
various properties, the node creation goes wrong. something like this
fdt_set_property(fdt, "mycommonprop2",..)
fdt_set_property(fdt, "mycommonprop1",..)I have given a try and dom0 fails to boot.
Are you sure? DOM0 doesn't care about the order of the properties... it only care about the name and the content.
Quoted 9 lines
Quoted 2 lines
What do you mean?
I mean why can't we move, why can't we move complete
make_gic_node
togic.c? as below and let it handle hw specific things?
fdt_set_property(fdt, "mycommonprop1",..)fdt_set_property(fdt, "mycommonprop2",..)gic_node_specific_properties();fdt_end();
That's the solution I've asked on V1...
Signature · 1 line
Julien Grall
Re: [PATCH v2 15/15] xen/arm: update GIC dt node with GIC v3 information
In reply to [email protected]Quoted 4 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Update GIC device tree node for DOM0 with GICv3
information.
Perhaps this should just be a callback in the vigc ops struct?
Quoted 15 lines
Signed-off-by Vijaya Kumar K <[email protected]>--- xen/arch/arm/domain_build.c | 41 ++++++++++++++++++++++++++++++++++------- xen/arch/arm/gic-v2.c | 8 ++++++++ xen/arch/arm/gic-v3.c | 8 ++++++++ xen/arch/arm/gic.c | 5 +++++ xen/include/asm-arm/gic.h | 5 +++++ 5 files changed, 60 insertions(+), 7 deletions(-)xen/arch/arm/domain_build.c +0
-0
xen/arch/arm/domain_build.c static int make_gic_node(const struct domain *d, void *fdt, · line 535
Quoted 4 lines
xen/arch/arm/domain_build.c +1
-0@@ -532,6 +532,8 @@ static int make_gic_node(const struct domain *d, void *fdt,u32 len;__be32 *new_cells, *tmp;int res =0 ; +int hw_type =GIC_VERSION_V2 ;
an enum, perhaps?
Quoted 14 lines
xen/arch/arm/domain_build.c +3
-0+u32 rd_stride =0 ;/* * Xen currently supports only a single GIC. Discard any secondary @@ -545,6 +547,8 @@ static int make_gic_node(const struct domain *d, void *fdt,DPRINT ("Create gic node\n" ); + hw_type =gic_hw_version (); + compatible =dt_get_property (gic,"compatible" , &len);if ( !compatible ) {
xen/arch/arm/domain_build.c static int make_gic_node(const struct domain *d, void *fdt, · line 559
Quoted 4 lines
xen/arch/arm/domain_build.c +1
-0@@ -552,6 +556,12 @@ static int make_gic_node(const struct domain *d, void *fdt,return -FDT_ERR_XEN (ENOENT ); } +if ( hw_type ==GIC_VERSION_V3 )
switch over a hw_type enum? With an empty v2 case. Likewise elsewhere, Then the compiler will help us catch missing cases.
Quoted 21 lines
xen/arch/arm/domain_build.c +5
-0+ { + res =dt_property_read_u32 (gic,"redistributor-stride" , &rd_stride); +if ( !res ) + rd_stride =0 ; + } res =fdt_begin_node (fdt,"interrupt-controller" );if ( res )return res;xen/arch/arm/gic-v3.c +1
-0@@ -49,6 +49,7 @@ struct rdist_region {/* Global state */ static struct { + int hw_version; paddr_t dbase; /* Address of distributor registers */ paddr_t dbase_size; void __iomem *map_dbase; /* Mapped address of distributor registers */
xen/arch/arm/gic-v3.c int gicv_init(struct domain *d) · line 772
Quoted 6 lines
xen/arch/arm/gic-v3.c +3
-0@@ -766,6 +767,11 @@ int gicv_init(struct domain *d)return 0 ; } +static int gic_hw_type (void ) +{ +return gic.hw_version;
Wouldn't this just be hardcoded as v3?
Ian.
Hi Vijay
Quoted 7 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Made changes to existing gic and vgic drivers
to make it generic and added support for GIC v3
hw versionTested with ARM64 simulator with single core
What about multiple core? On V1 you said you were unable to use SMP with GICv3, did you find the issue?
BTW, do you have a git tree with these patch series? I'd like to give a try on GICv2 platform.
Regards,
Signature · 1 line
Julien Grall
Quoted 5 lines · Julien Grall
Hi Vijay
Quoted 2 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Quoted 9 lines
Quoted 5 lines
Made changes to existing gic and vgic drivers
to make it generic and added support for GIC v3
hw versionTested with ARM64 simulator with single core
What about multiple core? On V1 you said you were unable to use SMP with GICv3, did you find the issue?
There is no issue with hardware now. Xen can boot with multicore (2
cores) but dom0 single core.
limited using bootargs. I started working on Dom0 boot with multicore.
In GICv3, On SGI at EL1 (kernel), it traps to EL2. Xen does not handle this trap.
So need to implement it. I started working on it and also trying to understand EL1
SGI routing in vgic driver. BTW do you know how SGI is handled in
ARMv7 with GICv2?
I think vgic_to_sgi() in vgic driver is managing it.
Quoted 3 lines
BTW, do you have a git tree with these patch series? I'd like to give a try on GICv2 platform.
No, I don't have any public git tree to share the patches
Quoted 4 lines
Regards,
--
Julien Grall
Quoted 19 lines · Vijay Kilari
Quoted 5 lines · Julien Grall
Hi Vijay
Quoted 2 lines · On 04/04/2014 12:56 PM, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Quoted 9 lines
Quoted 5 lines
Made changes to existing gic and vgic drivers
to make it generic and added support for GIC v3
hw versionTested with ARM64 simulator with single core
What about multiple core? On V1 you said you were unable to use SMP with GICv3, did you find the issue?
There is no issue with hardware now. Xen can boot with multicore (2
cores) but dom0 single core.
limited using bootargs. I started working on Dom0 boot with multicore.
Quoted 7 lines
In GICv3, On SGI at EL1 (kernel), it traps to EL2. Xen does not handle this trap.
So need to implement it. I started working on it and also trying to understand EL1
SGI routing in vgic driver. BTW do you know how SGI is handled in
ARMv7 with GICv2?
I thinkvgic_to_sgi()in vgic driver is managing it.
Right, EL1 raises an SGI via the distributor.
Regards,
Signature · 1 line
Julien Grall
Quoted 5 lines · On Fri, 2014-04-04 at 17:26 +0530, [email protected] wrote:
From: Vijaya Kumar K <[email protected]>
Made changes to existing gic and vgic drivers
to make it generic and added support for GIC v3
hw version
Which Xen changeset is this based on? I tried to apply it to staging but there were some conflicts in gic.h. I just wanted to have a look at the final code to help me understand the trajectory of one of the patches...