aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/msi.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2005-06-07 02:07:46 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-06-28 00:52:46 -0400
commit70549ad9cf074e12f12cdc931b29b2616dfb873a (patch)
treedde5cdc320df87f1eee4b6ef94146dd741a31d14 /drivers/pci/msi.c
parentbb4a61b6eaee01707f24deeefc5d7136f25f75c5 (diff)
[PATCH] PCI: clean up the MSI code a bit.
Mostly just cleans up the irq handling logic to be smaller and a bit more descriptive as to what it really does. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/msi.c')
-rw-r--r--drivers/pci/msi.c88
1 files changed, 33 insertions, 55 deletions
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 30206ac43c44..b5ab9aa6ff7c 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -28,10 +28,10 @@ static struct msi_desc* msi_desc[NR_IRQS] = { [0 ... NR_IRQS-1] = NULL };
28static kmem_cache_t* msi_cachep; 28static kmem_cache_t* msi_cachep;
29 29
30static int pci_msi_enable = 1; 30static int pci_msi_enable = 1;
31static int last_alloc_vector = 0; 31static int last_alloc_vector;
32static int nr_released_vectors = 0; 32static int nr_released_vectors;
33static int nr_reserved_vectors = NR_HP_RESERVED_VECTORS; 33static int nr_reserved_vectors = NR_HP_RESERVED_VECTORS;
34static int nr_msix_devices = 0; 34static int nr_msix_devices;
35 35
36#ifndef CONFIG_X86_IO_APIC 36#ifndef CONFIG_X86_IO_APIC
37int vector_irq[NR_VECTORS] = { [0 ... NR_VECTORS - 1] = -1}; 37int vector_irq[NR_VECTORS] = { [0 ... NR_VECTORS - 1] = -1};
@@ -170,44 +170,30 @@ static unsigned int startup_msi_irq_wo_maskbit(unsigned int vector)
170 return 0; /* never anything pending */ 170 return 0; /* never anything pending */
171} 171}
172 172
173static void release_msi(unsigned int vector); 173static unsigned int startup_msi_irq_w_maskbit(unsigned int vector)
174static void shutdown_msi_irq(unsigned int vector)
175{
176 release_msi(vector);
177}
178
179#define shutdown_msi_irq_wo_maskbit shutdown_msi_irq
180static void enable_msi_irq_wo_maskbit(unsigned int vector) {}
181static void disable_msi_irq_wo_maskbit(unsigned int vector) {}
182static void ack_msi_irq_wo_maskbit(unsigned int vector) {}
183static void end_msi_irq_wo_maskbit(unsigned int vector)
184{ 174{
185 move_msi(vector); 175 startup_msi_irq_wo_maskbit(vector);
186 ack_APIC_irq(); 176 unmask_MSI_irq(vector);
177 return 0; /* never anything pending */
187} 178}
188 179
189static unsigned int startup_msi_irq_w_maskbit(unsigned int vector) 180static void shutdown_msi_irq(unsigned int vector)
190{ 181{
191 struct msi_desc *entry; 182 struct msi_desc *entry;
192 unsigned long flags; 183 unsigned long flags;
193 184
194 spin_lock_irqsave(&msi_lock, flags); 185 spin_lock_irqsave(&msi_lock, flags);
195 entry = msi_desc[vector]; 186 entry = msi_desc[vector];
196 if (!entry || !entry->dev) { 187 if (entry && entry->dev)
197 spin_unlock_irqrestore(&msi_lock, flags); 188 entry->msi_attrib.state = 0; /* Mark it not active */
198 return 0;
199 }
200 entry->msi_attrib.state = 1; /* Mark it active */
201 spin_unlock_irqrestore(&msi_lock, flags); 189 spin_unlock_irqrestore(&msi_lock, flags);
202
203 unmask_MSI_irq(vector);
204 return 0; /* never anything pending */
205} 190}
206 191
207#define shutdown_msi_irq_w_maskbit shutdown_msi_irq 192static void end_msi_irq_wo_maskbit(unsigned int vector)
208#define enable_msi_irq_w_maskbit unmask_MSI_irq 193{
209#define disable_msi_irq_w_maskbit mask_MSI_irq 194 move_msi(vector);
210#define ack_msi_irq_w_maskbit mask_MSI_irq 195 ack_APIC_irq();
196}
211 197
212static void end_msi_irq_w_maskbit(unsigned int vector) 198static void end_msi_irq_w_maskbit(unsigned int vector)
213{ 199{
@@ -216,6 +202,10 @@ static void end_msi_irq_w_maskbit(unsigned int vector)
216 ack_APIC_irq(); 202 ack_APIC_irq();
217} 203}
218 204
205static void do_nothing(unsigned int vector)
206{
207}
208
219/* 209/*
220 * Interrupt Type for MSI-X PCI/PCI-X/PCI-Express Devices, 210 * Interrupt Type for MSI-X PCI/PCI-X/PCI-Express Devices,
221 * which implement the MSI-X Capability Structure. 211 * which implement the MSI-X Capability Structure.
@@ -223,10 +213,10 @@ static void end_msi_irq_w_maskbit(unsigned int vector)
223static struct hw_interrupt_type msix_irq_type = { 213static struct hw_interrupt_type msix_irq_type = {
224 .typename = "PCI-MSI-X", 214 .typename = "PCI-MSI-X",
225 .startup = startup_msi_irq_w_maskbit, 215 .startup = startup_msi_irq_w_maskbit,
226 .shutdown = shutdown_msi_irq_w_maskbit, 216 .shutdown = shutdown_msi_irq,
227 .enable = enable_msi_irq_w_maskbit, 217 .enable = unmask_MSI_irq,
228 .disable = disable_msi_irq_w_maskbit, 218 .disable = mask_MSI_irq,
229 .ack = ack_msi_irq_w_maskbit, 219 .ack = mask_MSI_irq,
230 .end = end_msi_irq_w_maskbit, 220 .end = end_msi_irq_w_maskbit,
231 .set_affinity = set_msi_irq_affinity 221 .set_affinity = set_msi_irq_affinity
232}; 222};
@@ -239,10 +229,10 @@ static struct hw_interrupt_type msix_irq_type = {
239static struct hw_interrupt_type msi_irq_w_maskbit_type = { 229static struct hw_interrupt_type msi_irq_w_maskbit_type = {
240 .typename = "PCI-MSI", 230 .typename = "PCI-MSI",
241 .startup = startup_msi_irq_w_maskbit, 231 .startup = startup_msi_irq_w_maskbit,
242 .shutdown = shutdown_msi_irq_w_maskbit, 232 .shutdown = shutdown_msi_irq,
243 .enable = enable_msi_irq_w_maskbit, 233 .enable = unmask_MSI_irq,
244 .disable = disable_msi_irq_w_maskbit, 234 .disable = mask_MSI_irq,
245 .ack = ack_msi_irq_w_maskbit, 235 .ack = mask_MSI_irq,
246 .end = end_msi_irq_w_maskbit, 236 .end = end_msi_irq_w_maskbit,
247 .set_affinity = set_msi_irq_affinity 237 .set_affinity = set_msi_irq_affinity
248}; 238};
@@ -255,10 +245,10 @@ static struct hw_interrupt_type msi_irq_w_maskbit_type = {
255static struct hw_interrupt_type msi_irq_wo_maskbit_type = { 245static struct hw_interrupt_type msi_irq_wo_maskbit_type = {
256 .typename = "PCI-MSI", 246 .typename = "PCI-MSI",
257 .startup = startup_msi_irq_wo_maskbit, 247 .startup = startup_msi_irq_wo_maskbit,
258 .shutdown = shutdown_msi_irq_wo_maskbit, 248 .shutdown = shutdown_msi_irq,
259 .enable = enable_msi_irq_wo_maskbit, 249 .enable = do_nothing,
260 .disable = disable_msi_irq_wo_maskbit, 250 .disable = do_nothing,
261 .ack = ack_msi_irq_wo_maskbit, 251 .ack = do_nothing,
262 .end = end_msi_irq_wo_maskbit, 252 .end = end_msi_irq_wo_maskbit,
263 .set_affinity = set_msi_irq_affinity 253 .set_affinity = set_msi_irq_affinity
264}; 254};
@@ -407,7 +397,7 @@ static struct msi_desc* alloc_msi_entry(void)
407{ 397{
408 struct msi_desc *entry; 398 struct msi_desc *entry;
409 399
410 entry = (struct msi_desc*) kmem_cache_alloc(msi_cachep, SLAB_KERNEL); 400 entry = kmem_cache_alloc(msi_cachep, SLAB_KERNEL);
411 if (!entry) 401 if (!entry)
412 return NULL; 402 return NULL;
413 403
@@ -796,18 +786,6 @@ void pci_disable_msi(struct pci_dev* dev)
796 } 786 }
797} 787}
798 788
799static void release_msi(unsigned int vector)
800{
801 struct msi_desc *entry;
802 unsigned long flags;
803
804 spin_lock_irqsave(&msi_lock, flags);
805 entry = msi_desc[vector];
806 if (entry && entry->dev)
807 entry->msi_attrib.state = 0; /* Mark it not active */
808 spin_unlock_irqrestore(&msi_lock, flags);
809}
810
811static int msi_free_vector(struct pci_dev* dev, int vector, int reassign) 789static int msi_free_vector(struct pci_dev* dev, int vector, int reassign)
812{ 790{
813 struct msi_desc *entry; 791 struct msi_desc *entry;
@@ -924,7 +902,7 @@ static int reroute_msix_table(int head, struct msix_entry *entries, int *nvec)
924/** 902/**
925 * pci_enable_msix - configure device's MSI-X capability structure 903 * pci_enable_msix - configure device's MSI-X capability structure
926 * @dev: pointer to the pci_dev data structure of MSI-X device function 904 * @dev: pointer to the pci_dev data structure of MSI-X device function
927 * @data: pointer to an array of MSI-X entries 905 * @entries: pointer to an array of MSI-X entries
928 * @nvec: number of MSI-X vectors requested for allocation by device driver 906 * @nvec: number of MSI-X vectors requested for allocation by device driver
929 * 907 *
930 * Setup the MSI-X capability structure of device function with the number 908 * Setup the MSI-X capability structure of device function with the number