Allocate flush slab in skd_pci_probe() instead of in skd_init() so it is allocated only if some devices are present (currently it is always allocated when the driver is loaded).
Cc: Akhil Bhansali <abhans...@stec-inc.com> Cc: Jeff Moyer <jmo...@redhat.com> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnier...@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.p...@samsung.com> --- drivers/block/skd_main.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c index 04eb9bd..e63a63c 100644 --- a/drivers/block/skd_main.c +++ b/drivers/block/skd_main.c @@ -5203,6 +5203,18 @@ static int skd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } } + if (!skd_flush_slab) { + skd_flush_slab = kmem_cache_create(SKD_FLUSH_JOB, + sizeof(struct skd_flush_cmd), + 0, 0, NULL); + if (!skd_flush_slab) { + pr_err("(%s): failed to allocate flush slab\n", + pci_name(pdev)); + rc = -ENOMEM; + goto err_out_regions; + } + } + skdev = skd_construct(pdev); if (skdev == NULL) goto err_out_regions; @@ -5714,14 +5726,6 @@ static int __init skd_init(void) skd_isr_type = SKD_IRQ_DEFAULT; } - skd_flush_slab = kmem_cache_create(SKD_FLUSH_JOB, - sizeof(struct skd_flush_cmd), - 0, 0, NULL); - if (!skd_flush_slab) { - pr_err(PFX "failed to allocate flush slab\n"); - goto err_kmem_cache_create; - } - if (skd_max_queue_depth < 1 || skd_max_queue_depth > SKD_MAX_QUEUE_DEPTH) { pr_err(PFX "skd_max_queue_depth %d invalid, re-set to %d\n", @@ -5776,9 +5780,6 @@ err_pci_register_driver: unregister_blkdev(skd_major, DRV_NAME); err_register_blkdev: - kmem_cache_destroy(skd_flush_slab); - -err_kmem_cache_create: return rc; } @@ -5790,7 +5791,8 @@ static void __exit skd_exit(void) unregister_blkdev(skd_major, DRV_NAME); - kmem_cache_destroy(skd_flush_slab); + if (skd_flush_slab) + kmem_cache_destroy(skd_flush_slab); } static int -- 1.8.2.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/