Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Bugreports.to..: <Linux390@de.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright IBM Corp. 1999, 2009
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #define KMSG_COMPONENT "dasd-fba"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/stddef.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <asm/debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/hdreg.h>	/* HDIO_GETGEO			    */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/bio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <asm/idals.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <asm/ebcdic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <asm/ccwdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include "dasd_int.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #include "dasd_fba.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #ifdef PRINTK_HEADER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #undef PRINTK_HEADER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #endif				/* PRINTK_HEADER */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define PRINTK_HEADER "dasd(fba):"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define FBA_DEFAULT_RETRIES 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define DASD_FBA_CCW_WRITE 0x41
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define DASD_FBA_CCW_READ 0x42
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define DASD_FBA_CCW_LOCATE 0x43
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define DASD_FBA_CCW_DEFINE_EXTENT 0x63
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) static struct dasd_discipline dasd_fba_discipline;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) static void *dasd_fba_zero_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) struct dasd_fba_private {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	struct dasd_fba_characteristics rdc_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) static struct ccw_device_id dasd_fba_ids[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	{ CCW_DEVICE_DEVTYPE (0x6310, 0, 0x9336, 0), .driver_info = 0x1},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	{ CCW_DEVICE_DEVTYPE (0x3880, 0, 0x3370, 0), .driver_info = 0x2},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	{ /* end of list */ },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) MODULE_DEVICE_TABLE(ccw, dasd_fba_ids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) static struct ccw_driver dasd_fba_driver; /* see below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) dasd_fba_probe(struct ccw_device *cdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	return dasd_generic_probe(cdev, &dasd_fba_discipline);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) dasd_fba_set_online(struct ccw_device *cdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	return dasd_generic_set_online(cdev, &dasd_fba_discipline);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) static struct ccw_driver dasd_fba_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		.name	= "dasd-fba",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		.owner	= THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	.ids         = dasd_fba_ids,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	.probe       = dasd_fba_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	.remove      = dasd_generic_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	.set_offline = dasd_generic_set_offline,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	.set_online  = dasd_fba_set_online,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	.notify      = dasd_generic_notify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	.path_event  = dasd_generic_path_event,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	.freeze      = dasd_generic_pm_freeze,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	.thaw	     = dasd_generic_restore_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	.restore     = dasd_generic_restore_device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	.int_class   = IRQIO_DAS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) define_extent(struct ccw1 * ccw, struct DE_fba_data *data, int rw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	      int blksize, int beg, int nr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	ccw->cmd_code = DASD_FBA_CCW_DEFINE_EXTENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	ccw->flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	ccw->count = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	ccw->cda = (__u32) __pa(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	memset(data, 0, sizeof (struct DE_fba_data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	if (rw == WRITE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		(data->mask).perm = 0x0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	else if (rw == READ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		(data->mask).perm = 0x1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		data->mask.perm = 0x2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	data->blk_size = blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	data->ext_loc = beg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	data->ext_end = nr - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) locate_record(struct ccw1 * ccw, struct LO_fba_data *data, int rw,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	      int block_nr, int block_ct)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	ccw->cmd_code = DASD_FBA_CCW_LOCATE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	ccw->flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	ccw->count = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	ccw->cda = (__u32) __pa(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	memset(data, 0, sizeof (struct LO_fba_data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	if (rw == WRITE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		data->operation.cmd = 0x5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	else if (rw == READ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		data->operation.cmd = 0x6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		data->operation.cmd = 0x8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	data->blk_nr = block_nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	data->blk_ct = block_ct;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) dasd_fba_check_characteristics(struct dasd_device *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	struct dasd_fba_private *private = device->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	struct ccw_device *cdev = device->cdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	struct dasd_block *block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	int readonly, rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	if (!private) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		private = kzalloc(sizeof(*private), GFP_KERNEL | GFP_DMA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		if (!private) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			dev_warn(&device->cdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 				 "Allocating memory for private DASD "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 				 "data failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 			return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		device->private = private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		memset(private, 0, sizeof(*private));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	block = dasd_alloc_block();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	if (IS_ERR(block)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s", "could not allocate "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 				"dasd block structure");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		device->private = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		kfree(private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		return PTR_ERR(block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	device->block = block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	block->base = device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	/* Read Device Characteristics */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	rc = dasd_generic_read_dev_chars(device, DASD_FBA_MAGIC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 					 &private->rdc_data, 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		DBF_EVENT_DEVID(DBF_WARNING, cdev, "Read device "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 				"characteristics returned error %d", rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		device->block = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		dasd_free_block(block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 		device->private = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		kfree(private);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	device->default_expires = DASD_EXPIRES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	device->default_retries = FBA_DEFAULT_RETRIES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	dasd_path_set_opm(device, LPM_ANYPATH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	readonly = dasd_device_is_ro(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	if (readonly)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		set_bit(DASD_FLAG_DEVICE_RO, &device->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	/* FBA supports discard, set the according feature bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	dasd_set_feature(cdev, DASD_FEATURE_DISCARD, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	dev_info(&device->cdev->dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		 "New FBA DASD %04X/%02X (CU %04X/%02X) with %d MB "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		 "and %d B/blk%s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		 cdev->id.dev_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		 cdev->id.dev_model,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		 cdev->id.cu_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		 cdev->id.cu_model,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		 ((private->rdc_data.blk_bdsa *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		   (private->rdc_data.blk_size >> 9)) >> 11),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		 private->rdc_data.blk_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		 readonly ? ", read-only device" : "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) static int dasd_fba_do_analysis(struct dasd_block *block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	struct dasd_fba_private *private = block->base->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	int sb, rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	rc = dasd_check_blocksize(private->rdc_data.blk_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	if (rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		DBF_DEV_EVENT(DBF_WARNING, block->base, "unknown blocksize %d",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 			    private->rdc_data.blk_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	block->blocks = private->rdc_data.blk_bdsa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	block->bp_block = private->rdc_data.blk_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	block->s2b_shift = 0;	/* bits to shift 512 to get a block */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	for (sb = 512; sb < private->rdc_data.blk_size; sb = sb << 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		block->s2b_shift++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) static int dasd_fba_fill_geometry(struct dasd_block *block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 				  struct hd_geometry *geo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	if (dasd_check_blocksize(block->bp_block) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	geo->cylinders = (block->blocks << block->s2b_shift) >> 10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	geo->heads = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	geo->sectors = 128 >> block->s2b_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) static dasd_erp_fn_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) dasd_fba_erp_action(struct dasd_ccw_req * cqr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	return dasd_default_erp_action;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) static dasd_erp_fn_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) dasd_fba_erp_postaction(struct dasd_ccw_req * cqr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	if (cqr->function == dasd_default_erp_action)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		return dasd_default_erp_postaction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	DBF_DEV_EVENT(DBF_WARNING, cqr->startdev, "unknown ERP action %p",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		    cqr->function);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) static void dasd_fba_check_for_device_change(struct dasd_device *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 					     struct dasd_ccw_req *cqr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 					     struct irb *irb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	char mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	/* first of all check for state change pending interrupt */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	mask = DEV_STAT_ATTENTION | DEV_STAT_DEV_END | DEV_STAT_UNIT_EXCEP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	if ((irb->scsw.cmd.dstat & mask) == mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		dasd_generic_handle_state_change(device);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)  * Builds a CCW with no data payload
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) static void ccw_write_no_data(struct ccw1 *ccw)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	ccw->cmd_code = DASD_FBA_CCW_WRITE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	ccw->flags |= CCW_FLAG_SLI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	ccw->count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)  * Builds a CCW that writes only zeroes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) static void ccw_write_zero(struct ccw1 *ccw, int count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	ccw->cmd_code = DASD_FBA_CCW_WRITE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	ccw->flags |= CCW_FLAG_SLI;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	ccw->count = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	ccw->cda = (__u32) (addr_t) dasd_fba_zero_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)  * Helper function to count the amount of necessary CCWs within a given range
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)  * with 4k alignment and command chaining in mind.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) static int count_ccws(sector_t first_rec, sector_t last_rec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		      unsigned int blocks_per_page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	sector_t wz_stop = 0, d_stop = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	int cur_pos = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	int count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	if (first_rec % blocks_per_page != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 		wz_stop = first_rec + blocks_per_page -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 			(first_rec % blocks_per_page) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		if (wz_stop > last_rec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 			wz_stop = last_rec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 		cur_pos = wz_stop - first_rec + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	if (last_rec - (first_rec + cur_pos) + 1 >= blocks_per_page) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		if ((last_rec - blocks_per_page + 1) % blocks_per_page != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 			d_stop = last_rec - ((last_rec - blocks_per_page + 1) %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 					     blocks_per_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 			d_stop = last_rec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		cur_pos += d_stop - (first_rec + cur_pos) + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	if (cur_pos == 0 || first_rec + cur_pos - 1 < last_rec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 		count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)  * This function builds a CCW request for block layer discard requests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)  * Each page in the z/VM hypervisor that represents certain records of an FBA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)  * device will be padded with zeros. This is a special behaviour of the WRITE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)  * command which is triggered when no data payload is added to the CCW.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)  * Note: Due to issues in some z/VM versions, we can't fully utilise this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)  * special behaviour. We have to keep a 4k (or 8 block) alignment in mind to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)  * work around those issues and write actual zeroes to the unaligned parts in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)  * the request. This workaround might be removed in the future.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) static struct dasd_ccw_req *dasd_fba_build_cp_discard(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 						struct dasd_device *memdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 						struct dasd_block *block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 						struct request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	struct LO_fba_data *LO_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	struct dasd_ccw_req *cqr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	struct ccw1 *ccw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	sector_t wz_stop = 0, d_stop = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	sector_t first_rec, last_rec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	unsigned int blksize = block->bp_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	unsigned int blocks_per_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	int wz_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	int d_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	int cur_pos = 0; /* Current position within the extent */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	int count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	int cplength;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	int datasize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	int nr_ccws;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	first_rec = blk_rq_pos(req) >> block->s2b_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	last_rec =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 		(blk_rq_pos(req) + blk_rq_sectors(req) - 1) >> block->s2b_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	count = last_rec - first_rec + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	blocks_per_page = BLOCKS_PER_PAGE(blksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	nr_ccws = count_ccws(first_rec, last_rec, blocks_per_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	/* define extent + nr_ccws * locate record + nr_ccws * single CCW */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 	cplength = 1 + 2 * nr_ccws;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	datasize = sizeof(struct DE_fba_data) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 		nr_ccws * (sizeof(struct LO_fba_data) + sizeof(struct ccw1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	cqr = dasd_smalloc_request(DASD_FBA_MAGIC, cplength, datasize, memdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 				   blk_mq_rq_to_pdu(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	if (IS_ERR(cqr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 		return cqr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	ccw = cqr->cpaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	define_extent(ccw++, cqr->data, WRITE, blksize, first_rec, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	LO_data = cqr->data + sizeof(struct DE_fba_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 	/* First part is not aligned. Calculate range to write zeroes. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	if (first_rec % blocks_per_page != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 		wz_stop = first_rec + blocks_per_page -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 			(first_rec % blocks_per_page) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 		if (wz_stop > last_rec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 			wz_stop = last_rec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 		wz_count = wz_stop - first_rec + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 		ccw[-1].flags |= CCW_FLAG_CC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 		locate_record(ccw++, LO_data++, WRITE, cur_pos, wz_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		ccw[-1].flags |= CCW_FLAG_CC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 		ccw_write_zero(ccw++, wz_count * blksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 		cur_pos = wz_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	/* We can do proper discard when we've got at least blocks_per_page blocks. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	if (last_rec - (first_rec + cur_pos) + 1 >= blocks_per_page) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 		/* is last record at page boundary? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 		if ((last_rec - blocks_per_page + 1) % blocks_per_page != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 			d_stop = last_rec - ((last_rec - blocks_per_page + 1) %
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 					     blocks_per_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 			d_stop = last_rec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 		d_count = d_stop - (first_rec + cur_pos) + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 		ccw[-1].flags |= CCW_FLAG_CC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 		locate_record(ccw++, LO_data++, WRITE, cur_pos, d_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 		ccw[-1].flags |= CCW_FLAG_CC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 		ccw_write_no_data(ccw++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 		cur_pos += d_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	/* We might still have some bits left which need to be zeroed. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	if (cur_pos == 0 || first_rec + cur_pos - 1 < last_rec) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 		if (d_stop != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 			wz_count = last_rec - d_stop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 		else if (wz_stop != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 			wz_count = last_rec - wz_stop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 			wz_count = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		ccw[-1].flags |= CCW_FLAG_CC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 		locate_record(ccw++, LO_data++, WRITE, cur_pos, wz_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 		ccw[-1].flags |= CCW_FLAG_CC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		ccw_write_zero(ccw++, wz_count * blksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	if (blk_noretry_request(req) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	    block->base->features & DASD_FEATURE_FAILFAST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 		set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	cqr->startdev = memdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	cqr->memdev = memdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	cqr->block = block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	cqr->expires = memdev->default_expires * HZ;	/* default 5 minutes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	cqr->retries = memdev->default_retries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	cqr->buildclk = get_tod_clock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 	cqr->status = DASD_CQR_FILLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	return cqr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) static struct dasd_ccw_req *dasd_fba_build_cp_regular(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 						struct dasd_device *memdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 						struct dasd_block *block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 						struct request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 	struct dasd_fba_private *private = block->base->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 	unsigned long *idaws;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	struct LO_fba_data *LO_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	struct dasd_ccw_req *cqr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	struct ccw1 *ccw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	struct req_iterator iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	struct bio_vec bv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 	char *dst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	int count, cidaw, cplength, datasize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	sector_t recid, first_rec, last_rec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	unsigned int blksize, off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	unsigned char cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	if (rq_data_dir(req) == READ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 		cmd = DASD_FBA_CCW_READ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	} else if (rq_data_dir(req) == WRITE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		cmd = DASD_FBA_CCW_WRITE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 		return ERR_PTR(-EINVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	blksize = block->bp_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	/* Calculate record id of first and last block. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	first_rec = blk_rq_pos(req) >> block->s2b_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	last_rec =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 		(blk_rq_pos(req) + blk_rq_sectors(req) - 1) >> block->s2b_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	/* Check struct bio and count the number of blocks for the request. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	cidaw = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	rq_for_each_segment(bv, req, iter) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 		if (bv.bv_len & (blksize - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 			/* Fba can only do full blocks. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 			return ERR_PTR(-EINVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 		count += bv.bv_len >> (block->s2b_shift + 9);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 		if (idal_is_needed (page_address(bv.bv_page), bv.bv_len))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 			cidaw += bv.bv_len / blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	/* Paranoia. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 	if (count != last_rec - first_rec + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 		return ERR_PTR(-EINVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 	/* 1x define extent + 1x locate record + number of blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	cplength = 2 + count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	/* 1x define extent + 1x locate record */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 	datasize = sizeof(struct DE_fba_data) + sizeof(struct LO_fba_data) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 		cidaw * sizeof(unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	 * Find out number of additional locate record ccws if the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 	 * can't do data chaining.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	if (private->rdc_data.mode.bits.data_chain == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 		cplength += count - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 		datasize += (count - 1)*sizeof(struct LO_fba_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	/* Allocate the ccw request. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	cqr = dasd_smalloc_request(DASD_FBA_MAGIC, cplength, datasize, memdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 				   blk_mq_rq_to_pdu(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	if (IS_ERR(cqr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 		return cqr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 	ccw = cqr->cpaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 	/* First ccw is define extent. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 	define_extent(ccw++, cqr->data, rq_data_dir(req),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 		      block->bp_block, blk_rq_pos(req), blk_rq_sectors(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 	/* Build locate_record + read/write ccws. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 	idaws = (unsigned long *) (cqr->data + sizeof(struct DE_fba_data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 	LO_data = (struct LO_fba_data *) (idaws + cidaw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 	/* Locate record for all blocks for smart devices. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 	if (private->rdc_data.mode.bits.data_chain != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 		ccw[-1].flags |= CCW_FLAG_CC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 		locate_record(ccw++, LO_data++, rq_data_dir(req), 0, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 	recid = first_rec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 	rq_for_each_segment(bv, req, iter) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 		dst = page_address(bv.bv_page) + bv.bv_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 		if (dasd_page_cache) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 			char *copy = kmem_cache_alloc(dasd_page_cache,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 						      GFP_DMA | __GFP_NOWARN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 			if (copy && rq_data_dir(req) == WRITE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 				memcpy(copy + bv.bv_offset, dst, bv.bv_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 			if (copy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 				dst = copy + bv.bv_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 		for (off = 0; off < bv.bv_len; off += blksize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 			/* Locate record for stupid devices. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 			if (private->rdc_data.mode.bits.data_chain == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 				ccw[-1].flags |= CCW_FLAG_CC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 				locate_record(ccw, LO_data++,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 					      rq_data_dir(req),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 					      recid - first_rec, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 				ccw->flags = CCW_FLAG_CC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 				ccw++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 				if (recid > first_rec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 					ccw[-1].flags |= CCW_FLAG_DC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 				else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 					ccw[-1].flags |= CCW_FLAG_CC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 			ccw->cmd_code = cmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 			ccw->count = block->bp_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 			if (idal_is_needed(dst, blksize)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 				ccw->cda = (__u32)(addr_t) idaws;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 				ccw->flags = CCW_FLAG_IDA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 				idaws = idal_create_words(idaws, dst, blksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 				ccw->cda = (__u32)(addr_t) dst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 				ccw->flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 			ccw++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 			dst += blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 			recid++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 	if (blk_noretry_request(req) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	    block->base->features & DASD_FEATURE_FAILFAST)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 		set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 	cqr->startdev = memdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 	cqr->memdev = memdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 	cqr->block = block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 	cqr->expires = memdev->default_expires * HZ;	/* default 5 minutes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 	cqr->retries = memdev->default_retries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	cqr->buildclk = get_tod_clock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 	cqr->status = DASD_CQR_FILLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 	return cqr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) static struct dasd_ccw_req *dasd_fba_build_cp(struct dasd_device *memdev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 					      struct dasd_block *block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 					      struct request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 	if (req_op(req) == REQ_OP_DISCARD || req_op(req) == REQ_OP_WRITE_ZEROES)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 		return dasd_fba_build_cp_discard(memdev, block, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 		return dasd_fba_build_cp_regular(memdev, block, req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) dasd_fba_free_cp(struct dasd_ccw_req *cqr, struct request *req)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 	struct dasd_fba_private *private = cqr->block->base->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	struct ccw1 *ccw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 	struct req_iterator iter;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 	struct bio_vec bv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	char *dst, *cda;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 	unsigned int blksize, off;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 	int status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 	if (!dasd_page_cache)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 	blksize = cqr->block->bp_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 	ccw = cqr->cpaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 	/* Skip over define extent & locate record. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 	ccw++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 	if (private->rdc_data.mode.bits.data_chain != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 		ccw++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 	rq_for_each_segment(bv, req, iter) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 		dst = page_address(bv.bv_page) + bv.bv_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 		for (off = 0; off < bv.bv_len; off += blksize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 			/* Skip locate record. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 			if (private->rdc_data.mode.bits.data_chain == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 				ccw++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 			if (dst) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 				if (ccw->flags & CCW_FLAG_IDA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 					cda = *((char **)((addr_t) ccw->cda));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 				else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 					cda = (char *)((addr_t) ccw->cda);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 				if (dst != cda) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 					if (rq_data_dir(req) == READ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 						memcpy(dst, cda, bv.bv_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 					kmem_cache_free(dasd_page_cache,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 					    (void *)((addr_t)cda & PAGE_MASK));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 				dst = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 			ccw++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 	status = cqr->status == DASD_CQR_DONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 	dasd_sfree_request(cqr, cqr->memdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) static void dasd_fba_handle_terminated_request(struct dasd_ccw_req *cqr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 	if (cqr->retries < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) 		cqr->status = DASD_CQR_FAILED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 		cqr->status = DASD_CQR_FILLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) dasd_fba_fill_info(struct dasd_device * device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 		   struct dasd_information2_t * info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 	struct dasd_fba_private *private = device->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 	info->label_block = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 	info->FBA_layout = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 	info->format = DASD_FORMAT_LDL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 	info->characteristics_size = sizeof(private->rdc_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 	memcpy(info->characteristics, &private->rdc_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 	       sizeof(private->rdc_data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 	info->confdata_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) dasd_fba_dump_sense_dbf(struct dasd_device *device, struct irb *irb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) 			char *reason)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) 	u64 *sense;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) 	sense = (u64 *) dasd_get_sense(irb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) 	if (sense) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) 		DBF_DEV_EVENT(DBF_EMERG, device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) 			      "%s: %s %02x%02x%02x %016llx %016llx %016llx "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) 			      "%016llx", reason,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) 			      scsw_is_tm(&irb->scsw) ? "t" : "c",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) 			      scsw_cc(&irb->scsw), scsw_cstat(&irb->scsw),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) 			      scsw_dstat(&irb->scsw), sense[0], sense[1],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) 			      sense[2], sense[3]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) 		DBF_DEV_EVENT(DBF_EMERG, device, "%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) 			      "SORRY - NO VALID SENSE AVAILABLE\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) dasd_fba_dump_sense(struct dasd_device *device, struct dasd_ccw_req * req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) 		    struct irb *irb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) 	char *page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) 	struct ccw1 *act, *end, *last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) 	int len, sl, sct, count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) 	page = (char *) get_zeroed_page(GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) 	if (page == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) 		DBF_DEV_EVENT(DBF_WARNING, device, "%s",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) 			    "No memory to dump sense data");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) 	len = sprintf(page, PRINTK_HEADER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) 		      " I/O status report for device %s:\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) 		      dev_name(&device->cdev->dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) 	len += sprintf(page + len, PRINTK_HEADER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) 		       " in req: %p CS: 0x%02X DS: 0x%02X\n", req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) 		       irb->scsw.cmd.cstat, irb->scsw.cmd.dstat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) 	len += sprintf(page + len, PRINTK_HEADER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) 		       " device %s: Failing CCW: %p\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) 		       dev_name(&device->cdev->dev),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) 		       (void *) (addr_t) irb->scsw.cmd.cpa);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) 	if (irb->esw.esw0.erw.cons) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) 		for (sl = 0; sl < 4; sl++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) 			len += sprintf(page + len, PRINTK_HEADER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) 				       " Sense(hex) %2d-%2d:",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) 				       (8 * sl), ((8 * sl) + 7));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) 			for (sct = 0; sct < 8; sct++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) 				len += sprintf(page + len, " %02x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) 					       irb->ecw[8 * sl + sct]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) 			len += sprintf(page + len, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) 		len += sprintf(page + len, PRINTK_HEADER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) 			       " SORRY - NO VALID SENSE AVAILABLE\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) 	printk(KERN_ERR "%s", page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) 	/* dump the Channel Program */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) 	/* print first CCWs (maximum 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) 	act = req->cpaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713)         for (last = act; last->flags & (CCW_FLAG_CC | CCW_FLAG_DC); last++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) 	end = min(act + 8, last);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) 	len = sprintf(page, PRINTK_HEADER " Related CP in req: %p\n", req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) 	while (act <= end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) 		len += sprintf(page + len, PRINTK_HEADER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) 			       " CCW %p: %08X %08X DAT:",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) 			       act, ((int *) act)[0], ((int *) act)[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) 		for (count = 0; count < 32 && count < act->count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) 		     count += sizeof(int))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) 			len += sprintf(page + len, " %08X",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) 				       ((int *) (addr_t) act->cda)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) 				       [(count>>2)]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) 		len += sprintf(page + len, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) 		act++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) 	printk(KERN_ERR "%s", page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) 	/* print failing CCW area */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) 	len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) 	if (act <  ((struct ccw1 *)(addr_t) irb->scsw.cmd.cpa) - 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) 		act = ((struct ccw1 *)(addr_t) irb->scsw.cmd.cpa) - 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) 		len += sprintf(page + len, PRINTK_HEADER "......\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) 	end = min((struct ccw1 *)(addr_t) irb->scsw.cmd.cpa + 2, last);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) 	while (act <= end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) 		len += sprintf(page + len, PRINTK_HEADER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) 			       " CCW %p: %08X %08X DAT:",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) 			       act, ((int *) act)[0], ((int *) act)[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) 		for (count = 0; count < 32 && count < act->count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) 		     count += sizeof(int))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) 			len += sprintf(page + len, " %08X",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) 				       ((int *) (addr_t) act->cda)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) 				       [(count>>2)]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) 		len += sprintf(page + len, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) 		act++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) 	/* print last CCWs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) 	if (act <  last - 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) 		act = last - 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) 		len += sprintf(page + len, PRINTK_HEADER "......\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) 	while (act <= last) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) 		len += sprintf(page + len, PRINTK_HEADER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) 			       " CCW %p: %08X %08X DAT:",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) 			       act, ((int *) act)[0], ((int *) act)[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) 		for (count = 0; count < 32 && count < act->count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) 		     count += sizeof(int))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) 			len += sprintf(page + len, " %08X",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) 				       ((int *) (addr_t) act->cda)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) 				       [(count>>2)]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) 		len += sprintf(page + len, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) 		act++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) 	if (len > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) 		printk(KERN_ERR "%s", page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) 	free_page((unsigned long) page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774)  * Initialize block layer request queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) static void dasd_fba_setup_blk_queue(struct dasd_block *block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) 	unsigned int logical_block_size = block->bp_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) 	struct request_queue *q = block->request_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) 	unsigned int max_bytes, max_discard_sectors;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) 	int max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) 	max = DASD_FBA_MAX_BLOCKS << block->s2b_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) 	blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) 	q->limits.max_dev_sectors = max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) 	blk_queue_logical_block_size(q, logical_block_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) 	blk_queue_max_hw_sectors(q, max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) 	blk_queue_max_segments(q, USHRT_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) 	/* With page sized segments each segment can be translated into one idaw/tidaw */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) 	blk_queue_max_segment_size(q, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) 	blk_queue_segment_boundary(q, PAGE_SIZE - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) 	q->limits.discard_granularity = logical_block_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) 	q->limits.discard_alignment = PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) 	/* Calculate max_discard_sectors and make it PAGE aligned */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) 	max_bytes = USHRT_MAX * logical_block_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) 	max_bytes = ALIGN_DOWN(max_bytes, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) 	max_discard_sectors = max_bytes / logical_block_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) 	blk_queue_max_discard_sectors(q, max_discard_sectors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) 	blk_queue_max_write_zeroes_sectors(q, max_discard_sectors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) 	blk_queue_flag_set(QUEUE_FLAG_DISCARD, q);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) static struct dasd_discipline dasd_fba_discipline = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) 	.owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) 	.name = "FBA ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) 	.ebcname = "FBA ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) 	.check_device = dasd_fba_check_characteristics,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) 	.do_analysis = dasd_fba_do_analysis,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) 	.verify_path = dasd_generic_verify_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) 	.setup_blk_queue = dasd_fba_setup_blk_queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) 	.fill_geometry = dasd_fba_fill_geometry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) 	.start_IO = dasd_start_IO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) 	.term_IO = dasd_term_IO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) 	.handle_terminated_request = dasd_fba_handle_terminated_request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) 	.erp_action = dasd_fba_erp_action,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) 	.erp_postaction = dasd_fba_erp_postaction,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) 	.check_for_device_change = dasd_fba_check_for_device_change,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) 	.build_cp = dasd_fba_build_cp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) 	.free_cp = dasd_fba_free_cp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) 	.dump_sense = dasd_fba_dump_sense,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) 	.dump_sense_dbf = dasd_fba_dump_sense_dbf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) 	.fill_info = dasd_fba_fill_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) static int __init
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) dasd_fba_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) 	ASCEBC(dasd_fba_discipline.ebcname, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) 	dasd_fba_zero_page = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) 	if (!dasd_fba_zero_page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) 	ret = ccw_driver_register(&dasd_fba_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) 	if (!ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) 		wait_for_device_probe();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) static void __exit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) dasd_fba_cleanup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) 	ccw_driver_unregister(&dasd_fba_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) 	free_page((unsigned long)dasd_fba_zero_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) module_init(dasd_fba_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) module_exit(dasd_fba_cleanup);