Skip to contentSkip to conversation

disp/gf119-: avoid creating non-existent heads

PATCH In review Ilia Mirkin 2 participants 3 messages Jul 3, 2017 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 disp/gf119-: avoid creating non-existent heads

We assume that each board has 4 heads for GF119+. However this is not necessarily true - in the case of a GP108 board, the register indicated that there were only 2.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101601

---

I'm not extremely happy about the fact that we have to duplicate the head count in both the nv50_display logic for creating DRM-side CRTC's, as well as the nvkm-side logic for creating heads. However I don't immediately see an easy way around it without creating a nvif ioctl to get the number of heads.

 drm/nouveau/nv50_display.c               | 8 +++++---
 drm/nouveau/nvkm/engine/disp/gf119.c     | 2 +-
 drm/nouveau/nvkm/engine/disp/headgf119.c | 4 +++-
 3 files changed, 9 insertions(+), 5 deletions(-)
drm/nouveau/nv50_display.c +5 -3
index e3132a2c..e2170efb 100644
@@ -4443,11 +4443,13 @@ nv50_display_create(struct drm_device *dev)
 
 	/* create crtc objects to represent the hw heads */
 	if (disp->disp->oclass >= GF110_DISP)
-		crtcs = nvif_rd32(&device->object, 0x022448);
+		crtcs = nvif_rd32(&device->object, 0x612004) & 0xf;
 	else
-		crtcs = 2;
+		crtcs = 0x3;
 
