Skip to contentSkip to conversation

dma-helpers: avoid calling dma_bdrv_unmap() twice

PATCH Applied Jules Wang 3 participants 3 messages May 23, 2014

lore
Share & tools
lore

Jules Wang

author
#0 lore raw

PATCH 1/1 dma-helpers: avoid calling dma_bdrv_unmap() twice

Calling dma_bdrv_unmap() twice is not necessary and may cause potential problems if some code changes.

---
 dma-helpers.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
dma-helpers.c +1 -1
index 5f421e9..53cbe92 100644
@@ -143,12 +143,12 @@ static void dma_bdrv_cb(void *opaque, int ret)
 
     dbs->acb = NULL;
     dbs->sector_num += dbs->iov.size / 512;
-    dma_bdrv_unmap(dbs);
 
     if (dbs->sg_cur_index == dbs->sg->nsg || ret < 0) {
         dma_complete(dbs, ret);
         return;
     }
+    dma_bdrv_unmap(dbs);
 
     while (dbs->sg_cur_index < dbs->sg->nsg) {
         cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte;
Signature · 1 line
1.7.1
Reviewed-by on v1 1/1
#1 lore raw

Il 23/05/2014 05:44, Jules Wang ha scritto:

Quoted 17 lines

Calling dma_bdrv_unmap() twice is not necessary and may cause potential problems if some code changes.

---
 dma-helpers.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
dma-helpers.c +0 -0
index 5f421e9..53cbe92 100644
@@ -143,12 +143,12 @@ static void dma_bdrv_cb(void *opaque, int ret)
 
     dbs->acb = NULL;
     dbs->sector_num += dbs->iov.size / 512;

dma-helpers.c static void dma_bdrv_cb(void *opaque, int ret) · line 154

Quoted 10 lines
dma-helpers.c +1 -1
-    dma_bdrv_unmap(dbs);
 
     if (dbs->sg_cur_index == dbs->sg->nsg || ret < 0) {
         dma_complete(dbs, ret);
         return;
     }
+    dma_bdrv_unmap(dbs);
 
     while (dbs->sg_cur_index < dbs->sg->nsg) {
         cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte;
#2 lore raw
In reply to Jules Wang
Quoted 16 lines · Jules Wang

Calling dma_bdrv_unmap() twice is not necessary and may cause potential problems if some code changes.

---
 dma-helpers.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
dma-helpers.c +0 -0
index 5f421e9..53cbe92 100644
@@ -143,12 +143,12 @@ static void dma_bdrv_cb(void *opaque, int ret)
 
     dbs->acb = NULL;
     dbs->sector_num += dbs->iov.size / 512;

dma-helpers.c static void dma_bdrv_cb(void *opaque, int ret) · line 154

Quoted 10 lines
dma-helpers.c +1 -1
-    dma_bdrv_unmap(dbs);
 
     if (dbs->sg_cur_index == dbs->sg->nsg || ret < 0) {
         dma_complete(dbs, ret);
         return;
     }
+    dma_bdrv_unmap(dbs);
 
     while (dbs->sg_cur_index < dbs->sg->nsg) {
         cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte;

Applied to -trivial!

Maybe not-so-trivial, as I had to look at dma_complete() (who calls dma_bdrv_unmap() ofcourse) to understand what's going on :)

Thank you!

/mjt