[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC PATCH v3 06/18] xen/arm: ITS: Add helper functions to manage its_devices
From: Vijaya Kumar K <Vijaya.Kumar@xxxxxxxxxxxxxxxxxx> Helper functions to mange its devices using RB-tree are introduced in physical ITS driver. This is global list of all the devices. Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@xxxxxxxxxxxxxxxxxx> --- xen/arch/arm/gic-v3-its.c | 49 +++++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/gic-its.h | 3 +++ 2 files changed, 52 insertions(+) diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c index b1a97c1..349d0bb 100644 --- a/xen/arch/arm/gic-v3-its.c +++ b/xen/arch/arm/gic-v3-its.c @@ -92,6 +92,7 @@ struct its_node { static LIST_HEAD(its_nodes); static DEFINE_SPINLOCK(its_lock); static struct rdist_prop *gic_rdists; +static struct rb_root rb_its_dev; #define gic_data_rdist() (per_cpu(rdist, smp_processor_id())) #define gic_data_rdist_rd_base() (per_cpu(rdist, smp_processor_id()).rbase) @@ -145,6 +146,53 @@ void dump_cmd(its_cmd_block *cmd) } #endif +/* RB-tree helpers for its_device */ +struct its_device * find_its_device(struct rb_root *root, u32 devid) +{ + struct rb_node *node = root->rb_node; + + while ( node ) + { + struct its_device *dev; + + dev = container_of(node, struct its_device, node); + if ( devid < dev->device_id ) + node = node->rb_left; + else if ( devid > dev->device_id ) + node = node->rb_right; + else + return dev; + } + + return NULL; +} + +int insert_its_device(struct rb_root *root, struct its_device *dev) +{ + struct rb_node **new, *parent; + + new = &root->rb_node; + parent = NULL; + while ( *new ) + { + struct its_device *this; + + this = container_of(*new, struct its_device, node); + parent = *new; + if ( dev->device_id < this->device_id ) + new = &((*new)->rb_left); + else if ( dev->device_id > this->device_id ) + new = &((*new)->rb_right); + else + return -EEXIST; + } + + rb_link_node(&dev->node, parent, new); + rb_insert_color(&dev->node, root); + + return 0; +} + #define ITS_CMD_QUEUE_SZ SZ_64K #define ITS_CMD_QUEUE_NR_ENTRIES (ITS_CMD_QUEUE_SZ / sizeof(its_cmd_block)) @@ -994,6 +1042,7 @@ static int its_probe(struct dt_device_node *node) list_add(&its->entry, &its_nodes); spin_unlock(&its_lock); + rb_its_dev = RB_ROOT; return 0; out_free_tables: diff --git a/xen/include/asm-arm/gic-its.h b/xen/include/asm-arm/gic-its.h index 4e42f7f..59a6490 100644 --- a/xen/include/asm-arm/gic-its.h +++ b/xen/include/asm-arm/gic-its.h @@ -19,6 +19,7 @@ #define __ASM_ARM_GIC_ITS_H__ #include <asm/gic_v3_defs.h> +#include <xen/rbtree.h> /* * Collection structure - just an ID, and a redistributor address to @@ -195,6 +196,8 @@ struct its_device { u32 nr_ites; /* Physical Device id */ u32 device_id; + /* RB-tree entry */ + struct rb_node node; }; static inline uint8_t its_decode_cmd(its_cmd_block *cmd) -- 1.7.9.5 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |