Skip to contentSkip to conversation

drm/bochs: cleanups and framebuffer setup fix.

PATCH In review Gerd Hoffmann 2 participants 14 messages Jun 27, 2019

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

PATCH v3 2/5 drm/bochs: pass framebuffer to bochs_hw_setbase

In reply to Gerd Hoffmann

Also rename to bochs_hw_setfb, we have to set more than just the base address.

---
 drivers/gpu/drm/bochs/bochs.h     |  5 +++--
 drivers/gpu/drm/bochs/bochs_hw.c  | 10 +++++-----
 drivers/gpu/drm/bochs/bochs_kms.c | 10 +++-------
 3 files changed, 11 insertions(+), 14 deletions(-)
drivers/gpu/drm/bochs/bochs.h +3 -2
index cc35d492142c..246f05f4a711 100644
@@ -85,8 +85,9 @@ void bochs_hw_setmode(struct bochs_device *bochs,
 		      struct drm_display_mode *mode);
 void bochs_hw_setformat(struct bochs_device *bochs,
 			const struct drm_format_info *format);
-void bochs_hw_setbase(struct bochs_device *bochs,
-		      int x, int y, u64 addr);
+void bochs_hw_setfb(struct bochs_device *bochs,
+		    struct drm_framebuffer *fb,
+		    int x, int y);
 int bochs_hw_load_edid(struct bochs_device *bochs);
 
 /* bochs_mm.c */
drivers/gpu/drm/bochs/bochs_hw.c +5 -5
index 791ab2f79947..67101c85029c 100644
@@ -254,17 +254,17 @@ void bochs_hw_setformat(struct bochs_device *bochs,
 	};
 }
 
-void bochs_hw_setbase(struct bochs_device *bochs,
-		      int x, int y, u64 addr)
+void bochs_hw_setfb(struct bochs_device *bochs,
+		    struct drm_framebuffer *fb,
+		    int x, int y)
 {
-	unsigned long offset = (unsigned long)addr +
+	struct drm_gem_vram_object *bo = drm_gem_vram_of_gem(fb->obj[0]);
+	unsigned long offset = bo->bo.offset +
 		y * bochs->stride +
 		x * (bochs->bpp / 8);
 	int vy = offset / bochs->stride;
 	int vx = (offset % bochs->stride) * 8 / bochs->bpp;
 
-	DRM_DEBUG_DRIVER("x %d, y %d, addr %llx -> offset %lx, vx %d, vy %d\n",
-			 x, y, addr, offset, vx, vy);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_X_OFFSET, vx);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_Y_OFFSET, vy);
 }
drivers/gpu/drm/bochs/bochs_kms.c +3 -7
index 5904eddc83a5..ddbf0802138d 100644
@@ -27,16 +27,12 @@ static const uint32_t bochs_formats[] = {
 static void bochs_plane_update(struct bochs_device *bochs,
 			       struct drm_plane_state *state)
 {
-	struct drm_gem_vram_object *gbo;
-
 	if (!state->fb || !bochs->stride)
 		return;
 
-	gbo = drm_gem_vram_of_gem(state->fb->obj[0]);
-	bochs_hw_setbase(bochs,
-			 state->crtc_x,
-			 state->crtc_y,
-			 gbo->bo.offset);
+	bochs_hw_setfb(bochs, state->fb,
+		       state->crtc_x,
+		       state->crtc_y);
 	bochs_hw_setformat(bochs, state->fb->format);
 }
 
Signature · 1 line
2.18.1
#7 lore raw

PATCH v3 2/5 drm/bochs: pass framebuffer to bochs_hw_setbase

In reply to Gerd Hoffmann

Also rename to bochs_hw_setfb, we have to set more than just the base address.

---
 drivers/gpu/drm/bochs/bochs.h     |  5 +++--
 drivers/gpu/drm/bochs/bochs_hw.c  | 10 +++++-----
 drivers/gpu/drm/bochs/bochs_kms.c | 10 +++-------
 3 files changed, 11 insertions(+), 14 deletions(-)
drivers/gpu/drm/bochs/bochs.h +3 -2
index cc35d492142c..246f05f4a711 100644
@@ -85,8 +85,9 @@ void bochs_hw_setmode(struct bochs_device *bochs,
 		      struct drm_display_mode *mode);
 void bochs_hw_setformat(struct bochs_device *bochs,
 			const struct drm_format_info *format);
-void bochs_hw_setbase(struct bochs_device *bochs,
-		      int x, int y, u64 addr);
+void bochs_hw_setfb(struct bochs_device *bochs,
+		    struct drm_framebuffer *fb,
+		    int x, int y);
 int bochs_hw_load_edid(struct bochs_device *bochs);
 
 /* bochs_mm.c */
drivers/gpu/drm/bochs/bochs_hw.c +5 -5
index 791ab2f79947..67101c85029c 100644
@@ -254,17 +254,17 @@ void bochs_hw_setformat(struct bochs_device *bochs,
 	};
 }
 
