diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2005-06-07 02:07:46 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-06-28 00:52:46 -0400 |
commit | 70549ad9cf074e12f12cdc931b29b2616dfb873a (patch) | |
tree | dde5cdc320df87f1eee4b6ef94146dd741a31d14 | |
parent | bb4a61b6eaee01707f24deeefc5d7136f25f75c5 (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>
-rw-r--r-- | drivers/pci/msi.c | 88 | ||||
-rw-r--r-- | drivers/pci/msi.h | 9 |
2 files changed, 37 insertions, 60 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 }; | |||
28 | static kmem_cache_t* msi_cachep; | 28 | static kmem_cache_t* msi_cachep; |
29 | 29 | ||
30 | static int pci_msi_enable = 1; | 30 | static int pci_msi_enable = 1; |
31 | static int last_alloc_vector = 0; | 31 | static int last_alloc_vector; |
32 | static int nr_released_vectors = 0; | 32 | static int nr_released_vectors; |
33 | static int nr_reserved_vectors = NR_HP_RESERVED_VECTORS; | 33 | static int nr_reserved_vectors = NR_HP_RESERVED_VECTORS; |
34 | static int nr_msix_devices = 0; | 34 | static int nr_msix_devices; |
35 | 35 | ||
36 | #ifndef CONFIG_X86_IO_APIC | 36 | #ifndef CONFIG_X86_IO_APIC |
37 | int vector_irq[NR_VECTORS] = { [0 ... NR_VECTORS - 1] = -1}; | 37 | int 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 | ||
173 | static void release_msi(unsigned int vector); | 173 | static unsigned int startup_msi_irq_w_maskbit(unsigned int vector) |
174 | static void shutdown_msi_irq(unsigned int vector) | ||
175 | { | ||
176 | release_msi(vector); | ||
177 | } | ||
178 | |||
179 | #define shutdown_msi_irq_wo_maskbit shutdown_msi_irq | ||
180 | static void enable_msi_irq_wo_maskbit(unsigned int vector) {} | ||
181 | static void disable_msi_irq_wo_maskbit(unsigned int vector) {} | ||
182 | static void ack_msi_irq_wo_maskbit(unsigned int vector) {} | ||
183 | static 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 | ||
189 | static unsigned int startup_msi_irq_w_maskbit(unsigned int vector) | 180 | static 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 | 192 | static 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 | ||
212 | static void end_msi_irq_w_maskbit(unsigned int vector) | 198 | static 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 | ||
205 | static 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) | |||
223 | static struct hw_interrupt_type msix_irq_type = { | 213 | static 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 = { | |||
239 | static struct hw_interrupt_type msi_irq_w_maskbit_type = { | 229 | static 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 = { | |||
255 | static struct hw_interrupt_type msi_irq_wo_maskbit_type = { | 245 | static 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 | ||
799 | static 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 | |||
811 | static int msi_free_vector(struct pci_dev* dev, int vector, int reassign) | 789 | static 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 |
diff --git a/drivers/pci/msi.h b/drivers/pci/msi.h index bef21ae3cbd0..390f1851c0f1 100644 --- a/drivers/pci/msi.h +++ b/drivers/pci/msi.h | |||
@@ -41,11 +41,11 @@ static inline void move_msi(int vector) {} | |||
41 | #define PCI_MSIX_FLAGS_BIRMASK (7 << 0) | 41 | #define PCI_MSIX_FLAGS_BIRMASK (7 << 0) |
42 | #define PCI_MSIX_FLAGS_BITMASK (1 << 0) | 42 | #define PCI_MSIX_FLAGS_BITMASK (1 << 0) |
43 | 43 | ||
44 | #define PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET 0 | ||
45 | #define PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET 4 | ||
46 | #define PCI_MSIX_ENTRY_DATA_OFFSET 8 | ||
47 | #define PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET 12 | ||
48 | #define PCI_MSIX_ENTRY_SIZE 16 | 44 | #define PCI_MSIX_ENTRY_SIZE 16 |
45 | #define PCI_MSIX_ENTRY_LOWER_ADDR_OFFSET 0 | ||
46 | #define PCI_MSIX_ENTRY_UPPER_ADDR_OFFSET 4 | ||
47 | #define PCI_MSIX_ENTRY_DATA_OFFSET 8 | ||
48 | #define PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET 12 | ||
49 | 49 | ||
50 | #define msi_control_reg(base) (base + PCI_MSI_FLAGS) | 50 | #define msi_control_reg(base) (base + PCI_MSI_FLAGS) |
51 | #define msi_lower_address_reg(base) (base + PCI_MSI_ADDRESS_LO) | 51 | #define msi_lower_address_reg(base) (base + PCI_MSI_ADDRESS_LO) |
@@ -64,7 +64,6 @@ static inline void move_msi(int vector) {} | |||
64 | #define msi_enable(control, num) multi_msi_enable(control, num); \ | 64 | #define msi_enable(control, num) multi_msi_enable(control, num); \ |
65 | control |= PCI_MSI_FLAGS_ENABLE | 65 | control |= PCI_MSI_FLAGS_ENABLE |
66 | 66 | ||
67 | #define msix_control_reg msi_control_reg | ||
68 | #define msix_table_offset_reg(base) (base + 0x04) | 67 | #define msix_table_offset_reg(base) (base + 0x04) |
69 | #define msix_pba_offset_reg(base) (base + 0x08) | 68 | #define msix_pba_offset_reg(base) (base + 0x08) |
70 | #define msix_enable(control) control |= PCI_MSIX_FLAGS_ENABLE | 69 | #define msix_enable(control) control |= PCI_MSIX_FLAGS_ENABLE |