aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/ioat
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2013-11-13 13:57:18 -0500
committerDan Williams <dan.j.williams@intel.com>2013-11-14 14:04:41 -0500
commit59056e85d7dd337674c65d9dac65008cb46a98cd (patch)
tree2487688810534d3a26e13de707c20747ed78cc86 /drivers/dma/ioat
parent21e96c7313486390c694919522a76dfea0a86c59 (diff)
ioatdma: clean up sed pool kmem_cache
Use a single cache for all sed allocations. No need to make it per channel. This also avoids the slub_debug warnings for multiple caches with the same name. Switching to dmam_pool_create() to fix leaking the dma pools on initialization failure and lets us kill ioat3_dma_remove(). Cc: Dave Jiang <dave.jiang@intel.com> Acked-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/dma/ioat')
-rw-r--r--drivers/dma/ioat/dma.h1
-rw-r--r--drivers/dma/ioat/dma_v2.h1
-rw-r--r--drivers/dma/ioat/dma_v3.c42
-rw-r--r--drivers/dma/ioat/pci.c20
4 files changed, 22 insertions, 42 deletions
diff --git a/drivers/dma/ioat/dma.h b/drivers/dma/ioat/dma.h
index 4300d5af188f..df552d841481 100644
--- a/drivers/dma/ioat/dma.h
+++ b/drivers/dma/ioat/dma.h
@@ -83,7 +83,6 @@ struct ioatdma_device {
83 struct pci_pool *completion_pool; 83 struct pci_pool *completion_pool;
84#define MAX_SED_POOLS 5 84#define MAX_SED_POOLS 5
85 struct dma_pool *sed_hw_pool[MAX_SED_POOLS]; 85 struct dma_pool *sed_hw_pool[MAX_SED_POOLS];
86 struct kmem_cache *sed_pool;
87 struct dma_device common; 86 struct dma_device common;
88 u8 version; 87 u8 version;
89 struct msix_entry msix_entries[4]; 88 struct msix_entry msix_entries[4];
diff --git a/drivers/dma/ioat/dma_v2.h b/drivers/dma/ioat/dma_v2.h
index 212d584fe427..470292767e68 100644
--- a/drivers/dma/ioat/dma_v2.h
+++ b/drivers/dma/ioat/dma_v2.h
@@ -157,7 +157,6 @@ static inline void ioat2_set_chainaddr(struct ioat2_dma_chan *ioat, u64 addr)
157 157
158int ioat2_dma_probe(struct ioatdma_device *dev, int dca); 158int ioat2_dma_probe(struct ioatdma_device *dev, int dca);
159int ioat3_dma_probe(struct ioatdma_device *dev, int dca); 159int ioat3_dma_probe(struct ioatdma_device *dev, int dca);
160void ioat3_dma_remove(struct ioatdma_device *dev);
161struct dca_provider *ioat2_dca_init(struct pci_dev *pdev, void __iomem *iobase); 160struct dca_provider *ioat2_dca_init(struct pci_dev *pdev, void __iomem *iobase);
162struct dca_provider *ioat3_dca_init(struct pci_dev *pdev, void __iomem *iobase); 161struct dca_provider *ioat3_dca_init(struct pci_dev *pdev, void __iomem *iobase);
163int ioat2_check_space_lock(struct ioat2_dma_chan *ioat, int num_descs); 162int ioat2_check_space_lock(struct ioat2_dma_chan *ioat, int num_descs);
diff --git a/drivers/dma/ioat/dma_v3.c b/drivers/dma/ioat/dma_v3.c
index 0284908997f8..f8170de1d6a4 100644
--- a/drivers/dma/ioat/dma_v3.c
+++ b/drivers/dma/ioat/dma_v3.c
@@ -67,6 +67,8 @@
67#include "dma.h" 67#include "dma.h"
68#include "dma_v2.h" 68#include "dma_v2.h"
69 69
70extern struct kmem_cache *ioat3_sed_cache;
71
70/* ioat hardware assumes at least two sources for raid operations */ 72/* ioat hardware assumes at least two sources for raid operations */
71#define src_cnt_to_sw(x) ((x) + 2) 73#define src_cnt_to_sw(x) ((x) + 2)
72#define src_cnt_to_hw(x) ((x) - 2) 74#define src_cnt_to_hw(x) ((x) - 2)
@@ -252,7 +254,7 @@ ioat3_alloc_sed(struct ioatdma_device *device, unsigned int hw_pool)
252 struct ioat_sed_ent *sed; 254 struct ioat_sed_ent *sed;
253 gfp_t flags = __GFP_ZERO | GFP_ATOMIC; 255 gfp_t flags = __GFP_ZERO | GFP_ATOMIC;
254 256
255 sed = kmem_cache_alloc(device->sed_pool, flags); 257 sed = kmem_cache_alloc(ioat3_sed_cache, flags);
256 if (!sed) 258 if (!sed)
257 return NULL; 259 return NULL;
258 260
@@ -260,7 +262,7 @@ ioat3_alloc_sed(struct ioatdma_device *device, unsigned int hw_pool)
260 sed->hw = dma_pool_alloc(device->sed_hw_pool[hw_pool], 262 sed->hw = dma_pool_alloc(device->sed_hw_pool[hw_pool],
261 flags, &sed->dma); 263 flags, &sed->dma);
262 if (!sed->hw) { 264 if (!sed->hw) {
263 kmem_cache_free(device->sed_pool, sed); 265 kmem_cache_free(ioat3_sed_cache, sed);
264 return NULL; 266 return NULL;
265 } 267 }
266 268
@@ -273,7 +275,7 @@ static void ioat3_free_sed(struct ioatdma_device *device, struct ioat_sed_ent *s
273 return; 275 return;
274 276
275 dma_pool_free(device->sed_hw_pool[sed->hw_pool], sed->hw, sed->dma); 277 dma_pool_free(device->sed_hw_pool[sed->hw_pool], sed->hw, sed->dma);
276 kmem_cache_free(device->sed_pool, sed); 278 kmem_cache_free(ioat3_sed_cache, sed);
277} 279}
278 280
279static bool desc_has_ext(struct ioat_ring_ent *desc) 281static bool desc_has_ext(struct ioat_ring_ent *desc)
@@ -1652,21 +1654,15 @@ int ioat3_dma_probe(struct ioatdma_device *device, int dca)
1652 char pool_name[14]; 1654 char pool_name[14];
1653 int i; 1655 int i;
1654 1656
1655 /* allocate sw descriptor pool for SED */
1656 device->sed_pool = kmem_cache_create("ioat_sed",
1657 sizeof(struct ioat_sed_ent), 0, 0, NULL);
1658 if (!device->sed_pool)
1659 return -ENOMEM;
1660
1661 for (i = 0; i < MAX_SED_POOLS; i++) { 1657 for (i = 0; i < MAX_SED_POOLS; i++) {
1662 snprintf(pool_name, 14, "ioat_hw%d_sed", i); 1658 snprintf(pool_name, 14, "ioat_hw%d_sed", i);
1663 1659
1664 /* allocate SED DMA pool */ 1660 /* allocate SED DMA pool */
1665 device->sed_hw_pool[i] = dma_pool_create(pool_name, 1661 device->sed_hw_pool[i] = dmam_pool_create(pool_name,
1666 &pdev->dev, 1662 &pdev->dev,
1667 SED_SIZE * (i + 1), 64, 0); 1663 SED_SIZE * (i + 1), 64, 0);
1668 if (!device->sed_hw_pool[i]) 1664 if (!device->sed_hw_pool[i])
1669 goto sed_pool_cleanup; 1665 return -ENOMEM;
1670 1666
1671 } 1667 }
1672 } 1668 }
@@ -1692,28 +1688,4 @@ int ioat3_dma_probe(struct ioatdma_device *device, int dca)
1692 device->dca = ioat3_dca_init(pdev, device->reg_base); 1688 device->dca = ioat3_dca_init(pdev, device->reg_base);
1693 1689
1694 return 0; 1690 return 0;
1695
1696sed_pool_cleanup:
1697 if (device->sed_pool) {
1698 int i;
1699 kmem_cache_destroy(device->sed_pool);
1700
1701 for (i = 0; i < MAX_SED_POOLS; i++)
1702 if (device->sed_hw_pool[i])
1703 dma_pool_destroy(device->sed_hw_pool[i]);
1704 }
1705
1706 return -ENOMEM;
1707}
1708
1709void ioat3_dma_remove(struct ioatdma_device *device)
1710{
1711 if (device->sed_pool) {
1712 int i;
1713 kmem_cache_destroy(device->sed_pool);
1714
1715 for (i = 0; i < MAX_SED_POOLS; i++)
1716 if (device->sed_hw_pool[i])
1717 dma_pool_destroy(device->sed_hw_pool[i]);
1718 }
1719} 1691}
diff --git a/drivers/dma/ioat/pci.c b/drivers/dma/ioat/pci.c
index 2c8d560e6334..1d051cd045db 100644
--- a/drivers/dma/ioat/pci.c
+++ b/drivers/dma/ioat/pci.c
@@ -123,6 +123,7 @@ module_param(ioat_dca_enabled, int, 0644);
123MODULE_PARM_DESC(ioat_dca_enabled, "control support of dca service (default: 1)"); 123MODULE_PARM_DESC(ioat_dca_enabled, "control support of dca service (default: 1)");
124 124
125struct kmem_cache *ioat2_cache; 125struct kmem_cache *ioat2_cache;
126struct kmem_cache *ioat3_sed_cache;
126 127
127#define DRV_NAME "ioatdma" 128#define DRV_NAME "ioatdma"
128 129
@@ -207,9 +208,6 @@ static void ioat_remove(struct pci_dev *pdev)
207 if (!device) 208 if (!device)
208 return; 209 return;
209 210
210 if (device->version >= IOAT_VER_3_0)
211 ioat3_dma_remove(device);
212
213 dev_err(&pdev->dev, "Removing dma and dca services\n"); 211 dev_err(&pdev->dev, "Removing dma and dca services\n");
214 if (device->dca) { 212 if (device->dca) {
215 unregister_dca_provider(device->dca, &pdev->dev); 213 unregister_dca_provider(device->dca, &pdev->dev);
@@ -221,7 +219,7 @@ static void ioat_remove(struct pci_dev *pdev)
221 219
222static int __init ioat_init_module(void) 220static int __init ioat_init_module(void)
223{ 221{
224 int err; 222 int err = -ENOMEM;
225 223
226 pr_info("%s: Intel(R) QuickData Technology Driver %s\n", 224 pr_info("%s: Intel(R) QuickData Technology Driver %s\n",
227 DRV_NAME, IOAT_DMA_VERSION); 225 DRV_NAME, IOAT_DMA_VERSION);
@@ -231,9 +229,21 @@ static int __init ioat_init_module(void)
231 if (!ioat2_cache) 229 if (!ioat2_cache)
232 return -ENOMEM; 230 return -ENOMEM;
233 231
232 ioat3_sed_cache = KMEM_CACHE(ioat_sed_ent, 0);
233 if (!ioat3_sed_cache)
234 goto err_ioat2_cache;
235
234 err = pci_register_driver(&ioat_pci_driver); 236 err = pci_register_driver(&ioat_pci_driver);
235 if (err) 237 if (err)
236 kmem_cache_destroy(ioat2_cache); 238 goto err_ioat3_cache;
239
240 return 0;
241
242 err_ioat3_cache:
243 kmem_cache_destroy(ioat3_sed_cache);
244
245 err_ioat2_cache:
246 kmem_cache_destroy(ioat2_cache);
237 247
238 return err; 248 return err;
239} 249}