Lines Matching refs:cmd
135 scsi_host_free_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd) in scsi_host_free_command() argument
139 if (cmd->prot_sdb) in scsi_host_free_command()
140 kmem_cache_free(scsi_sdb_cache, cmd->prot_sdb); in scsi_host_free_command()
141 kmem_cache_free(pool->sense_slab, cmd->sense_buffer); in scsi_host_free_command()
142 kmem_cache_free(pool->cmd_slab, cmd); in scsi_host_free_command()
157 struct scsi_cmnd *cmd; in scsi_host_alloc_command() local
159 cmd = kmem_cache_zalloc(pool->cmd_slab, gfp_mask | pool->gfp_mask); in scsi_host_alloc_command()
160 if (!cmd) in scsi_host_alloc_command()
163 cmd->sense_buffer = kmem_cache_alloc(pool->sense_slab, in scsi_host_alloc_command()
165 if (!cmd->sense_buffer) in scsi_host_alloc_command()
169 cmd->prot_sdb = kmem_cache_zalloc(scsi_sdb_cache, gfp_mask); in scsi_host_alloc_command()
170 if (!cmd->prot_sdb) in scsi_host_alloc_command()
174 return cmd; in scsi_host_alloc_command()
177 kmem_cache_free(pool->sense_slab, cmd->sense_buffer); in scsi_host_alloc_command()
179 kmem_cache_free(pool->cmd_slab, cmd); in scsi_host_alloc_command()
195 struct scsi_cmnd *cmd = scsi_host_alloc_command(shost, gfp_mask); in __scsi_get_command() local
197 if (unlikely(!cmd)) { in __scsi_get_command()
202 cmd = list_entry(shost->free_list.next, in __scsi_get_command()
204 list_del_init(&cmd->list); in __scsi_get_command()
208 if (cmd) { in __scsi_get_command()
211 buf = cmd->sense_buffer; in __scsi_get_command()
212 prot = cmd->prot_sdb; in __scsi_get_command()
214 memset(cmd, 0, sizeof(*cmd)); in __scsi_get_command()
216 cmd->sense_buffer = buf; in __scsi_get_command()
217 cmd->prot_sdb = prot; in __scsi_get_command()
221 return cmd; in __scsi_get_command()
233 struct scsi_cmnd *cmd = __scsi_get_command(dev->host, gfp_mask); in scsi_get_command() local
236 if (unlikely(cmd == NULL)) in scsi_get_command()
239 cmd->device = dev; in scsi_get_command()
240 INIT_LIST_HEAD(&cmd->list); in scsi_get_command()
241 INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler); in scsi_get_command()
243 list_add_tail(&cmd->list, &dev->cmd_list); in scsi_get_command()
245 cmd->jiffies_at_alloc = jiffies; in scsi_get_command()
246 return cmd; in scsi_get_command()
254 static void __scsi_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd) in __scsi_put_command() argument
261 list_add(&cmd->list, &shost->free_list); in __scsi_put_command()
262 cmd = NULL; in __scsi_put_command()
267 if (likely(cmd != NULL)) in __scsi_put_command()
268 scsi_host_free_command(shost, cmd); in __scsi_put_command()
279 void scsi_put_command(struct scsi_cmnd *cmd) in scsi_put_command() argument
284 spin_lock_irqsave(&cmd->device->list_lock, flags); in scsi_put_command()
285 BUG_ON(list_empty(&cmd->list)); in scsi_put_command()
286 list_del_init(&cmd->list); in scsi_put_command()
287 spin_unlock_irqrestore(&cmd->device->list_lock, flags); in scsi_put_command()
289 BUG_ON(delayed_work_pending(&cmd->abort_work)); in scsi_put_command()
291 __scsi_put_command(cmd->device->host, cmd); in scsi_put_command()
428 struct scsi_cmnd *cmd; in scsi_setup_command_freelist() local
440 cmd = scsi_host_alloc_command(shost, gfp_mask); in scsi_setup_command_freelist()
441 if (!cmd) { in scsi_setup_command_freelist()
446 list_add(&cmd->list, &shost->free_list); in scsi_setup_command_freelist()
464 struct scsi_cmnd *cmd; in scsi_destroy_command_freelist() local
466 cmd = list_entry(shost->free_list.next, struct scsi_cmnd, list); in scsi_destroy_command_freelist()
467 list_del_init(&cmd->list); in scsi_destroy_command_freelist()
468 scsi_host_free_command(shost, cmd); in scsi_destroy_command_freelist()
475 void scsi_log_send(struct scsi_cmnd *cmd) in scsi_log_send() argument
494 scmd_printk(KERN_INFO, cmd, in scsi_log_send()
495 "Send: scmd 0x%p\n", cmd); in scsi_log_send()
496 scsi_print_command(cmd); in scsi_log_send()
501 void scsi_log_completion(struct scsi_cmnd *cmd, int disposition) in scsi_log_completion() argument
520 if (((level > 0) && (cmd->result || disposition != SUCCESS)) || in scsi_log_completion()
522 scsi_print_result(cmd, "Done", disposition); in scsi_log_completion()
523 scsi_print_command(cmd); in scsi_log_completion()
524 if (status_byte(cmd->result) & CHECK_CONDITION) in scsi_log_completion()
525 scsi_print_sense(cmd); in scsi_log_completion()
527 scmd_printk(KERN_INFO, cmd, in scsi_log_completion()
529 atomic_read(&cmd->device->host->host_busy), in scsi_log_completion()
530 cmd->device->host->host_failed); in scsi_log_completion()
544 void scsi_cmd_get_serial(struct Scsi_Host *host, struct scsi_cmnd *cmd) in scsi_cmd_get_serial() argument
546 cmd->serial_number = host->cmd_serial_number++; in scsi_cmd_get_serial()
547 if (cmd->serial_number == 0) in scsi_cmd_get_serial()
548 cmd->serial_number = host->cmd_serial_number++; in scsi_cmd_get_serial()
560 void scsi_finish_command(struct scsi_cmnd *cmd) in scsi_finish_command() argument
562 struct scsi_device *sdev = cmd->device; in scsi_finish_command()
585 if (SCSI_SENSE_VALID(cmd)) in scsi_finish_command()
586 cmd->result |= (DRIVER_SENSE << 24); in scsi_finish_command()
590 "(result %x)\n", cmd->result)); in scsi_finish_command()
592 good_bytes = scsi_bufflen(cmd); in scsi_finish_command()
593 if (cmd->request->cmd_type != REQ_TYPE_BLOCK_PC) { in scsi_finish_command()
595 drv = scsi_cmd_to_driver(cmd); in scsi_finish_command()
597 good_bytes = drv->done(cmd); in scsi_finish_command()
605 good_bytes -= scsi_get_resid(cmd); in scsi_finish_command()
607 scsi_io_completion(cmd, good_bytes); in scsi_finish_command()
689 unsigned char cmd[16]; in scsi_vpd_inquiry() local
694 cmd[0] = INQUIRY; in scsi_vpd_inquiry()
695 cmd[1] = 1; /* EVPD */ in scsi_vpd_inquiry()
696 cmd[2] = page; in scsi_vpd_inquiry()
697 cmd[3] = len >> 8; in scsi_vpd_inquiry()
698 cmd[4] = len & 0xff; in scsi_vpd_inquiry()
699 cmd[5] = 0; /* Control byte */ in scsi_vpd_inquiry()
705 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, in scsi_vpd_inquiry()
871 unsigned char cmd[16]; in scsi_report_opcode() local
878 memset(cmd, 0, 16); in scsi_report_opcode()
879 cmd[0] = MAINTENANCE_IN; in scsi_report_opcode()
880 cmd[1] = MI_REPORT_SUPPORTED_OPERATION_CODES; in scsi_report_opcode()
881 cmd[2] = 1; /* One command format */ in scsi_report_opcode()
882 cmd[3] = opcode; in scsi_report_opcode()
883 put_unaligned_be32(len, &cmd[6]); in scsi_report_opcode()
886 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len, in scsi_report_opcode()