-void bochs_hw_setbase(struct bochs_device *bochs,
-		      int x, int y, u64 addr)
+void bochs_hw_setfb(struct bochs_device *bochs,
+		    struct drm_framebuffer *fb,
+		    int x, int y)
 {
-	unsigned long offset = (unsigned long)addr +
+	struct drm_gem_vram_object *bo = drm_gem_vram_of_gem(fb->obj[0]);
+	unsigned long offset = bo->bo.offset +
 		y * bochs->stride +
 		x * (bochs->bpp / 8);
 	int vy = offset / bochs->stride;
 	int vx = (offset % bochs->stride) * 8 / bochs->bpp;
 
-	DRM_DEBUG_DRIVER("x %d, y %d, addr %llx -> offset %lx, vx %d, vy %d\n",
-			 x, y, addr, offset, vx, vy);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_X_OFFSET, vx);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_Y_OFFSET, vy);
 }
drivers/gpu/drm/bochs/bochs_kms.c +3 -7
index 5904eddc83a5..ddbf0802138d 100644
@@ -27,16 +27,12 @@ static const uint32_t bochs_formats[] = {
 static void bochs_plane_update(struct bochs_device *bochs,
 			       struct drm_plane_state *state)
 {
-	struct drm_gem_vram_object *gbo;
-
 	if (!state->fb || !bochs->stride)
 		return;
 
-	gbo = drm_gem_vram_of_gem(state->fb->obj[0]);
-	bochs_hw_setbase(bochs,
-			 state->crtc_x,
-			 state->crtc_y,
-			 gbo->bo.offset);
+	bochs_hw_setfb(bochs, state->fb,
+		       state->crtc_x,
+		       state->crtc_y);
 	bochs_hw_setformat(bochs, state->fb->format);
 }
 
Signature · 1 line
2.18.1
#8 lore raw

PATCH v3 3/5 drm/bochs: drop yres_virtual from struct bochs_device

In reply to Gerd Hoffmann

Not needed, writing to VBE_DISPI_INDEX_VIRT_HEIGHT has no effect anyway.

---
 drivers/gpu/drm/bochs/bochs.h    | 1 -
 drivers/gpu/drm/bochs/bochs_hw.c | 8 ++------
 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/gpu/drm/bochs/bochs.h +0 -1
index 246f05f4a711..5c90b76708ef 100644
@@ -64,7 +64,6 @@ struct bochs_device {
 	/* mode */
 	u16 xres;
 	u16 yres;
-	u16 yres_virtual;
 	u32 stride;
 	u32 bpp;
 	struct edid *edid;
drivers/gpu/drm/bochs/bochs_hw.c +2 -6
index 67101c85029c..9ab6ec269ef9 100644
@@ -207,11 +207,9 @@ void bochs_hw_setmode(struct bochs_device *bochs,
 	bochs->yres = mode->vdisplay;
 	bochs->bpp = 32;
 	bochs->stride = mode->hdisplay * (bochs->bpp / 8);
-	bochs->yres_virtual = bochs->fb_size / bochs->stride;
 
-	DRM_DEBUG_DRIVER("%dx%d @ %d bpp, vy %d\n",
-			 bochs->xres, bochs->yres, bochs->bpp,
-			 bochs->yres_virtual);
+	DRM_DEBUG_DRIVER("%dx%d @ %d bpp\n",
+			 bochs->xres, bochs->yres, bochs->bpp);
 
 	bochs_vga_writeb(bochs, 0x3c0, 0x20); /* unblank */
 
@@ -221,8 +219,6 @@ void bochs_hw_setmode(struct bochs_device *bochs,
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_YRES,        bochs->yres);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_BANK,        0);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_VIRT_WIDTH,  bochs->xres);
-	bochs_dispi_write(bochs, VBE_DISPI_INDEX_VIRT_HEIGHT,
-			  bochs->yres_virtual);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_X_OFFSET,    0);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_Y_OFFSET,    0);
 
