aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Ott <sebott@linux.ibm.com>2018-06-04 13:18:03 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2018-06-12 09:14:31 -0400
commitec530174c43798099d305fbd6511e5d7fc7616d4 (patch)
tree6db57c06ff9a54f8e02bb1ee5c3d1752472ad749
parent61d388321032be9097935bbc5efdd6ac42691ed4 (diff)
s390/dasd: only use preallocated requests
Change the remaining users of dasd_kmalloc_request to use preallocated memory and remove this function. Signed-off-by: Sebastian Ott <sebott@linux.ibm.com> Reviewed-by: Stefan Haberland <sth@linux.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r--drivers/s390/block/dasd.c66
-rw-r--r--drivers/s390/block/dasd_alias.c6
-rw-r--r--drivers/s390/block/dasd_eer.c10
-rw-r--r--drivers/s390/block/dasd_int.h3
4 files changed, 8 insertions, 77 deletions
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 01a1d1dabb43..d3a38c421503 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -1222,51 +1222,6 @@ static void dasd_hosts_init(struct dentry *base_dentry,
1222 device->hosts_dentry = pde; 1222 device->hosts_dentry = pde;
1223} 1223}
1224 1224
1225/*
1226 * Allocate memory for a channel program with 'cplength' channel
1227 * command words and 'datasize' additional space. There are two
1228 * variantes: 1) dasd_kmalloc_request uses kmalloc to get the needed
1229 * memory and 2) dasd_smalloc_request uses the static ccw memory
1230 * that gets allocated for each device.
1231 */
1232struct dasd_ccw_req *dasd_kmalloc_request(int magic, int cplength,
1233 int datasize,
1234 struct dasd_device *device)
1235{
1236 struct dasd_ccw_req *cqr;
1237
1238 /* Sanity checks */
1239 BUG_ON(datasize > PAGE_SIZE ||
1240 (cplength*sizeof(struct ccw1)) > PAGE_SIZE);
1241
1242 cqr = kzalloc(sizeof(struct dasd_ccw_req), GFP_ATOMIC);
1243 if (cqr == NULL)
1244 return ERR_PTR(-ENOMEM);
1245 cqr->cpaddr = NULL;
1246 if (cplength > 0) {
1247 cqr->cpaddr = kcalloc(cplength, sizeof(struct ccw1),
1248 GFP_ATOMIC | GFP_DMA);
1249 if (cqr->cpaddr == NULL) {
1250 kfree(cqr);
1251 return ERR_PTR(-ENOMEM);
1252 }
1253 }
1254 cqr->data = NULL;
1255 if (datasize > 0) {
1256 cqr->data = kzalloc(datasize, GFP_ATOMIC | GFP_DMA);
1257 if (cqr->data == NULL) {
1258 kfree(cqr->cpaddr);
1259 kfree(cqr);
1260 return ERR_PTR(-ENOMEM);
1261 }
1262 }
1263 cqr->magic = magic;
1264 set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
1265 dasd_get_device(device);
1266 return cqr;
1267}
1268EXPORT_SYMBOL(dasd_kmalloc_request);
1269
1270struct dasd_ccw_req *dasd_smalloc_request(int magic, int cplength, int datasize, 1225struct dasd_ccw_req *dasd_smalloc_request(int magic, int cplength, int datasize,
1271 struct dasd_device *device, 1226 struct dasd_device *device,
1272 struct dasd_ccw_req *cqr) 1227 struct dasd_ccw_req *cqr)
@@ -1309,27 +1264,6 @@ struct dasd_ccw_req *dasd_smalloc_request(int magic, int cplength, int datasize,
1309} 1264}
1310EXPORT_SYMBOL(dasd_smalloc_request); 1265EXPORT_SYMBOL(dasd_smalloc_request);
1311 1266
1312/*
1313 * Free memory of a channel program. This function needs to free all the
1314 * idal lists that might have been created by dasd_set_cda and the
1315 * struct dasd_ccw_req itself.
1316 */
1317void dasd_kfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device)
1318{
1319 struct ccw1 *ccw;
1320
1321 /* Clear any idals used for the request. */
1322 ccw = cqr->cpaddr;
1323 do {
1324 clear_normalized_cda(ccw);
1325 } while (ccw++->flags & (CCW_FLAG_CC | CCW_FLAG_DC));
1326 kfree(cqr->cpaddr);
1327 kfree(cqr->data);
1328 kfree(cqr);
1329 dasd_put_device(device);
1330}
1331EXPORT_SYMBOL(dasd_kfree_request);
1332
1333void dasd_sfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device) 1267void dasd_sfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device)
1334{ 1268{
1335 unsigned long flags; 1269 unsigned long flags;
diff --git a/drivers/s390/block/dasd_alias.c b/drivers/s390/block/dasd_alias.c
index 5e963fe0e38d..e36a114354fc 100644
--- a/drivers/s390/block/dasd_alias.c
+++ b/drivers/s390/block/dasd_alias.c
@@ -407,9 +407,9 @@ static int read_unit_address_configuration(struct dasd_device *device,
407 int rc; 407 int rc;
408 unsigned long flags; 408 unsigned long flags;
409 409
410 cqr = dasd_kmalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ + 1 /* RSSD */, 410 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ + 1 /* RSSD */,
411 (sizeof(struct dasd_psf_prssd_data)), 411 (sizeof(struct dasd_psf_prssd_data)),
412 device); 412 device, NULL);
413 if (IS_ERR(cqr)) 413 if (IS_ERR(cqr))
414 return PTR_ERR(cqr); 414 return PTR_ERR(cqr);
415 cqr->startdev = device; 415 cqr->startdev = device;
@@ -457,7 +457,7 @@ static int read_unit_address_configuration(struct dasd_device *device,
457 lcu->flags |= NEED_UAC_UPDATE; 457 lcu->flags |= NEED_UAC_UPDATE;
458 spin_unlock_irqrestore(&lcu->lock, flags); 458 spin_unlock_irqrestore(&lcu->lock, flags);
459 } 459 }
460 dasd_kfree_request(cqr, cqr->memdev); 460 dasd_sfree_request(cqr, cqr->memdev);
461 return rc; 461 return rc;
462} 462}
463 463
diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c
index fb2c3599d95c..6545342bd43f 100644
--- a/drivers/s390/block/dasd_eer.c
+++ b/drivers/s390/block/dasd_eer.c
@@ -447,7 +447,7 @@ static void dasd_eer_snss_cb(struct dasd_ccw_req *cqr, void *data)
447 * is a new ccw in device->eer_cqr. Free the "old" 447 * is a new ccw in device->eer_cqr. Free the "old"
448 * snss request now. 448 * snss request now.
449 */ 449 */
450 dasd_kfree_request(cqr, device); 450 dasd_sfree_request(cqr, device);
451} 451}
452 452
453/* 453/*
@@ -472,8 +472,8 @@ int dasd_eer_enable(struct dasd_device *device)
472 if (rc) 472 if (rc)
473 goto out; 473 goto out;
474 474
475 cqr = dasd_kmalloc_request(DASD_ECKD_MAGIC, 1 /* SNSS */, 475 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* SNSS */,
476 SNSS_DATA_SIZE, device); 476 SNSS_DATA_SIZE, device, NULL);
477 if (IS_ERR(cqr)) { 477 if (IS_ERR(cqr)) {
478 rc = -ENOMEM; 478 rc = -ENOMEM;
479 cqr = NULL; 479 cqr = NULL;
@@ -505,7 +505,7 @@ out:
505 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); 505 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
506 506
507 if (cqr) 507 if (cqr)
508 dasd_kfree_request(cqr, device); 508 dasd_sfree_request(cqr, device);
509 509
510 return rc; 510 return rc;
511} 511}
@@ -528,7 +528,7 @@ void dasd_eer_disable(struct dasd_device *device)
528 in_use = test_and_clear_bit(DASD_FLAG_EER_IN_USE, &device->flags); 528 in_use = test_and_clear_bit(DASD_FLAG_EER_IN_USE, &device->flags);
529 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); 529 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
530 if (cqr && !in_use) 530 if (cqr && !in_use)
531 dasd_kfree_request(cqr, device); 531 dasd_sfree_request(cqr, device);
532} 532}
533 533
534/* 534/*
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 55bcbbed1b1d..976b6bd4fb05 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -707,10 +707,7 @@ extern const struct block_device_operations dasd_device_operations;
707extern struct kmem_cache *dasd_page_cache; 707extern struct kmem_cache *dasd_page_cache;
708 708
709struct dasd_ccw_req * 709struct dasd_ccw_req *
710dasd_kmalloc_request(int , int, int, struct dasd_device *);
711struct dasd_ccw_req *
712dasd_smalloc_request(int, int, int, struct dasd_device *, struct dasd_ccw_req *); 710dasd_smalloc_request(int, int, int, struct dasd_device *, struct dasd_ccw_req *);
713void dasd_kfree_request(struct dasd_ccw_req *, struct dasd_device *);
714void dasd_sfree_request(struct dasd_ccw_req *, struct dasd_device *); 711void dasd_sfree_request(struct dasd_ccw_req *, struct dasd_device *);
715void dasd_wakeup_cb(struct dasd_ccw_req *, void *); 712void dasd_wakeup_cb(struct dasd_ccw_req *, void *);
716 713