hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/s390/scsi/zfcp_aux.c
....@@ -4,7 +4,7 @@
44 *
55 * Module interface and handling of zfcp data structures.
66 *
7
- * Copyright IBM Corp. 2002, 2013
7
+ * Copyright IBM Corp. 2002, 2020
88 */
99
1010 /*
....@@ -25,6 +25,7 @@
2525 * Martin Petermann
2626 * Sven Schuetz
2727 * Steffen Maier
28
+ * Benjamin Block
2829 */
2930
3031 #define KMSG_COMPONENT "zfcp"
....@@ -36,6 +37,7 @@
3637 #include "zfcp_ext.h"
3738 #include "zfcp_fc.h"
3839 #include "zfcp_reqlist.h"
40
+#include "zfcp_diag.h"
3941
4042 #define ZFCP_BUS_ID_SIZE 20
4143
....@@ -123,6 +125,9 @@
123125 static int __init zfcp_module_init(void)
124126 {
125127 int retval = -ENOMEM;
128
+
129
+ if (zfcp_experimental_dix)
130
+ pr_warn("DIX is enabled. It is experimental and might cause problems\n");
126131
127132 zfcp_fsf_qtcb_cache = zfcp_cache_hw_align("zfcp_fsf_qtcb",
128133 sizeof(struct fsf_qtcb));
....@@ -248,30 +253,23 @@
248253
249254 static void zfcp_free_low_mem_buffers(struct zfcp_adapter *adapter)
250255 {
251
- if (adapter->pool.erp_req)
252
- mempool_destroy(adapter->pool.erp_req);
253
- if (adapter->pool.scsi_req)
254
- mempool_destroy(adapter->pool.scsi_req);
255
- if (adapter->pool.scsi_abort)
256
- mempool_destroy(adapter->pool.scsi_abort);
257
- if (adapter->pool.qtcb_pool)
258
- mempool_destroy(adapter->pool.qtcb_pool);
259
- if (adapter->pool.status_read_req)
260
- mempool_destroy(adapter->pool.status_read_req);
261
- if (adapter->pool.sr_data)
262
- mempool_destroy(adapter->pool.sr_data);
263
- if (adapter->pool.gid_pn)
264
- mempool_destroy(adapter->pool.gid_pn);
256
+ mempool_destroy(adapter->pool.erp_req);
257
+ mempool_destroy(adapter->pool.scsi_req);
258
+ mempool_destroy(adapter->pool.scsi_abort);
259
+ mempool_destroy(adapter->pool.qtcb_pool);
260
+ mempool_destroy(adapter->pool.status_read_req);
261
+ mempool_destroy(adapter->pool.sr_data);
262
+ mempool_destroy(adapter->pool.gid_pn);
265263 }
266264
267265 /**
268266 * zfcp_status_read_refill - refill the long running status_read_requests
269267 * @adapter: ptr to struct zfcp_adapter for which the buffers should be refilled
270268 *
271
- * Returns: 0 on success, 1 otherwise
272
- *
273
- * if there are 16 or more status_read requests missing an adapter_reopen
274
- * is triggered
269
+ * Return:
270
+ * * 0 on success meaning at least one status read is pending
271
+ * * 1 if posting failed and not a single status read buffer is pending,
272
+ * also triggers adapter reopen recovery
275273 */
276274 int zfcp_status_read_refill(struct zfcp_adapter *adapter)
277275 {
....@@ -360,6 +358,9 @@
360358
361359 adapter->erp_action.adapter = adapter;
362360
361
+ if (zfcp_diag_adapter_setup(adapter))
362
+ goto failed;
363
+
363364 if (zfcp_qdio_setup(adapter))
364365 goto failed;
365366
....@@ -406,14 +407,15 @@
406407 &zfcp_sysfs_adapter_attrs))
407408 goto failed;
408409
410
+ if (zfcp_diag_sysfs_setup(adapter))
411
+ goto failed;
412
+
409413 /* report size limit per scatter-gather segment */
410
- adapter->dma_parms.max_segment_size = ZFCP_QDIO_SBALE_LEN;
411414 adapter->ccw_device->dev.dma_parms = &adapter->dma_parms;
412415
413416 adapter->stat_read_buf_num = FSF_STATUS_READS_RECOM;
414417
415
- if (!zfcp_scsi_adapter_register(adapter))
416
- return adapter;
418
+ return adapter;
417419
418420 failed:
419421 zfcp_adapter_unregister(adapter);
....@@ -431,6 +433,7 @@
431433
432434 zfcp_fc_wka_ports_force_offline(adapter->gs);
433435 zfcp_scsi_adapter_unregister(adapter);
436
+ zfcp_diag_sysfs_destroy(adapter);
434437 sysfs_remove_group(&cdev->dev.kobj, &zfcp_sysfs_adapter_attrs);
435438
436439 zfcp_erp_thread_kill(adapter);
....@@ -454,6 +457,7 @@
454457 dev_set_drvdata(&adapter->ccw_device->dev, NULL);
455458 zfcp_fc_gs_destroy(adapter);
456459 zfcp_free_low_mem_buffers(adapter);
460
+ zfcp_diag_adapter_free(adapter);
457461 kfree(adapter->req_list);
458462 kfree(adapter->fc_stats);
459463 kfree(adapter->stats_reset_data);
....@@ -493,12 +497,12 @@
493497 if (port) {
494498 put_device(&port->dev);
495499 retval = -EEXIST;
496
- goto err_out;
500
+ goto err_put;
497501 }
498502
499503 port = kzalloc(sizeof(struct zfcp_port), GFP_KERNEL);
500504 if (!port)
501
- goto err_out;
505
+ goto err_put;
502506
503507 rwlock_init(&port->unit_list_lock);
504508 INIT_LIST_HEAD(&port->unit_list);
....@@ -521,7 +525,7 @@
521525
522526 if (dev_set_name(&port->dev, "0x%016llx", (unsigned long long)wwpn)) {
523527 kfree(port);
524
- goto err_out;
528
+ goto err_put;
525529 }
526530 retval = -EINVAL;
527531
....@@ -538,49 +542,8 @@
538542
539543 return port;
540544
541
-err_out:
545
+err_put:
542546 zfcp_ccw_adapter_put(adapter);
547
+err_out:
543548 return ERR_PTR(retval);
544
-}
545
-
546
-/**
547
- * zfcp_sg_free_table - free memory used by scatterlists
548
- * @sg: pointer to scatterlist
549
- * @count: number of scatterlist which are to be free'ed
550
- * the scatterlist are expected to reference pages always
551
- */
552
-void zfcp_sg_free_table(struct scatterlist *sg, int count)
553
-{
554
- int i;
555
-
556
- for (i = 0; i < count; i++, sg++)
557
- if (sg)
558
- free_page((unsigned long) sg_virt(sg));
559
- else
560
- break;
561
-}
562
-
563
-/**
564
- * zfcp_sg_setup_table - init scatterlist and allocate, assign buffers
565
- * @sg: pointer to struct scatterlist
566
- * @count: number of scatterlists which should be assigned with buffers
567
- * of size page
568
- *
569
- * Returns: 0 on success, -ENOMEM otherwise
570
- */
571
-int zfcp_sg_setup_table(struct scatterlist *sg, int count)
572
-{
573
- void *addr;
574
- int i;
575
-
576
- sg_init_table(sg, count);
577
- for (i = 0; i < count; i++, sg++) {
578
- addr = (void *) get_zeroed_page(GFP_KERNEL);
579
- if (!addr) {
580
- zfcp_sg_free_table(sg, i);
581
- return -ENOMEM;
582
- }
583
- sg_set_buf(sg, addr, PAGE_SIZE);
584
- }
585
- return 0;
586549 }