瀏覽代碼

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>
Michael Ellerman 18 年之前
父節點
當前提交
3e916c0503
共有 1 個文件被更改,包括 4 次插入40 次删除
  1. 4 40
      drivers/pci/msi.c

+ 4 - 40
drivers/pci/msi.c

@@ -24,20 +24,8 @@
 #include "pci.h"
 #include "pci.h"
 #include "msi.h"
 #include "msi.h"
 
 
-static struct kmem_cache* msi_cachep;
-
 static int pci_msi_enable = 1;
 static int pci_msi_enable = 1;
 
 
-static int msi_cache_init(void)
-{
-	msi_cachep = kmem_cache_create("msi_cache", sizeof(struct msi_desc),
-					0, SLAB_HWCACHE_ALIGN, NULL, NULL);
-	if (!msi_cachep)
-		return -ENOMEM;
-
-	return 0;
-}
-
 static void msi_set_enable(struct pci_dev *dev, int enable)
 static void msi_set_enable(struct pci_dev *dev, int enable)
 {
 {
 	int pos;
 	int pos;
@@ -221,28 +209,12 @@ void unmask_msi_irq(unsigned int irq)
 
 
 static int msi_free_irq(struct pci_dev* dev, int irq);
 static int msi_free_irq(struct pci_dev* dev, int irq);
 
 
-static int msi_init(void)
-{
-	static int status = -ENOMEM;
-
-	if (!status)
-		return status;
-
-	status = msi_cache_init();
-	if (status < 0) {
-		pci_msi_enable = 0;
-		printk(KERN_WARNING "PCI: MSI cache init failed\n");
-		return status;
-	}
-
-	return status;
-}
 
 
 static struct msi_desc* alloc_msi_entry(void)
 static struct msi_desc* alloc_msi_entry(void)
 {
 {
 	struct msi_desc *entry;
 	struct msi_desc *entry;
 
 
-	entry = kmem_cache_zalloc(msi_cachep, GFP_KERNEL);
+	entry = kzalloc(sizeof(struct msi_desc), GFP_KERNEL);
 	if (!entry)
 	if (!entry)
 		return NULL;
 		return NULL;
 
 
@@ -368,7 +340,7 @@ static int msi_capability_init(struct pci_dev *dev)
 	/* Configure MSI capability structure */
 	/* Configure MSI capability structure */
 	irq = arch_setup_msi_irq(dev, entry);
 	irq = arch_setup_msi_irq(dev, entry);
 	if (irq < 0) {
 	if (irq < 0) {
-		kmem_cache_free(msi_cachep, entry);
+		kfree(entry);
 		return irq;
 		return irq;
 	}
 	}
 	entry->link.head = irq;
 	entry->link.head = irq;
@@ -441,7 +413,7 @@ static int msix_capability_init(struct pci_dev *dev,
 		/* Configure MSI-X capability structure */
 		/* Configure MSI-X capability structure */
 		irq = arch_setup_msi_irq(dev, entry);
 		irq = arch_setup_msi_irq(dev, entry);
 		if (irq < 0) {
 		if (irq < 0) {
-			kmem_cache_free(msi_cachep, entry);
+			kfree(entry);
 			break;
 			break;
 		}
 		}
  		entries[i].vector = irq;
  		entries[i].vector = irq;
@@ -530,10 +502,6 @@ int pci_enable_msi(struct pci_dev* dev)
 	if (pci_msi_supported(dev) < 0)
 	if (pci_msi_supported(dev) < 0)
 		return -EINVAL;
 		return -EINVAL;
 
 
-	status = msi_init();
-	if (status < 0)
-		return status;
-
 	pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
 	pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
 	if (!pos)
 	if (!pos)
 		return -EINVAL;
 		return -EINVAL;
@@ -604,7 +572,7 @@ static int msi_free_irq(struct pci_dev* dev, int irq)
 	get_irq_msi(entry->link.tail)->link.head = entry->link.head;
 	get_irq_msi(entry->link.tail)->link.head = entry->link.head;
 
 
 	arch_teardown_msi_irq(irq);
 	arch_teardown_msi_irq(irq);
-	kmem_cache_free(msi_cachep, entry);
+	kfree(entry);
 
 
 	if (type == PCI_CAP_ID_MSIX) {
 	if (type == PCI_CAP_ID_MSIX) {
 		writel(1, base + entry_nr * PCI_MSIX_ENTRY_SIZE +
 		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)
 	if (!entries || pci_msi_supported(dev) < 0)
 	if (!entries || pci_msi_supported(dev) < 0)
  		return -EINVAL;
  		return -EINVAL;
 
 
-	status = msi_init();
-	if (status < 0)
-		return status;
-
 	pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
 	pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
 	if (!pos)
 	if (!pos)
  		return -EINVAL;
  		return -EINVAL;