diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2008-08-09 14:13:00 -0400 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2008-10-15 16:21:07 -0400 |
commit | 0a77b17c855c4ec1c87ed80e0f280095a4ee1f4f (patch) | |
tree | e5665d7f5be5b0f7200bdcb9582936ae37490727 /drivers | |
parent | 68e2aa793ed55b0c1461b4ab92554bb5ad152724 (diff) |
ieee1394: sbp2: stricter dma_sync
Two dma_sync_single_for_cpu() were called in the wrong place.
Luckily they were merely for DMA_TO_DEVICE, hence nobody noticed.
Also reorder the matching dma_sync_single_for_device() a little bit
so that they reside in the same functions as their counterparts.
This also avoids syncing the s/g table for requests which don't use it.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ieee1394/sbp2.c | 50 |
1 files changed, 16 insertions, 34 deletions
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index 1d6ad3435537..7a8119e0c910 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c | |||
@@ -1533,6 +1533,10 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb, | |||
1533 | orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1); | 1533 | orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1); |
1534 | orb->data_descriptor_lo = cmd->sge_dma; | 1534 | orb->data_descriptor_lo = cmd->sge_dma; |
1535 | 1535 | ||
1536 | dma_sync_single_for_cpu(hi->host->device.parent, cmd->sge_dma, | ||
1537 | sizeof(cmd->scatter_gather_element), | ||
1538 | DMA_TO_DEVICE); | ||
1539 | |||
1536 | /* loop through and fill out our SBP-2 page tables | 1540 | /* loop through and fill out our SBP-2 page tables |
1537 | * (and split up anything too large) */ | 1541 | * (and split up anything too large) */ |
1538 | for (i = 0, sg_count = 0; i < count; i++, sg = sg_next(sg)) { | 1542 | for (i = 0, sg_count = 0; i < count; i++, sg = sg_next(sg)) { |
@@ -1559,6 +1563,11 @@ static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb, | |||
1559 | sbp2util_cpu_to_be32_buffer(sg_element, | 1563 | sbp2util_cpu_to_be32_buffer(sg_element, |
1560 | (sizeof(struct sbp2_unrestricted_page_table)) * | 1564 | (sizeof(struct sbp2_unrestricted_page_table)) * |
1561 | sg_count); | 1565 | sg_count); |
1566 | |||
1567 | dma_sync_single_for_device(hi->host->device.parent, | ||
1568 | cmd->sge_dma, | ||
1569 | sizeof(cmd->scatter_gather_element), | ||
1570 | DMA_TO_DEVICE); | ||
1562 | } | 1571 | } |
1563 | } | 1572 | } |
1564 | 1573 | ||
@@ -1566,12 +1575,14 @@ static void sbp2_create_command_orb(struct sbp2_lu *lu, | |||
1566 | struct sbp2_command_info *cmd, | 1575 | struct sbp2_command_info *cmd, |
1567 | struct scsi_cmnd *SCpnt) | 1576 | struct scsi_cmnd *SCpnt) |
1568 | { | 1577 | { |
1569 | struct sbp2_fwhost_info *hi = lu->hi; | 1578 | struct device *dmadev = lu->hi->host->device.parent; |
1570 | struct sbp2_command_orb *orb = &cmd->command_orb; | 1579 | struct sbp2_command_orb *orb = &cmd->command_orb; |
1571 | u32 orb_direction; | 1580 | u32 orb_direction; |
1572 | unsigned int scsi_request_bufflen = scsi_bufflen(SCpnt); | 1581 | unsigned int scsi_request_bufflen = scsi_bufflen(SCpnt); |
1573 | enum dma_data_direction dma_dir = SCpnt->sc_data_direction; | 1582 | enum dma_data_direction dma_dir = SCpnt->sc_data_direction; |
1574 | 1583 | ||
1584 | dma_sync_single_for_cpu(dmadev, cmd->command_orb_dma, | ||
1585 | sizeof(struct sbp2_command_orb), DMA_TO_DEVICE); | ||
1575 | /* | 1586 | /* |
1576 | * Set-up our command ORB. | 1587 | * Set-up our command ORB. |
1577 | * | 1588 | * |
@@ -1603,7 +1614,7 @@ static void sbp2_create_command_orb(struct sbp2_lu *lu, | |||
1603 | orb->data_descriptor_lo = 0x0; | 1614 | orb->data_descriptor_lo = 0x0; |
1604 | orb->misc |= ORB_SET_DIRECTION(1); | 1615 | orb->misc |= ORB_SET_DIRECTION(1); |
1605 | } else | 1616 | } else |
1606 | sbp2_prep_command_orb_sg(orb, hi, cmd, scsi_sg_count(SCpnt), | 1617 | sbp2_prep_command_orb_sg(orb, lu->hi, cmd, scsi_sg_count(SCpnt), |
1607 | scsi_sglist(SCpnt), | 1618 | scsi_sglist(SCpnt), |
1608 | orb_direction, dma_dir); | 1619 | orb_direction, dma_dir); |
1609 | 1620 | ||
@@ -1611,6 +1622,9 @@ static void sbp2_create_command_orb(struct sbp2_lu *lu, | |||
1611 | 1622 | ||
1612 | memset(orb->cdb, 0, sizeof(orb->cdb)); | 1623 | memset(orb->cdb, 0, sizeof(orb->cdb)); |
1613 | memcpy(orb->cdb, SCpnt->cmnd, SCpnt->cmd_len); | 1624 | memcpy(orb->cdb, SCpnt->cmnd, SCpnt->cmd_len); |
1625 | |||
1626 | dma_sync_single_for_device(dmadev, cmd->command_orb_dma, | ||
1627 | sizeof(struct sbp2_command_orb), DMA_TO_DEVICE); | ||
1614 | } | 1628 | } |
1615 | 1629 | ||
1616 | static void sbp2_link_orb_command(struct sbp2_lu *lu, | 1630 | static void sbp2_link_orb_command(struct sbp2_lu *lu, |
@@ -1624,14 +1638,6 @@ static void sbp2_link_orb_command(struct sbp2_lu *lu, | |||
1624 | size_t length; | 1638 | size_t length; |
1625 | unsigned long flags; | 1639 | unsigned long flags; |
1626 | 1640 | ||
1627 | dma_sync_single_for_device(hi->host->device.parent, | ||
1628 | cmd->command_orb_dma, | ||
1629 | sizeof(struct sbp2_command_orb), | ||
1630 | DMA_TO_DEVICE); | ||
1631 | dma_sync_single_for_device(hi->host->device.parent, cmd->sge_dma, | ||
1632 | sizeof(cmd->scatter_gather_element), | ||
1633 | DMA_TO_DEVICE); | ||
1634 | |||
1635 | /* check to see if there are any previous orbs to use */ | 1641 | /* check to see if there are any previous orbs to use */ |
1636 | spin_lock_irqsave(&lu->cmd_orb_lock, flags); | 1642 | spin_lock_irqsave(&lu->cmd_orb_lock, flags); |
1637 | last_orb = lu->last_orb; | 1643 | last_orb = lu->last_orb; |
@@ -1789,13 +1795,6 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, | |||
1789 | else | 1795 | else |
1790 | cmd = sbp2util_find_command_for_orb(lu, sb->ORB_offset_lo); | 1796 | cmd = sbp2util_find_command_for_orb(lu, sb->ORB_offset_lo); |
1791 | if (cmd) { | 1797 | if (cmd) { |
1792 | dma_sync_single_for_cpu(hi->host->device.parent, | ||
1793 | cmd->command_orb_dma, | ||
1794 | sizeof(struct sbp2_command_orb), | ||
1795 | DMA_TO_DEVICE); | ||
1796 | dma_sync_single_for_cpu(hi->host->device.parent, cmd->sge_dma, | ||
1797 | sizeof(cmd->scatter_gather_element), | ||
1798 | DMA_TO_DEVICE); | ||
1799 | /* Grab SCSI command pointers and check status. */ | 1798 | /* Grab SCSI command pointers and check status. */ |
1800 | /* | 1799 | /* |
1801 | * FIXME: If the src field in the status is 1, the ORB DMA must | 1800 | * FIXME: If the src field in the status is 1, the ORB DMA must |
@@ -1912,7 +1911,6 @@ done: | |||
1912 | 1911 | ||
1913 | static void sbp2scsi_complete_all_commands(struct sbp2_lu *lu, u32 status) | 1912 | static void sbp2scsi_complete_all_commands(struct sbp2_lu *lu, u32 status) |
1914 | { | 1913 | { |
1915 | struct sbp2_fwhost_info *hi = lu->hi; | ||
1916 | struct list_head *lh; | 1914 | struct list_head *lh; |
1917 | struct sbp2_command_info *cmd; | 1915 | struct sbp2_command_info *cmd; |
1918 | unsigned long flags; | 1916 | unsigned long flags; |
@@ -1921,13 +1919,6 @@ static void sbp2scsi_complete_all_commands(struct sbp2_lu *lu, u32 status) | |||
1921 | while (!list_empty(&lu->cmd_orb_inuse)) { | 1919 | while (!list_empty(&lu->cmd_orb_inuse)) { |
1922 | lh = lu->cmd_orb_inuse.next; | 1920 | lh = lu->cmd_orb_inuse.next; |
1923 | cmd = list_entry(lh, struct sbp2_command_info, list); | 1921 | cmd = list_entry(lh, struct sbp2_command_info, list); |
1924 | dma_sync_single_for_cpu(hi->host->device.parent, | ||
1925 | cmd->command_orb_dma, | ||
1926 | sizeof(struct sbp2_command_orb), | ||
1927 | DMA_TO_DEVICE); | ||
1928 | dma_sync_single_for_cpu(hi->host->device.parent, cmd->sge_dma, | ||
1929 | sizeof(cmd->scatter_gather_element), | ||
1930 | DMA_TO_DEVICE); | ||
1931 | sbp2util_mark_command_completed(lu, cmd); | 1922 | sbp2util_mark_command_completed(lu, cmd); |
1932 | if (cmd->Current_SCpnt) { | 1923 | if (cmd->Current_SCpnt) { |
1933 | cmd->Current_SCpnt->result = status << 16; | 1924 | cmd->Current_SCpnt->result = status << 16; |
@@ -2049,7 +2040,6 @@ static void sbp2scsi_slave_destroy(struct scsi_device *sdev) | |||
2049 | static int sbp2scsi_abort(struct scsi_cmnd *SCpnt) | 2040 | static int sbp2scsi_abort(struct scsi_cmnd *SCpnt) |
2050 | { | 2041 | { |
2051 | struct sbp2_lu *lu = (struct sbp2_lu *)SCpnt->device->host->hostdata[0]; | 2042 | struct sbp2_lu *lu = (struct sbp2_lu *)SCpnt->device->host->hostdata[0]; |
2052 | struct sbp2_fwhost_info *hi = lu->hi; | ||
2053 | struct sbp2_command_info *cmd; | 2043 | struct sbp2_command_info *cmd; |
2054 | unsigned long flags; | 2044 | unsigned long flags; |
2055 | 2045 | ||
@@ -2063,14 +2053,6 @@ static int sbp2scsi_abort(struct scsi_cmnd *SCpnt) | |||
2063 | spin_lock_irqsave(&lu->cmd_orb_lock, flags); | 2053 | spin_lock_irqsave(&lu->cmd_orb_lock, flags); |
2064 | cmd = sbp2util_find_command_for_SCpnt(lu, SCpnt); | 2054 | cmd = sbp2util_find_command_for_SCpnt(lu, SCpnt); |
2065 | if (cmd) { | 2055 | if (cmd) { |
2066 | dma_sync_single_for_cpu(hi->host->device.parent, | ||
2067 | cmd->command_orb_dma, | ||
2068 | sizeof(struct sbp2_command_orb), | ||
2069 | DMA_TO_DEVICE); | ||
2070 | dma_sync_single_for_cpu(hi->host->device.parent, | ||
2071 | cmd->sge_dma, | ||
2072 | sizeof(cmd->scatter_gather_element), | ||
2073 | DMA_TO_DEVICE); | ||
2074 | sbp2util_mark_command_completed(lu, cmd); | 2056 | sbp2util_mark_command_completed(lu, cmd); |
2075 | if (cmd->Current_SCpnt) { | 2057 | if (cmd->Current_SCpnt) { |
2076 | cmd->Current_SCpnt->result = DID_ABORT << 16; | 2058 | cmd->Current_SCpnt->result = DID_ABORT << 16; |