Skip to contentSkip to conversation

drm/nouveau: fix dma_address check for CPU/GPU sync

PATCH In review Christian König 3 participants 4 messages Jun 14, 2021 – Jun 22, 2021

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

PATCH 1/1 drm/nouveau: fix dma_address check for CPU/GPU sync

AGP for example doesn't have a dma_address array.

---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +2 -2
index 3e09df0472ce..170aba99a110 100644
@@ -546,7 +546,7 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo)
 	struct ttm_tt *ttm_dma = (struct ttm_tt *)nvbo->bo.ttm;
 	int i, j;
 
-	if (!ttm_dma)
+	if (!ttm_dma || !ttm_dma->dma_address)
 		return;
 	if (!ttm_dma->pages) {
 		NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma);
@@ -582,7 +582,7 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo)
 	struct ttm_tt *ttm_dma = (struct ttm_tt *)nvbo->bo.ttm;
 	int i, j;
 
-	if (!ttm_dma)
+	if (!ttm_dma || !ttm_dma->dma_address)
 		return;
 	if (!ttm_dma->pages) {
 		NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma);
Signature · 1 line
2.25.1
Tested-by on v1 1/1
#1 lore raw
Quoted 3 lines · On Monday 14 June 2021 13:05:17 Christian König wrote:

AGP for example doesn't have a dma_address array.

Fixes NULL pointer dereference in nouveau_bo_sync_for_device on AGP cards.

Quoted 26 lines
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +2 -2
index 3e09df0472ce..170aba99a110 100644
@@ -546,7 +546,7 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo)
 	struct ttm_tt *ttm_dma = (struct ttm_tt *)nvbo->bo.ttm;
 	int i, j;
 
-	if (!ttm_dma)
+	if (!ttm_dma || !ttm_dma->dma_address)
 		return;
 	if (!ttm_dma->pages) {
 		NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma);
@@ -582,7 +582,7 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo)
 	struct ttm_tt *ttm_dma = (struct ttm_tt *)nvbo->bo.ttm;
 	int i, j;
 
-	if (!ttm_dma)
+	if (!ttm_dma || !ttm_dma->dma_address)
 		return;
 	if (!ttm_dma->pages) {
 		NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma);
Signature · 1 line
Ondrej Zary
#2 lore raw
In reply to Christian König

Ping? Does anybody wants to give me an rb or acked-by?

AGP is basically broken on nouveu without this.

Christian.

Am 14.06.21 um 13:05 schrieb Christian König:

Quoted 29 lines

AGP for example doesn't have a dma_address array.

---
  drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +2 -2
index 3e09df0472ce..170aba99a110 100644
@@ -546,7 +546,7 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo)
  	struct ttm_tt *ttm_dma = (struct ttm_tt *)nvbo->bo.ttm;
  	int i, j;
 
-	if (!ttm_dma)
+	if (!ttm_dma || !ttm_dma->dma_address)
  		return;
  	if (!ttm_dma->pages) {
  		NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma);
@@ -582,7 +582,7 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo)
  	struct ttm_tt *ttm_dma = (struct ttm_tt *)nvbo->bo.ttm;
  	int i, j;
 
-	if (!ttm_dma)
+	if (!ttm_dma || !ttm_dma->dma_address)
  		return;
  	if (!ttm_dma->pages) {
  		NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma);
Acked-by
#3 lore raw
Quoted 4 lines · Christian König

Ping? Does anybody wants to give me an rb or acked-by?

AGP is basically broken on nouveu without this.

Looks correct to me.

Quoted 28 lines

Christian.

Am 14.06.21 um 13:05 schrieb Christian König:

Quoted 24 lines

AGP for example doesn't have a dma_address array.

---
  drivers/gpu/drm/nouveau/nouveau_bo.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_bo.c +1 -1
index 3e09df0472ce..170aba99a110 100644
@@ -546,7 +546,7 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo)
      struct ttm_tt *ttm_dma = (struct ttm_tt *)nvbo->bo.ttm;
      int i, j;
 
-     if (!ttm_dma)
+     if (!ttm_dma || !ttm_dma->dma_address)
              return;
      if (!ttm_dma->pages) {
              NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma);
@@ -582,7 +582,7 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo)
      struct ttm_tt *ttm_dma = (struct ttm_tt *)nvbo->bo.ttm;
      int i, j;
 
Quoted 6 lines

drivers/gpu/drm/nouveau/nouveau_bo.c nouveau_bo_sync_for_device(struct nouveau_bo *nvbo) · line 552

Quoted 5 lines
drivers/gpu/drm/nouveau/nouveau_bo.c +1 -1
-     if (!ttm_dma)
+     if (!ttm_dma || !ttm_dma->dma_address)
              return;
      if (!ttm_dma->pages) {
              NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma);

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau