Lines Matching refs:cmd

181 scsi_host_free_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd)  in scsi_host_free_command()  argument
185 if (cmd->prot_sdb) in scsi_host_free_command()
186 kmem_cache_free(scsi_sdb_cache, cmd->prot_sdb); in scsi_host_free_command()
187 kmem_cache_free(pool->sense_slab, cmd->sense_buffer); in scsi_host_free_command()
188 kmem_cache_free(pool->cmd_slab, cmd); in scsi_host_free_command()
203 struct scsi_cmnd *cmd; in scsi_host_alloc_command() local
205 cmd = kmem_cache_zalloc(pool->cmd_slab, gfp_mask | pool->gfp_mask); in scsi_host_alloc_command()
206 if (!cmd) in scsi_host_alloc_command()
209 cmd->sense_buffer = kmem_cache_alloc(pool->sense_slab, in scsi_host_alloc_command()
211 if (!cmd->sense_buffer) in scsi_host_alloc_command()
215 cmd->prot_sdb = kmem_cache_zalloc(scsi_sdb_cache, gfp_mask); in scsi_host_alloc_command()
216 if (!cmd->prot_sdb) in scsi_host_alloc_command()
220 return cmd; in scsi_host_alloc_command()
223 kmem_cache_free(pool->sense_slab, cmd->sense_buffer); in scsi_host_alloc_command()
225 kmem_cache_free(pool->cmd_slab, cmd); in scsi_host_alloc_command()
241 struct scsi_cmnd *cmd = scsi_host_alloc_command(shost, gfp_mask); in __scsi_get_command() local
243 if (unlikely(!cmd)) { in __scsi_get_command()
248 cmd = list_entry(shost->free_list.next, in __scsi_get_command()
250 list_del_init(&cmd->list); in __scsi_get_command()
254 if (cmd) { in __scsi_get_command()
257 buf = cmd->sense_buffer; in __scsi_get_command()
258 prot = cmd->prot_sdb; in __scsi_get_command()
260 memset(cmd, 0, sizeof(*cmd)); in __scsi_get_command()
262 cmd->sense_buffer = buf; in __scsi_get_command()
263 cmd->prot_sdb = prot; in __scsi_get_command()
267 return cmd; in __scsi_get_command()
279 struct scsi_cmnd *cmd = __scsi_get_command(dev->host, gfp_mask); in scsi_get_command() local
282 if (unlikely(cmd == NULL)) in scsi_get_command()
285 cmd->device = dev; in scsi_get_command()
286 INIT_LIST_HEAD(&cmd->list); in scsi_get_command()
287 INIT_DELAYED_WORK(&cmd->abort_work, scmd_eh_abort_handler); in scsi_get_command()
289 list_add_tail(&cmd->list, &dev->cmd_list); in scsi_get_command()
291 cmd->jiffies_at_alloc = jiffies; in scsi_get_command()
292 return cmd; in scsi_get_command()
300 static void __scsi_put_command(struct Scsi_Host *shost, struct scsi_cmnd *cmd) in __scsi_put_command() argument
307 list_add(&cmd->list, &shost->free_list); in __scsi_put_command()
308 cmd = NULL; in __scsi_put_command()
313 if (likely(cmd != NULL)) in __scsi_put_command()
314 scsi_host_free_command(shost, cmd); in __scsi_put_command()
325 void scsi_put_command(struct scsi_cmnd *cmd) in scsi_put_command() argument
330 spin_lock_irqsave(&cmd->device->list_lock, flags); in scsi_put_command()
331 BUG_ON(list_empty(&cmd->list)); in scsi_put_command()
332 list_del_init(&cmd->list); in scsi_put_command()
333 spin_unlock_irqrestore(&cmd->device->list_lock, flags); in scsi_put_command()
335 BUG_ON(delayed_work_pending(&cmd->abort_work)); in scsi_put_command()
337 __scsi_put_command(cmd->device->host, cmd); in scsi_put_command()
474 struct scsi_cmnd *cmd; in scsi_setup_command_freelist() local
486 cmd = scsi_host_alloc_command(shost, gfp_mask); in scsi_setup_command_freelist()
487 if (!cmd) { in scsi_setup_command_freelist()
492 list_add(&cmd->list, &shost->free_list); in scsi_setup_command_freelist()
510 struct scsi_cmnd *cmd; in scsi_destroy_command_freelist() local
512 cmd = list_entry(shost->free_list.next, struct scsi_cmnd, list); in scsi_destroy_command_freelist()
513 list_del_init(&cmd->list); in scsi_destroy_command_freelist()
514 scsi_host_free_command(shost, cmd); in scsi_destroy_command_freelist()
521 void scsi_log_send(struct scsi_cmnd *cmd) in scsi_log_send() argument
540 scmd_printk(KERN_INFO, cmd, in scsi_log_send()
541 "Send: scmd 0x%p\n", cmd); in scsi_log_send()
542 scsi_print_command(cmd); in scsi_log_send()
547 void scsi_log_completion(struct scsi_cmnd *cmd, int disposition) in scsi_log_completion() argument
566 if (((level > 0) && (cmd->result || disposition != SUCCESS)) || in scsi_log_completion()
568 scsi_print_result(cmd, "Done", disposition); in scsi_log_completion()
569 scsi_print_command(cmd); in scsi_log_completion()
570 if (status_byte(cmd->result) & CHECK_CONDITION) in scsi_log_completion()
571 scsi_print_sense(cmd); in scsi_log_completion()
573 scmd_printk(KERN_INFO, cmd, in scsi_log_completion()
575 atomic_read(&cmd->device->host->host_busy), in scsi_log_completion()
576 cmd->device->host->host_failed); in scsi_log_completion()
590 void scsi_cmd_get_serial(struct Scsi_Host *host, struct scsi_cmnd *cmd) in scsi_cmd_get_serial() argument
592 cmd->serial_number = host->cmd_serial_number++; in scsi_cmd_get_serial()
593 if (cmd->serial_number == 0) in scsi_cmd_get_serial()
594 cmd->serial_number = host->cmd_serial_number++; in scsi_cmd_get_serial()
606 void scsi_finish_command(struct scsi_cmnd *cmd) in scsi_finish_command() argument
608 struct scsi_device *sdev = cmd->device; in scsi_finish_command()
631 if (SCSI_SENSE_VALID(cmd)) in scsi_finish_command()
632 cmd->result |= (DRIVER_SENSE << 24); in scsi_finish_command()
636 "(result %x)\n", cmd->result)); in scsi_finish_command()
638 good_bytes = scsi_bufflen(cmd); in scsi_finish_command()
639 if (cmd->request->cmd_type != REQ_TYPE_BLOCK_PC) { in scsi_finish_command()
641 drv = scsi_cmd_to_driver(cmd); in scsi_finish_command()
643 good_bytes = drv->done(cmd); in scsi_finish_command()
651 good_bytes -= scsi_get_resid(cmd); in scsi_finish_command()
653 scsi_io_completion(cmd, good_bytes); in scsi_finish_command()
756 unsigned char cmd[16]; in scsi_vpd_inquiry() local
761 cmd[0] = INQUIRY; in scsi_vpd_inquiry()
762 cmd[1] = 1; /* EVPD */ in scsi_vpd_inquiry()
763 cmd[2] = page; in scsi_vpd_inquiry()
764 cmd[3] = len >> 8; in scsi_vpd_inquiry()
765 cmd[4] = len & 0xff; in scsi_vpd_inquiry()
766 cmd[5] = 0; /* Control byte */ in scsi_vpd_inquiry()
772 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, in scsi_vpd_inquiry()
938 unsigned char cmd[16]; in scsi_report_opcode() local
945 memset(cmd, 0, 16); in scsi_report_opcode()
946 cmd[0] = MAINTENANCE_IN; in scsi_report_opcode()
947 cmd[1] = MI_REPORT_SUPPORTED_OPERATION_CODES; in scsi_report_opcode()
948 cmd[2] = 1; /* One command format */ in scsi_report_opcode()
949 cmd[3] = opcode; in scsi_report_opcode()
950 put_unaligned_be32(len, &cmd[6]); in scsi_report_opcode()
953 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len, in scsi_report_opcode()