Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

genirq: remove sparse irq code

This code is not ready, but we need to rip it out instead of rebasing
as we would lose the APIC/IO_APIC unification otherwise.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

authored by

Thomas Gleixner and committed by
Ingo Molnar
2cc21ef8 c6b7674f

+11 -439
+4 -126
arch/x86/kernel/io_apic.c
··· 111 111 struct irq_pin_list; 112 112 struct irq_cfg { 113 113 unsigned int irq; 114 - #ifdef CONFIG_HAVE_SPARSE_IRQ 115 - struct irq_cfg *next; 116 - #endif 117 114 struct irq_pin_list *irq_2_pin; 118 115 cpumask_t domain; 119 116 cpumask_t old_domain; ··· 148 151 149 152 static struct irq_cfg *irq_cfgx; 150 153 151 - #ifdef CONFIG_HAVE_SPARSE_IRQ 152 - /* 153 - * Protect the irq_cfgx_free freelist: 154 - */ 155 - static DEFINE_SPINLOCK(irq_cfg_lock); 156 - 157 - static struct irq_cfg *irq_cfgx_free; 158 - #endif 159 - 160 154 static void __init init_work(void *data) 161 155 { 162 156 struct dyn_array *da = data; ··· 162 174 legacy_count = ARRAY_SIZE(irq_cfg_legacy); 163 175 for (i = legacy_count; i < *da->nr; i++) 164 176 init_one_irq_cfg(&cfg[i]); 165 - 166 - #ifdef CONFIG_HAVE_SPARSE_IRQ 167 - for (i = 1; i < *da->nr; i++) 168 - cfg[i-1].next = &cfg[i]; 169 - 170 - irq_cfgx_free = &irq_cfgx[legacy_count]; 171 - irq_cfgx[legacy_count - 1].next = NULL; 172 - #endif 173 177 } 174 - 175 - #ifdef CONFIG_HAVE_SPARSE_IRQ 176 - /* need to be biger than size of irq_cfg_legacy */ 177 - static int nr_irq_cfg = 32; 178 - 179 - static int __init parse_nr_irq_cfg(char *arg) 180 - { 181 - if (arg) { 182 - nr_irq_cfg = simple_strtoul(arg, NULL, 0); 183 - if (nr_irq_cfg < 32) 184 - nr_irq_cfg = 32; 185 - } 186 - return 0; 187 - } 188 - 189 - early_param("nr_irq_cfg", parse_nr_irq_cfg); 190 - 191 - #define for_each_irq_cfg(irqX, cfg) \ 192 - for (cfg = irq_cfgx, irqX = cfg->irq; cfg; cfg = cfg->next, irqX = cfg ? cfg->irq : -1U) 193 - 194 - 195 - DEFINE_DYN_ARRAY(irq_cfgx, sizeof(struct irq_cfg), nr_irq_cfg, PAGE_SIZE, init_work); 196 - 197 - static struct irq_cfg *irq_cfg(unsigned int irq) 198 - { 199 - struct irq_cfg *cfg; 200 - 201 - cfg = irq_cfgx; 202 - while (cfg) { 203 - if (cfg->irq == irq) 204 - return cfg; 205 - 206 - cfg = cfg->next; 207 - } 208 - 209 - return NULL; 210 - } 211 - 212 - static struct irq_cfg *irq_cfg_alloc(unsigned int irq) 213 - { 214 - struct irq_cfg *cfg, *cfg_pri; 215 - unsigned long flags; 216 - int count = 0; 217 - int i; 218 - 219 - cfg_pri = cfg = irq_cfgx; 220 - while (cfg) { 221 - if (cfg->irq == irq) 222 - return cfg; 223 - 224 - cfg_pri = cfg; 225 - cfg = cfg->next; 226 - count++; 227 - } 228 - 229 - spin_lock_irqsave(&irq_cfg_lock, flags); 230 - if (!irq_cfgx_free) { 231 - unsigned long phys; 232 - unsigned long total_bytes; 233 - /* 234 - * we run out of pre-allocate ones, allocate more 235 - */ 236 - printk(KERN_DEBUG "try to get more irq_cfg %d\n", nr_irq_cfg); 237 - 238 - total_bytes = sizeof(struct irq_cfg) * nr_irq_cfg; 239 - if (after_bootmem) 240 - cfg = kzalloc(total_bytes, GFP_ATOMIC); 241 - else 242 - cfg = __alloc_bootmem_nopanic(total_bytes, PAGE_SIZE, 0); 243 - 244 - if (!cfg) 245 - panic("please boot with nr_irq_cfg= %d\n", count * 2); 246 - 247 - phys = __pa(cfg); 248 - printk(KERN_DEBUG "irq_cfg ==> [%#lx - %#lx]\n", phys, phys + total_bytes); 249 - 250 - for (i = 0; i < nr_irq_cfg; i++) 251 - init_one_irq_cfg(&cfg[i]); 252 - 253 - for (i = 1; i < nr_irq_cfg; i++) 254 - cfg[i-1].next = &cfg[i]; 255 - 256 - irq_cfgx_free = cfg; 257 - } 258 - 259 - cfg = irq_cfgx_free; 260 - irq_cfgx_free = irq_cfgx_free->next; 261 - cfg->next = NULL; 262 - if (cfg_pri) 263 - cfg_pri->next = cfg; 264 - else 265 - irq_cfgx = cfg; 266 - cfg->irq = irq; 267 - 268 - spin_unlock_irqrestore(&irq_cfg_lock, flags); 269 - 270 - return cfg; 271 - } 272 - #else 273 178 274 179 #define for_each_irq_cfg(irq, cfg) \ 275 180 for (irq = 0, cfg = &irq_cfgx[irq]; irq < nr_irqs; irq++, cfg = &irq_cfgx[irq]) ··· 171 290 172 291 struct irq_cfg *irq_cfg(unsigned int irq) 173 292 { 174 - if (irq < nr_irqs) 175 - return &irq_cfgx[irq]; 293 + if (irq < nr_irqs) 294 + return &irq_cfgx[irq]; 176 295 177 - return NULL; 296 + return NULL; 178 297 } 179 298 struct irq_cfg *irq_cfg_alloc(unsigned int irq) 180 299 { 181 - return irq_cfg(irq); 300 + return irq_cfg(irq); 182 301 } 183 302 184 - #endif 185 303 /* 186 304 * This is performance-critical, we want to do it O(1) 187 305 * ··· 2948 3068 unsigned long flags; 2949 3069 struct irq_cfg *cfg_new; 2950 3070 2951 - #ifndef CONFIG_HAVE_SPARSE_IRQ 2952 3071 irq_want = nr_irqs - 1; 2953 - #endif 2954 3072 2955 3073 irq = 0; 2956 3074 spin_lock_irqsave(&vector_lock, flags);
-8
arch/x86/kernel/irq_32.c
··· 272 272 struct irq_desc *desc = NULL; 273 273 int tail = 0; 274 274 275 - #ifdef CONFIG_HAVE_SPARSE_IRQ 276 - desc = (struct irq_desc *)v; 277 - entries = -1U; 278 - i = desc->irq; 279 - if (!desc->next) 280 - tail = 1; 281 - #else 282 275 entries = nr_irqs - 1; 283 276 i = *(loff_t *) v; 284 277 if (i == nr_irqs) 285 278 tail = 1; 286 279 else 287 280 desc = irq_to_desc(i); 288 - #endif 289 281 290 282 if (i == 0) { 291 283 seq_printf(p, " ");
-8
arch/x86/kernel/irq_64.c
··· 77 77 struct irq_desc *desc = NULL; 78 78 int tail = 0; 79 79 80 - #ifdef CONFIG_HAVE_SPARSE_IRQ 81 - desc = (struct irq_desc *)v; 82 - entries = -1U; 83 - i = desc->irq; 84 - if (!desc->next) 85 - tail = 1; 86 - #else 87 80 entries = nr_irqs - 1; 88 81 i = *(loff_t *) v; 89 82 if (i == nr_irqs) 90 83 tail = 1; 91 84 else 92 85 desc = irq_to_desc(i); 93 - #endif 94 86 95 87 if (i == 0) { 96 88 seq_printf(p, " ");
-31
drivers/char/random.c
··· 558 558 unsigned dont_count_entropy:1; 559 559 }; 560 560 561 - #ifndef CONFIG_HAVE_SPARSE_IRQ 562 - 563 561 #ifdef CONFIG_HAVE_DYN_ARRAY 564 562 static struct timer_rand_state **irq_timer_state; 565 563 DEFINE_DYN_ARRAY(irq_timer_state, sizeof(struct timer_rand_state *), nr_irqs, PAGE_SIZE, NULL); ··· 580 582 581 583 irq_timer_state[irq] = state; 582 584 } 583 - 584 - #else 585 - 586 - static struct timer_rand_state *get_timer_rand_state(unsigned int irq) 587 - { 588 - struct irq_desc *desc; 589 - 590 - desc = irq_to_desc(irq); 591 - 592 - if (!desc) 593 - return NULL; 594 - 595 - return desc->timer_rand_state; 596 - } 597 - 598 - static void set_timer_rand_state(unsigned int irq, struct timer_rand_state *state) 599 - { 600 - struct irq_desc *desc; 601 - 602 - desc = irq_to_desc(irq); 603 - 604 - if (!desc) 605 - return; 606 - 607 - desc->timer_rand_state = state; 608 - } 609 - #endif 610 585 611 586 static struct timer_rand_state input_timer_state; 612 587 ··· 938 967 { 939 968 struct timer_rand_state *state; 940 969 941 - #ifndef CONFIG_HAVE_SPARSE_IRQ 942 970 if (irq >= nr_irqs) 943 971 return; 944 - #endif 945 972 946 973 state = get_timer_rand_state(irq); 947 974
+1 -18
drivers/pci/htirq.c
··· 82 82 write_ht_irq_msg(irq, &msg); 83 83 } 84 84 85 - static unsigned int build_irq_for_pci_dev(struct pci_dev *dev) 86 - { 87 - unsigned int irq; 88 - 89 - irq = dev->bus->number; 90 - irq <<= 8; 91 - irq |= dev->devfn; 92 - irq <<= 12; 93 - 94 - return irq; 95 - } 96 - 97 85 /** 98 86 * __ht_create_irq - create an irq and attach it to a device. 99 87 * @dev: The hypertransport device to find the irq capability on. ··· 98 110 int max_irq; 99 111 int pos; 100 112 int irq; 101 - unsigned int irq_want; 102 113 103 114 pos = pci_find_ht_capability(dev, HT_CAPTYPE_IRQ); 104 115 if (!pos) ··· 125 138 cfg->msg.address_lo = 0xffffffff; 126 139 cfg->msg.address_hi = 0xffffffff; 127 140 128 - irq_want= build_irq_for_pci_dev(dev); 129 - #ifdef CONFIG_HAVE_SPARSE_IRQ 130 - irq = create_irq_nr(irq_want + idx); 131 - #else 132 141 irq = create_irq(); 133 - #endif 142 + 134 143 if (irq <= 0) { 135 144 kfree(cfg); 136 145 return -EBUSY;
-75
drivers/pci/intr_remapping.c
··· 19 19 u8 irte_mask; 20 20 }; 21 21 22 - #ifdef CONFIG_HAVE_SPARSE_IRQ 23 - static struct irq_2_iommu *irq_2_iommuX; 24 - /* fill one page ? */ 25 - static int nr_irq_2_iommu = 0x100; 26 - static int irq_2_iommu_index; 27 - DEFINE_DYN_ARRAY(irq_2_iommuX, sizeof(struct irq_2_iommu), nr_irq_2_iommu, PAGE_SIZE, NULL); 28 - 29 - extern void *__alloc_bootmem_nopanic(unsigned long size, 30 - unsigned long align, 31 - unsigned long goal); 32 - 33 - static struct irq_2_iommu *get_one_free_irq_2_iommu(int not_used) 34 - { 35 - struct irq_2_iommu *iommu; 36 - unsigned long total_bytes; 37 - 38 - if (irq_2_iommu_index >= nr_irq_2_iommu) { 39 - /* 40 - * we run out of pre-allocate ones, allocate more 41 - */ 42 - printk(KERN_DEBUG "try to get more irq_2_iommu %d\n", nr_irq_2_iommu); 43 - 44 - total_bytes = sizeof(struct irq_2_iommu)*nr_irq_2_iommu; 45 - 46 - if (after_bootmem) 47 - iommu = kzalloc(total_bytes, GFP_ATOMIC); 48 - else 49 - iommu = __alloc_bootmem_nopanic(total_bytes, PAGE_SIZE, 0); 50 - 51 - if (!iommu) 52 - panic("can not get more irq_2_iommu\n"); 53 - 54 - irq_2_iommuX = iommu; 55 - irq_2_iommu_index = 0; 56 - } 57 - 58 - iommu = &irq_2_iommuX[irq_2_iommu_index]; 59 - irq_2_iommu_index++; 60 - return iommu; 61 - } 62 - 63 - static struct irq_2_iommu *irq_2_iommu(unsigned int irq) 64 - { 65 - struct irq_desc *desc; 66 - 67 - desc = irq_to_desc(irq); 68 - 69 - BUG_ON(!desc); 70 - 71 - return desc->irq_2_iommu; 72 - } 73 - 74 - static struct irq_2_iommu *irq_2_iommu_alloc(unsigned int irq) 75 - { 76 - struct irq_desc *desc; 77 - struct irq_2_iommu *irq_iommu; 78 - 79 - /* 80 - * alloc irq desc if not allocated already. 81 - */ 82 - desc = irq_to_desc_alloc(irq); 83 - 84 - irq_iommu = desc->irq_2_iommu; 85 - 86 - if (!irq_iommu) 87 - desc->irq_2_iommu = get_one_free_irq_2_iommu(irq); 88 - 89 - return desc->irq_2_iommu; 90 - } 91 - 92 - #else /* !CONFIG_HAVE_SPARSE_IRQ */ 93 - 94 22 #ifdef CONFIG_HAVE_DYN_ARRAY 95 23 static struct irq_2_iommu *irq_2_iommuX; 96 24 DEFINE_DYN_ARRAY(irq_2_iommuX, sizeof(struct irq_2_iommu), nr_irqs, PAGE_SIZE, NULL); ··· 37 109 { 38 110 return irq_2_iommu(irq); 39 111 } 40 - #endif 41 112 42 113 static DEFINE_SPINLOCK(irq_2_ir_lock); 43 114 ··· 93 166 if (!count) 94 167 return -1; 95 168 96 - #ifndef CONFIG_HAVE_SPARSE_IRQ 97 169 /* protect irq_2_iommu_alloc later */ 98 170 if (irq >= nr_irqs) 99 171 return -1; 100 - #endif 101 172 102 173 /* 103 174 * start the IRTE search from index 0.
+6 -39
fs/proc/proc_misc.c
··· 529 529 softirq = cputime64_add(softirq, kstat_cpu(i).cpustat.softirq); 530 530 steal = cputime64_add(steal, kstat_cpu(i).cpustat.steal); 531 531 guest = cputime64_add(guest, kstat_cpu(i).cpustat.guest); 532 - for_each_irq_desc(j, desc) 533 - { 534 - unsigned int temp; 535 532 536 - temp = kstat_irqs_cpu(j, i); 537 - sum += temp; 538 - } 533 + for_each_irq_desc(j, desc) 534 + sum += kstat_irqs_cpu(j, i); 535 + 539 536 sum += arch_irq_stat_cpu(i); 540 537 } 541 538 sum += arch_irq_stat(); ··· 575 578 seq_printf(p, "intr %llu", (unsigned long long)sum); 576 579 577 580 /* sum again ? it could be updated? */ 578 - for_each_irq_desc(j, desc) 579 - { 581 + for_each_irq_desc(j, desc) { 580 582 per_irq_sum = 0; 581 - for_each_possible_cpu(i) { 582 - unsigned int temp; 583 583 584 - temp = kstat_irqs_cpu(j, i); 585 - per_irq_sum += temp; 586 - } 584 + for_each_possible_cpu(i) 585 + per_irq_sum += kstat_irqs_cpu(j, i); 587 586 588 - #ifdef CONFIG_HAVE_SPARSE_IRQ 589 - seq_printf(p, " %#x:%u", j, per_irq_sum); 590 - #else 591 587 seq_printf(p, " %u", per_irq_sum); 592 - #endif 593 588 } 594 589 595 590 seq_printf(p, ··· 634 645 */ 635 646 static void *int_seq_start(struct seq_file *f, loff_t *pos) 636 647 { 637 - #ifdef CONFIG_HAVE_SPARSE_IRQ 638 - struct irq_desc *desc; 639 - int irq; 640 - int count = *pos; 641 - 642 - for_each_irq_desc(irq, desc) { 643 - if (count-- == 0) 644 - return desc; 645 - } 646 - 647 - return NULL; 648 - #else 649 648 return (*pos <= nr_irqs) ? pos : NULL; 650 - #endif 651 649 } 652 650 653 651 654 652 static void *int_seq_next(struct seq_file *f, void *v, loff_t *pos) 655 653 { 656 - #ifdef CONFIG_HAVE_SPARSE_IRQ 657 - struct irq_desc *desc; 658 - 659 - desc = ((struct irq_desc *)v)->next; 660 - (*pos)++; 661 - 662 - return desc; 663 - #else 664 654 (*pos)++; 665 655 return (*pos <= nr_irqs) ? pos : NULL; 666 - #endif 667 656 } 668 657 669 658 static void int_seq_stop(struct seq_file *f, void *v)
-20
include/linux/irq.h
··· 167 167 */ 168 168 struct irq_desc { 169 169 unsigned int irq; 170 - #ifdef CONFIG_HAVE_SPARSE_IRQ 171 - struct irq_desc *next; 172 - struct timer_rand_state *timer_rand_state; 173 - #endif 174 170 #ifdef CONFIG_HAVE_DYN_ARRAY 175 171 unsigned int *kstat_irqs; 176 - #endif 177 - #if defined(CONFIG_INTR_REMAP) && defined(CONFIG_HAVE_SPARSE_IRQ) 178 - struct irq_2_iommu *irq_2_iommu; 179 172 #endif 180 173 irq_flow_handler_t handle_irq; 181 174 struct irq_chip *chip; ··· 198 205 } ____cacheline_internodealigned_in_smp; 199 206 200 207 201 - #ifndef CONFIG_HAVE_SPARSE_IRQ 202 - 203 208 #ifndef CONFIG_HAVE_DYN_ARRAY 204 209 /* could be removed if we get rid of all irq_desc reference */ 205 210 extern struct irq_desc irq_desc[NR_IRQS]; ··· 214 223 { 215 224 return irq_to_desc(irq); 216 225 } 217 - 218 - #else 219 - 220 - extern struct irq_desc *irq_to_desc(unsigned int irq); 221 - extern struct irq_desc *irq_to_desc_alloc(unsigned int irq); 222 - 223 - extern struct irq_desc *sparse_irqs; 224 - #define for_each_irq_desc(irqX, desc) \ 225 - for (desc = sparse_irqs, irqX = desc->irq; desc; desc = desc->next, irqX = desc ? desc->irq : -1U) 226 - 227 - #endif 228 226 229 227 #ifdef CONFIG_HAVE_DYN_ARRAY 230 228 #define kstat_irqs_this_cpu(DESC) \
-114
kernel/irq/handle.c
··· 111 111 } 112 112 } 113 113 114 - #ifdef CONFIG_HAVE_SPARSE_IRQ 115 - /* 116 - * Protect the sparse_irqs_free freelist: 117 - */ 118 - static DEFINE_SPINLOCK(sparse_irq_lock); 119 - static struct irq_desc *sparse_irqs_free; 120 - struct irq_desc *sparse_irqs; 121 - #endif 122 - 123 114 static void __init init_work(void *data) 124 115 { 125 116 struct dyn_array *da = data; ··· 121 130 122 131 for (i = 0; i < *da->nr; i++) { 123 132 init_one_irq_desc(&desc[i]); 124 - #ifndef CONFIG_HAVE_SPARSE_IRQ 125 133 desc[i].irq = i; 126 - #endif 127 134 } 128 135 129 136 /* init kstat_irqs, nr_cpu_ids is ready already */ 130 137 init_kstat_irqs(desc, *da->nr, nr_cpu_ids); 131 - 132 - #ifdef CONFIG_HAVE_SPARSE_IRQ 133 - for (i = 1; i < *da->nr; i++) 134 - desc[i-1].next = &desc[i]; 135 - 136 - sparse_irqs_free = sparse_irqs; 137 - sparse_irqs = NULL; 138 - #endif 139 138 } 140 139 141 - #ifdef CONFIG_HAVE_SPARSE_IRQ 142 - static int nr_irq_desc = 32; 143 - 144 - static int __init parse_nr_irq_desc(char *arg) 145 - { 146 - if (arg) 147 - nr_irq_desc = simple_strtoul(arg, NULL, 0); 148 - return 0; 149 - } 150 - 151 - early_param("nr_irq_desc", parse_nr_irq_desc); 152 - 153 - DEFINE_DYN_ARRAY(sparse_irqs, sizeof(struct irq_desc), nr_irq_desc, PAGE_SIZE, init_work); 154 - 155 - struct irq_desc *irq_to_desc(unsigned int irq) 156 - { 157 - struct irq_desc *desc; 158 - 159 - desc = sparse_irqs; 160 - while (desc) { 161 - if (desc->irq == irq) 162 - return desc; 163 - 164 - desc = desc->next; 165 - } 166 - return NULL; 167 - } 168 - 169 - struct irq_desc *irq_to_desc_alloc(unsigned int irq) 170 - { 171 - struct irq_desc *desc, *desc_pri; 172 - unsigned long flags; 173 - int count = 0; 174 - int i; 175 - 176 - desc_pri = desc = sparse_irqs; 177 - while (desc) { 178 - if (desc->irq == irq) 179 - return desc; 180 - 181 - desc_pri = desc; 182 - desc = desc->next; 183 - count++; 184 - } 185 - 186 - spin_lock_irqsave(&sparse_irq_lock, flags); 187 - /* 188 - * we run out of pre-allocate ones, allocate more 189 - */ 190 - if (!sparse_irqs_free) { 191 - unsigned long phys; 192 - unsigned long total_bytes; 193 - 194 - printk(KERN_DEBUG "try to get more irq_desc %d\n", nr_irq_desc); 195 - 196 - total_bytes = sizeof(struct irq_desc) * nr_irq_desc; 197 - if (after_bootmem) 198 - desc = kzalloc(total_bytes, GFP_ATOMIC); 199 - else 200 - desc = __alloc_bootmem_nopanic(total_bytes, PAGE_SIZE, 0); 201 - 202 - if (!desc) 203 - panic("please boot with nr_irq_desc= %d\n", count * 2); 204 - 205 - phys = __pa(desc); 206 - printk(KERN_DEBUG "irq_desc ==> [%#lx - %#lx]\n", phys, phys + total_bytes); 207 - 208 - for (i = 0; i < nr_irq_desc; i++) 209 - init_one_irq_desc(&desc[i]); 210 - 211 - for (i = 1; i < nr_irq_desc; i++) 212 - desc[i-1].next = &desc[i]; 213 - 214 - /* init kstat_irqs, nr_cpu_ids is ready already */ 215 - init_kstat_irqs(desc, nr_irq_desc, nr_cpu_ids); 216 - 217 - sparse_irqs_free = desc; 218 - } 219 - 220 - desc = sparse_irqs_free; 221 - sparse_irqs_free = sparse_irqs_free->next; 222 - desc->next = NULL; 223 - if (desc_pri) 224 - desc_pri->next = desc; 225 - else 226 - sparse_irqs = desc; 227 - desc->irq = irq; 228 - 229 - spin_unlock_irqrestore(&sparse_irq_lock, flags); 230 - 231 - return desc; 232 - } 233 - #else 234 140 struct irq_desc *irq_desc; 235 141 DEFINE_DYN_ARRAY(irq_desc, sizeof(struct irq_desc), nr_irqs, PAGE_SIZE, init_work); 236 - 237 - #endif 238 142 239 143 #else 240 144