From: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
To: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org
Cc: Martyn Welch <martyn.welch@ge.com>,
Manohar Vanga <manohar.vanga@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Igor Alekseev <igor.alekseev@itep.ru>,
Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Subject: [PATCH 3/6] vme: tsi148: fix first DMA item mapping
Date: Mon, 18 May 2015 21:56:30 +0300 [thread overview]
Message-ID: <1431975393-19735-4-git-send-email-dmitry.kalinkin@gmail.com> (raw)
In-Reply-To: <1431975393-19735-1-git-send-email-dmitry.kalinkin@gmail.com>
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>
---
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
next prev parent reply other threads:[~2015-05-18 18:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-18 18:56 [PATCH 0/6] vme: DMA improvements Dmitry Kalinkin
2015-05-18 18:56 ` [PATCH 1/6] Documentation: mention vme_master_mmap() in VME API Dmitry Kalinkin
2015-05-18 18:56 ` [PATCH 2/6] vme: tsi148: fix DMA lists longer that one item Dmitry Kalinkin
2015-05-18 18:56 ` Dmitry Kalinkin [this message]
2015-05-18 18:56 ` [PATCH 4/6] vme: stop DMA transfer on interruption Dmitry Kalinkin
2015-05-18 18:56 ` [PATCH 5/6] staging: vme_user: refactor llseek to switch(){} Dmitry Kalinkin
2015-05-18 18:56 ` [PATCH 6/6] staging: vme_user: provide DMA functionality Dmitry Kalinkin
2015-05-19 9:18 ` Dan Carpenter
2015-05-21 22:12 ` Dmitry Kalinkin
2015-05-22 7:59 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1431975393-19735-4-git-send-email-dmitry.kalinkin@gmail.com \
--to=dmitry.kalinkin@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=igor.alekseev@itep.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=manohar.vanga@gmail.com \
--cc=martyn.welch@ge.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®