aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2007-07-02 16:07:34 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2007-07-09 18:07:48 -0400
commitb4be016ad81af5a83f0be820edf106de883e6ade (patch)
treef15e6577aee7b098ba52bb3f8dfeaa2af61c3716 /drivers/firewire
parent332ef3310bc37ff29fd4382d6dfb38a787078091 (diff)
firewire: fw-sbp2: fix DMA mapping of S/G tables
- The CPU must not touch the buffer after it was DMA-mapped. - The size argument of dma_unmap_single(...page_table...) was bogus. - Move a comment closer to the code to which it refers to. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> Signed-off-by: Kristian Høgsberg <krh@redhat.com>
Diffstat (limited to 'drivers/firewire')
-rw-r--r--drivers/firewire/fw-sbp2.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index c7518ea4c8ee..a2ddf318a250 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -887,7 +887,7 @@ complete_command_orb(struct sbp2_orb *base_orb, struct sbp2_status *status)
887 887
888 if (orb->page_table_bus != 0) 888 if (orb->page_table_bus != 0)
889 dma_unmap_single(device->card->device, orb->page_table_bus, 889 dma_unmap_single(device->card->device, orb->page_table_bus,
890 sizeof(orb->page_table_bus), DMA_TO_DEVICE); 890 sizeof(orb->page_table), DMA_TO_DEVICE);
891 891
892 orb->cmd->result = result; 892 orb->cmd->result = result;
893 orb->done(orb->cmd); 893 orb->done(orb->cmd);
@@ -902,7 +902,6 @@ static int sbp2_command_orb_map_scatterlist(struct sbp2_command_orb *orb)
902 struct fw_device *device = fw_device(unit->device.parent); 902 struct fw_device *device = fw_device(unit->device.parent);
903 struct scatterlist *sg; 903 struct scatterlist *sg;
904 int sg_len, l, i, j, count; 904 int sg_len, l, i, j, count;
905 size_t size;
906 dma_addr_t sg_addr; 905 dma_addr_t sg_addr;
907 906
908 sg = (struct scatterlist *)orb->cmd->request_buffer; 907 sg = (struct scatterlist *)orb->cmd->request_buffer;
@@ -951,7 +950,13 @@ static int sbp2_command_orb_map_scatterlist(struct sbp2_command_orb *orb)
951 } 950 }
952 } 951 }
953 952
954 size = sizeof(orb->page_table[0]) * j; 953 fw_memcpy_to_be32(orb->page_table, orb->page_table,
954 sizeof(orb->page_table[0]) * j);
955 orb->page_table_bus =
956 dma_map_single(device->card->device, orb->page_table,
957 sizeof(orb->page_table), DMA_TO_DEVICE);
958 if (dma_mapping_error(orb->page_table_bus))
959 goto fail_page_table;
955 960
956 /* 961 /*
957 * The data_descriptor pointer is the one case where we need 962 * The data_descriptor pointer is the one case where we need
@@ -960,20 +965,12 @@ static int sbp2_command_orb_map_scatterlist(struct sbp2_command_orb *orb)
960 * initiator (i.e. us), but data_descriptor can refer to data 965 * initiator (i.e. us), but data_descriptor can refer to data
961 * on other nodes so we need to put our ID in descriptor.high. 966 * on other nodes so we need to put our ID in descriptor.high.
962 */ 967 */
963
964 orb->page_table_bus =
965 dma_map_single(device->card->device, orb->page_table,
966 size, DMA_TO_DEVICE);
967 if (dma_mapping_error(orb->page_table_bus))
968 goto fail_page_table;
969 orb->request.data_descriptor.high = sd->address_high; 968 orb->request.data_descriptor.high = sd->address_high;
970 orb->request.data_descriptor.low = orb->page_table_bus; 969 orb->request.data_descriptor.low = orb->page_table_bus;
971 orb->request.misc |= 970 orb->request.misc |=
972 COMMAND_ORB_PAGE_TABLE_PRESENT | 971 COMMAND_ORB_PAGE_TABLE_PRESENT |
973 COMMAND_ORB_DATA_SIZE(j); 972 COMMAND_ORB_DATA_SIZE(j);
974 973
975 fw_memcpy_to_be32(orb->page_table, orb->page_table, size);
976
977 return 0; 974 return 0;
978 975
979 fail_page_table: 976 fail_page_table: