Lines Matching full:device

49 MODULE_DESCRIPTION("Linux on S/390 DASD device driver,"
73 * SECTION: Operations on the device structure.
81 * Allocate memory for a new device structure.
85 struct dasd_device *device; in dasd_alloc_device() local
87 device = kzalloc(sizeof(struct dasd_device), GFP_ATOMIC); in dasd_alloc_device()
88 if (!device) in dasd_alloc_device()
91 /* Get two pages for normal block device operations. */ in dasd_alloc_device()
92 device->ccw_mem = (void *) __get_free_pages(GFP_ATOMIC | GFP_DMA, 1); in dasd_alloc_device()
93 if (!device->ccw_mem) { in dasd_alloc_device()
94 kfree(device); in dasd_alloc_device()
98 device->erp_mem = (void *) get_zeroed_page(GFP_ATOMIC | GFP_DMA); in dasd_alloc_device()
99 if (!device->erp_mem) { in dasd_alloc_device()
100 free_pages((unsigned long) device->ccw_mem, 1); in dasd_alloc_device()
101 kfree(device); in dasd_alloc_device()
105 device->ese_mem = (void *)__get_free_pages(GFP_ATOMIC | GFP_DMA, 1); in dasd_alloc_device()
106 if (!device->ese_mem) { in dasd_alloc_device()
107 free_page((unsigned long) device->erp_mem); in dasd_alloc_device()
108 free_pages((unsigned long) device->ccw_mem, 1); in dasd_alloc_device()
109 kfree(device); in dasd_alloc_device()
113 dasd_init_chunklist(&device->ccw_chunks, device->ccw_mem, PAGE_SIZE*2); in dasd_alloc_device()
114 dasd_init_chunklist(&device->erp_chunks, device->erp_mem, PAGE_SIZE); in dasd_alloc_device()
115 dasd_init_chunklist(&device->ese_chunks, device->ese_mem, PAGE_SIZE * 2); in dasd_alloc_device()
116 spin_lock_init(&device->mem_lock); in dasd_alloc_device()
117 atomic_set(&device->tasklet_scheduled, 0); in dasd_alloc_device()
118 tasklet_init(&device->tasklet, dasd_device_tasklet, in dasd_alloc_device()
119 (unsigned long) device); in dasd_alloc_device()
120 INIT_LIST_HEAD(&device->ccw_queue); in dasd_alloc_device()
121 timer_setup(&device->timer, dasd_device_timeout, 0); in dasd_alloc_device()
122 INIT_WORK(&device->kick_work, do_kick_device); in dasd_alloc_device()
123 INIT_WORK(&device->reload_device, do_reload_device); in dasd_alloc_device()
124 INIT_WORK(&device->requeue_requests, do_requeue_requests); in dasd_alloc_device()
125 device->state = DASD_STATE_NEW; in dasd_alloc_device()
126 device->target = DASD_STATE_NEW; in dasd_alloc_device()
127 mutex_init(&device->state_mutex); in dasd_alloc_device()
128 spin_lock_init(&device->profile.lock); in dasd_alloc_device()
129 return device; in dasd_alloc_device()
133 * Free memory of a device structure.
135 void dasd_free_device(struct dasd_device *device) in dasd_free_device() argument
137 kfree(device->private); in dasd_free_device()
138 free_pages((unsigned long) device->ese_mem, 1); in dasd_free_device()
139 free_page((unsigned long) device->erp_mem); in dasd_free_device()
140 free_pages((unsigned long) device->ccw_mem, 1); in dasd_free_device()
141 kfree(device); in dasd_free_device()
145 * Allocate memory for a new device structure.
154 /* open_count = 0 means device online but not in use */ in dasd_alloc_block()
172 * Free memory of a device structure.
181 * Make a new device known to the system.
183 static int dasd_state_new_to_known(struct dasd_device *device) in dasd_state_new_to_known() argument
186 * As long as the device is not in state DASD_STATE_NEW we want to in dasd_state_new_to_known()
189 dasd_get_device(device); in dasd_state_new_to_known()
190 device->state = DASD_STATE_KNOWN; in dasd_state_new_to_known()
195 * Let the system forget about a device.
197 static int dasd_state_known_to_new(struct dasd_device *device) in dasd_state_known_to_new() argument
199 /* Disable extended error reporting for this device. */ in dasd_state_known_to_new()
200 dasd_eer_disable(device); in dasd_state_known_to_new()
201 device->state = DASD_STATE_NEW; in dasd_state_known_to_new()
204 dasd_put_device(device); in dasd_state_known_to_new()
222 * Request the irq line for the device.
224 static int dasd_state_known_to_basic(struct dasd_device *device) in dasd_state_known_to_basic() argument
226 struct dasd_block *block = device->block; in dasd_state_known_to_basic()
239 dasd_profile_on(&device->block->profile); in dasd_state_known_to_basic()
241 device->debugfs_dentry = in dasd_state_known_to_basic()
242 dasd_debugfs_setup(dev_name(&device->cdev->dev), in dasd_state_known_to_basic()
244 dasd_profile_init(&device->profile, device->debugfs_dentry); in dasd_state_known_to_basic()
245 dasd_hosts_init(device->debugfs_dentry, device); in dasd_state_known_to_basic()
247 /* register 'device' debug area, used for all DBF_DEV_XXX calls */ in dasd_state_known_to_basic()
248 device->debug_area = debug_register(dev_name(&device->cdev->dev), 4, 1, in dasd_state_known_to_basic()
250 debug_register_view(device->debug_area, &debug_sprintf_view); in dasd_state_known_to_basic()
251 debug_set_level(device->debug_area, DBF_WARNING); in dasd_state_known_to_basic()
252 DBF_DEV_EVENT(DBF_EMERG, device, "%s", "debug area created"); in dasd_state_known_to_basic()
254 device->state = DASD_STATE_BASIC; in dasd_state_known_to_basic()
260 * Release the irq line for the device. Terminate any running i/o.
262 static int dasd_state_basic_to_known(struct dasd_device *device) in dasd_state_basic_to_known() argument
266 if (device->discipline->basic_to_known) { in dasd_state_basic_to_known()
267 rc = device->discipline->basic_to_known(device); in dasd_state_basic_to_known()
272 if (device->block) { in dasd_state_basic_to_known()
273 dasd_profile_exit(&device->block->profile); in dasd_state_basic_to_known()
274 debugfs_remove(device->block->debugfs_dentry); in dasd_state_basic_to_known()
275 dasd_gendisk_free(device->block); in dasd_state_basic_to_known()
276 dasd_block_clear_timer(device->block); in dasd_state_basic_to_known()
278 rc = dasd_flush_device_queue(device); in dasd_state_basic_to_known()
281 dasd_device_clear_timer(device); in dasd_state_basic_to_known()
282 dasd_profile_exit(&device->profile); in dasd_state_basic_to_known()
283 dasd_hosts_exit(device); in dasd_state_basic_to_known()
284 debugfs_remove(device->debugfs_dentry); in dasd_state_basic_to_known()
285 DBF_DEV_EVENT(DBF_EMERG, device, "%p debug area deleted", device); in dasd_state_basic_to_known()
286 if (device->debug_area != NULL) { in dasd_state_basic_to_known()
287 debug_unregister(device->debug_area); in dasd_state_basic_to_known()
288 device->debug_area = NULL; in dasd_state_basic_to_known()
290 device->state = DASD_STATE_KNOWN; in dasd_state_basic_to_known()
296 * -EAGAIN in which case the device keeps the state DASD_STATE_BASIC
304 * device is setup.
305 * In case the analysis returns an error, the device setup is stopped
308 static int dasd_state_basic_to_ready(struct dasd_device *device) in dasd_state_basic_to_ready() argument
310 struct dasd_block *block = device->block; in dasd_state_basic_to_ready()
316 device->state = DASD_STATE_READY; in dasd_state_basic_to_ready()
325 device->state = DASD_STATE_UNFMT; in dasd_state_basic_to_ready()
326 kobject_uevent(&disk_to_dev(device->block->gdp)->kobj, in dasd_state_basic_to_ready()
332 lim.max_dev_sectors = device->discipline->max_sectors(block); in dasd_state_basic_to_ready()
336 if (device->discipline->has_discard) { in dasd_state_basic_to_ready()
353 device->state = DASD_STATE_READY; in dasd_state_basic_to_ready()
357 device->state = DASD_STATE_BASIC; in dasd_state_basic_to_ready()
362 if (device->discipline->basic_to_ready) in dasd_state_basic_to_ready()
363 rc = device->discipline->basic_to_ready(device); in dasd_state_basic_to_ready()
368 int _wait_for_empty_queues(struct dasd_device *device) in _wait_for_empty_queues() argument
370 if (device->block) in _wait_for_empty_queues()
371 return list_empty(&device->ccw_queue) && in _wait_for_empty_queues()
372 list_empty(&device->block->ccw_queue); in _wait_for_empty_queues()
374 return list_empty(&device->ccw_queue); in _wait_for_empty_queues()
378 * Remove device from block device layer. Destroy dirty buffers.
382 static int dasd_state_ready_to_basic(struct dasd_device *device) in dasd_state_ready_to_basic() argument
386 device->state = DASD_STATE_BASIC; in dasd_state_ready_to_basic()
387 if (device->block) { in dasd_state_ready_to_basic()
388 struct dasd_block *block = device->block; in dasd_state_ready_to_basic()
391 device->state = DASD_STATE_READY; in dasd_state_ready_to_basic()
405 static int dasd_state_unfmt_to_basic(struct dasd_device *device) in dasd_state_unfmt_to_basic() argument
407 device->state = DASD_STATE_BASIC; in dasd_state_unfmt_to_basic()
412 * Make the device online and schedule the bottom half to start
417 dasd_state_ready_to_online(struct dasd_device * device) in dasd_state_ready_to_online() argument
419 device->state = DASD_STATE_ONLINE; in dasd_state_ready_to_online()
420 if (device->block) { in dasd_state_ready_to_online()
421 dasd_schedule_block_bh(device->block); in dasd_state_ready_to_online()
422 if ((device->features & DASD_FEATURE_USERAW)) { in dasd_state_ready_to_online()
423 kobject_uevent(&disk_to_dev(device->block->gdp)->kobj, in dasd_state_ready_to_online()
427 disk_uevent(file_bdev(device->block->bdev_file)->bd_disk, in dasd_state_ready_to_online()
436 static int dasd_state_online_to_ready(struct dasd_device *device) in dasd_state_online_to_ready() argument
440 if (device->discipline->online_to_ready) { in dasd_state_online_to_ready()
441 rc = device->discipline->online_to_ready(device); in dasd_state_online_to_ready()
446 device->state = DASD_STATE_READY; in dasd_state_online_to_ready()
447 if (device->block && !(device->features & DASD_FEATURE_USERAW)) in dasd_state_online_to_ready()
448 disk_uevent(file_bdev(device->block->bdev_file)->bd_disk, in dasd_state_online_to_ready()
454 * Device startup state changes.
456 static int dasd_increase_state(struct dasd_device *device) in dasd_increase_state() argument
461 if (device->state == DASD_STATE_NEW && in dasd_increase_state()
462 device->target >= DASD_STATE_KNOWN) in dasd_increase_state()
463 rc = dasd_state_new_to_known(device); in dasd_increase_state()
466 device->state == DASD_STATE_KNOWN && in dasd_increase_state()
467 device->target >= DASD_STATE_BASIC) in dasd_increase_state()
468 rc = dasd_state_known_to_basic(device); in dasd_increase_state()
471 device->state == DASD_STATE_BASIC && in dasd_increase_state()
472 device->target >= DASD_STATE_READY) in dasd_increase_state()
473 rc = dasd_state_basic_to_ready(device); in dasd_increase_state()
476 device->state == DASD_STATE_UNFMT && in dasd_increase_state()
477 device->target > DASD_STATE_UNFMT) in dasd_increase_state()
481 device->state == DASD_STATE_READY && in dasd_increase_state()
482 device->target >= DASD_STATE_ONLINE) in dasd_increase_state()
483 rc = dasd_state_ready_to_online(device); in dasd_increase_state()
489 * Device shutdown state changes.
491 static int dasd_decrease_state(struct dasd_device *device) in dasd_decrease_state() argument
496 if (device->state == DASD_STATE_ONLINE && in dasd_decrease_state()
497 device->target <= DASD_STATE_READY) in dasd_decrease_state()
498 rc = dasd_state_online_to_ready(device); in dasd_decrease_state()
501 device->state == DASD_STATE_READY && in dasd_decrease_state()
502 device->target <= DASD_STATE_BASIC) in dasd_decrease_state()
503 rc = dasd_state_ready_to_basic(device); in dasd_decrease_state()
506 device->state == DASD_STATE_UNFMT && in dasd_decrease_state()
507 device->target <= DASD_STATE_BASIC) in dasd_decrease_state()
508 rc = dasd_state_unfmt_to_basic(device); in dasd_decrease_state()
511 device->state == DASD_STATE_BASIC && in dasd_decrease_state()
512 device->target <= DASD_STATE_KNOWN) in dasd_decrease_state()
513 rc = dasd_state_basic_to_known(device); in dasd_decrease_state()
516 device->state == DASD_STATE_KNOWN && in dasd_decrease_state()
517 device->target <= DASD_STATE_NEW) in dasd_decrease_state()
518 rc = dasd_state_known_to_new(device); in dasd_decrease_state()
526 static void dasd_change_state(struct dasd_device *device) in dasd_change_state() argument
530 if (device->state == device->target) in dasd_change_state()
533 if (device->state < device->target) in dasd_change_state()
534 rc = dasd_increase_state(device); in dasd_change_state()
536 rc = dasd_decrease_state(device); in dasd_change_state()
540 device->target = device->state; in dasd_change_state()
542 /* let user-space know that the device status changed */ in dasd_change_state()
543 kobject_uevent(&device->cdev->dev.kobj, KOBJ_CHANGE); in dasd_change_state()
545 if (device->state == device->target) in dasd_change_state()
557 struct dasd_device *device = container_of(work, struct dasd_device, kick_work); in do_kick_device() local
558 mutex_lock(&device->state_mutex); in do_kick_device()
559 dasd_change_state(device); in do_kick_device()
560 mutex_unlock(&device->state_mutex); in do_kick_device()
561 dasd_schedule_device_bh(device); in do_kick_device()
562 dasd_put_device(device); in do_kick_device()
565 void dasd_kick_device(struct dasd_device *device) in dasd_kick_device() argument
567 dasd_get_device(device); in dasd_kick_device()
569 if (!schedule_work(&device->kick_work)) in dasd_kick_device()
570 dasd_put_device(device); in dasd_kick_device()
580 struct dasd_device *device = container_of(work, struct dasd_device, in do_reload_device() local
582 device->discipline->reload(device); in do_reload_device()
583 dasd_put_device(device); in do_reload_device()
586 void dasd_reload_device(struct dasd_device *device) in dasd_reload_device() argument
588 dasd_get_device(device); in dasd_reload_device()
590 if (!schedule_work(&device->reload_device)) in dasd_reload_device()
591 dasd_put_device(device); in dasd_reload_device()
596 * Set the target state for a device and starts the state change.
598 void dasd_set_target_state(struct dasd_device *device, int target) in dasd_set_target_state() argument
600 dasd_get_device(device); in dasd_set_target_state()
601 mutex_lock(&device->state_mutex); in dasd_set_target_state()
605 if (device->target != target) { in dasd_set_target_state()
606 if (device->state == target) in dasd_set_target_state()
608 device->target = target; in dasd_set_target_state()
610 if (device->state != device->target) in dasd_set_target_state()
611 dasd_change_state(device); in dasd_set_target_state()
612 mutex_unlock(&device->state_mutex); in dasd_set_target_state()
613 dasd_put_device(device); in dasd_set_target_state()
617 * Enable devices with device numbers in [from..to].
619 static inline int _wait_for_device(struct dasd_device *device) in _wait_for_device() argument
621 return (device->state == device->target); in _wait_for_device()
624 void dasd_enable_device(struct dasd_device *device) in dasd_enable_device() argument
626 dasd_set_target_state(device, DASD_STATE_ONLINE); in dasd_enable_device()
627 if (device->state <= DASD_STATE_KNOWN) in dasd_enable_device()
628 /* No discipline for device found. */ in dasd_enable_device()
629 dasd_set_target_state(device, DASD_STATE_NEW); in dasd_enable_device()
631 wait_event(dasd_init_waitq, _wait_for_device(device)); in dasd_enable_device()
633 dasd_reload_device(device); in dasd_enable_device()
634 if (device->discipline->kick_validate) in dasd_enable_device()
635 device->discipline->kick_validate(device); in dasd_enable_device()
640 * SECTION: device operation (interrupt handler, start i/o, term i/o ...)
660 struct dasd_device *device; in dasd_profile_start() local
686 * We count the request for the start device, even though it may run on in dasd_profile_start()
687 * some other device due to error recovery. This way we make sure that in dasd_profile_start()
690 device = cqr->startdev; in dasd_profile_start()
691 if (!device->profile.data) in dasd_profile_start()
694 spin_lock(get_ccwdev_lock(device->cdev)); in dasd_profile_start()
695 counter = 1; /* request is not yet queued on the start device */ in dasd_profile_start()
696 list_for_each(l, &device->ccw_queue) in dasd_profile_start()
699 spin_unlock(get_ccwdev_lock(device->cdev)); in dasd_profile_start()
701 spin_lock(&device->profile.lock); in dasd_profile_start()
702 device->profile.data->dasd_io_nr_req[counter]++; in dasd_profile_start()
704 device->profile.data->dasd_read_nr_req[counter]++; in dasd_profile_start()
705 spin_unlock(&device->profile.lock); in dasd_profile_start()
772 struct dasd_device *device; in dasd_profile_end() local
777 device = cqr->startdev; in dasd_profile_end()
780 device->profile.data)) in dasd_profile_end()
839 spin_lock(&device->profile.lock); in dasd_profile_end()
840 if (device->profile.data) { in dasd_profile_end()
841 data = device->profile.data; in dasd_profile_end()
846 dasd_profile_end_add_data(device->profile.data, in dasd_profile_end()
855 spin_unlock(&device->profile.lock); in dasd_profile_end()
1141 struct dasd_device *device; in dasd_hosts_show() local
1144 device = m->private; in dasd_hosts_show()
1145 dasd_get_device(device); in dasd_hosts_show()
1147 if (device->discipline->hosts_print) in dasd_hosts_show()
1148 rc = device->discipline->hosts_print(device, m); in dasd_hosts_show()
1150 dasd_put_device(device); in dasd_hosts_show()
1156 static void dasd_hosts_exit(struct dasd_device *device) in dasd_hosts_exit() argument
1158 debugfs_remove(device->hosts_dentry); in dasd_hosts_exit()
1159 device->hosts_dentry = NULL; in dasd_hosts_exit()
1163 struct dasd_device *device) in dasd_hosts_init() argument
1173 device, &dasd_hosts_fops); in dasd_hosts_init()
1175 device->hosts_dentry = pde; in dasd_hosts_init()
1179 struct dasd_device *device, in dasd_smalloc_request() argument
1193 spin_lock_irqsave(&device->mem_lock, flags); in dasd_smalloc_request()
1194 data = chunk = dasd_alloc_chunk(&device->ccw_chunks, size); in dasd_smalloc_request()
1195 spin_unlock_irqrestore(&device->mem_lock, flags); in dasd_smalloc_request()
1215 dasd_get_device(device); in dasd_smalloc_request()
1222 struct dasd_device *device) in dasd_fmalloc_request() argument
1236 spin_lock_irqsave(&device->mem_lock, flags); in dasd_fmalloc_request()
1237 cqr = dasd_alloc_chunk(&device->ese_chunks, size); in dasd_fmalloc_request()
1238 spin_unlock_irqrestore(&device->mem_lock, flags); in dasd_fmalloc_request()
1257 dasd_get_device(device); in dasd_fmalloc_request()
1263 void dasd_sfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device) in dasd_sfree_request() argument
1267 spin_lock_irqsave(&device->mem_lock, flags); in dasd_sfree_request()
1268 dasd_free_chunk(&device->ccw_chunks, cqr->mem_chunk); in dasd_sfree_request()
1269 spin_unlock_irqrestore(&device->mem_lock, flags); in dasd_sfree_request()
1270 dasd_put_device(device); in dasd_sfree_request()
1274 void dasd_ffree_request(struct dasd_ccw_req *cqr, struct dasd_device *device) in dasd_ffree_request() argument
1278 spin_lock_irqsave(&device->mem_lock, flags); in dasd_ffree_request()
1279 dasd_free_chunk(&device->ese_chunks, cqr); in dasd_ffree_request()
1280 spin_unlock_irqrestore(&device->mem_lock, flags); in dasd_ffree_request()
1281 dasd_put_device(device); in dasd_ffree_request()
1290 struct dasd_device *device; in dasd_check_cqr() local
1294 device = cqr->startdev; in dasd_check_cqr()
1295 if (strncmp((char *) &cqr->magic, device->discipline->ebcname, 4)) { in dasd_check_cqr()
1296 DBF_DEV_EVENT(DBF_WARNING, device, in dasd_check_cqr()
1300 *(unsigned int *) device->discipline->name); in dasd_check_cqr()
1308 * Timer keeps device runnig.
1314 struct dasd_device *device; in dasd_term_IO() local
1322 device = (struct dasd_device *) cqr->startdev; in dasd_term_IO()
1324 rc = ccw_device_clear(device->cdev, (long) cqr); in dasd_term_IO()
1330 DBF_DEV_EVENT(DBF_DEBUG, device, in dasd_term_IO()
1335 DBF_DEV_EVENT(DBF_ERR, device, "%s", in dasd_term_IO()
1336 "device gone, retry"); in dasd_term_IO()
1340 * device not valid so no I/O could be running in dasd_term_IO()
1348 DBF_DEV_EVENT(DBF_ERR, device, "%s", in dasd_term_IO()
1354 dev_err(&device->cdev->dev, in dasd_term_IO()
1361 dasd_schedule_device_bh(device); in dasd_term_IO()
1372 struct dasd_device *device; in dasd_start_IO() local
1381 device = (struct dasd_device *) cqr->startdev; in dasd_start_IO()
1384 test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags)) && in dasd_start_IO()
1386 DBF_DEV_EVENT(DBF_DEBUG, device, "start_IO: return request %p " in dasd_start_IO()
1393 dev_err(&device->cdev->dev, in dasd_start_IO()
1402 cqr->lpm &= dasd_path_get_opm(device); in dasd_start_IO()
1404 cqr->lpm = dasd_path_get_opm(device); in dasd_start_IO()
1414 rc = ccw_device_tm_start(device->cdev, cqr->cpaddr, in dasd_start_IO()
1417 rc = ccw_device_start(device->cdev, cqr->cpaddr, in dasd_start_IO()
1425 DBF_DEV_EVENT(DBF_WARNING, device, "%s", in dasd_start_IO()
1426 "start_IO: device busy, retry later"); in dasd_start_IO()
1437 DBF_DEV_EVENT(DBF_WARNING, device, in dasd_start_IO()
1440 } else if (cqr->lpm != dasd_path_get_opm(device)) { in dasd_start_IO()
1441 cqr->lpm = dasd_path_get_opm(device); in dasd_start_IO()
1442 DBF_DEV_EVENT(DBF_DEBUG, device, "%s", in dasd_start_IO()
1446 DBF_DEV_EVENT(DBF_WARNING, device, "%s", in dasd_start_IO()
1449 dasd_generic_last_path_gone(device); in dasd_start_IO()
1450 dasd_path_no_path(device); in dasd_start_IO()
1451 dasd_path_set_tbvpm(device, in dasd_start_IO()
1453 device->cdev)); in dasd_start_IO()
1457 DBF_DEV_EVENT(DBF_WARNING, device, "%s", in dasd_start_IO()
1458 "start_IO: -ENODEV device gone, retry"); in dasd_start_IO()
1460 dasd_handle_autoquiesce(device, cqr, DASD_EER_STARTIO); in dasd_start_IO()
1463 DBF_DEV_EVENT(DBF_WARNING, device, "%s", in dasd_start_IO()
1464 "start_IO: -EIO device gone, retry"); in dasd_start_IO()
1467 DBF_DEV_EVENT(DBF_WARNING, device, "%s", in dasd_start_IO()
1468 "start_IO: -EINVAL device currently " in dasd_start_IO()
1472 dev_err(&device->cdev->dev, in dasd_start_IO()
1493 struct dasd_device *device; in dasd_device_timeout() local
1495 device = from_timer(device, t, timer); in dasd_device_timeout()
1496 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); in dasd_device_timeout()
1498 dasd_device_remove_stop_bits(device, DASD_STOPPED_PENDING); in dasd_device_timeout()
1499 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); in dasd_device_timeout()
1500 dasd_schedule_device_bh(device); in dasd_device_timeout()
1504 * Setup timeout for a device in jiffies.
1506 void dasd_device_set_timer(struct dasd_device *device, int expires) in dasd_device_set_timer() argument
1509 del_timer(&device->timer); in dasd_device_set_timer()
1511 mod_timer(&device->timer, jiffies + expires); in dasd_device_set_timer()
1516 * Clear timeout for a device.
1518 void dasd_device_clear_timer(struct dasd_device *device) in dasd_device_clear_timer() argument
1520 del_timer(&device->timer); in dasd_device_clear_timer()
1528 struct dasd_device *device; in dasd_handle_killed_request() local
1540 device = dasd_device_from_cdev_locked(cdev); in dasd_handle_killed_request()
1541 if (IS_ERR(device)) { in dasd_handle_killed_request()
1543 "unable to get device from cdev"); in dasd_handle_killed_request()
1548 device != cqr->startdev || in dasd_handle_killed_request()
1552 "invalid device in request"); in dasd_handle_killed_request()
1553 dasd_put_device(device); in dasd_handle_killed_request()
1560 dasd_device_clear_timer(device); in dasd_handle_killed_request()
1561 dasd_schedule_device_bh(device); in dasd_handle_killed_request()
1562 dasd_put_device(device); in dasd_handle_killed_request()
1565 void dasd_generic_handle_state_change(struct dasd_device *device) in dasd_generic_handle_state_change() argument
1568 dasd_eer_snss(device); in dasd_generic_handle_state_change()
1570 dasd_device_remove_stop_bits(device, DASD_STOPPED_PENDING); in dasd_generic_handle_state_change()
1571 dasd_schedule_device_bh(device); in dasd_generic_handle_state_change()
1572 if (device->block) { in dasd_generic_handle_state_change()
1573 dasd_schedule_block_bh(device->block); in dasd_generic_handle_state_change()
1574 if (device->block->gdp) in dasd_generic_handle_state_change()
1575 blk_mq_run_hw_queues(device->block->gdp->queue, true); in dasd_generic_handle_state_change()
1589 struct dasd_device *device = NULL; in dasd_ese_needs_format() local
1594 device = block->base; in dasd_ese_needs_format()
1595 if (!device || !device->discipline->is_ese) in dasd_ese_needs_format()
1597 if (!device->discipline->is_ese(device)) in dasd_ese_needs_format()
1630 struct dasd_device *device; in dasd_int_handler() local
1643 device = cqr->startdev; in dasd_int_handler()
1645 dasd_device_clear_timer(device); in dasd_int_handler()
1647 dasd_schedule_device_bh(device); in dasd_int_handler()
1671 device = dasd_device_from_cdev_locked(cdev); in dasd_int_handler()
1672 if (IS_ERR(device)) in dasd_int_handler()
1675 if (device->discipline == dasd_diag_discipline_pointer) { in dasd_int_handler()
1676 dasd_put_device(device); in dasd_int_handler()
1696 * Stop device and check exhaust level. in dasd_int_handler()
1699 dasd_generic_space_exhaust(device, cqr); in dasd_int_handler()
1700 device->discipline->ext_pool_exhaust(device, cqr); in dasd_int_handler()
1701 dasd_put_device(device); in dasd_int_handler()
1706 device->discipline->dump_sense_dbf(device, irb, "int"); in dasd_int_handler()
1708 if (device->features & DASD_FEATURE_ERPLOG) in dasd_int_handler()
1709 device->discipline->dump_sense(device, cqr, irb); in dasd_int_handler()
1710 device->discipline->check_for_device_change(device, cqr, irb); in dasd_int_handler()
1711 dasd_put_device(device); in dasd_int_handler()
1716 device = dasd_device_from_cdev_locked(cdev); in dasd_int_handler()
1717 if (!IS_ERR(device)) { in dasd_int_handler()
1718 device->discipline->check_attention(device, in dasd_int_handler()
1720 dasd_put_device(device); in dasd_int_handler()
1727 device = (struct dasd_device *) cqr->startdev; in dasd_int_handler()
1728 if (!device || in dasd_int_handler()
1729 strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) { in dasd_int_handler()
1731 "invalid device in request"); in dasd_int_handler()
1742 device->discipline->ese_read(cqr, irb); in dasd_int_handler()
1745 dasd_device_clear_timer(device); in dasd_int_handler()
1746 dasd_schedule_device_bh(device); in dasd_int_handler()
1749 fcqr = device->discipline->ese_format(device, cqr, irb); in dasd_int_handler()
1760 dasd_schedule_device_bh(device); in dasd_int_handler()
1765 list_add(&fcqr->devlist, &device->ccw_queue); in dasd_int_handler()
1766 dasd_schedule_device_bh(device); in dasd_int_handler()
1775 dasd_device_clear_timer(device); in dasd_int_handler()
1777 dasd_schedule_device_bh(device); in dasd_int_handler()
1783 DBF_DEV_EVENT(DBF_DEBUG, device, "invalid status: bus_id %s, " in dasd_int_handler()
1796 if (cqr->devlist.next != &device->ccw_queue) { in dasd_int_handler()
1806 device->discipline->handle_hpf_error) in dasd_int_handler()
1807 device->discipline->handle_hpf_error(device, irb); in dasd_int_handler()
1814 if (cqr->lpm == dasd_path_get_opm(device)) in dasd_int_handler()
1815 DBF_DEV_EVENT(DBF_DEBUG, device, in dasd_int_handler()
1820 cqr->lpm = dasd_path_get_opm(device); in dasd_int_handler()
1827 (!device->stopped)) { in dasd_int_handler()
1828 if (device->discipline->start_IO(next) == 0) in dasd_int_handler()
1832 dasd_device_set_timer(device, expires); in dasd_int_handler()
1834 dasd_device_clear_timer(device); in dasd_int_handler()
1835 dasd_schedule_device_bh(device); in dasd_int_handler()
1841 struct dasd_device *device; in dasd_generic_uc_handler() local
1843 device = dasd_device_from_cdev_locked(cdev); in dasd_generic_uc_handler()
1845 if (IS_ERR(device)) in dasd_generic_uc_handler()
1847 if (test_bit(DASD_FLAG_OFFLINE, &device->flags) || in dasd_generic_uc_handler()
1848 device->state != device->target || in dasd_generic_uc_handler()
1849 !device->discipline->check_for_device_change){ in dasd_generic_uc_handler()
1850 dasd_put_device(device); in dasd_generic_uc_handler()
1853 if (device->discipline->dump_sense_dbf) in dasd_generic_uc_handler()
1854 device->discipline->dump_sense_dbf(device, irb, "uc"); in dasd_generic_uc_handler()
1855 device->discipline->check_for_device_change(device, NULL, irb); in dasd_generic_uc_handler()
1856 dasd_put_device(device); in dasd_generic_uc_handler()
1866 static void __dasd_device_recovery(struct dasd_device *device, in __dasd_device_recovery() argument
1878 list_for_each_safe(l, n, &device->ccw_queue) { in __dasd_device_recovery()
1891 static void __dasd_device_process_ccw_queue(struct dasd_device *device, in __dasd_device_process_ccw_queue() argument
1898 list_for_each_safe(l, n, &device->ccw_queue) { in __dasd_device_process_ccw_queue()
1907 __dasd_device_recovery(device, cqr); in __dasd_device_process_ccw_queue()
1914 static void __dasd_process_cqr(struct dasd_device *device, in __dasd_process_cqr() argument
1928 dev_err(&device->cdev->dev, in __dasd_process_cqr()
1940 static void __dasd_device_process_final_queue(struct dasd_device *device, in __dasd_device_process_final_queue() argument
1952 __dasd_process_cqr(device, cqr); in __dasd_device_process_final_queue()
1955 __dasd_process_cqr(device, cqr); in __dasd_device_process_final_queue()
1962 * check if device should be autoquiesced due to too many timeouts
1964 static void __dasd_device_check_autoquiesce_timeout(struct dasd_device *device, in __dasd_device_check_autoquiesce_timeout() argument
1967 if ((device->default_retries - cqr->retries) >= device->aq_timeouts) in __dasd_device_check_autoquiesce_timeout()
1968 dasd_handle_autoquiesce(device, cqr, DASD_EER_TIMEOUTS); in __dasd_device_check_autoquiesce_timeout()
1975 static void __dasd_device_check_expire(struct dasd_device *device) in __dasd_device_check_expire() argument
1979 if (list_empty(&device->ccw_queue)) in __dasd_device_check_expire()
1981 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); in __dasd_device_check_expire()
1984 if (test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) { in __dasd_device_check_expire()
1991 if (device->discipline->term_IO(cqr) != 0) { in __dasd_device_check_expire()
1993 dev_err(&device->cdev->dev, in __dasd_device_check_expire()
1997 dasd_device_set_timer(device, 5*HZ); in __dasd_device_check_expire()
1999 dev_err(&device->cdev->dev, in __dasd_device_check_expire()
2003 __dasd_device_check_autoquiesce_timeout(device, cqr); in __dasd_device_check_expire()
2008 * return 1 when device is not eligible for IO
2010 static int __dasd_device_is_unusable(struct dasd_device *device, in __dasd_device_is_unusable() argument
2015 if (test_bit(DASD_FLAG_OFFLINE, &device->flags) && in __dasd_device_is_unusable()
2016 !test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) { in __dasd_device_is_unusable()
2023 if (device->stopped) { in __dasd_device_is_unusable()
2024 if (device->stopped & mask) { in __dasd_device_is_unusable()
2029 /* CQR is not able to change device to in __dasd_device_is_unusable()
2033 /* CQR required to get device operational. */ in __dasd_device_is_unusable()
2042 static void __dasd_device_start_head(struct dasd_device *device) in __dasd_device_start_head() argument
2047 if (list_empty(&device->ccw_queue)) in __dasd_device_start_head()
2049 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); in __dasd_device_start_head()
2052 /* if device is not usable return request to upper layer */ in __dasd_device_start_head()
2053 if (__dasd_device_is_unusable(device, cqr)) { in __dasd_device_start_head()
2056 dasd_schedule_device_bh(device); in __dasd_device_start_head()
2060 rc = device->discipline->start_IO(cqr); in __dasd_device_start_head()
2062 dasd_device_set_timer(device, cqr->expires); in __dasd_device_start_head()
2064 dasd_schedule_device_bh(device); in __dasd_device_start_head()
2067 dasd_device_set_timer(device, 50); in __dasd_device_start_head()
2070 static void __dasd_device_check_path_events(struct dasd_device *device) in __dasd_device_check_path_events() argument
2075 tbvpm = dasd_path_get_tbvpm(device); in __dasd_device_check_path_events()
2076 fcsecpm = dasd_path_get_fcsecpm(device); in __dasd_device_check_path_events()
2081 if (device->stopped & ~(DASD_STOPPED_DC_WAIT)) in __dasd_device_check_path_events()
2084 dasd_path_clear_all_verify(device); in __dasd_device_check_path_events()
2085 dasd_path_clear_all_fcsec(device); in __dasd_device_check_path_events()
2087 rc = device->discipline->pe_handler(device, tbvpm, fcsecpm); in __dasd_device_check_path_events()
2089 dasd_path_add_tbvpm(device, tbvpm); in __dasd_device_check_path_events()
2090 dasd_path_add_fcsecpm(device, fcsecpm); in __dasd_device_check_path_events()
2091 dasd_device_set_timer(device, 50); in __dasd_device_check_path_events()
2101 * this function is called!. In other words, when 'device' is a base
2102 * device then all block layer requests must have been removed before
2105 int dasd_flush_device_queue(struct dasd_device *device) in dasd_flush_device_queue() argument
2112 spin_lock_irq(get_ccwdev_lock(device->cdev)); in dasd_flush_device_queue()
2114 list_for_each_entry_safe(cqr, n, &device->ccw_queue, devlist) { in dasd_flush_device_queue()
2118 rc = device->discipline->term_IO(cqr); in dasd_flush_device_queue()
2121 dev_err(&device->cdev->dev, in dasd_flush_device_queue()
2137 spin_unlock_irq(get_ccwdev_lock(device->cdev)); in dasd_flush_device_queue()
2150 __dasd_device_process_final_queue(device, &flush_queue); in dasd_flush_device_queue()
2156 * Acquire the device lock and process queues for the device.
2160 struct dasd_device *device = (struct dasd_device *) data; in dasd_device_tasklet() local
2163 atomic_set (&device->tasklet_scheduled, 0); in dasd_device_tasklet()
2165 spin_lock_irq(get_ccwdev_lock(device->cdev)); in dasd_device_tasklet()
2167 __dasd_device_check_expire(device); in dasd_device_tasklet()
2169 __dasd_device_process_ccw_queue(device, &final_queue); in dasd_device_tasklet()
2170 __dasd_device_check_path_events(device); in dasd_device_tasklet()
2171 spin_unlock_irq(get_ccwdev_lock(device->cdev)); in dasd_device_tasklet()
2173 __dasd_device_process_final_queue(device, &final_queue); in dasd_device_tasklet()
2174 spin_lock_irq(get_ccwdev_lock(device->cdev)); in dasd_device_tasklet()
2176 __dasd_device_start_head(device); in dasd_device_tasklet()
2177 spin_unlock_irq(get_ccwdev_lock(device->cdev)); in dasd_device_tasklet()
2180 dasd_put_device(device); in dasd_device_tasklet()
2184 * Schedules a call to dasd_tasklet over the device tasklet.
2186 void dasd_schedule_device_bh(struct dasd_device *device) in dasd_schedule_device_bh() argument
2189 if (atomic_cmpxchg (&device->tasklet_scheduled, 0, 1) != 0) in dasd_schedule_device_bh()
2191 dasd_get_device(device); in dasd_schedule_device_bh()
2192 tasklet_hi_schedule(&device->tasklet); in dasd_schedule_device_bh()
2196 void dasd_device_set_stop_bits(struct dasd_device *device, int bits) in dasd_device_set_stop_bits() argument
2198 device->stopped |= bits; in dasd_device_set_stop_bits()
2202 void dasd_device_remove_stop_bits(struct dasd_device *device, int bits) in dasd_device_remove_stop_bits() argument
2204 device->stopped &= ~bits; in dasd_device_remove_stop_bits()
2205 if (!device->stopped) in dasd_device_remove_stop_bits()
2211 * Queue a request to the head of the device ccw_queue.
2216 struct dasd_device *device; in dasd_add_request_head() local
2219 device = cqr->startdev; in dasd_add_request_head()
2220 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); in dasd_add_request_head()
2222 list_add(&cqr->devlist, &device->ccw_queue); in dasd_add_request_head()
2224 dasd_schedule_device_bh(device); in dasd_add_request_head()
2225 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); in dasd_add_request_head()
2230 * Queue a request to the tail of the device ccw_queue.
2235 struct dasd_device *device; in dasd_add_request_tail() local
2238 device = cqr->startdev; in dasd_add_request_tail()
2239 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); in dasd_add_request_tail()
2241 list_add_tail(&cqr->devlist, &device->ccw_queue); in dasd_add_request_tail()
2243 dasd_schedule_device_bh(device); in dasd_add_request_tail()
2244 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); in dasd_add_request_tail()
2262 struct dasd_device *device; in _wait_for_wakeup() local
2265 device = cqr->startdev; in _wait_for_wakeup()
2266 spin_lock_irq(get_ccwdev_lock(device->cdev)); in _wait_for_wakeup()
2268 spin_unlock_irq(get_ccwdev_lock(device->cdev)); in _wait_for_wakeup()
2277 struct dasd_device *device; in __dasd_sleep_on_erp() local
2282 device = cqr->startdev; in __dasd_sleep_on_erp()
2285 device->discipline->handle_terminated_request(cqr); in __dasd_sleep_on_erp()
2289 erp_fn = device->discipline->erp_action(cqr); in __dasd_sleep_on_erp()
2296 __dasd_process_erp(device, cqr); in __dasd_sleep_on_erp()
2316 struct dasd_device *device; in _dasd_sleep_on() local
2323 device = maincqr->startdev; in _dasd_sleep_on()
2333 if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags) && in _dasd_sleep_on()
2340 if (device->stopped & ~DASD_STOPPED_PENDING && in _dasd_sleep_on()
2342 !dasd_eer_enabled(device) && device->aq_mask == 0) { in _dasd_sleep_on()
2348 * Don't try to start requests if device is in in _dasd_sleep_on()
2351 if (test_bit(DASD_FLAG_OFFLINE, &device->flags)) { in _dasd_sleep_on()
2357 * Don't try to start requests if device is stopped in _dasd_sleep_on()
2363 generic_waitq, !(device->stopped)); in _dasd_sleep_on()
2370 wait_event(generic_waitq, !(device->stopped)); in _dasd_sleep_on()
2420 struct dasd_device *device; in _dasd_sleep_on_queue() local
2427 device = cqr->startdev; in _dasd_sleep_on_queue()
2431 if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags) && in _dasd_sleep_on_queue()
2438 if (device->stopped & ~DASD_STOPPED_PENDING && in _dasd_sleep_on_queue()
2440 !dasd_eer_enabled(device)) { in _dasd_sleep_on_queue()
2446 /*Don't try to start requests if device is stopped*/ in _dasd_sleep_on_queue()
2449 generic_waitq, !device->stopped); in _dasd_sleep_on_queue()
2456 wait_event(generic_waitq, !(device->stopped)); in _dasd_sleep_on_queue()
2505 * Queue a request to the tail of the device ccw_queue and wait for
2533 * Queue a request to the tail of the device ccw_queue and wait
2548 static inline int _dasd_term_running_cqr(struct dasd_device *device) in _dasd_term_running_cqr() argument
2553 if (list_empty(&device->ccw_queue)) in _dasd_term_running_cqr()
2555 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); in _dasd_term_running_cqr()
2556 rc = device->discipline->term_IO(cqr); in _dasd_term_running_cqr()
2569 struct dasd_device *device; in dasd_sleep_on_immediatly() local
2572 device = cqr->startdev; in dasd_sleep_on_immediatly()
2573 if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags) && in dasd_sleep_on_immediatly()
2579 spin_lock_irq(get_ccwdev_lock(device->cdev)); in dasd_sleep_on_immediatly()
2580 rc = _dasd_term_running_cqr(device); in dasd_sleep_on_immediatly()
2582 spin_unlock_irq(get_ccwdev_lock(device->cdev)); in dasd_sleep_on_immediatly()
2592 list_add(&cqr->devlist, device->ccw_queue.next); in dasd_sleep_on_immediatly()
2595 dasd_schedule_device_bh(device); in dasd_sleep_on_immediatly()
2597 spin_unlock_irq(get_ccwdev_lock(device->cdev)); in dasd_sleep_on_immediatly()
2609 dasd_schedule_device_bh(device); in dasd_sleep_on_immediatly()
2610 if (device->block) in dasd_sleep_on_immediatly()
2611 dasd_schedule_block_bh(device->block); in dasd_sleep_on_immediatly()
2628 struct dasd_device *device = cqr->startdev; in __dasd_cancel_req() local
2638 rc = device->discipline->term_IO(cqr); in __dasd_cancel_req()
2640 dev_err(&device->cdev->dev, in __dasd_cancel_req()
2649 dasd_schedule_device_bh(device); in __dasd_cancel_req()
2655 struct dasd_device *device = cqr->startdev; in dasd_cancel_req() local
2659 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); in dasd_cancel_req()
2661 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); in dasd_cancel_req()
2712 static void __dasd_process_erp(struct dasd_device *device, in __dasd_process_erp() argument
2718 DBF_DEV_EVENT(DBF_NOTICE, device, "%s", "ERP successful"); in __dasd_process_erp()
2720 dev_err(&device->cdev->dev, "ERP failed for the DASD\n"); in __dasd_process_erp()
2721 erp_fn = device->discipline->erp_postaction(cqr); in __dasd_process_erp()
2884 /* Don't try to start requests if device is stopped */ in __dasd_block_start_head()
3038 * Schedules a call to dasd_tasklet over the device tasklet.
3045 /* life cycle of block is bound to it's base device */ in dasd_schedule_block_bh()
3053 * SECTION: external block device operations
3075 "device not ready for request %p", req); in do_dasd_request()
3081 * if device is stopped do not fetch new requests in do_dasd_request()
3087 "device stopped request %p", req); in do_dasd_request()
3155 struct dasd_device *device; in dasd_times_out() local
3165 device = cqr->startdev ? cqr->startdev : block->base; in dasd_times_out()
3166 if (!device->blk_timeout) { in dasd_times_out()
3170 DBF_DEV_EVENT(DBF_WARNING, device, in dasd_times_out()
3175 spin_lock(get_ccwdev_lock(device->cdev)); in dasd_times_out()
3212 spin_unlock(get_ccwdev_lock(device->cdev)); in dasd_times_out()
3284 " Cannot open unrecognized device"); in dasd_open()
3349 * end of block device operations
3375 * Is the device read-only?
3377 * readonly device attribute, but how it is configured in z/VM.
3379 int dasd_device_is_ro(struct dasd_device *device) in dasd_device_is_ro() argument
3387 ccw_device_get_id(device->cdev, &dev_id); in dasd_device_is_ro()
3432 void dasd_generic_free_discipline(struct dasd_device *device) in dasd_generic_free_discipline() argument
3435 if (device->discipline) { in dasd_generic_free_discipline()
3436 if (device->discipline->uncheck_device) in dasd_generic_free_discipline()
3437 device->discipline->uncheck_device(device); in dasd_generic_free_discipline()
3438 module_put(device->discipline->owner); in dasd_generic_free_discipline()
3439 device->discipline = NULL; in dasd_generic_free_discipline()
3441 if (device->base_discipline) { in dasd_generic_free_discipline()
3442 module_put(device->base_discipline->owner); in dasd_generic_free_discipline()
3443 device->base_discipline = NULL; in dasd_generic_free_discipline()
3454 struct dasd_device *device; in dasd_generic_remove() local
3457 device = dasd_device_from_cdev(cdev); in dasd_generic_remove()
3458 if (IS_ERR(device)) in dasd_generic_remove()
3461 if (test_and_set_bit(DASD_FLAG_OFFLINE, &device->flags) && in dasd_generic_remove()
3462 !test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) { in dasd_generic_remove()
3464 dasd_put_device(device); in dasd_generic_remove()
3468 * This device is removed unconditionally. Set offline in dasd_generic_remove()
3472 dasd_set_target_state(device, DASD_STATE_NEW); in dasd_generic_remove()
3474 /* dasd_delete_device destroys the device reference. */ in dasd_generic_remove()
3475 block = device->block; in dasd_generic_remove()
3476 dasd_delete_device(device); in dasd_generic_remove()
3478 * life cycle of block is bound to device, so delete it after in dasd_generic_remove()
3479 * device was safely removed in dasd_generic_remove()
3487 * Activate a device. This is called from dasd_{eckd,fba}_probe() when either
3488 * the device is detected for the first time and is supposed to be used
3495 struct dasd_device *device; in dasd_generic_set_online() local
3496 struct device *dev; in dasd_generic_set_online()
3503 device = dasd_create_device(cdev); in dasd_generic_set_online()
3504 if (IS_ERR(device)) in dasd_generic_set_online()
3505 return PTR_ERR(device); in dasd_generic_set_online()
3508 if (device->features & DASD_FEATURE_USEDIAG) { in dasd_generic_set_online()
3517 dasd_delete_device(device); in dasd_generic_set_online()
3525 dasd_delete_device(device); in dasd_generic_set_online()
3531 dasd_delete_device(device); in dasd_generic_set_online()
3534 device->base_discipline = base_discipline; in dasd_generic_set_online()
3536 dasd_delete_device(device); in dasd_generic_set_online()
3539 device->discipline = discipline; in dasd_generic_set_online()
3541 /* check_device will allocate block device if necessary */ in dasd_generic_set_online()
3542 rc = discipline->check_device(device); in dasd_generic_set_online()
3546 dasd_delete_device(device); in dasd_generic_set_online()
3550 dasd_set_target_state(device, DASD_STATE_ONLINE); in dasd_generic_set_online()
3551 if (device->state <= DASD_STATE_KNOWN) { in dasd_generic_set_online()
3554 dasd_set_target_state(device, DASD_STATE_NEW); in dasd_generic_set_online()
3555 if (device->block) in dasd_generic_set_online()
3556 dasd_free_block(device->block); in dasd_generic_set_online()
3557 dasd_delete_device(device); in dasd_generic_set_online()
3559 dev_dbg(dev, "dasd_generic device found\n"); in dasd_generic_set_online()
3562 wait_event(dasd_init_waitq, _wait_for_device(device)); in dasd_generic_set_online()
3564 dasd_put_device(device); in dasd_generic_set_online()
3572 struct dasd_device *device; in dasd_generic_set_offline() local
3575 struct device *dev; in dasd_generic_set_offline()
3581 device = dasd_device_from_cdev_locked(cdev); in dasd_generic_set_offline()
3582 if (IS_ERR(device)) { in dasd_generic_set_offline()
3584 return PTR_ERR(device); in dasd_generic_set_offline()
3588 * We must make sure that this device is currently not in use. in dasd_generic_set_offline()
3593 if (device->block) { in dasd_generic_set_offline()
3594 max_count = device->block->bdev_file ? 0 : -1; in dasd_generic_set_offline()
3595 open_count = atomic_read(&device->block->open_count); in dasd_generic_set_offline()
3613 if (test_bit(DASD_FLAG_OFFLINE, &device->flags)) { in dasd_generic_set_offline()
3614 if (test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) { in dasd_generic_set_offline()
3616 &device->flags); in dasd_generic_set_offline()
3622 set_bit(DASD_FLAG_OFFLINE, &device->flags); in dasd_generic_set_offline()
3629 if (test_and_clear_bit(DASD_FLAG_SAFE_OFFLINE, &device->flags) && in dasd_generic_set_offline()
3630 !test_and_set_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) { in dasd_generic_set_offline()
3634 * If we want to set the device safe offline all IO operations in dasd_generic_set_offline()
3639 if (device->block && device->block->bdev_file) in dasd_generic_set_offline()
3640 bdev_mark_dead(file_bdev(device->block->bdev_file), false); in dasd_generic_set_offline()
3641 dasd_schedule_device_bh(device); in dasd_generic_set_offline()
3643 _wait_for_empty_queues(device)); in dasd_generic_set_offline()
3655 if (!test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) { in dasd_generic_set_offline()
3659 clear_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags); in dasd_generic_set_offline()
3663 dasd_set_target_state(device, DASD_STATE_NEW); in dasd_generic_set_offline()
3664 /* dasd_delete_device destroys the device reference. */ in dasd_generic_set_offline()
3665 block = device->block; in dasd_generic_set_offline()
3666 dasd_delete_device(device); in dasd_generic_set_offline()
3668 * life cycle of block is bound to device, so delete it after in dasd_generic_set_offline()
3669 * device was safely removed in dasd_generic_set_offline()
3679 clear_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags); in dasd_generic_set_offline()
3680 clear_bit(DASD_FLAG_OFFLINE, &device->flags); in dasd_generic_set_offline()
3682 dasd_put_device(device); in dasd_generic_set_offline()
3688 int dasd_generic_last_path_gone(struct dasd_device *device) in dasd_generic_last_path_gone() argument
3692 dev_warn(&device->cdev->dev, "No operational channel path is left " in dasd_generic_last_path_gone()
3693 "for the device\n"); in dasd_generic_last_path_gone()
3694 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "last path gone"); in dasd_generic_last_path_gone()
3696 dasd_handle_autoquiesce(device, NULL, DASD_EER_NOPATH); in dasd_generic_last_path_gone()
3698 if (device->state < DASD_STATE_BASIC) in dasd_generic_last_path_gone()
3700 /* Device is active. We want to keep it. */ in dasd_generic_last_path_gone()
3701 list_for_each_entry(cqr, &device->ccw_queue, devlist) in dasd_generic_last_path_gone()
3707 dasd_device_set_stop_bits(device, DASD_STOPPED_DC_WAIT); in dasd_generic_last_path_gone()
3708 dasd_device_clear_timer(device); in dasd_generic_last_path_gone()
3709 dasd_schedule_device_bh(device); in dasd_generic_last_path_gone()
3714 int dasd_generic_path_operational(struct dasd_device *device) in dasd_generic_path_operational() argument
3716 dev_info(&device->cdev->dev, "A channel path to the device has become " in dasd_generic_path_operational()
3718 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "path operational"); in dasd_generic_path_operational()
3719 dasd_device_remove_stop_bits(device, DASD_STOPPED_DC_WAIT); in dasd_generic_path_operational()
3720 dasd_schedule_device_bh(device); in dasd_generic_path_operational()
3721 if (device->block) { in dasd_generic_path_operational()
3722 dasd_schedule_block_bh(device->block); in dasd_generic_path_operational()
3723 if (device->block->gdp) in dasd_generic_path_operational()
3724 blk_mq_run_hw_queues(device->block->gdp->queue, true); in dasd_generic_path_operational()
3727 if (!device->stopped) in dasd_generic_path_operational()
3736 struct dasd_device *device; in dasd_generic_notify() local
3739 device = dasd_device_from_cdev_locked(cdev); in dasd_generic_notify()
3740 if (IS_ERR(device)) in dasd_generic_notify()
3747 dasd_path_no_path(device); in dasd_generic_notify()
3748 ret = dasd_generic_last_path_gone(device); in dasd_generic_notify()
3752 if (dasd_path_get_opm(device)) in dasd_generic_notify()
3753 ret = dasd_generic_path_operational(device); in dasd_generic_notify()
3756 dasd_put_device(device); in dasd_generic_notify()
3763 struct dasd_device *device; in dasd_generic_path_event() local
3766 device = dasd_device_from_cdev_locked(cdev); in dasd_generic_path_event()
3767 if (IS_ERR(device)) in dasd_generic_path_event()
3770 oldopm = dasd_path_get_opm(device); in dasd_generic_path_event()
3773 dasd_path_notoper(device, chp); in dasd_generic_path_event()
3776 dasd_path_available(device, chp); in dasd_generic_path_event()
3777 dasd_schedule_device_bh(device); in dasd_generic_path_event()
3780 if (!dasd_path_is_operational(device, chp) && in dasd_generic_path_event()
3781 !dasd_path_need_verify(device, chp)) { in dasd_generic_path_event()
3787 dasd_path_available(device, chp); in dasd_generic_path_event()
3788 dasd_schedule_device_bh(device); in dasd_generic_path_event()
3790 DBF_DEV_EVENT(DBF_WARNING, device, "%s", in dasd_generic_path_event()
3792 if (device->discipline->kick_validate) in dasd_generic_path_event()
3793 device->discipline->kick_validate(device); in dasd_generic_path_event()
3796 dasd_path_fcsec_update(device, chp); in dasd_generic_path_event()
3797 dasd_schedule_device_bh(device); in dasd_generic_path_event()
3800 hpfpm = dasd_path_get_hpfpm(device); in dasd_generic_path_event()
3801 ifccpm = dasd_path_get_ifccpm(device); in dasd_generic_path_event()
3802 if (!dasd_path_get_opm(device) && hpfpm) { in dasd_generic_path_event()
3804 * device has no operational paths but at least one path is in dasd_generic_path_event()
3808 if (device->discipline->disable_hpf) in dasd_generic_path_event()
3809 device->discipline->disable_hpf(device); in dasd_generic_path_event()
3810 dasd_device_set_stop_bits(device, DASD_STOPPED_NOT_ACC); in dasd_generic_path_event()
3811 dasd_path_set_tbvpm(device, hpfpm); in dasd_generic_path_event()
3812 dasd_schedule_device_bh(device); in dasd_generic_path_event()
3813 dasd_schedule_requeue(device); in dasd_generic_path_event()
3814 } else if (!dasd_path_get_opm(device) && ifccpm) { in dasd_generic_path_event()
3816 * device has no operational paths but at least one path is in dasd_generic_path_event()
3820 dasd_path_set_tbvpm(device, ifccpm); in dasd_generic_path_event()
3821 dasd_schedule_device_bh(device); in dasd_generic_path_event()
3823 if (oldopm && !dasd_path_get_opm(device) && !hpfpm && !ifccpm) { in dasd_generic_path_event()
3824 dev_warn(&device->cdev->dev, in dasd_generic_path_event()
3825 "No verified channel paths remain for the device\n"); in dasd_generic_path_event()
3826 DBF_DEV_EVENT(DBF_WARNING, device, in dasd_generic_path_event()
3829 dasd_handle_autoquiesce(device, NULL, DASD_EER_NOPATH); in dasd_generic_path_event()
3830 dasd_device_set_stop_bits(device, in dasd_generic_path_event()
3833 dasd_put_device(device); in dasd_generic_path_event()
3837 int dasd_generic_verify_path(struct dasd_device *device, __u8 lpm) in dasd_generic_verify_path() argument
3839 if (!dasd_path_get_opm(device) && lpm) { in dasd_generic_verify_path()
3840 dasd_path_set_opm(device, lpm); in dasd_generic_verify_path()
3841 dasd_generic_path_operational(device); in dasd_generic_verify_path()
3843 dasd_path_add_opm(device, lpm); in dasd_generic_verify_path()
3848 void dasd_generic_space_exhaust(struct dasd_device *device, in dasd_generic_space_exhaust() argument
3852 dasd_handle_autoquiesce(device, NULL, DASD_EER_NOSPC); in dasd_generic_space_exhaust()
3854 if (device->state < DASD_STATE_BASIC) in dasd_generic_space_exhaust()
3862 dasd_device_set_stop_bits(device, DASD_STOPPED_NOSPC); in dasd_generic_space_exhaust()
3863 dasd_device_clear_timer(device); in dasd_generic_space_exhaust()
3864 dasd_schedule_device_bh(device); in dasd_generic_space_exhaust()
3868 void dasd_generic_space_avail(struct dasd_device *device) in dasd_generic_space_avail() argument
3870 dev_info(&device->cdev->dev, "Extent pool space is available\n"); in dasd_generic_space_avail()
3871 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "space available"); in dasd_generic_space_avail()
3873 dasd_device_remove_stop_bits(device, DASD_STOPPED_NOSPC); in dasd_generic_space_avail()
3874 dasd_schedule_device_bh(device); in dasd_generic_space_avail()
3876 if (device->block) { in dasd_generic_space_avail()
3877 dasd_schedule_block_bh(device->block); in dasd_generic_space_avail()
3878 if (device->block->gdp) in dasd_generic_space_avail()
3879 blk_mq_run_hw_queues(device->block->gdp->queue, true); in dasd_generic_space_avail()
3881 if (!device->stopped) in dasd_generic_space_avail()
3889 int dasd_generic_requeue_all_requests(struct dasd_device *device) in dasd_generic_requeue_all_requests() argument
3891 struct dasd_block *block = device->block; in dasd_generic_requeue_all_requests()
3921 dasd_schedule_device_bh(device); in dasd_generic_requeue_all_requests()
3928 struct dasd_device *device = container_of(work, struct dasd_device, in do_requeue_requests() local
3930 dasd_generic_requeue_all_requests(device); in do_requeue_requests()
3931 dasd_device_remove_stop_bits(device, DASD_STOPPED_NOT_ACC); in do_requeue_requests()
3932 if (device->block) in do_requeue_requests()
3933 dasd_schedule_block_bh(device->block); in do_requeue_requests()
3934 dasd_put_device(device); in do_requeue_requests()
3937 void dasd_schedule_requeue(struct dasd_device *device) in dasd_schedule_requeue() argument
3939 dasd_get_device(device); in dasd_schedule_requeue()
3941 if (!schedule_work(&device->requeue_requests)) in dasd_schedule_requeue()
3942 dasd_put_device(device); in dasd_schedule_requeue()
3946 static int dasd_handle_autoquiesce(struct dasd_device *device, in dasd_handle_autoquiesce() argument
3951 if (dasd_eer_enabled(device)) in dasd_handle_autoquiesce()
3952 dasd_eer_write(device, cqr, reason); in dasd_handle_autoquiesce()
3954 if (!test_bit(reason, &device->aq_mask)) in dasd_handle_autoquiesce()
3958 if (dasd_eer_enabled(device)) in dasd_handle_autoquiesce()
3959 dasd_eer_write(device, NULL, DASD_EER_AUTOQUIESCE); in dasd_handle_autoquiesce()
3961 dev_info(&device->cdev->dev, in dasd_handle_autoquiesce()
3963 dasd_device_set_stop_bits(device, DASD_STOPPED_QUIESCE); in dasd_handle_autoquiesce()
3965 if (device->features & DASD_FEATURE_REQUEUEQUIESCE) in dasd_handle_autoquiesce()
3966 dasd_schedule_requeue(device); in dasd_handle_autoquiesce()
3971 static struct dasd_ccw_req *dasd_generic_build_rdc(struct dasd_device *device, in dasd_generic_build_rdc() argument
3978 cqr = dasd_smalloc_request(magic, 1 /* RDC */, rdc_buffer_size, device, in dasd_generic_build_rdc()
3982 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "%s", in dasd_generic_build_rdc()
3992 cqr->startdev = device; in dasd_generic_build_rdc()
3993 cqr->memdev = device; in dasd_generic_build_rdc()
4002 int dasd_generic_read_dev_chars(struct dasd_device *device, int magic, in dasd_generic_read_dev_chars() argument
4008 cqr = dasd_generic_build_rdc(device, rdc_buffer_size, magic); in dasd_generic_read_dev_chars()
4055 struct dasd_device *device; in dasd_generic_shutdown() local
4057 device = dasd_device_from_cdev(cdev); in dasd_generic_shutdown()
4058 if (IS_ERR(device)) in dasd_generic_shutdown()
4061 if (device->block) in dasd_generic_shutdown()
4062 dasd_schedule_block_bh(device->block); in dasd_generic_shutdown()
4064 dasd_schedule_device_bh(device); in dasd_generic_shutdown()
4066 wait_event(shutdown_waitq, _wait_for_empty_queues(device)); in dasd_generic_shutdown()
4114 pr_info("The DASD device driver could not be initialized\n"); in dasd_init()