Signature · 1 line
2.18.1
#9 lore raw

PATCH v3 3/5 drm/bochs: drop yres_virtual from struct bochs_device

In reply to Gerd Hoffmann

Not needed, writing to VBE_DISPI_INDEX_VIRT_HEIGHT has no effect anyway.

---
 drivers/gpu/drm/bochs/bochs.h    | 1 -
 drivers/gpu/drm/bochs/bochs_hw.c | 8 ++------
 2 files changed, 2 insertions(+), 7 deletions(-)
drivers/gpu/drm/bochs/bochs.h +0 -1
index 246f05f4a711..5c90b76708ef 100644
@@ -64,7 +64,6 @@ struct bochs_device {
 	/* mode */
 	u16 xres;
 	u16 yres;
-	u16 yres_virtual;
 	u32 stride;
 	u32 bpp;
 	struct edid *edid;
drivers/gpu/drm/bochs/bochs_hw.c +2 -6
index 67101c85029c..9ab6ec269ef9 100644
@@ -207,11 +207,9 @@ void bochs_hw_setmode(struct bochs_device *bochs,
 	bochs->yres = mode->vdisplay;
 	bochs->bpp = 32;
 	bochs->stride = mode->hdisplay * (bochs->bpp / 8);
-	bochs->yres_virtual = bochs->fb_size / bochs->stride;
 
-	DRM_DEBUG_DRIVER("%dx%d @ %d bpp, vy %d\n",
-			 bochs->xres, bochs->yres, bochs->bpp,
-			 bochs->yres_virtual);
+	DRM_DEBUG_DRIVER("%dx%d @ %d bpp\n",
+			 bochs->xres, bochs->yres, bochs->bpp);
 
 	bochs_vga_writeb(bochs, 0x3c0, 0x20); /* unblank */
 
@@ -221,8 +219,6 @@ void bochs_hw_setmode(struct bochs_device *bochs,
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_YRES,        bochs->yres);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_BANK,        0);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_VIRT_WIDTH,  bochs->xres);
-	bochs_dispi_write(bochs, VBE_DISPI_INDEX_VIRT_HEIGHT,
-			  bochs->yres_virtual);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_X_OFFSET,    0);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_Y_OFFSET,    0);
 
Signature · 1 line
2.18.1
#10 lore raw

PATCH v3 4/5 drm/bochs: drop stride and bpp from struct bochs_device

In reply to Gerd Hoffmann

No need to store that, struct drm_framebuffer has all we need.

Also update VBE_DISPI_INDEX_VIRT_WIDTH register, otherwise we'll have a fixes broken display in case pitch != width * cpp.

---
 drivers/gpu/drm/bochs/bochs.h     |  2 --
 drivers/gpu/drm/bochs/bochs_hw.c  | 18 +++++++++---------
 drivers/gpu/drm/bochs/bochs_kms.c |  2 +-
 3 files changed, 10 insertions(+), 12 deletions(-)
