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> |
Christoph Hellwig | a885c8c | 2006-01-08 01:02:50 -0800 | [diff] [blame] | 20 | #include <linux/hdreg.h> |
Cornelia Huck | f3445a1 | 2009-04-14 15:36:23 +0200 | [diff] [blame] | 21 | #include <linux/async.h> |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame] | 22 | #include <linux/mutex.h> |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 23 | #include <linux/debugfs.h> |
| 24 | #include <linux/seq_file.h> |
Stefan Weinhuber | e4258d5 | 2011-08-03 16:44:20 +0200 | [diff] [blame] | 25 | #include <linux/vmalloc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
| 27 | #include <asm/ccwdev.h> |
| 28 | #include <asm/ebcdic.h> |
| 29 | #include <asm/idals.h> |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 30 | #include <asm/itcw.h> |
Stefan Weinhuber | 33b62a3 | 2010-03-08 12:26:24 +0100 | [diff] [blame] | 31 | #include <asm/diag.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | |
| 33 | /* This is ugly... */ |
| 34 | #define PRINTK_HEADER "dasd:" |
| 35 | |
| 36 | #include "dasd_int.h" |
| 37 | /* |
| 38 | * SECTION: Constant definitions to be used within this file |
| 39 | */ |
| 40 | #define DASD_CHANQ_MAX_SIZE 4 |
| 41 | |
Stefan Weinhuber | 1c1e093 | 2010-05-12 09:32:11 +0200 | [diff] [blame] | 42 | #define DASD_SLEEPON_START_TAG (void *) 1 |
| 43 | #define DASD_SLEEPON_END_TAG (void *) 2 |
| 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | /* |
| 46 | * SECTION: exported variables of dasd.c |
| 47 | */ |
| 48 | debug_info_t *dasd_debug_area; |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 49 | static struct dentry *dasd_debugfs_root_entry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | struct dasd_discipline *dasd_diag_discipline_pointer; |
Heiko Carstens | 2b67fc4 | 2007-02-05 21:16:47 +0100 | [diff] [blame] | 51 | void dasd_int_handler(struct ccw_device *, unsigned long, struct irb *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
| 53 | MODULE_AUTHOR("Holger Smolinski <Holger.Smolinski@de.ibm.com>"); |
| 54 | MODULE_DESCRIPTION("Linux on S/390 DASD device driver," |
| 55 | " Copyright 2000 IBM Corporation"); |
| 56 | MODULE_SUPPORTED_DEVICE("dasd"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | MODULE_LICENSE("GPL"); |
| 58 | |
| 59 | /* |
| 60 | * SECTION: prototypes for static functions of dasd.c |
| 61 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 62 | static int dasd_alloc_queue(struct dasd_block *); |
| 63 | static void dasd_setup_queue(struct dasd_block *); |
| 64 | static void dasd_free_queue(struct dasd_block *); |
| 65 | static void dasd_flush_request_queue(struct dasd_block *); |
| 66 | static int dasd_flush_block_queue(struct dasd_block *); |
| 67 | static void dasd_device_tasklet(struct dasd_device *); |
| 68 | static void dasd_block_tasklet(struct dasd_block *); |
Al Viro | 4927b3f | 2006-12-06 19:18:20 +0000 | [diff] [blame] | 69 | static void do_kick_device(struct work_struct *); |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 70 | static void do_restore_device(struct work_struct *); |
Stefan Haberland | 501183f | 2010-05-17 10:00:10 +0200 | [diff] [blame] | 71 | static void do_reload_device(struct work_struct *); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 72 | static void dasd_return_cqr_cb(struct dasd_ccw_req *, void *); |
Stefan Weinhuber | 48cae88 | 2009-02-11 10:37:31 +0100 | [diff] [blame] | 73 | static void dasd_device_timeout(unsigned long); |
| 74 | static void dasd_block_timeout(unsigned long); |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 75 | static void __dasd_process_erp(struct dasd_device *, struct dasd_ccw_req *); |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 76 | static void dasd_profile_init(struct dasd_profile *, struct dentry *); |
| 77 | static void dasd_profile_exit(struct dasd_profile *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | |
| 79 | /* |
| 80 | * SECTION: Operations on the device structure. |
| 81 | */ |
| 82 | static wait_queue_head_t dasd_init_waitq; |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 83 | static wait_queue_head_t dasd_flush_wq; |
Stefan Haberland | c80ee72 | 2008-05-30 10:03:31 +0200 | [diff] [blame] | 84 | static wait_queue_head_t generic_waitq; |
Stefan Haberland | 4679e89 | 2012-06-19 17:30:12 +0200 | [diff] [blame^] | 85 | static wait_queue_head_t shutdown_waitq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | |
| 87 | /* |
| 88 | * Allocate memory for a new device structure. |
| 89 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 90 | struct dasd_device *dasd_alloc_device(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | { |
| 92 | struct dasd_device *device; |
| 93 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 94 | device = kzalloc(sizeof(struct dasd_device), GFP_ATOMIC); |
| 95 | if (!device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | return ERR_PTR(-ENOMEM); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | |
| 98 | /* Get two pages for normal block device operations. */ |
| 99 | device->ccw_mem = (void *) __get_free_pages(GFP_ATOMIC | GFP_DMA, 1); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 100 | if (!device->ccw_mem) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | kfree(device); |
| 102 | return ERR_PTR(-ENOMEM); |
| 103 | } |
| 104 | /* Get one page for error recovery. */ |
| 105 | device->erp_mem = (void *) get_zeroed_page(GFP_ATOMIC | GFP_DMA); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 106 | if (!device->erp_mem) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | free_pages((unsigned long) device->ccw_mem, 1); |
| 108 | kfree(device); |
| 109 | return ERR_PTR(-ENOMEM); |
| 110 | } |
| 111 | |
| 112 | dasd_init_chunklist(&device->ccw_chunks, device->ccw_mem, PAGE_SIZE*2); |
| 113 | dasd_init_chunklist(&device->erp_chunks, device->erp_mem, PAGE_SIZE); |
| 114 | spin_lock_init(&device->mem_lock); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 115 | atomic_set(&device->tasklet_scheduled, 0); |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 116 | tasklet_init(&device->tasklet, |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 117 | (void (*)(unsigned long)) dasd_device_tasklet, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | (unsigned long) device); |
| 119 | INIT_LIST_HEAD(&device->ccw_queue); |
| 120 | init_timer(&device->timer); |
Stefan Weinhuber | 48cae88 | 2009-02-11 10:37:31 +0100 | [diff] [blame] | 121 | device->timer.function = dasd_device_timeout; |
| 122 | device->timer.data = (unsigned long) device; |
Al Viro | 4927b3f | 2006-12-06 19:18:20 +0000 | [diff] [blame] | 123 | INIT_WORK(&device->kick_work, do_kick_device); |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 124 | INIT_WORK(&device->restore_device, do_restore_device); |
Stefan Haberland | 501183f | 2010-05-17 10:00:10 +0200 | [diff] [blame] | 125 | INIT_WORK(&device->reload_device, do_reload_device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | device->state = DASD_STATE_NEW; |
| 127 | device->target = DASD_STATE_NEW; |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame] | 128 | mutex_init(&device->state_mutex); |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 129 | spin_lock_init(&device->profile.lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | return device; |
| 131 | } |
| 132 | |
| 133 | /* |
| 134 | * Free memory of a device structure. |
| 135 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 136 | void dasd_free_device(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | { |
Jesper Juhl | 17fd682 | 2005-11-07 01:01:30 -0800 | [diff] [blame] | 138 | kfree(device->private); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | free_page((unsigned long) device->erp_mem); |
| 140 | free_pages((unsigned long) device->ccw_mem, 1); |
| 141 | kfree(device); |
| 142 | } |
| 143 | |
| 144 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 145 | * Allocate memory for a new device structure. |
| 146 | */ |
| 147 | struct dasd_block *dasd_alloc_block(void) |
| 148 | { |
| 149 | struct dasd_block *block; |
| 150 | |
| 151 | block = kzalloc(sizeof(*block), GFP_ATOMIC); |
| 152 | if (!block) |
| 153 | return ERR_PTR(-ENOMEM); |
| 154 | /* open_count = 0 means device online but not in use */ |
| 155 | atomic_set(&block->open_count, -1); |
| 156 | |
| 157 | spin_lock_init(&block->request_queue_lock); |
| 158 | atomic_set(&block->tasklet_scheduled, 0); |
| 159 | tasklet_init(&block->tasklet, |
| 160 | (void (*)(unsigned long)) dasd_block_tasklet, |
| 161 | (unsigned long) block); |
| 162 | INIT_LIST_HEAD(&block->ccw_queue); |
| 163 | spin_lock_init(&block->queue_lock); |
| 164 | init_timer(&block->timer); |
Stefan Weinhuber | 48cae88 | 2009-02-11 10:37:31 +0100 | [diff] [blame] | 165 | block->timer.function = dasd_block_timeout; |
| 166 | block->timer.data = (unsigned long) block; |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 167 | spin_lock_init(&block->profile.lock); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 168 | |
| 169 | return block; |
| 170 | } |
| 171 | |
| 172 | /* |
| 173 | * Free memory of a device structure. |
| 174 | */ |
| 175 | void dasd_free_block(struct dasd_block *block) |
| 176 | { |
| 177 | kfree(block); |
| 178 | } |
| 179 | |
| 180 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | * Make a new device known to the system. |
| 182 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 183 | static int dasd_state_new_to_known(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | { |
| 185 | int rc; |
| 186 | |
| 187 | /* |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 188 | * 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] | 189 | * keep the reference count > 0. |
| 190 | */ |
| 191 | dasd_get_device(device); |
| 192 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 193 | if (device->block) { |
| 194 | rc = dasd_alloc_queue(device->block); |
| 195 | if (rc) { |
| 196 | dasd_put_device(device); |
| 197 | return rc; |
| 198 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | device->state = DASD_STATE_KNOWN; |
| 201 | return 0; |
| 202 | } |
| 203 | |
| 204 | /* |
| 205 | * Let the system forget about a device. |
| 206 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 207 | static int dasd_state_known_to_new(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | { |
Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 209 | /* Disable extended error reporting for this device. */ |
| 210 | dasd_eer_disable(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | /* Forget the discipline information. */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 212 | if (device->discipline) { |
| 213 | if (device->discipline->uncheck_device) |
| 214 | device->discipline->uncheck_device(device); |
Peter Oberparleiter | aa88861 | 2006-02-20 18:28:13 -0800 | [diff] [blame] | 215 | module_put(device->discipline->owner); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 216 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | device->discipline = NULL; |
Peter Oberparleiter | aa88861 | 2006-02-20 18:28:13 -0800 | [diff] [blame] | 218 | if (device->base_discipline) |
| 219 | module_put(device->base_discipline->owner); |
| 220 | device->base_discipline = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | device->state = DASD_STATE_NEW; |
| 222 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 223 | if (device->block) |
| 224 | dasd_free_queue(device->block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | |
| 226 | /* Give up reference we took in dasd_state_new_to_known. */ |
| 227 | dasd_put_device(device); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 228 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | } |
| 230 | |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 231 | static struct dentry *dasd_debugfs_setup(const char *name, |
| 232 | struct dentry *base_dentry) |
| 233 | { |
| 234 | struct dentry *pde; |
| 235 | |
| 236 | if (!base_dentry) |
| 237 | return NULL; |
| 238 | pde = debugfs_create_dir(name, base_dentry); |
| 239 | if (!pde || IS_ERR(pde)) |
| 240 | return NULL; |
| 241 | return pde; |
| 242 | } |
| 243 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | /* |
| 245 | * Request the irq line for the device. |
| 246 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 247 | static int dasd_state_known_to_basic(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | { |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 249 | struct dasd_block *block = device->block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | int rc; |
| 251 | |
| 252 | /* Allocate and register gendisk structure. */ |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 253 | if (block) { |
| 254 | rc = dasd_gendisk_alloc(block); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 255 | if (rc) |
| 256 | return rc; |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 257 | block->debugfs_dentry = |
| 258 | dasd_debugfs_setup(block->gdp->disk_name, |
| 259 | dasd_debugfs_root_entry); |
| 260 | dasd_profile_init(&block->profile, block->debugfs_dentry); |
| 261 | if (dasd_global_profile_level == DASD_PROFILE_ON) |
| 262 | dasd_profile_on(&device->block->profile); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 263 | } |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 264 | device->debugfs_dentry = |
| 265 | dasd_debugfs_setup(dev_name(&device->cdev->dev), |
| 266 | dasd_debugfs_root_entry); |
| 267 | dasd_profile_init(&device->profile, device->debugfs_dentry); |
| 268 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | /* register 'device' debug area, used for all DBF_DEV_XXX calls */ |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 270 | device->debug_area = debug_register(dev_name(&device->cdev->dev), 4, 1, |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 271 | 8 * sizeof(long)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | debug_register_view(device->debug_area, &debug_sprintf_view); |
Horst Hummel | b0035f1 | 2006-09-20 15:59:07 +0200 | [diff] [blame] | 273 | debug_set_level(device->debug_area, DBF_WARNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | DBF_DEV_EVENT(DBF_EMERG, device, "%s", "debug area created"); |
| 275 | |
| 276 | device->state = DASD_STATE_BASIC; |
| 277 | return 0; |
| 278 | } |
| 279 | |
| 280 | /* |
| 281 | * Release the irq line for the device. Terminate any running i/o. |
| 282 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 283 | static int dasd_state_basic_to_known(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | { |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 285 | int rc; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 286 | if (device->block) { |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 287 | dasd_profile_exit(&device->block->profile); |
| 288 | if (device->block->debugfs_dentry) |
| 289 | debugfs_remove(device->block->debugfs_dentry); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 290 | dasd_gendisk_free(device->block); |
| 291 | dasd_block_clear_timer(device->block); |
| 292 | } |
| 293 | rc = dasd_flush_device_queue(device); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 294 | if (rc) |
| 295 | return rc; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 296 | dasd_device_clear_timer(device); |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 297 | dasd_profile_exit(&device->profile); |
| 298 | if (device->debugfs_dentry) |
| 299 | debugfs_remove(device->debugfs_dentry); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 300 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | DBF_DEV_EVENT(DBF_EMERG, device, "%p debug area deleted", device); |
| 302 | if (device->debug_area != NULL) { |
| 303 | debug_unregister(device->debug_area); |
| 304 | device->debug_area = NULL; |
| 305 | } |
| 306 | device->state = DASD_STATE_KNOWN; |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 307 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | /* |
| 311 | * Do the initial analysis. The do_analysis function may return |
| 312 | * -EAGAIN in which case the device keeps the state DASD_STATE_BASIC |
| 313 | * until the discipline decides to continue the startup sequence |
| 314 | * by calling the function dasd_change_state. The eckd disciplines |
| 315 | * uses this to start a ccw that detects the format. The completion |
| 316 | * interrupt for this detection ccw uses the kernel event daemon to |
| 317 | * trigger the call to dasd_change_state. All this is done in the |
| 318 | * discipline code, see dasd_eckd.c. |
Horst Hummel | 90f0094 | 2006-03-07 21:55:39 -0800 | [diff] [blame] | 319 | * After the analysis ccw is done (do_analysis returned 0) the block |
| 320 | * device is setup. |
| 321 | * In case the analysis returns an error, the device setup is stopped |
| 322 | * (a fake disk was already added to allow formatting). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 324 | static int dasd_state_basic_to_ready(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | { |
| 326 | int rc; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 327 | struct dasd_block *block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | |
| 329 | rc = 0; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 330 | block = device->block; |
Horst Hummel | 90f0094 | 2006-03-07 21:55:39 -0800 | [diff] [blame] | 331 | /* make disk known with correct capacity */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 332 | if (block) { |
| 333 | if (block->base->discipline->do_analysis != NULL) |
| 334 | rc = block->base->discipline->do_analysis(block); |
| 335 | if (rc) { |
| 336 | if (rc != -EAGAIN) |
| 337 | device->state = DASD_STATE_UNFMT; |
| 338 | return rc; |
| 339 | } |
| 340 | dasd_setup_queue(block); |
| 341 | set_capacity(block->gdp, |
| 342 | block->blocks << block->s2b_shift); |
| 343 | device->state = DASD_STATE_READY; |
| 344 | rc = dasd_scan_partitions(block); |
| 345 | if (rc) |
| 346 | device->state = DASD_STATE_BASIC; |
| 347 | } else { |
| 348 | device->state = DASD_STATE_READY; |
| 349 | } |
Horst Hummel | 90f0094 | 2006-03-07 21:55:39 -0800 | [diff] [blame] | 350 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | /* |
| 354 | * Remove device from block device layer. Destroy dirty buffers. |
| 355 | * Forget format information. Check if the target level is basic |
| 356 | * and if it is create fake disk for formatting. |
| 357 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 358 | static int dasd_state_ready_to_basic(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 359 | { |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 360 | int rc; |
| 361 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | device->state = DASD_STATE_BASIC; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 363 | if (device->block) { |
| 364 | struct dasd_block *block = device->block; |
| 365 | rc = dasd_flush_block_queue(block); |
| 366 | if (rc) { |
| 367 | device->state = DASD_STATE_READY; |
| 368 | return rc; |
| 369 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 370 | dasd_flush_request_queue(block); |
Stefan Haberland | b695adf | 2010-02-26 22:37:48 +0100 | [diff] [blame] | 371 | dasd_destroy_partitions(block); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 372 | block->blocks = 0; |
| 373 | block->bp_block = 0; |
| 374 | block->s2b_shift = 0; |
| 375 | } |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 376 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | /* |
Horst Hummel | 90f0094 | 2006-03-07 21:55:39 -0800 | [diff] [blame] | 380 | * Back to basic. |
| 381 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 382 | static int dasd_state_unfmt_to_basic(struct dasd_device *device) |
Horst Hummel | 90f0094 | 2006-03-07 21:55:39 -0800 | [diff] [blame] | 383 | { |
| 384 | device->state = DASD_STATE_BASIC; |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 385 | return 0; |
Horst Hummel | 90f0094 | 2006-03-07 21:55:39 -0800 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | * Make the device online and schedule the bottom half to start |
| 390 | * the requeueing of requests from the linux request queue to the |
| 391 | * ccw queue. |
| 392 | */ |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 393 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | dasd_state_ready_to_online(struct dasd_device * device) |
| 395 | { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 396 | int rc; |
Stefan Weinhuber | 1301809 | 2009-01-09 12:14:50 +0100 | [diff] [blame] | 397 | struct gendisk *disk; |
| 398 | struct disk_part_iter piter; |
| 399 | struct hd_struct *part; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 400 | |
| 401 | if (device->discipline->ready_to_online) { |
| 402 | rc = device->discipline->ready_to_online(device); |
| 403 | if (rc) |
| 404 | return rc; |
| 405 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | device->state = DASD_STATE_ONLINE; |
Stefan Weinhuber | 1301809 | 2009-01-09 12:14:50 +0100 | [diff] [blame] | 407 | if (device->block) { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 408 | dasd_schedule_block_bh(device->block); |
Stefan Haberland | e4dbb0f | 2011-01-05 12:48:06 +0100 | [diff] [blame] | 409 | if ((device->features & DASD_FEATURE_USERAW)) { |
| 410 | disk = device->block->gdp; |
| 411 | kobject_uevent(&disk_to_dev(disk)->kobj, KOBJ_CHANGE); |
| 412 | return 0; |
| 413 | } |
Stefan Weinhuber | 1301809 | 2009-01-09 12:14:50 +0100 | [diff] [blame] | 414 | disk = device->block->bdev->bd_disk; |
| 415 | disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0); |
| 416 | while ((part = disk_part_iter_next(&piter))) |
| 417 | kobject_uevent(&part_to_dev(part)->kobj, KOBJ_CHANGE); |
| 418 | disk_part_iter_exit(&piter); |
| 419 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | return 0; |
| 421 | } |
| 422 | |
| 423 | /* |
| 424 | * Stop the requeueing of requests again. |
| 425 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 426 | static int dasd_state_online_to_ready(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 428 | int rc; |
Stefan Weinhuber | 1301809 | 2009-01-09 12:14:50 +0100 | [diff] [blame] | 429 | struct gendisk *disk; |
| 430 | struct disk_part_iter piter; |
| 431 | struct hd_struct *part; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 432 | |
| 433 | if (device->discipline->online_to_ready) { |
| 434 | rc = device->discipline->online_to_ready(device); |
| 435 | if (rc) |
| 436 | return rc; |
| 437 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | device->state = DASD_STATE_READY; |
Stefan Haberland | e4dbb0f | 2011-01-05 12:48:06 +0100 | [diff] [blame] | 439 | if (device->block && !(device->features & DASD_FEATURE_USERAW)) { |
Stefan Weinhuber | 1301809 | 2009-01-09 12:14:50 +0100 | [diff] [blame] | 440 | disk = device->block->bdev->bd_disk; |
| 441 | disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0); |
| 442 | while ((part = disk_part_iter_next(&piter))) |
| 443 | kobject_uevent(&part_to_dev(part)->kobj, KOBJ_CHANGE); |
| 444 | disk_part_iter_exit(&piter); |
| 445 | } |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 446 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | /* |
| 450 | * Device startup state changes. |
| 451 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 452 | static int dasd_increase_state(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | { |
| 454 | int rc; |
| 455 | |
| 456 | rc = 0; |
| 457 | if (device->state == DASD_STATE_NEW && |
| 458 | device->target >= DASD_STATE_KNOWN) |
| 459 | rc = dasd_state_new_to_known(device); |
| 460 | |
| 461 | if (!rc && |
| 462 | device->state == DASD_STATE_KNOWN && |
| 463 | device->target >= DASD_STATE_BASIC) |
| 464 | rc = dasd_state_known_to_basic(device); |
| 465 | |
| 466 | if (!rc && |
| 467 | device->state == DASD_STATE_BASIC && |
| 468 | device->target >= DASD_STATE_READY) |
| 469 | rc = dasd_state_basic_to_ready(device); |
| 470 | |
| 471 | if (!rc && |
Horst Hummel | 39ccf95 | 2006-04-27 18:40:10 -0700 | [diff] [blame] | 472 | device->state == DASD_STATE_UNFMT && |
| 473 | device->target > DASD_STATE_UNFMT) |
| 474 | rc = -EPERM; |
| 475 | |
| 476 | if (!rc && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | device->state == DASD_STATE_READY && |
| 478 | device->target >= DASD_STATE_ONLINE) |
| 479 | rc = dasd_state_ready_to_online(device); |
| 480 | |
| 481 | return rc; |
| 482 | } |
| 483 | |
| 484 | /* |
| 485 | * Device shutdown state changes. |
| 486 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 487 | static int dasd_decrease_state(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | { |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 489 | int rc; |
| 490 | |
| 491 | rc = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | if (device->state == DASD_STATE_ONLINE && |
| 493 | device->target <= DASD_STATE_READY) |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 494 | rc = dasd_state_online_to_ready(device); |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 495 | |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 496 | if (!rc && |
| 497 | device->state == DASD_STATE_READY && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | device->target <= DASD_STATE_BASIC) |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 499 | rc = dasd_state_ready_to_basic(device); |
Horst Hummel | 90f0094 | 2006-03-07 21:55:39 -0800 | [diff] [blame] | 500 | |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 501 | if (!rc && |
| 502 | device->state == DASD_STATE_UNFMT && |
Horst Hummel | 90f0094 | 2006-03-07 21:55:39 -0800 | [diff] [blame] | 503 | device->target <= DASD_STATE_BASIC) |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 504 | rc = dasd_state_unfmt_to_basic(device); |
Horst Hummel | 90f0094 | 2006-03-07 21:55:39 -0800 | [diff] [blame] | 505 | |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 506 | if (!rc && |
| 507 | device->state == DASD_STATE_BASIC && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | device->target <= DASD_STATE_KNOWN) |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 509 | rc = dasd_state_basic_to_known(device); |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 510 | |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 511 | if (!rc && |
| 512 | device->state == DASD_STATE_KNOWN && |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | device->target <= DASD_STATE_NEW) |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 514 | rc = dasd_state_known_to_new(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 516 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 517 | } |
| 518 | |
| 519 | /* |
| 520 | * This is the main startup/shutdown routine. |
| 521 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 522 | static void dasd_change_state(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | { |
Sebastian Ott | 181d952 | 2009-06-22 12:08:21 +0200 | [diff] [blame] | 524 | int rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 525 | |
| 526 | if (device->state == device->target) |
| 527 | /* Already where we want to go today... */ |
| 528 | return; |
| 529 | if (device->state < device->target) |
| 530 | rc = dasd_increase_state(device); |
| 531 | else |
| 532 | rc = dasd_decrease_state(device); |
Sebastian Ott | 181d952 | 2009-06-22 12:08:21 +0200 | [diff] [blame] | 533 | if (rc == -EAGAIN) |
| 534 | return; |
| 535 | if (rc) |
| 536 | device->target = device->state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame] | 538 | if (device->state == device->target) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | wake_up(&dasd_init_waitq); |
Horst Hummel | 4dfd5c4 | 2007-04-27 16:01:47 +0200 | [diff] [blame] | 540 | |
| 541 | /* let user-space know that the device status changed */ |
| 542 | kobject_uevent(&device->cdev->dev.kobj, KOBJ_CHANGE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | } |
| 544 | |
| 545 | /* |
| 546 | * Kick starter for devices that did not complete the startup/shutdown |
| 547 | * procedure or were sleeping because of a pending state. |
| 548 | * dasd_kick_device will schedule a call do do_kick_device to the kernel |
| 549 | * event daemon. |
| 550 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 551 | static void do_kick_device(struct work_struct *work) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 552 | { |
Al Viro | 4927b3f | 2006-12-06 19:18:20 +0000 | [diff] [blame] | 553 | struct dasd_device *device = container_of(work, struct dasd_device, kick_work); |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame] | 554 | mutex_lock(&device->state_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | dasd_change_state(device); |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame] | 556 | mutex_unlock(&device->state_mutex); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 557 | dasd_schedule_device_bh(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | dasd_put_device(device); |
| 559 | } |
| 560 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 561 | void dasd_kick_device(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | { |
| 563 | dasd_get_device(device); |
| 564 | /* queue call to dasd_kick_device to the kernel event daemon. */ |
| 565 | schedule_work(&device->kick_work); |
| 566 | } |
| 567 | |
| 568 | /* |
Stefan Haberland | 501183f | 2010-05-17 10:00:10 +0200 | [diff] [blame] | 569 | * dasd_reload_device will schedule a call do do_reload_device to the kernel |
| 570 | * event daemon. |
| 571 | */ |
| 572 | static void do_reload_device(struct work_struct *work) |
| 573 | { |
| 574 | struct dasd_device *device = container_of(work, struct dasd_device, |
| 575 | reload_device); |
| 576 | device->discipline->reload(device); |
| 577 | dasd_put_device(device); |
| 578 | } |
| 579 | |
| 580 | void dasd_reload_device(struct dasd_device *device) |
| 581 | { |
| 582 | dasd_get_device(device); |
| 583 | /* queue call to dasd_reload_device to the kernel event daemon. */ |
| 584 | schedule_work(&device->reload_device); |
| 585 | } |
| 586 | EXPORT_SYMBOL(dasd_reload_device); |
| 587 | |
| 588 | /* |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 589 | * dasd_restore_device will schedule a call do do_restore_device to the kernel |
| 590 | * event daemon. |
| 591 | */ |
| 592 | static void do_restore_device(struct work_struct *work) |
| 593 | { |
| 594 | struct dasd_device *device = container_of(work, struct dasd_device, |
| 595 | restore_device); |
| 596 | device->cdev->drv->restore(device->cdev); |
| 597 | dasd_put_device(device); |
| 598 | } |
| 599 | |
| 600 | void dasd_restore_device(struct dasd_device *device) |
| 601 | { |
| 602 | dasd_get_device(device); |
| 603 | /* queue call to dasd_restore_device to the kernel event daemon. */ |
| 604 | schedule_work(&device->restore_device); |
| 605 | } |
| 606 | |
| 607 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | * Set the target state for a device and starts the state change. |
| 609 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 610 | void dasd_set_target_state(struct dasd_device *device, int target) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 611 | { |
Cornelia Huck | f3445a1 | 2009-04-14 15:36:23 +0200 | [diff] [blame] | 612 | dasd_get_device(device); |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame] | 613 | mutex_lock(&device->state_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | /* If we are in probeonly mode stop at DASD_STATE_READY. */ |
| 615 | if (dasd_probeonly && target > DASD_STATE_READY) |
| 616 | target = DASD_STATE_READY; |
| 617 | if (device->target != target) { |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame] | 618 | if (device->state == target) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | wake_up(&dasd_init_waitq); |
| 620 | device->target = target; |
| 621 | } |
| 622 | if (device->state != device->target) |
| 623 | dasd_change_state(device); |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame] | 624 | mutex_unlock(&device->state_mutex); |
| 625 | dasd_put_device(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | } |
| 627 | |
| 628 | /* |
| 629 | * Enable devices with device numbers in [from..to]. |
| 630 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 631 | static inline int _wait_for_device(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | { |
| 633 | return (device->state == device->target); |
| 634 | } |
| 635 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 636 | void dasd_enable_device(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | { |
| 638 | dasd_set_target_state(device, DASD_STATE_ONLINE); |
| 639 | if (device->state <= DASD_STATE_KNOWN) |
| 640 | /* No discipline for device found. */ |
| 641 | dasd_set_target_state(device, DASD_STATE_NEW); |
| 642 | /* Now wait for the devices to come up. */ |
| 643 | wait_event(dasd_init_waitq, _wait_for_device(device)); |
Stefan Haberland | 25e2cf1 | 2012-03-11 11:59:37 -0400 | [diff] [blame] | 644 | |
| 645 | dasd_reload_device(device); |
| 646 | if (device->discipline->kick_validate) |
| 647 | device->discipline->kick_validate(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | } |
| 649 | |
| 650 | /* |
| 651 | * SECTION: device operation (interrupt handler, start i/o, term i/o ...) |
| 652 | */ |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 653 | |
| 654 | unsigned int dasd_global_profile_level = DASD_PROFILE_OFF; |
| 655 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 656 | #ifdef CONFIG_DASD_PROFILE |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 657 | struct dasd_profile_info dasd_global_profile_data; |
| 658 | static struct dentry *dasd_global_profile_dentry; |
| 659 | static struct dentry *dasd_debugfs_global_entry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | |
| 661 | /* |
| 662 | * Add profiling information for cqr before execution. |
| 663 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 664 | static void dasd_profile_start(struct dasd_block *block, |
| 665 | struct dasd_ccw_req *cqr, |
| 666 | struct request *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | { |
| 668 | struct list_head *l; |
| 669 | unsigned int counter; |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 670 | struct dasd_device *device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 671 | |
| 672 | /* count the length of the chanq for statistics */ |
| 673 | counter = 0; |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 674 | if (dasd_global_profile_level || block->profile.data) |
| 675 | list_for_each(l, &block->ccw_queue) |
| 676 | if (++counter >= 31) |
| 677 | break; |
| 678 | |
| 679 | if (dasd_global_profile_level) { |
| 680 | dasd_global_profile_data.dasd_io_nr_req[counter]++; |
| 681 | if (rq_data_dir(req) == READ) |
| 682 | dasd_global_profile_data.dasd_read_nr_req[counter]++; |
| 683 | } |
| 684 | |
| 685 | spin_lock(&block->profile.lock); |
| 686 | if (block->profile.data) |
| 687 | block->profile.data->dasd_io_nr_req[counter]++; |
| 688 | if (rq_data_dir(req) == READ) |
| 689 | block->profile.data->dasd_read_nr_req[counter]++; |
| 690 | spin_unlock(&block->profile.lock); |
| 691 | |
| 692 | /* |
| 693 | * We count the request for the start device, even though it may run on |
| 694 | * some other device due to error recovery. This way we make sure that |
| 695 | * we count each request only once. |
| 696 | */ |
| 697 | device = cqr->startdev; |
| 698 | if (device->profile.data) { |
| 699 | counter = 1; /* request is not yet queued on the start device */ |
| 700 | list_for_each(l, &device->ccw_queue) |
| 701 | if (++counter >= 31) |
| 702 | break; |
| 703 | } |
| 704 | spin_lock(&device->profile.lock); |
| 705 | if (device->profile.data) { |
| 706 | device->profile.data->dasd_io_nr_req[counter]++; |
| 707 | if (rq_data_dir(req) == READ) |
| 708 | device->profile.data->dasd_read_nr_req[counter]++; |
| 709 | } |
| 710 | spin_unlock(&device->profile.lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 711 | } |
| 712 | |
| 713 | /* |
| 714 | * Add profiling information for cqr after execution. |
| 715 | */ |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 716 | |
| 717 | #define dasd_profile_counter(value, index) \ |
| 718 | { \ |
| 719 | for (index = 0; index < 31 && value >> (2+index); index++) \ |
| 720 | ; \ |
| 721 | } |
| 722 | |
| 723 | static void dasd_profile_end_add_data(struct dasd_profile_info *data, |
| 724 | int is_alias, |
| 725 | int is_tpm, |
| 726 | int is_read, |
| 727 | long sectors, |
| 728 | int sectors_ind, |
| 729 | int tottime_ind, |
| 730 | int tottimeps_ind, |
| 731 | int strtime_ind, |
| 732 | int irqtime_ind, |
| 733 | int irqtimeps_ind, |
| 734 | int endtime_ind) |
| 735 | { |
| 736 | /* in case of an overflow, reset the whole profile */ |
| 737 | if (data->dasd_io_reqs == UINT_MAX) { |
| 738 | memset(data, 0, sizeof(*data)); |
| 739 | getnstimeofday(&data->starttod); |
| 740 | } |
| 741 | data->dasd_io_reqs++; |
| 742 | data->dasd_io_sects += sectors; |
| 743 | if (is_alias) |
| 744 | data->dasd_io_alias++; |
| 745 | if (is_tpm) |
| 746 | data->dasd_io_tpm++; |
| 747 | |
| 748 | data->dasd_io_secs[sectors_ind]++; |
| 749 | data->dasd_io_times[tottime_ind]++; |
| 750 | data->dasd_io_timps[tottimeps_ind]++; |
| 751 | data->dasd_io_time1[strtime_ind]++; |
| 752 | data->dasd_io_time2[irqtime_ind]++; |
| 753 | data->dasd_io_time2ps[irqtimeps_ind]++; |
| 754 | data->dasd_io_time3[endtime_ind]++; |
| 755 | |
| 756 | if (is_read) { |
| 757 | data->dasd_read_reqs++; |
| 758 | data->dasd_read_sects += sectors; |
| 759 | if (is_alias) |
| 760 | data->dasd_read_alias++; |
| 761 | if (is_tpm) |
| 762 | data->dasd_read_tpm++; |
| 763 | data->dasd_read_secs[sectors_ind]++; |
| 764 | data->dasd_read_times[tottime_ind]++; |
| 765 | data->dasd_read_time1[strtime_ind]++; |
| 766 | data->dasd_read_time2[irqtime_ind]++; |
| 767 | data->dasd_read_time3[endtime_ind]++; |
| 768 | } |
| 769 | } |
| 770 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 771 | static void dasd_profile_end(struct dasd_block *block, |
| 772 | struct dasd_ccw_req *cqr, |
| 773 | struct request *req) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 774 | { |
| 775 | long strtime, irqtime, endtime, tottime; /* in microseconds */ |
| 776 | long tottimeps, sectors; |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 777 | struct dasd_device *device; |
| 778 | int sectors_ind, tottime_ind, tottimeps_ind, strtime_ind; |
| 779 | int irqtime_ind, irqtimeps_ind, endtime_ind; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 | |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 781 | device = cqr->startdev; |
| 782 | if (!(dasd_global_profile_level || |
| 783 | block->profile.data || |
| 784 | device->profile.data)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 785 | return; |
| 786 | |
Tejun Heo | 83096eb | 2009-05-07 22:24:39 +0900 | [diff] [blame] | 787 | sectors = blk_rq_sectors(req); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 788 | if (!cqr->buildclk || !cqr->startclk || |
| 789 | !cqr->stopclk || !cqr->endclk || |
| 790 | !sectors) |
| 791 | return; |
| 792 | |
| 793 | strtime = ((cqr->startclk - cqr->buildclk) >> 12); |
| 794 | irqtime = ((cqr->stopclk - cqr->startclk) >> 12); |
| 795 | endtime = ((cqr->endclk - cqr->stopclk) >> 12); |
| 796 | tottime = ((cqr->endclk - cqr->buildclk) >> 12); |
| 797 | tottimeps = tottime / sectors; |
| 798 | |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 799 | dasd_profile_counter(sectors, sectors_ind); |
| 800 | dasd_profile_counter(tottime, tottime_ind); |
| 801 | dasd_profile_counter(tottimeps, tottimeps_ind); |
| 802 | dasd_profile_counter(strtime, strtime_ind); |
| 803 | dasd_profile_counter(irqtime, irqtime_ind); |
| 804 | dasd_profile_counter(irqtime / sectors, irqtimeps_ind); |
| 805 | dasd_profile_counter(endtime, endtime_ind); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 807 | if (dasd_global_profile_level) { |
| 808 | dasd_profile_end_add_data(&dasd_global_profile_data, |
| 809 | cqr->startdev != block->base, |
| 810 | cqr->cpmode == 1, |
| 811 | rq_data_dir(req) == READ, |
| 812 | sectors, sectors_ind, tottime_ind, |
| 813 | tottimeps_ind, strtime_ind, |
| 814 | irqtime_ind, irqtimeps_ind, |
| 815 | endtime_ind); |
| 816 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 818 | spin_lock(&block->profile.lock); |
| 819 | if (block->profile.data) |
| 820 | dasd_profile_end_add_data(block->profile.data, |
| 821 | cqr->startdev != block->base, |
| 822 | cqr->cpmode == 1, |
| 823 | rq_data_dir(req) == READ, |
| 824 | sectors, sectors_ind, tottime_ind, |
| 825 | tottimeps_ind, strtime_ind, |
| 826 | irqtime_ind, irqtimeps_ind, |
| 827 | endtime_ind); |
| 828 | spin_unlock(&block->profile.lock); |
| 829 | |
| 830 | spin_lock(&device->profile.lock); |
| 831 | if (device->profile.data) |
| 832 | dasd_profile_end_add_data(device->profile.data, |
| 833 | cqr->startdev != block->base, |
| 834 | cqr->cpmode == 1, |
| 835 | rq_data_dir(req) == READ, |
| 836 | sectors, sectors_ind, tottime_ind, |
| 837 | tottimeps_ind, strtime_ind, |
| 838 | irqtime_ind, irqtimeps_ind, |
| 839 | endtime_ind); |
| 840 | spin_unlock(&device->profile.lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 841 | } |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 842 | |
| 843 | void dasd_profile_reset(struct dasd_profile *profile) |
| 844 | { |
| 845 | struct dasd_profile_info *data; |
| 846 | |
| 847 | spin_lock_bh(&profile->lock); |
| 848 | data = profile->data; |
| 849 | if (!data) { |
| 850 | spin_unlock_bh(&profile->lock); |
| 851 | return; |
| 852 | } |
| 853 | memset(data, 0, sizeof(*data)); |
| 854 | getnstimeofday(&data->starttod); |
| 855 | spin_unlock_bh(&profile->lock); |
| 856 | } |
| 857 | |
| 858 | void dasd_global_profile_reset(void) |
| 859 | { |
| 860 | memset(&dasd_global_profile_data, 0, sizeof(dasd_global_profile_data)); |
| 861 | getnstimeofday(&dasd_global_profile_data.starttod); |
| 862 | } |
| 863 | |
| 864 | int dasd_profile_on(struct dasd_profile *profile) |
| 865 | { |
| 866 | struct dasd_profile_info *data; |
| 867 | |
| 868 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
| 869 | if (!data) |
| 870 | return -ENOMEM; |
| 871 | spin_lock_bh(&profile->lock); |
| 872 | if (profile->data) { |
| 873 | spin_unlock_bh(&profile->lock); |
| 874 | kfree(data); |
| 875 | return 0; |
| 876 | } |
| 877 | getnstimeofday(&data->starttod); |
| 878 | profile->data = data; |
| 879 | spin_unlock_bh(&profile->lock); |
| 880 | return 0; |
| 881 | } |
| 882 | |
| 883 | void dasd_profile_off(struct dasd_profile *profile) |
| 884 | { |
| 885 | spin_lock_bh(&profile->lock); |
| 886 | kfree(profile->data); |
| 887 | profile->data = NULL; |
| 888 | spin_unlock_bh(&profile->lock); |
| 889 | } |
| 890 | |
| 891 | char *dasd_get_user_string(const char __user *user_buf, size_t user_len) |
| 892 | { |
| 893 | char *buffer; |
| 894 | |
Stefan Weinhuber | e4258d5 | 2011-08-03 16:44:20 +0200 | [diff] [blame] | 895 | buffer = vmalloc(user_len + 1); |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 896 | if (buffer == NULL) |
| 897 | return ERR_PTR(-ENOMEM); |
| 898 | if (copy_from_user(buffer, user_buf, user_len) != 0) { |
Stefan Weinhuber | e4258d5 | 2011-08-03 16:44:20 +0200 | [diff] [blame] | 899 | vfree(buffer); |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 900 | return ERR_PTR(-EFAULT); |
| 901 | } |
| 902 | /* got the string, now strip linefeed. */ |
| 903 | if (buffer[user_len - 1] == '\n') |
| 904 | buffer[user_len - 1] = 0; |
| 905 | else |
| 906 | buffer[user_len] = 0; |
| 907 | return buffer; |
| 908 | } |
| 909 | |
| 910 | static ssize_t dasd_stats_write(struct file *file, |
| 911 | const char __user *user_buf, |
| 912 | size_t user_len, loff_t *pos) |
| 913 | { |
| 914 | char *buffer, *str; |
| 915 | int rc; |
| 916 | struct seq_file *m = (struct seq_file *)file->private_data; |
| 917 | struct dasd_profile *prof = m->private; |
| 918 | |
| 919 | if (user_len > 65536) |
| 920 | user_len = 65536; |
| 921 | buffer = dasd_get_user_string(user_buf, user_len); |
| 922 | if (IS_ERR(buffer)) |
| 923 | return PTR_ERR(buffer); |
| 924 | |
| 925 | str = skip_spaces(buffer); |
| 926 | rc = user_len; |
| 927 | if (strncmp(str, "reset", 5) == 0) { |
| 928 | dasd_profile_reset(prof); |
| 929 | } else if (strncmp(str, "on", 2) == 0) { |
| 930 | rc = dasd_profile_on(prof); |
| 931 | if (!rc) |
| 932 | rc = user_len; |
| 933 | } else if (strncmp(str, "off", 3) == 0) { |
| 934 | dasd_profile_off(prof); |
| 935 | } else |
| 936 | rc = -EINVAL; |
Stefan Weinhuber | e4258d5 | 2011-08-03 16:44:20 +0200 | [diff] [blame] | 937 | vfree(buffer); |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 938 | return rc; |
| 939 | } |
| 940 | |
| 941 | static void dasd_stats_array(struct seq_file *m, unsigned int *array) |
| 942 | { |
| 943 | int i; |
| 944 | |
| 945 | for (i = 0; i < 32; i++) |
| 946 | seq_printf(m, "%u ", array[i]); |
| 947 | seq_putc(m, '\n'); |
| 948 | } |
| 949 | |
| 950 | static void dasd_stats_seq_print(struct seq_file *m, |
| 951 | struct dasd_profile_info *data) |
| 952 | { |
| 953 | seq_printf(m, "start_time %ld.%09ld\n", |
| 954 | data->starttod.tv_sec, data->starttod.tv_nsec); |
| 955 | seq_printf(m, "total_requests %u\n", data->dasd_io_reqs); |
| 956 | seq_printf(m, "total_sectors %u\n", data->dasd_io_sects); |
| 957 | seq_printf(m, "total_pav %u\n", data->dasd_io_alias); |
| 958 | seq_printf(m, "total_hpf %u\n", data->dasd_io_tpm); |
| 959 | seq_printf(m, "histogram_sectors "); |
| 960 | dasd_stats_array(m, data->dasd_io_secs); |
| 961 | seq_printf(m, "histogram_io_times "); |
| 962 | dasd_stats_array(m, data->dasd_io_times); |
| 963 | seq_printf(m, "histogram_io_times_weighted "); |
| 964 | dasd_stats_array(m, data->dasd_io_timps); |
| 965 | seq_printf(m, "histogram_time_build_to_ssch "); |
| 966 | dasd_stats_array(m, data->dasd_io_time1); |
| 967 | seq_printf(m, "histogram_time_ssch_to_irq "); |
| 968 | dasd_stats_array(m, data->dasd_io_time2); |
| 969 | seq_printf(m, "histogram_time_ssch_to_irq_weighted "); |
| 970 | dasd_stats_array(m, data->dasd_io_time2ps); |
| 971 | seq_printf(m, "histogram_time_irq_to_end "); |
| 972 | dasd_stats_array(m, data->dasd_io_time3); |
| 973 | seq_printf(m, "histogram_ccw_queue_length "); |
| 974 | dasd_stats_array(m, data->dasd_io_nr_req); |
| 975 | seq_printf(m, "total_read_requests %u\n", data->dasd_read_reqs); |
| 976 | seq_printf(m, "total_read_sectors %u\n", data->dasd_read_sects); |
| 977 | seq_printf(m, "total_read_pav %u\n", data->dasd_read_alias); |
| 978 | seq_printf(m, "total_read_hpf %u\n", data->dasd_read_tpm); |
| 979 | seq_printf(m, "histogram_read_sectors "); |
| 980 | dasd_stats_array(m, data->dasd_read_secs); |
| 981 | seq_printf(m, "histogram_read_times "); |
| 982 | dasd_stats_array(m, data->dasd_read_times); |
| 983 | seq_printf(m, "histogram_read_time_build_to_ssch "); |
| 984 | dasd_stats_array(m, data->dasd_read_time1); |
| 985 | seq_printf(m, "histogram_read_time_ssch_to_irq "); |
| 986 | dasd_stats_array(m, data->dasd_read_time2); |
| 987 | seq_printf(m, "histogram_read_time_irq_to_end "); |
| 988 | dasd_stats_array(m, data->dasd_read_time3); |
| 989 | seq_printf(m, "histogram_read_ccw_queue_length "); |
| 990 | dasd_stats_array(m, data->dasd_read_nr_req); |
| 991 | } |
| 992 | |
| 993 | static int dasd_stats_show(struct seq_file *m, void *v) |
| 994 | { |
| 995 | struct dasd_profile *profile; |
| 996 | struct dasd_profile_info *data; |
| 997 | |
| 998 | profile = m->private; |
| 999 | spin_lock_bh(&profile->lock); |
| 1000 | data = profile->data; |
| 1001 | if (!data) { |
| 1002 | spin_unlock_bh(&profile->lock); |
| 1003 | seq_printf(m, "disabled\n"); |
| 1004 | return 0; |
| 1005 | } |
| 1006 | dasd_stats_seq_print(m, data); |
| 1007 | spin_unlock_bh(&profile->lock); |
| 1008 | return 0; |
| 1009 | } |
| 1010 | |
| 1011 | static int dasd_stats_open(struct inode *inode, struct file *file) |
| 1012 | { |
| 1013 | struct dasd_profile *profile = inode->i_private; |
| 1014 | return single_open(file, dasd_stats_show, profile); |
| 1015 | } |
| 1016 | |
| 1017 | static const struct file_operations dasd_stats_raw_fops = { |
| 1018 | .owner = THIS_MODULE, |
| 1019 | .open = dasd_stats_open, |
| 1020 | .read = seq_read, |
| 1021 | .llseek = seq_lseek, |
| 1022 | .release = single_release, |
| 1023 | .write = dasd_stats_write, |
| 1024 | }; |
| 1025 | |
| 1026 | static ssize_t dasd_stats_global_write(struct file *file, |
| 1027 | const char __user *user_buf, |
| 1028 | size_t user_len, loff_t *pos) |
| 1029 | { |
| 1030 | char *buffer, *str; |
| 1031 | ssize_t rc; |
| 1032 | |
| 1033 | if (user_len > 65536) |
| 1034 | user_len = 65536; |
| 1035 | buffer = dasd_get_user_string(user_buf, user_len); |
| 1036 | if (IS_ERR(buffer)) |
| 1037 | return PTR_ERR(buffer); |
| 1038 | str = skip_spaces(buffer); |
| 1039 | rc = user_len; |
| 1040 | if (strncmp(str, "reset", 5) == 0) { |
| 1041 | dasd_global_profile_reset(); |
| 1042 | } else if (strncmp(str, "on", 2) == 0) { |
| 1043 | dasd_global_profile_reset(); |
| 1044 | dasd_global_profile_level = DASD_PROFILE_GLOBAL_ONLY; |
| 1045 | } else if (strncmp(str, "off", 3) == 0) { |
| 1046 | dasd_global_profile_level = DASD_PROFILE_OFF; |
| 1047 | } else |
| 1048 | rc = -EINVAL; |
Stefan Weinhuber | e4258d5 | 2011-08-03 16:44:20 +0200 | [diff] [blame] | 1049 | vfree(buffer); |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 1050 | return rc; |
| 1051 | } |
| 1052 | |
| 1053 | static int dasd_stats_global_show(struct seq_file *m, void *v) |
| 1054 | { |
| 1055 | if (!dasd_global_profile_level) { |
| 1056 | seq_printf(m, "disabled\n"); |
| 1057 | return 0; |
| 1058 | } |
| 1059 | dasd_stats_seq_print(m, &dasd_global_profile_data); |
| 1060 | return 0; |
| 1061 | } |
| 1062 | |
| 1063 | static int dasd_stats_global_open(struct inode *inode, struct file *file) |
| 1064 | { |
| 1065 | return single_open(file, dasd_stats_global_show, NULL); |
| 1066 | } |
| 1067 | |
| 1068 | static const struct file_operations dasd_stats_global_fops = { |
| 1069 | .owner = THIS_MODULE, |
| 1070 | .open = dasd_stats_global_open, |
| 1071 | .read = seq_read, |
| 1072 | .llseek = seq_lseek, |
| 1073 | .release = single_release, |
| 1074 | .write = dasd_stats_global_write, |
| 1075 | }; |
| 1076 | |
| 1077 | static void dasd_profile_init(struct dasd_profile *profile, |
| 1078 | struct dentry *base_dentry) |
| 1079 | { |
Al Viro | f4ae40a | 2011-07-24 04:33:43 -0400 | [diff] [blame] | 1080 | umode_t mode; |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 1081 | struct dentry *pde; |
| 1082 | |
| 1083 | if (!base_dentry) |
| 1084 | return; |
| 1085 | profile->dentry = NULL; |
| 1086 | profile->data = NULL; |
| 1087 | mode = (S_IRUSR | S_IWUSR | S_IFREG); |
| 1088 | pde = debugfs_create_file("statistics", mode, base_dentry, |
| 1089 | profile, &dasd_stats_raw_fops); |
| 1090 | if (pde && !IS_ERR(pde)) |
| 1091 | profile->dentry = pde; |
| 1092 | return; |
| 1093 | } |
| 1094 | |
| 1095 | static void dasd_profile_exit(struct dasd_profile *profile) |
| 1096 | { |
| 1097 | dasd_profile_off(profile); |
| 1098 | if (profile->dentry) { |
| 1099 | debugfs_remove(profile->dentry); |
| 1100 | profile->dentry = NULL; |
| 1101 | } |
| 1102 | } |
| 1103 | |
| 1104 | static void dasd_statistics_removeroot(void) |
| 1105 | { |
| 1106 | dasd_global_profile_level = DASD_PROFILE_OFF; |
| 1107 | if (dasd_global_profile_dentry) { |
| 1108 | debugfs_remove(dasd_global_profile_dentry); |
| 1109 | dasd_global_profile_dentry = NULL; |
| 1110 | } |
| 1111 | if (dasd_debugfs_global_entry) |
| 1112 | debugfs_remove(dasd_debugfs_global_entry); |
| 1113 | if (dasd_debugfs_root_entry) |
| 1114 | debugfs_remove(dasd_debugfs_root_entry); |
| 1115 | } |
| 1116 | |
| 1117 | static void dasd_statistics_createroot(void) |
| 1118 | { |
Al Viro | f4ae40a | 2011-07-24 04:33:43 -0400 | [diff] [blame] | 1119 | umode_t mode; |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 1120 | struct dentry *pde; |
| 1121 | |
| 1122 | dasd_debugfs_root_entry = NULL; |
| 1123 | dasd_debugfs_global_entry = NULL; |
| 1124 | dasd_global_profile_dentry = NULL; |
| 1125 | pde = debugfs_create_dir("dasd", NULL); |
| 1126 | if (!pde || IS_ERR(pde)) |
| 1127 | goto error; |
| 1128 | dasd_debugfs_root_entry = pde; |
| 1129 | pde = debugfs_create_dir("global", dasd_debugfs_root_entry); |
| 1130 | if (!pde || IS_ERR(pde)) |
| 1131 | goto error; |
| 1132 | dasd_debugfs_global_entry = pde; |
| 1133 | |
| 1134 | mode = (S_IRUSR | S_IWUSR | S_IFREG); |
| 1135 | pde = debugfs_create_file("statistics", mode, dasd_debugfs_global_entry, |
| 1136 | NULL, &dasd_stats_global_fops); |
| 1137 | if (!pde || IS_ERR(pde)) |
| 1138 | goto error; |
| 1139 | dasd_global_profile_dentry = pde; |
| 1140 | return; |
| 1141 | |
| 1142 | error: |
| 1143 | DBF_EVENT(DBF_ERR, "%s", |
| 1144 | "Creation of the dasd debugfs interface failed"); |
| 1145 | dasd_statistics_removeroot(); |
| 1146 | return; |
| 1147 | } |
| 1148 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1149 | #else |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1150 | #define dasd_profile_start(block, cqr, req) do {} while (0) |
| 1151 | #define dasd_profile_end(block, cqr, req) do {} while (0) |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 1152 | |
| 1153 | static void dasd_statistics_createroot(void) |
| 1154 | { |
| 1155 | return; |
| 1156 | } |
| 1157 | |
| 1158 | static void dasd_statistics_removeroot(void) |
| 1159 | { |
| 1160 | return; |
| 1161 | } |
| 1162 | |
| 1163 | int dasd_stats_generic_show(struct seq_file *m, void *v) |
| 1164 | { |
| 1165 | seq_printf(m, "Statistics are not activated in this kernel\n"); |
| 1166 | return 0; |
| 1167 | } |
| 1168 | |
| 1169 | static void dasd_profile_init(struct dasd_profile *profile, |
| 1170 | struct dentry *base_dentry) |
| 1171 | { |
| 1172 | return; |
| 1173 | } |
| 1174 | |
| 1175 | static void dasd_profile_exit(struct dasd_profile *profile) |
| 1176 | { |
| 1177 | return; |
| 1178 | } |
| 1179 | |
| 1180 | int dasd_profile_on(struct dasd_profile *profile) |
| 1181 | { |
| 1182 | return 0; |
| 1183 | } |
| 1184 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1185 | #endif /* CONFIG_DASD_PROFILE */ |
| 1186 | |
| 1187 | /* |
| 1188 | * Allocate memory for a channel program with 'cplength' channel |
| 1189 | * command words and 'datasize' additional space. There are two |
| 1190 | * variantes: 1) dasd_kmalloc_request uses kmalloc to get the needed |
| 1191 | * memory and 2) dasd_smalloc_request uses the static ccw memory |
| 1192 | * that gets allocated for each device. |
| 1193 | */ |
Stefan Haberland | 68b781f | 2009-09-11 10:28:29 +0200 | [diff] [blame] | 1194 | struct dasd_ccw_req *dasd_kmalloc_request(int magic, int cplength, |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1195 | int datasize, |
| 1196 | struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1197 | { |
| 1198 | struct dasd_ccw_req *cqr; |
| 1199 | |
| 1200 | /* Sanity checks */ |
Stefan Haberland | 68b781f | 2009-09-11 10:28:29 +0200 | [diff] [blame] | 1201 | BUG_ON(datasize > PAGE_SIZE || |
Eric Sesterhenn | 7ac1e87 | 2006-03-24 18:48:13 +0100 | [diff] [blame] | 1202 | (cplength*sizeof(struct ccw1)) > PAGE_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1203 | |
Eric Sesterhenn | 88abaab | 2006-03-24 03:15:31 -0800 | [diff] [blame] | 1204 | cqr = kzalloc(sizeof(struct dasd_ccw_req), GFP_ATOMIC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1205 | if (cqr == NULL) |
| 1206 | return ERR_PTR(-ENOMEM); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1207 | cqr->cpaddr = NULL; |
| 1208 | if (cplength > 0) { |
Eric Sesterhenn | 88abaab | 2006-03-24 03:15:31 -0800 | [diff] [blame] | 1209 | cqr->cpaddr = kcalloc(cplength, sizeof(struct ccw1), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1210 | GFP_ATOMIC | GFP_DMA); |
| 1211 | if (cqr->cpaddr == NULL) { |
| 1212 | kfree(cqr); |
| 1213 | return ERR_PTR(-ENOMEM); |
| 1214 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1215 | } |
| 1216 | cqr->data = NULL; |
| 1217 | if (datasize > 0) { |
Eric Sesterhenn | 88abaab | 2006-03-24 03:15:31 -0800 | [diff] [blame] | 1218 | cqr->data = kzalloc(datasize, GFP_ATOMIC | GFP_DMA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1219 | if (cqr->data == NULL) { |
Jesper Juhl | 17fd682 | 2005-11-07 01:01:30 -0800 | [diff] [blame] | 1220 | kfree(cqr->cpaddr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1221 | kfree(cqr); |
| 1222 | return ERR_PTR(-ENOMEM); |
| 1223 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1224 | } |
Stefan Haberland | 68b781f | 2009-09-11 10:28:29 +0200 | [diff] [blame] | 1225 | cqr->magic = magic; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1226 | set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags); |
| 1227 | dasd_get_device(device); |
| 1228 | return cqr; |
| 1229 | } |
| 1230 | |
Stefan Haberland | 68b781f | 2009-09-11 10:28:29 +0200 | [diff] [blame] | 1231 | struct dasd_ccw_req *dasd_smalloc_request(int magic, int cplength, |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1232 | int datasize, |
| 1233 | struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1234 | { |
| 1235 | unsigned long flags; |
| 1236 | struct dasd_ccw_req *cqr; |
| 1237 | char *data; |
| 1238 | int size; |
| 1239 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1240 | size = (sizeof(struct dasd_ccw_req) + 7L) & -8L; |
| 1241 | if (cplength > 0) |
| 1242 | size += cplength * sizeof(struct ccw1); |
| 1243 | if (datasize > 0) |
| 1244 | size += datasize; |
| 1245 | spin_lock_irqsave(&device->mem_lock, flags); |
| 1246 | cqr = (struct dasd_ccw_req *) |
| 1247 | dasd_alloc_chunk(&device->ccw_chunks, size); |
| 1248 | spin_unlock_irqrestore(&device->mem_lock, flags); |
| 1249 | if (cqr == NULL) |
| 1250 | return ERR_PTR(-ENOMEM); |
| 1251 | memset(cqr, 0, sizeof(struct dasd_ccw_req)); |
| 1252 | data = (char *) cqr + ((sizeof(struct dasd_ccw_req) + 7L) & -8L); |
| 1253 | cqr->cpaddr = NULL; |
| 1254 | if (cplength > 0) { |
| 1255 | cqr->cpaddr = (struct ccw1 *) data; |
| 1256 | data += cplength*sizeof(struct ccw1); |
| 1257 | memset(cqr->cpaddr, 0, cplength*sizeof(struct ccw1)); |
| 1258 | } |
| 1259 | cqr->data = NULL; |
| 1260 | if (datasize > 0) { |
| 1261 | cqr->data = data; |
| 1262 | memset(cqr->data, 0, datasize); |
| 1263 | } |
Stefan Haberland | 68b781f | 2009-09-11 10:28:29 +0200 | [diff] [blame] | 1264 | cqr->magic = magic; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1265 | set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags); |
| 1266 | dasd_get_device(device); |
| 1267 | return cqr; |
| 1268 | } |
| 1269 | |
| 1270 | /* |
| 1271 | * Free memory of a channel program. This function needs to free all the |
| 1272 | * idal lists that might have been created by dasd_set_cda and the |
| 1273 | * struct dasd_ccw_req itself. |
| 1274 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1275 | 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] | 1276 | { |
Martin Schwidefsky | 347a8dc | 2006-01-06 00:19:28 -0800 | [diff] [blame] | 1277 | #ifdef CONFIG_64BIT |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1278 | struct ccw1 *ccw; |
| 1279 | |
| 1280 | /* Clear any idals used for the request. */ |
| 1281 | ccw = cqr->cpaddr; |
| 1282 | do { |
| 1283 | clear_normalized_cda(ccw); |
| 1284 | } while (ccw++->flags & (CCW_FLAG_CC | CCW_FLAG_DC)); |
| 1285 | #endif |
Jesper Juhl | 17fd682 | 2005-11-07 01:01:30 -0800 | [diff] [blame] | 1286 | kfree(cqr->cpaddr); |
| 1287 | kfree(cqr->data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1288 | kfree(cqr); |
| 1289 | dasd_put_device(device); |
| 1290 | } |
| 1291 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1292 | 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] | 1293 | { |
| 1294 | unsigned long flags; |
| 1295 | |
| 1296 | spin_lock_irqsave(&device->mem_lock, flags); |
| 1297 | dasd_free_chunk(&device->ccw_chunks, cqr); |
| 1298 | spin_unlock_irqrestore(&device->mem_lock, flags); |
| 1299 | dasd_put_device(device); |
| 1300 | } |
| 1301 | |
| 1302 | /* |
| 1303 | * Check discipline magic in cqr. |
| 1304 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1305 | static inline int dasd_check_cqr(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1306 | { |
| 1307 | struct dasd_device *device; |
| 1308 | |
| 1309 | if (cqr == NULL) |
| 1310 | return -EINVAL; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1311 | device = cqr->startdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1312 | if (strncmp((char *) &cqr->magic, device->discipline->ebcname, 4)) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1313 | DBF_DEV_EVENT(DBF_WARNING, device, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1314 | " dasd_ccw_req 0x%08x magic doesn't match" |
| 1315 | " discipline 0x%08x", |
| 1316 | cqr->magic, |
| 1317 | *(unsigned int *) device->discipline->name); |
| 1318 | return -EINVAL; |
| 1319 | } |
| 1320 | return 0; |
| 1321 | } |
| 1322 | |
| 1323 | /* |
| 1324 | * Terminate the current i/o and set the request to clear_pending. |
| 1325 | * Timer keeps device runnig. |
| 1326 | * ccw_device_clear can fail if the i/o subsystem |
| 1327 | * is in a bad mood. |
| 1328 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1329 | int dasd_term_IO(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1330 | { |
| 1331 | struct dasd_device *device; |
| 1332 | int retries, rc; |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1333 | char errorstring[ERRORLENGTH]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1334 | |
| 1335 | /* Check the cqr */ |
| 1336 | rc = dasd_check_cqr(cqr); |
| 1337 | if (rc) |
| 1338 | return rc; |
| 1339 | retries = 0; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1340 | device = (struct dasd_device *) cqr->startdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1341 | while ((retries < 5) && (cqr->status == DASD_CQR_IN_IO)) { |
| 1342 | rc = ccw_device_clear(device->cdev, (long) cqr); |
| 1343 | switch (rc) { |
| 1344 | case 0: /* termination successful */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1345 | cqr->status = DASD_CQR_CLEAR_PENDING; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1346 | cqr->stopclk = get_clock(); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1347 | cqr->starttime = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1348 | DBF_DEV_EVENT(DBF_DEBUG, device, |
| 1349 | "terminate cqr %p successful", |
| 1350 | cqr); |
| 1351 | break; |
| 1352 | case -ENODEV: |
| 1353 | DBF_DEV_EVENT(DBF_ERR, device, "%s", |
| 1354 | "device gone, retry"); |
| 1355 | break; |
| 1356 | case -EIO: |
| 1357 | DBF_DEV_EVENT(DBF_ERR, device, "%s", |
| 1358 | "I/O error, retry"); |
| 1359 | break; |
| 1360 | case -EINVAL: |
| 1361 | case -EBUSY: |
| 1362 | DBF_DEV_EVENT(DBF_ERR, device, "%s", |
| 1363 | "device busy, retry later"); |
| 1364 | break; |
| 1365 | default: |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1366 | /* internal error 10 - unknown rc*/ |
| 1367 | snprintf(errorstring, ERRORLENGTH, "10 %d", rc); |
| 1368 | dev_err(&device->cdev->dev, "An error occurred in the " |
| 1369 | "DASD device driver, reason=%s\n", errorstring); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1370 | BUG(); |
| 1371 | break; |
| 1372 | } |
| 1373 | retries++; |
| 1374 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1375 | dasd_schedule_device_bh(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1376 | return rc; |
| 1377 | } |
| 1378 | |
| 1379 | /* |
| 1380 | * Start the i/o. This start_IO can fail if the channel is really busy. |
| 1381 | * In that case set up a timer to start the request later. |
| 1382 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1383 | int dasd_start_IO(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1384 | { |
| 1385 | struct dasd_device *device; |
| 1386 | int rc; |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1387 | char errorstring[ERRORLENGTH]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1388 | |
| 1389 | /* Check the cqr */ |
| 1390 | rc = dasd_check_cqr(cqr); |
Stefan Weinhuber | 6cc7f16 | 2009-06-12 10:26:39 +0200 | [diff] [blame] | 1391 | if (rc) { |
| 1392 | cqr->intrc = rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1393 | return rc; |
Stefan Weinhuber | 6cc7f16 | 2009-06-12 10:26:39 +0200 | [diff] [blame] | 1394 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1395 | device = (struct dasd_device *) cqr->startdev; |
Stefan Weinhuber | 5a27e60 | 2011-01-05 12:48:04 +0100 | [diff] [blame] | 1396 | if (((cqr->block && |
| 1397 | test_bit(DASD_FLAG_LOCK_STOLEN, &cqr->block->base->flags)) || |
| 1398 | test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags)) && |
| 1399 | !test_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags)) { |
| 1400 | DBF_DEV_EVENT(DBF_DEBUG, device, "start_IO: return request %p " |
| 1401 | "because of stolen lock", cqr); |
| 1402 | cqr->status = DASD_CQR_ERROR; |
| 1403 | cqr->intrc = -EPERM; |
| 1404 | return -EPERM; |
| 1405 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1406 | if (cqr->retries < 0) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1407 | /* internal error 14 - start_IO run out of retries */ |
| 1408 | sprintf(errorstring, "14 %p", cqr); |
| 1409 | dev_err(&device->cdev->dev, "An error occurred in the DASD " |
| 1410 | "device driver, reason=%s\n", errorstring); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1411 | cqr->status = DASD_CQR_ERROR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1412 | return -EIO; |
| 1413 | } |
| 1414 | cqr->startclk = get_clock(); |
| 1415 | cqr->starttime = jiffies; |
| 1416 | cqr->retries--; |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 1417 | if (!test_bit(DASD_CQR_VERIFY_PATH, &cqr->flags)) { |
| 1418 | cqr->lpm &= device->path_data.opm; |
| 1419 | if (!cqr->lpm) |
| 1420 | cqr->lpm = device->path_data.opm; |
| 1421 | } |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 1422 | if (cqr->cpmode == 1) { |
| 1423 | rc = ccw_device_tm_start(device->cdev, cqr->cpaddr, |
| 1424 | (long) cqr, cqr->lpm); |
| 1425 | } else { |
| 1426 | rc = ccw_device_start(device->cdev, cqr->cpaddr, |
| 1427 | (long) cqr, cqr->lpm, 0); |
| 1428 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1429 | switch (rc) { |
| 1430 | case 0: |
| 1431 | cqr->status = DASD_CQR_IN_IO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1432 | break; |
| 1433 | case -EBUSY: |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 1434 | DBF_DEV_EVENT(DBF_WARNING, device, "%s", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1435 | "start_IO: device busy, retry later"); |
| 1436 | break; |
| 1437 | case -ETIMEDOUT: |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 1438 | DBF_DEV_EVENT(DBF_WARNING, device, "%s", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1439 | "start_IO: request timeout, retry later"); |
| 1440 | break; |
| 1441 | case -EACCES: |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 1442 | /* -EACCES indicates that the request used only a subset of the |
| 1443 | * available paths and all these paths are gone. If the lpm of |
| 1444 | * this request was only a subset of the opm (e.g. the ppm) then |
| 1445 | * we just do a retry with all available paths. |
| 1446 | * If we already use the full opm, something is amiss, and we |
| 1447 | * need a full path verification. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1448 | */ |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 1449 | if (test_bit(DASD_CQR_VERIFY_PATH, &cqr->flags)) { |
| 1450 | DBF_DEV_EVENT(DBF_WARNING, device, |
| 1451 | "start_IO: selected paths gone (%x)", |
| 1452 | cqr->lpm); |
| 1453 | } else if (cqr->lpm != device->path_data.opm) { |
| 1454 | cqr->lpm = device->path_data.opm; |
| 1455 | DBF_DEV_EVENT(DBF_DEBUG, device, "%s", |
| 1456 | "start_IO: selected paths gone," |
| 1457 | " retry on all paths"); |
| 1458 | } else { |
| 1459 | DBF_DEV_EVENT(DBF_WARNING, device, "%s", |
| 1460 | "start_IO: all paths in opm gone," |
| 1461 | " do path verification"); |
| 1462 | dasd_generic_last_path_gone(device); |
| 1463 | device->path_data.opm = 0; |
| 1464 | device->path_data.ppm = 0; |
| 1465 | device->path_data.npm = 0; |
| 1466 | device->path_data.tbvpm = |
| 1467 | ccw_device_get_path_mask(device->cdev); |
| 1468 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1469 | break; |
| 1470 | case -ENODEV: |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 1471 | DBF_DEV_EVENT(DBF_WARNING, device, "%s", |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 1472 | "start_IO: -ENODEV device gone, retry"); |
| 1473 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1474 | case -EIO: |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 1475 | DBF_DEV_EVENT(DBF_WARNING, device, "%s", |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 1476 | "start_IO: -EIO device gone, retry"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1477 | break; |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 1478 | case -EINVAL: |
| 1479 | /* most likely caused in power management context */ |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 1480 | DBF_DEV_EVENT(DBF_WARNING, device, "%s", |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 1481 | "start_IO: -EINVAL device currently " |
| 1482 | "not accessible"); |
| 1483 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1484 | default: |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1485 | /* internal error 11 - unknown rc */ |
| 1486 | snprintf(errorstring, ERRORLENGTH, "11 %d", rc); |
| 1487 | dev_err(&device->cdev->dev, |
| 1488 | "An error occurred in the DASD device driver, " |
| 1489 | "reason=%s\n", errorstring); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1490 | BUG(); |
| 1491 | break; |
| 1492 | } |
Stefan Weinhuber | 6cc7f16 | 2009-06-12 10:26:39 +0200 | [diff] [blame] | 1493 | cqr->intrc = rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1494 | return rc; |
| 1495 | } |
| 1496 | |
| 1497 | /* |
| 1498 | * Timeout function for dasd devices. This is used for different purposes |
| 1499 | * 1) missing interrupt handler for normal operation |
| 1500 | * 2) delayed start of request where start_IO failed with -EBUSY |
| 1501 | * 3) timeout for missing state change interrupts |
| 1502 | * The head of the ccw queue will have status DASD_CQR_IN_IO for 1), |
| 1503 | * DASD_CQR_QUEUED for 2) and 3). |
| 1504 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1505 | static void dasd_device_timeout(unsigned long ptr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1506 | { |
| 1507 | unsigned long flags; |
| 1508 | struct dasd_device *device; |
| 1509 | |
| 1510 | device = (struct dasd_device *) ptr; |
| 1511 | spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); |
| 1512 | /* re-activate request queue */ |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 1513 | dasd_device_remove_stop_bits(device, DASD_STOPPED_PENDING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1514 | spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1515 | dasd_schedule_device_bh(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1516 | } |
| 1517 | |
| 1518 | /* |
| 1519 | * Setup timeout for a device in jiffies. |
| 1520 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1521 | void dasd_device_set_timer(struct dasd_device *device, int expires) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1522 | { |
Stefan Weinhuber | 48cae88 | 2009-02-11 10:37:31 +0100 | [diff] [blame] | 1523 | if (expires == 0) |
| 1524 | del_timer(&device->timer); |
| 1525 | else |
| 1526 | mod_timer(&device->timer, jiffies + expires); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1527 | } |
| 1528 | |
| 1529 | /* |
| 1530 | * Clear timeout for a device. |
| 1531 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1532 | void dasd_device_clear_timer(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1533 | { |
Stefan Weinhuber | 48cae88 | 2009-02-11 10:37:31 +0100 | [diff] [blame] | 1534 | del_timer(&device->timer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1535 | } |
| 1536 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1537 | static void dasd_handle_killed_request(struct ccw_device *cdev, |
| 1538 | unsigned long intparm) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1539 | { |
| 1540 | struct dasd_ccw_req *cqr; |
| 1541 | struct dasd_device *device; |
| 1542 | |
Stefan Weinhuber | f16f584 | 2008-05-15 16:52:36 +0200 | [diff] [blame] | 1543 | if (!intparm) |
| 1544 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1545 | cqr = (struct dasd_ccw_req *) intparm; |
| 1546 | if (cqr->status != DASD_CQR_IN_IO) { |
Stefan Haberland | b8ed5dd | 2009-12-07 12:51:52 +0100 | [diff] [blame] | 1547 | DBF_EVENT_DEVID(DBF_DEBUG, cdev, |
| 1548 | "invalid status in handle_killed_request: " |
| 1549 | "%02x", cqr->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1550 | return; |
| 1551 | } |
| 1552 | |
Stefan Haberland | 589c74d | 2010-02-26 22:37:47 +0100 | [diff] [blame] | 1553 | device = dasd_device_from_cdev_locked(cdev); |
| 1554 | if (IS_ERR(device)) { |
| 1555 | DBF_EVENT_DEVID(DBF_DEBUG, cdev, "%s", |
| 1556 | "unable to get device from cdev"); |
| 1557 | return; |
| 1558 | } |
| 1559 | |
| 1560 | if (!cqr->startdev || |
| 1561 | device != cqr->startdev || |
| 1562 | strncmp(cqr->startdev->discipline->ebcname, |
| 1563 | (char *) &cqr->magic, 4)) { |
Stefan Haberland | 294001a | 2010-01-27 10:12:35 +0100 | [diff] [blame] | 1564 | DBF_EVENT_DEVID(DBF_DEBUG, cdev, "%s", |
| 1565 | "invalid device in request"); |
Stefan Haberland | 589c74d | 2010-02-26 22:37:47 +0100 | [diff] [blame] | 1566 | dasd_put_device(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1567 | return; |
| 1568 | } |
| 1569 | |
| 1570 | /* Schedule request to be retried. */ |
| 1571 | cqr->status = DASD_CQR_QUEUED; |
| 1572 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1573 | dasd_device_clear_timer(device); |
| 1574 | dasd_schedule_device_bh(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1575 | dasd_put_device(device); |
| 1576 | } |
| 1577 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1578 | void dasd_generic_handle_state_change(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1579 | { |
Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 1580 | /* First of all start sense subsystem status request. */ |
| 1581 | dasd_eer_snss(device); |
| 1582 | |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 1583 | dasd_device_remove_stop_bits(device, DASD_STOPPED_PENDING); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1584 | dasd_schedule_device_bh(device); |
| 1585 | if (device->block) |
| 1586 | dasd_schedule_block_bh(device->block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1587 | } |
| 1588 | |
| 1589 | /* |
| 1590 | * Interrupt handler for "normal" ssch-io based dasd devices. |
| 1591 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1592 | void dasd_int_handler(struct ccw_device *cdev, unsigned long intparm, |
| 1593 | struct irb *irb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1594 | { |
| 1595 | struct dasd_ccw_req *cqr, *next; |
| 1596 | struct dasd_device *device; |
| 1597 | unsigned long long now; |
| 1598 | int expires; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1599 | |
| 1600 | if (IS_ERR(irb)) { |
| 1601 | switch (PTR_ERR(irb)) { |
| 1602 | case -EIO: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1603 | break; |
| 1604 | case -ETIMEDOUT: |
Stefan Haberland | b8ed5dd | 2009-12-07 12:51:52 +0100 | [diff] [blame] | 1605 | DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s: " |
| 1606 | "request timed out\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1607 | break; |
| 1608 | default: |
Stefan Haberland | b8ed5dd | 2009-12-07 12:51:52 +0100 | [diff] [blame] | 1609 | DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s: " |
| 1610 | "unknown error %ld\n", __func__, |
| 1611 | PTR_ERR(irb)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1612 | } |
Stefan Weinhuber | f16f584 | 2008-05-15 16:52:36 +0200 | [diff] [blame] | 1613 | dasd_handle_killed_request(cdev, intparm); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1614 | return; |
| 1615 | } |
| 1616 | |
| 1617 | now = get_clock(); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1618 | cqr = (struct dasd_ccw_req *) intparm; |
Stefan Weinhuber | 5a27e60 | 2011-01-05 12:48:04 +0100 | [diff] [blame] | 1619 | /* check for conditions that should be handled immediately */ |
| 1620 | if (!cqr || |
| 1621 | !(scsw_dstat(&irb->scsw) == (DEV_STAT_CHN_END | DEV_STAT_DEV_END) && |
| 1622 | scsw_cstat(&irb->scsw) == 0)) { |
Stefan Weinhuber | a5a0061 | 2010-10-25 16:10:47 +0200 | [diff] [blame] | 1623 | if (cqr) |
| 1624 | memcpy(&cqr->irb, irb, sizeof(*irb)); |
Martin Schwidefsky | a00bfd7 | 2006-09-20 15:59:05 +0200 | [diff] [blame] | 1625 | device = dasd_device_from_cdev_locked(cdev); |
Stefan Haberland | 56b86b6 | 2010-10-25 16:10:49 +0200 | [diff] [blame] | 1626 | if (IS_ERR(device)) |
| 1627 | return; |
| 1628 | /* ignore unsolicited interrupts for DIAG discipline */ |
| 1629 | if (device->discipline == dasd_diag_discipline_pointer) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1630 | dasd_put_device(device); |
Stefan Haberland | 56b86b6 | 2010-10-25 16:10:49 +0200 | [diff] [blame] | 1631 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1632 | } |
Stefan Weinhuber | 5a27e60 | 2011-01-05 12:48:04 +0100 | [diff] [blame] | 1633 | device->discipline->dump_sense_dbf(device, irb, "int"); |
| 1634 | if (device->features & DASD_FEATURE_ERPLOG) |
| 1635 | device->discipline->dump_sense(device, cqr, irb); |
| 1636 | device->discipline->check_for_device_change(device, cqr, irb); |
Stefan Haberland | 56b86b6 | 2010-10-25 16:10:49 +0200 | [diff] [blame] | 1637 | dasd_put_device(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1638 | } |
Stefan Weinhuber | 5a27e60 | 2011-01-05 12:48:04 +0100 | [diff] [blame] | 1639 | if (!cqr) |
| 1640 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1641 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1642 | device = (struct dasd_device *) cqr->startdev; |
| 1643 | if (!device || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1644 | strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) { |
Stefan Haberland | 294001a | 2010-01-27 10:12:35 +0100 | [diff] [blame] | 1645 | DBF_EVENT_DEVID(DBF_DEBUG, cdev, "%s", |
| 1646 | "invalid device in request"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1647 | return; |
| 1648 | } |
| 1649 | |
| 1650 | /* Check for clear pending */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1651 | if (cqr->status == DASD_CQR_CLEAR_PENDING && |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 1652 | scsw_fctl(&irb->scsw) & SCSW_FCTL_CLEAR_FUNC) { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1653 | cqr->status = DASD_CQR_CLEARED; |
| 1654 | dasd_device_clear_timer(device); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1655 | wake_up(&dasd_flush_wq); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1656 | dasd_schedule_device_bh(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1657 | return; |
| 1658 | } |
| 1659 | |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 1660 | /* check status - the request might have been killed by dyn detach */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1661 | if (cqr->status != DASD_CQR_IN_IO) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1662 | DBF_DEV_EVENT(DBF_DEBUG, device, "invalid status: bus_id %s, " |
| 1663 | "status %02x", dev_name(&cdev->dev), cqr->status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1664 | return; |
| 1665 | } |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1666 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1667 | next = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1668 | expires = 0; |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 1669 | if (scsw_dstat(&irb->scsw) == (DEV_STAT_CHN_END | DEV_STAT_DEV_END) && |
| 1670 | scsw_cstat(&irb->scsw) == 0) { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1671 | /* request was completed successfully */ |
| 1672 | cqr->status = DASD_CQR_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1673 | cqr->stopclk = now; |
| 1674 | /* Start first request on queue if possible -> fast_io. */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1675 | if (cqr->devlist.next != &device->ccw_queue) { |
| 1676 | next = list_entry(cqr->devlist.next, |
| 1677 | struct dasd_ccw_req, devlist); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1678 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1679 | } else { /* error */ |
Stefan Haberland | 6c5f57c | 2008-02-05 16:50:46 +0100 | [diff] [blame] | 1680 | /* |
| 1681 | * If we don't want complex ERP for this request, then just |
| 1682 | * reset this and retry it in the fastpath |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1683 | */ |
Stefan Haberland | 6c5f57c | 2008-02-05 16:50:46 +0100 | [diff] [blame] | 1684 | if (!test_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags) && |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1685 | cqr->retries > 0) { |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 1686 | if (cqr->lpm == device->path_data.opm) |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1687 | DBF_DEV_EVENT(DBF_DEBUG, device, |
| 1688 | "default ERP in fastpath " |
| 1689 | "(%i retries left)", |
| 1690 | cqr->retries); |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 1691 | if (!test_bit(DASD_CQR_VERIFY_PATH, &cqr->flags)) |
| 1692 | cqr->lpm = device->path_data.opm; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1693 | cqr->status = DASD_CQR_QUEUED; |
| 1694 | next = cqr; |
| 1695 | } else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1696 | cqr->status = DASD_CQR_ERROR; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1697 | } |
| 1698 | if (next && (next->status == DASD_CQR_QUEUED) && |
| 1699 | (!device->stopped)) { |
| 1700 | if (device->discipline->start_IO(next) == 0) |
| 1701 | expires = next->expires; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1702 | } |
| 1703 | if (expires != 0) |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1704 | dasd_device_set_timer(device, expires); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1705 | else |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1706 | dasd_device_clear_timer(device); |
| 1707 | dasd_schedule_device_bh(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1708 | } |
| 1709 | |
Stefan Haberland | a23ed00 | 2010-05-26 23:27:09 +0200 | [diff] [blame] | 1710 | enum uc_todo dasd_generic_uc_handler(struct ccw_device *cdev, struct irb *irb) |
| 1711 | { |
| 1712 | struct dasd_device *device; |
| 1713 | |
| 1714 | device = dasd_device_from_cdev_locked(cdev); |
| 1715 | |
| 1716 | if (IS_ERR(device)) |
| 1717 | goto out; |
| 1718 | if (test_bit(DASD_FLAG_OFFLINE, &device->flags) || |
| 1719 | device->state != device->target || |
Stefan Weinhuber | 5a27e60 | 2011-01-05 12:48:04 +0100 | [diff] [blame] | 1720 | !device->discipline->check_for_device_change){ |
Stefan Haberland | a23ed00 | 2010-05-26 23:27:09 +0200 | [diff] [blame] | 1721 | dasd_put_device(device); |
| 1722 | goto out; |
| 1723 | } |
Stefan Weinhuber | 5a27e60 | 2011-01-05 12:48:04 +0100 | [diff] [blame] | 1724 | if (device->discipline->dump_sense_dbf) |
| 1725 | device->discipline->dump_sense_dbf(device, irb, "uc"); |
| 1726 | device->discipline->check_for_device_change(device, NULL, irb); |
Stefan Haberland | a23ed00 | 2010-05-26 23:27:09 +0200 | [diff] [blame] | 1727 | dasd_put_device(device); |
| 1728 | out: |
| 1729 | return UC_TODO_RETRY; |
| 1730 | } |
| 1731 | EXPORT_SYMBOL_GPL(dasd_generic_uc_handler); |
| 1732 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1733 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1734 | * If we have an error on a dasd_block layer request then we cancel |
| 1735 | * and return all further requests from the same dasd_block as well. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1736 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1737 | static void __dasd_device_recovery(struct dasd_device *device, |
| 1738 | struct dasd_ccw_req *ref_cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1739 | { |
| 1740 | struct list_head *l, *n; |
| 1741 | struct dasd_ccw_req *cqr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1742 | |
| 1743 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1744 | * only requeue request that came from the dasd_block layer |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1745 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1746 | if (!ref_cqr->block) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1747 | return; |
Horst Hummel | f24acd4 | 2005-05-01 08:58:59 -0700 | [diff] [blame] | 1748 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1749 | list_for_each_safe(l, n, &device->ccw_queue) { |
| 1750 | cqr = list_entry(l, struct dasd_ccw_req, devlist); |
| 1751 | if (cqr->status == DASD_CQR_QUEUED && |
| 1752 | ref_cqr->block == cqr->block) { |
| 1753 | cqr->status = DASD_CQR_CLEARED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1754 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1755 | } |
| 1756 | }; |
| 1757 | |
| 1758 | /* |
| 1759 | * Remove those ccw requests from the queue that need to be returned |
| 1760 | * to the upper layer. |
| 1761 | */ |
| 1762 | static void __dasd_device_process_ccw_queue(struct dasd_device *device, |
| 1763 | struct list_head *final_queue) |
| 1764 | { |
| 1765 | struct list_head *l, *n; |
| 1766 | struct dasd_ccw_req *cqr; |
| 1767 | |
| 1768 | /* Process request with final status. */ |
| 1769 | list_for_each_safe(l, n, &device->ccw_queue) { |
| 1770 | cqr = list_entry(l, struct dasd_ccw_req, devlist); |
| 1771 | |
| 1772 | /* Stop list processing at the first non-final request. */ |
| 1773 | if (cqr->status == DASD_CQR_QUEUED || |
| 1774 | cqr->status == DASD_CQR_IN_IO || |
| 1775 | cqr->status == DASD_CQR_CLEAR_PENDING) |
| 1776 | break; |
| 1777 | if (cqr->status == DASD_CQR_ERROR) { |
| 1778 | __dasd_device_recovery(device, cqr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1779 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1780 | /* Rechain finished requests to final queue */ |
| 1781 | list_move_tail(&cqr->devlist, final_queue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1782 | } |
| 1783 | } |
| 1784 | |
| 1785 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1786 | * the cqrs from the final queue are returned to the upper layer |
| 1787 | * by setting a dasd_block state and calling the callback function |
| 1788 | */ |
| 1789 | static void __dasd_device_process_final_queue(struct dasd_device *device, |
| 1790 | struct list_head *final_queue) |
| 1791 | { |
| 1792 | struct list_head *l, *n; |
| 1793 | struct dasd_ccw_req *cqr; |
Stefan Weinhuber | 03513bc | 2008-02-19 15:29:27 +0100 | [diff] [blame] | 1794 | struct dasd_block *block; |
Stefan Haberland | c80ee72 | 2008-05-30 10:03:31 +0200 | [diff] [blame] | 1795 | void (*callback)(struct dasd_ccw_req *, void *data); |
| 1796 | void *callback_data; |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1797 | char errorstring[ERRORLENGTH]; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1798 | |
| 1799 | list_for_each_safe(l, n, final_queue) { |
| 1800 | cqr = list_entry(l, struct dasd_ccw_req, devlist); |
| 1801 | list_del_init(&cqr->devlist); |
Stefan Weinhuber | 03513bc | 2008-02-19 15:29:27 +0100 | [diff] [blame] | 1802 | block = cqr->block; |
Stefan Haberland | c80ee72 | 2008-05-30 10:03:31 +0200 | [diff] [blame] | 1803 | callback = cqr->callback; |
| 1804 | callback_data = cqr->callback_data; |
Stefan Weinhuber | 03513bc | 2008-02-19 15:29:27 +0100 | [diff] [blame] | 1805 | if (block) |
| 1806 | spin_lock_bh(&block->queue_lock); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1807 | switch (cqr->status) { |
| 1808 | case DASD_CQR_SUCCESS: |
| 1809 | cqr->status = DASD_CQR_DONE; |
| 1810 | break; |
| 1811 | case DASD_CQR_ERROR: |
| 1812 | cqr->status = DASD_CQR_NEED_ERP; |
| 1813 | break; |
| 1814 | case DASD_CQR_CLEARED: |
| 1815 | cqr->status = DASD_CQR_TERMINATED; |
| 1816 | break; |
| 1817 | default: |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1818 | /* internal error 12 - wrong cqr status*/ |
| 1819 | snprintf(errorstring, ERRORLENGTH, "12 %p %x02", cqr, cqr->status); |
| 1820 | dev_err(&device->cdev->dev, |
| 1821 | "An error occurred in the DASD device driver, " |
| 1822 | "reason=%s\n", errorstring); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1823 | BUG(); |
| 1824 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1825 | if (cqr->callback != NULL) |
Stefan Haberland | c80ee72 | 2008-05-30 10:03:31 +0200 | [diff] [blame] | 1826 | (callback)(cqr, callback_data); |
Stefan Weinhuber | 03513bc | 2008-02-19 15:29:27 +0100 | [diff] [blame] | 1827 | if (block) |
| 1828 | spin_unlock_bh(&block->queue_lock); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1829 | } |
| 1830 | } |
| 1831 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1832 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1833 | * Take a look at the first request on the ccw queue and check |
| 1834 | * if it reached its expire time. If so, terminate the IO. |
| 1835 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1836 | static void __dasd_device_check_expire(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1837 | { |
| 1838 | struct dasd_ccw_req *cqr; |
| 1839 | |
| 1840 | if (list_empty(&device->ccw_queue)) |
| 1841 | return; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1842 | cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); |
Horst Hummel | 29145a6 | 2006-12-04 15:40:15 +0100 | [diff] [blame] | 1843 | if ((cqr->status == DASD_CQR_IN_IO && cqr->expires != 0) && |
| 1844 | (time_after_eq(jiffies, cqr->expires + cqr->starttime))) { |
| 1845 | if (device->discipline->term_IO(cqr) != 0) { |
| 1846 | /* Hmpf, try again in 5 sec */ |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1847 | dev_err(&device->cdev->dev, |
Heiko Carstens | 625c94d | 2010-08-13 10:06:38 +0200 | [diff] [blame] | 1848 | "cqr %p timed out (%lus) but cannot be " |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1849 | "ended, retrying in 5 s\n", |
| 1850 | cqr, (cqr->expires/HZ)); |
Stefan Haberland | 7dc1da9 | 2008-01-26 14:11:26 +0100 | [diff] [blame] | 1851 | cqr->expires += 5*HZ; |
| 1852 | dasd_device_set_timer(device, 5*HZ); |
Horst Hummel | 29145a6 | 2006-12-04 15:40:15 +0100 | [diff] [blame] | 1853 | } else { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1854 | dev_err(&device->cdev->dev, |
Heiko Carstens | 625c94d | 2010-08-13 10:06:38 +0200 | [diff] [blame] | 1855 | "cqr %p timed out (%lus), %i retries " |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1856 | "remaining\n", cqr, (cqr->expires/HZ), |
| 1857 | cqr->retries); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1858 | } |
| 1859 | } |
| 1860 | } |
| 1861 | |
| 1862 | /* |
| 1863 | * Take a look at the first request on the ccw queue and check |
| 1864 | * if it needs to be started. |
| 1865 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1866 | static void __dasd_device_start_head(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1867 | { |
| 1868 | struct dasd_ccw_req *cqr; |
| 1869 | int rc; |
| 1870 | |
| 1871 | if (list_empty(&device->ccw_queue)) |
| 1872 | return; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1873 | cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); |
Peter Oberparleiter | 25ee4cf | 2006-04-10 22:53:47 -0700 | [diff] [blame] | 1874 | if (cqr->status != DASD_CQR_QUEUED) |
| 1875 | return; |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 1876 | /* when device is stopped, return request to previous layer |
| 1877 | * exception: only the disconnect or unresumed bits are set and the |
| 1878 | * cqr is a path verification request |
| 1879 | */ |
| 1880 | if (device->stopped && |
| 1881 | !(!(device->stopped & ~(DASD_STOPPED_DC_WAIT | DASD_UNRESUMED_PM)) |
| 1882 | && test_bit(DASD_CQR_VERIFY_PATH, &cqr->flags))) { |
| 1883 | cqr->intrc = -EAGAIN; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1884 | cqr->status = DASD_CQR_CLEARED; |
| 1885 | dasd_schedule_device_bh(device); |
Peter Oberparleiter | 25ee4cf | 2006-04-10 22:53:47 -0700 | [diff] [blame] | 1886 | return; |
Horst Hummel | 1c01b8a | 2006-01-06 00:19:15 -0800 | [diff] [blame] | 1887 | } |
Peter Oberparleiter | 25ee4cf | 2006-04-10 22:53:47 -0700 | [diff] [blame] | 1888 | |
| 1889 | rc = device->discipline->start_IO(cqr); |
| 1890 | if (rc == 0) |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1891 | dasd_device_set_timer(device, cqr->expires); |
Peter Oberparleiter | 25ee4cf | 2006-04-10 22:53:47 -0700 | [diff] [blame] | 1892 | else if (rc == -EACCES) { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1893 | dasd_schedule_device_bh(device); |
Peter Oberparleiter | 25ee4cf | 2006-04-10 22:53:47 -0700 | [diff] [blame] | 1894 | } else |
| 1895 | /* Hmpf, try again in 1/2 sec */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1896 | dasd_device_set_timer(device, 50); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1897 | } |
| 1898 | |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 1899 | static void __dasd_device_check_path_events(struct dasd_device *device) |
| 1900 | { |
| 1901 | int rc; |
| 1902 | |
| 1903 | if (device->path_data.tbvpm) { |
| 1904 | if (device->stopped & ~(DASD_STOPPED_DC_WAIT | |
| 1905 | DASD_UNRESUMED_PM)) |
| 1906 | return; |
| 1907 | rc = device->discipline->verify_path( |
| 1908 | device, device->path_data.tbvpm); |
| 1909 | if (rc) |
| 1910 | dasd_device_set_timer(device, 50); |
| 1911 | else |
| 1912 | device->path_data.tbvpm = 0; |
| 1913 | } |
| 1914 | }; |
| 1915 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1916 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1917 | * Go through all request on the dasd_device request queue, |
| 1918 | * terminate them on the cdev if necessary, and return them to the |
| 1919 | * submitting layer via callback. |
| 1920 | * Note: |
| 1921 | * Make sure that all 'submitting layers' still exist when |
| 1922 | * this function is called!. In other words, when 'device' is a base |
| 1923 | * device then all block layer requests must have been removed before |
| 1924 | * via dasd_flush_block_queue. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1925 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1926 | int dasd_flush_device_queue(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1927 | { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1928 | struct dasd_ccw_req *cqr, *n; |
| 1929 | int rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1930 | struct list_head flush_queue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1931 | |
| 1932 | INIT_LIST_HEAD(&flush_queue); |
| 1933 | spin_lock_irq(get_ccwdev_lock(device->cdev)); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1934 | rc = 0; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1935 | list_for_each_entry_safe(cqr, n, &device->ccw_queue, devlist) { |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1936 | /* Check status and move request to flush_queue */ |
| 1937 | switch (cqr->status) { |
| 1938 | case DASD_CQR_IN_IO: |
| 1939 | rc = device->discipline->term_IO(cqr); |
| 1940 | if (rc) { |
| 1941 | /* unable to terminate requeust */ |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 1942 | dev_err(&device->cdev->dev, |
| 1943 | "Flushing the DASD request queue " |
| 1944 | "failed for request %p\n", cqr); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1945 | /* stop flush processing */ |
| 1946 | goto finished; |
| 1947 | } |
| 1948 | break; |
| 1949 | case DASD_CQR_QUEUED: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1950 | cqr->stopclk = get_clock(); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1951 | cqr->status = DASD_CQR_CLEARED; |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1952 | break; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1953 | default: /* no need to modify the others */ |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1954 | break; |
| 1955 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1956 | list_move_tail(&cqr->devlist, &flush_queue); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1957 | } |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1958 | finished: |
| 1959 | spin_unlock_irq(get_ccwdev_lock(device->cdev)); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1960 | /* |
| 1961 | * After this point all requests must be in state CLEAR_PENDING, |
| 1962 | * CLEARED, SUCCESS or ERROR. Now wait for CLEAR_PENDING to become |
| 1963 | * one of the others. |
| 1964 | */ |
| 1965 | list_for_each_entry_safe(cqr, n, &flush_queue, devlist) |
| 1966 | wait_event(dasd_flush_wq, |
| 1967 | (cqr->status != DASD_CQR_CLEAR_PENDING)); |
| 1968 | /* |
| 1969 | * Now set each request back to TERMINATED, DONE or NEED_ERP |
| 1970 | * and call the callback function of flushed requests |
| 1971 | */ |
| 1972 | __dasd_device_process_final_queue(device, &flush_queue); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 1973 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1974 | } |
| 1975 | |
| 1976 | /* |
| 1977 | * Acquire the device lock and process queues for the device. |
| 1978 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1979 | static void dasd_device_tasklet(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1980 | { |
| 1981 | struct list_head final_queue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1982 | |
| 1983 | atomic_set (&device->tasklet_scheduled, 0); |
| 1984 | INIT_LIST_HEAD(&final_queue); |
| 1985 | spin_lock_irq(get_ccwdev_lock(device->cdev)); |
| 1986 | /* Check expire time of first request on the ccw queue. */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1987 | __dasd_device_check_expire(device); |
| 1988 | /* find final requests on ccw queue */ |
| 1989 | __dasd_device_process_ccw_queue(device, &final_queue); |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 1990 | __dasd_device_check_path_events(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1991 | spin_unlock_irq(get_ccwdev_lock(device->cdev)); |
| 1992 | /* Now call the callback function of requests with final status */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 1993 | __dasd_device_process_final_queue(device, &final_queue); |
| 1994 | spin_lock_irq(get_ccwdev_lock(device->cdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1995 | /* 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] | 1996 | __dasd_device_start_head(device); |
| 1997 | spin_unlock_irq(get_ccwdev_lock(device->cdev)); |
Stefan Haberland | 4679e89 | 2012-06-19 17:30:12 +0200 | [diff] [blame^] | 1998 | if (waitqueue_active(&shutdown_waitq)) |
| 1999 | wake_up(&shutdown_waitq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2000 | dasd_put_device(device); |
| 2001 | } |
| 2002 | |
| 2003 | /* |
| 2004 | * Schedules a call to dasd_tasklet over the device tasklet. |
| 2005 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2006 | void dasd_schedule_device_bh(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2007 | { |
| 2008 | /* Protect against rescheduling. */ |
Martin Schwidefsky | 973bd99 | 2006-01-06 00:19:07 -0800 | [diff] [blame] | 2009 | if (atomic_cmpxchg (&device->tasklet_scheduled, 0, 1) != 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2010 | return; |
| 2011 | dasd_get_device(device); |
| 2012 | tasklet_hi_schedule(&device->tasklet); |
| 2013 | } |
| 2014 | |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2015 | void dasd_device_set_stop_bits(struct dasd_device *device, int bits) |
| 2016 | { |
| 2017 | device->stopped |= bits; |
| 2018 | } |
| 2019 | EXPORT_SYMBOL_GPL(dasd_device_set_stop_bits); |
| 2020 | |
| 2021 | void dasd_device_remove_stop_bits(struct dasd_device *device, int bits) |
| 2022 | { |
| 2023 | device->stopped &= ~bits; |
| 2024 | if (!device->stopped) |
| 2025 | wake_up(&generic_waitq); |
| 2026 | } |
| 2027 | EXPORT_SYMBOL_GPL(dasd_device_remove_stop_bits); |
| 2028 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2029 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2030 | * Queue a request to the head of the device ccw_queue. |
| 2031 | * Start the I/O if possible. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2032 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2033 | void dasd_add_request_head(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2034 | { |
| 2035 | struct dasd_device *device; |
| 2036 | unsigned long flags; |
| 2037 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2038 | device = cqr->startdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2039 | spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2040 | cqr->status = DASD_CQR_QUEUED; |
| 2041 | list_add(&cqr->devlist, &device->ccw_queue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2042 | /* let the bh start the request to keep them in order */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2043 | dasd_schedule_device_bh(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2044 | spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); |
| 2045 | } |
| 2046 | |
| 2047 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2048 | * Queue a request to the tail of the device ccw_queue. |
| 2049 | * Start the I/O if possible. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2050 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2051 | void dasd_add_request_tail(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2052 | { |
| 2053 | struct dasd_device *device; |
| 2054 | unsigned long flags; |
| 2055 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2056 | device = cqr->startdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2057 | spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2058 | cqr->status = DASD_CQR_QUEUED; |
| 2059 | list_add_tail(&cqr->devlist, &device->ccw_queue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2060 | /* let the bh start the request to keep them in order */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2061 | dasd_schedule_device_bh(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2062 | spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); |
| 2063 | } |
| 2064 | |
| 2065 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2066 | * Wakeup helper for the 'sleep_on' functions. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2067 | */ |
Stefan Haberland | 5915a87 | 2011-10-30 15:16:57 +0100 | [diff] [blame] | 2068 | void dasd_wakeup_cb(struct dasd_ccw_req *cqr, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2069 | { |
Stefan Weinhuber | 1c1e093 | 2010-05-12 09:32:11 +0200 | [diff] [blame] | 2070 | spin_lock_irq(get_ccwdev_lock(cqr->startdev->cdev)); |
| 2071 | cqr->callback_data = DASD_SLEEPON_END_TAG; |
| 2072 | spin_unlock_irq(get_ccwdev_lock(cqr->startdev->cdev)); |
| 2073 | wake_up(&generic_waitq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2074 | } |
Stefan Haberland | 5915a87 | 2011-10-30 15:16:57 +0100 | [diff] [blame] | 2075 | EXPORT_SYMBOL_GPL(dasd_wakeup_cb); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2076 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2077 | static inline int _wait_for_wakeup(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2078 | { |
| 2079 | struct dasd_device *device; |
| 2080 | int rc; |
| 2081 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2082 | device = cqr->startdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2083 | spin_lock_irq(get_ccwdev_lock(device->cdev)); |
Stefan Weinhuber | 1c1e093 | 2010-05-12 09:32:11 +0200 | [diff] [blame] | 2084 | rc = (cqr->callback_data == DASD_SLEEPON_END_TAG); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2085 | spin_unlock_irq(get_ccwdev_lock(device->cdev)); |
| 2086 | return rc; |
| 2087 | } |
| 2088 | |
| 2089 | /* |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2090 | * checks if error recovery is necessary, returns 1 if yes, 0 otherwise. |
| 2091 | */ |
| 2092 | static int __dasd_sleep_on_erp(struct dasd_ccw_req *cqr) |
| 2093 | { |
| 2094 | struct dasd_device *device; |
| 2095 | dasd_erp_fn_t erp_fn; |
| 2096 | |
| 2097 | if (cqr->status == DASD_CQR_FILLED) |
| 2098 | return 0; |
| 2099 | device = cqr->startdev; |
| 2100 | if (test_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags)) { |
| 2101 | if (cqr->status == DASD_CQR_TERMINATED) { |
| 2102 | device->discipline->handle_terminated_request(cqr); |
| 2103 | return 1; |
| 2104 | } |
| 2105 | if (cqr->status == DASD_CQR_NEED_ERP) { |
| 2106 | erp_fn = device->discipline->erp_action(cqr); |
| 2107 | erp_fn(cqr); |
| 2108 | return 1; |
| 2109 | } |
| 2110 | if (cqr->status == DASD_CQR_FAILED) |
| 2111 | dasd_log_sense(cqr, &cqr->irb); |
| 2112 | if (cqr->refers) { |
| 2113 | __dasd_process_erp(device, cqr); |
| 2114 | return 1; |
| 2115 | } |
| 2116 | } |
| 2117 | return 0; |
| 2118 | } |
| 2119 | |
| 2120 | static int __dasd_sleep_on_loop_condition(struct dasd_ccw_req *cqr) |
| 2121 | { |
| 2122 | if (test_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags)) { |
| 2123 | if (cqr->refers) /* erp is not done yet */ |
| 2124 | return 1; |
| 2125 | return ((cqr->status != DASD_CQR_DONE) && |
| 2126 | (cqr->status != DASD_CQR_FAILED)); |
| 2127 | } else |
| 2128 | return (cqr->status == DASD_CQR_FILLED); |
| 2129 | } |
| 2130 | |
| 2131 | static int _dasd_sleep_on(struct dasd_ccw_req *maincqr, int interruptible) |
| 2132 | { |
| 2133 | struct dasd_device *device; |
| 2134 | int rc; |
| 2135 | struct list_head ccw_queue; |
| 2136 | struct dasd_ccw_req *cqr; |
| 2137 | |
| 2138 | INIT_LIST_HEAD(&ccw_queue); |
| 2139 | maincqr->status = DASD_CQR_FILLED; |
| 2140 | device = maincqr->startdev; |
| 2141 | list_add(&maincqr->blocklist, &ccw_queue); |
| 2142 | for (cqr = maincqr; __dasd_sleep_on_loop_condition(cqr); |
| 2143 | cqr = list_first_entry(&ccw_queue, |
| 2144 | struct dasd_ccw_req, blocklist)) { |
| 2145 | |
| 2146 | if (__dasd_sleep_on_erp(cqr)) |
| 2147 | continue; |
| 2148 | if (cqr->status != DASD_CQR_FILLED) /* could be failed */ |
| 2149 | continue; |
Stefan Weinhuber | 5a27e60 | 2011-01-05 12:48:04 +0100 | [diff] [blame] | 2150 | if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags) && |
| 2151 | !test_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags)) { |
| 2152 | cqr->status = DASD_CQR_FAILED; |
| 2153 | cqr->intrc = -EPERM; |
| 2154 | continue; |
| 2155 | } |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2156 | /* Non-temporary stop condition will trigger fail fast */ |
| 2157 | if (device->stopped & ~DASD_STOPPED_PENDING && |
| 2158 | test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) && |
| 2159 | (!dasd_eer_enabled(device))) { |
| 2160 | cqr->status = DASD_CQR_FAILED; |
| 2161 | continue; |
| 2162 | } |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2163 | /* Don't try to start requests if device is stopped */ |
| 2164 | if (interruptible) { |
| 2165 | rc = wait_event_interruptible( |
| 2166 | generic_waitq, !(device->stopped)); |
| 2167 | if (rc == -ERESTARTSYS) { |
| 2168 | cqr->status = DASD_CQR_FAILED; |
| 2169 | maincqr->intrc = rc; |
| 2170 | continue; |
| 2171 | } |
| 2172 | } else |
| 2173 | wait_event(generic_waitq, !(device->stopped)); |
| 2174 | |
Stefan Haberland | 5915a87 | 2011-10-30 15:16:57 +0100 | [diff] [blame] | 2175 | if (!cqr->callback) |
| 2176 | cqr->callback = dasd_wakeup_cb; |
| 2177 | |
Stefan Weinhuber | 1c1e093 | 2010-05-12 09:32:11 +0200 | [diff] [blame] | 2178 | cqr->callback_data = DASD_SLEEPON_START_TAG; |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2179 | dasd_add_request_tail(cqr); |
| 2180 | if (interruptible) { |
| 2181 | rc = wait_event_interruptible( |
| 2182 | generic_waitq, _wait_for_wakeup(cqr)); |
| 2183 | if (rc == -ERESTARTSYS) { |
| 2184 | dasd_cancel_req(cqr); |
| 2185 | /* wait (non-interruptible) for final status */ |
| 2186 | wait_event(generic_waitq, |
| 2187 | _wait_for_wakeup(cqr)); |
| 2188 | cqr->status = DASD_CQR_FAILED; |
| 2189 | maincqr->intrc = rc; |
| 2190 | continue; |
| 2191 | } |
| 2192 | } else |
| 2193 | wait_event(generic_waitq, _wait_for_wakeup(cqr)); |
| 2194 | } |
| 2195 | |
| 2196 | maincqr->endclk = get_clock(); |
| 2197 | if ((maincqr->status != DASD_CQR_DONE) && |
| 2198 | (maincqr->intrc != -ERESTARTSYS)) |
| 2199 | dasd_log_sense(maincqr, &maincqr->irb); |
| 2200 | if (maincqr->status == DASD_CQR_DONE) |
| 2201 | rc = 0; |
| 2202 | else if (maincqr->intrc) |
| 2203 | rc = maincqr->intrc; |
| 2204 | else |
| 2205 | rc = -EIO; |
| 2206 | return rc; |
| 2207 | } |
| 2208 | |
| 2209 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2210 | * Queue a request to the tail of the device ccw_queue and wait for |
| 2211 | * it's completion. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2212 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2213 | int dasd_sleep_on(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2214 | { |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2215 | return _dasd_sleep_on(cqr, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2216 | } |
| 2217 | |
| 2218 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2219 | * Queue a request to the tail of the device ccw_queue and wait |
| 2220 | * interruptible for it's completion. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2221 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2222 | int dasd_sleep_on_interruptible(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2223 | { |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2224 | return _dasd_sleep_on(cqr, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2225 | } |
| 2226 | |
| 2227 | /* |
| 2228 | * Whoa nelly now it gets really hairy. For some functions (e.g. steal lock |
| 2229 | * for eckd devices) the currently running request has to be terminated |
| 2230 | * and be put back to status queued, before the special request is added |
| 2231 | * to the head of the queue. Then the special request is waited on normally. |
| 2232 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2233 | static inline int _dasd_term_running_cqr(struct dasd_device *device) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2234 | { |
| 2235 | struct dasd_ccw_req *cqr; |
Stefan Haberland | aade6c0 | 2011-05-10 17:13:38 +0200 | [diff] [blame] | 2236 | int rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2237 | |
| 2238 | if (list_empty(&device->ccw_queue)) |
| 2239 | return 0; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2240 | cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); |
Stefan Haberland | aade6c0 | 2011-05-10 17:13:38 +0200 | [diff] [blame] | 2241 | rc = device->discipline->term_IO(cqr); |
| 2242 | if (!rc) |
| 2243 | /* |
| 2244 | * CQR terminated because a more important request is pending. |
| 2245 | * Undo decreasing of retry counter because this is |
| 2246 | * not an error case. |
| 2247 | */ |
| 2248 | cqr->retries++; |
| 2249 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2250 | } |
| 2251 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2252 | int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2253 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2254 | struct dasd_device *device; |
| 2255 | int rc; |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 2256 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2257 | device = cqr->startdev; |
Stefan Weinhuber | 5a27e60 | 2011-01-05 12:48:04 +0100 | [diff] [blame] | 2258 | if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags) && |
| 2259 | !test_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags)) { |
| 2260 | cqr->status = DASD_CQR_FAILED; |
| 2261 | cqr->intrc = -EPERM; |
| 2262 | return -EIO; |
| 2263 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2264 | spin_lock_irq(get_ccwdev_lock(device->cdev)); |
| 2265 | rc = _dasd_term_running_cqr(device); |
| 2266 | if (rc) { |
| 2267 | spin_unlock_irq(get_ccwdev_lock(device->cdev)); |
| 2268 | return rc; |
| 2269 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2270 | cqr->callback = dasd_wakeup_cb; |
Stefan Weinhuber | 1c1e093 | 2010-05-12 09:32:11 +0200 | [diff] [blame] | 2271 | cqr->callback_data = DASD_SLEEPON_START_TAG; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2272 | cqr->status = DASD_CQR_QUEUED; |
Stefan Haberland | 214b8ff | 2011-10-30 15:16:56 +0100 | [diff] [blame] | 2273 | /* |
| 2274 | * add new request as second |
| 2275 | * first the terminated cqr needs to be finished |
| 2276 | */ |
| 2277 | list_add(&cqr->devlist, device->ccw_queue.next); |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 2278 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2279 | /* let the bh start the request to keep them in order */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2280 | dasd_schedule_device_bh(device); |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 2281 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2282 | spin_unlock_irq(get_ccwdev_lock(device->cdev)); |
| 2283 | |
Stefan Haberland | c80ee72 | 2008-05-30 10:03:31 +0200 | [diff] [blame] | 2284 | wait_event(generic_waitq, _wait_for_wakeup(cqr)); |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 2285 | |
Stefan Weinhuber | 6cc7f16 | 2009-06-12 10:26:39 +0200 | [diff] [blame] | 2286 | if (cqr->status == DASD_CQR_DONE) |
| 2287 | rc = 0; |
| 2288 | else if (cqr->intrc) |
| 2289 | rc = cqr->intrc; |
| 2290 | else |
| 2291 | rc = -EIO; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2292 | return rc; |
| 2293 | } |
| 2294 | |
| 2295 | /* |
| 2296 | * Cancels a request that was started with dasd_sleep_on_req. |
| 2297 | * This is useful to timeout requests. The request will be |
| 2298 | * terminated if it is currently in i/o. |
| 2299 | * Returns 1 if the request has been terminated. |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2300 | * 0 if there was no need to terminate the request (not started yet) |
| 2301 | * negative error code if termination failed |
| 2302 | * Cancellation of a request is an asynchronous operation! The calling |
| 2303 | * function has to wait until the request is properly returned via callback. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2304 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2305 | int dasd_cancel_req(struct dasd_ccw_req *cqr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2306 | { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2307 | struct dasd_device *device = cqr->startdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2308 | unsigned long flags; |
| 2309 | int rc; |
| 2310 | |
| 2311 | rc = 0; |
| 2312 | spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); |
| 2313 | switch (cqr->status) { |
| 2314 | case DASD_CQR_QUEUED: |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2315 | /* request was not started - just set to cleared */ |
| 2316 | cqr->status = DASD_CQR_CLEARED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2317 | break; |
| 2318 | case DASD_CQR_IN_IO: |
| 2319 | /* request in IO - terminate IO and release again */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2320 | rc = device->discipline->term_IO(cqr); |
| 2321 | if (rc) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 2322 | dev_err(&device->cdev->dev, |
| 2323 | "Cancelling request %p failed with rc=%d\n", |
| 2324 | cqr, rc); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2325 | } else { |
| 2326 | cqr->stopclk = get_clock(); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2327 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2328 | break; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2329 | default: /* already finished or clear pending - do nothing */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2330 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2331 | } |
| 2332 | spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2333 | dasd_schedule_device_bh(device); |
| 2334 | return rc; |
| 2335 | } |
| 2336 | |
| 2337 | |
| 2338 | /* |
| 2339 | * SECTION: Operations of the dasd_block layer. |
| 2340 | */ |
| 2341 | |
| 2342 | /* |
| 2343 | * Timeout function for dasd_block. This is used when the block layer |
| 2344 | * is waiting for something that may not come reliably, (e.g. a state |
| 2345 | * change interrupt) |
| 2346 | */ |
| 2347 | static void dasd_block_timeout(unsigned long ptr) |
| 2348 | { |
| 2349 | unsigned long flags; |
| 2350 | struct dasd_block *block; |
| 2351 | |
| 2352 | block = (struct dasd_block *) ptr; |
| 2353 | spin_lock_irqsave(get_ccwdev_lock(block->base->cdev), flags); |
| 2354 | /* re-activate request queue */ |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2355 | dasd_device_remove_stop_bits(block->base, DASD_STOPPED_PENDING); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2356 | spin_unlock_irqrestore(get_ccwdev_lock(block->base->cdev), flags); |
| 2357 | dasd_schedule_block_bh(block); |
| 2358 | } |
| 2359 | |
| 2360 | /* |
| 2361 | * Setup timeout for a dasd_block in jiffies. |
| 2362 | */ |
| 2363 | void dasd_block_set_timer(struct dasd_block *block, int expires) |
| 2364 | { |
Stefan Weinhuber | 48cae88 | 2009-02-11 10:37:31 +0100 | [diff] [blame] | 2365 | if (expires == 0) |
| 2366 | del_timer(&block->timer); |
| 2367 | else |
| 2368 | mod_timer(&block->timer, jiffies + expires); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2369 | } |
| 2370 | |
| 2371 | /* |
| 2372 | * Clear timeout for a dasd_block. |
| 2373 | */ |
| 2374 | void dasd_block_clear_timer(struct dasd_block *block) |
| 2375 | { |
Stefan Weinhuber | 48cae88 | 2009-02-11 10:37:31 +0100 | [diff] [blame] | 2376 | del_timer(&block->timer); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2377 | } |
| 2378 | |
| 2379 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2380 | * Process finished error recovery ccw. |
| 2381 | */ |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2382 | static void __dasd_process_erp(struct dasd_device *device, |
| 2383 | struct dasd_ccw_req *cqr) |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2384 | { |
| 2385 | dasd_erp_fn_t erp_fn; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2386 | |
| 2387 | if (cqr->status == DASD_CQR_DONE) |
| 2388 | DBF_DEV_EVENT(DBF_NOTICE, device, "%s", "ERP successful"); |
| 2389 | else |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 2390 | dev_err(&device->cdev->dev, "ERP failed for the DASD\n"); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2391 | erp_fn = device->discipline->erp_postaction(cqr); |
| 2392 | erp_fn(cqr); |
| 2393 | } |
| 2394 | |
| 2395 | /* |
| 2396 | * Fetch requests from the block device queue. |
| 2397 | */ |
| 2398 | static void __dasd_process_request_queue(struct dasd_block *block) |
| 2399 | { |
| 2400 | struct request_queue *queue; |
| 2401 | struct request *req; |
| 2402 | struct dasd_ccw_req *cqr; |
| 2403 | struct dasd_device *basedev; |
| 2404 | unsigned long flags; |
| 2405 | queue = block->request_queue; |
| 2406 | basedev = block->base; |
| 2407 | /* No queue ? Then there is nothing to do. */ |
| 2408 | if (queue == NULL) |
| 2409 | return; |
| 2410 | |
| 2411 | /* |
| 2412 | * We requeue request from the block device queue to the ccw |
| 2413 | * queue only in two states. In state DASD_STATE_READY the |
| 2414 | * partition detection is done and we need to requeue requests |
| 2415 | * for that. State DASD_STATE_ONLINE is normal block device |
| 2416 | * operation. |
| 2417 | */ |
Stefan Weinhuber | 97f604b | 2009-09-11 10:28:28 +0200 | [diff] [blame] | 2418 | if (basedev->state < DASD_STATE_READY) { |
| 2419 | while ((req = blk_fetch_request(block->request_queue))) |
| 2420 | __blk_end_request_all(req, -EIO); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2421 | return; |
Stefan Weinhuber | 97f604b | 2009-09-11 10:28:28 +0200 | [diff] [blame] | 2422 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2423 | /* Now we try to fetch requests from the request queue */ |
Jens Axboe | 7eaceac | 2011-03-10 08:52:07 +0100 | [diff] [blame] | 2424 | while ((req = blk_peek_request(queue))) { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2425 | if (basedev->features & DASD_FEATURE_READONLY && |
| 2426 | rq_data_dir(req) == WRITE) { |
| 2427 | DBF_DEV_EVENT(DBF_ERR, basedev, |
| 2428 | "Rejecting write request %p", |
| 2429 | req); |
Tejun Heo | 9934c8c | 2009-05-08 11:54:16 +0900 | [diff] [blame] | 2430 | blk_start_request(req); |
Tejun Heo | 40cbbb7 | 2009-04-23 11:05:19 +0900 | [diff] [blame] | 2431 | __blk_end_request_all(req, -EIO); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2432 | continue; |
| 2433 | } |
| 2434 | cqr = basedev->discipline->build_cp(basedev, block, req); |
| 2435 | if (IS_ERR(cqr)) { |
| 2436 | if (PTR_ERR(cqr) == -EBUSY) |
| 2437 | break; /* normal end condition */ |
| 2438 | if (PTR_ERR(cqr) == -ENOMEM) |
| 2439 | break; /* terminate request queue loop */ |
| 2440 | if (PTR_ERR(cqr) == -EAGAIN) { |
| 2441 | /* |
| 2442 | * The current request cannot be build right |
| 2443 | * now, we have to try later. If this request |
| 2444 | * is the head-of-queue we stop the device |
| 2445 | * for 1/2 second. |
| 2446 | */ |
| 2447 | if (!list_empty(&block->ccw_queue)) |
| 2448 | break; |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2449 | spin_lock_irqsave( |
| 2450 | get_ccwdev_lock(basedev->cdev), flags); |
| 2451 | dasd_device_set_stop_bits(basedev, |
| 2452 | DASD_STOPPED_PENDING); |
| 2453 | spin_unlock_irqrestore( |
| 2454 | get_ccwdev_lock(basedev->cdev), flags); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2455 | dasd_block_set_timer(block, HZ/2); |
| 2456 | break; |
| 2457 | } |
| 2458 | DBF_DEV_EVENT(DBF_ERR, basedev, |
| 2459 | "CCW creation failed (rc=%ld) " |
| 2460 | "on request %p", |
| 2461 | PTR_ERR(cqr), req); |
Tejun Heo | 9934c8c | 2009-05-08 11:54:16 +0900 | [diff] [blame] | 2462 | blk_start_request(req); |
Tejun Heo | 40cbbb7 | 2009-04-23 11:05:19 +0900 | [diff] [blame] | 2463 | __blk_end_request_all(req, -EIO); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2464 | continue; |
| 2465 | } |
| 2466 | /* |
| 2467 | * Note: callback is set to dasd_return_cqr_cb in |
| 2468 | * __dasd_block_start_head to cover erp requests as well |
| 2469 | */ |
| 2470 | cqr->callback_data = (void *) req; |
| 2471 | cqr->status = DASD_CQR_FILLED; |
Tejun Heo | 9934c8c | 2009-05-08 11:54:16 +0900 | [diff] [blame] | 2472 | blk_start_request(req); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2473 | list_add_tail(&cqr->blocklist, &block->ccw_queue); |
| 2474 | dasd_profile_start(block, cqr, req); |
| 2475 | } |
| 2476 | } |
| 2477 | |
| 2478 | static void __dasd_cleanup_cqr(struct dasd_ccw_req *cqr) |
| 2479 | { |
| 2480 | struct request *req; |
| 2481 | int status; |
Kiyoshi Ueda | 4c4e214 | 2008-01-28 10:29:42 +0100 | [diff] [blame] | 2482 | int error = 0; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2483 | |
| 2484 | req = (struct request *) cqr->callback_data; |
| 2485 | dasd_profile_end(cqr->block, cqr, req); |
Stefan Weinhuber | fe6b8e7 | 2008-02-05 16:50:47 +0100 | [diff] [blame] | 2486 | status = cqr->block->base->discipline->free_cp(cqr, req); |
Kiyoshi Ueda | 4c4e214 | 2008-01-28 10:29:42 +0100 | [diff] [blame] | 2487 | if (status <= 0) |
| 2488 | error = status ? status : -EIO; |
Tejun Heo | 40cbbb7 | 2009-04-23 11:05:19 +0900 | [diff] [blame] | 2489 | __blk_end_request_all(req, error); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2490 | } |
| 2491 | |
| 2492 | /* |
| 2493 | * Process ccw request queue. |
| 2494 | */ |
| 2495 | static void __dasd_process_block_ccw_queue(struct dasd_block *block, |
| 2496 | struct list_head *final_queue) |
| 2497 | { |
| 2498 | struct list_head *l, *n; |
| 2499 | struct dasd_ccw_req *cqr; |
| 2500 | dasd_erp_fn_t erp_fn; |
| 2501 | unsigned long flags; |
| 2502 | struct dasd_device *base = block->base; |
| 2503 | |
| 2504 | restart: |
| 2505 | /* Process request with final status. */ |
| 2506 | list_for_each_safe(l, n, &block->ccw_queue) { |
| 2507 | cqr = list_entry(l, struct dasd_ccw_req, blocklist); |
| 2508 | if (cqr->status != DASD_CQR_DONE && |
| 2509 | cqr->status != DASD_CQR_FAILED && |
| 2510 | cqr->status != DASD_CQR_NEED_ERP && |
| 2511 | cqr->status != DASD_CQR_TERMINATED) |
| 2512 | continue; |
| 2513 | |
| 2514 | if (cqr->status == DASD_CQR_TERMINATED) { |
| 2515 | base->discipline->handle_terminated_request(cqr); |
| 2516 | goto restart; |
| 2517 | } |
| 2518 | |
| 2519 | /* Process requests that may be recovered */ |
| 2520 | if (cqr->status == DASD_CQR_NEED_ERP) { |
Stefan Haberland | 6c5f57c | 2008-02-05 16:50:46 +0100 | [diff] [blame] | 2521 | erp_fn = base->discipline->erp_action(cqr); |
Stefan Haberland | 6a5176c | 2010-04-22 17:17:02 +0200 | [diff] [blame] | 2522 | if (IS_ERR(erp_fn(cqr))) |
| 2523 | continue; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2524 | goto restart; |
| 2525 | } |
| 2526 | |
Stefan Haberland | a9cffb2 | 2008-11-14 18:18:08 +0100 | [diff] [blame] | 2527 | /* log sense for fatal error */ |
| 2528 | if (cqr->status == DASD_CQR_FAILED) { |
| 2529 | dasd_log_sense(cqr, &cqr->irb); |
| 2530 | } |
| 2531 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2532 | /* First of all call extended error reporting. */ |
| 2533 | if (dasd_eer_enabled(base) && |
| 2534 | cqr->status == DASD_CQR_FAILED) { |
| 2535 | dasd_eer_write(base, cqr, DASD_EER_FATALERROR); |
| 2536 | |
| 2537 | /* restart request */ |
| 2538 | cqr->status = DASD_CQR_FILLED; |
| 2539 | cqr->retries = 255; |
| 2540 | spin_lock_irqsave(get_ccwdev_lock(base->cdev), flags); |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2541 | dasd_device_set_stop_bits(base, DASD_STOPPED_QUIESCE); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2542 | spin_unlock_irqrestore(get_ccwdev_lock(base->cdev), |
| 2543 | flags); |
| 2544 | goto restart; |
| 2545 | } |
| 2546 | |
| 2547 | /* Process finished ERP request. */ |
| 2548 | if (cqr->refers) { |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2549 | __dasd_process_erp(base, cqr); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2550 | goto restart; |
| 2551 | } |
| 2552 | |
| 2553 | /* Rechain finished requests to final queue */ |
| 2554 | cqr->endclk = get_clock(); |
| 2555 | list_move_tail(&cqr->blocklist, final_queue); |
| 2556 | } |
| 2557 | } |
| 2558 | |
| 2559 | static void dasd_return_cqr_cb(struct dasd_ccw_req *cqr, void *data) |
| 2560 | { |
| 2561 | dasd_schedule_block_bh(cqr->block); |
| 2562 | } |
| 2563 | |
| 2564 | static void __dasd_block_start_head(struct dasd_block *block) |
| 2565 | { |
| 2566 | struct dasd_ccw_req *cqr; |
| 2567 | |
| 2568 | if (list_empty(&block->ccw_queue)) |
| 2569 | return; |
| 2570 | /* We allways begin with the first requests on the queue, as some |
| 2571 | * of previously started requests have to be enqueued on a |
| 2572 | * dasd_device again for error recovery. |
| 2573 | */ |
| 2574 | list_for_each_entry(cqr, &block->ccw_queue, blocklist) { |
| 2575 | if (cqr->status != DASD_CQR_FILLED) |
| 2576 | continue; |
Stefan Weinhuber | 5a27e60 | 2011-01-05 12:48:04 +0100 | [diff] [blame] | 2577 | if (test_bit(DASD_FLAG_LOCK_STOLEN, &block->base->flags) && |
| 2578 | !test_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags)) { |
| 2579 | cqr->status = DASD_CQR_FAILED; |
| 2580 | cqr->intrc = -EPERM; |
| 2581 | dasd_schedule_block_bh(block); |
| 2582 | continue; |
| 2583 | } |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2584 | /* Non-temporary stop condition will trigger fail fast */ |
| 2585 | if (block->base->stopped & ~DASD_STOPPED_PENDING && |
| 2586 | test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) && |
| 2587 | (!dasd_eer_enabled(block->base))) { |
| 2588 | cqr->status = DASD_CQR_FAILED; |
| 2589 | dasd_schedule_block_bh(block); |
| 2590 | continue; |
| 2591 | } |
| 2592 | /* Don't try to start requests if device is stopped */ |
| 2593 | if (block->base->stopped) |
| 2594 | return; |
| 2595 | |
| 2596 | /* just a fail safe check, should not happen */ |
| 2597 | if (!cqr->startdev) |
| 2598 | cqr->startdev = block->base; |
| 2599 | |
| 2600 | /* make sure that the requests we submit find their way back */ |
| 2601 | cqr->callback = dasd_return_cqr_cb; |
| 2602 | |
| 2603 | dasd_add_request_tail(cqr); |
| 2604 | } |
| 2605 | } |
| 2606 | |
| 2607 | /* |
| 2608 | * Central dasd_block layer routine. Takes requests from the generic |
| 2609 | * block layer request queue, creates ccw requests, enqueues them on |
| 2610 | * a dasd_device and processes ccw requests that have been returned. |
| 2611 | */ |
| 2612 | static void dasd_block_tasklet(struct dasd_block *block) |
| 2613 | { |
| 2614 | struct list_head final_queue; |
| 2615 | struct list_head *l, *n; |
| 2616 | struct dasd_ccw_req *cqr; |
| 2617 | |
| 2618 | atomic_set(&block->tasklet_scheduled, 0); |
| 2619 | INIT_LIST_HEAD(&final_queue); |
| 2620 | spin_lock(&block->queue_lock); |
| 2621 | /* Finish off requests on ccw queue */ |
| 2622 | __dasd_process_block_ccw_queue(block, &final_queue); |
| 2623 | spin_unlock(&block->queue_lock); |
| 2624 | /* Now call the callback function of requests with final status */ |
| 2625 | spin_lock_irq(&block->request_queue_lock); |
| 2626 | list_for_each_safe(l, n, &final_queue) { |
| 2627 | cqr = list_entry(l, struct dasd_ccw_req, blocklist); |
| 2628 | list_del_init(&cqr->blocklist); |
| 2629 | __dasd_cleanup_cqr(cqr); |
| 2630 | } |
| 2631 | spin_lock(&block->queue_lock); |
| 2632 | /* Get new request from the block device request queue */ |
| 2633 | __dasd_process_request_queue(block); |
| 2634 | /* Now check if the head of the ccw queue needs to be started. */ |
| 2635 | __dasd_block_start_head(block); |
| 2636 | spin_unlock(&block->queue_lock); |
| 2637 | spin_unlock_irq(&block->request_queue_lock); |
Stefan Haberland | 4679e89 | 2012-06-19 17:30:12 +0200 | [diff] [blame^] | 2638 | if (waitqueue_active(&shutdown_waitq)) |
| 2639 | wake_up(&shutdown_waitq); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2640 | dasd_put_device(block->base); |
| 2641 | } |
| 2642 | |
| 2643 | static void _dasd_wake_block_flush_cb(struct dasd_ccw_req *cqr, void *data) |
| 2644 | { |
| 2645 | wake_up(&dasd_flush_wq); |
| 2646 | } |
| 2647 | |
| 2648 | /* |
| 2649 | * Go through all request on the dasd_block request queue, cancel them |
| 2650 | * on the respective dasd_device, and return them to the generic |
| 2651 | * block layer. |
| 2652 | */ |
| 2653 | static int dasd_flush_block_queue(struct dasd_block *block) |
| 2654 | { |
| 2655 | struct dasd_ccw_req *cqr, *n; |
| 2656 | int rc, i; |
| 2657 | struct list_head flush_queue; |
| 2658 | |
| 2659 | INIT_LIST_HEAD(&flush_queue); |
| 2660 | spin_lock_bh(&block->queue_lock); |
| 2661 | rc = 0; |
| 2662 | restart: |
| 2663 | list_for_each_entry_safe(cqr, n, &block->ccw_queue, blocklist) { |
| 2664 | /* if this request currently owned by a dasd_device cancel it */ |
| 2665 | if (cqr->status >= DASD_CQR_QUEUED) |
| 2666 | rc = dasd_cancel_req(cqr); |
| 2667 | if (rc < 0) |
| 2668 | break; |
| 2669 | /* Rechain request (including erp chain) so it won't be |
| 2670 | * touched by the dasd_block_tasklet anymore. |
| 2671 | * Replace the callback so we notice when the request |
| 2672 | * is returned from the dasd_device layer. |
| 2673 | */ |
| 2674 | cqr->callback = _dasd_wake_block_flush_cb; |
| 2675 | for (i = 0; cqr != NULL; cqr = cqr->refers, i++) |
| 2676 | list_move_tail(&cqr->blocklist, &flush_queue); |
| 2677 | if (i > 1) |
| 2678 | /* moved more than one request - need to restart */ |
| 2679 | goto restart; |
| 2680 | } |
| 2681 | spin_unlock_bh(&block->queue_lock); |
| 2682 | /* Now call the callback function of flushed requests */ |
| 2683 | restart_cb: |
| 2684 | list_for_each_entry_safe(cqr, n, &flush_queue, blocklist) { |
| 2685 | wait_event(dasd_flush_wq, (cqr->status < DASD_CQR_QUEUED)); |
| 2686 | /* Process finished ERP request. */ |
| 2687 | if (cqr->refers) { |
Stefan Haberland | 0cd4bd4 | 2008-12-25 13:38:54 +0100 | [diff] [blame] | 2688 | spin_lock_bh(&block->queue_lock); |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 2689 | __dasd_process_erp(block->base, cqr); |
Stefan Haberland | 0cd4bd4 | 2008-12-25 13:38:54 +0100 | [diff] [blame] | 2690 | spin_unlock_bh(&block->queue_lock); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2691 | /* restart list_for_xx loop since dasd_process_erp |
| 2692 | * might remove multiple elements */ |
| 2693 | goto restart_cb; |
| 2694 | } |
| 2695 | /* call the callback function */ |
Stefan Haberland | 0cd4bd4 | 2008-12-25 13:38:54 +0100 | [diff] [blame] | 2696 | spin_lock_irq(&block->request_queue_lock); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2697 | cqr->endclk = get_clock(); |
| 2698 | list_del_init(&cqr->blocklist); |
| 2699 | __dasd_cleanup_cqr(cqr); |
Stefan Haberland | 0cd4bd4 | 2008-12-25 13:38:54 +0100 | [diff] [blame] | 2700 | spin_unlock_irq(&block->request_queue_lock); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2701 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2702 | return rc; |
| 2703 | } |
| 2704 | |
| 2705 | /* |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2706 | * Schedules a call to dasd_tasklet over the device tasklet. |
| 2707 | */ |
| 2708 | void dasd_schedule_block_bh(struct dasd_block *block) |
| 2709 | { |
| 2710 | /* Protect against rescheduling. */ |
| 2711 | if (atomic_cmpxchg(&block->tasklet_scheduled, 0, 1) != 0) |
| 2712 | return; |
| 2713 | /* life cycle of block is bound to it's base device */ |
| 2714 | dasd_get_device(block->base); |
| 2715 | tasklet_hi_schedule(&block->tasklet); |
| 2716 | } |
| 2717 | |
| 2718 | |
| 2719 | /* |
| 2720 | * SECTION: external block device operations |
| 2721 | * (request queue handling, open, release, etc.) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2722 | */ |
| 2723 | |
| 2724 | /* |
| 2725 | * Dasd request queue function. Called from ll_rw_blk.c |
| 2726 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2727 | static void do_dasd_request(struct request_queue *queue) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2728 | { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2729 | struct dasd_block *block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2730 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2731 | block = queue->queuedata; |
| 2732 | spin_lock(&block->queue_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2733 | /* Get new request from the block device request queue */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2734 | __dasd_process_request_queue(block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2735 | /* 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] | 2736 | __dasd_block_start_head(block); |
| 2737 | spin_unlock(&block->queue_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2738 | } |
| 2739 | |
| 2740 | /* |
| 2741 | * Allocate and initialize request queue and default I/O scheduler. |
| 2742 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2743 | static int dasd_alloc_queue(struct dasd_block *block) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2744 | { |
| 2745 | int rc; |
| 2746 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2747 | block->request_queue = blk_init_queue(do_dasd_request, |
| 2748 | &block->request_queue_lock); |
| 2749 | if (block->request_queue == NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2750 | return -ENOMEM; |
| 2751 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2752 | block->request_queue->queuedata = block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2753 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2754 | elevator_exit(block->request_queue->elevator); |
Josef 'Jeff' Sipek | 08a8a0c | 2008-04-17 07:45:56 +0200 | [diff] [blame] | 2755 | block->request_queue->elevator = NULL; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2756 | rc = elevator_init(block->request_queue, "deadline"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2757 | if (rc) { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2758 | blk_cleanup_queue(block->request_queue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2759 | return rc; |
| 2760 | } |
| 2761 | return 0; |
| 2762 | } |
| 2763 | |
| 2764 | /* |
| 2765 | * Allocate and initialize request queue. |
| 2766 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2767 | static void dasd_setup_queue(struct dasd_block *block) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2768 | { |
| 2769 | int max; |
| 2770 | |
Stefan Haberland | e4dbb0f | 2011-01-05 12:48:06 +0100 | [diff] [blame] | 2771 | if (block->base->features & DASD_FEATURE_USERAW) { |
| 2772 | /* |
| 2773 | * the max_blocks value for raw_track access is 256 |
| 2774 | * it is higher than the native ECKD value because we |
| 2775 | * only need one ccw per track |
| 2776 | * so the max_hw_sectors are |
| 2777 | * 2048 x 512B = 1024kB = 16 tracks |
| 2778 | */ |
| 2779 | max = 2048; |
| 2780 | } else { |
| 2781 | max = block->base->discipline->max_blocks << block->s2b_shift; |
| 2782 | } |
| 2783 | blk_queue_logical_block_size(block->request_queue, |
| 2784 | block->bp_block); |
Martin K. Petersen | 086fa5f | 2010-02-26 00:20:38 -0500 | [diff] [blame] | 2785 | blk_queue_max_hw_sectors(block->request_queue, max); |
Martin K. Petersen | 8a78362 | 2010-02-26 00:20:39 -0500 | [diff] [blame] | 2786 | blk_queue_max_segments(block->request_queue, -1L); |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 2787 | /* with page sized segments we can translate each segement into |
| 2788 | * one idaw/tidaw |
| 2789 | */ |
| 2790 | blk_queue_max_segment_size(block->request_queue, PAGE_SIZE); |
| 2791 | blk_queue_segment_boundary(block->request_queue, PAGE_SIZE - 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2792 | } |
| 2793 | |
| 2794 | /* |
| 2795 | * Deactivate and free request queue. |
| 2796 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2797 | static void dasd_free_queue(struct dasd_block *block) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2798 | { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2799 | if (block->request_queue) { |
| 2800 | blk_cleanup_queue(block->request_queue); |
| 2801 | block->request_queue = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2802 | } |
| 2803 | } |
| 2804 | |
| 2805 | /* |
| 2806 | * Flush request on the request queue. |
| 2807 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2808 | static void dasd_flush_request_queue(struct dasd_block *block) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2809 | { |
| 2810 | struct request *req; |
| 2811 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2812 | if (!block->request_queue) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2813 | return; |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 2814 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2815 | spin_lock_irq(&block->request_queue_lock); |
Tejun Heo | 9934c8c | 2009-05-08 11:54:16 +0900 | [diff] [blame] | 2816 | while ((req = blk_fetch_request(block->request_queue))) |
Tejun Heo | 40cbbb7 | 2009-04-23 11:05:19 +0900 | [diff] [blame] | 2817 | __blk_end_request_all(req, -EIO); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2818 | spin_unlock_irq(&block->request_queue_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2819 | } |
| 2820 | |
Al Viro | 57a7c0b | 2008-03-02 10:36:08 -0500 | [diff] [blame] | 2821 | static int dasd_open(struct block_device *bdev, fmode_t mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2822 | { |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame] | 2823 | struct dasd_device *base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2824 | int rc; |
| 2825 | |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 2826 | base = dasd_device_from_gendisk(bdev->bd_disk); |
| 2827 | if (!base) |
Stefan Haberland | 9eb2512 | 2010-02-26 22:37:46 +0100 | [diff] [blame] | 2828 | return -ENODEV; |
| 2829 | |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 2830 | atomic_inc(&base->block->open_count); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2831 | if (test_bit(DASD_FLAG_OFFLINE, &base->flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2832 | rc = -ENODEV; |
| 2833 | goto unlock; |
| 2834 | } |
| 2835 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2836 | if (!try_module_get(base->discipline->owner)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2837 | rc = -EINVAL; |
| 2838 | goto unlock; |
| 2839 | } |
| 2840 | |
| 2841 | if (dasd_probeonly) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 2842 | dev_info(&base->cdev->dev, |
| 2843 | "Accessing the DASD failed because it is in " |
| 2844 | "probeonly mode\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2845 | rc = -EPERM; |
| 2846 | goto out; |
| 2847 | } |
| 2848 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2849 | if (base->state <= DASD_STATE_BASIC) { |
| 2850 | DBF_DEV_EVENT(DBF_ERR, base, " %s", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2851 | " Cannot open unrecognized device"); |
| 2852 | rc = -ENODEV; |
| 2853 | goto out; |
| 2854 | } |
| 2855 | |
Stefan Weinhuber | 33b62a3 | 2010-03-08 12:26:24 +0100 | [diff] [blame] | 2856 | if ((mode & FMODE_WRITE) && |
| 2857 | (test_bit(DASD_FLAG_DEVICE_RO, &base->flags) || |
| 2858 | (base->features & DASD_FEATURE_READONLY))) { |
| 2859 | rc = -EROFS; |
| 2860 | goto out; |
| 2861 | } |
| 2862 | |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 2863 | dasd_put_device(base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2864 | return 0; |
| 2865 | |
| 2866 | out: |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2867 | module_put(base->discipline->owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2868 | unlock: |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 2869 | atomic_dec(&base->block->open_count); |
| 2870 | dasd_put_device(base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2871 | return rc; |
| 2872 | } |
| 2873 | |
Al Viro | 57a7c0b | 2008-03-02 10:36:08 -0500 | [diff] [blame] | 2874 | static int dasd_release(struct gendisk *disk, fmode_t mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2875 | { |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 2876 | struct dasd_device *base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2877 | |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 2878 | base = dasd_device_from_gendisk(disk); |
| 2879 | if (!base) |
| 2880 | return -ENODEV; |
| 2881 | |
| 2882 | atomic_dec(&base->block->open_count); |
| 2883 | module_put(base->discipline->owner); |
| 2884 | dasd_put_device(base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2885 | return 0; |
| 2886 | } |
| 2887 | |
Christoph Hellwig | a885c8c | 2006-01-08 01:02:50 -0800 | [diff] [blame] | 2888 | /* |
| 2889 | * Return disk geometry. |
| 2890 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2891 | static int dasd_getgeo(struct block_device *bdev, struct hd_geometry *geo) |
Christoph Hellwig | a885c8c | 2006-01-08 01:02:50 -0800 | [diff] [blame] | 2892 | { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2893 | struct dasd_device *base; |
Christoph Hellwig | a885c8c | 2006-01-08 01:02:50 -0800 | [diff] [blame] | 2894 | |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 2895 | base = dasd_device_from_gendisk(bdev->bd_disk); |
| 2896 | if (!base) |
Christoph Hellwig | a885c8c | 2006-01-08 01:02:50 -0800 | [diff] [blame] | 2897 | return -ENODEV; |
| 2898 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2899 | if (!base->discipline || |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 2900 | !base->discipline->fill_geometry) { |
| 2901 | dasd_put_device(base); |
Christoph Hellwig | a885c8c | 2006-01-08 01:02:50 -0800 | [diff] [blame] | 2902 | return -EINVAL; |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 2903 | } |
| 2904 | base->discipline->fill_geometry(base->block, geo); |
| 2905 | geo->start = get_start_sect(bdev) >> base->block->s2b_shift; |
| 2906 | dasd_put_device(base); |
Christoph Hellwig | a885c8c | 2006-01-08 01:02:50 -0800 | [diff] [blame] | 2907 | return 0; |
| 2908 | } |
| 2909 | |
Alexey Dobriyan | 83d5cde | 2009-09-21 17:01:13 -0700 | [diff] [blame] | 2910 | const struct block_device_operations |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2911 | dasd_device_operations = { |
| 2912 | .owner = THIS_MODULE, |
Al Viro | 57a7c0b | 2008-03-02 10:36:08 -0500 | [diff] [blame] | 2913 | .open = dasd_open, |
| 2914 | .release = dasd_release, |
Heiko Carstens | 0000d03 | 2009-03-26 15:23:45 +0100 | [diff] [blame] | 2915 | .ioctl = dasd_ioctl, |
| 2916 | .compat_ioctl = dasd_ioctl, |
Christoph Hellwig | a885c8c | 2006-01-08 01:02:50 -0800 | [diff] [blame] | 2917 | .getgeo = dasd_getgeo, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2918 | }; |
| 2919 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2920 | /******************************************************************************* |
| 2921 | * end of block device operations |
| 2922 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2923 | |
| 2924 | static void |
| 2925 | dasd_exit(void) |
| 2926 | { |
| 2927 | #ifdef CONFIG_PROC_FS |
| 2928 | dasd_proc_exit(); |
| 2929 | #endif |
Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 2930 | dasd_eer_exit(); |
Horst Hummel | 6bb0e01 | 2005-07-27 11:45:03 -0700 | [diff] [blame] | 2931 | if (dasd_page_cache != NULL) { |
| 2932 | kmem_cache_destroy(dasd_page_cache); |
| 2933 | dasd_page_cache = NULL; |
| 2934 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2935 | dasd_gendisk_exit(); |
| 2936 | dasd_devmap_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2937 | if (dasd_debug_area != NULL) { |
| 2938 | debug_unregister(dasd_debug_area); |
| 2939 | dasd_debug_area = NULL; |
| 2940 | } |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 2941 | dasd_statistics_removeroot(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2942 | } |
| 2943 | |
| 2944 | /* |
| 2945 | * SECTION: common functions for ccw_driver use |
| 2946 | */ |
| 2947 | |
Stefan Weinhuber | 33b62a3 | 2010-03-08 12:26:24 +0100 | [diff] [blame] | 2948 | /* |
| 2949 | * Is the device read-only? |
| 2950 | * Note that this function does not report the setting of the |
| 2951 | * readonly device attribute, but how it is configured in z/VM. |
| 2952 | */ |
| 2953 | int dasd_device_is_ro(struct dasd_device *device) |
| 2954 | { |
| 2955 | struct ccw_dev_id dev_id; |
| 2956 | struct diag210 diag_data; |
| 2957 | int rc; |
| 2958 | |
| 2959 | if (!MACHINE_IS_VM) |
| 2960 | return 0; |
| 2961 | ccw_device_get_id(device->cdev, &dev_id); |
| 2962 | memset(&diag_data, 0, sizeof(diag_data)); |
| 2963 | diag_data.vrdcdvno = dev_id.devno; |
| 2964 | diag_data.vrdclen = sizeof(diag_data); |
| 2965 | rc = diag210(&diag_data); |
| 2966 | if (rc == 0 || rc == 2) { |
| 2967 | return diag_data.vrdcvfla & 0x80; |
| 2968 | } else { |
| 2969 | DBF_EVENT(DBF_WARNING, "diag210 failed for dev=%04x with rc=%d", |
| 2970 | dev_id.devno, rc); |
| 2971 | return 0; |
| 2972 | } |
| 2973 | } |
| 2974 | EXPORT_SYMBOL_GPL(dasd_device_is_ro); |
| 2975 | |
Cornelia Huck | f3445a1 | 2009-04-14 15:36:23 +0200 | [diff] [blame] | 2976 | static void dasd_generic_auto_online(void *data, async_cookie_t cookie) |
| 2977 | { |
| 2978 | struct ccw_device *cdev = data; |
| 2979 | int ret; |
| 2980 | |
| 2981 | ret = ccw_device_set_online(cdev); |
| 2982 | if (ret) |
| 2983 | pr_warning("%s: Setting the DASD online failed with rc=%d\n", |
| 2984 | dev_name(&cdev->dev), ret); |
Cornelia Huck | f3445a1 | 2009-04-14 15:36:23 +0200 | [diff] [blame] | 2985 | } |
| 2986 | |
Horst Hummel | 1c01b8a | 2006-01-06 00:19:15 -0800 | [diff] [blame] | 2987 | /* |
| 2988 | * Initial attempt at a probe function. this can be simplified once |
| 2989 | * the other detection code is gone. |
| 2990 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 2991 | int dasd_generic_probe(struct ccw_device *cdev, |
| 2992 | struct dasd_discipline *discipline) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2993 | { |
| 2994 | int ret; |
| 2995 | |
| 2996 | ret = dasd_add_sysfs_files(cdev); |
| 2997 | if (ret) { |
Stefan Haberland | b8ed5dd | 2009-12-07 12:51:52 +0100 | [diff] [blame] | 2998 | DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s", |
| 2999 | "dasd_generic_probe: could not add " |
| 3000 | "sysfs entries"); |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 3001 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3002 | } |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 3003 | cdev->handler = &dasd_int_handler; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3004 | |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 3005 | /* |
| 3006 | * Automatically online either all dasd devices (dasd_autodetect) |
| 3007 | * or all devices specified with dasd= parameters during |
| 3008 | * initial probe. |
| 3009 | */ |
| 3010 | if ((dasd_get_feature(cdev, DASD_FEATURE_INITIAL_ONLINE) > 0 ) || |
Kay Sievers | 2a0217d | 2008-10-10 21:33:09 +0200 | [diff] [blame] | 3011 | (dasd_autodetect && dasd_busid_known(dev_name(&cdev->dev)) != 0)) |
Cornelia Huck | f3445a1 | 2009-04-14 15:36:23 +0200 | [diff] [blame] | 3012 | async_schedule(dasd_generic_auto_online, cdev); |
Stefan Haberland | de3e0da | 2008-01-26 14:11:08 +0100 | [diff] [blame] | 3013 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3014 | } |
| 3015 | |
Horst Hummel | 1c01b8a | 2006-01-06 00:19:15 -0800 | [diff] [blame] | 3016 | /* |
| 3017 | * This will one day be called from a global not_oper handler. |
| 3018 | * It is also used by driver_unregister during module unload. |
| 3019 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3020 | void dasd_generic_remove(struct ccw_device *cdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3021 | { |
| 3022 | struct dasd_device *device; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3023 | struct dasd_block *block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3024 | |
Horst Hummel | 59afda7 | 2005-05-16 21:53:39 -0700 | [diff] [blame] | 3025 | cdev->handler = NULL; |
| 3026 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3027 | dasd_remove_sysfs_files(cdev); |
| 3028 | device = dasd_device_from_cdev(cdev); |
| 3029 | if (IS_ERR(device)) |
| 3030 | return; |
| 3031 | if (test_and_set_bit(DASD_FLAG_OFFLINE, &device->flags)) { |
| 3032 | /* Already doing offline processing */ |
| 3033 | dasd_put_device(device); |
| 3034 | return; |
| 3035 | } |
| 3036 | /* |
| 3037 | * This device is removed unconditionally. Set offline |
| 3038 | * flag to prevent dasd_open from opening it while it is |
| 3039 | * no quite down yet. |
| 3040 | */ |
| 3041 | dasd_set_target_state(device, DASD_STATE_NEW); |
| 3042 | /* dasd_delete_device destroys the device reference. */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3043 | block = device->block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3044 | dasd_delete_device(device); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3045 | /* |
| 3046 | * life cycle of block is bound to device, so delete it after |
| 3047 | * device was safely removed |
| 3048 | */ |
| 3049 | if (block) |
| 3050 | dasd_free_block(block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3051 | } |
| 3052 | |
Horst Hummel | 1c01b8a | 2006-01-06 00:19:15 -0800 | [diff] [blame] | 3053 | /* |
| 3054 | * 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] | 3055 | * 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] | 3056 | * or the user has started activation through sysfs. |
| 3057 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3058 | int dasd_generic_set_online(struct ccw_device *cdev, |
| 3059 | struct dasd_discipline *base_discipline) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3060 | { |
Peter Oberparleiter | aa88861 | 2006-02-20 18:28:13 -0800 | [diff] [blame] | 3061 | struct dasd_discipline *discipline; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3062 | struct dasd_device *device; |
Horst Hummel | c6eb7b7 | 2005-09-03 15:57:58 -0700 | [diff] [blame] | 3063 | int rc; |
Horst Hummel | f24acd4 | 2005-05-01 08:58:59 -0700 | [diff] [blame] | 3064 | |
Horst Hummel | 4054557 | 2006-06-29 15:08:18 +0200 | [diff] [blame] | 3065 | /* first online clears initial online feature flag */ |
| 3066 | dasd_set_feature(cdev, DASD_FEATURE_INITIAL_ONLINE, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3067 | device = dasd_create_device(cdev); |
| 3068 | if (IS_ERR(device)) |
| 3069 | return PTR_ERR(device); |
| 3070 | |
Peter Oberparleiter | aa88861 | 2006-02-20 18:28:13 -0800 | [diff] [blame] | 3071 | discipline = base_discipline; |
Horst Hummel | c6eb7b7 | 2005-09-03 15:57:58 -0700 | [diff] [blame] | 3072 | if (device->features & DASD_FEATURE_USEDIAG) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3073 | if (!dasd_diag_discipline_pointer) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 3074 | pr_warning("%s Setting the DASD online failed because " |
| 3075 | "of missing DIAG discipline\n", |
| 3076 | dev_name(&cdev->dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3077 | dasd_delete_device(device); |
| 3078 | return -ENODEV; |
| 3079 | } |
| 3080 | discipline = dasd_diag_discipline_pointer; |
| 3081 | } |
Peter Oberparleiter | aa88861 | 2006-02-20 18:28:13 -0800 | [diff] [blame] | 3082 | if (!try_module_get(base_discipline->owner)) { |
| 3083 | dasd_delete_device(device); |
| 3084 | return -EINVAL; |
| 3085 | } |
| 3086 | if (!try_module_get(discipline->owner)) { |
| 3087 | module_put(base_discipline->owner); |
| 3088 | dasd_delete_device(device); |
| 3089 | return -EINVAL; |
| 3090 | } |
| 3091 | device->base_discipline = base_discipline; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3092 | device->discipline = discipline; |
| 3093 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3094 | /* check_device will allocate block device if necessary */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3095 | rc = discipline->check_device(device); |
| 3096 | if (rc) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 3097 | pr_warning("%s Setting the DASD online with discipline %s " |
| 3098 | "failed with rc=%i\n", |
| 3099 | dev_name(&cdev->dev), discipline->name, rc); |
Peter Oberparleiter | aa88861 | 2006-02-20 18:28:13 -0800 | [diff] [blame] | 3100 | module_put(discipline->owner); |
| 3101 | module_put(base_discipline->owner); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3102 | dasd_delete_device(device); |
| 3103 | return rc; |
| 3104 | } |
| 3105 | |
| 3106 | dasd_set_target_state(device, DASD_STATE_ONLINE); |
| 3107 | if (device->state <= DASD_STATE_KNOWN) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 3108 | pr_warning("%s Setting the DASD online failed because of a " |
| 3109 | "missing discipline\n", dev_name(&cdev->dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3110 | rc = -ENODEV; |
| 3111 | dasd_set_target_state(device, DASD_STATE_NEW); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3112 | if (device->block) |
| 3113 | dasd_free_block(device->block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3114 | dasd_delete_device(device); |
| 3115 | } else |
| 3116 | pr_debug("dasd_generic device %s found\n", |
Kay Sievers | 2a0217d | 2008-10-10 21:33:09 +0200 | [diff] [blame] | 3117 | dev_name(&cdev->dev)); |
Stefan Haberland | 589c74d | 2010-02-26 22:37:47 +0100 | [diff] [blame] | 3118 | |
| 3119 | wait_event(dasd_init_waitq, _wait_for_device(device)); |
| 3120 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3121 | dasd_put_device(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3122 | return rc; |
| 3123 | } |
| 3124 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3125 | int dasd_generic_set_offline(struct ccw_device *cdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3126 | { |
| 3127 | struct dasd_device *device; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3128 | struct dasd_block *block; |
Horst Hummel | dafd87a | 2006-04-10 22:53:47 -0700 | [diff] [blame] | 3129 | int max_count, open_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3130 | |
| 3131 | device = dasd_device_from_cdev(cdev); |
| 3132 | if (IS_ERR(device)) |
| 3133 | return PTR_ERR(device); |
| 3134 | if (test_and_set_bit(DASD_FLAG_OFFLINE, &device->flags)) { |
| 3135 | /* Already doing offline processing */ |
| 3136 | dasd_put_device(device); |
| 3137 | return 0; |
| 3138 | } |
| 3139 | /* |
| 3140 | * We must make sure that this device is currently not in use. |
| 3141 | * The open_count is increased for every opener, that includes |
| 3142 | * the blkdev_get in dasd_scan_partitions. We are only interested |
| 3143 | * in the other openers. |
| 3144 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3145 | if (device->block) { |
Heiko Carstens | a806170 | 2008-04-17 07:46:26 +0200 | [diff] [blame] | 3146 | max_count = device->block->bdev ? 0 : -1; |
| 3147 | open_count = atomic_read(&device->block->open_count); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3148 | if (open_count > max_count) { |
| 3149 | if (open_count > 0) |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 3150 | pr_warning("%s: The DASD cannot be set offline " |
| 3151 | "with open count %i\n", |
| 3152 | dev_name(&cdev->dev), open_count); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3153 | else |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 3154 | pr_warning("%s: The DASD cannot be set offline " |
| 3155 | "while it is in use\n", |
| 3156 | dev_name(&cdev->dev)); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3157 | clear_bit(DASD_FLAG_OFFLINE, &device->flags); |
| 3158 | dasd_put_device(device); |
| 3159 | return -EBUSY; |
| 3160 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3161 | } |
| 3162 | dasd_set_target_state(device, DASD_STATE_NEW); |
| 3163 | /* dasd_delete_device destroys the device reference. */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3164 | block = device->block; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3165 | dasd_delete_device(device); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3166 | /* |
| 3167 | * life cycle of block is bound to device, so delete it after |
| 3168 | * device was safely removed |
| 3169 | */ |
| 3170 | if (block) |
| 3171 | dasd_free_block(block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3172 | return 0; |
| 3173 | } |
| 3174 | |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 3175 | int dasd_generic_last_path_gone(struct dasd_device *device) |
| 3176 | { |
| 3177 | struct dasd_ccw_req *cqr; |
| 3178 | |
| 3179 | dev_warn(&device->cdev->dev, "No operational channel path is left " |
| 3180 | "for the device\n"); |
| 3181 | DBF_DEV_EVENT(DBF_WARNING, device, "%s", "last path gone"); |
| 3182 | /* First of all call extended error reporting. */ |
| 3183 | dasd_eer_write(device, NULL, DASD_EER_NOPATH); |
| 3184 | |
| 3185 | if (device->state < DASD_STATE_BASIC) |
| 3186 | return 0; |
| 3187 | /* Device is active. We want to keep it. */ |
| 3188 | list_for_each_entry(cqr, &device->ccw_queue, devlist) |
| 3189 | if ((cqr->status == DASD_CQR_IN_IO) || |
| 3190 | (cqr->status == DASD_CQR_CLEAR_PENDING)) { |
| 3191 | cqr->status = DASD_CQR_QUEUED; |
| 3192 | cqr->retries++; |
| 3193 | } |
| 3194 | dasd_device_set_stop_bits(device, DASD_STOPPED_DC_WAIT); |
| 3195 | dasd_device_clear_timer(device); |
| 3196 | dasd_schedule_device_bh(device); |
| 3197 | return 1; |
| 3198 | } |
| 3199 | EXPORT_SYMBOL_GPL(dasd_generic_last_path_gone); |
| 3200 | |
| 3201 | int dasd_generic_path_operational(struct dasd_device *device) |
| 3202 | { |
| 3203 | dev_info(&device->cdev->dev, "A channel path to the device has become " |
| 3204 | "operational\n"); |
| 3205 | DBF_DEV_EVENT(DBF_WARNING, device, "%s", "path operational"); |
| 3206 | dasd_device_remove_stop_bits(device, DASD_STOPPED_DC_WAIT); |
| 3207 | if (device->stopped & DASD_UNRESUMED_PM) { |
| 3208 | dasd_device_remove_stop_bits(device, DASD_UNRESUMED_PM); |
| 3209 | dasd_restore_device(device); |
| 3210 | return 1; |
| 3211 | } |
| 3212 | dasd_schedule_device_bh(device); |
| 3213 | if (device->block) |
| 3214 | dasd_schedule_block_bh(device->block); |
| 3215 | return 1; |
| 3216 | } |
| 3217 | EXPORT_SYMBOL_GPL(dasd_generic_path_operational); |
| 3218 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3219 | int dasd_generic_notify(struct ccw_device *cdev, int event) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3220 | { |
| 3221 | struct dasd_device *device; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3222 | int ret; |
| 3223 | |
Peter Oberparleiter | 91c3691 | 2008-08-21 19:46:39 +0200 | [diff] [blame] | 3224 | device = dasd_device_from_cdev_locked(cdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3225 | if (IS_ERR(device)) |
| 3226 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3227 | ret = 0; |
| 3228 | switch (event) { |
| 3229 | case CIO_GONE: |
Sebastian Ott | 47593bf | 2009-03-31 19:16:05 +0200 | [diff] [blame] | 3230 | case CIO_BOXED: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3231 | case CIO_NO_PATH: |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 3232 | device->path_data.opm = 0; |
| 3233 | device->path_data.ppm = 0; |
| 3234 | device->path_data.npm = 0; |
| 3235 | ret = dasd_generic_last_path_gone(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3236 | break; |
| 3237 | case CIO_OPER: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3238 | ret = 1; |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 3239 | if (device->path_data.opm) |
| 3240 | ret = dasd_generic_path_operational(device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3241 | break; |
| 3242 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3243 | dasd_put_device(device); |
| 3244 | return ret; |
| 3245 | } |
| 3246 | |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 3247 | void dasd_generic_path_event(struct ccw_device *cdev, int *path_event) |
| 3248 | { |
| 3249 | int chp; |
| 3250 | __u8 oldopm, eventlpm; |
| 3251 | struct dasd_device *device; |
| 3252 | |
| 3253 | device = dasd_device_from_cdev_locked(cdev); |
| 3254 | if (IS_ERR(device)) |
| 3255 | return; |
| 3256 | for (chp = 0; chp < 8; chp++) { |
| 3257 | eventlpm = 0x80 >> chp; |
| 3258 | if (path_event[chp] & PE_PATH_GONE) { |
| 3259 | oldopm = device->path_data.opm; |
| 3260 | device->path_data.opm &= ~eventlpm; |
| 3261 | device->path_data.ppm &= ~eventlpm; |
| 3262 | device->path_data.npm &= ~eventlpm; |
| 3263 | if (oldopm && !device->path_data.opm) |
| 3264 | dasd_generic_last_path_gone(device); |
| 3265 | } |
| 3266 | if (path_event[chp] & PE_PATH_AVAILABLE) { |
| 3267 | device->path_data.opm &= ~eventlpm; |
| 3268 | device->path_data.ppm &= ~eventlpm; |
| 3269 | device->path_data.npm &= ~eventlpm; |
| 3270 | device->path_data.tbvpm |= eventlpm; |
| 3271 | dasd_schedule_device_bh(device); |
| 3272 | } |
Stefan Haberland | f163303 | 2012-01-18 18:03:41 +0100 | [diff] [blame] | 3273 | if (path_event[chp] & PE_PATHGROUP_ESTABLISHED) { |
| 3274 | DBF_DEV_EVENT(DBF_WARNING, device, "%s", |
| 3275 | "Pathgroup re-established\n"); |
| 3276 | if (device->discipline->kick_validate) |
| 3277 | device->discipline->kick_validate(device); |
| 3278 | } |
Stefan Weinhuber | a4d26c6 | 2011-01-05 12:48:03 +0100 | [diff] [blame] | 3279 | } |
| 3280 | dasd_put_device(device); |
| 3281 | } |
| 3282 | EXPORT_SYMBOL_GPL(dasd_generic_path_event); |
| 3283 | |
| 3284 | int dasd_generic_verify_path(struct dasd_device *device, __u8 lpm) |
| 3285 | { |
| 3286 | if (!device->path_data.opm && lpm) { |
| 3287 | device->path_data.opm = lpm; |
| 3288 | dasd_generic_path_operational(device); |
| 3289 | } else |
| 3290 | device->path_data.opm |= lpm; |
| 3291 | return 0; |
| 3292 | } |
| 3293 | EXPORT_SYMBOL_GPL(dasd_generic_verify_path); |
| 3294 | |
| 3295 | |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 3296 | int dasd_generic_pm_freeze(struct ccw_device *cdev) |
| 3297 | { |
| 3298 | struct dasd_ccw_req *cqr, *n; |
| 3299 | int rc; |
| 3300 | struct list_head freeze_queue; |
| 3301 | struct dasd_device *device = dasd_device_from_cdev(cdev); |
| 3302 | |
| 3303 | if (IS_ERR(device)) |
| 3304 | return PTR_ERR(device); |
Stefan Haberland | 6f272b9 | 2011-01-05 12:48:05 +0100 | [diff] [blame] | 3305 | |
Stefan Haberland | c8d1c0f | 2011-10-30 15:17:09 +0100 | [diff] [blame] | 3306 | /* mark device as suspended */ |
| 3307 | set_bit(DASD_FLAG_SUSPENDED, &device->flags); |
| 3308 | |
Stefan Haberland | 6f272b9 | 2011-01-05 12:48:05 +0100 | [diff] [blame] | 3309 | if (device->discipline->freeze) |
| 3310 | rc = device->discipline->freeze(device); |
| 3311 | |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 3312 | /* disallow new I/O */ |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 3313 | dasd_device_set_stop_bits(device, DASD_STOPPED_PM); |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 3314 | /* clear active requests */ |
| 3315 | INIT_LIST_HEAD(&freeze_queue); |
| 3316 | spin_lock_irq(get_ccwdev_lock(cdev)); |
| 3317 | rc = 0; |
| 3318 | list_for_each_entry_safe(cqr, n, &device->ccw_queue, devlist) { |
| 3319 | /* Check status and move request to flush_queue */ |
| 3320 | if (cqr->status == DASD_CQR_IN_IO) { |
| 3321 | rc = device->discipline->term_IO(cqr); |
| 3322 | if (rc) { |
| 3323 | /* unable to terminate requeust */ |
| 3324 | dev_err(&device->cdev->dev, |
| 3325 | "Unable to terminate request %p " |
| 3326 | "on suspend\n", cqr); |
| 3327 | spin_unlock_irq(get_ccwdev_lock(cdev)); |
| 3328 | dasd_put_device(device); |
| 3329 | return rc; |
| 3330 | } |
| 3331 | } |
| 3332 | list_move_tail(&cqr->devlist, &freeze_queue); |
| 3333 | } |
| 3334 | |
| 3335 | spin_unlock_irq(get_ccwdev_lock(cdev)); |
| 3336 | |
| 3337 | list_for_each_entry_safe(cqr, n, &freeze_queue, devlist) { |
| 3338 | wait_event(dasd_flush_wq, |
| 3339 | (cqr->status != DASD_CQR_CLEAR_PENDING)); |
| 3340 | if (cqr->status == DASD_CQR_CLEARED) |
| 3341 | cqr->status = DASD_CQR_QUEUED; |
| 3342 | } |
| 3343 | /* move freeze_queue to start of the ccw_queue */ |
| 3344 | spin_lock_irq(get_ccwdev_lock(cdev)); |
| 3345 | list_splice_tail(&freeze_queue, &device->ccw_queue); |
| 3346 | spin_unlock_irq(get_ccwdev_lock(cdev)); |
| 3347 | |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 3348 | dasd_put_device(device); |
| 3349 | return rc; |
| 3350 | } |
| 3351 | EXPORT_SYMBOL_GPL(dasd_generic_pm_freeze); |
| 3352 | |
| 3353 | int dasd_generic_restore_device(struct ccw_device *cdev) |
| 3354 | { |
| 3355 | struct dasd_device *device = dasd_device_from_cdev(cdev); |
| 3356 | int rc = 0; |
| 3357 | |
| 3358 | if (IS_ERR(device)) |
| 3359 | return PTR_ERR(device); |
| 3360 | |
Stefan Haberland | e6125fb | 2009-06-22 12:08:17 +0200 | [diff] [blame] | 3361 | /* allow new IO again */ |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 3362 | dasd_device_remove_stop_bits(device, |
| 3363 | (DASD_STOPPED_PM | DASD_UNRESUMED_PM)); |
Stefan Haberland | e6125fb | 2009-06-22 12:08:17 +0200 | [diff] [blame] | 3364 | |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 3365 | dasd_schedule_device_bh(device); |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 3366 | |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 3367 | /* |
| 3368 | * call discipline restore function |
| 3369 | * if device is stopped do nothing e.g. for disconnected devices |
| 3370 | */ |
| 3371 | if (device->discipline->restore && !(device->stopped)) |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 3372 | rc = device->discipline->restore(device); |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 3373 | if (rc || device->stopped) |
Stefan Haberland | e6125fb | 2009-06-22 12:08:17 +0200 | [diff] [blame] | 3374 | /* |
| 3375 | * if the resume failed for the DASD we put it in |
| 3376 | * an UNRESUMED stop state |
| 3377 | */ |
| 3378 | device->stopped |= DASD_UNRESUMED_PM; |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 3379 | |
Stefan Haberland | 6fca97a | 2009-10-06 10:34:15 +0200 | [diff] [blame] | 3380 | if (device->block) |
| 3381 | dasd_schedule_block_bh(device->block); |
| 3382 | |
Stefan Haberland | c8d1c0f | 2011-10-30 15:17:09 +0100 | [diff] [blame] | 3383 | clear_bit(DASD_FLAG_SUSPENDED, &device->flags); |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 3384 | dasd_put_device(device); |
Stefan Haberland | e6125fb | 2009-06-22 12:08:17 +0200 | [diff] [blame] | 3385 | return 0; |
Stefan Haberland | d41dd12 | 2009-06-16 10:30:25 +0200 | [diff] [blame] | 3386 | } |
| 3387 | EXPORT_SYMBOL_GPL(dasd_generic_restore_device); |
| 3388 | |
Heiko Carstens | 763968e | 2007-05-10 15:45:46 +0200 | [diff] [blame] | 3389 | static struct dasd_ccw_req *dasd_generic_build_rdc(struct dasd_device *device, |
| 3390 | void *rdc_buffer, |
| 3391 | int rdc_buffer_size, |
Stefan Haberland | 68b781f | 2009-09-11 10:28:29 +0200 | [diff] [blame] | 3392 | int magic) |
Cornelia Huck | 17283b5 | 2007-05-04 18:47:51 +0200 | [diff] [blame] | 3393 | { |
| 3394 | struct dasd_ccw_req *cqr; |
| 3395 | struct ccw1 *ccw; |
Stefan Haberland | d9fa944 | 2009-10-14 12:43:48 +0200 | [diff] [blame] | 3396 | unsigned long *idaw; |
Cornelia Huck | 17283b5 | 2007-05-04 18:47:51 +0200 | [diff] [blame] | 3397 | |
| 3398 | cqr = dasd_smalloc_request(magic, 1 /* RDC */, rdc_buffer_size, device); |
| 3399 | |
| 3400 | if (IS_ERR(cqr)) { |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 3401 | /* internal error 13 - Allocating the RDC request failed*/ |
| 3402 | dev_err(&device->cdev->dev, |
| 3403 | "An error occurred in the DASD device driver, " |
| 3404 | "reason=%s\n", "13"); |
Cornelia Huck | 17283b5 | 2007-05-04 18:47:51 +0200 | [diff] [blame] | 3405 | return cqr; |
| 3406 | } |
| 3407 | |
| 3408 | ccw = cqr->cpaddr; |
| 3409 | ccw->cmd_code = CCW_CMD_RDC; |
Stefan Haberland | d9fa944 | 2009-10-14 12:43:48 +0200 | [diff] [blame] | 3410 | if (idal_is_needed(rdc_buffer, rdc_buffer_size)) { |
| 3411 | idaw = (unsigned long *) (cqr->data); |
| 3412 | ccw->cda = (__u32)(addr_t) idaw; |
| 3413 | ccw->flags = CCW_FLAG_IDA; |
| 3414 | idaw = idal_create_words(idaw, rdc_buffer, rdc_buffer_size); |
| 3415 | } else { |
| 3416 | ccw->cda = (__u32)(addr_t) rdc_buffer; |
| 3417 | ccw->flags = 0; |
| 3418 | } |
Cornelia Huck | 17283b5 | 2007-05-04 18:47:51 +0200 | [diff] [blame] | 3419 | |
Stefan Haberland | d9fa944 | 2009-10-14 12:43:48 +0200 | [diff] [blame] | 3420 | ccw->count = rdc_buffer_size; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3421 | cqr->startdev = device; |
| 3422 | cqr->memdev = device; |
Cornelia Huck | 17283b5 | 2007-05-04 18:47:51 +0200 | [diff] [blame] | 3423 | cqr->expires = 10*HZ; |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 3424 | cqr->retries = 256; |
Cornelia Huck | 17283b5 | 2007-05-04 18:47:51 +0200 | [diff] [blame] | 3425 | cqr->buildclk = get_clock(); |
| 3426 | cqr->status = DASD_CQR_FILLED; |
| 3427 | return cqr; |
| 3428 | } |
| 3429 | |
| 3430 | |
Stefan Haberland | 68b781f | 2009-09-11 10:28:29 +0200 | [diff] [blame] | 3431 | int dasd_generic_read_dev_chars(struct dasd_device *device, int magic, |
Sebastian Ott | 92636b1 | 2009-06-12 10:26:37 +0200 | [diff] [blame] | 3432 | void *rdc_buffer, int rdc_buffer_size) |
Cornelia Huck | 17283b5 | 2007-05-04 18:47:51 +0200 | [diff] [blame] | 3433 | { |
| 3434 | int ret; |
| 3435 | struct dasd_ccw_req *cqr; |
| 3436 | |
Sebastian Ott | 92636b1 | 2009-06-12 10:26:37 +0200 | [diff] [blame] | 3437 | cqr = dasd_generic_build_rdc(device, rdc_buffer, rdc_buffer_size, |
Cornelia Huck | 17283b5 | 2007-05-04 18:47:51 +0200 | [diff] [blame] | 3438 | magic); |
| 3439 | if (IS_ERR(cqr)) |
| 3440 | return PTR_ERR(cqr); |
| 3441 | |
| 3442 | ret = dasd_sleep_on(cqr); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3443 | dasd_sfree_request(cqr, cqr->memdev); |
Cornelia Huck | 17283b5 | 2007-05-04 18:47:51 +0200 | [diff] [blame] | 3444 | return ret; |
| 3445 | } |
Cornelia Huck | aaff0f6 | 2007-05-10 15:45:45 +0200 | [diff] [blame] | 3446 | EXPORT_SYMBOL_GPL(dasd_generic_read_dev_chars); |
Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 3447 | |
Stefan Weinhuber | f3eb538 | 2009-03-26 15:23:48 +0100 | [diff] [blame] | 3448 | /* |
| 3449 | * In command mode and transport mode we need to look for sense |
| 3450 | * data in different places. The sense data itself is allways |
| 3451 | * an array of 32 bytes, so we can unify the sense data access |
| 3452 | * for both modes. |
| 3453 | */ |
| 3454 | char *dasd_get_sense(struct irb *irb) |
| 3455 | { |
| 3456 | struct tsb *tsb = NULL; |
| 3457 | char *sense = NULL; |
| 3458 | |
| 3459 | if (scsw_is_tm(&irb->scsw) && (irb->scsw.tm.fcxs == 0x01)) { |
| 3460 | if (irb->scsw.tm.tcw) |
| 3461 | tsb = tcw_get_tsb((struct tcw *)(unsigned long) |
| 3462 | irb->scsw.tm.tcw); |
| 3463 | if (tsb && tsb->length == 64 && tsb->flags) |
| 3464 | switch (tsb->flags & 0x07) { |
| 3465 | case 1: /* tsa_iostat */ |
| 3466 | sense = tsb->tsa.iostat.sense; |
| 3467 | break; |
| 3468 | case 2: /* tsa_ddpc */ |
| 3469 | sense = tsb->tsa.ddpc.sense; |
| 3470 | break; |
| 3471 | default: |
| 3472 | /* currently we don't use interrogate data */ |
| 3473 | break; |
| 3474 | } |
| 3475 | } else if (irb->esw.esw0.erw.cons) { |
| 3476 | sense = irb->ecw; |
| 3477 | } |
| 3478 | return sense; |
| 3479 | } |
| 3480 | EXPORT_SYMBOL_GPL(dasd_get_sense); |
| 3481 | |
Stefan Haberland | 4679e89 | 2012-06-19 17:30:12 +0200 | [diff] [blame^] | 3482 | static inline int _wait_for_empty_queues(struct dasd_device *device) |
| 3483 | { |
| 3484 | if (device->block) |
| 3485 | return list_empty(&device->ccw_queue) && |
| 3486 | list_empty(&device->block->ccw_queue); |
| 3487 | else |
| 3488 | return list_empty(&device->ccw_queue); |
| 3489 | } |
| 3490 | |
| 3491 | void dasd_generic_shutdown(struct ccw_device *cdev) |
| 3492 | { |
| 3493 | struct dasd_device *device; |
| 3494 | |
| 3495 | device = dasd_device_from_cdev(cdev); |
| 3496 | if (IS_ERR(device)) |
| 3497 | return; |
| 3498 | |
| 3499 | if (device->block) |
| 3500 | dasd_schedule_block_bh(device->block); |
| 3501 | |
| 3502 | dasd_schedule_device_bh(device); |
| 3503 | |
| 3504 | wait_event(shutdown_waitq, _wait_for_empty_queues(device)); |
| 3505 | } |
| 3506 | EXPORT_SYMBOL_GPL(dasd_generic_shutdown); |
| 3507 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3508 | static int __init dasd_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3509 | { |
| 3510 | int rc; |
| 3511 | |
| 3512 | init_waitqueue_head(&dasd_init_waitq); |
Horst Hummel | 8f61701 | 2006-08-30 14:33:33 +0200 | [diff] [blame] | 3513 | init_waitqueue_head(&dasd_flush_wq); |
Stefan Haberland | c80ee72 | 2008-05-30 10:03:31 +0200 | [diff] [blame] | 3514 | init_waitqueue_head(&generic_waitq); |
Stefan Haberland | 4679e89 | 2012-06-19 17:30:12 +0200 | [diff] [blame^] | 3515 | init_waitqueue_head(&shutdown_waitq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3516 | |
| 3517 | /* register 'common' DASD debug area, used for all DBF_XXX calls */ |
Peter Tiedemann | 361f494 | 2008-01-26 14:11:30 +0100 | [diff] [blame] | 3518 | dasd_debug_area = debug_register("dasd", 1, 1, 8 * sizeof(long)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3519 | if (dasd_debug_area == NULL) { |
| 3520 | rc = -ENOMEM; |
| 3521 | goto failed; |
| 3522 | } |
| 3523 | debug_register_view(dasd_debug_area, &debug_sprintf_view); |
Horst Hummel | b0035f1 | 2006-09-20 15:59:07 +0200 | [diff] [blame] | 3524 | debug_set_level(dasd_debug_area, DBF_WARNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3525 | |
| 3526 | DBF_EVENT(DBF_EMERG, "%s", "debug area created"); |
| 3527 | |
| 3528 | dasd_diag_discipline_pointer = NULL; |
| 3529 | |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 3530 | dasd_statistics_createroot(); |
| 3531 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3532 | rc = dasd_devmap_init(); |
| 3533 | if (rc) |
| 3534 | goto failed; |
| 3535 | rc = dasd_gendisk_init(); |
| 3536 | if (rc) |
| 3537 | goto failed; |
| 3538 | rc = dasd_parse(); |
| 3539 | if (rc) |
| 3540 | goto failed; |
Stefan Weinhuber | 20c6446 | 2006-03-24 03:15:25 -0800 | [diff] [blame] | 3541 | rc = dasd_eer_init(); |
| 3542 | if (rc) |
| 3543 | goto failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3544 | #ifdef CONFIG_PROC_FS |
| 3545 | rc = dasd_proc_init(); |
| 3546 | if (rc) |
| 3547 | goto failed; |
| 3548 | #endif |
| 3549 | |
| 3550 | return 0; |
| 3551 | failed: |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 3552 | pr_info("The DASD device driver could not be initialized\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3553 | dasd_exit(); |
| 3554 | return rc; |
| 3555 | } |
| 3556 | |
| 3557 | module_init(dasd_init); |
| 3558 | module_exit(dasd_exit); |
| 3559 | |
| 3560 | EXPORT_SYMBOL(dasd_debug_area); |
| 3561 | EXPORT_SYMBOL(dasd_diag_discipline_pointer); |
| 3562 | |
| 3563 | EXPORT_SYMBOL(dasd_add_request_head); |
| 3564 | EXPORT_SYMBOL(dasd_add_request_tail); |
| 3565 | EXPORT_SYMBOL(dasd_cancel_req); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3566 | EXPORT_SYMBOL(dasd_device_clear_timer); |
| 3567 | EXPORT_SYMBOL(dasd_block_clear_timer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3568 | EXPORT_SYMBOL(dasd_enable_device); |
| 3569 | EXPORT_SYMBOL(dasd_int_handler); |
| 3570 | EXPORT_SYMBOL(dasd_kfree_request); |
| 3571 | EXPORT_SYMBOL(dasd_kick_device); |
| 3572 | EXPORT_SYMBOL(dasd_kmalloc_request); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3573 | EXPORT_SYMBOL(dasd_schedule_device_bh); |
| 3574 | EXPORT_SYMBOL(dasd_schedule_block_bh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3575 | EXPORT_SYMBOL(dasd_set_target_state); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3576 | EXPORT_SYMBOL(dasd_device_set_timer); |
| 3577 | EXPORT_SYMBOL(dasd_block_set_timer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3578 | EXPORT_SYMBOL(dasd_sfree_request); |
| 3579 | EXPORT_SYMBOL(dasd_sleep_on); |
| 3580 | EXPORT_SYMBOL(dasd_sleep_on_immediatly); |
| 3581 | EXPORT_SYMBOL(dasd_sleep_on_interruptible); |
| 3582 | EXPORT_SYMBOL(dasd_smalloc_request); |
| 3583 | EXPORT_SYMBOL(dasd_start_IO); |
| 3584 | EXPORT_SYMBOL(dasd_term_IO); |
| 3585 | |
| 3586 | EXPORT_SYMBOL_GPL(dasd_generic_probe); |
| 3587 | EXPORT_SYMBOL_GPL(dasd_generic_remove); |
| 3588 | EXPORT_SYMBOL_GPL(dasd_generic_notify); |
| 3589 | EXPORT_SYMBOL_GPL(dasd_generic_set_online); |
| 3590 | EXPORT_SYMBOL_GPL(dasd_generic_set_offline); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 3591 | EXPORT_SYMBOL_GPL(dasd_generic_handle_state_change); |
| 3592 | EXPORT_SYMBOL_GPL(dasd_flush_device_queue); |
| 3593 | EXPORT_SYMBOL_GPL(dasd_alloc_block); |
| 3594 | EXPORT_SYMBOL_GPL(dasd_free_block); |