Commit 3f6270ef authored by FUJITA Tomonori's avatar FUJITA Tomonori Committed by James Bottomley

[SCSI] megaraid_old: convert to use the data buffer accessors

- remove the unnecessary map_single path.

- convert to use the new accessors for the sg lists and the
parameters.

Jens Axboe <jens.axboe@oracle.com> did the for_each_sg cleanup.
Signed-off-by: default avatarFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Acked-by: default avatarSumant Patro <sumant.patro@lsi.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 2b14ec78
...@@ -523,10 +523,8 @@ mega_build_cmd(adapter_t *adapter, Scsi_Cmnd *cmd, int *busy) ...@@ -523,10 +523,8 @@ mega_build_cmd(adapter_t *adapter, Scsi_Cmnd *cmd, int *busy)
/* /*
* filter the internal and ioctl commands * filter the internal and ioctl commands
*/ */
if((cmd->cmnd[0] == MEGA_INTERNAL_CMD)) { if((cmd->cmnd[0] == MEGA_INTERNAL_CMD))
return cmd->request_buffer; return (scb_t *)cmd->host_scribble;
}
/* /*
* We know what channels our logical drives are on - mega_find_card() * We know what channels our logical drives are on - mega_find_card()
...@@ -657,22 +655,14 @@ mega_build_cmd(adapter_t *adapter, Scsi_Cmnd *cmd, int *busy) ...@@ -657,22 +655,14 @@ mega_build_cmd(adapter_t *adapter, Scsi_Cmnd *cmd, int *busy)
case MODE_SENSE: { case MODE_SENSE: {
char *buf; char *buf;
if (cmd->use_sg) {
struct scatterlist *sg; struct scatterlist *sg;
sg = (struct scatterlist *)cmd->request_buffer; sg = scsi_sglist(cmd);
buf = kmap_atomic(sg->page, KM_IRQ0) + buf = kmap_atomic(sg->page, KM_IRQ0) + sg->offset;
sg->offset;
} else
buf = cmd->request_buffer;
memset(buf, 0, cmd->cmnd[4]);
if (cmd->use_sg) {
struct scatterlist *sg;
sg = (struct scatterlist *)cmd->request_buffer; memset(buf, 0, cmd->cmnd[4]);
kunmap_atomic(buf - sg->offset, KM_IRQ0); kunmap_atomic(buf - sg->offset, KM_IRQ0);
}
cmd->result = (DID_OK << 16); cmd->result = (DID_OK << 16);
cmd->scsi_done(cmd); cmd->scsi_done(cmd);
return NULL; return NULL;
...@@ -1551,24 +1541,16 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) ...@@ -1551,24 +1541,16 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)
islogical = adapter->logdrv_chan[cmd->device->channel]; islogical = adapter->logdrv_chan[cmd->device->channel];
if( cmd->cmnd[0] == INQUIRY && !islogical ) { if( cmd->cmnd[0] == INQUIRY && !islogical ) {
if( cmd->use_sg ) { sgl = scsi_sglist(cmd);
sgl = (struct scatterlist *)
cmd->request_buffer;
if( sgl->page ) { if( sgl->page ) {
c = *(unsigned char *) c = *(unsigned char *)
page_address((&sgl[0])->page) + page_address((&sgl[0])->page) +
(&sgl[0])->offset; (&sgl[0])->offset;
} } else {
else {
printk(KERN_WARNING printk(KERN_WARNING
"megaraid: invalid sg.\n"); "megaraid: invalid sg.\n");
c = 0; c = 0;
} }
}
else {
c = *(u8 *)cmd->request_buffer;
}
if(IS_RAID_CH(adapter, cmd->device->channel) && if(IS_RAID_CH(adapter, cmd->device->channel) &&
((c & 0x1F ) == TYPE_DISK)) { ((c & 0x1F ) == TYPE_DISK)) {
...@@ -1704,30 +1686,14 @@ mega_rundoneq (adapter_t *adapter) ...@@ -1704,30 +1686,14 @@ mega_rundoneq (adapter_t *adapter)
static void static void
mega_free_scb(adapter_t *adapter, scb_t *scb) mega_free_scb(adapter_t *adapter, scb_t *scb)
{ {
unsigned long length;
switch( scb->dma_type ) { switch( scb->dma_type ) {
case MEGA_DMA_TYPE_NONE: case MEGA_DMA_TYPE_NONE:
break; break;
case MEGA_BULK_DATA:
if (scb->cmd->use_sg == 0)
length = scb->cmd->request_bufflen;
else {
struct scatterlist *sgl =
(struct scatterlist *)scb->cmd->request_buffer;
length = sgl->length;
}
pci_unmap_page(adapter->dev, scb->dma_h_bulkdata,
length, scb->dma_direction);
break;
case MEGA_SGLIST: case MEGA_SGLIST:
pci_unmap_sg(adapter->dev, scb->cmd->request_buffer, scsi_dma_unmap(scb->cmd);
scb->cmd->use_sg, scb->dma_direction);
break; break;
default: default:
break; break;
} }
...@@ -1767,80 +1733,33 @@ __mega_busywait_mbox (adapter_t *adapter) ...@@ -1767,80 +1733,33 @@ __mega_busywait_mbox (adapter_t *adapter)
static int static int
mega_build_sglist(adapter_t *adapter, scb_t *scb, u32 *buf, u32 *len) mega_build_sglist(adapter_t *adapter, scb_t *scb, u32 *buf, u32 *len)
{ {
struct scatterlist *sgl; struct scatterlist *sg;
struct page *page;
unsigned long offset;
unsigned int length;
Scsi_Cmnd *cmd; Scsi_Cmnd *cmd;
int sgcnt; int sgcnt;
int idx; int idx;
cmd = scb->cmd; cmd = scb->cmd;
/* Scatter-gather not used */
if( cmd->use_sg == 0 || (cmd->use_sg == 1 &&
!adapter->has_64bit_addr)) {
if (cmd->use_sg == 0) {
page = virt_to_page(cmd->request_buffer);
offset = offset_in_page(cmd->request_buffer);
length = cmd->request_bufflen;
} else {
sgl = (struct scatterlist *)cmd->request_buffer;
page = sgl->page;
offset = sgl->offset;
length = sgl->length;
}
scb->dma_h_bulkdata = pci_map_page(adapter->dev,
page, offset,
length,
scb->dma_direction);
scb->dma_type = MEGA_BULK_DATA;
/*
* We need to handle special 64-bit commands that need a
* minimum of 1 SG
*/
if( adapter->has_64bit_addr ) {
scb->sgl64[0].address = scb->dma_h_bulkdata;
scb->sgl64[0].length = length;
*buf = (u32)scb->sgl_dma_addr;
*len = (u32)length;
return 1;
}
else {
*buf = (u32)scb->dma_h_bulkdata;
*len = (u32)length;
}
return 0;
}
sgl = (struct scatterlist *)cmd->request_buffer;
/* /*
* Copy Scatter-Gather list info into controller structure. * Copy Scatter-Gather list info into controller structure.
* *
* The number of sg elements returned must not exceed our limit * The number of sg elements returned must not exceed our limit
*/ */
sgcnt = pci_map_sg(adapter->dev, sgl, cmd->use_sg, sgcnt = scsi_dma_map(cmd);
scb->dma_direction);
scb->dma_type = MEGA_SGLIST; scb->dma_type = MEGA_SGLIST;
BUG_ON(sgcnt > adapter->sglen); BUG_ON(sgcnt > adapter->sglen || sgcnt < 0);
*len = 0; *len = 0;
for( idx = 0; idx < sgcnt; idx++, sgl++ ) { scsi_for_each_sg(cmd, sg, sgcnt, idx) {
if (adapter->has_64bit_addr) {
if( adapter->has_64bit_addr ) { scb->sgl64[idx].address = sg_dma_address(sg);
scb->sgl64[idx].address = sg_dma_address(sgl); *len += scb->sgl64[idx].length = sg_dma_len(sg);
*len += scb->sgl64[idx].length = sg_dma_len(sgl); } else {
} scb->sgl[idx].address = sg_dma_address(sg);
else { *len += scb->sgl[idx].length = sg_dma_len(sg);
scb->sgl[idx].address = sg_dma_address(sgl);
*len += scb->sgl[idx].length = sg_dma_len(sgl);
} }
} }
...@@ -4494,7 +4413,7 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru) ...@@ -4494,7 +4413,7 @@ mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
scmd->device = sdev; scmd->device = sdev;
scmd->device->host = adapter->host; scmd->device->host = adapter->host;
scmd->request_buffer = (void *)scb; scmd->host_scribble = (void *)scb;
scmd->cmnd[0] = MEGA_INTERNAL_CMD; scmd->cmnd[0] = MEGA_INTERNAL_CMD;
scb->state |= SCB_ACTIVE; scb->state |= SCB_ACTIVE;
......
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