drivers/gpu/drm/bochs/bochs.h +0 -2
index 5c90b76708ef..4081b3aba28d 100644
@@ -64,8 +64,6 @@ struct bochs_device {
 	/* mode */
 	u16 xres;
 	u16 yres;
-	u32 stride;
-	u32 bpp;
 	struct edid *edid;
 
 	/* drm */
drivers/gpu/drm/bochs/bochs_hw.c +9 -9
index 9ab6ec269ef9..178715c6755d 100644
@@ -205,16 +205,14 @@ void bochs_hw_setmode(struct bochs_device *bochs,
 {
 	bochs->xres = mode->hdisplay;
 	bochs->yres = mode->vdisplay;
-	bochs->bpp = 32;
-	bochs->stride = mode->hdisplay * (bochs->bpp / 8);
 
-	DRM_DEBUG_DRIVER("%dx%d @ %d bpp\n",
-			 bochs->xres, bochs->yres, bochs->bpp);
+	DRM_DEBUG_DRIVER("%dx%d\n",
+			 bochs->xres, bochs->yres);
 
 	bochs_vga_writeb(bochs, 0x3c0, 0x20); /* unblank */
 
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_ENABLE,      0);
-	bochs_dispi_write(bochs, VBE_DISPI_INDEX_BPP,         bochs->bpp);
+	bochs_dispi_write(bochs, VBE_DISPI_INDEX_BPP,         32);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_XRES,        bochs->xres);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_YRES,        bochs->yres);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_BANK,        0);
@@ -256,11 +254,13 @@ void bochs_hw_setfb(struct bochs_device *bochs,
 {
 	struct drm_gem_vram_object *bo = drm_gem_vram_of_gem(fb->obj[0]);
 	unsigned long offset = bo->bo.offset +
-		y * bochs->stride +
-		x * (bochs->bpp / 8);
-	int vy = offset / bochs->stride;
-	int vx = (offset % bochs->stride) * 8 / bochs->bpp;
+		y * fb->pitches[0] +
+		x * fb->format->cpp[0];
+	int vy = offset / fb->pitches[0];
+	int vx = (offset % fb->pitches[0]) / fb->format->cpp[0];
+	int vw = fb->pitches[0] / fb->format->cpp[0];
 
+	bochs_dispi_write(bochs, VBE_DISPI_INDEX_VIRT_WIDTH, vw);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_X_OFFSET, vx);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_Y_OFFSET, vy);
 }
