Lines Matching full:device
64 MODULE_DESCRIPTION("Linux on S/390 DASD device driver,"
91 * SECTION: Operations on the device structure.
99 * Allocate memory for a new device structure.
103 struct dasd_device *device; in dasd_alloc_device() local
105 device = kzalloc(sizeof(struct dasd_device), GFP_ATOMIC); in dasd_alloc_device()
106 if (!device) in dasd_alloc_device()
109 /* Get two pages for normal block device operations. */ in dasd_alloc_device()
110 device->ccw_mem = (void *) __get_free_pages(GFP_ATOMIC | GFP_DMA, 1); in dasd_alloc_device()
111 if (!device->ccw_mem) { in dasd_alloc_device()
112 kfree(device); in dasd_alloc_device()
116 device->erp_mem = (void *) get_zeroed_page(GFP_ATOMIC | GFP_DMA); in dasd_alloc_device()
117 if (!device->erp_mem) { in dasd_alloc_device()
118 free_pages((unsigned long) device->ccw_mem, 1); in dasd_alloc_device()
119 kfree(device); in dasd_alloc_device()
123 device->ese_mem = (void *)__get_free_pages(GFP_ATOMIC | GFP_DMA, 1); in dasd_alloc_device()
124 if (!device->ese_mem) { in dasd_alloc_device()
125 free_page((unsigned long) device->erp_mem); in dasd_alloc_device()
126 free_pages((unsigned long) device->ccw_mem, 1); in dasd_alloc_device()
127 kfree(device); in dasd_alloc_device()
131 dasd_init_chunklist(&device->ccw_chunks, device->ccw_mem, PAGE_SIZE*2); in dasd_alloc_device()
132 dasd_init_chunklist(&device->erp_chunks, device->erp_mem, PAGE_SIZE); in dasd_alloc_device()
133 dasd_init_chunklist(&device->ese_chunks, device->ese_mem, PAGE_SIZE * 2); in dasd_alloc_device()
134 spin_lock_init(&device->mem_lock); in dasd_alloc_device()
135 atomic_set(&device->tasklet_scheduled, 0); in dasd_alloc_device()
136 tasklet_init(&device->tasklet, dasd_device_tasklet, in dasd_alloc_device()
137 (unsigned long) device); in dasd_alloc_device()
138 INIT_LIST_HEAD(&device->ccw_queue); in dasd_alloc_device()
139 timer_setup(&device->timer, dasd_device_timeout, 0); in dasd_alloc_device()
140 INIT_WORK(&device->kick_work, do_kick_device); in dasd_alloc_device()
141 INIT_WORK(&device->restore_device, do_restore_device); in dasd_alloc_device()
142 INIT_WORK(&device->reload_device, do_reload_device); in dasd_alloc_device()
143 INIT_WORK(&device->requeue_requests, do_requeue_requests); in dasd_alloc_device()
144 device->state = DASD_STATE_NEW; in dasd_alloc_device()
145 device->target = DASD_STATE_NEW; in dasd_alloc_device()
146 mutex_init(&device->state_mutex); in dasd_alloc_device()
147 spin_lock_init(&device->profile.lock); in dasd_alloc_device()
148 return device; in dasd_alloc_device()
152 * Free memory of a device structure.
154 void dasd_free_device(struct dasd_device *device) in dasd_free_device() argument
156 kfree(device->private); in dasd_free_device()
157 free_pages((unsigned long) device->ese_mem, 1); in dasd_free_device()
158 free_page((unsigned long) device->erp_mem); in dasd_free_device()
159 free_pages((unsigned long) device->ccw_mem, 1); in dasd_free_device()
160 kfree(device); in dasd_free_device()
164 * Allocate memory for a new device structure.
173 /* open_count = 0 means device online but not in use */ in dasd_alloc_block()
191 * Free memory of a device structure.
200 * Make a new device known to the system.
202 static int dasd_state_new_to_known(struct dasd_device *device) in dasd_state_new_to_known() argument
207 * As long as the device is not in state DASD_STATE_NEW we want to in dasd_state_new_to_known()
210 dasd_get_device(device); in dasd_state_new_to_known()
212 if (device->block) { in dasd_state_new_to_known()
213 rc = dasd_alloc_queue(device->block); in dasd_state_new_to_known()
215 dasd_put_device(device); in dasd_state_new_to_known()
219 device->state = DASD_STATE_KNOWN; in dasd_state_new_to_known()
224 * Let the system forget about a device.
226 static int dasd_state_known_to_new(struct dasd_device *device) in dasd_state_known_to_new() argument
228 /* Disable extended error reporting for this device. */ in dasd_state_known_to_new()
229 dasd_eer_disable(device); in dasd_state_known_to_new()
230 device->state = DASD_STATE_NEW; in dasd_state_known_to_new()
232 if (device->block) in dasd_state_known_to_new()
233 dasd_free_queue(device->block); in dasd_state_known_to_new()
236 dasd_put_device(device); in dasd_state_known_to_new()
254 * Request the irq line for the device.
256 static int dasd_state_known_to_basic(struct dasd_device *device) in dasd_state_known_to_basic() argument
258 struct dasd_block *block = device->block; in dasd_state_known_to_basic()
271 dasd_profile_on(&device->block->profile); in dasd_state_known_to_basic()
273 device->debugfs_dentry = in dasd_state_known_to_basic()
274 dasd_debugfs_setup(dev_name(&device->cdev->dev), in dasd_state_known_to_basic()
276 dasd_profile_init(&device->profile, device->debugfs_dentry); in dasd_state_known_to_basic()
277 dasd_hosts_init(device->debugfs_dentry, device); in dasd_state_known_to_basic()
279 /* register 'device' debug area, used for all DBF_DEV_XXX calls */ in dasd_state_known_to_basic()
280 device->debug_area = debug_register(dev_name(&device->cdev->dev), 4, 1, in dasd_state_known_to_basic()
282 debug_register_view(device->debug_area, &debug_sprintf_view); in dasd_state_known_to_basic()
283 debug_set_level(device->debug_area, DBF_WARNING); in dasd_state_known_to_basic()
284 DBF_DEV_EVENT(DBF_EMERG, device, "%s", "debug area created"); in dasd_state_known_to_basic()
286 device->state = DASD_STATE_BASIC; in dasd_state_known_to_basic()
292 * Release the irq line for the device. Terminate any running i/o.
294 static int dasd_state_basic_to_known(struct dasd_device *device) in dasd_state_basic_to_known() argument
298 if (device->discipline->basic_to_known) { in dasd_state_basic_to_known()
299 rc = device->discipline->basic_to_known(device); in dasd_state_basic_to_known()
304 if (device->block) { in dasd_state_basic_to_known()
305 dasd_profile_exit(&device->block->profile); in dasd_state_basic_to_known()
306 debugfs_remove(device->block->debugfs_dentry); in dasd_state_basic_to_known()
307 dasd_gendisk_free(device->block); in dasd_state_basic_to_known()
308 dasd_block_clear_timer(device->block); in dasd_state_basic_to_known()
310 rc = dasd_flush_device_queue(device); in dasd_state_basic_to_known()
313 dasd_device_clear_timer(device); in dasd_state_basic_to_known()
314 dasd_profile_exit(&device->profile); in dasd_state_basic_to_known()
315 dasd_hosts_exit(device); in dasd_state_basic_to_known()
316 debugfs_remove(device->debugfs_dentry); in dasd_state_basic_to_known()
317 DBF_DEV_EVENT(DBF_EMERG, device, "%p debug area deleted", device); in dasd_state_basic_to_known()
318 if (device->debug_area != NULL) { in dasd_state_basic_to_known()
319 debug_unregister(device->debug_area); in dasd_state_basic_to_known()
320 device->debug_area = NULL; in dasd_state_basic_to_known()
322 device->state = DASD_STATE_KNOWN; in dasd_state_basic_to_known()
328 * -EAGAIN in which case the device keeps the state DASD_STATE_BASIC
336 * device is setup.
337 * In case the analysis returns an error, the device setup is stopped
340 static int dasd_state_basic_to_ready(struct dasd_device *device) in dasd_state_basic_to_ready() argument
347 block = device->block; in dasd_state_basic_to_ready()
354 device->state = DASD_STATE_UNFMT; in dasd_state_basic_to_ready()
355 disk = device->block->gdp; in dasd_state_basic_to_ready()
362 if (device->discipline->setup_blk_queue) in dasd_state_basic_to_ready()
363 device->discipline->setup_blk_queue(block); in dasd_state_basic_to_ready()
366 device->state = DASD_STATE_READY; in dasd_state_basic_to_ready()
369 device->state = DASD_STATE_BASIC; in dasd_state_basic_to_ready()
373 device->state = DASD_STATE_READY; in dasd_state_basic_to_ready()
376 if (device->discipline->basic_to_ready) in dasd_state_basic_to_ready()
377 rc = device->discipline->basic_to_ready(device); in dasd_state_basic_to_ready()
382 int _wait_for_empty_queues(struct dasd_device *device) in _wait_for_empty_queues() argument
384 if (device->block) in _wait_for_empty_queues()
385 return list_empty(&device->ccw_queue) && in _wait_for_empty_queues()
386 list_empty(&device->block->ccw_queue); in _wait_for_empty_queues()
388 return list_empty(&device->ccw_queue); in _wait_for_empty_queues()
392 * Remove device from block device layer. Destroy dirty buffers.
396 static int dasd_state_ready_to_basic(struct dasd_device *device) in dasd_state_ready_to_basic() argument
400 device->state = DASD_STATE_BASIC; in dasd_state_ready_to_basic()
401 if (device->block) { in dasd_state_ready_to_basic()
402 struct dasd_block *block = device->block; in dasd_state_ready_to_basic()
405 device->state = DASD_STATE_READY; in dasd_state_ready_to_basic()
419 static int dasd_state_unfmt_to_basic(struct dasd_device *device) in dasd_state_unfmt_to_basic() argument
421 device->state = DASD_STATE_BASIC; in dasd_state_unfmt_to_basic()
426 * Make the device online and schedule the bottom half to start
431 dasd_state_ready_to_online(struct dasd_device * device) in dasd_state_ready_to_online() argument
437 device->state = DASD_STATE_ONLINE; in dasd_state_ready_to_online()
438 if (device->block) { in dasd_state_ready_to_online()
439 dasd_schedule_block_bh(device->block); in dasd_state_ready_to_online()
440 if ((device->features & DASD_FEATURE_USERAW)) { in dasd_state_ready_to_online()
441 disk = device->block->gdp; in dasd_state_ready_to_online()
445 disk = device->block->bdev->bd_disk; in dasd_state_ready_to_online()
457 static int dasd_state_online_to_ready(struct dasd_device *device) in dasd_state_online_to_ready() argument
464 if (device->discipline->online_to_ready) { in dasd_state_online_to_ready()
465 rc = device->discipline->online_to_ready(device); in dasd_state_online_to_ready()
470 device->state = DASD_STATE_READY; in dasd_state_online_to_ready()
471 if (device->block && !(device->features & DASD_FEATURE_USERAW)) { in dasd_state_online_to_ready()
472 disk = device->block->bdev->bd_disk; in dasd_state_online_to_ready()
482 * Device startup state changes.
484 static int dasd_increase_state(struct dasd_device *device) in dasd_increase_state() argument
489 if (device->state == DASD_STATE_NEW && in dasd_increase_state()
490 device->target >= DASD_STATE_KNOWN) in dasd_increase_state()
491 rc = dasd_state_new_to_known(device); in dasd_increase_state()
494 device->state == DASD_STATE_KNOWN && in dasd_increase_state()
495 device->target >= DASD_STATE_BASIC) in dasd_increase_state()
496 rc = dasd_state_known_to_basic(device); in dasd_increase_state()
499 device->state == DASD_STATE_BASIC && in dasd_increase_state()
500 device->target >= DASD_STATE_READY) in dasd_increase_state()
501 rc = dasd_state_basic_to_ready(device); in dasd_increase_state()
504 device->state == DASD_STATE_UNFMT && in dasd_increase_state()
505 device->target > DASD_STATE_UNFMT) in dasd_increase_state()
509 device->state == DASD_STATE_READY && in dasd_increase_state()
510 device->target >= DASD_STATE_ONLINE) in dasd_increase_state()
511 rc = dasd_state_ready_to_online(device); in dasd_increase_state()
517 * Device shutdown state changes.
519 static int dasd_decrease_state(struct dasd_device *device) in dasd_decrease_state() argument
524 if (device->state == DASD_STATE_ONLINE && in dasd_decrease_state()
525 device->target <= DASD_STATE_READY) in dasd_decrease_state()
526 rc = dasd_state_online_to_ready(device); in dasd_decrease_state()
529 device->state == DASD_STATE_READY && in dasd_decrease_state()
530 device->target <= DASD_STATE_BASIC) in dasd_decrease_state()
531 rc = dasd_state_ready_to_basic(device); in dasd_decrease_state()
534 device->state == DASD_STATE_UNFMT && in dasd_decrease_state()
535 device->target <= DASD_STATE_BASIC) in dasd_decrease_state()
536 rc = dasd_state_unfmt_to_basic(device); in dasd_decrease_state()
539 device->state == DASD_STATE_BASIC && in dasd_decrease_state()
540 device->target <= DASD_STATE_KNOWN) in dasd_decrease_state()
541 rc = dasd_state_basic_to_known(device); in dasd_decrease_state()
544 device->state == DASD_STATE_KNOWN && in dasd_decrease_state()
545 device->target <= DASD_STATE_NEW) in dasd_decrease_state()
546 rc = dasd_state_known_to_new(device); in dasd_decrease_state()
554 static void dasd_change_state(struct dasd_device *device) in dasd_change_state() argument
558 if (device->state == device->target) in dasd_change_state()
561 if (device->state < device->target) in dasd_change_state()
562 rc = dasd_increase_state(device); in dasd_change_state()
564 rc = dasd_decrease_state(device); in dasd_change_state()
568 device->target = device->state; in dasd_change_state()
570 /* let user-space know that the device status changed */ in dasd_change_state()
571 kobject_uevent(&device->cdev->dev.kobj, KOBJ_CHANGE); in dasd_change_state()
573 if (device->state == device->target) in dasd_change_state()
585 struct dasd_device *device = container_of(work, struct dasd_device, kick_work); in do_kick_device() local
586 mutex_lock(&device->state_mutex); in do_kick_device()
587 dasd_change_state(device); in do_kick_device()
588 mutex_unlock(&device->state_mutex); in do_kick_device()
589 dasd_schedule_device_bh(device); in do_kick_device()
590 dasd_put_device(device); in do_kick_device()
593 void dasd_kick_device(struct dasd_device *device) in dasd_kick_device() argument
595 dasd_get_device(device); in dasd_kick_device()
597 if (!schedule_work(&device->kick_work)) in dasd_kick_device()
598 dasd_put_device(device); in dasd_kick_device()
608 struct dasd_device *device = container_of(work, struct dasd_device, in do_reload_device() local
610 device->discipline->reload(device); in do_reload_device()
611 dasd_put_device(device); in do_reload_device()
614 void dasd_reload_device(struct dasd_device *device) in dasd_reload_device() argument
616 dasd_get_device(device); in dasd_reload_device()
618 if (!schedule_work(&device->reload_device)) in dasd_reload_device()
619 dasd_put_device(device); in dasd_reload_device()
629 struct dasd_device *device = container_of(work, struct dasd_device, in do_restore_device() local
631 device->cdev->drv->restore(device->cdev); in do_restore_device()
632 dasd_put_device(device); in do_restore_device()
635 void dasd_restore_device(struct dasd_device *device) in dasd_restore_device() argument
637 dasd_get_device(device); in dasd_restore_device()
639 if (!schedule_work(&device->restore_device)) in dasd_restore_device()
640 dasd_put_device(device); in dasd_restore_device()
644 * Set the target state for a device and starts the state change.
646 void dasd_set_target_state(struct dasd_device *device, int target) in dasd_set_target_state() argument
648 dasd_get_device(device); in dasd_set_target_state()
649 mutex_lock(&device->state_mutex); in dasd_set_target_state()
653 if (device->target != target) { in dasd_set_target_state()
654 if (device->state == target) in dasd_set_target_state()
656 device->target = target; in dasd_set_target_state()
658 if (device->state != device->target) in dasd_set_target_state()
659 dasd_change_state(device); in dasd_set_target_state()
660 mutex_unlock(&device->state_mutex); in dasd_set_target_state()
661 dasd_put_device(device); in dasd_set_target_state()
666 * Enable devices with device numbers in [from..to].
668 static inline int _wait_for_device(struct dasd_device *device) in _wait_for_device() argument
670 return (device->state == device->target); in _wait_for_device()
673 void dasd_enable_device(struct dasd_device *device) in dasd_enable_device() argument
675 dasd_set_target_state(device, DASD_STATE_ONLINE); in dasd_enable_device()
676 if (device->state <= DASD_STATE_KNOWN) in dasd_enable_device()
677 /* No discipline for device found. */ in dasd_enable_device()
678 dasd_set_target_state(device, DASD_STATE_NEW); in dasd_enable_device()
680 wait_event(dasd_init_waitq, _wait_for_device(device)); in dasd_enable_device()
682 dasd_reload_device(device); in dasd_enable_device()
683 if (device->discipline->kick_validate) in dasd_enable_device()
684 device->discipline->kick_validate(device); in dasd_enable_device()
689 * SECTION: device operation (interrupt handler, start i/o, term i/o ...)
709 struct dasd_device *device; in dasd_profile_start() local
735 * We count the request for the start device, even though it may run on in dasd_profile_start()
736 * some other device due to error recovery. This way we make sure that in dasd_profile_start()
739 device = cqr->startdev; in dasd_profile_start()
740 if (device->profile.data) { in dasd_profile_start()
741 counter = 1; /* request is not yet queued on the start device */ in dasd_profile_start()
742 list_for_each(l, &device->ccw_queue) in dasd_profile_start()
746 spin_lock(&device->profile.lock); in dasd_profile_start()
747 if (device->profile.data) { in dasd_profile_start()
748 device->profile.data->dasd_io_nr_req[counter]++; in dasd_profile_start()
750 device->profile.data->dasd_read_nr_req[counter]++; in dasd_profile_start()
752 spin_unlock(&device->profile.lock); in dasd_profile_start()
819 struct dasd_device *device; in dasd_profile_end() local
824 device = cqr->startdev; in dasd_profile_end()
827 device->profile.data)) in dasd_profile_end()
886 spin_lock(&device->profile.lock); in dasd_profile_end()
887 if (device->profile.data) { in dasd_profile_end()
888 data = device->profile.data; in dasd_profile_end()
893 dasd_profile_end_add_data(device->profile.data, in dasd_profile_end()
902 spin_unlock(&device->profile.lock); in dasd_profile_end()
1194 struct dasd_device *device; in dasd_hosts_show() local
1197 device = m->private; in dasd_hosts_show()
1198 dasd_get_device(device); in dasd_hosts_show()
1200 if (device->discipline->hosts_print) in dasd_hosts_show()
1201 rc = device->discipline->hosts_print(device, m); in dasd_hosts_show()
1203 dasd_put_device(device); in dasd_hosts_show()
1209 static void dasd_hosts_exit(struct dasd_device *device) in dasd_hosts_exit() argument
1211 debugfs_remove(device->hosts_dentry); in dasd_hosts_exit()
1212 device->hosts_dentry = NULL; in dasd_hosts_exit()
1216 struct dasd_device *device) in dasd_hosts_init() argument
1226 device, &dasd_hosts_fops); in dasd_hosts_init()
1228 device->hosts_dentry = pde; in dasd_hosts_init()
1232 struct dasd_device *device, in dasd_smalloc_request() argument
1246 spin_lock_irqsave(&device->mem_lock, flags); in dasd_smalloc_request()
1247 data = chunk = dasd_alloc_chunk(&device->ccw_chunks, size); in dasd_smalloc_request()
1248 spin_unlock_irqrestore(&device->mem_lock, flags); in dasd_smalloc_request()
1268 dasd_get_device(device); in dasd_smalloc_request()
1275 struct dasd_device *device) in dasd_fmalloc_request() argument
1289 spin_lock_irqsave(&device->mem_lock, flags); in dasd_fmalloc_request()
1290 cqr = dasd_alloc_chunk(&device->ese_chunks, size); in dasd_fmalloc_request()
1291 spin_unlock_irqrestore(&device->mem_lock, flags); in dasd_fmalloc_request()
1310 dasd_get_device(device); in dasd_fmalloc_request()
1316 void dasd_sfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device) in dasd_sfree_request() argument
1320 spin_lock_irqsave(&device->mem_lock, flags); in dasd_sfree_request()
1321 dasd_free_chunk(&device->ccw_chunks, cqr->mem_chunk); in dasd_sfree_request()
1322 spin_unlock_irqrestore(&device->mem_lock, flags); in dasd_sfree_request()
1323 dasd_put_device(device); in dasd_sfree_request()
1327 void dasd_ffree_request(struct dasd_ccw_req *cqr, struct dasd_device *device) in dasd_ffree_request() argument
1331 spin_lock_irqsave(&device->mem_lock, flags); in dasd_ffree_request()
1332 dasd_free_chunk(&device->ese_chunks, cqr); in dasd_ffree_request()
1333 spin_unlock_irqrestore(&device->mem_lock, flags); in dasd_ffree_request()
1334 dasd_put_device(device); in dasd_ffree_request()
1343 struct dasd_device *device; in dasd_check_cqr() local
1347 device = cqr->startdev; in dasd_check_cqr()
1348 if (strncmp((char *) &cqr->magic, device->discipline->ebcname, 4)) { in dasd_check_cqr()
1349 DBF_DEV_EVENT(DBF_WARNING, device, in dasd_check_cqr()
1353 *(unsigned int *) device->discipline->name); in dasd_check_cqr()
1361 * Timer keeps device runnig.
1367 struct dasd_device *device; in dasd_term_IO() local
1376 device = (struct dasd_device *) cqr->startdev; in dasd_term_IO()
1378 rc = ccw_device_clear(device->cdev, (long) cqr); in dasd_term_IO()
1384 DBF_DEV_EVENT(DBF_DEBUG, device, in dasd_term_IO()
1389 DBF_DEV_EVENT(DBF_ERR, device, "%s", in dasd_term_IO()
1390 "device gone, retry"); in dasd_term_IO()
1394 * device not valid so no I/O could be running in dasd_term_IO()
1402 DBF_DEV_EVENT(DBF_ERR, device, "%s", in dasd_term_IO()
1410 dev_err(&device->cdev->dev, "An error occurred in the " in dasd_term_IO()
1411 "DASD device driver, reason=%s\n", errorstring); in dasd_term_IO()
1417 dasd_schedule_device_bh(device); in dasd_term_IO()
1428 struct dasd_device *device; in dasd_start_IO() local
1438 device = (struct dasd_device *) cqr->startdev; in dasd_start_IO()
1441 test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags)) && in dasd_start_IO()
1443 DBF_DEV_EVENT(DBF_DEBUG, device, "start_IO: return request %p " in dasd_start_IO()
1452 dev_err(&device->cdev->dev, "An error occurred in the DASD " in dasd_start_IO()
1453 "device driver, reason=%s\n", errorstring); in dasd_start_IO()
1461 cqr->lpm &= dasd_path_get_opm(device); in dasd_start_IO()
1463 cqr->lpm = dasd_path_get_opm(device); in dasd_start_IO()
1466 rc = ccw_device_tm_start(device->cdev, cqr->cpaddr, in dasd_start_IO()
1469 rc = ccw_device_start(device->cdev, cqr->cpaddr, in dasd_start_IO()
1477 DBF_DEV_EVENT(DBF_WARNING, device, "%s", in dasd_start_IO()
1478 "start_IO: device busy, retry later"); in dasd_start_IO()
1489 DBF_DEV_EVENT(DBF_WARNING, device, in dasd_start_IO()
1492 } else if (cqr->lpm != dasd_path_get_opm(device)) { in dasd_start_IO()
1493 cqr->lpm = dasd_path_get_opm(device); in dasd_start_IO()
1494 DBF_DEV_EVENT(DBF_DEBUG, device, "%s", in dasd_start_IO()
1498 DBF_DEV_EVENT(DBF_WARNING, device, "%s", in dasd_start_IO()
1501 dasd_generic_last_path_gone(device); in dasd_start_IO()
1502 dasd_path_no_path(device); in dasd_start_IO()
1503 dasd_path_set_tbvpm(device, in dasd_start_IO()
1505 device->cdev)); in dasd_start_IO()
1509 DBF_DEV_EVENT(DBF_WARNING, device, "%s", in dasd_start_IO()
1510 "start_IO: -ENODEV device gone, retry"); in dasd_start_IO()
1513 DBF_DEV_EVENT(DBF_WARNING, device, "%s", in dasd_start_IO()
1514 "start_IO: -EIO device gone, retry"); in dasd_start_IO()
1518 DBF_DEV_EVENT(DBF_WARNING, device, "%s", in dasd_start_IO()
1519 "start_IO: -EINVAL device currently " in dasd_start_IO()
1525 dev_err(&device->cdev->dev, in dasd_start_IO()
1526 "An error occurred in the DASD device driver, " in dasd_start_IO()
1547 struct dasd_device *device; in dasd_device_timeout() local
1549 device = from_timer(device, t, timer); in dasd_device_timeout()
1550 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); in dasd_device_timeout()
1552 dasd_device_remove_stop_bits(device, DASD_STOPPED_PENDING); in dasd_device_timeout()
1553 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); in dasd_device_timeout()
1554 dasd_schedule_device_bh(device); in dasd_device_timeout()
1558 * Setup timeout for a device in jiffies.
1560 void dasd_device_set_timer(struct dasd_device *device, int expires) in dasd_device_set_timer() argument
1563 del_timer(&device->timer); in dasd_device_set_timer()
1565 mod_timer(&device->timer, jiffies + expires); in dasd_device_set_timer()
1570 * Clear timeout for a device.
1572 void dasd_device_clear_timer(struct dasd_device *device) in dasd_device_clear_timer() argument
1574 del_timer(&device->timer); in dasd_device_clear_timer()
1582 struct dasd_device *device; in dasd_handle_killed_request() local
1594 device = dasd_device_from_cdev_locked(cdev); in dasd_handle_killed_request()
1595 if (IS_ERR(device)) { in dasd_handle_killed_request()
1597 "unable to get device from cdev"); in dasd_handle_killed_request()
1602 device != cqr->startdev || in dasd_handle_killed_request()
1606 "invalid device in request"); in dasd_handle_killed_request()
1607 dasd_put_device(device); in dasd_handle_killed_request()
1614 dasd_device_clear_timer(device); in dasd_handle_killed_request()
1615 dasd_schedule_device_bh(device); in dasd_handle_killed_request()
1616 dasd_put_device(device); in dasd_handle_killed_request()
1619 void dasd_generic_handle_state_change(struct dasd_device *device) in dasd_generic_handle_state_change() argument
1622 dasd_eer_snss(device); in dasd_generic_handle_state_change()
1624 dasd_device_remove_stop_bits(device, DASD_STOPPED_PENDING); in dasd_generic_handle_state_change()
1625 dasd_schedule_device_bh(device); in dasd_generic_handle_state_change()
1626 if (device->block) { in dasd_generic_handle_state_change()
1627 dasd_schedule_block_bh(device->block); in dasd_generic_handle_state_change()
1628 if (device->block->request_queue) in dasd_generic_handle_state_change()
1629 blk_mq_run_hw_queues(device->block->request_queue, in dasd_generic_handle_state_change()
1644 struct dasd_device *device = NULL; in dasd_ese_needs_format() local
1649 device = block->base; in dasd_ese_needs_format()
1650 if (!device || !device->discipline->is_ese) in dasd_ese_needs_format()
1652 if (!device->discipline->is_ese(device)) in dasd_ese_needs_format()
1679 struct dasd_device *device; in dasd_int_handler() local
1691 device = cqr->startdev; in dasd_int_handler()
1693 dasd_device_clear_timer(device); in dasd_int_handler()
1695 dasd_schedule_device_bh(device); in dasd_int_handler()
1719 device = dasd_device_from_cdev_locked(cdev); in dasd_int_handler()
1720 if (IS_ERR(device)) in dasd_int_handler()
1723 if (device->discipline == dasd_diag_discipline_pointer) { in dasd_int_handler()
1724 dasd_put_device(device); in dasd_int_handler()
1743 * Stop device and check exhaust level. in dasd_int_handler()
1746 dasd_generic_space_exhaust(device, cqr); in dasd_int_handler()
1747 device->discipline->ext_pool_exhaust(device, cqr); in dasd_int_handler()
1748 dasd_put_device(device); in dasd_int_handler()
1753 device->discipline->dump_sense_dbf(device, irb, "int"); in dasd_int_handler()
1755 if (device->features & DASD_FEATURE_ERPLOG) in dasd_int_handler()
1756 device->discipline->dump_sense(device, cqr, irb); in dasd_int_handler()
1757 device->discipline->check_for_device_change(device, cqr, irb); in dasd_int_handler()
1758 dasd_put_device(device); in dasd_int_handler()
1763 device = dasd_device_from_cdev_locked(cdev); in dasd_int_handler()
1764 if (!IS_ERR(device)) { in dasd_int_handler()
1765 device->discipline->check_attention(device, in dasd_int_handler()
1767 dasd_put_device(device); in dasd_int_handler()
1774 device = (struct dasd_device *) cqr->startdev; in dasd_int_handler()
1775 if (!device || in dasd_int_handler()
1776 strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) { in dasd_int_handler()
1778 "invalid device in request"); in dasd_int_handler()
1784 device->discipline->ese_read(cqr, irb); in dasd_int_handler()
1787 dasd_device_clear_timer(device); in dasd_int_handler()
1788 dasd_schedule_device_bh(device); in dasd_int_handler()
1791 fcqr = device->discipline->ese_format(device, cqr, irb); in dasd_int_handler()
1802 dasd_schedule_device_bh(device); in dasd_int_handler()
1807 list_add(&fcqr->devlist, &device->ccw_queue); in dasd_int_handler()
1808 dasd_schedule_device_bh(device); in dasd_int_handler()
1817 dasd_device_clear_timer(device); in dasd_int_handler()
1819 dasd_schedule_device_bh(device); in dasd_int_handler()
1825 DBF_DEV_EVENT(DBF_DEBUG, device, "invalid status: bus_id %s, " in dasd_int_handler()
1838 if (cqr->devlist.next != &device->ccw_queue) { in dasd_int_handler()
1848 device->discipline->handle_hpf_error) in dasd_int_handler()
1849 device->discipline->handle_hpf_error(device, irb); in dasd_int_handler()
1856 if (cqr->lpm == dasd_path_get_opm(device)) in dasd_int_handler()
1857 DBF_DEV_EVENT(DBF_DEBUG, device, in dasd_int_handler()
1862 cqr->lpm = dasd_path_get_opm(device); in dasd_int_handler()
1869 (!device->stopped)) { in dasd_int_handler()
1870 if (device->discipline->start_IO(next) == 0) in dasd_int_handler()
1874 dasd_device_set_timer(device, expires); in dasd_int_handler()
1876 dasd_device_clear_timer(device); in dasd_int_handler()
1877 dasd_schedule_device_bh(device); in dasd_int_handler()
1883 struct dasd_device *device; in dasd_generic_uc_handler() local
1885 device = dasd_device_from_cdev_locked(cdev); in dasd_generic_uc_handler()
1887 if (IS_ERR(device)) in dasd_generic_uc_handler()
1889 if (test_bit(DASD_FLAG_OFFLINE, &device->flags) || in dasd_generic_uc_handler()
1890 device->state != device->target || in dasd_generic_uc_handler()
1891 !device->discipline->check_for_device_change){ in dasd_generic_uc_handler()
1892 dasd_put_device(device); in dasd_generic_uc_handler()
1895 if (device->discipline->dump_sense_dbf) in dasd_generic_uc_handler()
1896 device->discipline->dump_sense_dbf(device, irb, "uc"); in dasd_generic_uc_handler()
1897 device->discipline->check_for_device_change(device, NULL, irb); in dasd_generic_uc_handler()
1898 dasd_put_device(device); in dasd_generic_uc_handler()
1908 static void __dasd_device_recovery(struct dasd_device *device, in __dasd_device_recovery() argument
1920 list_for_each_safe(l, n, &device->ccw_queue) { in __dasd_device_recovery()
1933 static void __dasd_device_process_ccw_queue(struct dasd_device *device, in __dasd_device_process_ccw_queue() argument
1940 list_for_each_safe(l, n, &device->ccw_queue) { in __dasd_device_process_ccw_queue()
1949 __dasd_device_recovery(device, cqr); in __dasd_device_process_ccw_queue()
1956 static void __dasd_process_cqr(struct dasd_device *device, in __dasd_process_cqr() argument
1974 dev_err(&device->cdev->dev, in __dasd_process_cqr()
1975 "An error occurred in the DASD device driver, " in __dasd_process_cqr()
1987 static void __dasd_device_process_final_queue(struct dasd_device *device, in __dasd_device_process_final_queue() argument
1999 __dasd_process_cqr(device, cqr); in __dasd_device_process_final_queue()
2002 __dasd_process_cqr(device, cqr); in __dasd_device_process_final_queue()
2012 static void __dasd_device_check_expire(struct dasd_device *device) in __dasd_device_check_expire() argument
2016 if (list_empty(&device->ccw_queue)) in __dasd_device_check_expire()
2018 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); in __dasd_device_check_expire()
2021 if (test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) { in __dasd_device_check_expire()
2028 if (device->discipline->term_IO(cqr) != 0) { in __dasd_device_check_expire()
2030 dev_err(&device->cdev->dev, in __dasd_device_check_expire()
2035 dasd_device_set_timer(device, 5*HZ); in __dasd_device_check_expire()
2037 dev_err(&device->cdev->dev, in __dasd_device_check_expire()
2046 * return 1 when device is not eligible for IO
2048 static int __dasd_device_is_unusable(struct dasd_device *device, in __dasd_device_is_unusable() argument
2053 if (test_bit(DASD_FLAG_OFFLINE, &device->flags) && in __dasd_device_is_unusable()
2054 !test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) { in __dasd_device_is_unusable()
2061 if (device->stopped) { in __dasd_device_is_unusable()
2062 if (device->stopped & mask) { in __dasd_device_is_unusable()
2067 /* CQR is not able to change device to in __dasd_device_is_unusable()
2071 /* CQR required to get device operational. */ in __dasd_device_is_unusable()
2080 static void __dasd_device_start_head(struct dasd_device *device) in __dasd_device_start_head() argument
2085 if (list_empty(&device->ccw_queue)) in __dasd_device_start_head()
2087 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); in __dasd_device_start_head()
2090 /* if device is not usable return request to upper layer */ in __dasd_device_start_head()
2091 if (__dasd_device_is_unusable(device, cqr)) { in __dasd_device_start_head()
2094 dasd_schedule_device_bh(device); in __dasd_device_start_head()
2098 rc = device->discipline->start_IO(cqr); in __dasd_device_start_head()
2100 dasd_device_set_timer(device, cqr->expires); in __dasd_device_start_head()
2102 dasd_schedule_device_bh(device); in __dasd_device_start_head()
2105 dasd_device_set_timer(device, 50); in __dasd_device_start_head()
2108 static void __dasd_device_check_path_events(struct dasd_device *device) in __dasd_device_check_path_events() argument
2112 if (!dasd_path_get_tbvpm(device)) in __dasd_device_check_path_events()
2115 if (device->stopped & in __dasd_device_check_path_events()
2118 rc = device->discipline->verify_path(device, in __dasd_device_check_path_events()
2119 dasd_path_get_tbvpm(device)); in __dasd_device_check_path_events()
2121 dasd_device_set_timer(device, 50); in __dasd_device_check_path_events()
2123 dasd_path_clear_all_verify(device); in __dasd_device_check_path_events()
2132 * this function is called!. In other words, when 'device' is a base
2133 * device then all block layer requests must have been removed before
2136 int dasd_flush_device_queue(struct dasd_device *device) in dasd_flush_device_queue() argument
2143 spin_lock_irq(get_ccwdev_lock(device->cdev)); in dasd_flush_device_queue()
2145 list_for_each_entry_safe(cqr, n, &device->ccw_queue, devlist) { in dasd_flush_device_queue()
2149 rc = device->discipline->term_IO(cqr); in dasd_flush_device_queue()
2152 dev_err(&device->cdev->dev, in dasd_flush_device_queue()
2169 spin_unlock_irq(get_ccwdev_lock(device->cdev)); in dasd_flush_device_queue()
2182 __dasd_device_process_final_queue(device, &flush_queue); in dasd_flush_device_queue()
2188 * Acquire the device lock and process queues for the device.
2192 struct dasd_device *device = (struct dasd_device *) data; in dasd_device_tasklet() local
2195 atomic_set (&device->tasklet_scheduled, 0); in dasd_device_tasklet()
2197 spin_lock_irq(get_ccwdev_lock(device->cdev)); in dasd_device_tasklet()
2199 __dasd_device_check_expire(device); in dasd_device_tasklet()
2201 __dasd_device_process_ccw_queue(device, &final_queue); in dasd_device_tasklet()
2202 __dasd_device_check_path_events(device); in dasd_device_tasklet()
2203 spin_unlock_irq(get_ccwdev_lock(device->cdev)); in dasd_device_tasklet()
2205 __dasd_device_process_final_queue(device, &final_queue); in dasd_device_tasklet()
2206 spin_lock_irq(get_ccwdev_lock(device->cdev)); in dasd_device_tasklet()
2208 __dasd_device_start_head(device); in dasd_device_tasklet()
2209 spin_unlock_irq(get_ccwdev_lock(device->cdev)); in dasd_device_tasklet()
2212 dasd_put_device(device); in dasd_device_tasklet()
2216 * Schedules a call to dasd_tasklet over the device tasklet.
2218 void dasd_schedule_device_bh(struct dasd_device *device) in dasd_schedule_device_bh() argument
2221 if (atomic_cmpxchg (&device->tasklet_scheduled, 0, 1) != 0) in dasd_schedule_device_bh()
2223 dasd_get_device(device); in dasd_schedule_device_bh()
2224 tasklet_hi_schedule(&device->tasklet); in dasd_schedule_device_bh()
2228 void dasd_device_set_stop_bits(struct dasd_device *device, int bits) in dasd_device_set_stop_bits() argument
2230 device->stopped |= bits; in dasd_device_set_stop_bits()
2234 void dasd_device_remove_stop_bits(struct dasd_device *device, int bits) in dasd_device_remove_stop_bits() argument
2236 device->stopped &= ~bits; in dasd_device_remove_stop_bits()
2237 if (!device->stopped) in dasd_device_remove_stop_bits()
2243 * Queue a request to the head of the device ccw_queue.
2248 struct dasd_device *device; in dasd_add_request_head() local
2251 device = cqr->startdev; in dasd_add_request_head()
2252 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); in dasd_add_request_head()
2254 list_add(&cqr->devlist, &device->ccw_queue); in dasd_add_request_head()
2256 dasd_schedule_device_bh(device); in dasd_add_request_head()
2257 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); in dasd_add_request_head()
2262 * Queue a request to the tail of the device ccw_queue.
2267 struct dasd_device *device; in dasd_add_request_tail() local
2270 device = cqr->startdev; in dasd_add_request_tail()
2271 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); in dasd_add_request_tail()
2273 list_add_tail(&cqr->devlist, &device->ccw_queue); in dasd_add_request_tail()
2275 dasd_schedule_device_bh(device); in dasd_add_request_tail()
2276 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); in dasd_add_request_tail()
2294 struct dasd_device *device; in _wait_for_wakeup() local
2297 device = cqr->startdev; in _wait_for_wakeup()
2298 spin_lock_irq(get_ccwdev_lock(device->cdev)); in _wait_for_wakeup()
2300 spin_unlock_irq(get_ccwdev_lock(device->cdev)); in _wait_for_wakeup()
2309 struct dasd_device *device; in __dasd_sleep_on_erp() local
2314 device = cqr->startdev; in __dasd_sleep_on_erp()
2317 device->discipline->handle_terminated_request(cqr); in __dasd_sleep_on_erp()
2321 erp_fn = device->discipline->erp_action(cqr); in __dasd_sleep_on_erp()
2328 __dasd_process_erp(device, cqr); in __dasd_sleep_on_erp()
2348 struct dasd_device *device; in _dasd_sleep_on() local
2355 device = maincqr->startdev; in _dasd_sleep_on()
2365 if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags) && in _dasd_sleep_on()
2372 if (device->stopped & ~DASD_STOPPED_PENDING && in _dasd_sleep_on()
2374 (!dasd_eer_enabled(device))) { in _dasd_sleep_on()
2380 * Don't try to start requests if device is in in _dasd_sleep_on()
2383 if (test_bit(DASD_FLAG_OFFLINE, &device->flags)) { in _dasd_sleep_on()
2389 * Don't try to start requests if device is stopped in _dasd_sleep_on()
2395 generic_waitq, !(device->stopped)); in _dasd_sleep_on()
2402 wait_event(generic_waitq, !(device->stopped)); in _dasd_sleep_on()
2452 struct dasd_device *device; in _dasd_sleep_on_queue() local
2459 device = cqr->startdev; in _dasd_sleep_on_queue()
2463 if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags) && in _dasd_sleep_on_queue()
2470 if (device->stopped & ~DASD_STOPPED_PENDING && in _dasd_sleep_on_queue()
2472 !dasd_eer_enabled(device)) { in _dasd_sleep_on_queue()
2478 /*Don't try to start requests if device is stopped*/ in _dasd_sleep_on_queue()
2481 generic_waitq, !device->stopped); in _dasd_sleep_on_queue()
2488 wait_event(generic_waitq, !(device->stopped)); in _dasd_sleep_on_queue()
2534 * Queue a request to the tail of the device ccw_queue and wait for
2562 * Queue a request to the tail of the device ccw_queue and wait
2577 static inline int _dasd_term_running_cqr(struct dasd_device *device) in _dasd_term_running_cqr() argument
2582 if (list_empty(&device->ccw_queue)) in _dasd_term_running_cqr()
2584 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); in _dasd_term_running_cqr()
2585 rc = device->discipline->term_IO(cqr); in _dasd_term_running_cqr()
2598 struct dasd_device *device; in dasd_sleep_on_immediatly() local
2601 device = cqr->startdev; in dasd_sleep_on_immediatly()
2602 if (test_bit(DASD_FLAG_LOCK_STOLEN, &device->flags) && in dasd_sleep_on_immediatly()
2608 spin_lock_irq(get_ccwdev_lock(device->cdev)); in dasd_sleep_on_immediatly()
2609 rc = _dasd_term_running_cqr(device); in dasd_sleep_on_immediatly()
2611 spin_unlock_irq(get_ccwdev_lock(device->cdev)); in dasd_sleep_on_immediatly()
2621 list_add(&cqr->devlist, device->ccw_queue.next); in dasd_sleep_on_immediatly()
2624 dasd_schedule_device_bh(device); in dasd_sleep_on_immediatly()
2626 spin_unlock_irq(get_ccwdev_lock(device->cdev)); in dasd_sleep_on_immediatly()
2638 dasd_schedule_device_bh(device); in dasd_sleep_on_immediatly()
2639 if (device->block) in dasd_sleep_on_immediatly()
2640 dasd_schedule_block_bh(device->block); in dasd_sleep_on_immediatly()
2657 struct dasd_device *device = cqr->startdev; in __dasd_cancel_req() local
2667 rc = device->discipline->term_IO(cqr); in __dasd_cancel_req()
2669 dev_err(&device->cdev->dev, in __dasd_cancel_req()
2679 dasd_schedule_device_bh(device); in __dasd_cancel_req()
2685 struct dasd_device *device = cqr->startdev; in dasd_cancel_req() local
2689 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); in dasd_cancel_req()
2691 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); in dasd_cancel_req()
2742 static void __dasd_process_erp(struct dasd_device *device, in __dasd_process_erp() argument
2748 DBF_DEV_EVENT(DBF_NOTICE, device, "%s", "ERP successful"); in __dasd_process_erp()
2750 dev_err(&device->cdev->dev, "ERP failed for the DASD\n"); in __dasd_process_erp()
2751 erp_fn = device->discipline->erp_postaction(cqr); in __dasd_process_erp()
2912 /* Don't try to start requests if device is stopped */ in __dasd_block_start_head()
3056 * Schedules a call to dasd_tasklet over the device tasklet.
3063 /* life cycle of block is bound to it's base device */ in dasd_schedule_block_bh()
3071 * SECTION: external block device operations
3092 "device not ready for request %p", req); in do_dasd_request()
3098 * if device is stopped do not fetch new requests in do_dasd_request()
3104 "device stopped request %p", req); in do_dasd_request()
3172 struct dasd_device *device; in dasd_times_out() local
3182 device = cqr->startdev ? cqr->startdev : block->base; in dasd_times_out()
3183 if (!device->blk_timeout) { in dasd_times_out()
3187 DBF_DEV_EVENT(DBF_WARNING, device, in dasd_times_out()
3192 spin_lock(get_ccwdev_lock(device->cdev)); in dasd_times_out()
3229 spin_unlock(get_ccwdev_lock(device->cdev)); in dasd_times_out()
3340 " Cannot open unrecognized device"); in dasd_open()
3406 * end of block device operations
3432 * Is the device read-only?
3434 * readonly device attribute, but how it is configured in z/VM.
3436 int dasd_device_is_ro(struct dasd_device *device) in dasd_device_is_ro() argument
3444 ccw_device_get_id(device->cdev, &dev_id); in dasd_device_is_ro()
3500 void dasd_generic_free_discipline(struct dasd_device *device) in dasd_generic_free_discipline() argument
3503 if (device->discipline) { in dasd_generic_free_discipline()
3504 if (device->discipline->uncheck_device) in dasd_generic_free_discipline()
3505 device->discipline->uncheck_device(device); in dasd_generic_free_discipline()
3506 module_put(device->discipline->owner); in dasd_generic_free_discipline()
3507 device->discipline = NULL; in dasd_generic_free_discipline()
3509 if (device->base_discipline) { in dasd_generic_free_discipline()
3510 module_put(device->base_discipline->owner); in dasd_generic_free_discipline()
3511 device->base_discipline = NULL; in dasd_generic_free_discipline()
3522 struct dasd_device *device; in dasd_generic_remove() local
3527 device = dasd_device_from_cdev(cdev); in dasd_generic_remove()
3528 if (IS_ERR(device)) { in dasd_generic_remove()
3532 if (test_and_set_bit(DASD_FLAG_OFFLINE, &device->flags) && in dasd_generic_remove()
3533 !test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) { in dasd_generic_remove()
3535 dasd_put_device(device); in dasd_generic_remove()
3540 * This device is removed unconditionally. Set offline in dasd_generic_remove()
3544 dasd_set_target_state(device, DASD_STATE_NEW); in dasd_generic_remove()
3545 /* dasd_delete_device destroys the device reference. */ in dasd_generic_remove()
3546 block = device->block; in dasd_generic_remove()
3547 dasd_delete_device(device); in dasd_generic_remove()
3549 * life cycle of block is bound to device, so delete it after in dasd_generic_remove()
3550 * device was safely removed in dasd_generic_remove()
3560 * Activate a device. This is called from dasd_{eckd,fba}_probe() when either
3561 * the device is detected for the first time and is supposed to be used
3568 struct dasd_device *device; in dasd_generic_set_online() local
3573 device = dasd_create_device(cdev); in dasd_generic_set_online()
3574 if (IS_ERR(device)) in dasd_generic_set_online()
3575 return PTR_ERR(device); in dasd_generic_set_online()
3578 if (device->features & DASD_FEATURE_USEDIAG) { in dasd_generic_set_online()
3588 dasd_delete_device(device); in dasd_generic_set_online()
3597 dasd_delete_device(device); in dasd_generic_set_online()
3603 dasd_delete_device(device); in dasd_generic_set_online()
3608 dasd_delete_device(device); in dasd_generic_set_online()
3611 device->base_discipline = base_discipline; in dasd_generic_set_online()
3612 device->discipline = discipline; in dasd_generic_set_online()
3614 /* check_device will allocate block device if necessary */ in dasd_generic_set_online()
3615 rc = discipline->check_device(device); in dasd_generic_set_online()
3621 dasd_delete_device(device); in dasd_generic_set_online()
3625 dasd_set_target_state(device, DASD_STATE_ONLINE); in dasd_generic_set_online()
3626 if (device->state <= DASD_STATE_KNOWN) { in dasd_generic_set_online()
3630 dasd_set_target_state(device, DASD_STATE_NEW); in dasd_generic_set_online()
3631 if (device->block) in dasd_generic_set_online()
3632 dasd_free_block(device->block); in dasd_generic_set_online()
3633 dasd_delete_device(device); in dasd_generic_set_online()
3635 pr_debug("dasd_generic device %s found\n", in dasd_generic_set_online()
3638 wait_event(dasd_init_waitq, _wait_for_device(device)); in dasd_generic_set_online()
3640 dasd_put_device(device); in dasd_generic_set_online()
3647 struct dasd_device *device; in dasd_generic_set_offline() local
3654 device = dasd_device_from_cdev_locked(cdev); in dasd_generic_set_offline()
3655 if (IS_ERR(device)) { in dasd_generic_set_offline()
3657 return PTR_ERR(device); in dasd_generic_set_offline()
3661 * We must make sure that this device is currently not in use. in dasd_generic_set_offline()
3666 if (device->block) { in dasd_generic_set_offline()
3667 max_count = device->block->bdev ? 0 : -1; in dasd_generic_set_offline()
3668 open_count = atomic_read(&device->block->open_count); in dasd_generic_set_offline()
3687 if (test_bit(DASD_FLAG_OFFLINE, &device->flags)) { in dasd_generic_set_offline()
3688 if (test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) { in dasd_generic_set_offline()
3690 &device->flags); in dasd_generic_set_offline()
3696 set_bit(DASD_FLAG_OFFLINE, &device->flags); in dasd_generic_set_offline()
3703 if (test_and_clear_bit(DASD_FLAG_SAFE_OFFLINE, &device->flags) && in dasd_generic_set_offline()
3704 !test_and_set_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) { in dasd_generic_set_offline()
3708 * If we want to set the device safe offline all IO operations in dasd_generic_set_offline()
3713 if (device->block) { in dasd_generic_set_offline()
3714 rc = fsync_bdev(device->block->bdev); in dasd_generic_set_offline()
3718 dasd_schedule_device_bh(device); in dasd_generic_set_offline()
3720 _wait_for_empty_queues(device)); in dasd_generic_set_offline()
3732 if (!test_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags)) { in dasd_generic_set_offline()
3736 clear_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags); in dasd_generic_set_offline()
3740 dasd_set_target_state(device, DASD_STATE_NEW); in dasd_generic_set_offline()
3741 /* dasd_delete_device destroys the device reference. */ in dasd_generic_set_offline()
3742 block = device->block; in dasd_generic_set_offline()
3743 dasd_delete_device(device); in dasd_generic_set_offline()
3745 * life cycle of block is bound to device, so delete it after in dasd_generic_set_offline()
3746 * device was safely removed in dasd_generic_set_offline()
3756 clear_bit(DASD_FLAG_SAFE_OFFLINE_RUNNING, &device->flags); in dasd_generic_set_offline()
3757 clear_bit(DASD_FLAG_OFFLINE, &device->flags); in dasd_generic_set_offline()
3759 dasd_put_device(device); in dasd_generic_set_offline()
3765 int dasd_generic_last_path_gone(struct dasd_device *device) in dasd_generic_last_path_gone() argument
3769 dev_warn(&device->cdev->dev, "No operational channel path is left " in dasd_generic_last_path_gone()
3770 "for the device\n"); in dasd_generic_last_path_gone()
3771 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "last path gone"); in dasd_generic_last_path_gone()
3773 dasd_eer_write(device, NULL, DASD_EER_NOPATH); in dasd_generic_last_path_gone()
3775 if (device->state < DASD_STATE_BASIC) in dasd_generic_last_path_gone()
3777 /* Device is active. We want to keep it. */ in dasd_generic_last_path_gone()
3778 list_for_each_entry(cqr, &device->ccw_queue, devlist) in dasd_generic_last_path_gone()
3784 dasd_device_set_stop_bits(device, DASD_STOPPED_DC_WAIT); in dasd_generic_last_path_gone()
3785 dasd_device_clear_timer(device); in dasd_generic_last_path_gone()
3786 dasd_schedule_device_bh(device); in dasd_generic_last_path_gone()
3791 int dasd_generic_path_operational(struct dasd_device *device) in dasd_generic_path_operational() argument
3793 dev_info(&device->cdev->dev, "A channel path to the device has become " in dasd_generic_path_operational()
3795 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "path operational"); in dasd_generic_path_operational()
3796 dasd_device_remove_stop_bits(device, DASD_STOPPED_DC_WAIT); in dasd_generic_path_operational()
3797 if (device->stopped & DASD_UNRESUMED_PM) { in dasd_generic_path_operational()
3798 dasd_device_remove_stop_bits(device, DASD_UNRESUMED_PM); in dasd_generic_path_operational()
3799 dasd_restore_device(device); in dasd_generic_path_operational()
3802 dasd_schedule_device_bh(device); in dasd_generic_path_operational()
3803 if (device->block) { in dasd_generic_path_operational()
3804 dasd_schedule_block_bh(device->block); in dasd_generic_path_operational()
3805 if (device->block->request_queue) in dasd_generic_path_operational()
3806 blk_mq_run_hw_queues(device->block->request_queue, in dasd_generic_path_operational()
3810 if (!device->stopped) in dasd_generic_path_operational()
3819 struct dasd_device *device; in dasd_generic_notify() local
3822 device = dasd_device_from_cdev_locked(cdev); in dasd_generic_notify()
3823 if (IS_ERR(device)) in dasd_generic_notify()
3830 dasd_path_no_path(device); in dasd_generic_notify()
3831 ret = dasd_generic_last_path_gone(device); in dasd_generic_notify()
3835 if (dasd_path_get_opm(device)) in dasd_generic_notify()
3836 ret = dasd_generic_path_operational(device); in dasd_generic_notify()
3839 dasd_put_device(device); in dasd_generic_notify()
3846 struct dasd_device *device; in dasd_generic_path_event() local
3849 device = dasd_device_from_cdev_locked(cdev); in dasd_generic_path_event()
3850 if (IS_ERR(device)) in dasd_generic_path_event()
3853 oldopm = dasd_path_get_opm(device); in dasd_generic_path_event()
3856 dasd_path_notoper(device, chp); in dasd_generic_path_event()
3859 dasd_path_available(device, chp); in dasd_generic_path_event()
3860 dasd_schedule_device_bh(device); in dasd_generic_path_event()
3863 if (!dasd_path_is_operational(device, chp) && in dasd_generic_path_event()
3864 !dasd_path_need_verify(device, chp)) { in dasd_generic_path_event()
3870 dasd_path_available(device, chp); in dasd_generic_path_event()
3871 dasd_schedule_device_bh(device); in dasd_generic_path_event()
3873 DBF_DEV_EVENT(DBF_WARNING, device, "%s", in dasd_generic_path_event()
3875 if (device->discipline->kick_validate) in dasd_generic_path_event()
3876 device->discipline->kick_validate(device); in dasd_generic_path_event()
3879 hpfpm = dasd_path_get_hpfpm(device); in dasd_generic_path_event()
3880 ifccpm = dasd_path_get_ifccpm(device); in dasd_generic_path_event()
3881 if (!dasd_path_get_opm(device) && hpfpm) { in dasd_generic_path_event()
3883 * device has no operational paths but at least one path is in dasd_generic_path_event()
3887 if (device->discipline->disable_hpf) in dasd_generic_path_event()
3888 device->discipline->disable_hpf(device); in dasd_generic_path_event()
3889 dasd_device_set_stop_bits(device, DASD_STOPPED_NOT_ACC); in dasd_generic_path_event()
3890 dasd_path_set_tbvpm(device, hpfpm); in dasd_generic_path_event()
3891 dasd_schedule_device_bh(device); in dasd_generic_path_event()
3892 dasd_schedule_requeue(device); in dasd_generic_path_event()
3893 } else if (!dasd_path_get_opm(device) && ifccpm) { in dasd_generic_path_event()
3895 * device has no operational paths but at least one path is in dasd_generic_path_event()
3899 dasd_path_set_tbvpm(device, ifccpm); in dasd_generic_path_event()
3900 dasd_schedule_device_bh(device); in dasd_generic_path_event()
3902 if (oldopm && !dasd_path_get_opm(device) && !hpfpm && !ifccpm) { in dasd_generic_path_event()
3903 dev_warn(&device->cdev->dev, in dasd_generic_path_event()
3904 "No verified channel paths remain for the device\n"); in dasd_generic_path_event()
3905 DBF_DEV_EVENT(DBF_WARNING, device, in dasd_generic_path_event()
3907 dasd_eer_write(device, NULL, DASD_EER_NOPATH); in dasd_generic_path_event()
3908 dasd_device_set_stop_bits(device, in dasd_generic_path_event()
3911 dasd_put_device(device); in dasd_generic_path_event()
3915 int dasd_generic_verify_path(struct dasd_device *device, __u8 lpm) in dasd_generic_verify_path() argument
3917 if (!dasd_path_get_opm(device) && lpm) { in dasd_generic_verify_path()
3918 dasd_path_set_opm(device, lpm); in dasd_generic_verify_path()
3919 dasd_generic_path_operational(device); in dasd_generic_verify_path()
3921 dasd_path_add_opm(device, lpm); in dasd_generic_verify_path()
3926 void dasd_generic_space_exhaust(struct dasd_device *device, in dasd_generic_space_exhaust() argument
3929 dasd_eer_write(device, NULL, DASD_EER_NOSPC); in dasd_generic_space_exhaust()
3931 if (device->state < DASD_STATE_BASIC) in dasd_generic_space_exhaust()
3939 dasd_device_set_stop_bits(device, DASD_STOPPED_NOSPC); in dasd_generic_space_exhaust()
3940 dasd_device_clear_timer(device); in dasd_generic_space_exhaust()
3941 dasd_schedule_device_bh(device); in dasd_generic_space_exhaust()
3945 void dasd_generic_space_avail(struct dasd_device *device) in dasd_generic_space_avail() argument
3947 dev_info(&device->cdev->dev, "Extent pool space is available\n"); in dasd_generic_space_avail()
3948 DBF_DEV_EVENT(DBF_WARNING, device, "%s", "space available"); in dasd_generic_space_avail()
3950 dasd_device_remove_stop_bits(device, DASD_STOPPED_NOSPC); in dasd_generic_space_avail()
3951 dasd_schedule_device_bh(device); in dasd_generic_space_avail()
3953 if (device->block) { in dasd_generic_space_avail()
3954 dasd_schedule_block_bh(device->block); in dasd_generic_space_avail()
3955 if (device->block->request_queue) in dasd_generic_space_avail()
3956 blk_mq_run_hw_queues(device->block->request_queue, true); in dasd_generic_space_avail()
3958 if (!device->stopped) in dasd_generic_space_avail()
3966 static int dasd_generic_requeue_all_requests(struct dasd_device *device) in dasd_generic_requeue_all_requests() argument
3974 spin_lock_irq(get_ccwdev_lock(device->cdev)); in dasd_generic_requeue_all_requests()
3976 list_for_each_entry_safe(cqr, n, &device->ccw_queue, devlist) { in dasd_generic_requeue_all_requests()
3979 rc = device->discipline->term_IO(cqr); in dasd_generic_requeue_all_requests()
3982 dev_err(&device->cdev->dev, in dasd_generic_requeue_all_requests()
3985 spin_unlock_irq(get_ccwdev_lock(device->cdev)); in dasd_generic_requeue_all_requests()
3986 dasd_put_device(device); in dasd_generic_requeue_all_requests()
3992 spin_unlock_irq(get_ccwdev_lock(device->cdev)); in dasd_generic_requeue_all_requests()
4000 * for block device requests in dasd_generic_requeue_all_requests()
4005 /* remove requests from device and block queue */ in dasd_generic_requeue_all_requests()
4029 * and go back to the device queue in dasd_generic_requeue_all_requests()
4033 spin_lock_irq(get_ccwdev_lock(device->cdev)); in dasd_generic_requeue_all_requests()
4034 list_splice_tail(&requeue_queue, &device->ccw_queue); in dasd_generic_requeue_all_requests()
4035 spin_unlock_irq(get_ccwdev_lock(device->cdev)); in dasd_generic_requeue_all_requests()
4037 dasd_schedule_device_bh(device); in dasd_generic_requeue_all_requests()
4043 struct dasd_device *device = container_of(work, struct dasd_device, in do_requeue_requests() local
4045 dasd_generic_requeue_all_requests(device); in do_requeue_requests()
4046 dasd_device_remove_stop_bits(device, DASD_STOPPED_NOT_ACC); in do_requeue_requests()
4047 if (device->block) in do_requeue_requests()
4048 dasd_schedule_block_bh(device->block); in do_requeue_requests()
4049 dasd_put_device(device); in do_requeue_requests()
4052 void dasd_schedule_requeue(struct dasd_device *device) in dasd_schedule_requeue() argument
4054 dasd_get_device(device); in dasd_schedule_requeue()
4056 if (!schedule_work(&device->requeue_requests)) in dasd_schedule_requeue()
4057 dasd_put_device(device); in dasd_schedule_requeue()
4063 struct dasd_device *device = dasd_device_from_cdev(cdev); in dasd_generic_pm_freeze() local
4065 if (IS_ERR(device)) in dasd_generic_pm_freeze()
4066 return PTR_ERR(device); in dasd_generic_pm_freeze()
4068 /* mark device as suspended */ in dasd_generic_pm_freeze()
4069 set_bit(DASD_FLAG_SUSPENDED, &device->flags); in dasd_generic_pm_freeze()
4071 if (device->discipline->freeze) in dasd_generic_pm_freeze()
4072 device->discipline->freeze(device); in dasd_generic_pm_freeze()
4075 dasd_device_set_stop_bits(device, DASD_STOPPED_PM); in dasd_generic_pm_freeze()
4077 return dasd_generic_requeue_all_requests(device); in dasd_generic_pm_freeze()
4083 struct dasd_device *device = dasd_device_from_cdev(cdev); in dasd_generic_restore_device() local
4086 if (IS_ERR(device)) in dasd_generic_restore_device()
4087 return PTR_ERR(device); in dasd_generic_restore_device()
4090 dasd_device_remove_stop_bits(device, in dasd_generic_restore_device()
4093 dasd_schedule_device_bh(device); in dasd_generic_restore_device()
4097 * if device is stopped do nothing e.g. for disconnected devices in dasd_generic_restore_device()
4099 if (device->discipline->restore && !(device->stopped)) in dasd_generic_restore_device()
4100 rc = device->discipline->restore(device); in dasd_generic_restore_device()
4101 if (rc || device->stopped) in dasd_generic_restore_device()
4106 device->stopped |= DASD_UNRESUMED_PM; in dasd_generic_restore_device()
4108 if (device->block) { in dasd_generic_restore_device()
4109 dasd_schedule_block_bh(device->block); in dasd_generic_restore_device()
4110 if (device->block->request_queue) in dasd_generic_restore_device()
4111 blk_mq_run_hw_queues(device->block->request_queue, in dasd_generic_restore_device()
4115 clear_bit(DASD_FLAG_SUSPENDED, &device->flags); in dasd_generic_restore_device()
4116 dasd_put_device(device); in dasd_generic_restore_device()
4121 static struct dasd_ccw_req *dasd_generic_build_rdc(struct dasd_device *device, in dasd_generic_build_rdc() argument
4128 cqr = dasd_smalloc_request(magic, 1 /* RDC */, rdc_buffer_size, device, in dasd_generic_build_rdc()
4133 dev_err(&device->cdev->dev, in dasd_generic_build_rdc()
4134 "An error occurred in the DASD device driver, " in dasd_generic_build_rdc()
4144 cqr->startdev = device; in dasd_generic_build_rdc()
4145 cqr->memdev = device; in dasd_generic_build_rdc()
4154 int dasd_generic_read_dev_chars(struct dasd_device *device, int magic, in dasd_generic_read_dev_chars() argument
4160 cqr = dasd_generic_build_rdc(device, rdc_buffer_size, magic); in dasd_generic_read_dev_chars()
4208 struct dasd_device *device; in dasd_generic_shutdown() local
4210 device = dasd_device_from_cdev(cdev); in dasd_generic_shutdown()
4211 if (IS_ERR(device)) in dasd_generic_shutdown()
4214 if (device->block) in dasd_generic_shutdown()
4215 dasd_schedule_block_bh(device->block); in dasd_generic_shutdown()
4217 dasd_schedule_device_bh(device); in dasd_generic_shutdown()
4219 wait_event(shutdown_waitq, _wait_for_empty_queues(device)); in dasd_generic_shutdown()
4267 pr_info("The DASD device driver could not be initialized\n"); in dasd_init()