Lines Matching refs:srp
181 static int sg_start_req(Sg_request *srp, unsigned char *cmd);
182 static int sg_finish_rem_req(Sg_request * srp);
185 Sg_request * srp);
189 static int sg_common_write(Sg_fd * sfp, Sg_request * srp,
191 static int sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer);
194 static void sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size);
195 static void sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp);
200 static int sg_remove_request(Sg_fd * sfp, Sg_request * srp);
418 Sg_request *srp; in sg_read() local
467 srp = sg_get_rq_mark(sfp, req_pack_id); in sg_read()
468 if (!srp) { /* now wait on packet to arrive */ in sg_read()
479 (srp = sg_get_rq_mark(sfp, req_pack_id)))); in sg_read()
489 if (srp->header.interface_id != '\0') { in sg_read()
490 retval = sg_new_read(sfp, buf, count, srp); in sg_read()
494 hp = &srp->header; in sg_read()
507 ((srp->data.cmd_opcode >= 0xc0) && (12 == hp->cmd_len)) ? 1 : 0; in sg_read()
513 memcpy(old_hdr->sense_buffer, srp->sense_b, in sg_read()
536 old_hdr->result = (srp->sense_b[0] == 0 && in sg_read()
554 if (sg_read_oxfer(srp, buf, count - SZ_SG_HEADER)) { in sg_read()
561 sg_finish_rem_req(srp); in sg_read()
562 sg_remove_request(sfp, srp); in sg_read()
570 sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp) in sg_new_read() argument
572 sg_io_hdr_t *hp = &srp->header; in sg_new_read()
586 len = 8 + (int) srp->sense_b[7]; /* Additional sense length field */ in sg_new_read()
588 if (copy_to_user(hp->sbp, srp->sense_b, len)) { in sg_new_read()
602 err2 = sg_finish_rem_req(srp); in sg_new_read()
603 sg_remove_request(sfp, srp); in sg_new_read()
615 Sg_request *srp; in sg_write() local
648 if (!(srp = sg_add_request(sfp))) { in sg_write()
673 sg_remove_request(sfp, srp); in sg_write()
676 hp = &srp->header; in sg_write()
714 k = sg_common_write(sfp, srp, cmnd, sfp->timeout, blocking); in sg_write()
724 Sg_request *srp; in sg_new_write() local
736 if (!(srp = sg_add_request(sfp))) { in sg_new_write()
741 srp->sg_io_owned = sg_io_owned; in sg_new_write()
742 hp = &srp->header; in sg_new_write()
744 sg_remove_request(sfp, srp); in sg_new_write()
748 sg_remove_request(sfp, srp); in sg_new_write()
753 sg_remove_request(sfp, srp); in sg_new_write()
757 sg_remove_request(sfp, srp); in sg_new_write()
761 sg_remove_request(sfp, srp); in sg_new_write()
765 ul_timeout = msecs_to_jiffies(srp->header.timeout); in sg_new_write()
768 sg_remove_request(sfp, srp); in sg_new_write()
772 sg_remove_request(sfp, srp); in sg_new_write()
776 sg_remove_request(sfp, srp); in sg_new_write()
780 sg_remove_request(sfp, srp); in sg_new_write()
783 k = sg_common_write(sfp, srp, cmnd, timeout, blocking); in sg_new_write()
787 *o_srp = srp; in sg_new_write()
792 sg_common_write(Sg_fd * sfp, Sg_request * srp, in sg_common_write() argument
797 sg_io_hdr_t *hp = &srp->header; in sg_common_write()
799 srp->data.cmd_opcode = cmnd[0]; /* hold opcode of command */ in sg_common_write()
814 k = sg_start_req(srp, cmnd); in sg_common_write()
818 sg_finish_rem_req(srp); in sg_common_write()
819 sg_remove_request(sfp, srp); in sg_common_write()
823 if (srp->bio) { in sg_common_write()
824 scsi_req_free_cmd(scsi_req(srp->rq)); in sg_common_write()
825 blk_end_request_all(srp->rq, BLK_STS_IOERR); in sg_common_write()
826 srp->rq = NULL; in sg_common_write()
829 sg_finish_rem_req(srp); in sg_common_write()
830 sg_remove_request(sfp, srp); in sg_common_write()
841 srp->rq->timeout = timeout; in sg_common_write()
844 srp->rq, at_head, sg_rq_end_io); in sg_common_write()
848 static int srp_done(Sg_fd *sfp, Sg_request *srp) in srp_done() argument
854 ret = srp->done; in srp_done()
871 Sg_request *srp; in sg_fill_request_table() local
876 list_for_each_entry(srp, &sfp->rq_list, entry) { in sg_fill_request_table()
879 rinfo[val].req_state = srp->done + 1; in sg_fill_request_table()
881 srp->header.masked_status & in sg_fill_request_table()
882 srp->header.host_status & in sg_fill_request_table()
883 srp->header.driver_status; in sg_fill_request_table()
884 if (srp->done) in sg_fill_request_table()
886 srp->header.duration; in sg_fill_request_table()
890 (ms > srp->header.duration) ? in sg_fill_request_table()
891 (ms - srp->header.duration) : 0; in sg_fill_request_table()
893 rinfo[val].orphan = srp->orphan; in sg_fill_request_table()
894 rinfo[val].sg_io_owned = srp->sg_io_owned; in sg_fill_request_table()
895 rinfo[val].pack_id = srp->header.pack_id; in sg_fill_request_table()
896 rinfo[val].usr_ptr = srp->header.usr_ptr; in sg_fill_request_table()
909 Sg_request *srp; in sg_ioctl() local
928 1, read_only, 1, &srp); in sg_ioctl()
932 (srp_done(sfp, srp) || atomic_read(&sdp->detaching))); in sg_ioctl()
936 if (srp->done) { in sg_ioctl()
937 srp->done = 2; in sg_ioctl()
939 result = sg_new_read(sfp, p, SZ_SG_IO_HDR, srp); in sg_ioctl()
942 srp->orphan = 1; in sg_ioctl()
1003 list_for_each_entry(srp, &sfp->rq_list, entry) { in sg_ioctl()
1004 if ((1 == srp->done) && (!srp->sg_io_owned)) { in sg_ioctl()
1007 __put_user(srp->header.pack_id, ip); in sg_ioctl()
1017 list_for_each_entry(srp, &sfp->rq_list, entry) { in sg_ioctl()
1018 if ((1 == srp->done) && (!srp->sg_io_owned)) in sg_ioctl()
1177 Sg_request *srp; in sg_poll() local
1189 list_for_each_entry(srp, &sfp->rq_list, entry) { in sg_poll()
1191 if ((0 == res) && (1 == srp->done) && (!srp->sg_io_owned)) in sg_poll()
1308 struct sg_request *srp = container_of(work, struct sg_request, ew.work); in sg_rq_end_io_usercontext() local
1309 struct sg_fd *sfp = srp->parentfp; in sg_rq_end_io_usercontext()
1311 sg_finish_rem_req(srp); in sg_rq_end_io_usercontext()
1312 sg_remove_request(sfp, srp); in sg_rq_end_io_usercontext()
1323 struct sg_request *srp = rq->end_io_data; in sg_rq_end_io() local
1332 if (WARN_ON(srp->done != 0)) in sg_rq_end_io()
1335 sfp = srp->parentfp; in sg_rq_end_io()
1349 srp->header.pack_id, result)); in sg_rq_end_io()
1350 srp->header.resid = resid; in sg_rq_end_io()
1352 srp->header.duration = (ms > srp->header.duration) ? in sg_rq_end_io()
1353 (ms - srp->header.duration) : 0; in sg_rq_end_io()
1357 srp->header.status = 0xff & result; in sg_rq_end_io()
1358 srp->header.masked_status = status_byte(result); in sg_rq_end_io()
1359 srp->header.msg_status = msg_byte(result); in sg_rq_end_io()
1360 srp->header.host_status = host_byte(result); in sg_rq_end_io()
1361 srp->header.driver_status = driver_byte(result); in sg_rq_end_io()
1363 ((CHECK_CONDITION == srp->header.masked_status) || in sg_rq_end_io()
1364 (COMMAND_TERMINATED == srp->header.masked_status))) in sg_rq_end_io()
1381 memcpy(srp->sense_b, req->sense, SCSI_SENSE_BUFFERSIZE); in sg_rq_end_io()
1391 srp->rq = NULL; in sg_rq_end_io()
1396 if (unlikely(srp->orphan)) { in sg_rq_end_io()
1398 srp->sg_io_owned = 0; in sg_rq_end_io()
1402 srp->done = done; in sg_rq_end_io()
1413 INIT_WORK(&srp->ew.work, sg_rq_end_io_usercontext); in sg_rq_end_io()
1414 schedule_work(&srp->ew.work); in sg_rq_end_io()
1703 sg_start_req(Sg_request *srp, unsigned char *cmd) in sg_start_req() argument
1708 Sg_fd *sfp = srp->parentfp; in sg_start_req()
1709 sg_io_hdr_t *hp = &srp->header; in sg_start_req()
1713 Sg_scatter_hold *req_schp = &srp->data; in sg_start_req()
1754 srp->rq = rq; in sg_start_req()
1755 rq->end_io_data = srp; in sg_start_req()
1774 sg_link_reserve(sfp, srp, dxfer_len); in sg_start_req()
1822 srp->bio = rq->bio; in sg_start_req()
1833 sg_finish_rem_req(Sg_request *srp) in sg_finish_rem_req() argument
1837 Sg_fd *sfp = srp->parentfp; in sg_finish_rem_req()
1838 Sg_scatter_hold *req_schp = &srp->data; in sg_finish_rem_req()
1842 (int) srp->res_used)); in sg_finish_rem_req()
1843 if (srp->bio) in sg_finish_rem_req()
1844 ret = blk_rq_unmap_user(srp->bio); in sg_finish_rem_req()
1846 if (srp->rq) { in sg_finish_rem_req()
1847 scsi_req_free_cmd(scsi_req(srp->rq)); in sg_finish_rem_req()
1848 blk_put_request(srp->rq); in sg_finish_rem_req()
1851 if (srp->res_used) in sg_finish_rem_req()
1852 sg_unlink_reserve(sfp, srp); in sg_finish_rem_req()
1978 sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer) in sg_read_oxfer() argument
1980 Sg_scatter_hold *schp = &srp->data; in sg_read_oxfer()
1983 SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, srp->parentfp->parentdp, in sg_read_oxfer()
2029 sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size) in sg_link_reserve() argument
2031 Sg_scatter_hold *req_schp = &srp->data; in sg_link_reserve()
2035 srp->res_used = 1; in sg_link_reserve()
2060 sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp) in sg_unlink_reserve() argument
2062 Sg_scatter_hold *req_schp = &srp->data; in sg_unlink_reserve()
2064 SCSI_LOG_TIMEOUT(4, sg_printk(KERN_INFO, srp->parentfp->parentdp, in sg_unlink_reserve()
2072 srp->res_used = 0; in sg_unlink_reserve()
2130 sg_remove_request(Sg_fd * sfp, Sg_request * srp) in sg_remove_request() argument
2135 if (!sfp || !srp || list_empty(&sfp->rq_list)) in sg_remove_request()
2138 if (!list_empty(&srp->entry)) { in sg_remove_request()
2139 list_del(&srp->entry); in sg_remove_request()
2140 srp->parentfp = NULL; in sg_remove_request()
2200 Sg_request *srp; in sg_remove_sfp_usercontext() local
2206 srp = list_first_entry(&sfp->rq_list, Sg_request, entry); in sg_remove_sfp_usercontext()
2207 sg_finish_rem_req(srp); in sg_remove_sfp_usercontext()
2208 list_del(&srp->entry); in sg_remove_sfp_usercontext()
2209 srp->parentfp = NULL; in sg_remove_sfp_usercontext()
2521 Sg_request *srp; in sg_proc_debug_helper() local
2540 list_for_each_entry(srp, &fp->rq_list, entry) { in sg_proc_debug_helper()
2541 hp = &srp->header; in sg_proc_debug_helper()
2543 if (srp->res_used) { in sg_proc_debug_helper()
2556 blen = srp->data.bufflen; in sg_proc_debug_helper()
2557 usg = srp->data.k_use_sg; in sg_proc_debug_helper()
2558 seq_puts(s, srp->done ? in sg_proc_debug_helper()
2559 ((1 == srp->done) ? "rcv:" : "fin:") in sg_proc_debug_helper()
2562 srp->header.pack_id, blen); in sg_proc_debug_helper()
2563 if (srp->done) in sg_proc_debug_helper()
2573 (int) srp->data.cmd_opcode); in sg_proc_debug_helper()