Skip to contentSkip to conversation

fpga: dfl: afu: Pass the correct device to dma_mapping_error()

PATCH In review Scott Wood 5 participants 6 messages Apr 10, 2019 – May 9, 2019

Subsystems (2)
lore
Share & tools
lore

Scott Wood

author
#0 lore raw

PATCH 1/1 fpga: dfl: afu: Pass the correct device to dma_mapping_error()

dma_mapping_error() was being called on a different device struct than what was passed to map/unmap. Besides rendering the error checking ineffective, it caused a debug splat with CONFIG_DMA_API_DEBUG.

---
 drivers/fpga/dfl-afu-dma-region.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/dfl-afu-dma-region.c +1 -1
index e18a786fc943..cd68002ac097 100644
@@ -399,7 +399,7 @@ int afu_dma_map_region(struct dfl_feature_platform_data *pdata,
 				    region->pages[0], 0,
 				    region->length,
 				    DMA_BIDIRECTIONAL);
-	if (dma_mapping_error(&pdata->dev->dev, region->iova)) {
+	if (dma_mapping_error(dfl_fpga_pdata_to_parent(pdata), region->iova)) {
 		dev_err(&pdata->dev->dev, "failed to map for dma\n");
 		ret = -EFAULT;
 		goto unpin_pages;
Signature · 1 line
1.8.3.1
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Scott Wood

dma_mapping_error() was being called on a different device struct than what was passed to map/unmap. Besides rendering the error checking ineffective, it caused a debug splat with CONFIG_DMA_API_DEBUG.

Hi Scott,

Looks good to me. Thanks for catching this issue.

Hao

Quoted 19 lines
---
 drivers/fpga/dfl-afu-dma-region.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/dfl-afu-dma-region.c +1 -1
index e18a786fc943..cd68002ac097 100644
@@ -399,7 +399,7 @@ int afu_dma_map_region(struct dfl_feature_platform_data *pdata,
 				    region->pages[0], 0,
 				    region->length,
 				    DMA_BIDIRECTIONAL);
-	if (dma_mapping_error(&pdata->dev->dev, region->iova)) {
+	if (dma_mapping_error(dfl_fpga_pdata_to_parent(pdata), region->iova)) {
 		dev_err(&pdata->dev->dev, "failed to map for dma\n");
 		ret = -EFAULT;
 		goto unpin_pages;
Signature · 1 line
1.8.3.1
#2 lore raw

Hi Scott,

good catch!

Quoted 20 lines · Wu Hao
Quoted 5 lines · Scott Wood

dma_mapping_error() was being called on a different device struct than what was passed to map/unmap. Besides rendering the error checking ineffective, it caused a debug splat with CONFIG_DMA_API_DEBUG.

Hi Scott,

Looks good to me. Thanks for catching this issue.

Hao

Quoted 4 lines
---
 drivers/fpga/dfl-afu-dma-region.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
Quoted 14 lines
drivers/fpga/dfl-afu-dma-region.c +1 -2
index e18a786fc943..cd68002ac097 100644
@@ -399,7 +399,7 @@ int afu_dma_map_region(struct dfl_feature_platform_data *pdata,
                                  region->pages[0], 0,
                                  region->length,
                                  DMA_BIDIRECTIONAL);
-     if (dma_mapping_error(&pdata->dev->dev, region->iova)) {
+     if (dma_mapping_error(dfl_fpga_pdata_to_parent(pdata), region->iova)) {
              dev_err(&pdata->dev->dev, "failed to map for dma\n");
              ret = -EFAULT;
              goto unpin_pages;
--
Quoted 1 line

1.8.3.1

Thanks
Moritz

Acked-by
#3 lore raw

On Thu, Apr 11, 2019 at 11:36 AM Moritz Fischer
<[email protected]> wrote:

Hi Scott,

Thanks!

Quoted 35 lines

Hi Scott,

good catch!

Quoted 29 lines · Wu Hao
Quoted 5 lines · Scott Wood

dma_mapping_error() was being called on a different device struct than what was passed to map/unmap. Besides rendering the error checking ineffective, it caused a debug splat with CONFIG_DMA_API_DEBUG.

Hi Scott,

Looks good to me. Thanks for catching this issue.

Hao

Quoted 13 lines
---
 drivers/fpga/dfl-afu-dma-region.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/dfl-afu-dma-region.c +0 -1
index e18a786fc943..cd68002ac097 100644
@@ -399,7 +399,7 @@ int afu_dma_map_region(struct dfl_feature_platform_data *pdata,
                                  region->pages[0], 0,
                                  region->length,
                                  DMA_BIDIRECTIONAL);
-     if (dma_mapping_error(&pdata->dev->dev, region->iova)) {
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
drivers/fpga/dfl-afu-dma-region.c +1 -1
+     if (dma_mapping_error(dfl_fpga_pdata_to_parent(pdata), region->iova)) {
              dev_err(&pdata->dev->dev, "failed to map for dma\n");
              ret = -EFAULT;
              goto unpin_pages;
--

1.8.3.1

Quoted 3 lines

Thanks
Moritz

Alan

author
#4 lore raw
Quoted 51 lines · Alan Tull

On Thu, Apr 11, 2019 at 11:36 AM Moritz Fischer
<[email protected]> wrote:

Hi Scott,

Thanks!

Quoted 44 lines

Hi Scott,

good catch!

Quoted 38 lines · Wu Hao
Quoted 6 lines · Scott Wood

dma_mapping_error() was being called on a different device struct than
what was passed to map/unmap. Besides rendering the error checking ineffective, it caused a debug splat with CONFIG_DMA_API_DEBUG.

Hi Scott,

Looks good to me. Thanks for catching this issue.

Hao

Quoted 22 lines
---
 drivers/fpga/dfl-afu-dma-region.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/dfl- renamed from drivers/fpga/dfl-afu-dma-region.c +0 -0

afu-dma-region.c
index e18a786fc943..cd68002ac097 100644

drivers/fpga/dfl-afu-dma-region.c +1 -1
@@ -399,7 +399,7 @@ int afu_dma_map_region(struct
 dfl_feature_platform_data *pdata,
                                  region->pages[0], 0,
                                  region->length,
                                  DMA_BIDIRECTIONAL);
-     if (dma_mapping_error(&pdata->dev->dev, region->iova)) {
+     if (dma_mapping_error(dfl_fpga_pdata_to_parent(pdata), region-
 >iova)) {
              dev_err(&pdata->dev->dev, "failed to map for dma\n");
              ret = -EFAULT;
              goto unpin_pages;

--
1.8.3.1

Quoted 3 lines
Quoted 1 line

Whose tree would these patches be going through?

-Scott

maintainer
#5 lore raw

Hi Scott,

Quoted 52 lines · Scott Wood
Quoted 51 lines · Alan Tull

On Thu, Apr 11, 2019 at 11:36 AM Moritz Fischer
<[email protected]> wrote:

Hi Scott,

Thanks!

Quoted 44 lines

Hi Scott,

good catch!

Quoted 38 lines · Wu Hao
Quoted 6 lines · Scott Wood

dma_mapping_error() was being called on a different device struct than
what was passed to map/unmap. Besides rendering the error checking ineffective, it caused a debug splat with CONFIG_DMA_API_DEBUG.

Hi Scott,

Looks good to me. Thanks for catching this issue.

Hao

Quoted 22 lines
---
 drivers/fpga/dfl-afu-dma-region.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/dfl- renamed from drivers/fpga/dfl-afu-dma-region.c +0 -0

afu-dma-region.c
index e18a786fc943..cd68002ac097 100644

drivers/fpga/dfl-afu-dma-region.c +1 -1
@@ -399,7 +399,7 @@ int afu_dma_map_region(struct
 dfl_feature_platform_data *pdata,
                                  region->pages[0], 0,
                                  region->length,
                                  DMA_BIDIRECTIONAL);
-     if (dma_mapping_error(&pdata->dev->dev, region->iova)) {
+     if (dma_mapping_error(dfl_fpga_pdata_to_parent(pdata), region-
 >iova)) {
              dev_err(&pdata->dev->dev, "failed to map for dma\n");
              ret = -EFAULT;
              goto unpin_pages;

--
1.8.3.1

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Whose tree would these patches be going through?

Greg, usually. We're a bit late this time... again ... But haven't forgotten about it.

Sorry,

Moritz