Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+22 -42
-1
drivers/dma/ioat/dma.h
··· 83 83 struct pci_pool *completion_pool; 84 84 #define MAX_SED_POOLS 5 85 85 struct dma_pool *sed_hw_pool[MAX_SED_POOLS]; 86 - struct kmem_cache *sed_pool; 87 86 struct dma_device common; 88 87 u8 version; 89 88 struct msix_entry msix_entries[4];
-1
drivers/dma/ioat/dma_v2.h
··· 157 157 158 158 int ioat2_dma_probe(struct ioatdma_device *dev, int dca); 159 159 int ioat3_dma_probe(struct ioatdma_device *dev, int dca); 160 - void ioat3_dma_remove(struct ioatdma_device *dev); 161 160 struct dca_provider *ioat2_dca_init(struct pci_dev *pdev, void __iomem *iobase); 162 161 struct dca_provider *ioat3_dca_init(struct pci_dev *pdev, void __iomem *iobase); 163 162 int ioat2_check_space_lock(struct ioat2_dma_chan *ioat, int num_descs);
+7 -35
drivers/dma/ioat/dma_v3.c
··· 67 67 #include "dma.h" 68 68 #include "dma_v2.h" 69 69 70 + extern struct kmem_cache *ioat3_sed_cache; 71 + 70 72 /* ioat hardware assumes at least two sources for raid operations */ 71 73 #define src_cnt_to_sw(x) ((x) + 2) 72 74 #define src_cnt_to_hw(x) ((x) - 2) ··· 254 252 struct ioat_sed_ent *sed; 255 253 gfp_t flags = __GFP_ZERO | GFP_ATOMIC; 256 254 257 - sed = kmem_cache_alloc(device->sed_pool, flags); 255 + sed = kmem_cache_alloc(ioat3_sed_cache, flags); 258 256 if (!sed) 259 257 return NULL; 260 258 ··· 262 260 sed->hw = dma_pool_alloc(device->sed_hw_pool[hw_pool], 263 261 flags, &sed->dma); 264 262 if (!sed->hw) { 265 - kmem_cache_free(device->sed_pool, sed); 263 + kmem_cache_free(ioat3_sed_cache, sed); 266 264 return NULL; 267 265 } 268 266 ··· 275 273 return; 276 274 277 275 dma_pool_free(device->sed_hw_pool[sed->hw_pool], sed->hw, sed->dma); 278 - kmem_cache_free(device->sed_pool, sed); 276 + kmem_cache_free(ioat3_sed_cache, sed); 279 277 } 280 278 281 279 static bool desc_has_ext(struct ioat_ring_ent *desc) ··· 1654 1652 char pool_name[14]; 1655 1653 int i; 1656 1654 1657 - /* allocate sw descriptor pool for SED */ 1658 - device->sed_pool = kmem_cache_create("ioat_sed", 1659 - sizeof(struct ioat_sed_ent), 0, 0, NULL); 1660 - if (!device->sed_pool) 1661 - return -ENOMEM; 1662 - 1663 1655 for (i = 0; i < MAX_SED_POOLS; i++) { 1664 1656 snprintf(pool_name, 14, "ioat_hw%d_sed", i); 1665 1657 1666 1658 /* allocate SED DMA pool */ 1667 - device->sed_hw_pool[i] = dma_pool_create(pool_name, 1659 + device->sed_hw_pool[i] = dmam_pool_create(pool_name, 1668 1660 &pdev->dev, 1669 1661 SED_SIZE * (i + 1), 64, 0); 1670 1662 if (!device->sed_hw_pool[i]) 1671 - goto sed_pool_cleanup; 1663 + return -ENOMEM; 1672 1664 1673 1665 } 1674 1666 } ··· 1688 1692 device->dca = ioat3_dca_init(pdev, device->reg_base); 1689 1693 1690 1694 return 0; 1691 - 1692 - sed_pool_cleanup: 1693 - if (device->sed_pool) { 1694 - int i; 1695 - kmem_cache_destroy(device->sed_pool); 1696 - 1697 - for (i = 0; i < MAX_SED_POOLS; i++) 1698 - if (device->sed_hw_pool[i]) 1699 - dma_pool_destroy(device->sed_hw_pool[i]); 1700 - } 1701 - 1702 - return -ENOMEM; 1703 - } 1704 - 1705 - void ioat3_dma_remove(struct ioatdma_device *device) 1706 - { 1707 - if (device->sed_pool) { 1708 - int i; 1709 - kmem_cache_destroy(device->sed_pool); 1710 - 1711 - for (i = 0; i < MAX_SED_POOLS; i++) 1712 - if (device->sed_hw_pool[i]) 1713 - dma_pool_destroy(device->sed_hw_pool[i]); 1714 - } 1715 1695 }
+15 -5
drivers/dma/ioat/pci.c
··· 123 123 MODULE_PARM_DESC(ioat_dca_enabled, "control support of dca service (default: 1)"); 124 124 125 125 struct kmem_cache *ioat2_cache; 126 + struct kmem_cache *ioat3_sed_cache; 126 127 127 128 #define DRV_NAME "ioatdma" 128 129 ··· 208 207 if (!device) 209 208 return; 210 209 211 - if (device->version >= IOAT_VER_3_0) 212 - ioat3_dma_remove(device); 213 - 214 210 dev_err(&pdev->dev, "Removing dma and dca services\n"); 215 211 if (device->dca) { 216 212 unregister_dca_provider(device->dca, &pdev->dev); ··· 219 221 220 222 static int __init ioat_init_module(void) 221 223 { 222 - int err; 224 + int err = -ENOMEM; 223 225 224 226 pr_info("%s: Intel(R) QuickData Technology Driver %s\n", 225 227 DRV_NAME, IOAT_DMA_VERSION); ··· 229 231 if (!ioat2_cache) 230 232 return -ENOMEM; 231 233 234 + ioat3_sed_cache = KMEM_CACHE(ioat_sed_ent, 0); 235 + if (!ioat3_sed_cache) 236 + goto err_ioat2_cache; 237 + 232 238 err = pci_register_driver(&ioat_pci_driver); 233 239 if (err) 234 - kmem_cache_destroy(ioat2_cache); 240 + goto err_ioat3_cache; 241 + 242 + return 0; 243 + 244 + err_ioat3_cache: 245 + kmem_cache_destroy(ioat3_sed_cache); 246 + 247 + err_ioat2_cache: 248 + kmem_cache_destroy(ioat2_cache); 235 249 236 250 return err; 237 251 }