drivers/gpu/drm/bochs/bochs_kms.c +1 -1
index ddbf0802138d..28edfb2772ff 100644
@@ -27,7 +27,7 @@ static const uint32_t bochs_formats[] = {
 static void bochs_plane_update(struct bochs_device *bochs,
 			       struct drm_plane_state *state)
 {
-	if (!state->fb || !bochs->stride)
+	if (!state->fb)
 		return;
 
 	bochs_hw_setfb(bochs, state->fb,
Signature · 1 line
2.18.1
#11 lore raw

PATCH v3 4/5 drm/bochs: drop stride and bpp from struct bochs_device

In reply to Gerd Hoffmann

No need to store that, struct drm_framebuffer has all we need.

Also update VBE_DISPI_INDEX_VIRT_WIDTH register, otherwise we'll have a fixes broken display in case pitch != width * cpp.

---
 drivers/gpu/drm/bochs/bochs.h     |  2 --
 drivers/gpu/drm/bochs/bochs_hw.c  | 18 +++++++++---------
 drivers/gpu/drm/bochs/bochs_kms.c |  2 +-
 3 files changed, 10 insertions(+), 12 deletions(-)
drivers/gpu/drm/bochs/bochs.h +0 -2
index 5c90b76708ef..4081b3aba28d 100644
@@ -64,8 +64,6 @@ struct bochs_device {
 	/* mode */
 	u16 xres;
 	u16 yres;
-	u32 stride;
-	u32 bpp;
 	struct edid *edid;
 
 	/* drm */
drivers/gpu/drm/bochs/bochs_hw.c +9 -9
index 9ab6ec269ef9..178715c6755d 100644
@@ -205,16 +205,14 @@ void bochs_hw_setmode(struct bochs_device *bochs,
 {
 	bochs->xres = mode->hdisplay;
 	bochs->yres = mode->vdisplay;
-	bochs->bpp = 32;
-	bochs->stride = mode->hdisplay * (bochs->bpp / 8);
 
-	DRM_DEBUG_DRIVER("%dx%d @ %d bpp\n",
-			 bochs->xres, bochs->yres, bochs->bpp);
+	DRM_DEBUG_DRIVER("%dx%d\n",
+			 bochs->xres, bochs->yres);
 
 	bochs_vga_writeb(bochs, 0x3c0, 0x20); /* unblank */
 
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_ENABLE,      0);
-	bochs_dispi_write(bochs, VBE_DISPI_INDEX_BPP,         bochs->bpp);
+	bochs_dispi_write(bochs, VBE_DISPI_INDEX_BPP,         32);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_XRES,        bochs->xres);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_YRES,        bochs->yres);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_BANK,        0);
@@ -256,11 +254,13 @@ void bochs_hw_setfb(struct bochs_device *bochs,
 {
 	struct drm_gem_vram_object *bo = drm_gem_vram_of_gem(fb->obj[0]);
 	unsigned long offset = bo->bo.offset +
-		y * bochs->stride +
-		x * (bochs->bpp / 8);
-	int vy = offset / bochs->stride;
-	int vx = (offset % bochs->stride) * 8 / bochs->bpp;
+		y * fb->pitches[0] +
+		x * fb->format->cpp[0];
+	int vy = offset / fb->pitches[0];
+	int vx = (offset % fb->pitches[0]) / fb->format->cpp[0];
+	int vw = fb->pitches[0] / fb->format->cpp[0];
 
+	bochs_dispi_write(bochs, VBE_DISPI_INDEX_VIRT_WIDTH, vw);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_X_OFFSET, vx);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_Y_OFFSET, vy);
 }
drivers/gpu/drm/bochs/bochs_kms.c +1 -1
index ddbf0802138d..28edfb2772ff 100644
@@ -27,7 +27,7 @@ static const uint32_t bochs_formats[] = {
 static void bochs_plane_update(struct bochs_device *bochs,
 			       struct drm_plane_state *state)
 {
-	if (!state->fb || !bochs->stride)
+	if (!state->fb)
 		return;
 
 	bochs_hw_setfb(bochs, state->fb,
Signature · 1 line
2.18.1
#12 lore raw

PATCH v3 5/5 drm/bochs: move bochs_hw_setformat() call

In reply to Gerd Hoffmann

Call it from bochs_hw_setfb().
This also allows to make bochs_hw_setformat static.

---
 drivers/gpu/drm/bochs/bochs.h     | 2 --
 drivers/gpu/drm/bochs/bochs_hw.c  | 5 +++--
 drivers/gpu/drm/bochs/bochs_kms.c | 1 -
 3 files changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/bochs/bochs.h +0 -2
index 4081b3aba28d..528b8e8dde40 100644
@@ -80,8 +80,6 @@ void bochs_hw_fini(struct drm_device *dev);
 
 void bochs_hw_setmode(struct bochs_device *bochs,
 		      struct drm_display_mode *mode);
-void bochs_hw_setformat(struct bochs_device *bochs,
-			const struct drm_format_info *format);
 void bochs_hw_setfb(struct bochs_device *bochs,
 		    struct drm_framebuffer *fb,
 		    int x, int y);
drivers/gpu/drm/bochs/bochs_hw.c +3 -2
index 178715c6755d..daa4fda3d322 100644
@@ -224,8 +224,8 @@ void bochs_hw_setmode(struct bochs_device *bochs,
 			  VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED);
 }
 
-void bochs_hw_setformat(struct bochs_device *bochs,
-			const struct drm_format_info *format)
+static void bochs_hw_setformat(struct bochs_device *bochs,
+			       const struct drm_format_info *format)
 {
 	DRM_DEBUG_DRIVER("format %c%c%c%c\n",
 			 (format->format >>  0) & 0xff,
@@ -263,4 +263,5 @@ void bochs_hw_setfb(struct bochs_device *bochs,
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_VIRT_WIDTH, vw);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_X_OFFSET, vx);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_Y_OFFSET, vy);
+	bochs_hw_setformat(bochs, fb->format);
 }
drivers/gpu/drm/bochs/bochs_kms.c +0 -1
index 28edfb2772ff..368803bd12e5 100644
@@ -33,7 +33,6 @@ static void bochs_plane_update(struct bochs_device *bochs,
 	bochs_hw_setfb(bochs, state->fb,
 		       state->crtc_x,
 		       state->crtc_y);
-	bochs_hw_setformat(bochs, state->fb->format);
 }
 
 static void bochs_pipe_enable(struct drm_simple_display_pipe *pipe,
Signature · 1 line
2.18.1
#13 lore raw

PATCH v3 5/5 drm/bochs: move bochs_hw_setformat() call

In reply to Gerd Hoffmann

Call it from bochs_hw_setfb().
This also allows to make bochs_hw_setformat static.

---
 drivers/gpu/drm/bochs/bochs.h     | 2 --
 drivers/gpu/drm/bochs/bochs_hw.c  | 5 +++--
 drivers/gpu/drm/bochs/bochs_kms.c | 1 -
 3 files changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/bochs/bochs.h +0 -2
index 4081b3aba28d..528b8e8dde40 100644
@@ -80,8 +80,6 @@ void bochs_hw_fini(struct drm_device *dev);
 
 void bochs_hw_setmode(struct bochs_device *bochs,
 		      struct drm_display_mode *mode);
-void bochs_hw_setformat(struct bochs_device *bochs,
-			const struct drm_format_info *format);
 void bochs_hw_setfb(struct bochs_device *bochs,
 		    struct drm_framebuffer *fb,
 		    int x, int y);
drivers/gpu/drm/bochs/bochs_hw.c +3 -2
index 178715c6755d..daa4fda3d322 100644
@@ -224,8 +224,8 @@ void bochs_hw_setmode(struct bochs_device *bochs,
 			  VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED);
 }
 
-void bochs_hw_setformat(struct bochs_device *bochs,
-			const struct drm_format_info *format)
+static void bochs_hw_setformat(struct bochs_device *bochs,
+			       const struct drm_format_info *format)
 {
 	DRM_DEBUG_DRIVER("format %c%c%c%c\n",
 			 (format->format >>  0) & 0xff,
@@ -263,4 +263,5 @@ void bochs_hw_setfb(struct bochs_device *bochs,
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_VIRT_WIDTH, vw);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_X_OFFSET, vx);
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_Y_OFFSET, vy);
+	bochs_hw_setformat(bochs, fb->format);
 }
drivers/gpu/drm/bochs/bochs_kms.c +0 -1
index 28edfb2772ff..368803bd12e5 100644
@@ -33,7 +33,6 @@ static void bochs_plane_update(struct bochs_device *bochs,
 	bochs_hw_setfb(bochs, state->fb,
 		       state->crtc_x,
 		       state->crtc_y);
-	bochs_hw_setformat(bochs, state->fb->format);
 }
 
 static void bochs_pipe_enable(struct drm_simple_display_pipe *pipe,
Signature · 1 line
2.18.1
#0 lore raw

v3 cover drm/bochs: cleanups and framebuffer setup fix.

Gerd Hoffmann (5):
gem/vram: pin to vram in vmap
drm/bochs: pass framebuffer to bochs_hw_setbase drm/bochs: drop yres_virtual from struct bochs_device drm/bochs: drop stride and bpp from struct bochs_device drm/bochs: move bochs_hw_setformat() call

 drivers/gpu/drm/bochs/bochs.h         | 10 +++-----
 drivers/gpu/drm/bochs/bochs_hw.c      | 37 ++++++++++++---------------
 drivers/gpu/drm/bochs/bochs_kms.c     | 13 +++-------
 drivers/gpu/drm/drm_gem_vram_helper.c |  2 +-
 4 files changed, 25 insertions(+), 37 deletions(-)
Signature · 6 lines
2.18.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH v3 1/5 gem/vram: pin to vram in vmap

drm clients like the generic framebuffer emulation keep a permanent vmap active, which in turn has a permanent pin. This pin needs to be in vram, otherwise we can't display the framebuffer.

---
 drivers/gpu/drm/drm_gem_vram_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_gem_vram_helper.c +1 -1
index 4de782ca26b2..c724876c6f2a 100644
@@ -592,7 +592,7 @@ void *drm_gem_vram_driver_gem_prime_vmap(struct drm_gem_object *gem)
 	int ret;
 	void *base;
 
-	ret = drm_gem_vram_pin(gbo, 0);
+	ret = drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM);
 	if (ret)
 		return NULL;
 	base = drm_gem_vram_kmap(gbo, true, NULL);
Signature · 6 lines
2.18.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

Re: [PATCH v3 1/5] gem/vram: pin to vram in vmap

Hi

Am 27.06.19 um 14:23 schrieb Gerd Hoffmann:

Quoted 14 lines

drm clients like the generic framebuffer emulation keep a permanent vmap active, which in turn has a permanent pin. This pin needs to be in vram, otherwise we can't display the framebuffer.

---
 drivers/gpu/drm/drm_gem_vram_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_gem_vram_helper.c +0 -0
index 4de782ca26b2..c724876c6f2a 100644

drivers/gpu/drm/drm_gem_vram_helper.c void *drm_gem_vram_driver_gem_prime_vmap(struct drm_gem_object *gem) · line 595

Quoted 5 lines
drivers/gpu/drm/drm_gem_vram_helper.c +1 -1
@@ -592,7 +592,7 @@ void *drm_gem_vram_driver_gem_prime_vmap(struct drm_gem_object *gem)
 	int ret;
 	void *base;
 
-	ret = drm_gem_vram_pin(gbo, 0);
+	ret = drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM);

