Lines Matching refs:cqr
702 struct dasd_ccw_req *cqr, in dasd_profile_start() argument
737 device = cqr->startdev; in dasd_profile_start()
812 struct dasd_ccw_req *cqr, in dasd_profile_end() argument
822 device = cqr->startdev; in dasd_profile_end()
829 if (!cqr->buildclk || !cqr->startclk || in dasd_profile_end()
830 !cqr->stopclk || !cqr->endclk || in dasd_profile_end()
834 strtime = ((cqr->startclk - cqr->buildclk) >> 12); in dasd_profile_end()
835 irqtime = ((cqr->stopclk - cqr->startclk) >> 12); in dasd_profile_end()
836 endtime = ((cqr->endclk - cqr->stopclk) >> 12); in dasd_profile_end()
837 tottime = ((cqr->endclk - cqr->buildclk) >> 12); in dasd_profile_end()
856 cqr->startdev != block->base, in dasd_profile_end()
857 cqr->cpmode == 1, in dasd_profile_end()
874 cqr->startdev != block->base, in dasd_profile_end()
875 cqr->cpmode == 1, in dasd_profile_end()
892 cqr->startdev != block->base, in dasd_profile_end()
893 cqr->cpmode == 1, in dasd_profile_end()
1153 #define dasd_profile_start(block, cqr, req) do {} while (0) argument
1154 #define dasd_profile_end(block, cqr, req) do {} while (0) argument
1231 struct dasd_ccw_req *cqr) in dasd_smalloc_request() argument
1241 if (!cqr) in dasd_smalloc_request()
1242 size += (sizeof(*cqr) + 7L) & -8L; in dasd_smalloc_request()
1249 if (!cqr) { in dasd_smalloc_request()
1250 cqr = (void *) data; in dasd_smalloc_request()
1251 data += (sizeof(*cqr) + 7L) & -8L; in dasd_smalloc_request()
1253 memset(cqr, 0, sizeof(*cqr)); in dasd_smalloc_request()
1254 cqr->mem_chunk = chunk; in dasd_smalloc_request()
1256 cqr->cpaddr = data; in dasd_smalloc_request()
1258 memset(cqr->cpaddr, 0, cplength * sizeof(struct ccw1)); in dasd_smalloc_request()
1261 cqr->data = data; in dasd_smalloc_request()
1262 memset(cqr->data, 0, datasize); in dasd_smalloc_request()
1264 cqr->magic = magic; in dasd_smalloc_request()
1265 set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags); in dasd_smalloc_request()
1267 return cqr; in dasd_smalloc_request()
1275 struct dasd_ccw_req *cqr; in dasd_fmalloc_request() local
1280 cqr_size = (sizeof(*cqr) + 7L) & -8L; in dasd_fmalloc_request()
1288 cqr = dasd_alloc_chunk(&device->ese_chunks, size); in dasd_fmalloc_request()
1290 if (!cqr) in dasd_fmalloc_request()
1292 memset(cqr, 0, sizeof(*cqr)); in dasd_fmalloc_request()
1293 data = (char *)cqr + cqr_size; in dasd_fmalloc_request()
1294 cqr->cpaddr = NULL; in dasd_fmalloc_request()
1296 cqr->cpaddr = data; in dasd_fmalloc_request()
1298 memset(cqr->cpaddr, 0, cplength * sizeof(struct ccw1)); in dasd_fmalloc_request()
1300 cqr->data = NULL; in dasd_fmalloc_request()
1302 cqr->data = data; in dasd_fmalloc_request()
1303 memset(cqr->data, 0, datasize); in dasd_fmalloc_request()
1306 cqr->magic = magic; in dasd_fmalloc_request()
1307 set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags); in dasd_fmalloc_request()
1310 return cqr; in dasd_fmalloc_request()
1314 void dasd_sfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device) in dasd_sfree_request() argument
1319 dasd_free_chunk(&device->ccw_chunks, cqr->mem_chunk); in dasd_sfree_request()
1325 void dasd_ffree_request(struct dasd_ccw_req *cqr, struct dasd_device *device) in dasd_ffree_request() argument
1330 dasd_free_chunk(&device->ese_chunks, cqr); in dasd_ffree_request()
1339 static inline int dasd_check_cqr(struct dasd_ccw_req *cqr) in dasd_check_cqr() argument
1343 if (cqr == NULL) in dasd_check_cqr()
1345 device = cqr->startdev; in dasd_check_cqr()
1346 if (strncmp((char *) &cqr->magic, device->discipline->ebcname, 4)) { in dasd_check_cqr()
1350 cqr->magic, in dasd_check_cqr()
1363 int dasd_term_IO(struct dasd_ccw_req *cqr) in dasd_term_IO() argument
1370 rc = dasd_check_cqr(cqr); in dasd_term_IO()
1374 device = (struct dasd_device *) cqr->startdev; in dasd_term_IO()
1375 while ((retries < 5) && (cqr->status == DASD_CQR_IN_IO)) { in dasd_term_IO()
1376 rc = ccw_device_clear(device->cdev, (long) cqr); in dasd_term_IO()
1379 cqr->status = DASD_CQR_CLEAR_PENDING; in dasd_term_IO()
1380 cqr->stopclk = get_tod_clock(); in dasd_term_IO()
1381 cqr->starttime = 0; in dasd_term_IO()
1384 cqr); in dasd_term_IO()
1395 cqr->status = DASD_CQR_CLEARED; in dasd_term_IO()
1396 cqr->stopclk = get_tod_clock(); in dasd_term_IO()
1397 cqr->starttime = 0; in dasd_term_IO()
1399 cqr->retries = -1; in dasd_term_IO()
1424 int dasd_start_IO(struct dasd_ccw_req *cqr) in dasd_start_IO() argument
1431 rc = dasd_check_cqr(cqr); in dasd_start_IO()
1433 cqr->intrc = rc; in dasd_start_IO()
1436 device = (struct dasd_device *) cqr->startdev; in dasd_start_IO()
1437 if (((cqr->block && in dasd_start_IO()
1438 test_bit(DASD_FLAG_LOCK_STOLEN, &cqr->block->base->flags)) || in dasd_start_IO()
1440 !test_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags)) { in dasd_start_IO()
1442 "because of stolen lock", cqr); in dasd_start_IO()
1443 cqr->status = DASD_CQR_ERROR; in dasd_start_IO()
1444 cqr->intrc = -EPERM; in dasd_start_IO()
1447 if (cqr->retries < 0) { in dasd_start_IO()
1449 sprintf(errorstring, "14 %p", cqr); in dasd_start_IO()
1452 cqr->status = DASD_CQR_ERROR; in dasd_start_IO()
1455 cqr->startclk = get_tod_clock(); in dasd_start_IO()
1456 cqr->starttime = jiffies; in dasd_start_IO()
1457 cqr->retries--; in dasd_start_IO()
1458 if (!test_bit(DASD_CQR_VERIFY_PATH, &cqr->flags)) { in dasd_start_IO()
1459 cqr->lpm &= dasd_path_get_opm(device); in dasd_start_IO()
1460 if (!cqr->lpm) in dasd_start_IO()
1461 cqr->lpm = dasd_path_get_opm(device); in dasd_start_IO()
1463 if (cqr->cpmode == 1) { in dasd_start_IO()
1464 rc = ccw_device_tm_start(device->cdev, cqr->cpaddr, in dasd_start_IO()
1465 (long) cqr, cqr->lpm); in dasd_start_IO()
1467 rc = ccw_device_start(device->cdev, cqr->cpaddr, in dasd_start_IO()
1468 (long) cqr, cqr->lpm, 0); in dasd_start_IO()
1472 cqr->status = DASD_CQR_IN_IO; in dasd_start_IO()
1486 if (test_bit(DASD_CQR_VERIFY_PATH, &cqr->flags)) { in dasd_start_IO()
1489 cqr->lpm); in dasd_start_IO()
1490 } else if (cqr->lpm != dasd_path_get_opm(device)) { in dasd_start_IO()
1491 cqr->lpm = dasd_path_get_opm(device); in dasd_start_IO()
1529 cqr->intrc = rc; in dasd_start_IO()
1579 struct dasd_ccw_req *cqr; in dasd_handle_killed_request() local
1584 cqr = (struct dasd_ccw_req *) intparm; in dasd_handle_killed_request()
1585 if (cqr->status != DASD_CQR_IN_IO) { in dasd_handle_killed_request()
1588 "%02x", cqr->status); in dasd_handle_killed_request()
1599 if (!cqr->startdev || in dasd_handle_killed_request()
1600 device != cqr->startdev || in dasd_handle_killed_request()
1601 strncmp(cqr->startdev->discipline->ebcname, in dasd_handle_killed_request()
1602 (char *) &cqr->magic, 4)) { in dasd_handle_killed_request()
1610 cqr->status = DASD_CQR_QUEUED; in dasd_handle_killed_request()
1676 struct dasd_ccw_req *cqr, *next, *fcqr; in dasd_int_handler() local
1684 cqr = (struct dasd_ccw_req *) intparm; in dasd_int_handler()
1688 if (cqr && cqr->status == DASD_CQR_CLEAR_PENDING) { in dasd_int_handler()
1689 device = cqr->startdev; in dasd_int_handler()
1690 cqr->status = DASD_CQR_CLEARED; in dasd_int_handler()
1712 if (!cqr || in dasd_int_handler()
1715 if (cqr) in dasd_int_handler()
1716 memcpy(&cqr->irb, irb, sizeof(*irb)); in dasd_int_handler()
1735 test_bit(DASD_CQR_SUPPRESS_FP, &cqr->flags); in dasd_int_handler()
1737 test_bit(DASD_CQR_SUPPRESS_NRF, &cqr->flags); in dasd_int_handler()
1744 dasd_generic_space_exhaust(device, cqr); in dasd_int_handler()
1745 device->discipline->ext_pool_exhaust(device, cqr); in dasd_int_handler()
1754 device->discipline->dump_sense(device, cqr, irb); in dasd_int_handler()
1755 device->discipline->check_for_device_change(device, cqr, irb); in dasd_int_handler()
1769 if (!cqr) in dasd_int_handler()
1772 device = (struct dasd_device *) cqr->startdev; in dasd_int_handler()
1774 strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) { in dasd_int_handler()
1780 if (dasd_ese_needs_format(cqr->block, irb)) { in dasd_int_handler()
1781 if (rq_data_dir((struct request *)cqr->callback_data) == READ) { in dasd_int_handler()
1782 device->discipline->ese_read(cqr); in dasd_int_handler()
1783 cqr->status = DASD_CQR_SUCCESS; in dasd_int_handler()
1784 cqr->stopclk = now; in dasd_int_handler()
1789 fcqr = device->discipline->ese_format(device, cqr); in dasd_int_handler()
1795 cqr->status = DASD_CQR_QUEUED; in dasd_int_handler()
1798 cqr->status = DASD_CQR_QUEUED; in dasd_int_handler()
1806 if (cqr->status == DASD_CQR_CLEAR_PENDING && in dasd_int_handler()
1808 cqr->status = DASD_CQR_CLEARED; in dasd_int_handler()
1816 if (cqr->status != DASD_CQR_IN_IO) { in dasd_int_handler()
1818 "status %02x", dev_name(&cdev->dev), cqr->status); in dasd_int_handler()
1827 cqr->status = DASD_CQR_SUCCESS; in dasd_int_handler()
1828 cqr->stopclk = now; in dasd_int_handler()
1830 if (cqr->devlist.next != &device->ccw_queue) { in dasd_int_handler()
1831 next = list_entry(cqr->devlist.next, in dasd_int_handler()
1839 if (cqr->cpmode && dasd_check_hpf_error(irb) && in dasd_int_handler()
1846 if (!test_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags) && in dasd_int_handler()
1847 cqr->retries > 0) { in dasd_int_handler()
1848 if (cqr->lpm == dasd_path_get_opm(device)) in dasd_int_handler()
1852 cqr->retries); in dasd_int_handler()
1853 if (!test_bit(DASD_CQR_VERIFY_PATH, &cqr->flags)) in dasd_int_handler()
1854 cqr->lpm = dasd_path_get_opm(device); in dasd_int_handler()
1855 cqr->status = DASD_CQR_QUEUED; in dasd_int_handler()
1856 next = cqr; in dasd_int_handler()
1858 cqr->status = DASD_CQR_ERROR; in dasd_int_handler()
1904 struct dasd_ccw_req *cqr; in __dasd_device_recovery() local
1913 cqr = list_entry(l, struct dasd_ccw_req, devlist); in __dasd_device_recovery()
1914 if (cqr->status == DASD_CQR_QUEUED && in __dasd_device_recovery()
1915 ref_cqr->block == cqr->block) { in __dasd_device_recovery()
1916 cqr->status = DASD_CQR_CLEARED; in __dasd_device_recovery()
1929 struct dasd_ccw_req *cqr; in __dasd_device_process_ccw_queue() local
1933 cqr = list_entry(l, struct dasd_ccw_req, devlist); in __dasd_device_process_ccw_queue()
1936 if (cqr->status == DASD_CQR_QUEUED || in __dasd_device_process_ccw_queue()
1937 cqr->status == DASD_CQR_IN_IO || in __dasd_device_process_ccw_queue()
1938 cqr->status == DASD_CQR_CLEAR_PENDING) in __dasd_device_process_ccw_queue()
1940 if (cqr->status == DASD_CQR_ERROR) { in __dasd_device_process_ccw_queue()
1941 __dasd_device_recovery(device, cqr); in __dasd_device_process_ccw_queue()
1944 list_move_tail(&cqr->devlist, final_queue); in __dasd_device_process_ccw_queue()
1949 struct dasd_ccw_req *cqr) in __dasd_process_cqr() argument
1953 switch (cqr->status) { in __dasd_process_cqr()
1955 cqr->status = DASD_CQR_DONE; in __dasd_process_cqr()
1958 cqr->status = DASD_CQR_NEED_ERP; in __dasd_process_cqr()
1961 cqr->status = DASD_CQR_TERMINATED; in __dasd_process_cqr()
1965 snprintf(errorstring, ERRORLENGTH, "12 %p %x02", cqr, cqr->status); in __dasd_process_cqr()
1971 if (cqr->callback) in __dasd_process_cqr()
1972 cqr->callback(cqr, cqr->callback_data); in __dasd_process_cqr()
1983 struct dasd_ccw_req *cqr; in __dasd_device_process_final_queue() local
1987 cqr = list_entry(l, struct dasd_ccw_req, devlist); in __dasd_device_process_final_queue()
1988 list_del_init(&cqr->devlist); in __dasd_device_process_final_queue()
1989 block = cqr->block; in __dasd_device_process_final_queue()
1991 __dasd_process_cqr(device, cqr); in __dasd_device_process_final_queue()
1994 __dasd_process_cqr(device, cqr); in __dasd_device_process_final_queue()
2006 struct dasd_ccw_req *cqr; in __dasd_device_check_expire() local
2010 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); in __dasd_device_check_expire()
2011 if ((cqr->status == DASD_CQR_IN_IO && cqr->expires != 0) && in __dasd_device_check_expire()
2012 (time_after_eq(jiffies, cqr->expires + cqr->starttime))) { in __dasd_device_check_expire()
2018 cqr->retries++; in __dasd_device_check_expire()
2020 if (device->discipline->term_IO(cqr) != 0) { in __dasd_device_check_expire()
2025 cqr, (cqr->expires/HZ)); in __dasd_device_check_expire()
2026 cqr->expires += 5*HZ; in __dasd_device_check_expire()
2031 "remaining\n", cqr, (cqr->expires/HZ), in __dasd_device_check_expire()
2032 cqr->retries); in __dasd_device_check_expire()
2041 struct dasd_ccw_req *cqr) in __dasd_device_is_unusable() argument
2058 if (!test_bit(DASD_CQR_VERIFY_PATH, &cqr->flags)) { in __dasd_device_is_unusable()
2074 struct dasd_ccw_req *cqr; in __dasd_device_start_head() local
2079 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); in __dasd_device_start_head()
2080 if (cqr->status != DASD_CQR_QUEUED) in __dasd_device_start_head()
2083 if (__dasd_device_is_unusable(device, cqr)) { in __dasd_device_start_head()
2084 cqr->intrc = -EAGAIN; in __dasd_device_start_head()
2085 cqr->status = DASD_CQR_CLEARED; in __dasd_device_start_head()
2090 rc = device->discipline->start_IO(cqr); in __dasd_device_start_head()
2092 dasd_device_set_timer(device, cqr->expires); in __dasd_device_start_head()
2130 struct dasd_ccw_req *cqr, *n; in dasd_flush_device_queue() local
2137 list_for_each_entry_safe(cqr, n, &device->ccw_queue, devlist) { in dasd_flush_device_queue()
2139 switch (cqr->status) { in dasd_flush_device_queue()
2141 rc = device->discipline->term_IO(cqr); in dasd_flush_device_queue()
2146 "failed for request %p\n", cqr); in dasd_flush_device_queue()
2152 cqr->stopclk = get_tod_clock(); in dasd_flush_device_queue()
2153 cqr->status = DASD_CQR_CLEARED; in dasd_flush_device_queue()
2158 list_move_tail(&cqr->devlist, &flush_queue); in dasd_flush_device_queue()
2167 list_for_each_entry_safe(cqr, n, &flush_queue, devlist) in dasd_flush_device_queue()
2169 (cqr->status != DASD_CQR_CLEAR_PENDING)); in dasd_flush_device_queue()
2238 void dasd_add_request_head(struct dasd_ccw_req *cqr) in dasd_add_request_head() argument
2243 device = cqr->startdev; in dasd_add_request_head()
2245 cqr->status = DASD_CQR_QUEUED; in dasd_add_request_head()
2246 list_add(&cqr->devlist, &device->ccw_queue); in dasd_add_request_head()
2257 void dasd_add_request_tail(struct dasd_ccw_req *cqr) in dasd_add_request_tail() argument
2262 device = cqr->startdev; in dasd_add_request_tail()
2264 cqr->status = DASD_CQR_QUEUED; in dasd_add_request_tail()
2265 list_add_tail(&cqr->devlist, &device->ccw_queue); in dasd_add_request_tail()
2275 void dasd_wakeup_cb(struct dasd_ccw_req *cqr, void *data) in dasd_wakeup_cb() argument
2277 spin_lock_irq(get_ccwdev_lock(cqr->startdev->cdev)); in dasd_wakeup_cb()
2278 cqr->callback_data = DASD_SLEEPON_END_TAG; in dasd_wakeup_cb()
2279 spin_unlock_irq(get_ccwdev_lock(cqr->startdev->cdev)); in dasd_wakeup_cb()
2284 static inline int _wait_for_wakeup(struct dasd_ccw_req *cqr) in _wait_for_wakeup() argument
2289 device = cqr->startdev; in _wait_for_wakeup()
2291 rc = (cqr->callback_data == DASD_SLEEPON_END_TAG); in _wait_for_wakeup()
2299 static int __dasd_sleep_on_erp(struct dasd_ccw_req *cqr) in __dasd_sleep_on_erp() argument
2304 if (cqr->status == DASD_CQR_FILLED) in __dasd_sleep_on_erp()
2306 device = cqr->startdev; in __dasd_sleep_on_erp()
2307 if (test_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags)) { in __dasd_sleep_on_erp()
2308 if (cqr->status == DASD_CQR_TERMINATED) { in __dasd_sleep_on_erp()
2309 device->discipline->handle_terminated_request(cqr); in __dasd_sleep_on_erp()
2312 if (cqr->status == DASD_CQR_NEED_ERP) { in __dasd_sleep_on_erp()
2313 erp_fn = device->discipline->erp_action(cqr); in __dasd_sleep_on_erp()
2314 erp_fn(cqr); in __dasd_sleep_on_erp()
2317 if (cqr->status == DASD_CQR_FAILED) in __dasd_sleep_on_erp()
2318 dasd_log_sense(cqr, &cqr->irb); in __dasd_sleep_on_erp()
2319 if (cqr->refers) { in __dasd_sleep_on_erp()
2320 __dasd_process_erp(device, cqr); in __dasd_sleep_on_erp()
2327 static int __dasd_sleep_on_loop_condition(struct dasd_ccw_req *cqr) in __dasd_sleep_on_loop_condition() argument
2329 if (test_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags)) { in __dasd_sleep_on_loop_condition()
2330 if (cqr->refers) /* erp is not done yet */ in __dasd_sleep_on_loop_condition()
2332 return ((cqr->status != DASD_CQR_DONE) && in __dasd_sleep_on_loop_condition()
2333 (cqr->status != DASD_CQR_FAILED)); in __dasd_sleep_on_loop_condition()
2335 return (cqr->status == DASD_CQR_FILLED); in __dasd_sleep_on_loop_condition()
2343 struct dasd_ccw_req *cqr; in _dasd_sleep_on() local
2349 for (cqr = maincqr; __dasd_sleep_on_loop_condition(cqr); in _dasd_sleep_on()
2350 cqr = list_first_entry(&ccw_queue, in _dasd_sleep_on()
2353 if (__dasd_sleep_on_erp(cqr)) in _dasd_sleep_on()
2355 if (cqr->status != DASD_CQR_FILLED) /* could be failed */ in _dasd_sleep_on()
2358 !test_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags)) { in _dasd_sleep_on()
2359 cqr->status = DASD_CQR_FAILED; in _dasd_sleep_on()
2360 cqr->intrc = -EPERM; in _dasd_sleep_on()
2365 test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) && in _dasd_sleep_on()
2367 cqr->status = DASD_CQR_FAILED; in _dasd_sleep_on()
2368 cqr->intrc = -ENOLINK; in _dasd_sleep_on()
2376 cqr->status = DASD_CQR_FAILED; in _dasd_sleep_on()
2377 cqr->intrc = -ENODEV; in _dasd_sleep_on()
2384 if (!test_bit(DASD_CQR_VERIFY_PATH, &cqr->flags)) { in _dasd_sleep_on()
2389 cqr->status = DASD_CQR_FAILED; in _dasd_sleep_on()
2396 if (!cqr->callback) in _dasd_sleep_on()
2397 cqr->callback = dasd_wakeup_cb; in _dasd_sleep_on()
2399 cqr->callback_data = DASD_SLEEPON_START_TAG; in _dasd_sleep_on()
2400 dasd_add_request_tail(cqr); in _dasd_sleep_on()
2403 generic_waitq, _wait_for_wakeup(cqr)); in _dasd_sleep_on()
2405 dasd_cancel_req(cqr); in _dasd_sleep_on()
2408 _wait_for_wakeup(cqr)); in _dasd_sleep_on()
2409 cqr->status = DASD_CQR_FAILED; in _dasd_sleep_on()
2414 wait_event(generic_waitq, _wait_for_wakeup(cqr)); in _dasd_sleep_on()
2432 struct dasd_ccw_req *cqr; in _wait_for_wakeup_queue() local
2434 list_for_each_entry(cqr, ccw_queue, blocklist) { in _wait_for_wakeup_queue()
2435 if (cqr->callback_data != DASD_SLEEPON_END_TAG) in _wait_for_wakeup_queue()
2445 struct dasd_ccw_req *cqr, *n; in _dasd_sleep_on_queue() local
2450 list_for_each_entry_safe(cqr, n, ccw_queue, blocklist) { in _dasd_sleep_on_queue()
2451 device = cqr->startdev; in _dasd_sleep_on_queue()
2452 if (cqr->status != DASD_CQR_FILLED) /*could be failed*/ in _dasd_sleep_on_queue()
2456 !test_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags)) { in _dasd_sleep_on_queue()
2457 cqr->status = DASD_CQR_FAILED; in _dasd_sleep_on_queue()
2458 cqr->intrc = -EPERM; in _dasd_sleep_on_queue()
2463 test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) && in _dasd_sleep_on_queue()
2465 cqr->status = DASD_CQR_FAILED; in _dasd_sleep_on_queue()
2466 cqr->intrc = -EAGAIN; in _dasd_sleep_on_queue()
2475 cqr->status = DASD_CQR_FAILED; in _dasd_sleep_on_queue()
2476 cqr->intrc = rc; in _dasd_sleep_on_queue()
2482 if (!cqr->callback) in _dasd_sleep_on_queue()
2483 cqr->callback = dasd_wakeup_cb; in _dasd_sleep_on_queue()
2484 cqr->callback_data = DASD_SLEEPON_START_TAG; in _dasd_sleep_on_queue()
2485 dasd_add_request_tail(cqr); in _dasd_sleep_on_queue()
2491 list_for_each_entry_safe(cqr, n, ccw_queue, blocklist) { in _dasd_sleep_on_queue()
2498 sense = dasd_get_sense(&cqr->irb); in _dasd_sleep_on_queue()
2500 test_bit(DASD_CQR_SUPPRESS_FP, &cqr->flags)) in _dasd_sleep_on_queue()
2502 if (scsw_cstat(&cqr->irb.scsw) == 0x40 && in _dasd_sleep_on_queue()
2503 test_bit(DASD_CQR_SUPPRESS_IL, &cqr->flags)) in _dasd_sleep_on_queue()
2511 if (cqr->startdev != cqr->basedev && !cqr->refers && in _dasd_sleep_on_queue()
2512 (cqr->status == DASD_CQR_TERMINATED || in _dasd_sleep_on_queue()
2513 cqr->status == DASD_CQR_NEED_ERP)) in _dasd_sleep_on_queue()
2517 if (__dasd_sleep_on_erp(cqr)) in _dasd_sleep_on_queue()
2529 int dasd_sleep_on(struct dasd_ccw_req *cqr) in dasd_sleep_on() argument
2531 return _dasd_sleep_on(cqr, 0); in dasd_sleep_on()
2557 int dasd_sleep_on_interruptible(struct dasd_ccw_req *cqr) in dasd_sleep_on_interruptible() argument
2559 return _dasd_sleep_on(cqr, 1); in dasd_sleep_on_interruptible()
2571 struct dasd_ccw_req *cqr; in _dasd_term_running_cqr() local
2576 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist); in _dasd_term_running_cqr()
2577 rc = device->discipline->term_IO(cqr); in _dasd_term_running_cqr()
2584 cqr->retries++; in _dasd_term_running_cqr()
2588 int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr) in dasd_sleep_on_immediatly() argument
2593 device = cqr->startdev; in dasd_sleep_on_immediatly()
2595 !test_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags)) { in dasd_sleep_on_immediatly()
2596 cqr->status = DASD_CQR_FAILED; in dasd_sleep_on_immediatly()
2597 cqr->intrc = -EPERM; in dasd_sleep_on_immediatly()
2606 cqr->callback = dasd_wakeup_cb; in dasd_sleep_on_immediatly()
2607 cqr->callback_data = DASD_SLEEPON_START_TAG; in dasd_sleep_on_immediatly()
2608 cqr->status = DASD_CQR_QUEUED; in dasd_sleep_on_immediatly()
2613 list_add(&cqr->devlist, device->ccw_queue.next); in dasd_sleep_on_immediatly()
2620 wait_event(generic_waitq, _wait_for_wakeup(cqr)); in dasd_sleep_on_immediatly()
2622 if (cqr->status == DASD_CQR_DONE) in dasd_sleep_on_immediatly()
2624 else if (cqr->intrc) in dasd_sleep_on_immediatly()
2625 rc = cqr->intrc; in dasd_sleep_on_immediatly()
2647 static int __dasd_cancel_req(struct dasd_ccw_req *cqr) in __dasd_cancel_req() argument
2649 struct dasd_device *device = cqr->startdev; in __dasd_cancel_req()
2652 switch (cqr->status) { in __dasd_cancel_req()
2655 cqr->status = DASD_CQR_CLEARED; in __dasd_cancel_req()
2659 rc = device->discipline->term_IO(cqr); in __dasd_cancel_req()
2663 cqr, rc); in __dasd_cancel_req()
2665 cqr->stopclk = get_tod_clock(); in __dasd_cancel_req()
2675 int dasd_cancel_req(struct dasd_ccw_req *cqr) in dasd_cancel_req() argument
2677 struct dasd_device *device = cqr->startdev; in dasd_cancel_req()
2682 rc = __dasd_cancel_req(cqr); in dasd_cancel_req()
2735 struct dasd_ccw_req *cqr) in __dasd_process_erp() argument
2739 if (cqr->status == DASD_CQR_DONE) in __dasd_process_erp()
2743 erp_fn = device->discipline->erp_postaction(cqr); in __dasd_process_erp()
2744 erp_fn(cqr); in __dasd_process_erp()
2747 static void __dasd_cleanup_cqr(struct dasd_ccw_req *cqr) in __dasd_cleanup_cqr() argument
2753 req = (struct request *) cqr->callback_data; in __dasd_cleanup_cqr()
2754 dasd_profile_end(cqr->block, cqr, req); in __dasd_cleanup_cqr()
2756 status = cqr->block->base->discipline->free_cp(cqr, req); in __dasd_cleanup_cqr()
2760 switch (cqr->intrc) { in __dasd_cleanup_cqr()
2797 struct dasd_ccw_req *cqr; in __dasd_process_block_ccw_queue() local
2805 cqr = list_entry(l, struct dasd_ccw_req, blocklist); in __dasd_process_block_ccw_queue()
2806 if (cqr->status != DASD_CQR_DONE && in __dasd_process_block_ccw_queue()
2807 cqr->status != DASD_CQR_FAILED && in __dasd_process_block_ccw_queue()
2808 cqr->status != DASD_CQR_NEED_ERP && in __dasd_process_block_ccw_queue()
2809 cqr->status != DASD_CQR_TERMINATED) in __dasd_process_block_ccw_queue()
2812 if (cqr->status == DASD_CQR_TERMINATED) { in __dasd_process_block_ccw_queue()
2813 base->discipline->handle_terminated_request(cqr); in __dasd_process_block_ccw_queue()
2818 if (cqr->status == DASD_CQR_NEED_ERP) { in __dasd_process_block_ccw_queue()
2819 erp_fn = base->discipline->erp_action(cqr); in __dasd_process_block_ccw_queue()
2820 if (IS_ERR(erp_fn(cqr))) in __dasd_process_block_ccw_queue()
2826 if (cqr->status == DASD_CQR_FAILED) { in __dasd_process_block_ccw_queue()
2827 dasd_log_sense(cqr, &cqr->irb); in __dasd_process_block_ccw_queue()
2832 cqr->status == DASD_CQR_FAILED) { in __dasd_process_block_ccw_queue()
2833 dasd_eer_write(base, cqr, DASD_EER_FATALERROR); in __dasd_process_block_ccw_queue()
2836 cqr->status = DASD_CQR_FILLED; in __dasd_process_block_ccw_queue()
2837 cqr->retries = 255; in __dasd_process_block_ccw_queue()
2846 if (cqr->refers) { in __dasd_process_block_ccw_queue()
2847 __dasd_process_erp(base, cqr); in __dasd_process_block_ccw_queue()
2852 cqr->endclk = get_tod_clock(); in __dasd_process_block_ccw_queue()
2853 list_move_tail(&cqr->blocklist, final_queue); in __dasd_process_block_ccw_queue()
2857 static void dasd_return_cqr_cb(struct dasd_ccw_req *cqr, void *data) in dasd_return_cqr_cb() argument
2859 dasd_schedule_block_bh(cqr->block); in dasd_return_cqr_cb()
2864 struct dasd_ccw_req *cqr; in __dasd_block_start_head() local
2872 list_for_each_entry(cqr, &block->ccw_queue, blocklist) { in __dasd_block_start_head()
2873 if (cqr->status != DASD_CQR_FILLED) in __dasd_block_start_head()
2876 !test_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags)) { in __dasd_block_start_head()
2877 cqr->status = DASD_CQR_FAILED; in __dasd_block_start_head()
2878 cqr->intrc = -EPERM; in __dasd_block_start_head()
2884 test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) && in __dasd_block_start_head()
2886 cqr->status = DASD_CQR_FAILED; in __dasd_block_start_head()
2887 cqr->intrc = -ENOLINK; in __dasd_block_start_head()
2896 if (!cqr->startdev) in __dasd_block_start_head()
2897 cqr->startdev = block->base; in __dasd_block_start_head()
2900 cqr->callback = dasd_return_cqr_cb; in __dasd_block_start_head()
2902 dasd_add_request_tail(cqr); in __dasd_block_start_head()
2916 struct dasd_ccw_req *cqr; in dasd_block_tasklet() local
2928 cqr = list_entry(l, struct dasd_ccw_req, blocklist); in dasd_block_tasklet()
2929 dq = cqr->dq; in dasd_block_tasklet()
2931 list_del_init(&cqr->blocklist); in dasd_block_tasklet()
2932 __dasd_cleanup_cqr(cqr); in dasd_block_tasklet()
2946 static void _dasd_wake_block_flush_cb(struct dasd_ccw_req *cqr, void *data) in _dasd_wake_block_flush_cb() argument
2955 static int _dasd_requeue_request(struct dasd_ccw_req *cqr) in _dasd_requeue_request() argument
2957 struct dasd_block *block = cqr->block; in _dasd_requeue_request()
2962 spin_lock_irq(&cqr->dq->lock); in _dasd_requeue_request()
2963 req = (struct request *) cqr->callback_data; in _dasd_requeue_request()
2965 spin_unlock_irq(&cqr->dq->lock); in _dasd_requeue_request()
2977 struct dasd_ccw_req *cqr, *n; in dasd_flush_block_queue() local
2986 list_for_each_entry_safe(cqr, n, &block->ccw_queue, blocklist) { in dasd_flush_block_queue()
2988 if (cqr->status >= DASD_CQR_QUEUED) in dasd_flush_block_queue()
2989 rc = dasd_cancel_req(cqr); in dasd_flush_block_queue()
2997 cqr->callback = _dasd_wake_block_flush_cb; in dasd_flush_block_queue()
2998 for (i = 0; cqr != NULL; cqr = cqr->refers, i++) in dasd_flush_block_queue()
2999 list_move_tail(&cqr->blocklist, &flush_queue); in dasd_flush_block_queue()
3007 list_for_each_entry_safe(cqr, n, &flush_queue, blocklist) { in dasd_flush_block_queue()
3008 wait_event(dasd_flush_wq, (cqr->status < DASD_CQR_QUEUED)); in dasd_flush_block_queue()
3010 if (cqr->refers) { in dasd_flush_block_queue()
3012 __dasd_process_erp(block->base, cqr); in dasd_flush_block_queue()
3019 spin_lock_irqsave(&cqr->dq->lock, flags); in dasd_flush_block_queue()
3020 cqr->endclk = get_tod_clock(); in dasd_flush_block_queue()
3021 list_del_init(&cqr->blocklist); in dasd_flush_block_queue()
3022 __dasd_cleanup_cqr(cqr); in dasd_flush_block_queue()
3023 spin_unlock_irqrestore(&cqr->dq->lock, flags); in dasd_flush_block_queue()
3058 struct dasd_ccw_req *cqr; in do_dasd_request() local
3099 cqr = basedev->discipline->build_cp(basedev, block, req); in do_dasd_request()
3100 if (IS_ERR(cqr)) { in do_dasd_request()
3101 if (PTR_ERR(cqr) == -EBUSY || in do_dasd_request()
3102 PTR_ERR(cqr) == -ENOMEM || in do_dasd_request()
3103 PTR_ERR(cqr) == -EAGAIN) { in do_dasd_request()
3109 PTR_ERR(cqr), req); in do_dasd_request()
3117 cqr->callback_data = req; in do_dasd_request()
3118 cqr->status = DASD_CQR_FILLED; in do_dasd_request()
3119 cqr->dq = dq; in do_dasd_request()
3123 list_add_tail(&cqr->blocklist, &block->ccw_queue); in do_dasd_request()
3124 INIT_LIST_HEAD(&cqr->devlist); in do_dasd_request()
3125 dasd_profile_start(block, cqr, req); in do_dasd_request()
3146 struct dasd_ccw_req *cqr; in dasd_times_out() local
3150 cqr = blk_mq_rq_to_pdu(req); in dasd_times_out()
3151 if (!cqr) in dasd_times_out()
3154 spin_lock_irqsave(&cqr->dq->lock, flags); in dasd_times_out()
3155 device = cqr->startdev ? cqr->startdev : block->base; in dasd_times_out()
3157 spin_unlock_irqrestore(&cqr->dq->lock, flags); in dasd_times_out()
3162 cqr, cqr->status); in dasd_times_out()
3166 cqr->retries = -1; in dasd_times_out()
3167 cqr->intrc = -ETIMEDOUT; in dasd_times_out()
3168 if (cqr->status >= DASD_CQR_QUEUED) { in dasd_times_out()
3169 rc = __dasd_cancel_req(cqr); in dasd_times_out()
3170 } else if (cqr->status == DASD_CQR_FILLED || in dasd_times_out()
3171 cqr->status == DASD_CQR_NEED_ERP) { in dasd_times_out()
3172 cqr->status = DASD_CQR_TERMINATED; in dasd_times_out()
3173 } else if (cqr->status == DASD_CQR_IN_ERP) { in dasd_times_out()
3181 if (tmpcqr != cqr) in dasd_times_out()
3205 spin_unlock_irqrestore(&cqr->dq->lock, flags); in dasd_times_out()
3740 struct dasd_ccw_req *cqr; in dasd_generic_last_path_gone() local
3751 list_for_each_entry(cqr, &device->ccw_queue, devlist) in dasd_generic_last_path_gone()
3752 if ((cqr->status == DASD_CQR_IN_IO) || in dasd_generic_last_path_gone()
3753 (cqr->status == DASD_CQR_CLEAR_PENDING)) { in dasd_generic_last_path_gone()
3754 cqr->status = DASD_CQR_QUEUED; in dasd_generic_last_path_gone()
3755 cqr->retries++; in dasd_generic_last_path_gone()
3900 struct dasd_ccw_req *cqr) in dasd_generic_space_exhaust() argument
3907 if (cqr->status == DASD_CQR_IN_IO || in dasd_generic_space_exhaust()
3908 cqr->status == DASD_CQR_CLEAR_PENDING) { in dasd_generic_space_exhaust()
3909 cqr->status = DASD_CQR_QUEUED; in dasd_generic_space_exhaust()
3910 cqr->retries++; in dasd_generic_space_exhaust()
3942 struct dasd_ccw_req *cqr, *n; in dasd_generic_requeue_all_requests() local
3949 list_for_each_entry_safe(cqr, n, &device->ccw_queue, devlist) { in dasd_generic_requeue_all_requests()
3951 if (cqr->status == DASD_CQR_IN_IO) { in dasd_generic_requeue_all_requests()
3952 rc = device->discipline->term_IO(cqr); in dasd_generic_requeue_all_requests()
3957 "on suspend\n", cqr); in dasd_generic_requeue_all_requests()
3963 list_move_tail(&cqr->devlist, &requeue_queue); in dasd_generic_requeue_all_requests()
3967 list_for_each_entry_safe(cqr, n, &requeue_queue, devlist) { in dasd_generic_requeue_all_requests()
3969 (cqr->status != DASD_CQR_CLEAR_PENDING)); in dasd_generic_requeue_all_requests()
3975 if (_dasd_requeue_request(cqr)) in dasd_generic_requeue_all_requests()
3979 list_del_init(&cqr->devlist); in dasd_generic_requeue_all_requests()
3980 while (cqr->refers != NULL) { in dasd_generic_requeue_all_requests()
3981 refers = cqr->refers; in dasd_generic_requeue_all_requests()
3983 list_del(&cqr->blocklist); in dasd_generic_requeue_all_requests()
3985 dasd_free_erp_request(cqr, cqr->memdev); in dasd_generic_requeue_all_requests()
3986 cqr = refers; in dasd_generic_requeue_all_requests()
3995 list_del_init(&cqr->blocklist); in dasd_generic_requeue_all_requests()
3996 cqr->block->base->discipline->free_cp( in dasd_generic_requeue_all_requests()
3997 cqr, (struct request *) cqr->callback_data); in dasd_generic_requeue_all_requests()
4098 struct dasd_ccw_req *cqr; in dasd_generic_build_rdc() local
4101 cqr = dasd_smalloc_request(magic, 1 /* RDC */, rdc_buffer_size, device, in dasd_generic_build_rdc()
4104 if (IS_ERR(cqr)) { in dasd_generic_build_rdc()
4109 return cqr; in dasd_generic_build_rdc()
4112 ccw = cqr->cpaddr; in dasd_generic_build_rdc()
4114 ccw->cda = (__u32)(addr_t) cqr->data; in dasd_generic_build_rdc()
4117 cqr->startdev = device; in dasd_generic_build_rdc()
4118 cqr->memdev = device; in dasd_generic_build_rdc()
4119 cqr->expires = 10*HZ; in dasd_generic_build_rdc()
4120 cqr->retries = 256; in dasd_generic_build_rdc()
4121 cqr->buildclk = get_tod_clock(); in dasd_generic_build_rdc()
4122 cqr->status = DASD_CQR_FILLED; in dasd_generic_build_rdc()
4123 return cqr; in dasd_generic_build_rdc()
4131 struct dasd_ccw_req *cqr; in dasd_generic_read_dev_chars() local
4133 cqr = dasd_generic_build_rdc(device, rdc_buffer_size, magic); in dasd_generic_read_dev_chars()
4134 if (IS_ERR(cqr)) in dasd_generic_read_dev_chars()
4135 return PTR_ERR(cqr); in dasd_generic_read_dev_chars()
4137 ret = dasd_sleep_on(cqr); in dasd_generic_read_dev_chars()
4139 memcpy(rdc_buffer, cqr->data, rdc_buffer_size); in dasd_generic_read_dev_chars()
4140 dasd_sfree_request(cqr, cqr->memdev); in dasd_generic_read_dev_chars()