Skip to content

Commit 59056e8

Browse files
committed
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>
1 parent 21e96c7 commit 59056e8

4 files changed

Lines changed: 22 additions & 42 deletions

File tree

‎drivers/dma/ioat/dma.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ struct ioatdma_device {
8383
struct pci_pool *completion_pool;
8484
#define MAX_SED_POOLS 5
8585
struct dma_pool *sed_hw_pool[MAX_SED_POOLS];
86-
struct kmem_cache *sed_pool;
8786
struct dma_device common;
8887
u8 version;
8988
struct msix_entry msix_entries[4];

‎drivers/dma/ioat/dma_v2.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ static inline void ioat2_set_chainaddr(struct ioat2_dma_chan *ioat, u64 addr)
157157

158158
int ioat2_dma_probe(struct ioatdma_device *dev, int dca);
159159
int ioat3_dma_probe(struct ioatdma_device *dev, int dca);
160-
void ioat3_dma_remove(struct ioatdma_device *dev);
161160
struct dca_provider *ioat2_dca_init(struct pci_dev *pdev, void __iomem *iobase);
162161
struct dca_provider *ioat3_dca_init(struct pci_dev *pdev, void __iomem *iobase);
163162
int ioat2_check_space_lock(struct ioat2_dma_chan *ioat, int num_descs);

‎drivers/dma/ioat/dma_v3.c‎

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767
#include "dma.h"
6868
#include "dma_v2.h"
6969

70+
extern struct kmem_cache *ioat3_sed_cache;
71+
7072
/* ioat hardware assumes at least two sources for raid operations */
7173
#define src_cnt_to_sw(x) ((x) + 2)
7274
#define src_cnt_to_hw(x) ((x) - 2)
@@ -252,15 +254,15 @@ ioat3_alloc_sed(struct ioatdma_device *device, unsigned int hw_pool)
252254
struct ioat_sed_ent *sed;
253255
gfp_t flags = __GFP_ZERO | GFP_ATOMIC;
254256

255-
sed = kmem_cache_alloc(device->sed_pool, flags);
257+
sed = kmem_cache_alloc(ioat3_sed_cache, flags);
256258
if (!sed)
257259
return NULL;
258260

259261
sed->hw_pool = hw_pool;
260262
sed->hw = dma_pool_alloc(device->sed_hw_pool[hw_pool],
261263
flags, &sed->dma);
262264
if (!sed->hw) {
263-
kmem_cache_free(device->sed_pool, sed);
265+
kmem_cache_free(ioat3_sed_cache, sed);
264266
return NULL;
265267
}
266268

@@ -273,7 +275,7 @@ static void ioat3_free_sed(struct ioatdma_device *device, struct ioat_sed_ent *s
273275
return;
274276

275277
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);
277279
}
278280

279281
static bool desc_has_ext(struct ioat_ring_ent *desc)
@@ -1652,21 +1654,15 @@ int ioat3_dma_probe(struct ioatdma_device *device, int dca)
16521654
char pool_name[14];
16531655
int i;
16541656

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-
16611657
for (i = 0; i < MAX_SED_POOLS; i++) {
16621658
snprintf(pool_name, 14, "ioat_hw%d_sed", i);
16631659

16641660
/* 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,
16661662
&pdev->dev,
16671663
SED_SIZE * (i + 1), 64, 0);
16681664
if (!device->sed_hw_pool[i])
1669-
goto sed_pool_cleanup;
1665+
return -ENOMEM;
16701666

16711667
}
16721668
}
@@ -1692,28 +1688,4 @@ int ioat3_dma_probe(struct ioatdma_device *device, int dca)
16921688
device->dca = ioat3_dca_init(pdev, device->reg_base);
16931689

16941690
return 0;
1695-
1696-
sed_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-
1709-
void 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-
}
17191691
}

‎drivers/dma/ioat/pci.c‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ module_param(ioat_dca_enabled, int, 0644);
123123
MODULE_PARM_DESC(ioat_dca_enabled, "control support of dca service (default: 1)");
124124

125125
struct kmem_cache *ioat2_cache;
126+
struct kmem_cache *ioat3_sed_cache;
126127

127128
#define DRV_NAME "ioatdma"
128129

@@ -207,9 +208,6 @@ static void ioat_remove(struct pci_dev *pdev)
207208
if (!device)
208209
return;
209210

210-
if (device->version >= IOAT_VER_3_0)
211-
ioat3_dma_remove(device);
212-
213211
dev_err(&pdev->dev, "Removing dma and dca services\n");
214212
if (device->dca) {
215213
unregister_dca_provider(device->dca, &pdev->dev);
@@ -221,7 +219,7 @@ static void ioat_remove(struct pci_dev *pdev)
221219

222220
static int __init ioat_init_module(void)
223221
{
224-
int err;
222+
int err = -ENOMEM;
225223

226224
pr_info("%s: Intel(R) QuickData Technology Driver %s\n",
227225
DRV_NAME, IOAT_DMA_VERSION);
@@ -231,9 +229,21 @@ static int __init ioat_init_module(void)
231229
if (!ioat2_cache)
232230
return -ENOMEM;
233231

232+
ioat3_sed_cache = KMEM_CACHE(ioat_sed_ent, 0);
233+
if (!ioat3_sed_cache)
234+
goto err_ioat2_cache;
235+
234236
err = pci_register_driver(&ioat_pci_driver);
235237
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);
237247

238248
return err;
239249
}

0 commit comments

Comments
 (0)