-	for (i = 0; i < crtcs; i++) {
+	for (i = 0; i < fls(crtcs); i++) {
+		if (!(crtcs & (1 << i)))
+			continue;
 		ret = nv50_head_create(dev, i);
 		if (ret)
 			goto out;
drm/nouveau/nvkm/engine/disp/gf119.c +1 -1
index d8765b57..415987e9 100644
@@ -168,7 +168,7 @@ int
 gf119_disp_new_(const struct nv50_disp_func *func, struct nvkm_device *device,
 		int index, struct nvkm_disp **pdisp)
 {
-	u32 heads = nvkm_rd32(device, 0x022448);
+	u32 heads = fls(nvkm_rd32(device, 0x612004) & 0xf);
 	return nv50_disp_new_(func, device, index, heads, pdisp);
 }
 
drm/nouveau/nvkm/engine/disp/headgf119.c +3 -1
index b3355275..8d44bdf6 100644
@@ -92,5 +92,7 @@ gf119_head = {
 int
 gf119_head_new(struct nvkm_disp *disp, int id)
 {
-	return nvkm_head_new_(&gf119_head, disp, id);
+	if (nvkm_rd32(disp->engine.subdev.device, 0x612004) & 0xf & (1 << id))
+		return nvkm_head_new_(&gf119_head, disp, id);
+	return 0;
 }
Signature · 6 lines
2.13.0

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

A message that is not in the archive (sent off-list or not yet received): 20170703170626.9330-1-imirkin-FrUbXkNCsVf2fBVCVOL8/[email protected]

#2 lore raw
Quoted 4 lines · Ilia Mirkin

We assume that each board has 4 heads for GF119+. However this is not necessarily true - in the case of a GP108 board, the register indicated that there were only 2.

Quoted 8 lines

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101601

---

I'm not extremely happy about the fact that we have to duplicate the head count in both the nv50_display logic for creating DRM-side CRTC's, as well as the nvkm-side logic for creating heads. However I don't immediately see an easy way around it without creating a nvif ioctl to get the number of heads.

Yeah, I have WIP stuff from long ago that would make this nicer, but for now it's fine to do what you've done here.

Quoted 32 lines
 drm/nouveau/nv50_display.c               | 8 +++++---
 drm/nouveau/nvkm/engine/disp/gf119.c     | 2 +-
 drm/nouveau/nvkm/engine/disp/headgf119.c | 4 +++-
 3 files changed, 9 insertions(+), 5 deletions(-)
drm/nouveau/nv50_display.c +5 -3
index e3132a2c..e2170efb 100644
@@ -4443,11 +4443,13 @@ nv50_display_create(struct drm_device *dev)
 
 	/* create crtc objects to represent the hw heads */
 	if (disp->disp->oclass >= GF110_DISP)
-		crtcs = nvif_rd32(&device->object, 0x022448);
+		crtcs = nvif_rd32(&device->object, 0x612004) & 0xf;
 	else
-		crtcs = 2;
+		crtcs = 0x3;
 
-	for (i = 0; i < crtcs; i++) {
+	for (i = 0; i < fls(crtcs); i++) {
+		if (!(crtcs & (1 << i)))
+			continue;
 		ret = nv50_head_create(dev, i);
 		if (ret)
 			goto out;
drm/nouveau/nvkm/engine/disp/gf119.c +0 -0
index d8765b57..415987e9 100644

drm/nouveau/nvkm/engine/disp/gf119.c int · line 172

Quoted 6 lines
drm/nouveau/nvkm/engine/disp/gf119.c +1 -1
@@ -168,7 +168,7 @@ int
 gf119_disp_new_(const struct nv50_disp_func *func, struct nvkm_device *device,
 		int index, struct nvkm_disp **pdisp)
 {
-	u32 heads = nvkm_rd32(device, 0x022448);
+	u32 heads = fls(nvkm_rd32(device, 0x612004) & 0xf);
 	return nv50_disp_new_(func, device, index, heads, pdisp);

I'd drop this change. I suspect 0x022448 is still the "maximum head count" register, and that 0x612004 is just a disable mask.

Quoted 8 lines
drm/nouveau/nvkm/engine/disp/gf119.c +0 -0
 }
 
drm/nouveau/nvkm/engine/disp/headgf119.c +0 -0
index b3355275..8d44bdf6 100644

drm/nouveau/nvkm/engine/disp/headgf119.c gf119_head = { · line 98

Quoted 8 lines
drm/nouveau/nvkm/engine/disp/headgf119.c +3 -1
@@ -92,5 +92,7 @@ gf119_head = {
 int
 gf119_head_new(struct nvkm_disp *disp, int id)
 {
-	return nvkm_head_new_(&gf119_head, disp, id);
+	if (nvkm_rd32(disp->engine.subdev.device, 0x612004) & 0xf & (1 << id))
+		return nvkm_head_new_(&gf119_head, disp, id);
+	return 0;
 }

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

A message that is not in the archive (sent off-list or not yet received): 54829522-1ad0-641d-41ef-69402b047d2b-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#4 lore raw
Quoted 48 lines · Ben Skeggs
Quoted 4 lines · Ilia Mirkin

We assume that each board has 4 heads for GF119+. However this is not necessarily true - in the case of a GP108 board, the register indicated that there were only 2.

Quoted 8 lines

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101601

---

I'm not extremely happy about the fact that we have to duplicate the head count in both the nv50_display logic for creating DRM-side CRTC's, as well as the nvkm-side logic for creating heads. However I don't immediately see an easy way around it without creating a nvif ioctl to get the number of heads.

Yeah, I have WIP stuff from long ago that would make this nicer, but for now it's fine to do what you've done here.

Quoted 32 lines
 drm/nouveau/nv50_display.c               | 8 +++++---
 drm/nouveau/nvkm/engine/disp/gf119.c     | 2 +-
 drm/nouveau/nvkm/engine/disp/headgf119.c | 4 +++-
 3 files changed, 9 insertions(+), 5 deletions(-)
drm/nouveau/nv50_display.c +5 -3
index e3132a2c..e2170efb 100644
@@ -4443,11 +4443,13 @@ nv50_display_create(struct drm_device *dev)
 
      /* create crtc objects to represent the hw heads */
      if (disp->disp->oclass >= GF110_DISP)
-             crtcs = nvif_rd32(&device->object, 0x022448);
+             crtcs = nvif_rd32(&device->object, 0x612004) & 0xf;
      else
-             crtcs = 2;
+             crtcs = 0x3;
 
-     for (i = 0; i < crtcs; i++) {
+     for (i = 0; i < fls(crtcs); i++) {
+             if (!(crtcs & (1 << i)))
+                     continue;
              ret = nv50_head_create(dev, i);
              if (ret)
                      goto out;
drm/nouveau/nvkm/engine/disp/gf119.c +0 -0
index d8765b57..415987e9 100644
@@ -168,7 +168,7 @@ int
Quoted 8 lines

drm/nouveau/nvkm/engine/disp/gf119.c int · line 172

Quoted 6 lines
drm/nouveau/nvkm/engine/disp/gf119.c +1 -1
 gf119_disp_new_(const struct nv50_disp_func *func, struct nvkm_device *device,
              int index, struct nvkm_disp **pdisp)
 {
-     u32 heads = nvkm_rd32(device, 0x022448);
+     u32 heads = fls(nvkm_rd32(device, 0x612004) & 0xf);
      return nv50_disp_new_(func, device, index, heads, pdisp);

I'd drop this change. I suspect 0x022448 is still the "maximum head count" register, and that 0x612004 is just a disable mask.

I suspect you're right (it's 4 as expected on the GP108 in question). I think I was trying to avoid creating phantom heads, but the code in headgf119.c will prevent that and ultimately have an identical effect.

Feel free to drop this hunk when applying.

Quoted 15 lines
Quoted 15 lines
drm/nouveau/nvkm/engine/disp/gf119.c +0 -0
 }
 
drm/nouveau/nvkm/engine/disp/headgf119.c +3 -1
index b3355275..8d44bdf6 100644
@@ -92,5 +92,7 @@ gf119_head = {
 int
 gf119_head_new(struct nvkm_disp *disp, int id)
 {
-     return nvkm_head_new_(&gf119_head, disp, id);
+     if (nvkm_rd32(disp->engine.subdev.device, 0x612004) & 0xf & (1 << id))
+             return nvkm_head_new_(&gf119_head, disp, id);
+     return 0;
Quoted 9 lines

drm/nouveau/nvkm/engine/disp/headgf119.c gf119_head = { · line 98

Quoted 2 lines
drm/nouveau/nvkm/engine/disp/headgf119.c +0 -0
 }

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

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