Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * File...........: linux/drivers/s390/block/dasd.c |
| 3 | * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> |
| 4 | * Horst Hummel <Horst.Hummel@de.ibm.com> |
| 5 | * Carsten Otte <Cotte@de.ibm.com> |
| 6 | * Martin Schwidefsky <schwidefsky@de.ibm.com> |
| 7 | * Bugreports.to..: <Linux390@de.ibm.com> |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 8 | * Copyright IBM Corp. 1999, 2009 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | */ |
| 10 | |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 11 | #define KMSG_COMPONENT "dasd" |
| 12 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
| 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/kmod.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/interrupt.h> |
| 17 | #include <linux/ctype.h> |
| 18 | #include <linux/major.h> |
| 19 | #include <linux/slab.h> |
| 20 | #include <linux/buffer_head.h> |
Christoph Hellwig | a885c8c | 2006-01-08 01:02:50 -0800 | [diff] [blame] | 21 | #include <linux/hdreg.h> |
Cornelia Huck | f3445a1 | 2009-04-14 15:36:23 +0200 | [diff] [blame] | 22 | #include <linux/async.h> |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame^] | 23 | #include <linux/mutex.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
| 25 | #include <asm/ccwdev.h> |
| 26 | #include <asm/ebcdic.h> |
| 27 | #include <asm/idals.h> |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 28 | #include <asm/itcw.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | |
| 30 | /* This is ugly... */ |
| 31 | #define PRINTK_HEADER "dasd:" |
| 32 | |
| 33 | #include "dasd_int.h" |
| 34 | /* |
| 35 | * SECTION: Constant definitions to be used within this file |
| 36 | */ |
| 37 | #define DASD_CHANQ_MAX_SIZE 4 |
| 38 | |
| 39 | /* |
| 40 | * SECTION: exported variables of dasd.c |
| 41 | */ |
| 42 | debug_info_t *dasd_debug_area; |
| 43 | struct dasd_discipline *dasd_diag_discipline_pointer; |
Heiko Carstens | 2b67fc4 | 2007-02-05 21:16:47 +0100 | [diff] [blame] | 44 | void dasd_int_handler(struct ccw_device *, unsigned long, struct irb *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
| 46 | MODULE_AUTHOR("Holger Smolinski <Holger.Smolinski@de.ibm.com>"); |
| 47 | MODULE_DESCRIPTION("Linux on S/390 DASD device driver," |
| 48 | " Copyright 2000 IBM Corporation"); |
| 49 | MODULE_SUPPORTED_DEVICE("dasd"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | MODULE_LICENSE("GPL"); |
| 51 | |
| 52 | /* |
| 53 | * SECTION: prototypes for static functions of dasd.c |
| 54 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 55 | static int dasd_alloc_queue(struct dasd_block *); |
| 56 | static void dasd_setup_queue(struct dasd_block *); |
| 57 | static void dasd_free_queue(struct dasd_block *); |
| 58 | static void dasd_flush_request_queue(struct dasd_block *); |
| 59 | static int dasd_flush_block_queue(struct dasd_block *); |
| 60 | static void dasd_device_tasklet(struct dasd_device *); |
| 61 | static void dasd_block_tasklet(struct dasd_block *); |
Al Viro | 4927b3f | 2006-12-06 19:18:20 +0000 | [diff] [blame] | 62 | static void do_kick_device(struct work_struct *); |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 63 | static void do_restore_device(struct work_struct *); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 64 | static void dasd_return_cqr_cb(struct dasd_ccw_req *, void *); |
Stefan Weinhuber | 48cae88 | 2009-02-11 10:37:31 +0100 | [diff] [blame] | 65 | static void dasd_device_timeout(unsigned long); |
| 66 | static void dasd_block_timeout(unsigned long); |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 67 | static void __dasd_process_erp(struct dasd_device *, struct dasd_ccw_req *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
| 69 | /* |
| 70 | * SECTION: Operations on the device structure. |
| 71 | */ |
| 72 | static wait_queue_head_t dasd_init_waitq; |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 73 | static wait_queue_head_t dasd_flush_wq; |
Stefan Haberland | c80ee72 | 2008-05-30 10:03:31 +0200 | [diff] [blame] | 74 | static wait_queue_head_t generic_waitq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
| 76 | /* |
| 77 | * Allocate memory for a new device structure. |
| 78 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 79 | struct dasd_device *dasd_alloc_device(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | { |
| 81 | struct dasd_device *device; |
| 82 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 83 | device = kzalloc(sizeof(struct dasd_device), GFP_ATOMIC); |
| 84 | if (!device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | return ERR_PTR(-ENOMEM); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | |
| 87 | /* Get two pages for normal block device operations. */ |
| 88 | device->ccw_mem = (void *) __get_free_pages(GFP_ATOMIC | GFP_DMA, 1); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 89 | if (!device->ccw_mem) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | kfree(device); |
| 91 | return ERR_PTR(-ENOMEM); |
| 92 | } |
| 93 | /* Get one page for error recovery. */ |
| 94 | device->erp_mem = (void *) get_zeroed_page(GFP_ATOMIC | GFP_DMA); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 95 | if (!device->erp_mem) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | free_pages((unsigned long) device->ccw_mem, 1); |
| 97 | kfree(device); |
| 98 | return ERR_PTR(-ENOMEM); |
| 99 | } |
| 100 | |
| 101 | dasd_init_chunklist(&device->ccw_chunks, device->ccw_mem, PAGE_SIZE*2); |
| 102 | dasd_init_chunklist(&device->erp_chunks, device->erp_mem, PAGE_SIZE); |
| 103 | spin_lock_init(&device->mem_lock); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 104 | atomic_set(&device->tasklet_scheduled, 0); |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 105 | tasklet_init(&device->tasklet, |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 106 | (void (*)(unsigned long)) dasd_device_tasklet, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | (unsigned long) device); |
| 108 | INIT_LIST_HEAD(&device->ccw_queue); |
| 109 | init_timer(&device->timer); |
Stefan Weinhuber | 48cae88 | 2009-02-11 10:37:31 +0100 | [diff] [blame] | 110 | device->timer.function = dasd_device_timeout; |
| 111 | device->timer.data = (unsigned long) device; |
Al Viro | 4927b3f | 2006-12-06 19:18:20 +0000 | [diff] [blame] | 112 | INIT_WORK(&device->kick_work, do_kick_device); |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 113 | INIT_WORK(&device->restore_device, do_restore_device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | device->state = DASD_STATE_NEW; |
| 115 | device->target = DASD_STATE_NEW; |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame^] | 116 | mutex_init(&device->state_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | |
| 118 | return device; |
| 119 | } |
| 120 | |
| 121 | /* |
| 122 | * Free memory of a device structure. |
| 123 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 124 | void dasd_free_device(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | { |
Jesper Juhl | 17fd682 | 2005-11-07 01:01:30 -0800 | [diff] [blame] | 126 | kfree(device->private); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | free_page((unsigned long) device->erp_mem); |
| 128 | free_pages((unsigned long) device->ccw_mem, 1); |
| 129 | kfree(device); |
| 130 | } |
| 131 | |
| 132 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 133 | * Allocate memory for a new device structure. |
| 134 | */ |
| 135 | struct dasd_block *dasd_alloc_block(void) |
| 136 | { |
| 137 | struct dasd_block *block; |
| 138 | |
| 139 | block = kzalloc(sizeof(*block), GFP_ATOMIC); |
| 140 | if (!block) |
| 141 | return ERR_PTR(-ENOMEM); |
| 142 | /* open_count = 0 means device online but not in use */ |
| 143 | atomic_set(&block->open_count, -1); |
| 144 | |
| 145 | spin_lock_init(&block->request_queue_lock); |
| 146 | atomic_set(&block->tasklet_scheduled, 0); |
| 147 | tasklet_init(&block->tasklet, |
| 148 | (void (*)(unsigned long)) dasd_block_tasklet, |
| 149 | (unsigned long) block); |
| 150 | INIT_LIST_HEAD(&block->ccw_queue); |
| 151 | spin_lock_init(&block->queue_lock); |
| 152 | init_timer(&block->timer); |
Stefan Weinhuber | 48cae88 | 2009-02-11 10:37:31 +0100 | [diff] [blame] | 153 | block->timer.function = dasd_block_timeout; |
| 154 | block->timer.data = (unsigned long) block; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 155 | |
| 156 | return block; |
| 157 | } |
| 158 | |
| 159 | /* |
| 160 | * Free memory of a device structure. |
| 161 | */ |
| 162 | void dasd_free_block(struct dasd_block *block) |
| 163 | { |
| 164 | kfree(block); |
| 165 | } |
| 166 | |
| 167 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | * Make a new device known to the system. |
| 169 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 170 | static int dasd_state_new_to_known(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | { |
| 172 | int rc; |
| 173 | |
| 174 | /* |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 175 | * As long as the device is not in state DASD_STATE_NEW we want to |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | * keep the reference count > 0. |
| 177 | */ |
| 178 | dasd_get_device(device); |
| 179 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 180 | if (device->block) { |
| 181 | rc = dasd_alloc_queue(device->block); |
| 182 | if (rc) { |
| 183 | dasd_put_device(device); |
| 184 | return rc; |
| 185 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | device->state = DASD_STATE_KNOWN; |
| 188 | return 0; |
| 189 | } |
| 190 | |
| 191 | /* |
| 192 | * Let the system forget about a device. |
| 193 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 194 | static int dasd_state_known_to_new(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | { |
Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 196 | /* Disable extended error reporting for this device. */ |
| 197 | dasd_eer_disable(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | /* Forget the discipline information. */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 199 | if (device->discipline) { |
| 200 | if (device->discipline->uncheck_device) |
| 201 | device->discipline->uncheck_device(device); |
Peter Oberparleiter | aa88861 | 2006-02-20 18:28:13 -0800 | [diff] [blame] | 202 | module_put(device->discipline->owner); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 203 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | device->discipline = NULL; |
Peter Oberparleiter | aa88861 | 2006-02-20 18:28:13 -0800 | [diff] [blame] | 205 | if (device->base_discipline) |
| 206 | module_put(device->base_discipline->owner); |
| 207 | device->base_discipline = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | device->state = DASD_STATE_NEW; |
| 209 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 210 | if (device->block) |
| 211 | dasd_free_queue(device->block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | |
| 213 | /* Give up reference we took in dasd_state_new_to_known. */ |
| 214 | dasd_put_device(device); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 215 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | /* |
| 219 | * Request the irq line for the device. |
| 220 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 221 | static int dasd_state_known_to_basic(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | { |
| 223 | int rc; |
| 224 | |
| 225 | /* Allocate and register gendisk structure. */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 226 | if (device->block) { |
| 227 | rc = dasd_gendisk_alloc(device->block); |
| 228 | if (rc) |
| 229 | return rc; |
| 230 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | /* register 'device' debug area, used for all DBF_DEV_XXX calls */ |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 232 | device->debug_area = debug_register(dev_name(&device->cdev->dev), 4, 1, |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 233 | 8 * sizeof(long)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | debug_register_view(device->debug_area, &debug_sprintf_view); |
Horst Hummel | b0035f1 | 2006-09-20 15:59:07 +0200 | [diff] [blame] | 235 | debug_set_level(device->debug_area, DBF_WARNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | DBF_DEV_EVENT(DBF_EMERG, device, "%s", "debug area created"); |
| 237 | |
| 238 | device->state = DASD_STATE_BASIC; |
| 239 | return 0; |
| 240 | } |
| 241 | |
| 242 | /* |
| 243 | * Release the irq line for the device. Terminate any running i/o. |
| 244 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 245 | static int dasd_state_basic_to_known(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | { |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 247 | int rc; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 248 | if (device->block) { |
| 249 | dasd_gendisk_free(device->block); |
| 250 | dasd_block_clear_timer(device->block); |
| 251 | } |
| 252 | rc = dasd_flush_device_queue(device); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 253 | if (rc) |
| 254 | return rc; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 255 | dasd_device_clear_timer(device); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 256 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | DBF_DEV_EVENT(DBF_EMERG, device, "%p debug area deleted", device); |
| 258 | if (device->debug_area != NULL) { |
| 259 | debug_unregister(device->debug_area); |
| 260 | device->debug_area = NULL; |
| 261 | } |
| 262 | device->state = DASD_STATE_KNOWN; |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 263 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | /* |
| 267 | * Do the initial analysis. The do_analysis function may return |
| 268 | * -EAGAIN in which case the device keeps the state DASD_STATE_BASIC |
| 269 | * until the discipline decides to continue the startup sequence |
| 270 | * by calling the function dasd_change_state. The eckd disciplines |
| 271 | * uses this to start a ccw that detects the format. The completion |
| 272 | * interrupt for this detection ccw uses the kernel event daemon to |
| 273 | * trigger the call to dasd_change_state. All this is done in the |
| 274 | * discipline code, see dasd_eckd.c. |
Horst Hummel | 90f0094 | 2006-03-07 21:55:39 -0800 | [diff] [blame] | 275 | * After the analysis ccw is done (do_analysis returned 0) the block |
| 276 | * device is setup. |
| 277 | * In case the analysis returns an error, the device setup is stopped |
| 278 | * (a fake disk was already added to allow formatting). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 280 | static int dasd_state_basic_to_ready(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | { |
| 282 | int rc; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 283 | struct dasd_block *block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | |
| 285 | rc = 0; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 286 | block = device->block; |
Horst Hummel | 90f0094 | 2006-03-07 21:55:39 -0800 | [diff] [blame] | 287 | /* make disk known with correct capacity */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 288 | if (block) { |
| 289 | if (block->base->discipline->do_analysis != NULL) |
| 290 | rc = block->base->discipline->do_analysis(block); |
| 291 | if (rc) { |
| 292 | if (rc != -EAGAIN) |
| 293 | device->state = DASD_STATE_UNFMT; |
| 294 | return rc; |
| 295 | } |
| 296 | dasd_setup_queue(block); |
| 297 | set_capacity(block->gdp, |
| 298 | block->blocks << block->s2b_shift); |
| 299 | device->state = DASD_STATE_READY; |
| 300 | rc = dasd_scan_partitions(block); |
| 301 | if (rc) |
| 302 | device->state = DASD_STATE_BASIC; |
| 303 | } else { |
| 304 | device->state = DASD_STATE_READY; |
| 305 | } |
Horst Hummel | 90f0094 | 2006-03-07 21:55:39 -0800 | [diff] [blame] | 306 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | /* |
| 310 | * Remove device from block device layer. Destroy dirty buffers. |
| 311 | * Forget format information. Check if the target level is basic |
| 312 | * and if it is create fake disk for formatting. |
| 313 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 314 | static int dasd_state_ready_to_basic(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | { |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 316 | int rc; |
| 317 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | device->state = DASD_STATE_BASIC; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 319 | if (device->block) { |
| 320 | struct dasd_block *block = device->block; |
| 321 | rc = dasd_flush_block_queue(block); |
| 322 | if (rc) { |
| 323 | device->state = DASD_STATE_READY; |
| 324 | return rc; |
| 325 | } |
| 326 | dasd_destroy_partitions(block); |
| 327 | dasd_flush_request_queue(block); |
| 328 | block->blocks = 0; |
| 329 | block->bp_block = 0; |
| 330 | block->s2b_shift = 0; |
| 331 | } |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 332 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | /* |
Horst Hummel | 90f0094 | 2006-03-07 21:55:39 -0800 | [diff] [blame] | 336 | * Back to basic. |
| 337 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 338 | static int dasd_state_unfmt_to_basic(struct dasd_device *device) |
Horst Hummel | 90f0094 | 2006-03-07 21:55:39 -0800 | [diff] [blame] | 339 | { |
| 340 | device->state = DASD_STATE_BASIC; |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 341 | return 0; |
Horst Hummel | 90f0094 | 2006-03-07 21:55:39 -0800 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | * Make the device online and schedule the bottom half to start |
| 346 | * the requeueing of requests from the linux request queue to the |
| 347 | * ccw queue. |
| 348 | */ |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 349 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | dasd_state_ready_to_online(struct dasd_device * device) |
| 351 | { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 352 | int rc; |
Stefan Weinhuber | 1301809 | 2009-01-09 12:14:50 +0100 | [diff] [blame] | 353 | struct gendisk *disk; |
| 354 | struct disk_part_iter piter; |
| 355 | struct hd_struct *part; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 356 | |
| 357 | if (device->discipline->ready_to_online) { |
| 358 | rc = device->discipline->ready_to_online(device); |
| 359 | if (rc) |
| 360 | return rc; |
| 361 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | device->state = DASD_STATE_ONLINE; |
Stefan Weinhuber | 1301809 | 2009-01-09 12:14:50 +0100 | [diff] [blame] | 363 | if (device->block) { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 364 | dasd_schedule_block_bh(device->block); |
Stefan Weinhuber | 1301809 | 2009-01-09 12:14:50 +0100 | [diff] [blame] | 365 | disk = device->block->bdev->bd_disk; |
| 366 | disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0); |
| 367 | while ((part = disk_part_iter_next(&piter))) |
| 368 | kobject_uevent(&part_to_dev(part)->kobj, KOBJ_CHANGE); |
| 369 | disk_part_iter_exit(&piter); |
| 370 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | return 0; |
| 372 | } |
| 373 | |
| 374 | /* |
| 375 | * Stop the requeueing of requests again. |
| 376 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 377 | static int dasd_state_online_to_ready(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 379 | int rc; |
Stefan Weinhuber | 1301809 | 2009-01-09 12:14:50 +0100 | [diff] [blame] | 380 | struct gendisk *disk; |
| 381 | struct disk_part_iter piter; |
| 382 | struct hd_struct *part; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 383 | |
| 384 | if (device->discipline->online_to_ready) { |
| 385 | rc = device->discipline->online_to_ready(device); |
| 386 | if (rc) |
| 387 | return rc; |
| 388 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | device->state = DASD_STATE_READY; |
Stefan Weinhuber | 1301809 | 2009-01-09 12:14:50 +0100 | [diff] [blame] | 390 | if (device->block) { |
| 391 | disk = device->block->bdev->bd_disk; |
| 392 | disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0); |
| 393 | while ((part = disk_part_iter_next(&piter))) |
| 394 | kobject_uevent(&part_to_dev(part)->kobj, KOBJ_CHANGE); |
| 395 | disk_part_iter_exit(&piter); |
| 396 | } |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 397 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | /* |
| 401 | * Device startup state changes. |
| 402 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 403 | static int dasd_increase_state(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | { |
| 405 | int rc; |
| 406 | |
| 407 | rc = 0; |
| 408 | if (device->state == DASD_STATE_NEW && |
| 409 | device->target >= DASD_STATE_KNOWN) |
| 410 | rc = dasd_state_new_to_known(device); |
| 411 | |
| 412 | if (!rc && |
| 413 | device->state == DASD_STATE_KNOWN && |
| 414 | device->target >= DASD_STATE_BASIC) |
| 415 | rc = dasd_state_known_to_basic(device); |
| 416 | |
| 417 | if (!rc && |
| 418 | device->state == DASD_STATE_BASIC && |
| 419 | device->target >= DASD_STATE_READY) |
| 420 | rc = dasd_state_basic_to_ready(device); |
| 421 | |
| 422 | if (!rc && |
Horst Hummel | 39ccf95 | 2006-04-27 18:40:10 -0700 | [diff] [blame] | 423 | device->state == DASD_STATE_UNFMT && |
| 424 | device->target > DASD_STATE_UNFMT) |
| 425 | rc = -EPERM; |
| 426 | |
| 427 | if (!rc && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 428 | device->state == DASD_STATE_READY && |
| 429 | device->target >= DASD_STATE_ONLINE) |
| 430 | rc = dasd_state_ready_to_online(device); |
| 431 | |
| 432 | return rc; |
| 433 | } |
| 434 | |
| 435 | /* |
| 436 | * Device shutdown state changes. |
| 437 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 438 | static int dasd_decrease_state(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | { |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 440 | int rc; |
| 441 | |
| 442 | rc = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 443 | if (device->state == DASD_STATE_ONLINE && |
| 444 | device->target <= DASD_STATE_READY) |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 445 | rc = dasd_state_online_to_ready(device); |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 446 | |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 447 | if (!rc && |
| 448 | device->state == DASD_STATE_READY && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | device->target <= DASD_STATE_BASIC) |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 450 | rc = dasd_state_ready_to_basic(device); |
Horst Hummel | 90f0094 | 2006-03-07 21:55:39 -0800 | [diff] [blame] | 451 | |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 452 | if (!rc && |
| 453 | device->state == DASD_STATE_UNFMT && |
Horst Hummel | 90f0094 | 2006-03-07 21:55:39 -0800 | [diff] [blame] | 454 | device->target <= DASD_STATE_BASIC) |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 455 | rc = dasd_state_unfmt_to_basic(device); |
Horst Hummel | 90f0094 | 2006-03-07 21:55:39 -0800 | [diff] [blame] | 456 | |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 457 | if (!rc && |
| 458 | device->state == DASD_STATE_BASIC && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | device->target <= DASD_STATE_KNOWN) |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 460 | rc = dasd_state_basic_to_known(device); |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 461 | |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 462 | if (!rc && |
| 463 | device->state == DASD_STATE_KNOWN && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | device->target <= DASD_STATE_NEW) |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 465 | rc = dasd_state_known_to_new(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 467 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | } |
| 469 | |
| 470 | /* |
| 471 | * This is the main startup/shutdown routine. |
| 472 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 473 | static void dasd_change_state(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | { |
Sebastian Ott | 181d952 | 2009-06-22 12:08:21 +0200 | [diff] [blame] | 475 | int rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 476 | |
| 477 | if (device->state == device->target) |
| 478 | /* Already where we want to go today... */ |
| 479 | return; |
| 480 | if (device->state < device->target) |
| 481 | rc = dasd_increase_state(device); |
| 482 | else |
| 483 | rc = dasd_decrease_state(device); |
Sebastian Ott | 181d952 | 2009-06-22 12:08:21 +0200 | [diff] [blame] | 484 | if (rc == -EAGAIN) |
| 485 | return; |
| 486 | if (rc) |
| 487 | device->target = device->state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame^] | 489 | if (device->state == device->target) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | wake_up(&dasd_init_waitq); |
Horst Hummel | 4dfd5c4 | 2007-04-27 16:01:47 +0200 | [diff] [blame] | 491 | |
| 492 | /* let user-space know that the device status changed */ |
| 493 | kobject_uevent(&device->cdev->dev.kobj, KOBJ_CHANGE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | /* |
| 497 | * Kick starter for devices that did not complete the startup/shutdown |
| 498 | * procedure or were sleeping because of a pending state. |
| 499 | * dasd_kick_device will schedule a call do do_kick_device to the kernel |
| 500 | * event daemon. |
| 501 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 502 | static void do_kick_device(struct work_struct *work) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 503 | { |
Al Viro | 4927b3f | 2006-12-06 19:18:20 +0000 | [diff] [blame] | 504 | struct dasd_device *device = container_of(work, struct dasd_device, kick_work); |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame^] | 505 | mutex_lock(&device->state_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 506 | dasd_change_state(device); |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame^] | 507 | mutex_unlock(&device->state_mutex); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 508 | dasd_schedule_device_bh(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | dasd_put_device(device); |
| 510 | } |
| 511 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 512 | void dasd_kick_device(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | { |
| 514 | dasd_get_device(device); |
| 515 | /* queue call to dasd_kick_device to the kernel event daemon. */ |
| 516 | schedule_work(&device->kick_work); |
| 517 | } |
| 518 | |
| 519 | /* |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 520 | * dasd_restore_device will schedule a call do do_restore_device to the kernel |
| 521 | * event daemon. |
| 522 | */ |
| 523 | static void do_restore_device(struct work_struct *work) |
| 524 | { |
| 525 | struct dasd_device *device = container_of(work, struct dasd_device, |
| 526 | restore_device); |
| 527 | device->cdev->drv->restore(device->cdev); |
| 528 | dasd_put_device(device); |
| 529 | } |
| 530 | |
| 531 | void dasd_restore_device(struct dasd_device *device) |
| 532 | { |
| 533 | dasd_get_device(device); |
| 534 | /* queue call to dasd_restore_device to the kernel event daemon. */ |
| 535 | schedule_work(&device->restore_device); |
| 536 | } |
| 537 | |
| 538 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | * Set the target state for a device and starts the state change. |
| 540 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 541 | void dasd_set_target_state(struct dasd_device *device, int target) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | { |
Cornelia Huck | f3445a1 | 2009-04-14 15:36:23 +0200 | [diff] [blame] | 543 | dasd_get_device(device); |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame^] | 544 | mutex_lock(&device->state_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | /* If we are in probeonly mode stop at DASD_STATE_READY. */ |
| 546 | if (dasd_probeonly && target > DASD_STATE_READY) |
| 547 | target = DASD_STATE_READY; |
| 548 | if (device->target != target) { |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame^] | 549 | if (device->state == target) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | wake_up(&dasd_init_waitq); |
| 551 | device->target = target; |
| 552 | } |
| 553 | if (device->state != device->target) |
| 554 | dasd_change_state(device); |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame^] | 555 | mutex_unlock(&device->state_mutex); |
| 556 | dasd_put_device(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | /* |
| 560 | * Enable devices with device numbers in [from..to]. |
| 561 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 562 | static inline int _wait_for_device(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | { |
| 564 | return (device->state == device->target); |
| 565 | } |
| 566 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 567 | void dasd_enable_device(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | { |
| 569 | dasd_set_target_state(device, DASD_STATE_ONLINE); |
| 570 | if (device->state <= DASD_STATE_KNOWN) |
| 571 | /* No discipline for device found. */ |
| 572 | dasd_set_target_state(device, DASD_STATE_NEW); |
| 573 | /* Now wait for the devices to come up. */ |
| 574 | wait_event(dasd_init_waitq, _wait_for_device(device)); |
| 575 | } |
| 576 | |
| 577 | /* |
| 578 | * SECTION: device operation (interrupt handler, start i/o, term i/o ...) |
| 579 | */ |
| 580 | #ifdef CONFIG_DASD_PROFILE |
| 581 | |
| 582 | struct dasd_profile_info_t dasd_global_profile; |
| 583 | unsigned int dasd_profile_level = DASD_PROFILE_OFF; |
| 584 | |
| 585 | /* |
| 586 | * Increments counter in global and local profiling structures. |
| 587 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 588 | #define dasd_profile_counter(value, counter, block) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | { \ |
| 590 | int index; \ |
| 591 | for (index = 0; index < 31 && value >> (2+index); index++); \ |
| 592 | dasd_global_profile.counter[index]++; \ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 593 | block->profile.counter[index]++; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | /* |
| 597 | * Add profiling information for cqr before execution. |
| 598 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 599 | static void dasd_profile_start(struct dasd_block *block, |
| 600 | struct dasd_ccw_req *cqr, |
| 601 | struct request *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | { |
| 603 | struct list_head *l; |
| 604 | unsigned int counter; |
| 605 | |
| 606 | if (dasd_profile_level != DASD_PROFILE_ON) |
| 607 | return; |
| 608 | |
| 609 | /* count the length of the chanq for statistics */ |
| 610 | counter = 0; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 611 | list_for_each(l, &block->ccw_queue) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 612 | if (++counter >= 31) |
| 613 | break; |
| 614 | dasd_global_profile.dasd_io_nr_req[counter]++; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 615 | block->profile.dasd_io_nr_req[counter]++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | /* |
| 619 | * Add profiling information for cqr after execution. |
| 620 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 621 | static void dasd_profile_end(struct dasd_block *block, |
| 622 | struct dasd_ccw_req *cqr, |
| 623 | struct request *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | { |
| 625 | long strtime, irqtime, endtime, tottime; /* in microseconds */ |
| 626 | long tottimeps, sectors; |
| 627 | |
| 628 | if (dasd_profile_level != DASD_PROFILE_ON) |
| 629 | return; |
| 630 | |
Tejun Heo | 83096eb | 2009-05-07 22:24:39 +0900 | [diff] [blame] | 631 | sectors = blk_rq_sectors(req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | if (!cqr->buildclk || !cqr->startclk || |
| 633 | !cqr->stopclk || !cqr->endclk || |
| 634 | !sectors) |
| 635 | return; |
| 636 | |
| 637 | strtime = ((cqr->startclk - cqr->buildclk) >> 12); |
| 638 | irqtime = ((cqr->stopclk - cqr->startclk) >> 12); |
| 639 | endtime = ((cqr->endclk - cqr->stopclk) >> 12); |
| 640 | tottime = ((cqr->endclk - cqr->buildclk) >> 12); |
| 641 | tottimeps = tottime / sectors; |
| 642 | |
| 643 | if (!dasd_global_profile.dasd_io_reqs) |
| 644 | memset(&dasd_global_profile, 0, |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 645 | sizeof(struct dasd_profile_info_t)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | dasd_global_profile.dasd_io_reqs++; |
| 647 | dasd_global_profile.dasd_io_sects += sectors; |
| 648 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 649 | if (!block->profile.dasd_io_reqs) |
| 650 | memset(&block->profile, 0, |
| 651 | sizeof(struct dasd_profile_info_t)); |
| 652 | block->profile.dasd_io_reqs++; |
| 653 | block->profile.dasd_io_sects += sectors; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 655 | dasd_profile_counter(sectors, dasd_io_secs, block); |
| 656 | dasd_profile_counter(tottime, dasd_io_times, block); |
| 657 | dasd_profile_counter(tottimeps, dasd_io_timps, block); |
| 658 | dasd_profile_counter(strtime, dasd_io_time1, block); |
| 659 | dasd_profile_counter(irqtime, dasd_io_time2, block); |
| 660 | dasd_profile_counter(irqtime / sectors, dasd_io_time2ps, block); |
| 661 | dasd_profile_counter(endtime, dasd_io_time3, block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | } |
| 663 | #else |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 664 | #define dasd_profile_start(block, cqr, req) do {} while (0) |
| 665 | #define dasd_profile_end(block, cqr, req) do {} while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 666 | #endif /* CONFIG_DASD_PROFILE */ |
| 667 | |
| 668 | /* |
| 669 | * Allocate memory for a channel program with 'cplength' channel |
| 670 | * command words and 'datasize' additional space. There are two |
| 671 | * variantes: 1) dasd_kmalloc_request uses kmalloc to get the needed |
| 672 | * memory and 2) dasd_smalloc_request uses the static ccw memory |
| 673 | * that gets allocated for each device. |
| 674 | */ |
Stefan Haberland | 68b781f | 2009-09-11 10:28:29 +0200 | [diff] [blame] | 675 | struct dasd_ccw_req *dasd_kmalloc_request(int magic, int cplength, |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 676 | int datasize, |
| 677 | struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | { |
| 679 | struct dasd_ccw_req *cqr; |
| 680 | |
| 681 | /* Sanity checks */ |
Stefan Haberland | 68b781f | 2009-09-11 10:28:29 +0200 | [diff] [blame] | 682 | BUG_ON(datasize > PAGE_SIZE || |
Eric Sesterhenn | 7ac1e87 | 2006-03-24 18:48:13 +0100 | [diff] [blame] | 683 | (cplength*sizeof(struct ccw1)) > PAGE_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | |
Eric Sesterhenn | 88abaab | 2006-03-24 03:15:31 -0800 | [diff] [blame] | 685 | cqr = kzalloc(sizeof(struct dasd_ccw_req), GFP_ATOMIC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | if (cqr == NULL) |
| 687 | return ERR_PTR(-ENOMEM); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | cqr->cpaddr = NULL; |
| 689 | if (cplength > 0) { |
Eric Sesterhenn | 88abaab | 2006-03-24 03:15:31 -0800 | [diff] [blame] | 690 | cqr->cpaddr = kcalloc(cplength, sizeof(struct ccw1), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | GFP_ATOMIC | GFP_DMA); |
| 692 | if (cqr->cpaddr == NULL) { |
| 693 | kfree(cqr); |
| 694 | return ERR_PTR(-ENOMEM); |
| 695 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | } |
| 697 | cqr->data = NULL; |
| 698 | if (datasize > 0) { |
Eric Sesterhenn | 88abaab | 2006-03-24 03:15:31 -0800 | [diff] [blame] | 699 | cqr->data = kzalloc(datasize, GFP_ATOMIC | GFP_DMA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | if (cqr->data == NULL) { |
Jesper Juhl | 17fd682 | 2005-11-07 01:01:30 -0800 | [diff] [blame] | 701 | kfree(cqr->cpaddr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 702 | kfree(cqr); |
| 703 | return ERR_PTR(-ENOMEM); |
| 704 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | } |
Stefan Haberland | 68b781f | 2009-09-11 10:28:29 +0200 | [diff] [blame] | 706 | cqr->magic = magic; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 707 | set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags); |
| 708 | dasd_get_device(device); |
| 709 | return cqr; |
| 710 | } |
| 711 | |
Stefan Haberland | 68b781f | 2009-09-11 10:28:29 +0200 | [diff] [blame] | 712 | struct dasd_ccw_req *dasd_smalloc_request(int magic, int cplength, |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 713 | int datasize, |
| 714 | struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 715 | { |
| 716 | unsigned long flags; |
| 717 | struct dasd_ccw_req *cqr; |
| 718 | char *data; |
| 719 | int size; |
| 720 | |
| 721 | /* Sanity checks */ |
Stefan Haberland | 68b781f | 2009-09-11 10:28:29 +0200 | [diff] [blame] | 722 | BUG_ON(datasize > PAGE_SIZE || |
Eric Sesterhenn | 7ac1e87 | 2006-03-24 18:48:13 +0100 | [diff] [blame] | 723 | (cplength*sizeof(struct ccw1)) > PAGE_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 724 | |
| 725 | size = (sizeof(struct dasd_ccw_req) + 7L) & -8L; |
| 726 | if (cplength > 0) |
| 727 | size += cplength * sizeof(struct ccw1); |
| 728 | if (datasize > 0) |
| 729 | size += datasize; |
| 730 | spin_lock_irqsave(&device->mem_lock, flags); |
| 731 | cqr = (struct dasd_ccw_req *) |
| 732 | dasd_alloc_chunk(&device->ccw_chunks, size); |
| 733 | spin_unlock_irqrestore(&device->mem_lock, flags); |
| 734 | if (cqr == NULL) |
| 735 | return ERR_PTR(-ENOMEM); |
| 736 | memset(cqr, 0, sizeof(struct dasd_ccw_req)); |
| 737 | data = (char *) cqr + ((sizeof(struct dasd_ccw_req) + 7L) & -8L); |
| 738 | cqr->cpaddr = NULL; |
| 739 | if (cplength > 0) { |
| 740 | cqr->cpaddr = (struct ccw1 *) data; |
| 741 | data += cplength*sizeof(struct ccw1); |
| 742 | memset(cqr->cpaddr, 0, cplength*sizeof(struct ccw1)); |
| 743 | } |
| 744 | cqr->data = NULL; |
| 745 | if (datasize > 0) { |
| 746 | cqr->data = data; |
| 747 | memset(cqr->data, 0, datasize); |
| 748 | } |
Stefan Haberland | 68b781f | 2009-09-11 10:28:29 +0200 | [diff] [blame] | 749 | cqr->magic = magic; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 750 | set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags); |
| 751 | dasd_get_device(device); |
| 752 | return cqr; |
| 753 | } |
| 754 | |
| 755 | /* |
| 756 | * Free memory of a channel program. This function needs to free all the |
| 757 | * idal lists that might have been created by dasd_set_cda and the |
| 758 | * struct dasd_ccw_req itself. |
| 759 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 760 | void dasd_kfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | { |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 762 | #ifdef CONFIG_64BIT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | struct ccw1 *ccw; |
| 764 | |
| 765 | /* Clear any idals used for the request. */ |
| 766 | ccw = cqr->cpaddr; |
| 767 | do { |
| 768 | clear_normalized_cda(ccw); |
| 769 | } while (ccw++->flags & (CCW_FLAG_CC | CCW_FLAG_DC)); |
| 770 | #endif |
Jesper Juhl | 17fd682 | 2005-11-07 01:01:30 -0800 | [diff] [blame] | 771 | kfree(cqr->cpaddr); |
| 772 | kfree(cqr->data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 773 | kfree(cqr); |
| 774 | dasd_put_device(device); |
| 775 | } |
| 776 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 777 | void dasd_sfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 778 | { |
| 779 | unsigned long flags; |
| 780 | |
| 781 | spin_lock_irqsave(&device->mem_lock, flags); |
| 782 | dasd_free_chunk(&device->ccw_chunks, cqr); |
| 783 | spin_unlock_irqrestore(&device->mem_lock, flags); |
| 784 | dasd_put_device(device); |
| 785 | } |
| 786 | |
| 787 | /* |
| 788 | * Check discipline magic in cqr. |
| 789 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 790 | static inline int dasd_check_cqr(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 791 | { |
| 792 | struct dasd_device *device; |
| 793 | |
| 794 | if (cqr == NULL) |
| 795 | return -EINVAL; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 796 | device = cqr->startdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 797 | if (strncmp((char *) &cqr->magic, device->discipline->ebcname, 4)) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 798 | DBF_DEV_EVENT(DBF_WARNING, device, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 799 | " dasd_ccw_req 0x%08x magic doesn't match" |
| 800 | " discipline 0x%08x", |
| 801 | cqr->magic, |
| 802 | *(unsigned int *) device->discipline->name); |
| 803 | return -EINVAL; |
| 804 | } |
| 805 | return 0; |
| 806 | } |
| 807 | |
| 808 | /* |
| 809 | * Terminate the current i/o and set the request to clear_pending. |
| 810 | * Timer keeps device runnig. |
| 811 | * ccw_device_clear can fail if the i/o subsystem |
| 812 | * is in a bad mood. |
| 813 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 814 | int dasd_term_IO(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 815 | { |
| 816 | struct dasd_device *device; |
| 817 | int retries, rc; |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 818 | char errorstring[ERRORLENGTH]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | |
| 820 | /* Check the cqr */ |
| 821 | rc = dasd_check_cqr(cqr); |
| 822 | if (rc) |
| 823 | return rc; |
| 824 | retries = 0; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 825 | device = (struct dasd_device *) cqr->startdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 826 | while ((retries < 5) && (cqr->status == DASD_CQR_IN_IO)) { |
| 827 | rc = ccw_device_clear(device->cdev, (long) cqr); |
| 828 | switch (rc) { |
| 829 | case 0: /* termination successful */ |
Horst Hummel | c2ba444 | 2006-02-01 03:06:37 -0800 | [diff] [blame] | 830 | cqr->retries--; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 831 | cqr->status = DASD_CQR_CLEAR_PENDING; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 832 | cqr->stopclk = get_clock(); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 833 | cqr->starttime = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 834 | DBF_DEV_EVENT(DBF_DEBUG, device, |
| 835 | "terminate cqr %p successful", |
| 836 | cqr); |
| 837 | break; |
| 838 | case -ENODEV: |
| 839 | DBF_DEV_EVENT(DBF_ERR, device, "%s", |
| 840 | "device gone, retry"); |
| 841 | break; |
| 842 | case -EIO: |
| 843 | DBF_DEV_EVENT(DBF_ERR, device, "%s", |
| 844 | "I/O error, retry"); |
| 845 | break; |
| 846 | case -EINVAL: |
| 847 | case -EBUSY: |
| 848 | DBF_DEV_EVENT(DBF_ERR, device, "%s", |
| 849 | "device busy, retry later"); |
| 850 | break; |
| 851 | default: |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 852 | /* internal error 10 - unknown rc*/ |
| 853 | snprintf(errorstring, ERRORLENGTH, "10 %d", rc); |
| 854 | dev_err(&device->cdev->dev, "An error occurred in the " |
| 855 | "DASD device driver, reason=%s\n", errorstring); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 856 | BUG(); |
| 857 | break; |
| 858 | } |
| 859 | retries++; |
| 860 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 861 | dasd_schedule_device_bh(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 862 | return rc; |
| 863 | } |
| 864 | |
| 865 | /* |
| 866 | * Start the i/o. This start_IO can fail if the channel is really busy. |
| 867 | * In that case set up a timer to start the request later. |
| 868 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 869 | int dasd_start_IO(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 870 | { |
| 871 | struct dasd_device *device; |
| 872 | int rc; |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 873 | char errorstring[ERRORLENGTH]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 874 | |
| 875 | /* Check the cqr */ |
| 876 | rc = dasd_check_cqr(cqr); |
Stefan Weinhuber | 6cc7f16 | 2009-06-12 10:26:39 +0200 | [diff] [blame] | 877 | if (rc) { |
| 878 | cqr->intrc = rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 879 | return rc; |
Stefan Weinhuber | 6cc7f16 | 2009-06-12 10:26:39 +0200 | [diff] [blame] | 880 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 881 | device = (struct dasd_device *) cqr->startdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 882 | if (cqr->retries < 0) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 883 | /* internal error 14 - start_IO run out of retries */ |
| 884 | sprintf(errorstring, "14 %p", cqr); |
| 885 | dev_err(&device->cdev->dev, "An error occurred in the DASD " |
| 886 | "device driver, reason=%s\n", errorstring); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 887 | cqr->status = DASD_CQR_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 888 | return -EIO; |
| 889 | } |
| 890 | cqr->startclk = get_clock(); |
| 891 | cqr->starttime = jiffies; |
| 892 | cqr->retries--; |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 893 | if (cqr->cpmode == 1) { |
| 894 | rc = ccw_device_tm_start(device->cdev, cqr->cpaddr, |
| 895 | (long) cqr, cqr->lpm); |
| 896 | } else { |
| 897 | rc = ccw_device_start(device->cdev, cqr->cpaddr, |
| 898 | (long) cqr, cqr->lpm, 0); |
| 899 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 900 | switch (rc) { |
| 901 | case 0: |
| 902 | cqr->status = DASD_CQR_IN_IO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 903 | break; |
| 904 | case -EBUSY: |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 905 | DBF_DEV_EVENT(DBF_DEBUG, device, "%s", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 906 | "start_IO: device busy, retry later"); |
| 907 | break; |
| 908 | case -ETIMEDOUT: |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 909 | DBF_DEV_EVENT(DBF_DEBUG, device, "%s", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 910 | "start_IO: request timeout, retry later"); |
| 911 | break; |
| 912 | case -EACCES: |
| 913 | /* -EACCES indicates that the request used only a |
| 914 | * subset of the available pathes and all these |
| 915 | * pathes are gone. |
| 916 | * Do a retry with all available pathes. |
| 917 | */ |
| 918 | cqr->lpm = LPM_ANYPATH; |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 919 | DBF_DEV_EVENT(DBF_DEBUG, device, "%s", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 920 | "start_IO: selected pathes gone," |
| 921 | " retry on all pathes"); |
| 922 | break; |
| 923 | case -ENODEV: |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 924 | DBF_DEV_EVENT(DBF_DEBUG, device, "%s", |
| 925 | "start_IO: -ENODEV device gone, retry"); |
| 926 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 927 | case -EIO: |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 928 | DBF_DEV_EVENT(DBF_DEBUG, device, "%s", |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 929 | "start_IO: -EIO device gone, retry"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 930 | break; |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 931 | case -EINVAL: |
| 932 | /* most likely caused in power management context */ |
| 933 | DBF_DEV_EVENT(DBF_DEBUG, device, "%s", |
| 934 | "start_IO: -EINVAL device currently " |
| 935 | "not accessible"); |
| 936 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 937 | default: |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 938 | /* internal error 11 - unknown rc */ |
| 939 | snprintf(errorstring, ERRORLENGTH, "11 %d", rc); |
| 940 | dev_err(&device->cdev->dev, |
| 941 | "An error occurred in the DASD device driver, " |
| 942 | "reason=%s\n", errorstring); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 943 | BUG(); |
| 944 | break; |
| 945 | } |
Stefan Weinhuber | 6cc7f16 | 2009-06-12 10:26:39 +0200 | [diff] [blame] | 946 | cqr->intrc = rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | return rc; |
| 948 | } |
| 949 | |
| 950 | /* |
| 951 | * Timeout function for dasd devices. This is used for different purposes |
| 952 | * 1) missing interrupt handler for normal operation |
| 953 | * 2) delayed start of request where start_IO failed with -EBUSY |
| 954 | * 3) timeout for missing state change interrupts |
| 955 | * The head of the ccw queue will have status DASD_CQR_IN_IO for 1), |
| 956 | * DASD_CQR_QUEUED for 2) and 3). |
| 957 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 958 | static void dasd_device_timeout(unsigned long ptr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 959 | { |
| 960 | unsigned long flags; |
| 961 | struct dasd_device *device; |
| 962 | |
| 963 | device = (struct dasd_device *) ptr; |
| 964 | spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); |
| 965 | /* re-activate request queue */ |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 966 | dasd_device_remove_stop_bits(device, DASD_STOPPED_PENDING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 967 | spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 968 | dasd_schedule_device_bh(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 969 | } |
| 970 | |
| 971 | /* |
| 972 | * Setup timeout for a device in jiffies. |
| 973 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 974 | void dasd_device_set_timer(struct dasd_device *device, int expires) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 975 | { |
Stefan Weinhuber | 48cae88 | 2009-02-11 10:37:31 +0100 | [diff] [blame] | 976 | if (expires == 0) |
| 977 | del_timer(&device->timer); |
| 978 | else |
| 979 | mod_timer(&device->timer, jiffies + expires); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 980 | } |
| 981 | |
| 982 | /* |
| 983 | * Clear timeout for a device. |
| 984 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 985 | void dasd_device_clear_timer(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 986 | { |
Stefan Weinhuber | 48cae88 | 2009-02-11 10:37:31 +0100 | [diff] [blame] | 987 | del_timer(&device->timer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 | } |
| 989 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 990 | static void dasd_handle_killed_request(struct ccw_device *cdev, |
| 991 | unsigned long intparm) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 992 | { |
| 993 | struct dasd_ccw_req *cqr; |
| 994 | struct dasd_device *device; |
| 995 | |
Stefan Weinhuber | f16f5843 | 2008-05-15 16:52:36 +0200 | [diff] [blame] | 996 | if (!intparm) |
| 997 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | cqr = (struct dasd_ccw_req *) intparm; |
| 999 | if (cqr->status != DASD_CQR_IN_IO) { |
Stefan Haberland | b8ed5dd | 2009-12-07 12:51:52 +0100 | [diff] [blame] | 1000 | DBF_EVENT_DEVID(DBF_DEBUG, cdev, |
| 1001 | "invalid status in handle_killed_request: " |
| 1002 | "%02x", cqr->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1003 | return; |
| 1004 | } |
| 1005 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1006 | device = (struct dasd_device *) cqr->startdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | if (device == NULL || |
Martin Schwidefsky | a00bfd7 | 2006-09-20 15:59:05 +0200 | [diff] [blame] | 1008 | device != dasd_device_from_cdev_locked(cdev) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1009 | strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) { |
Stefan Haberland | 294001a | 2010-01-27 10:12:35 +0100 | [diff] [blame] | 1010 | DBF_EVENT_DEVID(DBF_DEBUG, cdev, "%s", |
| 1011 | "invalid device in request"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1012 | return; |
| 1013 | } |
| 1014 | |
| 1015 | /* Schedule request to be retried. */ |
| 1016 | cqr->status = DASD_CQR_QUEUED; |
| 1017 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1018 | dasd_device_clear_timer(device); |
| 1019 | dasd_schedule_device_bh(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1020 | dasd_put_device(device); |
| 1021 | } |
| 1022 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1023 | void dasd_generic_handle_state_change(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1024 | { |
Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 1025 | /* First of all start sense subsystem status request. */ |
| 1026 | dasd_eer_snss(device); |
| 1027 | |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 1028 | dasd_device_remove_stop_bits(device, DASD_STOPPED_PENDING); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1029 | dasd_schedule_device_bh(device); |
| 1030 | if (device->block) |
| 1031 | dasd_schedule_block_bh(device->block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1032 | } |
| 1033 | |
| 1034 | /* |
| 1035 | * Interrupt handler for "normal" ssch-io based dasd devices. |
| 1036 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1037 | void dasd_int_handler(struct ccw_device *cdev, unsigned long intparm, |
| 1038 | struct irb *irb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1039 | { |
| 1040 | struct dasd_ccw_req *cqr, *next; |
| 1041 | struct dasd_device *device; |
| 1042 | unsigned long long now; |
| 1043 | int expires; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1044 | |
| 1045 | if (IS_ERR(irb)) { |
| 1046 | switch (PTR_ERR(irb)) { |
| 1047 | case -EIO: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | break; |
| 1049 | case -ETIMEDOUT: |
Stefan Haberland | b8ed5dd | 2009-12-07 12:51:52 +0100 | [diff] [blame] | 1050 | DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s: " |
| 1051 | "request timed out\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1052 | break; |
| 1053 | default: |
Stefan Haberland | b8ed5dd | 2009-12-07 12:51:52 +0100 | [diff] [blame] | 1054 | DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s: " |
| 1055 | "unknown error %ld\n", __func__, |
| 1056 | PTR_ERR(irb)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1057 | } |
Stefan Weinhuber | f16f5843 | 2008-05-15 16:52:36 +0200 | [diff] [blame] | 1058 | dasd_handle_killed_request(cdev, intparm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1059 | return; |
| 1060 | } |
| 1061 | |
| 1062 | now = get_clock(); |
| 1063 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1064 | /* check for unsolicited interrupts */ |
| 1065 | cqr = (struct dasd_ccw_req *) intparm; |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 1066 | if (!cqr || ((scsw_cc(&irb->scsw) == 1) && |
| 1067 | (scsw_fctl(&irb->scsw) & SCSW_FCTL_START_FUNC) && |
| 1068 | (scsw_stctl(&irb->scsw) & SCSW_STCTL_STATUS_PEND))) { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1069 | if (cqr && cqr->status == DASD_CQR_IN_IO) |
| 1070 | cqr->status = DASD_CQR_QUEUED; |
Martin Schwidefsky | a00bfd7 | 2006-09-20 15:59:05 +0200 | [diff] [blame] | 1071 | device = dasd_device_from_cdev_locked(cdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1072 | if (!IS_ERR(device)) { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1073 | dasd_device_clear_timer(device); |
| 1074 | device->discipline->handle_unsolicited_interrupt(device, |
| 1075 | irb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1076 | dasd_put_device(device); |
| 1077 | } |
| 1078 | return; |
| 1079 | } |
| 1080 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1081 | device = (struct dasd_device *) cqr->startdev; |
| 1082 | if (!device || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1083 | strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) { |
Stefan Haberland | 294001a | 2010-01-27 10:12:35 +0100 | [diff] [blame] | 1084 | DBF_EVENT_DEVID(DBF_DEBUG, cdev, "%s", |
| 1085 | "invalid device in request"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1086 | return; |
| 1087 | } |
| 1088 | |
| 1089 | /* Check for clear pending */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1090 | if (cqr->status == DASD_CQR_CLEAR_PENDING && |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 1091 | scsw_fctl(&irb->scsw) & SCSW_FCTL_CLEAR_FUNC) { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1092 | cqr->status = DASD_CQR_CLEARED; |
| 1093 | dasd_device_clear_timer(device); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1094 | wake_up(&dasd_flush_wq); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1095 | dasd_schedule_device_bh(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1096 | return; |
| 1097 | } |
| 1098 | |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 1099 | /* check status - the request might have been killed by dyn detach */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1100 | if (cqr->status != DASD_CQR_IN_IO) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1101 | DBF_DEV_EVENT(DBF_DEBUG, device, "invalid status: bus_id %s, " |
| 1102 | "status %02x", dev_name(&cdev->dev), cqr->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1103 | return; |
| 1104 | } |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1105 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1106 | next = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1107 | expires = 0; |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 1108 | if (scsw_dstat(&irb->scsw) == (DEV_STAT_CHN_END | DEV_STAT_DEV_END) && |
| 1109 | scsw_cstat(&irb->scsw) == 0) { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1110 | /* request was completed successfully */ |
| 1111 | cqr->status = DASD_CQR_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1112 | cqr->stopclk = now; |
| 1113 | /* Start first request on queue if possible -> fast_io. */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1114 | if (cqr->devlist.next != &device->ccw_queue) { |
| 1115 | next = list_entry(cqr->devlist.next, |
| 1116 | struct dasd_ccw_req, devlist); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1117 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1118 | } else { /* error */ |
| 1119 | memcpy(&cqr->irb, irb, sizeof(struct irb)); |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1120 | /* log sense for every failed I/O to s390 debugfeature */ |
| 1121 | dasd_log_sense_dbf(cqr, irb); |
Horst Hummel | 9575bf2 | 2006-12-08 15:54:15 +0100 | [diff] [blame] | 1122 | if (device->features & DASD_FEATURE_ERPLOG) { |
Horst Hummel | 9575bf2 | 2006-12-08 15:54:15 +0100 | [diff] [blame] | 1123 | dasd_log_sense(cqr, irb); |
| 1124 | } |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1125 | |
Stefan Haberland | 6c5f57c | 2008-02-05 16:50:46 +0100 | [diff] [blame] | 1126 | /* |
| 1127 | * If we don't want complex ERP for this request, then just |
| 1128 | * reset this and retry it in the fastpath |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1129 | */ |
Stefan Haberland | 6c5f57c | 2008-02-05 16:50:46 +0100 | [diff] [blame] | 1130 | if (!test_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags) && |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1131 | cqr->retries > 0) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1132 | if (cqr->lpm == LPM_ANYPATH) |
| 1133 | DBF_DEV_EVENT(DBF_DEBUG, device, |
| 1134 | "default ERP in fastpath " |
| 1135 | "(%i retries left)", |
| 1136 | cqr->retries); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1137 | cqr->lpm = LPM_ANYPATH; |
| 1138 | cqr->status = DASD_CQR_QUEUED; |
| 1139 | next = cqr; |
| 1140 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1141 | cqr->status = DASD_CQR_ERROR; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1142 | } |
| 1143 | if (next && (next->status == DASD_CQR_QUEUED) && |
| 1144 | (!device->stopped)) { |
| 1145 | if (device->discipline->start_IO(next) == 0) |
| 1146 | expires = next->expires; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1147 | } |
| 1148 | if (expires != 0) |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1149 | dasd_device_set_timer(device, expires); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1150 | else |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1151 | dasd_device_clear_timer(device); |
| 1152 | dasd_schedule_device_bh(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1153 | } |
| 1154 | |
| 1155 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1156 | * If we have an error on a dasd_block layer request then we cancel |
| 1157 | * and return all further requests from the same dasd_block as well. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1158 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1159 | static void __dasd_device_recovery(struct dasd_device *device, |
| 1160 | struct dasd_ccw_req *ref_cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1161 | { |
| 1162 | struct list_head *l, *n; |
| 1163 | struct dasd_ccw_req *cqr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1164 | |
| 1165 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1166 | * only requeue request that came from the dasd_block layer |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1167 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1168 | if (!ref_cqr->block) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1169 | return; |
Horst Hummel | f24acd4 | 2005-05-01 08:58:59 -0700 | [diff] [blame] | 1170 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1171 | list_for_each_safe(l, n, &device->ccw_queue) { |
| 1172 | cqr = list_entry(l, struct dasd_ccw_req, devlist); |
| 1173 | if (cqr->status == DASD_CQR_QUEUED && |
| 1174 | ref_cqr->block == cqr->block) { |
| 1175 | cqr->status = DASD_CQR_CLEARED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1176 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1177 | } |
| 1178 | }; |
| 1179 | |
| 1180 | /* |
| 1181 | * Remove those ccw requests from the queue that need to be returned |
| 1182 | * to the upper layer. |
| 1183 | */ |
| 1184 | static void __dasd_device_process_ccw_queue(struct dasd_device *device, |
| 1185 | struct list_head *final_queue) |
| 1186 | { |
| 1187 | struct list_head *l, *n; |
| 1188 | struct dasd_ccw_req *cqr; |
| 1189 | |
| 1190 | /* Process request with final status. */ |
| 1191 | list_for_each_safe(l, n, &device->ccw_queue) { |
| 1192 | cqr = list_entry(l, struct dasd_ccw_req, devlist); |
| 1193 | |
| 1194 | /* Stop list processing at the first non-final request. */ |
| 1195 | if (cqr->status == DASD_CQR_QUEUED || |
| 1196 | cqr->status == DASD_CQR_IN_IO || |
| 1197 | cqr->status == DASD_CQR_CLEAR_PENDING) |
| 1198 | break; |
| 1199 | if (cqr->status == DASD_CQR_ERROR) { |
| 1200 | __dasd_device_recovery(device, cqr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1201 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1202 | /* Rechain finished requests to final queue */ |
| 1203 | list_move_tail(&cqr->devlist, final_queue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1204 | } |
| 1205 | } |
| 1206 | |
| 1207 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1208 | * the cqrs from the final queue are returned to the upper layer |
| 1209 | * by setting a dasd_block state and calling the callback function |
| 1210 | */ |
| 1211 | static void __dasd_device_process_final_queue(struct dasd_device *device, |
| 1212 | struct list_head *final_queue) |
| 1213 | { |
| 1214 | struct list_head *l, *n; |
| 1215 | struct dasd_ccw_req *cqr; |
Stefan Weinhuber | 03513bc | 2008-02-19 15:29:27 +0100 | [diff] [blame] | 1216 | struct dasd_block *block; |
Stefan Haberland | c80ee72 | 2008-05-30 10:03:31 +0200 | [diff] [blame] | 1217 | void (*callback)(struct dasd_ccw_req *, void *data); |
| 1218 | void *callback_data; |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1219 | char errorstring[ERRORLENGTH]; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1220 | |
| 1221 | list_for_each_safe(l, n, final_queue) { |
| 1222 | cqr = list_entry(l, struct dasd_ccw_req, devlist); |
| 1223 | list_del_init(&cqr->devlist); |
Stefan Weinhuber | 03513bc | 2008-02-19 15:29:27 +0100 | [diff] [blame] | 1224 | block = cqr->block; |
Stefan Haberland | c80ee72 | 2008-05-30 10:03:31 +0200 | [diff] [blame] | 1225 | callback = cqr->callback; |
| 1226 | callback_data = cqr->callback_data; |
Stefan Weinhuber | 03513bc | 2008-02-19 15:29:27 +0100 | [diff] [blame] | 1227 | if (block) |
| 1228 | spin_lock_bh(&block->queue_lock); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1229 | switch (cqr->status) { |
| 1230 | case DASD_CQR_SUCCESS: |
| 1231 | cqr->status = DASD_CQR_DONE; |
| 1232 | break; |
| 1233 | case DASD_CQR_ERROR: |
| 1234 | cqr->status = DASD_CQR_NEED_ERP; |
| 1235 | break; |
| 1236 | case DASD_CQR_CLEARED: |
| 1237 | cqr->status = DASD_CQR_TERMINATED; |
| 1238 | break; |
| 1239 | default: |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1240 | /* internal error 12 - wrong cqr status*/ |
| 1241 | snprintf(errorstring, ERRORLENGTH, "12 %p %x02", cqr, cqr->status); |
| 1242 | dev_err(&device->cdev->dev, |
| 1243 | "An error occurred in the DASD device driver, " |
| 1244 | "reason=%s\n", errorstring); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1245 | BUG(); |
| 1246 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1247 | if (cqr->callback != NULL) |
Stefan Haberland | c80ee72 | 2008-05-30 10:03:31 +0200 | [diff] [blame] | 1248 | (callback)(cqr, callback_data); |
Stefan Weinhuber | 03513bc | 2008-02-19 15:29:27 +0100 | [diff] [blame] | 1249 | if (block) |
| 1250 | spin_unlock_bh(&block->queue_lock); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1251 | } |
| 1252 | } |
| 1253 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1254 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1255 | * Take a look at the first request on the ccw queue and check |
| 1256 | * if it reached its expire time. If so, terminate the IO. |
| 1257 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1258 | static void __dasd_device_check_expire(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1259 | { |
| 1260 | struct dasd_ccw_req *cqr; |
| 1261 | |
| 1262 | if (list_empty(&device->ccw_queue)) |
| 1263 | return; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1264 | cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); |
Horst Hummel | 29145a6 | 2006-12-04 15:40:15 +0100 | [diff] [blame] | 1265 | if ((cqr->status == DASD_CQR_IN_IO && cqr->expires != 0) && |
| 1266 | (time_after_eq(jiffies, cqr->expires + cqr->starttime))) { |
| 1267 | if (device->discipline->term_IO(cqr) != 0) { |
| 1268 | /* Hmpf, try again in 5 sec */ |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1269 | dev_err(&device->cdev->dev, |
| 1270 | "cqr %p timed out (%is) but cannot be " |
| 1271 | "ended, retrying in 5 s\n", |
| 1272 | cqr, (cqr->expires/HZ)); |
Stefan Haberland | 7dc1da9 | 2008-01-26 14:11:26 +0100 | [diff] [blame] | 1273 | cqr->expires += 5*HZ; |
| 1274 | dasd_device_set_timer(device, 5*HZ); |
Horst Hummel | 29145a6 | 2006-12-04 15:40:15 +0100 | [diff] [blame] | 1275 | } else { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1276 | dev_err(&device->cdev->dev, |
| 1277 | "cqr %p timed out (%is), %i retries " |
| 1278 | "remaining\n", cqr, (cqr->expires/HZ), |
| 1279 | cqr->retries); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1280 | } |
| 1281 | } |
| 1282 | } |
| 1283 | |
| 1284 | /* |
| 1285 | * Take a look at the first request on the ccw queue and check |
| 1286 | * if it needs to be started. |
| 1287 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1288 | static void __dasd_device_start_head(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1289 | { |
| 1290 | struct dasd_ccw_req *cqr; |
| 1291 | int rc; |
| 1292 | |
| 1293 | if (list_empty(&device->ccw_queue)) |
| 1294 | return; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1295 | cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); |
Peter Oberparleiter | 25ee4cf | 2006-04-10 22:53:47 -0700 | [diff] [blame] | 1296 | if (cqr->status != DASD_CQR_QUEUED) |
| 1297 | return; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1298 | /* when device is stopped, return request to previous layer */ |
| 1299 | if (device->stopped) { |
| 1300 | cqr->status = DASD_CQR_CLEARED; |
| 1301 | dasd_schedule_device_bh(device); |
Peter Oberparleiter | 25ee4cf | 2006-04-10 22:53:47 -0700 | [diff] [blame] | 1302 | return; |
Horst Hummel | 1c01b8a | 2006-01-06 00:19:15 -0800 | [diff] [blame] | 1303 | } |
Peter Oberparleiter | 25ee4cf | 2006-04-10 22:53:47 -0700 | [diff] [blame] | 1304 | |
| 1305 | rc = device->discipline->start_IO(cqr); |
| 1306 | if (rc == 0) |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1307 | dasd_device_set_timer(device, cqr->expires); |
Peter Oberparleiter | 25ee4cf | 2006-04-10 22:53:47 -0700 | [diff] [blame] | 1308 | else if (rc == -EACCES) { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1309 | dasd_schedule_device_bh(device); |
Peter Oberparleiter | 25ee4cf | 2006-04-10 22:53:47 -0700 | [diff] [blame] | 1310 | } else |
| 1311 | /* Hmpf, try again in 1/2 sec */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1312 | dasd_device_set_timer(device, 50); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1313 | } |
| 1314 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1315 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1316 | * Go through all request on the dasd_device request queue, |
| 1317 | * terminate them on the cdev if necessary, and return them to the |
| 1318 | * submitting layer via callback. |
| 1319 | * Note: |
| 1320 | * Make sure that all 'submitting layers' still exist when |
| 1321 | * this function is called!. In other words, when 'device' is a base |
| 1322 | * device then all block layer requests must have been removed before |
| 1323 | * via dasd_flush_block_queue. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1324 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1325 | int dasd_flush_device_queue(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1326 | { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1327 | struct dasd_ccw_req *cqr, *n; |
| 1328 | int rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1329 | struct list_head flush_queue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1330 | |
| 1331 | INIT_LIST_HEAD(&flush_queue); |
| 1332 | spin_lock_irq(get_ccwdev_lock(device->cdev)); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1333 | rc = 0; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1334 | list_for_each_entry_safe(cqr, n, &device->ccw_queue, devlist) { |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1335 | /* Check status and move request to flush_queue */ |
| 1336 | switch (cqr->status) { |
| 1337 | case DASD_CQR_IN_IO: |
| 1338 | rc = device->discipline->term_IO(cqr); |
| 1339 | if (rc) { |
| 1340 | /* unable to terminate requeust */ |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1341 | dev_err(&device->cdev->dev, |
| 1342 | "Flushing the DASD request queue " |
| 1343 | "failed for request %p\n", cqr); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1344 | /* stop flush processing */ |
| 1345 | goto finished; |
| 1346 | } |
| 1347 | break; |
| 1348 | case DASD_CQR_QUEUED: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1349 | cqr->stopclk = get_clock(); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1350 | cqr->status = DASD_CQR_CLEARED; |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1351 | break; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1352 | default: /* no need to modify the others */ |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1353 | break; |
| 1354 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1355 | list_move_tail(&cqr->devlist, &flush_queue); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1356 | } |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1357 | finished: |
| 1358 | spin_unlock_irq(get_ccwdev_lock(device->cdev)); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1359 | /* |
| 1360 | * After this point all requests must be in state CLEAR_PENDING, |
| 1361 | * CLEARED, SUCCESS or ERROR. Now wait for CLEAR_PENDING to become |
| 1362 | * one of the others. |
| 1363 | */ |
| 1364 | list_for_each_entry_safe(cqr, n, &flush_queue, devlist) |
| 1365 | wait_event(dasd_flush_wq, |
| 1366 | (cqr->status != DASD_CQR_CLEAR_PENDING)); |
| 1367 | /* |
| 1368 | * Now set each request back to TERMINATED, DONE or NEED_ERP |
| 1369 | * and call the callback function of flushed requests |
| 1370 | */ |
| 1371 | __dasd_device_process_final_queue(device, &flush_queue); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1372 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1373 | } |
| 1374 | |
| 1375 | /* |
| 1376 | * Acquire the device lock and process queues for the device. |
| 1377 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1378 | static void dasd_device_tasklet(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1379 | { |
| 1380 | struct list_head final_queue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1381 | |
| 1382 | atomic_set (&device->tasklet_scheduled, 0); |
| 1383 | INIT_LIST_HEAD(&final_queue); |
| 1384 | spin_lock_irq(get_ccwdev_lock(device->cdev)); |
| 1385 | /* Check expire time of first request on the ccw queue. */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1386 | __dasd_device_check_expire(device); |
| 1387 | /* find final requests on ccw queue */ |
| 1388 | __dasd_device_process_ccw_queue(device, &final_queue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1389 | spin_unlock_irq(get_ccwdev_lock(device->cdev)); |
| 1390 | /* Now call the callback function of requests with final status */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1391 | __dasd_device_process_final_queue(device, &final_queue); |
| 1392 | spin_lock_irq(get_ccwdev_lock(device->cdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1393 | /* Now check if the head of the ccw queue needs to be started. */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1394 | __dasd_device_start_head(device); |
| 1395 | spin_unlock_irq(get_ccwdev_lock(device->cdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1396 | dasd_put_device(device); |
| 1397 | } |
| 1398 | |
| 1399 | /* |
| 1400 | * Schedules a call to dasd_tasklet over the device tasklet. |
| 1401 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1402 | void dasd_schedule_device_bh(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1403 | { |
| 1404 | /* Protect against rescheduling. */ |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 1405 | if (atomic_cmpxchg (&device->tasklet_scheduled, 0, 1) != 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1406 | return; |
| 1407 | dasd_get_device(device); |
| 1408 | tasklet_hi_schedule(&device->tasklet); |
| 1409 | } |
| 1410 | |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 1411 | void dasd_device_set_stop_bits(struct dasd_device *device, int bits) |
| 1412 | { |
| 1413 | device->stopped |= bits; |
| 1414 | } |
| 1415 | EXPORT_SYMBOL_GPL(dasd_device_set_stop_bits); |
| 1416 | |
| 1417 | void dasd_device_remove_stop_bits(struct dasd_device *device, int bits) |
| 1418 | { |
| 1419 | device->stopped &= ~bits; |
| 1420 | if (!device->stopped) |
| 1421 | wake_up(&generic_waitq); |
| 1422 | } |
| 1423 | EXPORT_SYMBOL_GPL(dasd_device_remove_stop_bits); |
| 1424 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1425 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1426 | * Queue a request to the head of the device ccw_queue. |
| 1427 | * Start the I/O if possible. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1428 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1429 | void dasd_add_request_head(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1430 | { |
| 1431 | struct dasd_device *device; |
| 1432 | unsigned long flags; |
| 1433 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1434 | device = cqr->startdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1435 | spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1436 | cqr->status = DASD_CQR_QUEUED; |
| 1437 | list_add(&cqr->devlist, &device->ccw_queue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1438 | /* let the bh start the request to keep them in order */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1439 | dasd_schedule_device_bh(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1440 | spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); |
| 1441 | } |
| 1442 | |
| 1443 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1444 | * Queue a request to the tail of the device ccw_queue. |
| 1445 | * Start the I/O if possible. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1446 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1447 | void dasd_add_request_tail(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1448 | { |
| 1449 | struct dasd_device *device; |
| 1450 | unsigned long flags; |
| 1451 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1452 | device = cqr->startdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1453 | spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1454 | cqr->status = DASD_CQR_QUEUED; |
| 1455 | list_add_tail(&cqr->devlist, &device->ccw_queue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1456 | /* let the bh start the request to keep them in order */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1457 | dasd_schedule_device_bh(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1458 | spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); |
| 1459 | } |
| 1460 | |
| 1461 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1462 | * Wakeup helper for the 'sleep_on' functions. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1463 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1464 | static void dasd_wakeup_cb(struct dasd_ccw_req *cqr, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1465 | { |
| 1466 | wake_up((wait_queue_head_t *) data); |
| 1467 | } |
| 1468 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1469 | static inline int _wait_for_wakeup(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1470 | { |
| 1471 | struct dasd_device *device; |
| 1472 | int rc; |
| 1473 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1474 | device = cqr->startdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1475 | spin_lock_irq(get_ccwdev_lock(device->cdev)); |
Horst Hummel | c2ba444 | 2006-02-01 03:06:37 -0800 | [diff] [blame] | 1476 | rc = ((cqr->status == DASD_CQR_DONE || |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1477 | cqr->status == DASD_CQR_NEED_ERP || |
| 1478 | cqr->status == DASD_CQR_TERMINATED) && |
| 1479 | list_empty(&cqr->devlist)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1480 | spin_unlock_irq(get_ccwdev_lock(device->cdev)); |
| 1481 | return rc; |
| 1482 | } |
| 1483 | |
| 1484 | /* |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 1485 | * checks if error recovery is necessary, returns 1 if yes, 0 otherwise. |
| 1486 | */ |
| 1487 | static int __dasd_sleep_on_erp(struct dasd_ccw_req *cqr) |
| 1488 | { |
| 1489 | struct dasd_device *device; |
| 1490 | dasd_erp_fn_t erp_fn; |
| 1491 | |
| 1492 | if (cqr->status == DASD_CQR_FILLED) |
| 1493 | return 0; |
| 1494 | device = cqr->startdev; |
| 1495 | if (test_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags)) { |
| 1496 | if (cqr->status == DASD_CQR_TERMINATED) { |
| 1497 | device->discipline->handle_terminated_request(cqr); |
| 1498 | return 1; |
| 1499 | } |
| 1500 | if (cqr->status == DASD_CQR_NEED_ERP) { |
| 1501 | erp_fn = device->discipline->erp_action(cqr); |
| 1502 | erp_fn(cqr); |
| 1503 | return 1; |
| 1504 | } |
| 1505 | if (cqr->status == DASD_CQR_FAILED) |
| 1506 | dasd_log_sense(cqr, &cqr->irb); |
| 1507 | if (cqr->refers) { |
| 1508 | __dasd_process_erp(device, cqr); |
| 1509 | return 1; |
| 1510 | } |
| 1511 | } |
| 1512 | return 0; |
| 1513 | } |
| 1514 | |
| 1515 | static int __dasd_sleep_on_loop_condition(struct dasd_ccw_req *cqr) |
| 1516 | { |
| 1517 | if (test_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags)) { |
| 1518 | if (cqr->refers) /* erp is not done yet */ |
| 1519 | return 1; |
| 1520 | return ((cqr->status != DASD_CQR_DONE) && |
| 1521 | (cqr->status != DASD_CQR_FAILED)); |
| 1522 | } else |
| 1523 | return (cqr->status == DASD_CQR_FILLED); |
| 1524 | } |
| 1525 | |
| 1526 | static int _dasd_sleep_on(struct dasd_ccw_req *maincqr, int interruptible) |
| 1527 | { |
| 1528 | struct dasd_device *device; |
| 1529 | int rc; |
| 1530 | struct list_head ccw_queue; |
| 1531 | struct dasd_ccw_req *cqr; |
| 1532 | |
| 1533 | INIT_LIST_HEAD(&ccw_queue); |
| 1534 | maincqr->status = DASD_CQR_FILLED; |
| 1535 | device = maincqr->startdev; |
| 1536 | list_add(&maincqr->blocklist, &ccw_queue); |
| 1537 | for (cqr = maincqr; __dasd_sleep_on_loop_condition(cqr); |
| 1538 | cqr = list_first_entry(&ccw_queue, |
| 1539 | struct dasd_ccw_req, blocklist)) { |
| 1540 | |
| 1541 | if (__dasd_sleep_on_erp(cqr)) |
| 1542 | continue; |
| 1543 | if (cqr->status != DASD_CQR_FILLED) /* could be failed */ |
| 1544 | continue; |
| 1545 | |
| 1546 | /* Non-temporary stop condition will trigger fail fast */ |
| 1547 | if (device->stopped & ~DASD_STOPPED_PENDING && |
| 1548 | test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) && |
| 1549 | (!dasd_eer_enabled(device))) { |
| 1550 | cqr->status = DASD_CQR_FAILED; |
| 1551 | continue; |
| 1552 | } |
| 1553 | |
| 1554 | /* Don't try to start requests if device is stopped */ |
| 1555 | if (interruptible) { |
| 1556 | rc = wait_event_interruptible( |
| 1557 | generic_waitq, !(device->stopped)); |
| 1558 | if (rc == -ERESTARTSYS) { |
| 1559 | cqr->status = DASD_CQR_FAILED; |
| 1560 | maincqr->intrc = rc; |
| 1561 | continue; |
| 1562 | } |
| 1563 | } else |
| 1564 | wait_event(generic_waitq, !(device->stopped)); |
| 1565 | |
| 1566 | cqr->callback = dasd_wakeup_cb; |
| 1567 | cqr->callback_data = (void *) &generic_waitq; |
| 1568 | dasd_add_request_tail(cqr); |
| 1569 | if (interruptible) { |
| 1570 | rc = wait_event_interruptible( |
| 1571 | generic_waitq, _wait_for_wakeup(cqr)); |
| 1572 | if (rc == -ERESTARTSYS) { |
| 1573 | dasd_cancel_req(cqr); |
| 1574 | /* wait (non-interruptible) for final status */ |
| 1575 | wait_event(generic_waitq, |
| 1576 | _wait_for_wakeup(cqr)); |
| 1577 | cqr->status = DASD_CQR_FAILED; |
| 1578 | maincqr->intrc = rc; |
| 1579 | continue; |
| 1580 | } |
| 1581 | } else |
| 1582 | wait_event(generic_waitq, _wait_for_wakeup(cqr)); |
| 1583 | } |
| 1584 | |
| 1585 | maincqr->endclk = get_clock(); |
| 1586 | if ((maincqr->status != DASD_CQR_DONE) && |
| 1587 | (maincqr->intrc != -ERESTARTSYS)) |
| 1588 | dasd_log_sense(maincqr, &maincqr->irb); |
| 1589 | if (maincqr->status == DASD_CQR_DONE) |
| 1590 | rc = 0; |
| 1591 | else if (maincqr->intrc) |
| 1592 | rc = maincqr->intrc; |
| 1593 | else |
| 1594 | rc = -EIO; |
| 1595 | return rc; |
| 1596 | } |
| 1597 | |
| 1598 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1599 | * Queue a request to the tail of the device ccw_queue and wait for |
| 1600 | * it's completion. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1601 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1602 | int dasd_sleep_on(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1603 | { |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 1604 | return _dasd_sleep_on(cqr, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1605 | } |
| 1606 | |
| 1607 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1608 | * Queue a request to the tail of the device ccw_queue and wait |
| 1609 | * interruptible for it's completion. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1610 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1611 | int dasd_sleep_on_interruptible(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1612 | { |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 1613 | return _dasd_sleep_on(cqr, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1614 | } |
| 1615 | |
| 1616 | /* |
| 1617 | * Whoa nelly now it gets really hairy. For some functions (e.g. steal lock |
| 1618 | * for eckd devices) the currently running request has to be terminated |
| 1619 | * and be put back to status queued, before the special request is added |
| 1620 | * to the head of the queue. Then the special request is waited on normally. |
| 1621 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1622 | static inline int _dasd_term_running_cqr(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1623 | { |
| 1624 | struct dasd_ccw_req *cqr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1625 | |
| 1626 | if (list_empty(&device->ccw_queue)) |
| 1627 | return 0; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1628 | cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1629 | return device->discipline->term_IO(cqr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1630 | } |
| 1631 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1632 | int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1633 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1634 | struct dasd_device *device; |
| 1635 | int rc; |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 1636 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1637 | device = cqr->startdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1638 | spin_lock_irq(get_ccwdev_lock(device->cdev)); |
| 1639 | rc = _dasd_term_running_cqr(device); |
| 1640 | if (rc) { |
| 1641 | spin_unlock_irq(get_ccwdev_lock(device->cdev)); |
| 1642 | return rc; |
| 1643 | } |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 1644 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1645 | cqr->callback = dasd_wakeup_cb; |
Stefan Haberland | c80ee72 | 2008-05-30 10:03:31 +0200 | [diff] [blame] | 1646 | cqr->callback_data = (void *) &generic_waitq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1647 | cqr->status = DASD_CQR_QUEUED; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1648 | list_add(&cqr->devlist, &device->ccw_queue); |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 1649 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1650 | /* let the bh start the request to keep them in order */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1651 | dasd_schedule_device_bh(device); |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 1652 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1653 | spin_unlock_irq(get_ccwdev_lock(device->cdev)); |
| 1654 | |
Stefan Haberland | c80ee72 | 2008-05-30 10:03:31 +0200 | [diff] [blame] | 1655 | wait_event(generic_waitq, _wait_for_wakeup(cqr)); |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 1656 | |
Stefan Weinhuber | 6cc7f16 | 2009-06-12 10:26:39 +0200 | [diff] [blame] | 1657 | if (cqr->status == DASD_CQR_DONE) |
| 1658 | rc = 0; |
| 1659 | else if (cqr->intrc) |
| 1660 | rc = cqr->intrc; |
| 1661 | else |
| 1662 | rc = -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1663 | return rc; |
| 1664 | } |
| 1665 | |
| 1666 | /* |
| 1667 | * Cancels a request that was started with dasd_sleep_on_req. |
| 1668 | * This is useful to timeout requests. The request will be |
| 1669 | * terminated if it is currently in i/o. |
| 1670 | * Returns 1 if the request has been terminated. |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1671 | * 0 if there was no need to terminate the request (not started yet) |
| 1672 | * negative error code if termination failed |
| 1673 | * Cancellation of a request is an asynchronous operation! The calling |
| 1674 | * function has to wait until the request is properly returned via callback. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1675 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1676 | int dasd_cancel_req(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1677 | { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1678 | struct dasd_device *device = cqr->startdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1679 | unsigned long flags; |
| 1680 | int rc; |
| 1681 | |
| 1682 | rc = 0; |
| 1683 | spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); |
| 1684 | switch (cqr->status) { |
| 1685 | case DASD_CQR_QUEUED: |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1686 | /* request was not started - just set to cleared */ |
| 1687 | cqr->status = DASD_CQR_CLEARED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1688 | break; |
| 1689 | case DASD_CQR_IN_IO: |
| 1690 | /* request in IO - terminate IO and release again */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1691 | rc = device->discipline->term_IO(cqr); |
| 1692 | if (rc) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1693 | dev_err(&device->cdev->dev, |
| 1694 | "Cancelling request %p failed with rc=%d\n", |
| 1695 | cqr, rc); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1696 | } else { |
| 1697 | cqr->stopclk = get_clock(); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1698 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1699 | break; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1700 | default: /* already finished or clear pending - do nothing */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1701 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1702 | } |
| 1703 | spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1704 | dasd_schedule_device_bh(device); |
| 1705 | return rc; |
| 1706 | } |
| 1707 | |
| 1708 | |
| 1709 | /* |
| 1710 | * SECTION: Operations of the dasd_block layer. |
| 1711 | */ |
| 1712 | |
| 1713 | /* |
| 1714 | * Timeout function for dasd_block. This is used when the block layer |
| 1715 | * is waiting for something that may not come reliably, (e.g. a state |
| 1716 | * change interrupt) |
| 1717 | */ |
| 1718 | static void dasd_block_timeout(unsigned long ptr) |
| 1719 | { |
| 1720 | unsigned long flags; |
| 1721 | struct dasd_block *block; |
| 1722 | |
| 1723 | block = (struct dasd_block *) ptr; |
| 1724 | spin_lock_irqsave(get_ccwdev_lock(block->base->cdev), flags); |
| 1725 | /* re-activate request queue */ |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 1726 | dasd_device_remove_stop_bits(block->base, DASD_STOPPED_PENDING); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1727 | spin_unlock_irqrestore(get_ccwdev_lock(block->base->cdev), flags); |
| 1728 | dasd_schedule_block_bh(block); |
| 1729 | } |
| 1730 | |
| 1731 | /* |
| 1732 | * Setup timeout for a dasd_block in jiffies. |
| 1733 | */ |
| 1734 | void dasd_block_set_timer(struct dasd_block *block, int expires) |
| 1735 | { |
Stefan Weinhuber | 48cae88 | 2009-02-11 10:37:31 +0100 | [diff] [blame] | 1736 | if (expires == 0) |
| 1737 | del_timer(&block->timer); |
| 1738 | else |
| 1739 | mod_timer(&block->timer, jiffies + expires); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1740 | } |
| 1741 | |
| 1742 | /* |
| 1743 | * Clear timeout for a dasd_block. |
| 1744 | */ |
| 1745 | void dasd_block_clear_timer(struct dasd_block *block) |
| 1746 | { |
Stefan Weinhuber | 48cae88 | 2009-02-11 10:37:31 +0100 | [diff] [blame] | 1747 | del_timer(&block->timer); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1748 | } |
| 1749 | |
| 1750 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1751 | * Process finished error recovery ccw. |
| 1752 | */ |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 1753 | static void __dasd_process_erp(struct dasd_device *device, |
| 1754 | struct dasd_ccw_req *cqr) |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1755 | { |
| 1756 | dasd_erp_fn_t erp_fn; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1757 | |
| 1758 | if (cqr->status == DASD_CQR_DONE) |
| 1759 | DBF_DEV_EVENT(DBF_NOTICE, device, "%s", "ERP successful"); |
| 1760 | else |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1761 | dev_err(&device->cdev->dev, "ERP failed for the DASD\n"); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1762 | erp_fn = device->discipline->erp_postaction(cqr); |
| 1763 | erp_fn(cqr); |
| 1764 | } |
| 1765 | |
| 1766 | /* |
| 1767 | * Fetch requests from the block device queue. |
| 1768 | */ |
| 1769 | static void __dasd_process_request_queue(struct dasd_block *block) |
| 1770 | { |
| 1771 | struct request_queue *queue; |
| 1772 | struct request *req; |
| 1773 | struct dasd_ccw_req *cqr; |
| 1774 | struct dasd_device *basedev; |
| 1775 | unsigned long flags; |
| 1776 | queue = block->request_queue; |
| 1777 | basedev = block->base; |
| 1778 | /* No queue ? Then there is nothing to do. */ |
| 1779 | if (queue == NULL) |
| 1780 | return; |
| 1781 | |
| 1782 | /* |
| 1783 | * We requeue request from the block device queue to the ccw |
| 1784 | * queue only in two states. In state DASD_STATE_READY the |
| 1785 | * partition detection is done and we need to requeue requests |
| 1786 | * for that. State DASD_STATE_ONLINE is normal block device |
| 1787 | * operation. |
| 1788 | */ |
Stefan Weinhuber | 97f604b | 2009-09-11 10:28:28 +0200 | [diff] [blame] | 1789 | if (basedev->state < DASD_STATE_READY) { |
| 1790 | while ((req = blk_fetch_request(block->request_queue))) |
| 1791 | __blk_end_request_all(req, -EIO); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1792 | return; |
Stefan Weinhuber | 97f604b | 2009-09-11 10:28:28 +0200 | [diff] [blame] | 1793 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1794 | /* Now we try to fetch requests from the request queue */ |
Tejun Heo | 9934c8c | 2009-05-08 11:54:16 +0900 | [diff] [blame] | 1795 | while (!blk_queue_plugged(queue) && (req = blk_peek_request(queue))) { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1796 | if (basedev->features & DASD_FEATURE_READONLY && |
| 1797 | rq_data_dir(req) == WRITE) { |
| 1798 | DBF_DEV_EVENT(DBF_ERR, basedev, |
| 1799 | "Rejecting write request %p", |
| 1800 | req); |
Tejun Heo | 9934c8c | 2009-05-08 11:54:16 +0900 | [diff] [blame] | 1801 | blk_start_request(req); |
Tejun Heo | 40cbbb7 | 2009-04-23 11:05:19 +0900 | [diff] [blame] | 1802 | __blk_end_request_all(req, -EIO); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1803 | continue; |
| 1804 | } |
| 1805 | cqr = basedev->discipline->build_cp(basedev, block, req); |
| 1806 | if (IS_ERR(cqr)) { |
| 1807 | if (PTR_ERR(cqr) == -EBUSY) |
| 1808 | break; /* normal end condition */ |
| 1809 | if (PTR_ERR(cqr) == -ENOMEM) |
| 1810 | break; /* terminate request queue loop */ |
| 1811 | if (PTR_ERR(cqr) == -EAGAIN) { |
| 1812 | /* |
| 1813 | * The current request cannot be build right |
| 1814 | * now, we have to try later. If this request |
| 1815 | * is the head-of-queue we stop the device |
| 1816 | * for 1/2 second. |
| 1817 | */ |
| 1818 | if (!list_empty(&block->ccw_queue)) |
| 1819 | break; |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 1820 | spin_lock_irqsave( |
| 1821 | get_ccwdev_lock(basedev->cdev), flags); |
| 1822 | dasd_device_set_stop_bits(basedev, |
| 1823 | DASD_STOPPED_PENDING); |
| 1824 | spin_unlock_irqrestore( |
| 1825 | get_ccwdev_lock(basedev->cdev), flags); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1826 | dasd_block_set_timer(block, HZ/2); |
| 1827 | break; |
| 1828 | } |
| 1829 | DBF_DEV_EVENT(DBF_ERR, basedev, |
| 1830 | "CCW creation failed (rc=%ld) " |
| 1831 | "on request %p", |
| 1832 | PTR_ERR(cqr), req); |
Tejun Heo | 9934c8c | 2009-05-08 11:54:16 +0900 | [diff] [blame] | 1833 | blk_start_request(req); |
Tejun Heo | 40cbbb7 | 2009-04-23 11:05:19 +0900 | [diff] [blame] | 1834 | __blk_end_request_all(req, -EIO); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1835 | continue; |
| 1836 | } |
| 1837 | /* |
| 1838 | * Note: callback is set to dasd_return_cqr_cb in |
| 1839 | * __dasd_block_start_head to cover erp requests as well |
| 1840 | */ |
| 1841 | cqr->callback_data = (void *) req; |
| 1842 | cqr->status = DASD_CQR_FILLED; |
Tejun Heo | 9934c8c | 2009-05-08 11:54:16 +0900 | [diff] [blame] | 1843 | blk_start_request(req); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1844 | list_add_tail(&cqr->blocklist, &block->ccw_queue); |
| 1845 | dasd_profile_start(block, cqr, req); |
| 1846 | } |
| 1847 | } |
| 1848 | |
| 1849 | static void __dasd_cleanup_cqr(struct dasd_ccw_req *cqr) |
| 1850 | { |
| 1851 | struct request *req; |
| 1852 | int status; |
Kiyoshi Ueda | 4c4e214 | 2008-01-28 10:29:42 +0100 | [diff] [blame] | 1853 | int error = 0; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1854 | |
| 1855 | req = (struct request *) cqr->callback_data; |
| 1856 | dasd_profile_end(cqr->block, cqr, req); |
Stefan Weinhuber | fe6b8e7 | 2008-02-05 16:50:47 +0100 | [diff] [blame] | 1857 | status = cqr->block->base->discipline->free_cp(cqr, req); |
Kiyoshi Ueda | 4c4e214 | 2008-01-28 10:29:42 +0100 | [diff] [blame] | 1858 | if (status <= 0) |
| 1859 | error = status ? status : -EIO; |
Tejun Heo | 40cbbb7 | 2009-04-23 11:05:19 +0900 | [diff] [blame] | 1860 | __blk_end_request_all(req, error); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1861 | } |
| 1862 | |
| 1863 | /* |
| 1864 | * Process ccw request queue. |
| 1865 | */ |
| 1866 | static void __dasd_process_block_ccw_queue(struct dasd_block *block, |
| 1867 | struct list_head *final_queue) |
| 1868 | { |
| 1869 | struct list_head *l, *n; |
| 1870 | struct dasd_ccw_req *cqr; |
| 1871 | dasd_erp_fn_t erp_fn; |
| 1872 | unsigned long flags; |
| 1873 | struct dasd_device *base = block->base; |
| 1874 | |
| 1875 | restart: |
| 1876 | /* Process request with final status. */ |
| 1877 | list_for_each_safe(l, n, &block->ccw_queue) { |
| 1878 | cqr = list_entry(l, struct dasd_ccw_req, blocklist); |
| 1879 | if (cqr->status != DASD_CQR_DONE && |
| 1880 | cqr->status != DASD_CQR_FAILED && |
| 1881 | cqr->status != DASD_CQR_NEED_ERP && |
| 1882 | cqr->status != DASD_CQR_TERMINATED) |
| 1883 | continue; |
| 1884 | |
| 1885 | if (cqr->status == DASD_CQR_TERMINATED) { |
| 1886 | base->discipline->handle_terminated_request(cqr); |
| 1887 | goto restart; |
| 1888 | } |
| 1889 | |
| 1890 | /* Process requests that may be recovered */ |
| 1891 | if (cqr->status == DASD_CQR_NEED_ERP) { |
Stefan Haberland | 6c5f57c | 2008-02-05 16:50:46 +0100 | [diff] [blame] | 1892 | erp_fn = base->discipline->erp_action(cqr); |
| 1893 | erp_fn(cqr); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1894 | goto restart; |
| 1895 | } |
| 1896 | |
Stefan Haberland | a9cffb2 | 2008-11-14 18:18:08 +0100 | [diff] [blame] | 1897 | /* log sense for fatal error */ |
| 1898 | if (cqr->status == DASD_CQR_FAILED) { |
| 1899 | dasd_log_sense(cqr, &cqr->irb); |
| 1900 | } |
| 1901 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1902 | /* First of all call extended error reporting. */ |
| 1903 | if (dasd_eer_enabled(base) && |
| 1904 | cqr->status == DASD_CQR_FAILED) { |
| 1905 | dasd_eer_write(base, cqr, DASD_EER_FATALERROR); |
| 1906 | |
| 1907 | /* restart request */ |
| 1908 | cqr->status = DASD_CQR_FILLED; |
| 1909 | cqr->retries = 255; |
| 1910 | spin_lock_irqsave(get_ccwdev_lock(base->cdev), flags); |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 1911 | dasd_device_set_stop_bits(base, DASD_STOPPED_QUIESCE); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1912 | spin_unlock_irqrestore(get_ccwdev_lock(base->cdev), |
| 1913 | flags); |
| 1914 | goto restart; |
| 1915 | } |
| 1916 | |
| 1917 | /* Process finished ERP request. */ |
| 1918 | if (cqr->refers) { |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 1919 | __dasd_process_erp(base, cqr); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1920 | goto restart; |
| 1921 | } |
| 1922 | |
| 1923 | /* Rechain finished requests to final queue */ |
| 1924 | cqr->endclk = get_clock(); |
| 1925 | list_move_tail(&cqr->blocklist, final_queue); |
| 1926 | } |
| 1927 | } |
| 1928 | |
| 1929 | static void dasd_return_cqr_cb(struct dasd_ccw_req *cqr, void *data) |
| 1930 | { |
| 1931 | dasd_schedule_block_bh(cqr->block); |
| 1932 | } |
| 1933 | |
| 1934 | static void __dasd_block_start_head(struct dasd_block *block) |
| 1935 | { |
| 1936 | struct dasd_ccw_req *cqr; |
| 1937 | |
| 1938 | if (list_empty(&block->ccw_queue)) |
| 1939 | return; |
| 1940 | /* We allways begin with the first requests on the queue, as some |
| 1941 | * of previously started requests have to be enqueued on a |
| 1942 | * dasd_device again for error recovery. |
| 1943 | */ |
| 1944 | list_for_each_entry(cqr, &block->ccw_queue, blocklist) { |
| 1945 | if (cqr->status != DASD_CQR_FILLED) |
| 1946 | continue; |
| 1947 | /* Non-temporary stop condition will trigger fail fast */ |
| 1948 | if (block->base->stopped & ~DASD_STOPPED_PENDING && |
| 1949 | test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) && |
| 1950 | (!dasd_eer_enabled(block->base))) { |
| 1951 | cqr->status = DASD_CQR_FAILED; |
| 1952 | dasd_schedule_block_bh(block); |
| 1953 | continue; |
| 1954 | } |
| 1955 | /* Don't try to start requests if device is stopped */ |
| 1956 | if (block->base->stopped) |
| 1957 | return; |
| 1958 | |
| 1959 | /* just a fail safe check, should not happen */ |
| 1960 | if (!cqr->startdev) |
| 1961 | cqr->startdev = block->base; |
| 1962 | |
| 1963 | /* make sure that the requests we submit find their way back */ |
| 1964 | cqr->callback = dasd_return_cqr_cb; |
| 1965 | |
| 1966 | dasd_add_request_tail(cqr); |
| 1967 | } |
| 1968 | } |
| 1969 | |
| 1970 | /* |
| 1971 | * Central dasd_block layer routine. Takes requests from the generic |
| 1972 | * block layer request queue, creates ccw requests, enqueues them on |
| 1973 | * a dasd_device and processes ccw requests that have been returned. |
| 1974 | */ |
| 1975 | static void dasd_block_tasklet(struct dasd_block *block) |
| 1976 | { |
| 1977 | struct list_head final_queue; |
| 1978 | struct list_head *l, *n; |
| 1979 | struct dasd_ccw_req *cqr; |
| 1980 | |
| 1981 | atomic_set(&block->tasklet_scheduled, 0); |
| 1982 | INIT_LIST_HEAD(&final_queue); |
| 1983 | spin_lock(&block->queue_lock); |
| 1984 | /* Finish off requests on ccw queue */ |
| 1985 | __dasd_process_block_ccw_queue(block, &final_queue); |
| 1986 | spin_unlock(&block->queue_lock); |
| 1987 | /* Now call the callback function of requests with final status */ |
| 1988 | spin_lock_irq(&block->request_queue_lock); |
| 1989 | list_for_each_safe(l, n, &final_queue) { |
| 1990 | cqr = list_entry(l, struct dasd_ccw_req, blocklist); |
| 1991 | list_del_init(&cqr->blocklist); |
| 1992 | __dasd_cleanup_cqr(cqr); |
| 1993 | } |
| 1994 | spin_lock(&block->queue_lock); |
| 1995 | /* Get new request from the block device request queue */ |
| 1996 | __dasd_process_request_queue(block); |
| 1997 | /* Now check if the head of the ccw queue needs to be started. */ |
| 1998 | __dasd_block_start_head(block); |
| 1999 | spin_unlock(&block->queue_lock); |
| 2000 | spin_unlock_irq(&block->request_queue_lock); |
| 2001 | dasd_put_device(block->base); |
| 2002 | } |
| 2003 | |
| 2004 | static void _dasd_wake_block_flush_cb(struct dasd_ccw_req *cqr, void *data) |
| 2005 | { |
| 2006 | wake_up(&dasd_flush_wq); |
| 2007 | } |
| 2008 | |
| 2009 | /* |
| 2010 | * Go through all request on the dasd_block request queue, cancel them |
| 2011 | * on the respective dasd_device, and return them to the generic |
| 2012 | * block layer. |
| 2013 | */ |
| 2014 | static int dasd_flush_block_queue(struct dasd_block *block) |
| 2015 | { |
| 2016 | struct dasd_ccw_req *cqr, *n; |
| 2017 | int rc, i; |
| 2018 | struct list_head flush_queue; |
| 2019 | |
| 2020 | INIT_LIST_HEAD(&flush_queue); |
| 2021 | spin_lock_bh(&block->queue_lock); |
| 2022 | rc = 0; |
| 2023 | restart: |
| 2024 | list_for_each_entry_safe(cqr, n, &block->ccw_queue, blocklist) { |
| 2025 | /* if this request currently owned by a dasd_device cancel it */ |
| 2026 | if (cqr->status >= DASD_CQR_QUEUED) |
| 2027 | rc = dasd_cancel_req(cqr); |
| 2028 | if (rc < 0) |
| 2029 | break; |
| 2030 | /* Rechain request (including erp chain) so it won't be |
| 2031 | * touched by the dasd_block_tasklet anymore. |
| 2032 | * Replace the callback so we notice when the request |
| 2033 | * is returned from the dasd_device layer. |
| 2034 | */ |
| 2035 | cqr->callback = _dasd_wake_block_flush_cb; |
| 2036 | for (i = 0; cqr != NULL; cqr = cqr->refers, i++) |
| 2037 | list_move_tail(&cqr->blocklist, &flush_queue); |
| 2038 | if (i > 1) |
| 2039 | /* moved more than one request - need to restart */ |
| 2040 | goto restart; |
| 2041 | } |
| 2042 | spin_unlock_bh(&block->queue_lock); |
| 2043 | /* Now call the callback function of flushed requests */ |
| 2044 | restart_cb: |
| 2045 | list_for_each_entry_safe(cqr, n, &flush_queue, blocklist) { |
| 2046 | wait_event(dasd_flush_wq, (cqr->status < DASD_CQR_QUEUED)); |
| 2047 | /* Process finished ERP request. */ |
| 2048 | if (cqr->refers) { |
Stefan Haberland | 0cd4bd4 | 2008-12-25 13:38:54 +0100 | [diff] [blame] | 2049 | spin_lock_bh(&block->queue_lock); |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2050 | __dasd_process_erp(block->base, cqr); |
Stefan Haberland | 0cd4bd4 | 2008-12-25 13:38:54 +0100 | [diff] [blame] | 2051 | spin_unlock_bh(&block->queue_lock); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2052 | /* restart list_for_xx loop since dasd_process_erp |
| 2053 | * might remove multiple elements */ |
| 2054 | goto restart_cb; |
| 2055 | } |
| 2056 | /* call the callback function */ |
Stefan Haberland | 0cd4bd4 | 2008-12-25 13:38:54 +0100 | [diff] [blame] | 2057 | spin_lock_irq(&block->request_queue_lock); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2058 | cqr->endclk = get_clock(); |
| 2059 | list_del_init(&cqr->blocklist); |
| 2060 | __dasd_cleanup_cqr(cqr); |
Stefan Haberland | 0cd4bd4 | 2008-12-25 13:38:54 +0100 | [diff] [blame] | 2061 | spin_unlock_irq(&block->request_queue_lock); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2062 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2063 | return rc; |
| 2064 | } |
| 2065 | |
| 2066 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2067 | * Schedules a call to dasd_tasklet over the device tasklet. |
| 2068 | */ |
| 2069 | void dasd_schedule_block_bh(struct dasd_block *block) |
| 2070 | { |
| 2071 | /* Protect against rescheduling. */ |
| 2072 | if (atomic_cmpxchg(&block->tasklet_scheduled, 0, 1) != 0) |
| 2073 | return; |
| 2074 | /* life cycle of block is bound to it's base device */ |
| 2075 | dasd_get_device(block->base); |
| 2076 | tasklet_hi_schedule(&block->tasklet); |
| 2077 | } |
| 2078 | |
| 2079 | |
| 2080 | /* |
| 2081 | * SECTION: external block device operations |
| 2082 | * (request queue handling, open, release, etc.) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2083 | */ |
| 2084 | |
| 2085 | /* |
| 2086 | * Dasd request queue function. Called from ll_rw_blk.c |
| 2087 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2088 | static void do_dasd_request(struct request_queue *queue) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2089 | { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2090 | struct dasd_block *block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2091 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2092 | block = queue->queuedata; |
| 2093 | spin_lock(&block->queue_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2094 | /* Get new request from the block device request queue */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2095 | __dasd_process_request_queue(block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2096 | /* Now check if the head of the ccw queue needs to be started. */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2097 | __dasd_block_start_head(block); |
| 2098 | spin_unlock(&block->queue_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2099 | } |
| 2100 | |
| 2101 | /* |
| 2102 | * Allocate and initialize request queue and default I/O scheduler. |
| 2103 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2104 | static int dasd_alloc_queue(struct dasd_block *block) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2105 | { |
| 2106 | int rc; |
| 2107 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2108 | block->request_queue = blk_init_queue(do_dasd_request, |
| 2109 | &block->request_queue_lock); |
| 2110 | if (block->request_queue == NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2111 | return -ENOMEM; |
| 2112 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2113 | block->request_queue->queuedata = block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2114 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2115 | elevator_exit(block->request_queue->elevator); |
Josef 'Jeff' Sipek | 08a8a0c | 2008-04-17 07:45:56 +0200 | [diff] [blame] | 2116 | block->request_queue->elevator = NULL; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2117 | rc = elevator_init(block->request_queue, "deadline"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2118 | if (rc) { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2119 | blk_cleanup_queue(block->request_queue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2120 | return rc; |
| 2121 | } |
| 2122 | return 0; |
| 2123 | } |
| 2124 | |
| 2125 | /* |
| 2126 | * Allocate and initialize request queue. |
| 2127 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2128 | static void dasd_setup_queue(struct dasd_block *block) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2129 | { |
| 2130 | int max; |
| 2131 | |
Martin K. Petersen | e1defc4 | 2009-05-22 17:17:49 -0400 | [diff] [blame] | 2132 | blk_queue_logical_block_size(block->request_queue, block->bp_block); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2133 | max = block->base->discipline->max_blocks << block->s2b_shift; |
| 2134 | blk_queue_max_sectors(block->request_queue, max); |
| 2135 | blk_queue_max_phys_segments(block->request_queue, -1L); |
| 2136 | blk_queue_max_hw_segments(block->request_queue, -1L); |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 2137 | /* with page sized segments we can translate each segement into |
| 2138 | * one idaw/tidaw |
| 2139 | */ |
| 2140 | blk_queue_max_segment_size(block->request_queue, PAGE_SIZE); |
| 2141 | blk_queue_segment_boundary(block->request_queue, PAGE_SIZE - 1); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2142 | blk_queue_ordered(block->request_queue, QUEUE_ORDERED_DRAIN, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2143 | } |
| 2144 | |
| 2145 | /* |
| 2146 | * Deactivate and free request queue. |
| 2147 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2148 | static void dasd_free_queue(struct dasd_block *block) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2149 | { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2150 | if (block->request_queue) { |
| 2151 | blk_cleanup_queue(block->request_queue); |
| 2152 | block->request_queue = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2153 | } |
| 2154 | } |
| 2155 | |
| 2156 | /* |
| 2157 | * Flush request on the request queue. |
| 2158 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2159 | static void dasd_flush_request_queue(struct dasd_block *block) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2160 | { |
| 2161 | struct request *req; |
| 2162 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2163 | if (!block->request_queue) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2164 | return; |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 2165 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2166 | spin_lock_irq(&block->request_queue_lock); |
Tejun Heo | 9934c8c | 2009-05-08 11:54:16 +0900 | [diff] [blame] | 2167 | while ((req = blk_fetch_request(block->request_queue))) |
Tejun Heo | 40cbbb7 | 2009-04-23 11:05:19 +0900 | [diff] [blame] | 2168 | __blk_end_request_all(req, -EIO); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2169 | spin_unlock_irq(&block->request_queue_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2170 | } |
| 2171 | |
Al Viro | 57a7c0b | 2008-03-02 10:36:08 -0500 | [diff] [blame] | 2172 | static int dasd_open(struct block_device *bdev, fmode_t mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2173 | { |
Al Viro | 57a7c0b | 2008-03-02 10:36:08 -0500 | [diff] [blame] | 2174 | struct dasd_block *block = bdev->bd_disk->private_data; |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame^] | 2175 | struct dasd_device *base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2176 | int rc; |
| 2177 | |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame^] | 2178 | if (!block) |
| 2179 | return -ENODEV; |
| 2180 | |
| 2181 | base = block->base; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2182 | atomic_inc(&block->open_count); |
| 2183 | if (test_bit(DASD_FLAG_OFFLINE, &base->flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2184 | rc = -ENODEV; |
| 2185 | goto unlock; |
| 2186 | } |
| 2187 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2188 | if (!try_module_get(base->discipline->owner)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2189 | rc = -EINVAL; |
| 2190 | goto unlock; |
| 2191 | } |
| 2192 | |
| 2193 | if (dasd_probeonly) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 2194 | dev_info(&base->cdev->dev, |
| 2195 | "Accessing the DASD failed because it is in " |
| 2196 | "probeonly mode\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2197 | rc = -EPERM; |
| 2198 | goto out; |
| 2199 | } |
| 2200 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2201 | if (base->state <= DASD_STATE_BASIC) { |
| 2202 | DBF_DEV_EVENT(DBF_ERR, base, " %s", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2203 | " Cannot open unrecognized device"); |
| 2204 | rc = -ENODEV; |
| 2205 | goto out; |
| 2206 | } |
| 2207 | |
| 2208 | return 0; |
| 2209 | |
| 2210 | out: |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2211 | module_put(base->discipline->owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2212 | unlock: |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2213 | atomic_dec(&block->open_count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2214 | return rc; |
| 2215 | } |
| 2216 | |
Al Viro | 57a7c0b | 2008-03-02 10:36:08 -0500 | [diff] [blame] | 2217 | static int dasd_release(struct gendisk *disk, fmode_t mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2218 | { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2219 | struct dasd_block *block = disk->private_data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2220 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2221 | atomic_dec(&block->open_count); |
| 2222 | module_put(block->base->discipline->owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2223 | return 0; |
| 2224 | } |
| 2225 | |
Christoph Hellwig | a885c8c | 2006-01-08 01:02:50 -0800 | [diff] [blame] | 2226 | /* |
| 2227 | * Return disk geometry. |
| 2228 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2229 | static int dasd_getgeo(struct block_device *bdev, struct hd_geometry *geo) |
Christoph Hellwig | a885c8c | 2006-01-08 01:02:50 -0800 | [diff] [blame] | 2230 | { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2231 | struct dasd_block *block; |
| 2232 | struct dasd_device *base; |
Christoph Hellwig | a885c8c | 2006-01-08 01:02:50 -0800 | [diff] [blame] | 2233 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2234 | block = bdev->bd_disk->private_data; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2235 | if (!block) |
Christoph Hellwig | a885c8c | 2006-01-08 01:02:50 -0800 | [diff] [blame] | 2236 | return -ENODEV; |
Julia Lawall | cf05b82 | 2009-08-23 18:09:05 +0200 | [diff] [blame] | 2237 | base = block->base; |
Christoph Hellwig | a885c8c | 2006-01-08 01:02:50 -0800 | [diff] [blame] | 2238 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2239 | if (!base->discipline || |
| 2240 | !base->discipline->fill_geometry) |
Christoph Hellwig | a885c8c | 2006-01-08 01:02:50 -0800 | [diff] [blame] | 2241 | return -EINVAL; |
| 2242 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2243 | base->discipline->fill_geometry(block, geo); |
| 2244 | geo->start = get_start_sect(bdev) >> block->s2b_shift; |
Christoph Hellwig | a885c8c | 2006-01-08 01:02:50 -0800 | [diff] [blame] | 2245 | return 0; |
| 2246 | } |
| 2247 | |
Alexey Dobriyan | 83d5cde | 2009-09-21 17:01:13 -0700 | [diff] [blame] | 2248 | const struct block_device_operations |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2249 | dasd_device_operations = { |
| 2250 | .owner = THIS_MODULE, |
Al Viro | 57a7c0b | 2008-03-02 10:36:08 -0500 | [diff] [blame] | 2251 | .open = dasd_open, |
| 2252 | .release = dasd_release, |
Heiko Carstens | 0000d03 | 2009-03-26 15:23:45 +0100 | [diff] [blame] | 2253 | .ioctl = dasd_ioctl, |
| 2254 | .compat_ioctl = dasd_ioctl, |
Christoph Hellwig | a885c8c | 2006-01-08 01:02:50 -0800 | [diff] [blame] | 2255 | .getgeo = dasd_getgeo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2256 | }; |
| 2257 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2258 | /******************************************************************************* |
| 2259 | * end of block device operations |
| 2260 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2261 | |
| 2262 | static void |
| 2263 | dasd_exit(void) |
| 2264 | { |
| 2265 | #ifdef CONFIG_PROC_FS |
| 2266 | dasd_proc_exit(); |
| 2267 | #endif |
Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 2268 | dasd_eer_exit(); |
Horst Hummel | 6bb0e01 | 2005-07-27 11:45:03 -0700 | [diff] [blame] | 2269 | if (dasd_page_cache != NULL) { |
| 2270 | kmem_cache_destroy(dasd_page_cache); |
| 2271 | dasd_page_cache = NULL; |
| 2272 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2273 | dasd_gendisk_exit(); |
| 2274 | dasd_devmap_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2275 | if (dasd_debug_area != NULL) { |
| 2276 | debug_unregister(dasd_debug_area); |
| 2277 | dasd_debug_area = NULL; |
| 2278 | } |
| 2279 | } |
| 2280 | |
| 2281 | /* |
| 2282 | * SECTION: common functions for ccw_driver use |
| 2283 | */ |
| 2284 | |
Cornelia Huck | f3445a1 | 2009-04-14 15:36:23 +0200 | [diff] [blame] | 2285 | static void dasd_generic_auto_online(void *data, async_cookie_t cookie) |
| 2286 | { |
| 2287 | struct ccw_device *cdev = data; |
| 2288 | int ret; |
| 2289 | |
| 2290 | ret = ccw_device_set_online(cdev); |
| 2291 | if (ret) |
| 2292 | pr_warning("%s: Setting the DASD online failed with rc=%d\n", |
| 2293 | dev_name(&cdev->dev), ret); |
| 2294 | else { |
| 2295 | struct dasd_device *device = dasd_device_from_cdev(cdev); |
| 2296 | wait_event(dasd_init_waitq, _wait_for_device(device)); |
| 2297 | dasd_put_device(device); |
| 2298 | } |
| 2299 | } |
| 2300 | |
Horst Hummel | 1c01b8a | 2006-01-06 00:19:15 -0800 | [diff] [blame] | 2301 | /* |
| 2302 | * Initial attempt at a probe function. this can be simplified once |
| 2303 | * the other detection code is gone. |
| 2304 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2305 | int dasd_generic_probe(struct ccw_device *cdev, |
| 2306 | struct dasd_discipline *discipline) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2307 | { |
| 2308 | int ret; |
| 2309 | |
| 2310 | ret = dasd_add_sysfs_files(cdev); |
| 2311 | if (ret) { |
Stefan Haberland | b8ed5dd | 2009-12-07 12:51:52 +0100 | [diff] [blame] | 2312 | DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s", |
| 2313 | "dasd_generic_probe: could not add " |
| 2314 | "sysfs entries"); |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 2315 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2316 | } |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 2317 | cdev->handler = &dasd_int_handler; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2318 | |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 2319 | /* |
| 2320 | * Automatically online either all dasd devices (dasd_autodetect) |
| 2321 | * or all devices specified with dasd= parameters during |
| 2322 | * initial probe. |
| 2323 | */ |
| 2324 | if ((dasd_get_feature(cdev, DASD_FEATURE_INITIAL_ONLINE) > 0 ) || |
Kay Sievers | 2a0217d | 2008-10-10 21:33:09 +0200 | [diff] [blame] | 2325 | (dasd_autodetect && dasd_busid_known(dev_name(&cdev->dev)) != 0)) |
Cornelia Huck | f3445a1 | 2009-04-14 15:36:23 +0200 | [diff] [blame] | 2326 | async_schedule(dasd_generic_auto_online, cdev); |
Stefan Haberland | de3e0da | 2008-01-26 14:11:08 +0100 | [diff] [blame] | 2327 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2328 | } |
| 2329 | |
Horst Hummel | 1c01b8a | 2006-01-06 00:19:15 -0800 | [diff] [blame] | 2330 | /* |
| 2331 | * This will one day be called from a global not_oper handler. |
| 2332 | * It is also used by driver_unregister during module unload. |
| 2333 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2334 | void dasd_generic_remove(struct ccw_device *cdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2335 | { |
| 2336 | struct dasd_device *device; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2337 | struct dasd_block *block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2338 | |
Horst Hummel | 59afda7 | 2005-05-16 21:53:39 -0700 | [diff] [blame] | 2339 | cdev->handler = NULL; |
| 2340 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2341 | dasd_remove_sysfs_files(cdev); |
| 2342 | device = dasd_device_from_cdev(cdev); |
| 2343 | if (IS_ERR(device)) |
| 2344 | return; |
| 2345 | if (test_and_set_bit(DASD_FLAG_OFFLINE, &device->flags)) { |
| 2346 | /* Already doing offline processing */ |
| 2347 | dasd_put_device(device); |
| 2348 | return; |
| 2349 | } |
| 2350 | /* |
| 2351 | * This device is removed unconditionally. Set offline |
| 2352 | * flag to prevent dasd_open from opening it while it is |
| 2353 | * no quite down yet. |
| 2354 | */ |
| 2355 | dasd_set_target_state(device, DASD_STATE_NEW); |
| 2356 | /* dasd_delete_device destroys the device reference. */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2357 | block = device->block; |
| 2358 | device->block = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2359 | dasd_delete_device(device); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2360 | /* |
| 2361 | * life cycle of block is bound to device, so delete it after |
| 2362 | * device was safely removed |
| 2363 | */ |
| 2364 | if (block) |
| 2365 | dasd_free_block(block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2366 | } |
| 2367 | |
Horst Hummel | 1c01b8a | 2006-01-06 00:19:15 -0800 | [diff] [blame] | 2368 | /* |
| 2369 | * Activate a device. This is called from dasd_{eckd,fba}_probe() when either |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2370 | * the device is detected for the first time and is supposed to be used |
Horst Hummel | 1c01b8a | 2006-01-06 00:19:15 -0800 | [diff] [blame] | 2371 | * or the user has started activation through sysfs. |
| 2372 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2373 | int dasd_generic_set_online(struct ccw_device *cdev, |
| 2374 | struct dasd_discipline *base_discipline) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2375 | { |
Peter Oberparleiter | aa88861 | 2006-02-20 18:28:13 -0800 | [diff] [blame] | 2376 | struct dasd_discipline *discipline; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2377 | struct dasd_device *device; |
Horst Hummel | c6eb7b7 | 2005-09-03 15:57:58 -0700 | [diff] [blame] | 2378 | int rc; |
Horst Hummel | f24acd4 | 2005-05-01 08:58:59 -0700 | [diff] [blame] | 2379 | |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 2380 | /* first online clears initial online feature flag */ |
| 2381 | dasd_set_feature(cdev, DASD_FEATURE_INITIAL_ONLINE, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2382 | device = dasd_create_device(cdev); |
| 2383 | if (IS_ERR(device)) |
| 2384 | return PTR_ERR(device); |
| 2385 | |
Peter Oberparleiter | aa88861 | 2006-02-20 18:28:13 -0800 | [diff] [blame] | 2386 | discipline = base_discipline; |
Horst Hummel | c6eb7b7 | 2005-09-03 15:57:58 -0700 | [diff] [blame] | 2387 | if (device->features & DASD_FEATURE_USEDIAG) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2388 | if (!dasd_diag_discipline_pointer) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 2389 | pr_warning("%s Setting the DASD online failed because " |
| 2390 | "of missing DIAG discipline\n", |
| 2391 | dev_name(&cdev->dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2392 | dasd_delete_device(device); |
| 2393 | return -ENODEV; |
| 2394 | } |
| 2395 | discipline = dasd_diag_discipline_pointer; |
| 2396 | } |
Peter Oberparleiter | aa88861 | 2006-02-20 18:28:13 -0800 | [diff] [blame] | 2397 | if (!try_module_get(base_discipline->owner)) { |
| 2398 | dasd_delete_device(device); |
| 2399 | return -EINVAL; |
| 2400 | } |
| 2401 | if (!try_module_get(discipline->owner)) { |
| 2402 | module_put(base_discipline->owner); |
| 2403 | dasd_delete_device(device); |
| 2404 | return -EINVAL; |
| 2405 | } |
| 2406 | device->base_discipline = base_discipline; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2407 | device->discipline = discipline; |
| 2408 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2409 | /* check_device will allocate block device if necessary */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2410 | rc = discipline->check_device(device); |
| 2411 | if (rc) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 2412 | pr_warning("%s Setting the DASD online with discipline %s " |
| 2413 | "failed with rc=%i\n", |
| 2414 | dev_name(&cdev->dev), discipline->name, rc); |
Peter Oberparleiter | aa88861 | 2006-02-20 18:28:13 -0800 | [diff] [blame] | 2415 | module_put(discipline->owner); |
| 2416 | module_put(base_discipline->owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2417 | dasd_delete_device(device); |
| 2418 | return rc; |
| 2419 | } |
| 2420 | |
| 2421 | dasd_set_target_state(device, DASD_STATE_ONLINE); |
| 2422 | if (device->state <= DASD_STATE_KNOWN) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 2423 | pr_warning("%s Setting the DASD online failed because of a " |
| 2424 | "missing discipline\n", dev_name(&cdev->dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2425 | rc = -ENODEV; |
| 2426 | dasd_set_target_state(device, DASD_STATE_NEW); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2427 | if (device->block) |
| 2428 | dasd_free_block(device->block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2429 | dasd_delete_device(device); |
| 2430 | } else |
| 2431 | pr_debug("dasd_generic device %s found\n", |
Kay Sievers | 2a0217d | 2008-10-10 21:33:09 +0200 | [diff] [blame] | 2432 | dev_name(&cdev->dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2433 | dasd_put_device(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2434 | return rc; |
| 2435 | } |
| 2436 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2437 | int dasd_generic_set_offline(struct ccw_device *cdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2438 | { |
| 2439 | struct dasd_device *device; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2440 | struct dasd_block *block; |
Horst Hummel | dafd87a | 2006-04-10 22:53:47 -0700 | [diff] [blame] | 2441 | int max_count, open_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2442 | |
| 2443 | device = dasd_device_from_cdev(cdev); |
| 2444 | if (IS_ERR(device)) |
| 2445 | return PTR_ERR(device); |
| 2446 | if (test_and_set_bit(DASD_FLAG_OFFLINE, &device->flags)) { |
| 2447 | /* Already doing offline processing */ |
| 2448 | dasd_put_device(device); |
| 2449 | return 0; |
| 2450 | } |
| 2451 | /* |
| 2452 | * We must make sure that this device is currently not in use. |
| 2453 | * The open_count is increased for every opener, that includes |
| 2454 | * the blkdev_get in dasd_scan_partitions. We are only interested |
| 2455 | * in the other openers. |
| 2456 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2457 | if (device->block) { |
Heiko Carstens | a806170 | 2008-04-17 07:46:26 +0200 | [diff] [blame] | 2458 | max_count = device->block->bdev ? 0 : -1; |
| 2459 | open_count = atomic_read(&device->block->open_count); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2460 | if (open_count > max_count) { |
| 2461 | if (open_count > 0) |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 2462 | pr_warning("%s: The DASD cannot be set offline " |
| 2463 | "with open count %i\n", |
| 2464 | dev_name(&cdev->dev), open_count); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2465 | else |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 2466 | pr_warning("%s: The DASD cannot be set offline " |
| 2467 | "while it is in use\n", |
| 2468 | dev_name(&cdev->dev)); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2469 | clear_bit(DASD_FLAG_OFFLINE, &device->flags); |
| 2470 | dasd_put_device(device); |
| 2471 | return -EBUSY; |
| 2472 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2473 | } |
| 2474 | dasd_set_target_state(device, DASD_STATE_NEW); |
| 2475 | /* dasd_delete_device destroys the device reference. */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2476 | block = device->block; |
| 2477 | device->block = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2478 | dasd_delete_device(device); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2479 | /* |
| 2480 | * life cycle of block is bound to device, so delete it after |
| 2481 | * device was safely removed |
| 2482 | */ |
| 2483 | if (block) |
| 2484 | dasd_free_block(block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2485 | return 0; |
| 2486 | } |
| 2487 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2488 | int dasd_generic_notify(struct ccw_device *cdev, int event) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2489 | { |
| 2490 | struct dasd_device *device; |
| 2491 | struct dasd_ccw_req *cqr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2492 | int ret; |
| 2493 | |
Peter Oberparleiter | 91c3691 | 2008-08-21 19:46:39 +0200 | [diff] [blame] | 2494 | device = dasd_device_from_cdev_locked(cdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2495 | if (IS_ERR(device)) |
| 2496 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2497 | ret = 0; |
| 2498 | switch (event) { |
| 2499 | case CIO_GONE: |
Sebastian Ott | 47593bf | 2009-03-31 19:16:05 +0200 | [diff] [blame] | 2500 | case CIO_BOXED: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2501 | case CIO_NO_PATH: |
Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 2502 | /* First of all call extended error reporting. */ |
| 2503 | dasd_eer_write(device, NULL, DASD_EER_NOPATH); |
| 2504 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2505 | if (device->state < DASD_STATE_BASIC) |
| 2506 | break; |
| 2507 | /* Device is active. We want to keep it. */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2508 | list_for_each_entry(cqr, &device->ccw_queue, devlist) |
| 2509 | if (cqr->status == DASD_CQR_IN_IO) { |
| 2510 | cqr->status = DASD_CQR_QUEUED; |
| 2511 | cqr->retries++; |
| 2512 | } |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2513 | dasd_device_set_stop_bits(device, DASD_STOPPED_DC_WAIT); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2514 | dasd_device_clear_timer(device); |
| 2515 | dasd_schedule_device_bh(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2516 | ret = 1; |
| 2517 | break; |
| 2518 | case CIO_OPER: |
| 2519 | /* FIXME: add a sanity check. */ |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2520 | dasd_device_remove_stop_bits(device, DASD_STOPPED_DC_WAIT); |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 2521 | if (device->stopped & DASD_UNRESUMED_PM) { |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2522 | dasd_device_remove_stop_bits(device, DASD_UNRESUMED_PM); |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 2523 | dasd_restore_device(device); |
| 2524 | ret = 1; |
| 2525 | break; |
| 2526 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2527 | dasd_schedule_device_bh(device); |
| 2528 | if (device->block) |
| 2529 | dasd_schedule_block_bh(device->block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2530 | ret = 1; |
| 2531 | break; |
| 2532 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2533 | dasd_put_device(device); |
| 2534 | return ret; |
| 2535 | } |
| 2536 | |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 2537 | int dasd_generic_pm_freeze(struct ccw_device *cdev) |
| 2538 | { |
| 2539 | struct dasd_ccw_req *cqr, *n; |
| 2540 | int rc; |
| 2541 | struct list_head freeze_queue; |
| 2542 | struct dasd_device *device = dasd_device_from_cdev(cdev); |
| 2543 | |
| 2544 | if (IS_ERR(device)) |
| 2545 | return PTR_ERR(device); |
| 2546 | /* disallow new I/O */ |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2547 | dasd_device_set_stop_bits(device, DASD_STOPPED_PM); |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 2548 | /* clear active requests */ |
| 2549 | INIT_LIST_HEAD(&freeze_queue); |
| 2550 | spin_lock_irq(get_ccwdev_lock(cdev)); |
| 2551 | rc = 0; |
| 2552 | list_for_each_entry_safe(cqr, n, &device->ccw_queue, devlist) { |
| 2553 | /* Check status and move request to flush_queue */ |
| 2554 | if (cqr->status == DASD_CQR_IN_IO) { |
| 2555 | rc = device->discipline->term_IO(cqr); |
| 2556 | if (rc) { |
| 2557 | /* unable to terminate requeust */ |
| 2558 | dev_err(&device->cdev->dev, |
| 2559 | "Unable to terminate request %p " |
| 2560 | "on suspend\n", cqr); |
| 2561 | spin_unlock_irq(get_ccwdev_lock(cdev)); |
| 2562 | dasd_put_device(device); |
| 2563 | return rc; |
| 2564 | } |
| 2565 | } |
| 2566 | list_move_tail(&cqr->devlist, &freeze_queue); |
| 2567 | } |
| 2568 | |
| 2569 | spin_unlock_irq(get_ccwdev_lock(cdev)); |
| 2570 | |
| 2571 | list_for_each_entry_safe(cqr, n, &freeze_queue, devlist) { |
| 2572 | wait_event(dasd_flush_wq, |
| 2573 | (cqr->status != DASD_CQR_CLEAR_PENDING)); |
| 2574 | if (cqr->status == DASD_CQR_CLEARED) |
| 2575 | cqr->status = DASD_CQR_QUEUED; |
| 2576 | } |
| 2577 | /* move freeze_queue to start of the ccw_queue */ |
| 2578 | spin_lock_irq(get_ccwdev_lock(cdev)); |
| 2579 | list_splice_tail(&freeze_queue, &device->ccw_queue); |
| 2580 | spin_unlock_irq(get_ccwdev_lock(cdev)); |
| 2581 | |
| 2582 | if (device->discipline->freeze) |
| 2583 | rc = device->discipline->freeze(device); |
| 2584 | |
| 2585 | dasd_put_device(device); |
| 2586 | return rc; |
| 2587 | } |
| 2588 | EXPORT_SYMBOL_GPL(dasd_generic_pm_freeze); |
| 2589 | |
| 2590 | int dasd_generic_restore_device(struct ccw_device *cdev) |
| 2591 | { |
| 2592 | struct dasd_device *device = dasd_device_from_cdev(cdev); |
| 2593 | int rc = 0; |
| 2594 | |
| 2595 | if (IS_ERR(device)) |
| 2596 | return PTR_ERR(device); |
| 2597 | |
Stefan Haberland | e6125fb | 2009-06-22 12:08:17 +0200 | [diff] [blame] | 2598 | /* allow new IO again */ |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2599 | dasd_device_remove_stop_bits(device, |
| 2600 | (DASD_STOPPED_PM | DASD_UNRESUMED_PM)); |
Stefan Haberland | e6125fb | 2009-06-22 12:08:17 +0200 | [diff] [blame] | 2601 | |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 2602 | dasd_schedule_device_bh(device); |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 2603 | |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2604 | /* |
| 2605 | * call discipline restore function |
| 2606 | * if device is stopped do nothing e.g. for disconnected devices |
| 2607 | */ |
| 2608 | if (device->discipline->restore && !(device->stopped)) |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 2609 | rc = device->discipline->restore(device); |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2610 | if (rc || device->stopped) |
Stefan Haberland | e6125fb | 2009-06-22 12:08:17 +0200 | [diff] [blame] | 2611 | /* |
| 2612 | * if the resume failed for the DASD we put it in |
| 2613 | * an UNRESUMED stop state |
| 2614 | */ |
| 2615 | device->stopped |= DASD_UNRESUMED_PM; |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 2616 | |
Stefan Haberland | 6fca97a | 2009-10-06 10:34:15 +0200 | [diff] [blame] | 2617 | if (device->block) |
| 2618 | dasd_schedule_block_bh(device->block); |
| 2619 | |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 2620 | dasd_put_device(device); |
Stefan Haberland | e6125fb | 2009-06-22 12:08:17 +0200 | [diff] [blame] | 2621 | return 0; |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 2622 | } |
| 2623 | EXPORT_SYMBOL_GPL(dasd_generic_restore_device); |
| 2624 | |
Heiko Carstens | 763968e | 2007-05-10 15:45:46 +0200 | [diff] [blame] | 2625 | static struct dasd_ccw_req *dasd_generic_build_rdc(struct dasd_device *device, |
| 2626 | void *rdc_buffer, |
| 2627 | int rdc_buffer_size, |
Stefan Haberland | 68b781f | 2009-09-11 10:28:29 +0200 | [diff] [blame] | 2628 | int magic) |
Cornelia Huck | 17283b5 | 2007-05-04 18:47:51 +0200 | [diff] [blame] | 2629 | { |
| 2630 | struct dasd_ccw_req *cqr; |
| 2631 | struct ccw1 *ccw; |
Stefan Haberland | d9fa944 | 2009-10-14 12:43:48 +0200 | [diff] [blame] | 2632 | unsigned long *idaw; |
Cornelia Huck | 17283b5 | 2007-05-04 18:47:51 +0200 | [diff] [blame] | 2633 | |
| 2634 | cqr = dasd_smalloc_request(magic, 1 /* RDC */, rdc_buffer_size, device); |
| 2635 | |
| 2636 | if (IS_ERR(cqr)) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 2637 | /* internal error 13 - Allocating the RDC request failed*/ |
| 2638 | dev_err(&device->cdev->dev, |
| 2639 | "An error occurred in the DASD device driver, " |
| 2640 | "reason=%s\n", "13"); |
Cornelia Huck | 17283b5 | 2007-05-04 18:47:51 +0200 | [diff] [blame] | 2641 | return cqr; |
| 2642 | } |
| 2643 | |
| 2644 | ccw = cqr->cpaddr; |
| 2645 | ccw->cmd_code = CCW_CMD_RDC; |
Stefan Haberland | d9fa944 | 2009-10-14 12:43:48 +0200 | [diff] [blame] | 2646 | if (idal_is_needed(rdc_buffer, rdc_buffer_size)) { |
| 2647 | idaw = (unsigned long *) (cqr->data); |
| 2648 | ccw->cda = (__u32)(addr_t) idaw; |
| 2649 | ccw->flags = CCW_FLAG_IDA; |
| 2650 | idaw = idal_create_words(idaw, rdc_buffer, rdc_buffer_size); |
| 2651 | } else { |
| 2652 | ccw->cda = (__u32)(addr_t) rdc_buffer; |
| 2653 | ccw->flags = 0; |
| 2654 | } |
Cornelia Huck | 17283b5 | 2007-05-04 18:47:51 +0200 | [diff] [blame] | 2655 | |
Stefan Haberland | d9fa944 | 2009-10-14 12:43:48 +0200 | [diff] [blame] | 2656 | ccw->count = rdc_buffer_size; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2657 | cqr->startdev = device; |
| 2658 | cqr->memdev = device; |
Cornelia Huck | 17283b5 | 2007-05-04 18:47:51 +0200 | [diff] [blame] | 2659 | cqr->expires = 10*HZ; |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2660 | cqr->retries = 256; |
Cornelia Huck | 17283b5 | 2007-05-04 18:47:51 +0200 | [diff] [blame] | 2661 | cqr->buildclk = get_clock(); |
| 2662 | cqr->status = DASD_CQR_FILLED; |
| 2663 | return cqr; |
| 2664 | } |
| 2665 | |
| 2666 | |
Stefan Haberland | 68b781f | 2009-09-11 10:28:29 +0200 | [diff] [blame] | 2667 | int dasd_generic_read_dev_chars(struct dasd_device *device, int magic, |
Sebastian Ott | 92636b1 | 2009-06-12 10:26:37 +0200 | [diff] [blame] | 2668 | void *rdc_buffer, int rdc_buffer_size) |
Cornelia Huck | 17283b5 | 2007-05-04 18:47:51 +0200 | [diff] [blame] | 2669 | { |
| 2670 | int ret; |
| 2671 | struct dasd_ccw_req *cqr; |
| 2672 | |
Sebastian Ott | 92636b1 | 2009-06-12 10:26:37 +0200 | [diff] [blame] | 2673 | cqr = dasd_generic_build_rdc(device, rdc_buffer, rdc_buffer_size, |
Cornelia Huck | 17283b5 | 2007-05-04 18:47:51 +0200 | [diff] [blame] | 2674 | magic); |
| 2675 | if (IS_ERR(cqr)) |
| 2676 | return PTR_ERR(cqr); |
| 2677 | |
| 2678 | ret = dasd_sleep_on(cqr); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2679 | dasd_sfree_request(cqr, cqr->memdev); |
Cornelia Huck | 17283b5 | 2007-05-04 18:47:51 +0200 | [diff] [blame] | 2680 | return ret; |
| 2681 | } |
Cornelia Huck | aaff0f6 | 2007-05-10 15:45:45 +0200 | [diff] [blame] | 2682 | EXPORT_SYMBOL_GPL(dasd_generic_read_dev_chars); |
Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 2683 | |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 2684 | /* |
| 2685 | * In command mode and transport mode we need to look for sense |
| 2686 | * data in different places. The sense data itself is allways |
| 2687 | * an array of 32 bytes, so we can unify the sense data access |
| 2688 | * for both modes. |
| 2689 | */ |
| 2690 | char *dasd_get_sense(struct irb *irb) |
| 2691 | { |
| 2692 | struct tsb *tsb = NULL; |
| 2693 | char *sense = NULL; |
| 2694 | |
| 2695 | if (scsw_is_tm(&irb->scsw) && (irb->scsw.tm.fcxs == 0x01)) { |
| 2696 | if (irb->scsw.tm.tcw) |
| 2697 | tsb = tcw_get_tsb((struct tcw *)(unsigned long) |
| 2698 | irb->scsw.tm.tcw); |
| 2699 | if (tsb && tsb->length == 64 && tsb->flags) |
| 2700 | switch (tsb->flags & 0x07) { |
| 2701 | case 1: /* tsa_iostat */ |
| 2702 | sense = tsb->tsa.iostat.sense; |
| 2703 | break; |
| 2704 | case 2: /* tsa_ddpc */ |
| 2705 | sense = tsb->tsa.ddpc.sense; |
| 2706 | break; |
| 2707 | default: |
| 2708 | /* currently we don't use interrogate data */ |
| 2709 | break; |
| 2710 | } |
| 2711 | } else if (irb->esw.esw0.erw.cons) { |
| 2712 | sense = irb->ecw; |
| 2713 | } |
| 2714 | return sense; |
| 2715 | } |
| 2716 | EXPORT_SYMBOL_GPL(dasd_get_sense); |
| 2717 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2718 | static int __init dasd_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2719 | { |
| 2720 | int rc; |
| 2721 | |
| 2722 | init_waitqueue_head(&dasd_init_waitq); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 2723 | init_waitqueue_head(&dasd_flush_wq); |
Stefan Haberland | c80ee72 | 2008-05-30 10:03:31 +0200 | [diff] [blame] | 2724 | init_waitqueue_head(&generic_waitq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2725 | |
| 2726 | /* register 'common' DASD debug area, used for all DBF_XXX calls */ |
Peter Tiedemann | 361f494 | 2008-01-26 14:11:30 +0100 | [diff] [blame] | 2727 | dasd_debug_area = debug_register("dasd", 1, 1, 8 * sizeof(long)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2728 | if (dasd_debug_area == NULL) { |
| 2729 | rc = -ENOMEM; |
| 2730 | goto failed; |
| 2731 | } |
| 2732 | debug_register_view(dasd_debug_area, &debug_sprintf_view); |
Horst Hummel | b0035f1 | 2006-09-20 15:59:07 +0200 | [diff] [blame] | 2733 | debug_set_level(dasd_debug_area, DBF_WARNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2734 | |
| 2735 | DBF_EVENT(DBF_EMERG, "%s", "debug area created"); |
| 2736 | |
| 2737 | dasd_diag_discipline_pointer = NULL; |
| 2738 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2739 | rc = dasd_devmap_init(); |
| 2740 | if (rc) |
| 2741 | goto failed; |
| 2742 | rc = dasd_gendisk_init(); |
| 2743 | if (rc) |
| 2744 | goto failed; |
| 2745 | rc = dasd_parse(); |
| 2746 | if (rc) |
| 2747 | goto failed; |
Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 2748 | rc = dasd_eer_init(); |
| 2749 | if (rc) |
| 2750 | goto failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2751 | #ifdef CONFIG_PROC_FS |
| 2752 | rc = dasd_proc_init(); |
| 2753 | if (rc) |
| 2754 | goto failed; |
| 2755 | #endif |
| 2756 | |
| 2757 | return 0; |
| 2758 | failed: |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 2759 | pr_info("The DASD device driver could not be initialized\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2760 | dasd_exit(); |
| 2761 | return rc; |
| 2762 | } |
| 2763 | |
| 2764 | module_init(dasd_init); |
| 2765 | module_exit(dasd_exit); |
| 2766 | |
| 2767 | EXPORT_SYMBOL(dasd_debug_area); |
| 2768 | EXPORT_SYMBOL(dasd_diag_discipline_pointer); |
| 2769 | |
| 2770 | EXPORT_SYMBOL(dasd_add_request_head); |
| 2771 | EXPORT_SYMBOL(dasd_add_request_tail); |
| 2772 | EXPORT_SYMBOL(dasd_cancel_req); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2773 | EXPORT_SYMBOL(dasd_device_clear_timer); |
| 2774 | EXPORT_SYMBOL(dasd_block_clear_timer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2775 | EXPORT_SYMBOL(dasd_enable_device); |
| 2776 | EXPORT_SYMBOL(dasd_int_handler); |
| 2777 | EXPORT_SYMBOL(dasd_kfree_request); |
| 2778 | EXPORT_SYMBOL(dasd_kick_device); |
| 2779 | EXPORT_SYMBOL(dasd_kmalloc_request); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2780 | EXPORT_SYMBOL(dasd_schedule_device_bh); |
| 2781 | EXPORT_SYMBOL(dasd_schedule_block_bh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2782 | EXPORT_SYMBOL(dasd_set_target_state); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2783 | EXPORT_SYMBOL(dasd_device_set_timer); |
| 2784 | EXPORT_SYMBOL(dasd_block_set_timer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2785 | EXPORT_SYMBOL(dasd_sfree_request); |
| 2786 | EXPORT_SYMBOL(dasd_sleep_on); |
| 2787 | EXPORT_SYMBOL(dasd_sleep_on_immediatly); |
| 2788 | EXPORT_SYMBOL(dasd_sleep_on_interruptible); |
| 2789 | EXPORT_SYMBOL(dasd_smalloc_request); |
| 2790 | EXPORT_SYMBOL(dasd_start_IO); |
| 2791 | EXPORT_SYMBOL(dasd_term_IO); |
| 2792 | |
| 2793 | EXPORT_SYMBOL_GPL(dasd_generic_probe); |
| 2794 | EXPORT_SYMBOL_GPL(dasd_generic_remove); |
| 2795 | EXPORT_SYMBOL_GPL(dasd_generic_notify); |
| 2796 | EXPORT_SYMBOL_GPL(dasd_generic_set_online); |
| 2797 | EXPORT_SYMBOL_GPL(dasd_generic_set_offline); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2798 | EXPORT_SYMBOL_GPL(dasd_generic_handle_state_change); |
| 2799 | EXPORT_SYMBOL_GPL(dasd_flush_device_queue); |
| 2800 | EXPORT_SYMBOL_GPL(dasd_alloc_block); |
| 2801 | EXPORT_SYMBOL_GPL(dasd_free_block); |