ia64/linux-2.6.18-xen.hg

annotate kernel/irq/autoprobe.c @ 912:dd42cdb0ab89

[IA64] Build blktap2 driver by default in x86 builds.

add CONFIG_XEN_BLKDEV_TAP2=y to buildconfigs/linux-defconfig_xen_ia64.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Isaku Yamahata <yamahata@valinux.co.jp>
date Mon Jun 29 12:09:16 2009 +0900 (2009-06-29)
parents 831230e53067
children
rev   line source
ian@0 1 /*
ian@0 2 * linux/kernel/irq/autoprobe.c
ian@0 3 *
ian@0 4 * Copyright (C) 1992, 1998-2004 Linus Torvalds, Ingo Molnar
ian@0 5 *
ian@0 6 * This file contains the interrupt probing code and driver APIs.
ian@0 7 */
ian@0 8
ian@0 9 #include <linux/irq.h>
ian@0 10 #include <linux/module.h>
ian@0 11 #include <linux/interrupt.h>
ian@0 12 #include <linux/delay.h>
ian@0 13
ian@0 14 #include "internals.h"
ian@0 15
ian@0 16 /*
ian@0 17 * Autodetection depends on the fact that any interrupt that
ian@0 18 * comes in on to an unassigned handler will get stuck with
ian@0 19 * "IRQ_WAITING" cleared and the interrupt disabled.
ian@0 20 */
ian@0 21 static DEFINE_MUTEX(probing_active);
ian@0 22
ian@0 23 /**
ian@0 24 * probe_irq_on - begin an interrupt autodetect
ian@0 25 *
ian@0 26 * Commence probing for an interrupt. The interrupts are scanned
ian@0 27 * and a mask of potential interrupt lines is returned.
ian@0 28 *
ian@0 29 */
ian@0 30 unsigned long probe_irq_on(void)
ian@0 31 {
ian@0 32 struct irq_desc *desc;
ian@0 33 unsigned long mask;
ian@0 34 unsigned int i;
ian@0 35
ian@0 36 mutex_lock(&probing_active);
ian@0 37 /*
ian@0 38 * something may have generated an irq long ago and we want to
ian@0 39 * flush such a longstanding irq before considering it as spurious.
ian@0 40 */
ian@0 41 for (i = NR_IRQS-1; i > 0; i--) {
ian@0 42 desc = irq_desc + i;
ian@0 43
ian@0 44 spin_lock_irq(&desc->lock);
ian@0 45 if (!desc->action && !(desc->status & IRQ_NOPROBE)) {
ian@0 46 /*
ian@0 47 * An old-style architecture might still have
ian@0 48 * the handle_bad_irq handler there:
ian@0 49 */
ian@0 50 compat_irq_chip_set_default_handler(desc);
ian@0 51
ian@0 52 /*
ian@0 53 * Some chips need to know about probing in
ian@0 54 * progress:
ian@0 55 */
ian@0 56 if (desc->chip->set_type)
ian@0 57 desc->chip->set_type(i, IRQ_TYPE_PROBE);
ian@0 58 desc->chip->startup(i);
ian@0 59 }
ian@0 60 spin_unlock_irq(&desc->lock);
ian@0 61 }
ian@0 62
ian@0 63 /* Wait for longstanding interrupts to trigger. */
ian@0 64 msleep(20);
ian@0 65
ian@0 66 /*
ian@0 67 * enable any unassigned irqs
ian@0 68 * (we must startup again here because if a longstanding irq
ian@0 69 * happened in the previous stage, it may have masked itself)
ian@0 70 */
ian@0 71 for (i = NR_IRQS-1; i > 0; i--) {
ian@0 72 desc = irq_desc + i;
ian@0 73
ian@0 74 spin_lock_irq(&desc->lock);
ian@0 75 if (!desc->action && !(desc->status & IRQ_NOPROBE)) {
ian@0 76 desc->status |= IRQ_AUTODETECT | IRQ_WAITING;
ian@0 77 if (desc->chip->startup(i))
ian@0 78 desc->status |= IRQ_PENDING;
ian@0 79 }
ian@0 80 spin_unlock_irq(&desc->lock);
ian@0 81 }
ian@0 82
ian@0 83 /*
ian@0 84 * Wait for spurious interrupts to trigger
ian@0 85 */
ian@0 86 msleep(100);
ian@0 87
ian@0 88 /*
ian@0 89 * Now filter out any obviously spurious interrupts
ian@0 90 */
ian@0 91 mask = 0;
ian@0 92 for (i = 0; i < NR_IRQS; i++) {
ian@0 93 unsigned int status;
ian@0 94
ian@0 95 desc = irq_desc + i;
ian@0 96 spin_lock_irq(&desc->lock);
ian@0 97 status = desc->status;
ian@0 98
ian@0 99 if (status & IRQ_AUTODETECT) {
ian@0 100 /* It triggered already - consider it spurious. */
ian@0 101 if (!(status & IRQ_WAITING)) {
ian@0 102 desc->status = status & ~IRQ_AUTODETECT;
ian@0 103 desc->chip->shutdown(i);
ian@0 104 } else
ian@0 105 if (i < 32)
ian@0 106 mask |= 1 << i;
ian@0 107 }
ian@0 108 spin_unlock_irq(&desc->lock);
ian@0 109 }
ian@0 110
ian@0 111 return mask;
ian@0 112 }
ian@0 113 EXPORT_SYMBOL(probe_irq_on);
ian@0 114
ian@0 115 /**
ian@0 116 * probe_irq_mask - scan a bitmap of interrupt lines
ian@0 117 * @val: mask of interrupts to consider
ian@0 118 *
ian@0 119 * Scan the interrupt lines and return a bitmap of active
ian@0 120 * autodetect interrupts. The interrupt probe logic state
ian@0 121 * is then returned to its previous value.
ian@0 122 *
ian@0 123 * Note: we need to scan all the irq's even though we will
ian@0 124 * only return autodetect irq numbers - just so that we reset
ian@0 125 * them all to a known state.
ian@0 126 */
ian@0 127 unsigned int probe_irq_mask(unsigned long val)
ian@0 128 {
ian@0 129 unsigned int mask;
ian@0 130 int i;
ian@0 131
ian@0 132 mask = 0;
ian@0 133 for (i = 0; i < NR_IRQS; i++) {
ian@0 134 struct irq_desc *desc = irq_desc + i;
ian@0 135 unsigned int status;
ian@0 136
ian@0 137 spin_lock_irq(&desc->lock);
ian@0 138 status = desc->status;
ian@0 139
ian@0 140 if (status & IRQ_AUTODETECT) {
ian@0 141 if (i < 16 && !(status & IRQ_WAITING))
ian@0 142 mask |= 1 << i;
ian@0 143
ian@0 144 desc->status = status & ~IRQ_AUTODETECT;
ian@0 145 desc->chip->shutdown(i);
ian@0 146 }
ian@0 147 spin_unlock_irq(&desc->lock);
ian@0 148 }
ian@0 149 mutex_unlock(&probing_active);
ian@0 150
ian@0 151 return mask & val;
ian@0 152 }
ian@0 153 EXPORT_SYMBOL(probe_irq_mask);
ian@0 154
ian@0 155 /**
ian@0 156 * probe_irq_off - end an interrupt autodetect
ian@0 157 * @val: mask of potential interrupts (unused)
ian@0 158 *
ian@0 159 * Scans the unused interrupt lines and returns the line which
ian@0 160 * appears to have triggered the interrupt. If no interrupt was
ian@0 161 * found then zero is returned. If more than one interrupt is
ian@0 162 * found then minus the first candidate is returned to indicate
ian@0 163 * their is doubt.
ian@0 164 *
ian@0 165 * The interrupt probe logic state is returned to its previous
ian@0 166 * value.
ian@0 167 *
ian@0 168 * BUGS: When used in a module (which arguably shouldn't happen)
ian@0 169 * nothing prevents two IRQ probe callers from overlapping. The
ian@0 170 * results of this are non-optimal.
ian@0 171 */
ian@0 172 int probe_irq_off(unsigned long val)
ian@0 173 {
ian@0 174 int i, irq_found = 0, nr_irqs = 0;
ian@0 175
ian@0 176 for (i = 0; i < NR_IRQS; i++) {
ian@0 177 struct irq_desc *desc = irq_desc + i;
ian@0 178 unsigned int status;
ian@0 179
ian@0 180 spin_lock_irq(&desc->lock);
ian@0 181 status = desc->status;
ian@0 182
ian@0 183 if (status & IRQ_AUTODETECT) {
ian@0 184 if (!(status & IRQ_WAITING)) {
ian@0 185 if (!nr_irqs)
ian@0 186 irq_found = i;
ian@0 187 nr_irqs++;
ian@0 188 }
ian@0 189 desc->status = status & ~IRQ_AUTODETECT;
ian@0 190 desc->chip->shutdown(i);
ian@0 191 }
ian@0 192 spin_unlock_irq(&desc->lock);
ian@0 193 }
ian@0 194 mutex_unlock(&probing_active);
ian@0 195
ian@0 196 if (nr_irqs > 1)
ian@0 197 irq_found = -irq_found;
ian@0 198
ian@0 199 return irq_found;
ian@0 200 }
ian@0 201 EXPORT_SYMBOL(probe_irq_off);
ian@0 202