vme: tsi148: fix first DMA item mapping
This moves DMA mapping of the first list element to vme_list_add, the same place where other elements mappings occur. This prevents extra mapping or over-unmapping in the cases when vme_list_exec is called more or less than one time respectively. Also adds dma_mapping_error check. Signed-off-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com> Cc: Igor Alekseev <igor.alekseev@itep.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
f656eaee63
commit
b2383c90a9
@@ -1833,17 +1833,21 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,
|
|||||||
/* Add to list */
|
/* Add to list */
|
||||||
list_add_tail(&entry->list, &list->entries);
|
list_add_tail(&entry->list, &list->entries);
|
||||||
|
|
||||||
/* Fill out previous descriptors "Next Address" */
|
|
||||||
if (entry->list.prev != &list->entries) {
|
|
||||||
prev = list_entry(entry->list.prev, struct tsi148_dma_entry,
|
|
||||||
list);
|
|
||||||
/* We need the bus address for the pointer */
|
|
||||||
entry->dma_handle = dma_map_single(tsi148_bridge->parent,
|
entry->dma_handle = dma_map_single(tsi148_bridge->parent,
|
||||||
&entry->descriptor,
|
&entry->descriptor,
|
||||||
sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE);
|
sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE);
|
||||||
|
if (dma_mapping_error(tsi148_bridge->parent, entry->dma_handle)) {
|
||||||
|
dev_err(tsi148_bridge->parent, "DMA mapping error\n");
|
||||||
|
retval = -EINVAL;
|
||||||
|
goto err_dma;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fill out previous descriptors "Next Address" */
|
||||||
|
if (entry->list.prev != &list->entries) {
|
||||||
reg_split((unsigned long long)entry->dma_handle, &address_high,
|
reg_split((unsigned long long)entry->dma_handle, &address_high,
|
||||||
&address_low);
|
&address_low);
|
||||||
|
prev = list_entry(entry->list.prev, struct tsi148_dma_entry,
|
||||||
|
list);
|
||||||
prev->descriptor.dnlau = cpu_to_be32(address_high);
|
prev->descriptor.dnlau = cpu_to_be32(address_high);
|
||||||
prev->descriptor.dnlal = cpu_to_be32(address_low);
|
prev->descriptor.dnlal = cpu_to_be32(address_low);
|
||||||
|
|
||||||
@@ -1851,6 +1855,7 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
err_dma:
|
||||||
err_dest:
|
err_dest:
|
||||||
err_source:
|
err_source:
|
||||||
err_align:
|
err_align:
|
||||||
@@ -1921,10 +1926,6 @@ static int tsi148_dma_list_exec(struct vme_dma_list *list)
|
|||||||
entry = list_first_entry(&list->entries, struct tsi148_dma_entry,
|
entry = list_first_entry(&list->entries, struct tsi148_dma_entry,
|
||||||
list);
|
list);
|
||||||
|
|
||||||
entry->dma_handle = dma_map_single(tsi148_bridge->parent,
|
|
||||||
&entry->descriptor,
|
|
||||||
sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE);
|
|
||||||
|
|
||||||
mutex_unlock(&ctrlr->mtx);
|
mutex_unlock(&ctrlr->mtx);
|
||||||
|
|
||||||
reg_split(entry->dma_handle, &bus_addr_high, &bus_addr_low);
|
reg_split(entry->dma_handle, &bus_addr_high, &bus_addr_low);
|
||||||
|
|||||||
Reference in New Issue
Block a user