diff options
Diffstat (limited to 'drivers/s390/scsi/zfcp_aux.c')
-rw-r--r-- | drivers/s390/scsi/zfcp_aux.c | 76 |
1 files changed, 58 insertions, 18 deletions
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c index adc9d8f2c28f..d2b094d9c34f 100644 --- a/drivers/s390/scsi/zfcp_aux.c +++ b/drivers/s390/scsi/zfcp_aux.c | |||
@@ -299,11 +299,45 @@ zfcp_init_device_configure(void) | |||
299 | return; | 299 | return; |
300 | } | 300 | } |
301 | 301 | ||
302 | static int calc_alignment(int size) | ||
303 | { | ||
304 | int align = 1; | ||
305 | |||
306 | if (!size) | ||
307 | return 0; | ||
308 | |||
309 | while ((size - align) > 0) | ||
310 | align <<= 1; | ||
311 | |||
312 | return align; | ||
313 | } | ||
314 | |||
302 | static int __init | 315 | static int __init |
303 | zfcp_module_init(void) | 316 | zfcp_module_init(void) |
304 | { | 317 | { |
318 | int retval = -ENOMEM; | ||
319 | int size, align; | ||
320 | |||
321 | size = sizeof(struct zfcp_fsf_req_qtcb); | ||
322 | align = calc_alignment(size); | ||
323 | zfcp_data.fsf_req_qtcb_cache = | ||
324 | kmem_cache_create("zfcp_fsf", size, align, 0, NULL, NULL); | ||
325 | if (!zfcp_data.fsf_req_qtcb_cache) | ||
326 | goto out; | ||
305 | 327 | ||
306 | int retval = 0; | 328 | size = sizeof(struct fsf_status_read_buffer); |
329 | align = calc_alignment(size); | ||
330 | zfcp_data.sr_buffer_cache = | ||
331 | kmem_cache_create("zfcp_sr", size, align, 0, NULL, NULL); | ||
332 | if (!zfcp_data.sr_buffer_cache) | ||
333 | goto out_sr_cache; | ||
334 | |||
335 | size = sizeof(struct zfcp_gid_pn_data); | ||
336 | align = calc_alignment(size); | ||
337 | zfcp_data.gid_pn_cache = | ||
338 | kmem_cache_create("zfcp_gid", size, align, 0, NULL, NULL); | ||
339 | if (!zfcp_data.gid_pn_cache) | ||
340 | goto out_gid_cache; | ||
307 | 341 | ||
308 | atomic_set(&zfcp_data.loglevel, loglevel); | 342 | atomic_set(&zfcp_data.loglevel, loglevel); |
309 | 343 | ||
@@ -313,15 +347,16 @@ zfcp_module_init(void) | |||
313 | /* initialize adapters to be removed list head */ | 347 | /* initialize adapters to be removed list head */ |
314 | INIT_LIST_HEAD(&zfcp_data.adapter_remove_lh); | 348 | INIT_LIST_HEAD(&zfcp_data.adapter_remove_lh); |
315 | 349 | ||
316 | zfcp_transport_template = fc_attach_transport(&zfcp_transport_functions); | 350 | zfcp_data.scsi_transport_template = |
317 | if (!zfcp_transport_template) | 351 | fc_attach_transport(&zfcp_transport_functions); |
318 | return -ENODEV; | 352 | if (!zfcp_data.scsi_transport_template) |
353 | goto out_transport; | ||
319 | 354 | ||
320 | retval = misc_register(&zfcp_cfdc_misc); | 355 | retval = misc_register(&zfcp_cfdc_misc); |
321 | if (retval != 0) { | 356 | if (retval != 0) { |
322 | ZFCP_LOG_INFO("registration of misc device " | 357 | ZFCP_LOG_INFO("registration of misc device " |
323 | "zfcp_cfdc failed\n"); | 358 | "zfcp_cfdc failed\n"); |
324 | goto out; | 359 | goto out_misc; |
325 | } | 360 | } |
326 | 361 | ||
327 | ZFCP_LOG_TRACE("major/minor for zfcp_cfdc: %d/%d\n", | 362 | ZFCP_LOG_TRACE("major/minor for zfcp_cfdc: %d/%d\n", |
@@ -333,9 +368,6 @@ zfcp_module_init(void) | |||
333 | /* initialise configuration rw lock */ | 368 | /* initialise configuration rw lock */ |
334 | rwlock_init(&zfcp_data.config_lock); | 369 | rwlock_init(&zfcp_data.config_lock); |
335 | 370 | ||
336 | /* save address of data structure managing the driver module */ | ||
337 | zfcp_data.scsi_host_template.module = THIS_MODULE; | ||
338 | |||
339 | /* setup dynamic I/O */ | 371 | /* setup dynamic I/O */ |
340 | retval = zfcp_ccw_register(); | 372 | retval = zfcp_ccw_register(); |
341 | if (retval) { | 373 | if (retval) { |
@@ -350,6 +382,14 @@ zfcp_module_init(void) | |||
350 | 382 | ||
351 | out_ccw_register: | 383 | out_ccw_register: |
352 | misc_deregister(&zfcp_cfdc_misc); | 384 | misc_deregister(&zfcp_cfdc_misc); |
385 | out_misc: | ||
386 | fc_release_transport(zfcp_data.scsi_transport_template); | ||
387 | out_transport: | ||
388 | kmem_cache_destroy(zfcp_data.gid_pn_cache); | ||
389 | out_gid_cache: | ||
390 | kmem_cache_destroy(zfcp_data.sr_buffer_cache); | ||
391 | out_sr_cache: | ||
392 | kmem_cache_destroy(zfcp_data.fsf_req_qtcb_cache); | ||
353 | out: | 393 | out: |
354 | return retval; | 394 | return retval; |
355 | } | 395 | } |
@@ -935,20 +975,20 @@ static int | |||
935 | zfcp_allocate_low_mem_buffers(struct zfcp_adapter *adapter) | 975 | zfcp_allocate_low_mem_buffers(struct zfcp_adapter *adapter) |
936 | { | 976 | { |
937 | adapter->pool.fsf_req_erp = | 977 | adapter->pool.fsf_req_erp = |
938 | mempool_create_kmalloc_pool(ZFCP_POOL_FSF_REQ_ERP_NR, | 978 | mempool_create_slab_pool(ZFCP_POOL_FSF_REQ_ERP_NR, |
939 | sizeof(struct zfcp_fsf_req_pool_element)); | 979 | zfcp_data.fsf_req_qtcb_cache); |
940 | if (!adapter->pool.fsf_req_erp) | 980 | if (!adapter->pool.fsf_req_erp) |
941 | return -ENOMEM; | 981 | return -ENOMEM; |
942 | 982 | ||
943 | adapter->pool.fsf_req_scsi = | 983 | adapter->pool.fsf_req_scsi = |
944 | mempool_create_kmalloc_pool(ZFCP_POOL_FSF_REQ_SCSI_NR, | 984 | mempool_create_slab_pool(ZFCP_POOL_FSF_REQ_SCSI_NR, |
945 | sizeof(struct zfcp_fsf_req_pool_element)); | 985 | zfcp_data.fsf_req_qtcb_cache); |
946 | if (!adapter->pool.fsf_req_scsi) | 986 | if (!adapter->pool.fsf_req_scsi) |
947 | return -ENOMEM; | 987 | return -ENOMEM; |
948 | 988 | ||
949 | adapter->pool.fsf_req_abort = | 989 | adapter->pool.fsf_req_abort = |
950 | mempool_create_kmalloc_pool(ZFCP_POOL_FSF_REQ_ABORT_NR, | 990 | mempool_create_slab_pool(ZFCP_POOL_FSF_REQ_ABORT_NR, |
951 | sizeof(struct zfcp_fsf_req_pool_element)); | 991 | zfcp_data.fsf_req_qtcb_cache); |
952 | if (!adapter->pool.fsf_req_abort) | 992 | if (!adapter->pool.fsf_req_abort) |
953 | return -ENOMEM; | 993 | return -ENOMEM; |
954 | 994 | ||
@@ -959,14 +999,14 @@ zfcp_allocate_low_mem_buffers(struct zfcp_adapter *adapter) | |||
959 | return -ENOMEM; | 999 | return -ENOMEM; |
960 | 1000 | ||
961 | adapter->pool.data_status_read = | 1001 | adapter->pool.data_status_read = |
962 | mempool_create_kmalloc_pool(ZFCP_POOL_STATUS_READ_NR, | 1002 | mempool_create_slab_pool(ZFCP_POOL_STATUS_READ_NR, |
963 | sizeof(struct fsf_status_read_buffer)); | 1003 | zfcp_data.sr_buffer_cache); |
964 | if (!adapter->pool.data_status_read) | 1004 | if (!adapter->pool.data_status_read) |
965 | return -ENOMEM; | 1005 | return -ENOMEM; |
966 | 1006 | ||
967 | adapter->pool.data_gid_pn = | 1007 | adapter->pool.data_gid_pn = |
968 | mempool_create_kmalloc_pool(ZFCP_POOL_DATA_GID_PN_NR, | 1008 | mempool_create_slab_pool(ZFCP_POOL_DATA_GID_PN_NR, |
969 | sizeof(struct zfcp_gid_pn_data)); | 1009 | zfcp_data.gid_pn_cache); |
970 | if (!adapter->pool.data_gid_pn) | 1010 | if (!adapter->pool.data_gid_pn) |
971 | return -ENOMEM; | 1011 | return -ENOMEM; |
972 | 1012 | ||