Skip to contentSkip to conversation

nouveau: fw: sync dma after setup is called.

PATCH In review Dave Airlie 3 participants 3 messages Nov 14, 2024 – Nov 25, 2024

Subsystems (3)
lore
Share & tools
lore

Dave Airlie

author maintainer
#0 lore raw

PATCH 1/1 nouveau: fw: sync dma after setup is called.

From: Dave Airlie <[email protected]>

When this code moved to non-coherent allocator the sync was put too early for some firmwares which called the setup function, move the sync down after the setup function.

Fixes 9b340aeb26d5 ("nouveau/firmware: use dma non-coherent allocator")
---
 drivers/gpu/drm/nouveau/nvkm/falcon/fw.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/nouveau/nvkm/falcon/fw.c +6 -5
index a1c8545f1249..cac6d64ab67d 100644
@@ -89,11 +89,6 @@ nvkm_falcon_fw_boot(struct nvkm_falcon_fw *fw, struct nvkm_subdev *user,
 		nvkm_falcon_fw_dtor_sigs(fw);
 	}
 
-	/* after last write to the img, sync dma mappings */
-	dma_sync_single_for_device(fw->fw.device->dev,
-				   fw->fw.phys,
-				   sg_dma_len(&fw->fw.mem.sgl),
-				   DMA_TO_DEVICE);
 
 	FLCNFW_DBG(fw, "resetting");
 	fw->func->reset(fw);
@@ -105,6 +100,12 @@ nvkm_falcon_fw_boot(struct nvkm_falcon_fw *fw, struct nvkm_subdev *user,
 			goto done;
 	}
 
+	/* after last write to the img, sync dma mappings */
+	dma_sync_single_for_device(fw->fw.device->dev,
+				   fw->fw.phys,
+				   sg_dma_len(&fw->fw.mem.sgl),
+				   DMA_TO_DEVICE);
+
 	ret = fw->func->load(fw);
 	if (ret)
 		goto done;
Signature · 1 line
2.47.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Dave Airlie

From: Dave Airlie <[email protected]>

When this code moved to non-coherent allocator the sync was put too early for some firmwares which called the setup function, move the sync down after the setup function.

Fixes 9b340aeb26d5 ("nouveau/firmware: use dma non-coherent allocator")
Quoted 33 lines
---
  drivers/gpu/drm/nouveau/nvkm/falcon/fw.c | 11 ++++++-----
  1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/nouveau/nvkm/falcon/fw.c +6 -5
index a1c8545f1249..cac6d64ab67d 100644
@@ -89,11 +89,6 @@ nvkm_falcon_fw_boot(struct nvkm_falcon_fw *fw, struct nvkm_subdev *user,
  		nvkm_falcon_fw_dtor_sigs(fw);
  	}
 
-	/* after last write to the img, sync dma mappings */
-	dma_sync_single_for_device(fw->fw.device->dev,
-				   fw->fw.phys,
-				   sg_dma_len(&fw->fw.mem.sgl),
-				   DMA_TO_DEVICE);
 
  	FLCNFW_DBG(fw, "resetting");
  	fw->func->reset(fw);
@@ -105,6 +100,12 @@ nvkm_falcon_fw_boot(struct nvkm_falcon_fw *fw, struct nvkm_subdev *user,
  			goto done;
  	}
 
+	/* after last write to the img, sync dma mappings */
+	dma_sync_single_for_device(fw->fw.device->dev,
+				   fw->fw.phys,
+				   sg_dma_len(&fw->fw.mem.sgl),
+				   DMA_TO_DEVICE);
+
  	ret = fw->func->load(fw);
  	if (ret)
  		goto done;
maintainer
#2 lore raw
In reply to Dave Airlie
Quoted 7 lines · Dave Airlie

From: Dave Airlie <[email protected]>

When this code moved to non-coherent allocator the sync was put too early for some firmwares which called the setup function, move the sync down after the setup function.

Do you have a link of where this issue has been reported?

Quoted 37 lines
Fixes 9b340aeb26d5 ("nouveau/firmware: use dma non-coherent allocator")
---
  drivers/gpu/drm/nouveau/nvkm/falcon/fw.c | 11 ++++++-----
  1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/nouveau/nvkm/falcon/fw.c +6 -5
index a1c8545f1249..cac6d64ab67d 100644
@@ -89,11 +89,6 @@ nvkm_falcon_fw_boot(struct nvkm_falcon_fw *fw, struct nvkm_subdev *user,
  		nvkm_falcon_fw_dtor_sigs(fw);
  	}
 
-	/* after last write to the img, sync dma mappings */
-	dma_sync_single_for_device(fw->fw.device->dev,
-				   fw->fw.phys,
-				   sg_dma_len(&fw->fw.mem.sgl),
-				   DMA_TO_DEVICE);
 
  	FLCNFW_DBG(fw, "resetting");
  	fw->func->reset(fw);
@@ -105,6 +100,12 @@ nvkm_falcon_fw_boot(struct nvkm_falcon_fw *fw, struct nvkm_subdev *user,
  			goto done;
  	}
 
+	/* after last write to the img, sync dma mappings */
+	dma_sync_single_for_device(fw->fw.device->dev,
+				   fw->fw.phys,
+				   sg_dma_len(&fw->fw.mem.sgl),
+				   DMA_TO_DEVICE);
+
  	ret = fw->func->load(fw);
  	if (ret)
  		goto done;