^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Support for virtual IRQ subgroups.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2010 Paul Mundt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * This file is subject to the terms and conditions of the GNU General Public
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * License. See the file "COPYING" in the main directory of this archive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define pr_fmt(fmt) "intc: " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/radix-tree.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include "internals.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) static struct intc_map_entry intc_irq_xlate[INTC_NR_IRQS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) struct intc_virq_list {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) unsigned int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct intc_virq_list *next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define for_each_virq(entry, head) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) for (entry = head; entry; entry = entry->next)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * Tags for the radix tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define INTC_TAG_VIRQ_NEEDS_ALLOC 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) void intc_irq_xlate_set(unsigned int irq, intc_enum id, struct intc_desc_int *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) raw_spin_lock_irqsave(&intc_big_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) intc_irq_xlate[irq].enum_id = id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) intc_irq_xlate[irq].desc = d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) raw_spin_unlock_irqrestore(&intc_big_lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct intc_map_entry *intc_irq_xlate_get(unsigned int irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) return intc_irq_xlate + irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) int intc_irq_lookup(const char *chipname, intc_enum enum_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct intc_map_entry *ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct intc_desc_int *d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) int irq = -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) list_for_each_entry(d, &intc_list, list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) int tagged;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) if (strcmp(d->chip.name, chipname) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * Catch early lookups for subgroup VIRQs that have not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * yet been allocated an IRQ. This already includes a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * fast-path out if the tree is untagged, so there is no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) * need to explicitly test the root tree.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) tagged = radix_tree_tag_get(&d->tree, enum_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) INTC_TAG_VIRQ_NEEDS_ALLOC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) if (unlikely(tagged))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) ptr = radix_tree_lookup(&d->tree, enum_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) if (ptr) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) irq = ptr - intc_irq_xlate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) return irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) EXPORT_SYMBOL_GPL(intc_irq_lookup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) static int add_virq_to_pirq(unsigned int irq, unsigned int virq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct intc_virq_list *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) struct intc_virq_list **last = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) /* scan for duplicates */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) for_each_virq(entry, irq_get_handler_data(irq)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) if (entry->irq == virq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) last = &entry->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) entry = kzalloc(sizeof(struct intc_virq_list), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) if (!entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) entry->irq = virq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) if (last)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) *last = entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) irq_set_handler_data(irq, entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) static void intc_virq_handler(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) unsigned int irq = irq_desc_get_irq(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct irq_data *data = irq_desc_get_irq_data(desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct irq_chip *chip = irq_data_get_irq_chip(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) struct intc_virq_list *entry, *vlist = irq_data_get_irq_handler_data(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) struct intc_desc_int *d = get_intc_desc(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) chip->irq_mask_ack(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) for_each_virq(entry, vlist) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) unsigned long addr, handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) struct irq_desc *vdesc = irq_to_desc(entry->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) if (vdesc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) handle = (unsigned long)irq_desc_get_handler_data(vdesc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) addr = INTC_REG(d, _INTC_ADDR_E(handle), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) if (intc_reg_fns[_INTC_FN(handle)](addr, handle, 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) generic_handle_irq_desc(vdesc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) chip->irq_unmask(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) static unsigned long __init intc_subgroup_data(struct intc_subgroup *subgroup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) struct intc_desc_int *d,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) unsigned int index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) unsigned int fn = REG_FN_TEST_BASE + (subgroup->reg_width >> 3) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) return _INTC_MK(fn, MODE_ENABLE_REG, intc_get_reg(d, subgroup->reg),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 0, 1, (subgroup->reg_width - 1) - index);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static void __init intc_subgroup_init_one(struct intc_desc *desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) struct intc_desc_int *d,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) struct intc_subgroup *subgroup)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) struct intc_map_entry *mapped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) unsigned int pirq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) mapped = radix_tree_lookup(&d->tree, subgroup->parent_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) if (!mapped) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) WARN_ON(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) pirq = mapped - intc_irq_xlate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) raw_spin_lock_irqsave(&d->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) for (i = 0; i < ARRAY_SIZE(subgroup->enum_ids); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) struct intc_subgroup_entry *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) if (!subgroup->enum_ids[i])
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) entry = kmalloc(sizeof(*entry), GFP_NOWAIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) if (!entry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) entry->pirq = pirq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) entry->enum_id = subgroup->enum_ids[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) entry->handle = intc_subgroup_data(subgroup, d, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) err = radix_tree_insert(&d->tree, entry->enum_id, entry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) if (unlikely(err < 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) radix_tree_tag_set(&d->tree, entry->enum_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) INTC_TAG_VIRQ_NEEDS_ALLOC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) raw_spin_unlock_irqrestore(&d->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) void __init intc_subgroup_init(struct intc_desc *desc, struct intc_desc_int *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) if (!desc->hw.subgroups)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) for (i = 0; i < desc->hw.nr_subgroups; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) intc_subgroup_init_one(desc, d, desc->hw.subgroups + i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) static void __init intc_subgroup_map(struct intc_desc_int *d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) struct intc_subgroup_entry *entries[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) unsigned int nr_found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) raw_spin_lock_irqsave(&d->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) restart:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) nr_found = radix_tree_gang_lookup_tag_slot(&d->tree,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) (void ***)entries, 0, ARRAY_SIZE(entries),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) INTC_TAG_VIRQ_NEEDS_ALLOC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) for (i = 0; i < nr_found; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) struct intc_subgroup_entry *entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) int irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) entry = radix_tree_deref_slot((void **)entries[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) if (unlikely(!entry))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) if (radix_tree_deref_retry(entry))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) goto restart;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) irq = irq_alloc_desc(numa_node_id());
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) if (unlikely(irq < 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) pr_err("no more free IRQs, bailing..\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) activate_irq(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) pr_info("Setting up a chained VIRQ from %d -> %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) irq, entry->pirq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) intc_irq_xlate_set(irq, entry->enum_id, d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) irq_set_chip_and_handler_name(irq, irq_get_chip(entry->pirq),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) handle_simple_irq, "virq");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) irq_set_chip_data(irq, irq_get_chip_data(entry->pirq));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) irq_set_handler_data(irq, (void *)entry->handle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) * Set the virtual IRQ as non-threadable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) irq_set_nothread(irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) /* Set handler data before installing the handler */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) add_virq_to_pirq(entry->pirq, irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) irq_set_chained_handler(entry->pirq, intc_virq_handler);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) radix_tree_tag_clear(&d->tree, entry->enum_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) INTC_TAG_VIRQ_NEEDS_ALLOC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) radix_tree_replace_slot(&d->tree, (void **)entries[i],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) &intc_irq_xlate[irq]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) raw_spin_unlock_irqrestore(&d->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) void __init intc_finalize(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) struct intc_desc_int *d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) list_for_each_entry(d, &intc_list, list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) if (radix_tree_tagged(&d->tree, INTC_TAG_VIRQ_NEEDS_ALLOC))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) intc_subgroup_map(d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) }