aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ieee1394/sbp2.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ieee1394/sbp2.c')
-rw-r--r--drivers/ieee1394/sbp2.c75
1 files changed, 4 insertions, 71 deletions
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index e0c385a3b450..e882cb951b47 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -1509,69 +1509,6 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
1509 } 1509 }
1510} 1510}
1511 1511
1512static void sbp2_prep_command_orb_no_sg(struct sbp2_command_orb *orb,
1513 struct sbp2_fwhost_info *hi,
1514 struct sbp2_command_info *cmd,
1515 struct scatterlist *sgpnt,
1516 u32 orb_direction,
1517 unsigned int scsi_request_bufflen,
1518 void *scsi_request_buffer,
1519 enum dma_data_direction dma_dir)
1520{
1521 cmd->dma_dir = dma_dir;
1522 cmd->dma_size = scsi_request_bufflen;
1523 cmd->dma_type = CMD_DMA_SINGLE;
1524 cmd->cmd_dma = dma_map_single(hi->host->device.parent,
1525 scsi_request_buffer,
1526 cmd->dma_size, cmd->dma_dir);
1527 orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id);
1528 orb->misc |= ORB_SET_DIRECTION(orb_direction);
1529
1530 /* handle case where we get a command w/o s/g enabled
1531 * (but check for transfers larger than 64K) */
1532 if (scsi_request_bufflen <= SBP2_MAX_SG_ELEMENT_LENGTH) {
1533
1534 orb->data_descriptor_lo = cmd->cmd_dma;
1535 orb->misc |= ORB_SET_DATA_SIZE(scsi_request_bufflen);
1536
1537 } else {
1538 /* The buffer is too large. Turn this into page tables. */
1539
1540 struct sbp2_unrestricted_page_table *sg_element =
1541 &cmd->scatter_gather_element[0];
1542 u32 sg_count, sg_len;
1543 dma_addr_t sg_addr;
1544
1545 orb->data_descriptor_lo = cmd->sge_dma;
1546 orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1);
1547
1548 /* fill out our SBP-2 page tables; split up the large buffer */
1549 sg_count = 0;
1550 sg_len = scsi_request_bufflen;
1551 sg_addr = cmd->cmd_dma;
1552 while (sg_len) {
1553 sg_element[sg_count].segment_base_lo = sg_addr;
1554 if (sg_len > SBP2_MAX_SG_ELEMENT_LENGTH) {
1555 sg_element[sg_count].length_segment_base_hi =
1556 PAGE_TABLE_SET_SEGMENT_LENGTH(SBP2_MAX_SG_ELEMENT_LENGTH);
1557 sg_addr += SBP2_MAX_SG_ELEMENT_LENGTH;
1558 sg_len -= SBP2_MAX_SG_ELEMENT_LENGTH;
1559 } else {
1560 sg_element[sg_count].length_segment_base_hi =
1561 PAGE_TABLE_SET_SEGMENT_LENGTH(sg_len);
1562 sg_len = 0;
1563 }
1564 sg_count++;
1565 }
1566
1567 orb->misc |= ORB_SET_DATA_SIZE(sg_count);
1568
1569 sbp2util_cpu_to_be32_buffer(sg_element,
1570 (sizeof(struct sbp2_unrestricted_page_table)) *
1571 sg_count);
1572 }
1573}
1574
1575static void sbp2_create_command_orb(struct sbp2_lu *lu, 1512static void sbp2_create_command_orb(struct sbp2_lu *lu,
1576 struct sbp2_command_info *cmd, 1513 struct sbp2_command_info *cmd,
1577 unchar *scsi_cmd, 1514 unchar *scsi_cmd,
@@ -1615,13 +1552,9 @@ static void sbp2_create_command_orb(struct sbp2_lu *lu,
1615 orb->data_descriptor_hi = 0x0; 1552 orb->data_descriptor_hi = 0x0;
1616 orb->data_descriptor_lo = 0x0; 1553 orb->data_descriptor_lo = 0x0;
1617 orb->misc |= ORB_SET_DIRECTION(1); 1554 orb->misc |= ORB_SET_DIRECTION(1);
1618 } else if (scsi_use_sg) 1555 } else
1619 sbp2_prep_command_orb_sg(orb, hi, cmd, scsi_use_sg, sgpnt, 1556 sbp2_prep_command_orb_sg(orb, hi, cmd, scsi_use_sg, sgpnt,
1620 orb_direction, dma_dir); 1557 orb_direction, dma_dir);
1621 else
1622 sbp2_prep_command_orb_no_sg(orb, hi, cmd, sgpnt, orb_direction,
1623 scsi_request_bufflen,
1624 scsi_request_buffer, dma_dir);
1625 1558
1626 sbp2util_cpu_to_be32_buffer(orb, sizeof(*orb)); 1559 sbp2util_cpu_to_be32_buffer(orb, sizeof(*orb));
1627 1560
@@ -1710,15 +1643,15 @@ static int sbp2_send_command(struct sbp2_lu *lu, struct scsi_cmnd *SCpnt,
1710 void (*done)(struct scsi_cmnd *)) 1643 void (*done)(struct scsi_cmnd *))
1711{ 1644{
1712 unchar *scsi_cmd = (unchar *)SCpnt->cmnd; 1645 unchar *scsi_cmd = (unchar *)SCpnt->cmnd;
1713 unsigned int request_bufflen = SCpnt->request_bufflen; 1646 unsigned int request_bufflen = scsi_bufflen(SCpnt);
1714 struct sbp2_command_info *cmd; 1647 struct sbp2_command_info *cmd;
1715 1648
1716 cmd = sbp2util_allocate_command_orb(lu, SCpnt, done); 1649 cmd = sbp2util_allocate_command_orb(lu, SCpnt, done);
1717 if (!cmd) 1650 if (!cmd)
1718 return -EIO; 1651 return -EIO;
1719 1652
1720 sbp2_create_command_orb(lu, cmd, scsi_cmd, SCpnt->use_sg, 1653 sbp2_create_command_orb(lu, cmd, scsi_cmd, scsi_sg_count(SCpnt),
1721 request_bufflen, SCpnt->request_buffer, 1654 request_bufflen, scsi_sglist(SCpnt),
1722 SCpnt->sc_data_direction); 1655 SCpnt->sc_data_direction);
1723 sbp2_link_orb_command(lu, cmd); 1656 sbp2_link_orb_command(lu, cmd);
1724 1657