diff options
author | Michael Ellerman <michael@ellerman.id.au> | 2007-03-22 06:51:36 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-05-02 22:02:36 -0400 |
commit | 3e916c0503a34ba32202a69df1cfeb82f2c5749d (patch) | |
tree | fdd52252ad06c4ae036ed19920908f003edcd4a7 /drivers/pci | |
parent | 4cc086fa5b648dc3dcd56c963e42a212f2d9df29 (diff) |
MSI: Remove msi_cache
We don't need a special cache just for msi descriptors. They're not
particularly large, under 100 bytes for sure, and don't seem to require any
special alignment etc. On most systems there will be relatively few MSIs,
and hence we waste most of a page on the cache. Better to just kzalloc the
space for the few we do need.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Acked-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/msi.c | 44 |
1 files changed, 4 insertions, 40 deletions
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index a2002e7dc188..762bff18187d 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -24,20 +24,8 @@ | |||
24 | #include "pci.h" | 24 | #include "pci.h" |
25 | #include "msi.h" | 25 | #include "msi.h" |
26 | 26 | ||
27 | static struct kmem_cache* msi_cachep; | ||
28 | |||
29 | static int pci_msi_enable = 1; | 27 | static int pci_msi_enable = 1; |
30 | 28 | ||
31 | static int msi_cache_init(void) | ||
32 | { | ||
33 | msi_cachep = kmem_cache_create("msi_cache", sizeof(struct msi_desc), | ||
34 | 0, SLAB_HWCACHE_ALIGN, NULL, NULL); | ||
35 | if (!msi_cachep) | ||
36 | return -ENOMEM; | ||
37 | |||
38 | return 0; | ||
39 | } | ||
40 | |||
41 | static void msi_set_enable(struct pci_dev *dev, int enable) | 29 | static void msi_set_enable(struct pci_dev *dev, int enable) |
42 | { | 30 | { |
43 | int pos; | 31 | int pos; |
@@ -221,28 +209,12 @@ void unmask_msi_irq(unsigned int irq) | |||
221 | 209 | ||
222 | static int msi_free_irq(struct pci_dev* dev, int irq); | 210 | static int msi_free_irq(struct pci_dev* dev, int irq); |
223 | 211 | ||
224 | static int msi_init(void) | ||
225 | { | ||
226 | static int status = -ENOMEM; | ||
227 | |||
228 | if (!status) | ||
229 | return status; | ||
230 | |||
231 | status = msi_cache_init(); | ||
232 | if (status < 0) { | ||
233 | pci_msi_enable = 0; | ||
234 | printk(KERN_WARNING "PCI: MSI cache init failed\n"); | ||
235 | return status; | ||
236 | } | ||
237 | |||
238 | return status; | ||
239 | } | ||
240 | 212 | ||
241 | static struct msi_desc* alloc_msi_entry(void) | 213 | static struct msi_desc* alloc_msi_entry(void) |
242 | { | 214 | { |
243 | struct msi_desc *entry; | 215 | struct msi_desc *entry; |
244 | 216 | ||
245 | entry = kmem_cache_zalloc(msi_cachep, GFP_KERNEL); | 217 | entry = kzalloc(sizeof(struct msi_desc), GFP_KERNEL); |
246 | if (!entry) | 218 | if (!entry) |
247 | return NULL; | 219 | return NULL; |
248 | 220 | ||
@@ -368,7 +340,7 @@ static int msi_capability_init(struct pci_dev *dev) | |||
368 | /* Configure MSI capability structure */ | 340 | /* Configure MSI capability structure */ |
369 | irq = arch_setup_msi_irq(dev, entry); | 341 | irq = arch_setup_msi_irq(dev, entry); |
370 | if (irq < 0) { | 342 | if (irq < 0) { |
371 | kmem_cache_free(msi_cachep, entry); | 343 | kfree(entry); |
372 | return irq; | 344 | return irq; |
373 | } | 345 | } |
374 | entry->link.head = irq; | 346 | entry->link.head = irq; |
@@ -441,7 +413,7 @@ static int msix_capability_init(struct pci_dev *dev, | |||
441 | /* Configure MSI-X capability structure */ | 413 | /* Configure MSI-X capability structure */ |
442 | irq = arch_setup_msi_irq(dev, entry); | 414 | irq = arch_setup_msi_irq(dev, entry); |
443 | if (irq < 0) { | 415 | if (irq < 0) { |
444 | kmem_cache_free(msi_cachep, entry); | 416 | kfree(entry); |
445 | break; | 417 | break; |
446 | } | 418 | } |
447 | entries[i].vector = irq; | 419 | entries[i].vector = irq; |
@@ -530,10 +502,6 @@ int pci_enable_msi(struct pci_dev* dev) | |||
530 | if (pci_msi_supported(dev) < 0) | 502 | if (pci_msi_supported(dev) < 0) |
531 | return -EINVAL; | 503 | return -EINVAL; |
532 | 504 | ||
533 | status = msi_init(); | ||
534 | if (status < 0) | ||
535 | return status; | ||
536 | |||
537 | pos = pci_find_capability(dev, PCI_CAP_ID_MSI); | 505 | pos = pci_find_capability(dev, PCI_CAP_ID_MSI); |
538 | if (!pos) | 506 | if (!pos) |
539 | return -EINVAL; | 507 | return -EINVAL; |
@@ -604,7 +572,7 @@ static int msi_free_irq(struct pci_dev* dev, int irq) | |||
604 | get_irq_msi(entry->link.tail)->link.head = entry->link.head; | 572 | get_irq_msi(entry->link.tail)->link.head = entry->link.head; |
605 | 573 | ||
606 | arch_teardown_msi_irq(irq); | 574 | arch_teardown_msi_irq(irq); |
607 | kmem_cache_free(msi_cachep, entry); | 575 | kfree(entry); |
608 | 576 | ||
609 | if (type == PCI_CAP_ID_MSIX) { | 577 | if (type == PCI_CAP_ID_MSIX) { |
610 | writel(1, base + entry_nr * PCI_MSIX_ENTRY_SIZE + | 578 | writel(1, base + entry_nr * PCI_MSIX_ENTRY_SIZE + |
@@ -641,10 +609,6 @@ int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec) | |||
641 | if (!entries || pci_msi_supported(dev) < 0) | 609 | if (!entries || pci_msi_supported(dev) < 0) |
642 | return -EINVAL; | 610 | return -EINVAL; |
643 | 611 | ||
644 | status = msi_init(); | ||
645 | if (status < 0) | ||
646 | return status; | ||
647 | |||
648 | pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); | 612 | pos = pci_find_capability(dev, PCI_CAP_ID_MSIX); |
649 | if (!pos) | 613 | if (!pos) |
650 | return -EINVAL; | 614 | return -EINVAL; |