Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754753AbbERS5H (ORCPT ); Mon, 18 May 2015 14:57:07 -0400 Received: from mail-la0-f66.google.com ([209.85.215.66]:36744 "EHLO mail-la0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754320AbbERS45 (ORCPT ); Mon, 18 May 2015 14:56:57 -0400 From: Dmitry Kalinkin To: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org Cc: Martyn Welch , Manohar Vanga , Greg Kroah-Hartman , Igor Alekseev , Dmitry Kalinkin Subject: [PATCH 3/6] vme: tsi148: fix first DMA item mapping Date: Mon, 18 May 2015 21:56:30 +0300 Message-Id: <1431975393-19735-4-git-send-email-dmitry.kalinkin@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1431975393-19735-1-git-send-email-dmitry.kalinkin@gmail.com> References: <1431975393-19735-1-git-send-email-dmitry.kalinkin@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2591 Lines: 73 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 Cc: Igor Alekseev --- drivers/vme/bridges/vme_tsi148.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/vme/bridges/vme_tsi148.c b/drivers/vme/bridges/vme_tsi148.c index 1be4136..03b0755 100644 --- a/drivers/vme/bridges/vme_tsi148.c +++ b/drivers/vme/bridges/vme_tsi148.c @@ -1833,17 +1833,21 @@ static int tsi148_dma_list_add(struct vme_dma_list *list, /* Add to list */ list_add_tail(&entry->list, &list->entries); + entry->dma_handle = dma_map_single(tsi148_bridge->parent, + &entry->descriptor, + 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) { - 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->descriptor, - sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE); - reg_split((unsigned long long)entry->dma_handle, &address_high, &address_low); + prev = list_entry(entry->list.prev, struct tsi148_dma_entry, + list); prev->descriptor.dnlau = cpu_to_be32(address_high); 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; +err_dma: err_dest: err_source: 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, list); - entry->dma_handle = dma_map_single(tsi148_bridge->parent, - &entry->descriptor, - sizeof(struct tsi148_dma_descriptor), DMA_TO_DEVICE); - mutex_unlock(&ctrlr->mtx); reg_split(entry->dma_handle, &bus_addr_high, &bus_addr_low); -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/