lkml.org 
[lkml]   [2013]   [Sep]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 04/14] skd: alloc flush slab only if some devices are present
Date
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 <abhansali@stec-inc.com>
Cc: Jeff Moyer <jmoyer@redhat.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@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


\
 
 \ /
  Last update: 2013-09-30 16:01    [W:0.595 / U:0.508 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site