[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [RFC PATCH 05/19] xen/arm: its: Remove unused code in ITS driver
From: Vijaya Kumar K <Vijaya.Kumar@xxxxxxxxxxxxxxxxxx> ITS driver does not require functionality to create/free device. This will be handled by virtual ITS driver. The functionality of ITS driver will be limited to initialization, sending ITS commands received from Virtual ITS driver and ITS interrupt handling. The following functionality is removed - Remove its_device structure usage - Removed used command structure definitions - Removed handling of unused ITS commands like MAPD, MAPVI, INT and DISCARD and INV Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@xxxxxxxxxxxxxxxxxx> --- xen/arch/arm/gic-v3-its.c | 254 ++------------------------------------------- 1 file changed, 8 insertions(+), 246 deletions(-) diff --git a/xen/arch/arm/gic-v3-its.c b/xen/arch/arm/gic-v3-its.c index 53850fe..2ec7866 100644 --- a/xen/arch/arm/gic-v3-its.c +++ b/xen/arch/arm/gic-v3-its.c @@ -83,29 +83,12 @@ struct its_node { struct its_cmd_block *cmd_write; void *tables[GITS_BASER_NR_REGS]; struct its_collection *collections; - struct list_head its_device_list; u64 flags; u32 ite_size; }; #define ITS_ITT_ALIGN SZ_256 -/* - * The ITS view of a device - belongs to an ITS, a collection, owns an - * interrupt translation table, and a list of interrupts. - */ -struct its_device { - struct list_head entry; - struct its_node *its; - struct its_collection *collection; - void *itt; - unsigned long *lpi_map; - int lpi_base; - int nr_lpis; - u32 nr_ites; - u32 device_id; -}; - static LIST_HEAD(its_nodes); static DEFINE_SPINLOCK(its_lock); static struct dt_device_node *gic_root_node; @@ -121,43 +104,17 @@ static struct rdist_prop *gic_rdists; struct its_cmd_desc { union { struct { - struct its_device *dev; - u32 event_id; - } its_inv_cmd; - - struct { - struct its_device *dev; - u32 event_id; - } its_int_cmd; - - struct { - struct its_device *dev; - int valid; - } its_mapd_cmd; - - struct { struct its_collection *col; int valid; } its_mapc_cmd; struct { - struct its_device *dev; - u32 phys_id; - u32 event_id; - } its_mapvi_cmd; - - struct { - struct its_device *dev; struct its_collection *col; u32 id; + u32 dev_id; } its_movi_cmd; struct { - struct its_device *dev; - u32 event_id; - } its_discard_cmd; - - struct { struct its_collection *col; } its_invall_cmd; }; @@ -169,26 +126,6 @@ struct its_cmd_desc { typedef struct its_collection *(*its_cmd_builder_t)(struct its_cmd_block *, struct its_cmd_desc *); -static struct its_collection *its_build_mapd_cmd(struct its_cmd_block *cmd, - struct its_cmd_desc *desc) -{ - unsigned long itt_addr; - u8 size = max(fls(desc->its_mapd_cmd.dev->nr_ites) - 1, 1); - - itt_addr = __pa(desc->its_mapd_cmd.dev->itt); - itt_addr = ((itt_addr) + (ITS_ITT_ALIGN - 1)) & ~(ITS_ITT_ALIGN - 1); - - its_encode_cmd(cmd, GITS_CMD_MAPD); - its_encode_devid(cmd, desc->its_mapd_cmd.dev->device_id); - its_encode_size(cmd, size - 1); - its_encode_itt(cmd, itt_addr); - its_encode_valid(cmd, desc->its_mapd_cmd.valid); - - its_fixup_cmd(cmd); - - return desc->its_mapd_cmd.dev->collection; -} - static struct its_collection *its_build_mapc_cmd(struct its_cmd_block *cmd, struct its_cmd_desc *desc) { @@ -202,55 +139,17 @@ static struct its_collection *its_build_mapc_cmd(struct its_cmd_block *cmd, return desc->its_mapc_cmd.col; } -static struct its_collection *its_build_mapvi_cmd(struct its_cmd_block *cmd, - struct its_cmd_desc *desc) -{ - its_encode_cmd(cmd, GITS_CMD_MAPVI); - its_encode_devid(cmd, desc->its_mapvi_cmd.dev->device_id); - its_encode_event_id(cmd, desc->its_mapvi_cmd.event_id); - its_encode_phys_id(cmd, desc->its_mapvi_cmd.phys_id); - its_encode_collection(cmd, desc->its_mapvi_cmd.dev->collection->col_id); - - its_fixup_cmd(cmd); - - return desc->its_mapvi_cmd.dev->collection; -} - static struct its_collection *its_build_movi_cmd(struct its_cmd_block *cmd, struct its_cmd_desc *desc) { its_encode_cmd(cmd, GITS_CMD_MOVI); - its_encode_devid(cmd, desc->its_movi_cmd.dev->device_id); + its_encode_devid(cmd, desc->its_movi_cmd.dev_id); its_encode_event_id(cmd, desc->its_movi_cmd.id); its_encode_collection(cmd, desc->its_movi_cmd.col->col_id); its_fixup_cmd(cmd); - return desc->its_movi_cmd.dev->collection; -} - -static struct its_collection *its_build_discard_cmd(struct its_cmd_block *cmd, - struct its_cmd_desc *desc) -{ - its_encode_cmd(cmd, GITS_CMD_DISCARD); - its_encode_devid(cmd, desc->its_discard_cmd.dev->device_id); - its_encode_event_id(cmd, desc->its_discard_cmd.event_id); - - its_fixup_cmd(cmd); - - return desc->its_discard_cmd.dev->collection; -} - -static struct its_collection *its_build_inv_cmd(struct its_cmd_block *cmd, - struct its_cmd_desc *desc) -{ - its_encode_cmd(cmd, GITS_CMD_INV); - its_encode_devid(cmd, desc->its_inv_cmd.dev->device_id); - its_encode_event_id(cmd, desc->its_inv_cmd.event_id); - - its_fixup_cmd(cmd); - - return desc->its_inv_cmd.dev->collection; + return desc->its_movi_cmd.col; } static struct its_collection *its_build_invall_cmd(struct its_cmd_block *cmd, @@ -401,26 +300,6 @@ post: its_wait_for_range_completion(its, cmd, next_cmd); } -void its_send_inv(struct its_device *dev, u32 event_id) -{ - struct its_cmd_desc desc; - - desc.its_inv_cmd.dev = dev; - desc.its_inv_cmd.event_id = event_id; - - its_send_single_command(dev->its, its_build_inv_cmd, &desc); -} - -static void its_send_mapd(struct its_device *dev, int valid) -{ - struct its_cmd_desc desc; - - desc.its_mapd_cmd.dev = dev; - desc.its_mapd_cmd.valid = !!valid; - - its_send_single_command(dev->its, its_build_mapd_cmd, &desc); -} - static void its_send_mapc(struct its_node *its, struct its_collection *col, int valid) { @@ -432,37 +311,16 @@ static void its_send_mapc(struct its_node *its, struct its_collection *col, its_send_single_command(its, its_build_mapc_cmd, &desc); } -static void its_send_mapvi(struct its_device *dev, u32 irq_id, u32 id) +void its_send_movi(struct its_node *its, struct its_collection *col, + u32 dev_id, u32 id) { struct its_cmd_desc desc; - desc.its_mapvi_cmd.dev = dev; - desc.its_mapvi_cmd.phys_id = irq_id; - desc.its_mapvi_cmd.event_id = id; - - its_send_single_command(dev->its, its_build_mapvi_cmd, &desc); -} - -void its_send_movi(struct its_device *dev, - struct its_collection *col, u32 id) -{ - struct its_cmd_desc desc; - - desc.its_movi_cmd.dev = dev; + desc.its_movi_cmd.dev_id = dev_id; desc.its_movi_cmd.col = col; desc.its_movi_cmd.id = id; - its_send_single_command(dev->its, its_build_movi_cmd, &desc); -} - -void its_send_discard(struct its_device *dev, u32 id) -{ - struct its_cmd_desc desc; - - desc.its_discard_cmd.dev = dev; - desc.its_discard_cmd.event_id = id; - - its_send_single_command(dev->its, its_build_discard_cmd, &desc); + its_send_single_command(its, its_build_movi_cmd, &desc); } static void its_send_invall(struct its_node *its, struct its_collection *col) @@ -515,7 +373,7 @@ static int its_lpi_init(u32 id_bits) return 0; } -static unsigned long *its_lpi_alloc_chunks(int nr_irq, int *base, int *nr_ids) +unsigned long *its_lpi_alloc_chunks(int nr_irq, int *base, int *nr_ids) { unsigned long *bitmap = NULL; int chunk_id; @@ -864,101 +722,6 @@ static void its_cpu_init_collection(void) spin_unlock(&its_lock); } -struct its_device *its_find_device(struct its_node *its, u32 dev_id) -{ - struct its_device *its_dev = NULL, *tmp; - - spin_lock(&its->lock); - - list_for_each_entry(tmp, &its->its_device_list, entry) { - if (tmp->device_id == dev_id) { - its_dev = tmp; - break; - } - } - - spin_unlock(&its->lock); - - return its_dev; -} - -/* TODO: Removed static for compilation */ -struct its_device *its_create_device(struct its_node *its, u32 dev_id, - int nvecs) -{ - struct its_device *dev; - unsigned long *lpi_map; - void *itt; - int lpi_base; - int nr_lpis; - int cpu; - int sz; - - dev = xzalloc(struct its_device); - sz = nvecs * its->ite_size; - sz = max(sz, ITS_ITT_ALIGN) + ITS_ITT_ALIGN - 1; - itt = xzalloc_bytes(sz); - lpi_map = its_lpi_alloc_chunks(nvecs, &lpi_base, &nr_lpis); - - if (!dev || !itt || !lpi_map) { - xfree(dev); - xfree(itt); - xfree(lpi_map); - return NULL; - } - - dev->its = its; - dev->itt = itt; - dev->nr_ites = nvecs; - dev->lpi_map = lpi_map; - dev->lpi_base = lpi_base; - dev->nr_lpis = nr_lpis; - dev->device_id = dev_id; - INIT_LIST_HEAD(&dev->entry); - - spin_lock(&its->lock); - list_add(&dev->entry, &its->its_device_list); - spin_unlock(&its->lock); - - /* Bind the device to the first possible CPU */ - cpu = cpumask_first(&cpu_online_map); - dev->collection = &its->collections[cpu]; - - /* Map device to its ITT */ - its_send_mapd(dev, 1); - - return dev; -} - -void its_free_device(struct its_device *its_dev) -{ - spin_lock(&its_dev->its->lock); - list_del(&its_dev->entry); - spin_unlock(&its_dev->its->lock); - xfree(its_dev->itt); - xfree(its_dev); -} - -/* TODO: Removed static for compilation */ -int its_alloc_device_irq(struct its_device *dev, u32 id, - int *hwirq, unsigned int *irq) -{ - int idx; - - idx = find_first_zero_bit(dev->lpi_map, dev->nr_lpis); - if (idx == dev->nr_lpis) - return -ENOSPC; - - *hwirq = dev->lpi_base + idx; - - set_bit(idx, dev->lpi_map); - - /* Map the GIC irq ID to the device */ - its_send_mapvi(dev, *hwirq, id); - - return 0; -} - static int its_probe(struct dt_device_node *node) { paddr_t its_addr, its_size; @@ -999,7 +762,6 @@ static int its_probe(struct dt_device_node *node) spin_lock_init(&its->lock); INIT_LIST_HEAD(&its->entry); - INIT_LIST_HEAD(&its->its_device_list); its->base = its_base; its->phys_base = its_addr; its->ite_size = ((readl_relaxed(its_base + GITS_TYPER) >> 4) & 0xf) + 1; -- 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 |