I have a patch set that converts ast and mgag200 to generic framebuffer emulation with a shadow FB. The actual BO is mapped by the fbdev code on demand to update its content. Permanently mapping the fb console's BO would consume too much display memory. This requires the pin function's placement flag to be 0, so the BO is mapped in system memory by default. The proposed patch breaks this.

Some ideas for solving this:

1) Introduce a default_placement field in struct drm_gem_vram_helper
where this flag can be configured. I'd favor this option.

2) Introduce a separate callback function for pinning to vram. The
driver would have to set the correct function pointers.

3) Pin the fb console buffer manually from within the bochs driver.

Best regards
Thomas

Quoted 4 lines
drivers/gpu/drm/drm_gem_vram_helper.c +0 -0
 	if (ret)
 		return NULL;
 	base = drm_gem_vram_kmap(gbo, true, NULL);
Signature · 5 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

Re: [PATCH v3 1/5] gem/vram: pin to vram in vmap

Hi,

Quoted 7 lines

1) Introduce a default_placement field in struct drm_gem_vram_helper
where this flag can be configured. I'd favor this option.

2) Introduce a separate callback function for pinning to vram. The
driver would have to set the correct function pointers.

3) Pin the fb console buffer manually from within the bochs driver.

Hmm. Before calling drm_fbdev_generic_setup() the bo doesn't exist yet and when the function returns it is already vmapped and pinned I think.

