Commit 5390cfc3 authored by scameron@beardog.cca.cpqcorp.net's avatar scameron@beardog.cca.cpqcorp.net Committed by Jens Axboe

cciss: factor out core of sendcmd_withirq() for use by SCSI error handling code

Factor the core of sendcmd_withirq out to provide a simpler interface
which provides access to full error information.
Signed-off-by: default avatarStephen M. Cameron <scameron@beardog.cca.cpqcorp.net>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent 40df6ae4
...@@ -2278,114 +2278,123 @@ static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, size_ ...@@ -2278,114 +2278,123 @@ static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff, size_
return status; return status;
} }
static int sendcmd_withirq(__u8 cmd, static int sendcmd_withirq_core(ctlr_info_t *h, CommandList_struct *c)
int ctlr,
void *buff,
size_t size,
unsigned int use_unit_num,
unsigned int log_unit, __u8 page_code, int cmd_type)
{ {
ctlr_info_t *h = hba[ctlr]; DECLARE_COMPLETION_ONSTACK(wait);
CommandList_struct *c;
u64bit buff_dma_handle; u64bit buff_dma_handle;
unsigned long flags; unsigned long flags;
int return_status; int return_status = IO_OK;
DECLARE_COMPLETION_ONSTACK(wait);
if ((c = cmd_alloc(h, 0)) == NULL) resend_cmd2:
return -ENOMEM;
return_status = fill_cmd(c, cmd, ctlr, buff, size, use_unit_num,
log_unit, page_code, NULL, cmd_type);
if (return_status != IO_OK) {
cmd_free(h, c, 0);
return return_status;
}
resend_cmd2:
c->waiting = &wait; c->waiting = &wait;
/* Put the request on the tail of the queue and send it */ /* Put the request on the tail of the queue and send it */
spin_lock_irqsave(CCISS_LOCK(ctlr), flags); spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags);
addQ(&h->reqQ, c); addQ(&h->reqQ, c);
h->Qdepth++; h->Qdepth++;
start_io(h); start_io(h);
spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags);
wait_for_completion(&wait); wait_for_completion(&wait);
if (c->err_info->CommandStatus != 0) { /* an error has occurred */ if (c->err_info->CommandStatus == 0)
switch (c->err_info->CommandStatus) { goto command_done;
case CMD_TARGET_STATUS:
printk(KERN_WARNING "cciss: cmd %p has "
" completed with errors\n", c);
if (c->err_info->ScsiStatus) {
printk(KERN_WARNING "cciss: cmd %p "
"has SCSI Status = %x\n",
c, c->err_info->ScsiStatus);
}
break; switch (c->err_info->CommandStatus) {
case CMD_DATA_UNDERRUN: case CMD_TARGET_STATUS:
case CMD_DATA_OVERRUN: printk(KERN_WARNING "cciss: cmd 0x%02x "
/* expected for inquire and report lun commands */ "has completed with errors\n", c->Request.CDB[0]);
break; if (c->err_info->ScsiStatus) {
case CMD_INVALID: printk(KERN_WARNING "cciss: cmd 0x%02x "
printk(KERN_WARNING "cciss: Cmd %p is " "has SCSI Status = %x\n",
"reported invalid\n", c); c->Request.CDB[0], c->err_info->ScsiStatus);
return_status = IO_ERROR; }
break; break;
case CMD_PROTOCOL_ERR: case CMD_DATA_UNDERRUN:
printk(KERN_WARNING "cciss: cmd %p has " case CMD_DATA_OVERRUN:
"protocol error \n", c); /* expected for inquiry and report lun commands */
return_status = IO_ERROR; break;
break; case CMD_INVALID:
case CMD_HARDWARE_ERR: printk(KERN_WARNING "cciss: Cmd 0x%02x is "
printk(KERN_WARNING "cciss: cmd %p had " "reported invalid\n", c->Request.CDB[0]);
" hardware error\n", c); return_status = IO_ERROR;
return_status = IO_ERROR; break;
break; case CMD_PROTOCOL_ERR:
case CMD_CONNECTION_LOST: printk(KERN_WARNING "cciss: cmd 0x%02x has "
printk(KERN_WARNING "cciss: cmd %p had " "protocol error \n", c->Request.CDB[0]);
"connection lost\n", c); return_status = IO_ERROR;
return_status = IO_ERROR; break;
break; case CMD_HARDWARE_ERR:
case CMD_ABORTED: printk(KERN_WARNING "cciss: cmd 0x%02x had "
printk(KERN_WARNING "cciss: cmd %p was " " hardware error\n", c->Request.CDB[0]);
"aborted\n", c); return_status = IO_ERROR;
return_status = IO_ERROR; break;
break; case CMD_CONNECTION_LOST:
case CMD_ABORT_FAILED: printk(KERN_WARNING "cciss: cmd 0x%02x had "
printk(KERN_WARNING "cciss: cmd %p reports " "connection lost\n", c->Request.CDB[0]);
"abort failed\n", c); return_status = IO_ERROR;
return_status = IO_ERROR; break;
break; case CMD_ABORTED:
case CMD_UNSOLICITED_ABORT: printk(KERN_WARNING "cciss: cmd 0x%02x was "
"aborted\n", c->Request.CDB[0]);
return_status = IO_ERROR;
break;
case CMD_ABORT_FAILED:
printk(KERN_WARNING "cciss: cmd 0x%02x reports "
"abort failed\n", c->Request.CDB[0]);
return_status = IO_ERROR;
break;
case CMD_UNSOLICITED_ABORT:
printk(KERN_WARNING
"cciss%d: unsolicited abort 0x%02x\n", h->ctlr,
c->Request.CDB[0]);
if (c->retry_count < MAX_CMD_RETRIES) {
printk(KERN_WARNING printk(KERN_WARNING
"cciss%d: unsolicited abort %p\n", ctlr, c); "cciss%d: retrying 0x%02x\n", h->ctlr,
if (c->retry_count < MAX_CMD_RETRIES) { c->Request.CDB[0]);
printk(KERN_WARNING c->retry_count++;
"cciss%d: retrying %p\n", ctlr, c); /* erase the old error information */
c->retry_count++; memset(c->err_info, 0,
/* erase the old error information */ sizeof(ErrorInfo_struct));
memset(c->err_info, 0, return_status = IO_OK;
sizeof(ErrorInfo_struct)); INIT_COMPLETION(wait);
return_status = IO_OK; goto resend_cmd2;
INIT_COMPLETION(wait);
goto resend_cmd2;
}
return_status = IO_ERROR;
break;
default:
printk(KERN_WARNING "cciss: cmd %p returned "
"unknown status %x\n", c,
c->err_info->CommandStatus);
return_status = IO_ERROR;
} }
return_status = IO_ERROR;
break;
default:
printk(KERN_WARNING "cciss: cmd 0x%02x returned "
"unknown status %x\n", c->Request.CDB[0],
c->err_info->CommandStatus);
return_status = IO_ERROR;
} }
command_done:
/* unlock the buffers from DMA */ /* unlock the buffers from DMA */
buff_dma_handle.val32.lower = c->SG[0].Addr.lower; buff_dma_handle.val32.lower = c->SG[0].Addr.lower;
buff_dma_handle.val32.upper = c->SG[0].Addr.upper; buff_dma_handle.val32.upper = c->SG[0].Addr.upper;
pci_unmap_single(h->pdev, (dma_addr_t) buff_dma_handle.val, pci_unmap_single(h->pdev, (dma_addr_t) buff_dma_handle.val,
c->SG[0].Len, PCI_DMA_BIDIRECTIONAL); c->SG[0].Len, PCI_DMA_BIDIRECTIONAL);
return return_status;
}
static int sendcmd_withirq(__u8 cmd,
int ctlr,
void *buff,
size_t size,
unsigned int use_unit_num,
unsigned int log_unit, __u8 page_code, int cmd_type)
{
ctlr_info_t *h = hba[ctlr];
CommandList_struct *c;
int return_status;
c = cmd_alloc(h, 0);
if (!c)
return -ENOMEM;
return_status = fill_cmd(c, cmd, ctlr, buff, size, use_unit_num,
log_unit, page_code, NULL, cmd_type);
if (return_status == IO_OK)
return_status = sendcmd_withirq_core(h, c);
cmd_free(h, c, 0); cmd_free(h, c, 0);
return return_status; return return_status;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment