Skip to contentSkip to conversation

misc: fastrpc: fix incorrect usage of dma_map_sgtable

PATCH Applied Jonathan Marek 4 participants 4 messages Feb 8, 2021 – Mar 1, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 misc: fastrpc: fix incorrect usage of dma_map_sgtable

dma_map_sgtable() returns 0 on success, which is the opposite of what this code was doing.

Fixes 7cd7edb89437 ("misc: fastrpc: fix common struct sg_table related issues")
---
 drivers/misc/fastrpc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/misc/fastrpc.c +4 -3
index 70eb5ed942d0..f12e909034ac 100644
@@ -520,12 +520,13 @@ fastrpc_map_dma_buf(struct dma_buf_attachment *attachment,
 {
 	struct fastrpc_dma_buf_attachment *a = attachment->priv;
 	struct sg_table *table;
+	int ret;
 
 	table = &a->sgt;
 
-	if (!dma_map_sgtable(attachment->dev, table, dir, 0))
-		return ERR_PTR(-ENOMEM);
-
+	ret = dma_map_sgtable(attachment->dev, table, dir, 0);
+	if (ret)
+		table = ERR_PTR(ret);
 	return table;
 }
 
Signature · 1 line
2.26.1
Acked-by on v1 1/1
#1 lore raw

Hi

Quoted 5 lines · Jonathan Marek

dma_map_sgtable() returns 0 on success, which is the opposite of what this code was doing.

Fixes 7cd7edb89437 ("misc: fastrpc: fix common struct sg_table related issues")

Right, I'm really sorry for this regression.

Quoted 15 lines
---
  drivers/misc/fastrpc.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/misc/fastrpc.c +1 -0
index 70eb5ed942d0..f12e909034ac 100644
@@ -520,12 +520,13 @@ fastrpc_map_dma_buf(struct dma_buf_attachment *attachment,
  {
  	struct fastrpc_dma_buf_attachment *a = attachment->priv;
  	struct sg_table *table;
+	int ret;
 
  	table = &a->sgt;

drivers/misc/fastrpc.c fastrpc_map_dma_buf(struct dma_buf_attachment *attachment, · line 532

Quoted 10 lines
drivers/misc/fastrpc.c +3 -3
 
-	if (!dma_map_sgtable(attachment->dev, table, dir, 0))
-		return ERR_PTR(-ENOMEM);
-
+	ret = dma_map_sgtable(attachment->dev, table, dir, 0);
+	if (ret)
+		table = ERR_PTR(ret);
  	return table;
  }
 

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland
Reviewed-by on v1 1/1
#2 lore raw
In reply to Jonathan Marek
Quoted 6 lines · Jonathan Marek

dma_map_sgtable() returns 0 on success, which is the opposite of what this code was doing.

Fixes 7cd7edb89437 ("misc: fastrpc: fix common struct sg_table related issues")

---

Quoted 25 lines
  drivers/misc/fastrpc.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/misc/fastrpc.c +4 -3
index 70eb5ed942d0..f12e909034ac 100644
@@ -520,12 +520,13 @@ fastrpc_map_dma_buf(struct dma_buf_attachment *attachment,
  {
  	struct fastrpc_dma_buf_attachment *a = attachment->priv;
  	struct sg_table *table;
+	int ret;
 
  	table = &a->sgt;
 
-	if (!dma_map_sgtable(attachment->dev, table, dir, 0))
-		return ERR_PTR(-ENOMEM);
-
+	ret = dma_map_sgtable(attachment->dev, table, dir, 0);
+	if (ret)
+		table = ERR_PTR(ret);
  	return table;
  }
 
#3 lore raw
In reply to Jonathan Marek
This patch was applied to qcom/linux.git (refs/heads/for-next):

Hello:

This patch was applied to qcom/linux.git (refs/heads/for-next):

Quoted 8 lines · On Mon, 8 Feb 2021 15:04:01 -0500 you wrote:

dma_map_sgtable() returns 0 on success, which is the opposite of what this code was doing.

Fixes 7cd7edb89437 ("misc: fastrpc: fix common struct sg_table related issues")
---
 drivers/misc/fastrpc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Here is the summary with links:
- misc: fastrpc: fix incorrect usage of dma_map_sgtable

    https://git.kernel.org/qcom/c/b212658aebda

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html