Lines Matching full:job

39 	struct bsg_job *job = blk_mq_rq_to_pdu(rq);  in bsg_transport_fill_hdr()  local
42 job->request_len = hdr->request_len; in bsg_transport_fill_hdr()
43 job->request = memdup_user(uptr64(hdr->request), hdr->request_len); in bsg_transport_fill_hdr()
44 if (IS_ERR(job->request)) in bsg_transport_fill_hdr()
45 return PTR_ERR(job->request); in bsg_transport_fill_hdr()
48 job->bidi_rq = blk_get_request(rq->q, REQ_OP_SCSI_IN, 0); in bsg_transport_fill_hdr()
49 if (IS_ERR(job->bidi_rq)) { in bsg_transport_fill_hdr()
50 ret = PTR_ERR(job->bidi_rq); in bsg_transport_fill_hdr()
54 ret = blk_rq_map_user(rq->q, job->bidi_rq, NULL, in bsg_transport_fill_hdr()
60 job->bidi_bio = job->bidi_rq->bio; in bsg_transport_fill_hdr()
62 job->bidi_rq = NULL; in bsg_transport_fill_hdr()
63 job->bidi_bio = NULL; in bsg_transport_fill_hdr()
69 if (job->bidi_rq) in bsg_transport_fill_hdr()
70 blk_put_request(job->bidi_rq); in bsg_transport_fill_hdr()
72 kfree(job->request); in bsg_transport_fill_hdr()
78 struct bsg_job *job = blk_mq_rq_to_pdu(rq); in bsg_transport_complete_rq() local
85 hdr->device_status = job->result & 0xff; in bsg_transport_complete_rq()
86 hdr->transport_status = host_byte(job->result); in bsg_transport_complete_rq()
87 hdr->driver_status = driver_byte(job->result); in bsg_transport_complete_rq()
93 if (job->result < 0) { in bsg_transport_complete_rq()
95 job->reply_len = sizeof(u32); in bsg_transport_complete_rq()
96 ret = job->result; in bsg_transport_complete_rq()
99 if (job->reply_len && hdr->response) { in bsg_transport_complete_rq()
100 int len = min(hdr->max_response_len, job->reply_len); in bsg_transport_complete_rq()
102 if (copy_to_user(uptr64(hdr->response), job->reply, len)) in bsg_transport_complete_rq()
111 if (job->bidi_rq) { in bsg_transport_complete_rq()
112 unsigned int rsp_len = job->reply_payload.payload_len; in bsg_transport_complete_rq()
114 if (WARN_ON(job->reply_payload_rcv_len > rsp_len)) in bsg_transport_complete_rq()
117 hdr->din_resid = rsp_len - job->reply_payload_rcv_len; in bsg_transport_complete_rq()
127 struct bsg_job *job = blk_mq_rq_to_pdu(rq); in bsg_transport_free_rq() local
129 if (job->bidi_rq) { in bsg_transport_free_rq()
130 blk_rq_unmap_user(job->bidi_bio); in bsg_transport_free_rq()
131 blk_put_request(job->bidi_rq); in bsg_transport_free_rq()
134 kfree(job->request); in bsg_transport_free_rq()
145 * bsg_teardown_job - routine to teardown a bsg job
150 struct bsg_job *job = container_of(kref, struct bsg_job, kref); in bsg_teardown_job() local
151 struct request *rq = blk_mq_rq_from_pdu(job); in bsg_teardown_job()
153 put_device(job->dev); /* release reference for the request */ in bsg_teardown_job()
155 kfree(job->request_payload.sg_list); in bsg_teardown_job()
156 kfree(job->reply_payload.sg_list); in bsg_teardown_job()
161 void bsg_job_put(struct bsg_job *job) in bsg_job_put() argument
163 kref_put(&job->kref, bsg_teardown_job); in bsg_job_put()
167 int bsg_job_get(struct bsg_job *job) in bsg_job_get() argument
169 return kref_get_unless_zero(&job->kref); in bsg_job_get()
175 * @job: bsg_job that is complete
176 * @result: job reply result
179 * The LLD should call this when the bsg job has completed.
181 void bsg_job_done(struct bsg_job *job, int result, in bsg_job_done() argument
184 struct request *rq = blk_mq_rq_from_pdu(job); in bsg_job_done()
186 job->result = result; in bsg_job_done()
187 job->reply_payload_rcv_len = reply_payload_rcv_len; in bsg_job_done()
195 * @rq: BSG request that holds the job to be destroyed
199 struct bsg_job *job = blk_mq_rq_to_pdu(rq); in bsg_complete() local
201 bsg_job_put(job); in bsg_complete()
222 * @req: BSG request that needs a job structure
226 struct bsg_job *job = blk_mq_rq_to_pdu(req); in bsg_prepare_job() local
229 job->timeout = req->timeout; in bsg_prepare_job()
232 ret = bsg_map_buffer(&job->request_payload, req); in bsg_prepare_job()
236 if (job->bidi_rq) { in bsg_prepare_job()
237 ret = bsg_map_buffer(&job->reply_payload, job->bidi_rq); in bsg_prepare_job()
241 job->dev = dev; in bsg_prepare_job()
243 get_device(job->dev); in bsg_prepare_job()
244 kref_init(&job->kref); in bsg_prepare_job()
248 kfree(job->request_payload.sg_list); in bsg_prepare_job()
250 job->result = -ENOMEM; in bsg_prepare_job()
296 struct bsg_job *job = blk_mq_rq_to_pdu(req); in bsg_init_rq() local
298 job->reply = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL); in bsg_init_rq()
299 if (!job->reply) in bsg_init_rq()
307 struct bsg_job *job = blk_mq_rq_to_pdu(req); in bsg_initialize_rq() local
308 void *reply = job->reply; in bsg_initialize_rq()
310 memset(job, 0, sizeof(*job)); in bsg_initialize_rq()
311 job->reply = reply; in bsg_initialize_rq()
312 job->reply_len = SCSI_SENSE_BUFFERSIZE; in bsg_initialize_rq()
313 job->dd_data = job + 1; in bsg_initialize_rq()
319 struct bsg_job *job = blk_mq_rq_to_pdu(req); in bsg_exit_rq() local
321 kfree(job->reply); in bsg_exit_rq()
361 * @job_fn: bsg job handler
363 * @dd_job_size: size of LLD data needed for each job