So (3) isn't easily doable. (1) looks best to me.

cheers,
Gerd

#4 lore raw

Re: [PATCH v3 1/5] gem/vram: pin to vram in vmap

Hi

Am 27.06.19 um 17:16 schrieb Gerd Hoffmann:

Quoted 8 lines

Hi,

Quoted 5 lines

1) Introduce a default_placement field in struct drm_gem_vram_helper
where this flag can be configured. I'd favor this option.

2) Introduce a separate callback function for pinning to vram. The
driver would have to set the correct function pointers.

Quoted 6 lines
Quoted 1 line

3) Pin the fb console buffer manually from within the bochs driver.

Hmm. Before calling drm_fbdev_generic_setup() the bo doesn't exist yet and when the function returns it is already vmapped and pinned I think.

So (3) isn't easily doable. (1) looks best to me.

For my patches, it's OK to have to BO pinned to VRAM by default. As the BO will be unmapped most of the time, I can change this flag at any time.

Best regards
Thomas

Quoted 3 lines

cheers,
Gerd

Signature · 5 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)
#5 lore raw

Re: [PATCH v3 1/5] gem/vram: pin to vram in vmap

Am 27.06.19 um 17:54 schrieb Thomas Zimmermann:

Quoted 13 lines

Hi

Am 27.06.19 um 17:16 schrieb Gerd Hoffmann:

Quoted 10 lines

Hi,

Quoted 7 lines

1) Introduce a default_placement field in struct drm_gem_vram_helper
where this flag can be configured. I'd favor this option.

2) Introduce a separate callback function for pinning to vram. The
driver would have to set the correct function pointers.

3) Pin the fb console buffer manually from within the bochs driver.

Quoted 7 lines
Quoted 4 lines

Hmm. Before calling drm_fbdev_generic_setup() the bo doesn't exist yet and when the function returns it is already vmapped and pinned I think.

So (3) isn't easily doable. (1) looks best to me.

For my patches, it's OK to have to BO pinned to VRAM by default. As the BO will be unmapped most of the time, I can change this flag at any time.

So, yeah, option 1 ...

Quoted 13 lines

Best regards
Thomas

Quoted 3 lines

cheers,
Gerd

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 5 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah
HRB 21284 (AG Nürnberg)