Skip to contentSkip to conversation

drm/bochs: cleanups, atomic modesetting, generic fbdev.

PATCH Superseded Gerd Hoffmann 2 participants 39 messages Dec 19, 2018 – Dec 20, 2018

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover drm/bochs: cleanups, atomic modesetting, generic fbdev.

This series adds support for atomic modesetting to the bochs driver. It also switches over to the generic fbdev implementation and does some cleanups.

Gerd Hoffmann (14):
drm/bochs: encoder cleanup
drm/bochs: split bochs_hw_setmode
drm/bochs: atomic: add atomic_flush+atomic_enable callbacks. drm/bochs: atomic: add mode_set_nofb callback. drm/bochs: atomic: switch planes to atomic, wire up helpers. drm/bochs: atomic: use atomic set_config helper drm/bochs: atomic: use atomic page_flip helper drm/bochs: atomic: set DRIVER_ATOMIC
drm/bochs: remove old bochs_crtc_* functions drm/bochs: drop unused gpu_addr arg from bochs_bo_pin() drm/bochs: add basic prime support
drm/bochs: switch to generic drm fbdev emulation drm/bochs: drop old fbdev emulation code drm/bochs: move remaining fb bits to kms

 drivers/gpu/drm/bochs/bochs.h       |  27 +++--
 drivers/gpu/drm/bochs/bochs_drv.c   |  26 +++--
 drivers/gpu/drm/bochs/bochs_fbdev.c | 163 ---------------------------
 drivers/gpu/drm/bochs/bochs_hw.c    |  19 ++--
 drivers/gpu/drm/bochs/bochs_kms.c   | 218 +++++++++++++++++-------------------
 drivers/gpu/drm/bochs/bochs_mm.c    |  74 ++++++++++--
 drivers/gpu/drm/bochs/Makefile      |   2 +-
 7 files changed, 210 insertions(+), 319 deletions(-)
 delete mode 100644 drivers/gpu/drm/bochs/bochs_fbdev.c
Signature · 6 lines
2.9.3

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

PATCH 1/14 drm/bochs: encoder cleanup

Most unused callbacks can be NULL pointers these days. Drop a bunch of empty encoder callbacks.

---
 drivers/gpu/drm/bochs/bochs_kms.c | 26 --------------------------
 1 file changed, 26 deletions(-)
drivers/gpu/drm/bochs/bochs_kms.c +0 -26
index f87c284dd9..c8ce54498d 100644
@@ -170,31 +170,6 @@ static void bochs_crtc_init(struct drm_device *dev)
 	drm_crtc_helper_add(crtc, &bochs_helper_funcs);
 }
 
-static void bochs_encoder_mode_set(struct drm_encoder *encoder,
-				   struct drm_display_mode *mode,
-				   struct drm_display_mode *adjusted_mode)
-{
-}
-
-static void bochs_encoder_dpms(struct drm_encoder *encoder, int state)
-{
-}
-
-static void bochs_encoder_prepare(struct drm_encoder *encoder)
-{
-}
-
-static void bochs_encoder_commit(struct drm_encoder *encoder)
-{
-}
-
-static const struct drm_encoder_helper_funcs bochs_encoder_helper_funcs = {
-	.dpms = bochs_encoder_dpms,
-	.mode_set = bochs_encoder_mode_set,
-	.prepare = bochs_encoder_prepare,
-	.commit = bochs_encoder_commit,
-};
-
 static const struct drm_encoder_funcs bochs_encoder_encoder_funcs = {
 	.destroy = drm_encoder_cleanup,
 };
@@ -207,7 +182,6 @@ static void bochs_encoder_init(struct drm_device *dev)
 	encoder->possible_crtcs = 0x1;
 	drm_encoder_init(dev, encoder, &bochs_encoder_encoder_funcs,
 			 DRM_MODE_ENCODER_DAC, NULL);
-	drm_encoder_helper_add(encoder, &bochs_encoder_helper_funcs);
 }
 
 
Signature · 1 line
2.9.3
Reviewed-by on v1 1/14
#2 lore raw

Re: [PATCH 01/14] drm/bochs: encoder cleanup

Hi, Gerd!

Quoted 45 lines · Gerd Hoffmann

Most unused callbacks can be NULL pointers these days. Drop a bunch of empty encoder callbacks.

---
  drivers/gpu/drm/bochs/bochs_kms.c | 26 --------------------------
  1 file changed, 26 deletions(-)
drivers/gpu/drm/bochs/bochs_kms.c +0 -25
index f87c284dd9..c8ce54498d 100644
@@ -170,31 +170,6 @@ static void bochs_crtc_init(struct drm_device *dev)
  	drm_crtc_helper_add(crtc, &bochs_helper_funcs);
  }
 
-static void bochs_encoder_mode_set(struct drm_encoder *encoder,
-				   struct drm_display_mode *mode,
-				   struct drm_display_mode *adjusted_mode)
-{
-}
-
-static void bochs_encoder_dpms(struct drm_encoder *encoder, int state)
-{
-}
-
-static void bochs_encoder_prepare(struct drm_encoder *encoder)
-{
-}
-
-static void bochs_encoder_commit(struct drm_encoder *encoder)
-{
-}
-
-static const struct drm_encoder_helper_funcs bochs_encoder_helper_funcs = {
-	.dpms = bochs_encoder_dpms,
-	.mode_set = bochs_encoder_mode_set,
-	.prepare = bochs_encoder_prepare,
-	.commit = bochs_encoder_commit,
-};
-
  static const struct drm_encoder_funcs bochs_encoder_encoder_funcs = {
  	.destroy = drm_encoder_cleanup,
  };

drivers/gpu/drm/bochs/bochs_kms.c static void bochs_encoder_init(struct drm_device *dev) · line 187

Quoted 7 lines
drivers/gpu/drm/bochs/bochs_kms.c +0 -1
@@ -207,7 +182,6 @@ static void bochs_encoder_init(struct drm_device *dev)
  	encoder->possible_crtcs = 0x1;
  	drm_encoder_init(dev, encoder, &bochs_encoder_encoder_funcs,
  			 DRM_MODE_ENCODER_DAC, NULL);
-	drm_encoder_helper_add(encoder, &bochs_encoder_helper_funcs);
  }
 
 
#3 lore raw

PATCH 2/14 drm/bochs: split bochs_hw_setmode

In reply to Gerd Hoffmann

Create a separate bochs_hw_setformat function to configure the framebuffer format (actually just the byteorder).

---
 drivers/gpu/drm/bochs/bochs.h     |  5 +++--
 drivers/gpu/drm/bochs/bochs_hw.c  | 19 ++++++++++++-------
 drivers/gpu/drm/bochs/bochs_kms.c |  3 ++-
 3 files changed, 17 insertions(+), 10 deletions(-)
drivers/gpu/drm/bochs/bochs.h +3 -2
index fb38c8b857..4dc1b6384e 100644
@@ -121,8 +121,9 @@ int bochs_hw_init(struct drm_device *dev);
 void bochs_hw_fini(struct drm_device *dev);
 
 void bochs_hw_setmode(struct bochs_device *bochs,
-		      struct drm_display_mode *mode,
-		      const struct drm_format_info *format);
+		      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);
 int bochs_hw_load_edid(struct bochs_device *bochs);
drivers/gpu/drm/bochs/bochs_hw.c +12 -7
index c90a0d492f..bbb251fc78 100644
@@ -197,8 +197,7 @@ void bochs_hw_fini(struct drm_device *dev)
 }
 
 void bochs_hw_setmode(struct bochs_device *bochs,
-		      struct drm_display_mode *mode,
-		      const struct drm_format_info *format)
+		      struct drm_display_mode *mode)
 {
 	bochs->xres = mode->hdisplay;
 	bochs->yres = mode->vdisplay;
@@ -206,12 +205,8 @@ void bochs_hw_setmode(struct bochs_device *bochs,
 	bochs->stride = mode->hdisplay * (bochs->bpp / 8);
 	bochs->yres_virtual = bochs->fb_size / bochs->stride;
 
-	DRM_DEBUG_DRIVER("%dx%d @ %d bpp, format %c%c%c%c, vy %d\n",
+	DRM_DEBUG_DRIVER("%dx%d @ %d bpp, vy %d\n",
 			 bochs->xres, bochs->yres, bochs->bpp,
-			 (format->format >>  0) & 0xff,
-			 (format->format >>  8) & 0xff,
-			 (format->format >> 16) & 0xff,
-			 (format->format >> 24) & 0xff,
 			 bochs->yres_virtual);
 
 	bochs_vga_writeb(bochs, 0x3c0, 0x20); /* unblank */
@@ -229,6 +224,16 @@ void bochs_hw_setmode(struct bochs_device *bochs,
 
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_ENABLE,
 			  VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED);
+}
+
+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,
+			 (format->format >>  8) & 0xff,
+			 (format->format >> 16) & 0xff,
+			 (format->format >> 24) & 0xff);
 
 	switch (format->format) {
 	case DRM_FORMAT_XRGB8888:
drivers/gpu/drm/bochs/bochs_kms.c +2 -1
index c8ce54498d..f7e6d1a9b3 100644
@@ -80,7 +80,8 @@ static int bochs_crtc_mode_set(struct drm_crtc *crtc,
 	if (WARN_ON(crtc->primary->fb == NULL))
 		return -EINVAL;
 
-	bochs_hw_setmode(bochs, mode, crtc->primary->fb->format);
+	bochs_hw_setmode(bochs, mode);
+	bochs_hw_setformat(bochs, crtc->primary->fb->format);
 	bochs_crtc_mode_set_base(crtc, x, y, old_fb);
 	return 0;
 }
Signature · 1 line
2.9.3
Reviewed-by on v1 2/14
#4 lore raw

Re: [PATCH 02/14] drm/bochs: split bochs_hw_setmode

Hi, Gerd!

Quoted 76 lines · Gerd Hoffmann

Create a separate bochs_hw_setformat function to configure the framebuffer format (actually just the byteorder).

---
  drivers/gpu/drm/bochs/bochs.h     |  5 +++--
  drivers/gpu/drm/bochs/bochs_hw.c  | 19 ++++++++++++-------
  drivers/gpu/drm/bochs/bochs_kms.c |  3 ++-
  3 files changed, 17 insertions(+), 10 deletions(-)
drivers/gpu/drm/bochs/bochs.h +3 -2
index fb38c8b857..4dc1b6384e 100644
@@ -121,8 +121,9 @@ int bochs_hw_init(struct drm_device *dev);
  void bochs_hw_fini(struct drm_device *dev);
 
  void bochs_hw_setmode(struct bochs_device *bochs,
-		      struct drm_display_mode *mode,
-		      const struct drm_format_info *format);
+		      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);
  int bochs_hw_load_edid(struct bochs_device *bochs);
drivers/gpu/drm/bochs/bochs_hw.c +12 -7
index c90a0d492f..bbb251fc78 100644
@@ -197,8 +197,7 @@ void bochs_hw_fini(struct drm_device *dev)
  }
 
  void bochs_hw_setmode(struct bochs_device *bochs,
-		      struct drm_display_mode *mode,
-		      const struct drm_format_info *format)
+		      struct drm_display_mode *mode)
  {
  	bochs->xres = mode->hdisplay;
  	bochs->yres = mode->vdisplay;
@@ -206,12 +205,8 @@ void bochs_hw_setmode(struct bochs_device *bochs,
  	bochs->stride = mode->hdisplay * (bochs->bpp / 8);
  	bochs->yres_virtual = bochs->fb_size / bochs->stride;
 
-	DRM_DEBUG_DRIVER("%dx%d @ %d bpp, format %c%c%c%c, vy %d\n",
+	DRM_DEBUG_DRIVER("%dx%d @ %d bpp, vy %d\n",
  			 bochs->xres, bochs->yres, bochs->bpp,
-			 (format->format >>  0) & 0xff,
-			 (format->format >>  8) & 0xff,
-			 (format->format >> 16) & 0xff,
-			 (format->format >> 24) & 0xff,
  			 bochs->yres_virtual);
 
  	bochs_vga_writeb(bochs, 0x3c0, 0x20); /* unblank */
@@ -229,6 +224,16 @@ void bochs_hw_setmode(struct bochs_device *bochs,
 
  	bochs_dispi_write(bochs, VBE_DISPI_INDEX_ENABLE,
  			  VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED);
+}
+
+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,
+			 (format->format >>  8) & 0xff,
+			 (format->format >> 16) & 0xff,
+			 (format->format >> 24) & 0xff);
 
  	switch (format->format) {
  	case DRM_FORMAT_XRGB8888:
drivers/gpu/drm/bochs/bochs_kms.c +0 -0
index c8ce54498d..f7e6d1a9b3 100644

drivers/gpu/drm/bochs/bochs_kms.c static int bochs_crtc_mode_set(struct drm_crtc *crtc, · line 84

Quoted 6 lines
drivers/gpu/drm/bochs/bochs_kms.c +2 -1
@@ -80,7 +80,8 @@ static int bochs_crtc_mode_set(struct drm_crtc *crtc,
  	if (WARN_ON(crtc->primary->fb == NULL))
  		return -EINVAL;
 
-	bochs_hw_setmode(bochs, mode, crtc->primary->fb->format);
+	bochs_hw_setmode(bochs, mode);
+	bochs_hw_setformat(bochs, crtc->primary->fb->format);

I was about to suggest that you go away from direct crtc->primary

use, but it seems this code goes away in this series

drivers/gpu/drm/bochs/bochs_kms.c static int bochs_crtc_mode_set(struct drm_crtc *crtc, · line 87

Quoted 3 lines
drivers/gpu/drm/bochs/bochs_kms.c +0 -0
  	bochs_crtc_mode_set_base(crtc, x, y, old_fb);
  	return 0;
  }

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

#5 lore raw

PATCH 2/14 drm/bochs: split bochs_hw_setmode

In reply to Gerd Hoffmann

Create a separate bochs_hw_setformat function to configure the framebuffer format (actually just the byteorder).

---
 drivers/gpu/drm/bochs/bochs.h     |  5 +++--
 drivers/gpu/drm/bochs/bochs_hw.c  | 19 ++++++++++++-------
 drivers/gpu/drm/bochs/bochs_kms.c |  3 ++-
 3 files changed, 17 insertions(+), 10 deletions(-)
drivers/gpu/drm/bochs/bochs.h +3 -2
index fb38c8b857..4dc1b6384e 100644
@@ -121,8 +121,9 @@ int bochs_hw_init(struct drm_device *dev);
 void bochs_hw_fini(struct drm_device *dev);
 
 void bochs_hw_setmode(struct bochs_device *bochs,
-		      struct drm_display_mode *mode,
-		      const struct drm_format_info *format);
+		      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);
 int bochs_hw_load_edid(struct bochs_device *bochs);
drivers/gpu/drm/bochs/bochs_hw.c +12 -7
index c90a0d492f..bbb251fc78 100644
@@ -197,8 +197,7 @@ void bochs_hw_fini(struct drm_device *dev)
 }
 
 void bochs_hw_setmode(struct bochs_device *bochs,
-		      struct drm_display_mode *mode,
-		      const struct drm_format_info *format)
+		      struct drm_display_mode *mode)
 {
 	bochs->xres = mode->hdisplay;
 	bochs->yres = mode->vdisplay;
@@ -206,12 +205,8 @@ void bochs_hw_setmode(struct bochs_device *bochs,
 	bochs->stride = mode->hdisplay * (bochs->bpp / 8);
 	bochs->yres_virtual = bochs->fb_size / bochs->stride;
 
-	DRM_DEBUG_DRIVER("%dx%d @ %d bpp, format %c%c%c%c, vy %d\n",
+	DRM_DEBUG_DRIVER("%dx%d @ %d bpp, vy %d\n",
 			 bochs->xres, bochs->yres, bochs->bpp,
-			 (format->format >>  0) & 0xff,
-			 (format->format >>  8) & 0xff,
-			 (format->format >> 16) & 0xff,
-			 (format->format >> 24) & 0xff,
 			 bochs->yres_virtual);
 
 	bochs_vga_writeb(bochs, 0x3c0, 0x20); /* unblank */
@@ -229,6 +224,16 @@ void bochs_hw_setmode(struct bochs_device *bochs,
 
 	bochs_dispi_write(bochs, VBE_DISPI_INDEX_ENABLE,
 			  VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED);
+}
+
+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,
+			 (format->format >>  8) & 0xff,
+			 (format->format >> 16) & 0xff,
+			 (format->format >> 24) & 0xff);
 
 	switch (format->format) {
 	case DRM_FORMAT_XRGB8888:
drivers/gpu/drm/bochs/bochs_kms.c +2 -1
index c8ce54498d..f7e6d1a9b3 100644
@@ -80,7 +80,8 @@ static int bochs_crtc_mode_set(struct drm_crtc *crtc,
 	if (WARN_ON(crtc->primary->fb == NULL))
 		return -EINVAL;
 
-	bochs_hw_setmode(bochs, mode, crtc->primary->fb->format);
+	bochs_hw_setmode(bochs, mode);
+	bochs_hw_setformat(bochs, crtc->primary->fb->format);
 	bochs_crtc_mode_set_base(crtc, x, y, old_fb);
 	return 0;
 }
Signature · 1 line
2.9.3
#6 lore raw

PATCH 3/14 drm/bochs: atomic: add atomic_flush+atomic_enable callbacks.

In reply to Gerd Hoffmann

Conversion to atomic modesetting, step one.
Add atomic crtc helper callbacks.

---
 drivers/gpu/drm/bochs/bochs_kms.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/gpu/drm/bochs/bochs_kms.c +25 -0
index f7e6d1a9b3..59d469f343 100644
@@ -115,6 +115,29 @@ static int bochs_crtc_page_flip(struct drm_crtc *crtc,
 	return 0;
 }
 
+static void bochs_crtc_atomic_enable(struct drm_crtc *crtc,
+				     struct drm_crtc_state *old_crtc_state)
+{
+}
+
+static void bochs_crtc_atomic_flush(struct drm_crtc *crtc,
+				    struct drm_crtc_state *old_crtc_state)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_pending_vblank_event *event;
+	unsigned long irqflags;
+
+	if (crtc->state && crtc->state->event) {
+		event = crtc->state->event;
+		crtc->state->event = NULL;
+
+		spin_lock_irqsave(&dev->event_lock, irqflags);
+		drm_crtc_send_vblank_event(crtc, event);
+		spin_unlock_irqrestore(&dev->event_lock, irqflags);
+	}
+}
+
+
 /* These provide the minimum set of functions required to handle a CRTC */
 static const struct drm_crtc_funcs bochs_crtc_funcs = {
 	.set_config = drm_crtc_helper_set_config,
@@ -128,6 +151,8 @@ static const struct drm_crtc_helper_funcs bochs_helper_funcs = {
 	.mode_set_base = bochs_crtc_mode_set_base,
 	.prepare = bochs_crtc_prepare,
 	.commit = bochs_crtc_commit,
+	.atomic_enable = bochs_crtc_atomic_enable,
+	.atomic_flush = bochs_crtc_atomic_flush,
 };
 
 static const uint32_t bochs_formats[] = {
Signature · 1 line
2.9.3
#7 lore raw

Re: [PATCH 03/14] drm/bochs: atomic: add atomic_flush+atomic_enable callbacks.

Hi, Gerd!

Quoted 17 lines · Gerd Hoffmann

Conversion to atomic modesetting, step one.
Add atomic crtc helper callbacks.

---
  drivers/gpu/drm/bochs/bochs_kms.c | 25 +++++++++++++++++++++++++
  1 file changed, 25 insertions(+)
drivers/gpu/drm/bochs/bochs_kms.c +1 -0
index f7e6d1a9b3..59d469f343 100644
@@ -115,6 +115,29 @@ static int bochs_crtc_page_flip(struct drm_crtc *crtc,
  	return 0;
  }
 
+static void bochs_crtc_atomic_enable(struct drm_crtc *crtc,

drivers/gpu/drm/bochs/bochs_kms.c static int bochs_crtc_page_flip(struct drm_crtc *crtc, · line 128

Quoted 10 lines
drivers/gpu/drm/bochs/bochs_kms.c +10 -0
+				     struct drm_crtc_state *old_crtc_state)
+{
+}
+
+static void bochs_crtc_atomic_flush(struct drm_crtc *crtc,
+				    struct drm_crtc_state *old_crtc_state)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_pending_vblank_event *event;
+	unsigned long irqflags;

You could probably move these under the actual if where these are needed, but it's up to you

drivers/gpu/drm/bochs/bochs_kms.c static int bochs_crtc_page_flip(struct drm_crtc *crtc, · line 132

Quoted 4 lines
drivers/gpu/drm/bochs/bochs_kms.c +4 -0
+
+	if (crtc->state && crtc->state->event) {
+		event = crtc->state->event;
+		crtc->state->event = NULL;

Not quite sure if touching the event above is allowed w/o holding the event lock

Quoted 20 lines
drivers/gpu/drm/bochs/bochs_kms.c +10 -0
+
+		spin_lock_irqsave(&dev->event_lock, irqflags);
+		drm_crtc_send_vblank_event(crtc, event);
+		spin_unlock_irqrestore(&dev->event_lock, irqflags);
+	}
+}
+
+
  /* These provide the minimum set of functions required to handle a CRTC */
  static const struct drm_crtc_funcs bochs_crtc_funcs = {
  	.set_config = drm_crtc_helper_set_config,
@@ -128,6 +151,8 @@ static const struct drm_crtc_helper_funcs bochs_helper_funcs = {
  	.mode_set_base = bochs_crtc_mode_set_base,
  	.prepare = bochs_crtc_prepare,
  	.commit = bochs_crtc_commit,
+	.atomic_enable = bochs_crtc_atomic_enable,
+	.atomic_flush = bochs_crtc_atomic_flush,
  };
 
  static const uint32_t bochs_formats[] = {
#8 lore raw

PATCH 3/14 drm/bochs: atomic: add atomic_flush+atomic_enable callbacks.

In reply to Gerd Hoffmann

Conversion to atomic modesetting, step one.
Add atomic crtc helper callbacks.

---
 drivers/gpu/drm/bochs/bochs_kms.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/gpu/drm/bochs/bochs_kms.c +25 -0
index f7e6d1a9b3..59d469f343 100644
@@ -115,6 +115,29 @@ static int bochs_crtc_page_flip(struct drm_crtc *crtc,
 	return 0;
 }
 
+static void bochs_crtc_atomic_enable(struct drm_crtc *crtc,
+				     struct drm_crtc_state *old_crtc_state)
+{
+}
+
+static void bochs_crtc_atomic_flush(struct drm_crtc *crtc,
+				    struct drm_crtc_state *old_crtc_state)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_pending_vblank_event *event;
+	unsigned long irqflags;
+
+	if (crtc->state && crtc->state->event) {
+		event = crtc->state->event;
+		crtc->state->event = NULL;
+
+		spin_lock_irqsave(&dev->event_lock, irqflags);
+		drm_crtc_send_vblank_event(crtc, event);
+		spin_unlock_irqrestore(&dev->event_lock, irqflags);
+	}
+}
+
+
 /* These provide the minimum set of functions required to handle a CRTC */
 static const struct drm_crtc_funcs bochs_crtc_funcs = {
 	.set_config = drm_crtc_helper_set_config,
@@ -128,6 +151,8 @@ static const struct drm_crtc_helper_funcs bochs_helper_funcs = {
 	.mode_set_base = bochs_crtc_mode_set_base,
 	.prepare = bochs_crtc_prepare,
 	.commit = bochs_crtc_commit,
+	.atomic_enable = bochs_crtc_atomic_enable,
+	.atomic_flush = bochs_crtc_atomic_flush,
 };
 
 static const uint32_t bochs_formats[] = {
Signature · 1 line
2.9.3
#9 lore raw

PATCH 4/14 drm/bochs: atomic: add mode_set_nofb callback.

In reply to Gerd Hoffmann

Conversion to atomic modesetting, step two.
Add mode_set_nofb crtc helper callback.

---
 drivers/gpu/drm/bochs/bochs_kms.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/gpu/drm/bochs/bochs_kms.c +9 -0
index 59d469f343..18b705fb0b 100644
@@ -86,6 +86,14 @@ static int bochs_crtc_mode_set(struct drm_crtc *crtc,
 	return 0;
 }
 
+static void bochs_crtc_mode_set_nofb(struct drm_crtc *crtc)
+{
+	struct bochs_device *bochs =
+		container_of(crtc, struct bochs_device, crtc);
+
+	bochs_hw_setmode(bochs, &crtc->mode);
+}
+
 static void bochs_crtc_prepare(struct drm_crtc *crtc)
 {
 }
@@ -149,6 +157,7 @@ static const struct drm_crtc_helper_funcs bochs_helper_funcs = {
 	.dpms = bochs_crtc_dpms,
 	.mode_set = bochs_crtc_mode_set,
 	.mode_set_base = bochs_crtc_mode_set_base,
+	.mode_set_nofb = bochs_crtc_mode_set_nofb,
 	.prepare = bochs_crtc_prepare,
 	.commit = bochs_crtc_commit,
 	.atomic_enable = bochs_crtc_atomic_enable,
Signature · 1 line
2.9.3
Reviewed-by on v1 4/14
#10 lore raw

Re: [PATCH 04/14] drm/bochs: atomic: add mode_set_nofb callback.

Quoted 4 lines · Gerd Hoffmann

Conversion to atomic modesetting, step two.
Add mode_set_nofb crtc helper callback.

Quoted 31 lines
---
  drivers/gpu/drm/bochs/bochs_kms.c | 9 +++++++++
  1 file changed, 9 insertions(+)
drivers/gpu/drm/bochs/bochs_kms.c +9 -0
index 59d469f343..18b705fb0b 100644
@@ -86,6 +86,14 @@ static int bochs_crtc_mode_set(struct drm_crtc *crtc,
  	return 0;
  }
 
+static void bochs_crtc_mode_set_nofb(struct drm_crtc *crtc)
+{
+	struct bochs_device *bochs =
+		container_of(crtc, struct bochs_device, crtc);
+
+	bochs_hw_setmode(bochs, &crtc->mode);
+}
+
  static void bochs_crtc_prepare(struct drm_crtc *crtc)
  {
  }
@@ -149,6 +157,7 @@ static const struct drm_crtc_helper_funcs bochs_helper_funcs = {
  	.dpms = bochs_crtc_dpms,
  	.mode_set = bochs_crtc_mode_set,
  	.mode_set_base = bochs_crtc_mode_set_base,
+	.mode_set_nofb = bochs_crtc_mode_set_nofb,
  	.prepare = bochs_crtc_prepare,
  	.commit = bochs_crtc_commit,
  	.atomic_enable = bochs_crtc_atomic_enable,
#11 lore raw

PATCH 5/14 drm/bochs: atomic: switch planes to atomic, wire up helpers.

In reply to Gerd Hoffmann

Conversion to atomic modesetting, step three.
Wire up atomic helpers. Switch planes to atomic.

We are late to the party, the transitional helpers are gone, so this can't be splitted into smaller steps any more.

---
 drivers/gpu/drm/bochs/bochs_fbdev.c |  3 ++
 drivers/gpu/drm/bochs/bochs_kms.c   | 70 +++++++++++++++++++++++++++++++++++--
 2 files changed, 70 insertions(+), 3 deletions(-)
drivers/gpu/drm/bochs/bochs_fbdev.c +3 -0
index dd3c7df267..d9f3d42999 100644
@@ -6,6 +6,7 @@
  */
 
 #include "bochs.h"
+#include <drm/drm_atomic_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 
 /* ---------------------------------------------------------------------- */
@@ -149,6 +150,8 @@ bochs_gem_fb_create(struct drm_device *dev, struct drm_file *file,
 
 const struct drm_mode_config_funcs bochs_mode_funcs = {
 	.fb_create = bochs_gem_fb_create,
+	.atomic_check = drm_atomic_helper_check,
+	.atomic_commit = drm_atomic_helper_commit,
 };
 
 int bochs_fbdev_init(struct bochs_device *bochs)
drivers/gpu/drm/bochs/bochs_kms.c +67 -3

121 lines not on this page · raw message

Signature · 1 line
2.9.3
Reviewed-by on v1 5/14
#12 lore raw

Re: [PATCH 05/14] drm/bochs: atomic: switch planes to atomic, wire up helpers.

Quoted 48 lines · Gerd Hoffmann

Conversion to atomic modesetting, step three.
Wire up atomic helpers. Switch planes to atomic.

We are late to the party, the transitional helpers are gone, so this can't be splitted into smaller steps any more.

---
  drivers/gpu/drm/bochs/bochs_fbdev.c |  3 ++
  drivers/gpu/drm/bochs/bochs_kms.c   | 70 +++++++++++++++++++++++++++++++++++--
  2 files changed, 70 insertions(+), 3 deletions(-)
drivers/gpu/drm/bochs/bochs_fbdev.c +3 -0
index dd3c7df267..d9f3d42999 100644
@@ -6,6 +6,7 @@
   */
 
  #include "bochs.h"
+#include <drm/drm_atomic_helper.h>
  #include <drm/drm_gem_framebuffer_helper.h>
 
  /* ---------------------------------------------------------------------- */
@@ -149,6 +150,8 @@ bochs_gem_fb_create(struct drm_device *dev, struct drm_file *file,
 
  const struct drm_mode_config_funcs bochs_mode_funcs = {
  	.fb_create = bochs_gem_fb_create,
+	.atomic_check = drm_atomic_helper_check,
+	.atomic_commit = drm_atomic_helper_commit,
  };
 
  int bochs_fbdev_init(struct bochs_device *bochs)
drivers/gpu/drm/bochs/bochs_kms.c +2 -0
index 18b705fb0b..aa3ba0377a 100644
@@ -6,7 +6,9 @@
   */
 
  #include "bochs.h"
+#include <drm/drm_atomic_helper.h>
  #include <drm/drm_plane_helper.h>
+#include <drm/drm_atomic_uapi.h>
 
  static int defx = 1024;
  static int defy = 768;

drivers/gpu/drm/bochs/bochs_kms.c static int bochs_crtc_page_flip(struct drm_crtc *crtc, · line 118

Quoted 5 lines
drivers/gpu/drm/bochs/bochs_kms.c +1 -1
@@ -113,7 +115,7 @@ static int bochs_crtc_page_flip(struct drm_crtc *crtc,
  	struct drm_framebuffer *old_fb = crtc->primary->fb;
  	unsigned long irqflags;
 
-	crtc->primary->fb = fb;
+	drm_atomic_set_fb_for_plane(crtc->primary->state, fb);

Taking into account that crtc->primary access goes away in the series:

Quoted 104 lines
drivers/gpu/drm/bochs/bochs_kms.c +62 -2
  	bochs_crtc_mode_set_base(crtc, 0, 0, old_fb);
  	if (event) {
  		spin_lock_irqsave(&bochs->dev->event_lock, irqflags);
@@ -151,6 +153,9 @@ static const struct drm_crtc_funcs bochs_crtc_funcs = {
  	.set_config = drm_crtc_helper_set_config,
  	.destroy = drm_crtc_cleanup,
  	.page_flip = bochs_crtc_page_flip,
+	.reset = drm_atomic_helper_crtc_reset,
+	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
+	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
  };
 
  static const struct drm_crtc_helper_funcs bochs_helper_funcs = {
@@ -169,6 +174,59 @@ static const uint32_t bochs_formats[] = {
  	DRM_FORMAT_BGRX8888,
  };
 
+static void bochs_plane_atomic_update(struct drm_plane *plane,
+				      struct drm_plane_state *old_state)
+{
+	struct bochs_device *bochs = plane->dev->dev_private;
+	struct bochs_bo *bo;
+
+	if (!plane->state->fb)
+		return;
+	bo = gem_to_bochs_bo(plane->state->fb->obj[0]);
+	bochs_hw_setbase(bochs,
+			 plane->state->crtc_x,
+			 plane->state->crtc_y,
+			 bo->bo.offset);
+	bochs_hw_setformat(bochs, plane->state->fb->format);
+}
+
+static int bochs_plane_prepare_fb(struct drm_plane *plane,
+				struct drm_plane_state *new_state)
+{
+	struct bochs_bo *bo;
+
+	if (!new_state->fb)
+		return 0;
+	bo = gem_to_bochs_bo(new_state->fb->obj[0]);
+	return bochs_bo_pin(bo, TTM_PL_FLAG_VRAM, NULL);
+}
+
+static void bochs_plane_cleanup_fb(struct drm_plane *plane,
+				   struct drm_plane_state *old_state)
+{
+	struct bochs_bo *bo;
+
+	if (!old_state->fb)
+		return;
+	bo = gem_to_bochs_bo(old_state->fb->obj[0]);
+	bochs_bo_unpin(bo);
+}
+
+static const struct drm_plane_helper_funcs bochs_plane_helper_funcs = {
+	.atomic_update = bochs_plane_atomic_update,
+	.prepare_fb = bochs_plane_prepare_fb,
+	.cleanup_fb = bochs_plane_cleanup_fb,
+};
+
+static const struct drm_plane_funcs bochs_plane_funcs = {
+       .update_plane   = drm_atomic_helper_update_plane,
+       .disable_plane  = drm_atomic_helper_disable_plane,
+       .destroy        = drm_primary_helper_destroy,
+       .reset          = drm_atomic_helper_plane_reset,
+       .atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
+       .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
+};
+
  static struct drm_plane *bochs_primary_plane(struct drm_device *dev)
  {
  	struct drm_plane *primary;
@@ -181,16 +239,17 @@ static struct drm_plane *bochs_primary_plane(struct drm_device *dev)
  	}
 
  	ret = drm_universal_plane_init(dev, primary, 0,
-				       &drm_primary_helper_funcs,
+				       &bochs_plane_funcs,
  				       bochs_formats,
  				       ARRAY_SIZE(bochs_formats),
  				       NULL,
  				       DRM_PLANE_TYPE_PRIMARY, NULL);
  	if (ret) {
  		kfree(primary);
-		primary = NULL;
+		return NULL;
  	}
 
+	drm_plane_helper_add(primary, &bochs_plane_helper_funcs);
  	return primary;
  }
 
@@ -275,6 +334,9 @@ static const struct drm_connector_funcs bochs_connector_connector_funcs = {
  	.dpms = drm_helper_connector_dpms,
  	.fill_modes = drm_helper_probe_single_connector_modes,
  	.destroy = drm_connector_cleanup,
+	.reset = drm_atomic_helper_connector_reset,
+	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
+	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
  };
 
  static void bochs_connector_init(struct drm_device *dev)

drivers/gpu/drm/bochs/bochs_kms.c int bochs_kms_init(struct bochs_device *bochs) · line 387

Quoted 8 lines
drivers/gpu/drm/bochs/bochs_kms.c +2 -0
@@ -318,6 +380,8 @@ int bochs_kms_init(struct bochs_device *bochs)
  	drm_connector_attach_encoder(&bochs->connector,
  					  &bochs->encoder);
 
+	drm_mode_config_reset(bochs->dev);
+
  	return 0;
  }
 

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

#13 lore raw

PATCH 5/14 drm/bochs: atomic: switch planes to atomic, wire up helpers.

In reply to Gerd Hoffmann

Conversion to atomic modesetting, step three.
Wire up atomic helpers. Switch planes to atomic.

We are late to the party, the transitional helpers are gone, so this can't be splitted into smaller steps any more.

---
 drivers/gpu/drm/bochs/bochs_fbdev.c |  3 ++
 drivers/gpu/drm/bochs/bochs_kms.c   | 70 +++++++++++++++++++++++++++++++++++--
 2 files changed, 70 insertions(+), 3 deletions(-)
drivers/gpu/drm/bochs/bochs_fbdev.c +3 -0
index dd3c7df267..d9f3d42999 100644
@@ -6,6 +6,7 @@
  */
 
 #include "bochs.h"
+#include <drm/drm_atomic_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 
 /* ---------------------------------------------------------------------- */
@@ -149,6 +150,8 @@ bochs_gem_fb_create(struct drm_device *dev, struct drm_file *file,
 
 const struct drm_mode_config_funcs bochs_mode_funcs = {
 	.fb_create = bochs_gem_fb_create,
+	.atomic_check = drm_atomic_helper_check,
+	.atomic_commit = drm_atomic_helper_commit,
 };
 
 int bochs_fbdev_init(struct bochs_device *bochs)
drivers/gpu/drm/bochs/bochs_kms.c +67 -3

121 lines not on this page · raw message

Signature · 1 line
2.9.3
#14 lore raw

PATCH 6/14 drm/bochs: atomic: use atomic set_config helper

In reply to Gerd Hoffmann

Conversion to atomic modesetting, step four.
Use atomic set_config helper for crtc.

---
 drivers/gpu/drm/bochs/bochs_kms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bochs/bochs_kms.c +1 -1
index aa3ba0377a..dcc8b864fc 100644
@@ -150,7 +150,7 @@ static void bochs_crtc_atomic_flush(struct drm_crtc *crtc,
 
 /* These provide the minimum set of functions required to handle a CRTC */
 static const struct drm_crtc_funcs bochs_crtc_funcs = {
-	.set_config = drm_crtc_helper_set_config,
+	.set_config = drm_atomic_helper_set_config,
 	.destroy = drm_crtc_cleanup,
 	.page_flip = bochs_crtc_page_flip,
 	.reset = drm_atomic_helper_crtc_reset,
Signature · 1 line
2.9.3
Reviewed-by on v1 6/14
#15 lore raw

Re: [PATCH 06/14] drm/bochs: atomic: use atomic set_config helper

Quoted 4 lines · Gerd Hoffmann

Conversion to atomic modesetting, step four.
Use atomic set_config helper for crtc.

Quoted 9 lines
---
  drivers/gpu/drm/bochs/bochs_kms.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bochs/bochs_kms.c +0 -0
index aa3ba0377a..dcc8b864fc 100644

drivers/gpu/drm/bochs/bochs_kms.c static void bochs_crtc_atomic_flush(struct drm_crtc *crtc, · line 156

Quoted 8 lines
drivers/gpu/drm/bochs/bochs_kms.c +1 -1
@@ -150,7 +150,7 @@ static void bochs_crtc_atomic_flush(struct drm_crtc *crtc,
 
  /* These provide the minimum set of functions required to handle a CRTC */
  static const struct drm_crtc_funcs bochs_crtc_funcs = {
-	.set_config = drm_crtc_helper_set_config,
+	.set_config = drm_atomic_helper_set_config,
  	.destroy = drm_crtc_cleanup,
  	.page_flip = bochs_crtc_page_flip,
  	.reset = drm_atomic_helper_crtc_reset,

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

#16 lore raw

PATCH 7/14 drm/bochs: atomic: use atomic page_flip helper

In reply to Gerd Hoffmann

Conversion to atomic modesetting, step five.
Use atomic page_flip helper for crtc.

---
 drivers/gpu/drm/bochs/bochs_kms.c | 23 +----------------------
 1 file changed, 1 insertion(+), 22 deletions(-)
drivers/gpu/drm/bochs/bochs_kms.c +1 -22
index dcc8b864fc..9e836386e9 100644
@@ -104,27 +104,6 @@ static void bochs_crtc_commit(struct drm_crtc *crtc)
 {
 }
 
-static int bochs_crtc_page_flip(struct drm_crtc *crtc,
-				struct drm_framebuffer *fb,
-				struct drm_pending_vblank_event *event,
-				uint32_t page_flip_flags,
-				struct drm_modeset_acquire_ctx *ctx)
-{
-	struct bochs_device *bochs =
-		container_of(crtc, struct bochs_device, crtc);
-	struct drm_framebuffer *old_fb = crtc->primary->fb;
-	unsigned long irqflags;
-
-	drm_atomic_set_fb_for_plane(crtc->primary->state, fb);
-	bochs_crtc_mode_set_base(crtc, 0, 0, old_fb);
-	if (event) {
-		spin_lock_irqsave(&bochs->dev->event_lock, irqflags);
-		drm_crtc_send_vblank_event(crtc, event);
-		spin_unlock_irqrestore(&bochs->dev->event_lock, irqflags);
-	}
-	return 0;
-}
-
 static void bochs_crtc_atomic_enable(struct drm_crtc *crtc,
 				     struct drm_crtc_state *old_crtc_state)
 {
@@ -152,7 +131,7 @@ static void bochs_crtc_atomic_flush(struct drm_crtc *crtc,
 static const struct drm_crtc_funcs bochs_crtc_funcs = {
 	.set_config = drm_atomic_helper_set_config,
 	.destroy = drm_crtc_cleanup,
-	.page_flip = bochs_crtc_page_flip,
+	.page_flip = drm_atomic_helper_page_flip,
 	.reset = drm_atomic_helper_crtc_reset,
 	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
Signature · 1 line
2.9.3
Reviewed-by on v1 7/14
#17 lore raw

Re: [PATCH 07/14] drm/bochs: atomic: use atomic page_flip helper

Quoted 4 lines · Gerd Hoffmann

Conversion to atomic modesetting, step five.
Use atomic page_flip helper for crtc.

Quoted 37 lines
---
  drivers/gpu/drm/bochs/bochs_kms.c | 23 +----------------------
  1 file changed, 1 insertion(+), 22 deletions(-)
drivers/gpu/drm/bochs/bochs_kms.c +0 -21
index dcc8b864fc..9e836386e9 100644
@@ -104,27 +104,6 @@ static void bochs_crtc_commit(struct drm_crtc *crtc)
  {
  }
 
-static int bochs_crtc_page_flip(struct drm_crtc *crtc,
-				struct drm_framebuffer *fb,
-				struct drm_pending_vblank_event *event,
-				uint32_t page_flip_flags,
-				struct drm_modeset_acquire_ctx *ctx)
-{
-	struct bochs_device *bochs =
-		container_of(crtc, struct bochs_device, crtc);
-	struct drm_framebuffer *old_fb = crtc->primary->fb;
-	unsigned long irqflags;
-
-	drm_atomic_set_fb_for_plane(crtc->primary->state, fb);
-	bochs_crtc_mode_set_base(crtc, 0, 0, old_fb);
-	if (event) {
-		spin_lock_irqsave(&bochs->dev->event_lock, irqflags);
-		drm_crtc_send_vblank_event(crtc, event);
-		spin_unlock_irqrestore(&bochs->dev->event_lock, irqflags);
-	}
-	return 0;
-}
-
  static void bochs_crtc_atomic_enable(struct drm_crtc *crtc,
  				     struct drm_crtc_state *old_crtc_state)
  {

drivers/gpu/drm/bochs/bochs_kms.c static void bochs_crtc_atomic_flush(struct drm_crtc *crtc, · line 137

Quoted 8 lines
drivers/gpu/drm/bochs/bochs_kms.c +1 -1
@@ -152,7 +131,7 @@ static void bochs_crtc_atomic_flush(struct drm_crtc *crtc,
  static const struct drm_crtc_funcs bochs_crtc_funcs = {
  	.set_config = drm_atomic_helper_set_config,
  	.destroy = drm_crtc_cleanup,
-	.page_flip = bochs_crtc_page_flip,
+	.page_flip = drm_atomic_helper_page_flip,
  	.reset = drm_atomic_helper_crtc_reset,
  	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
  	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,

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

#18 lore raw

PATCH 7/14 drm/bochs: atomic: use atomic page_flip helper

In reply to Gerd Hoffmann

Conversion to atomic modesetting, step five.
Use atomic page_flip helper for crtc.

---
 drivers/gpu/drm/bochs/bochs_kms.c | 23 +----------------------
 1 file changed, 1 insertion(+), 22 deletions(-)
drivers/gpu/drm/bochs/bochs_kms.c +1 -22
index dcc8b864fc..9e836386e9 100644
@@ -104,27 +104,6 @@ static void bochs_crtc_commit(struct drm_crtc *crtc)
 {
 }
 
-static int bochs_crtc_page_flip(struct drm_crtc *crtc,
-				struct drm_framebuffer *fb,
-				struct drm_pending_vblank_event *event,
-				uint32_t page_flip_flags,
-				struct drm_modeset_acquire_ctx *ctx)
-{
-	struct bochs_device *bochs =
-		container_of(crtc, struct bochs_device, crtc);
-	struct drm_framebuffer *old_fb = crtc->primary->fb;
-	unsigned long irqflags;
-
-	drm_atomic_set_fb_for_plane(crtc->primary->state, fb);
-	bochs_crtc_mode_set_base(crtc, 0, 0, old_fb);
-	if (event) {
-		spin_lock_irqsave(&bochs->dev->event_lock, irqflags);
-		drm_crtc_send_vblank_event(crtc, event);
-		spin_unlock_irqrestore(&bochs->dev->event_lock, irqflags);
-	}
-	return 0;
-}
-
 static void bochs_crtc_atomic_enable(struct drm_crtc *crtc,
 				     struct drm_crtc_state *old_crtc_state)
 {
@@ -152,7 +131,7 @@ static void bochs_crtc_atomic_flush(struct drm_crtc *crtc,
 static const struct drm_crtc_funcs bochs_crtc_funcs = {
 	.set_config = drm_atomic_helper_set_config,
 	.destroy = drm_crtc_cleanup,
-	.page_flip = bochs_crtc_page_flip,
+	.page_flip = drm_atomic_helper_page_flip,
 	.reset = drm_atomic_helper_crtc_reset,
 	.atomic_duplicate_state = drm_atomic_helper_crtc_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_crtc_destroy_state,
Signature · 1 line
2.9.3
#19 lore raw

PATCH 8/14 drm/bochs: atomic: set DRIVER_ATOMIC

In reply to Gerd Hoffmann

Conversion to atomic modesetting, final step.
Set the DRIVER_ATOMIC flag.

---
 drivers/gpu/drm/bochs/bochs_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bochs/bochs_drv.c +1 -1
index f3dd66ae99..278f9d2e7f 100644
@@ -81,7 +81,7 @@ static const struct file_operations bochs_fops = {
 };
 
 static struct drm_driver bochs_driver = {
-	.driver_features	= DRIVER_GEM | DRIVER_MODESET,
+	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
 	.fops			= &bochs_fops,
 	.name			= "bochs-drm",
 	.desc			= "bochs dispi vga interface (qemu stdvga)",
Signature · 1 line
2.9.3
Reviewed-by on v1 8/14
#20 lore raw

Re: [PATCH 08/14] drm/bochs: atomic: set DRIVER_ATOMIC

Quoted 4 lines · Gerd Hoffmann

Conversion to atomic modesetting, final step.
Set the DRIVER_ATOMIC flag.

Quoted 17 lines
---
  drivers/gpu/drm/bochs/bochs_drv.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bochs/bochs_drv.c +1 -1
index f3dd66ae99..278f9d2e7f 100644
@@ -81,7 +81,7 @@ static const struct file_operations bochs_fops = {
  };
 
  static struct drm_driver bochs_driver = {
-	.driver_features	= DRIVER_GEM | DRIVER_MODESET,
+	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
  	.fops			= &bochs_fops,
  	.name			= "bochs-drm",
  	.desc			= "bochs dispi vga interface (qemu stdvga)",
#21 lore raw

PATCH 8/14 drm/bochs: atomic: set DRIVER_ATOMIC

In reply to Gerd Hoffmann

Conversion to atomic modesetting, final step.
Set the DRIVER_ATOMIC flag.

---
 drivers/gpu/drm/bochs/bochs_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bochs/bochs_drv.c +1 -1
index f3dd66ae99..278f9d2e7f 100644
@@ -81,7 +81,7 @@ static const struct file_operations bochs_fops = {
 };
 
 static struct drm_driver bochs_driver = {
-	.driver_features	= DRIVER_GEM | DRIVER_MODESET,
+	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
 	.fops			= &bochs_fops,
 	.name			= "bochs-drm",
 	.desc			= "bochs dispi vga interface (qemu stdvga)",
Signature · 1 line
2.9.3
#22 lore raw

PATCH 9/14 drm/bochs: remove old bochs_crtc_* functions

In reply to Gerd Hoffmann

Remove the old, now unused crtc callbacks.

---
 drivers/gpu/drm/bochs/bochs_kms.c | 81 ---------------------------------------
 1 file changed, 81 deletions(-)
drivers/gpu/drm/bochs/bochs_kms.c +0 -81
index 9e836386e9..85dd268fa1 100644
@@ -20,74 +20,6 @@ MODULE_PARM_DESC(defy, "default y resolution");
 
 /* ---------------------------------------------------------------------- */
 
-static void bochs_crtc_dpms(struct drm_crtc *crtc, int mode)
-{
-	switch (mode) {
-	case DRM_MODE_DPMS_ON:
-	case DRM_MODE_DPMS_STANDBY:
-	case DRM_MODE_DPMS_SUSPEND:
-	case DRM_MODE_DPMS_OFF:
-	default:
-		return;
-	}
-}
-
-static int bochs_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
-				    struct drm_framebuffer *old_fb)
-{
-	struct bochs_device *bochs =
-		container_of(crtc, struct bochs_device, crtc);
-	struct bochs_bo *bo;
-	u64 gpu_addr = 0;
-	int ret;
-
-	if (old_fb) {
-		bo = gem_to_bochs_bo(old_fb->obj[0]);
-		ret = ttm_bo_reserve(&bo->bo, true, false, NULL);
-		if (ret) {
-			DRM_ERROR("failed to reserve old_fb bo\n");
-		} else {
-			bochs_bo_unpin(bo);
-			ttm_bo_unreserve(&bo->bo);
-		}
-	}
-
-	if (WARN_ON(crtc->primary->fb == NULL))
-		return -EINVAL;
-
-	bo = gem_to_bochs_bo(crtc->primary->fb->obj[0]);
-	ret = ttm_bo_reserve(&bo->bo, true, false, NULL);
-	if (ret)
-		return ret;
-
-	ret = bochs_bo_pin(bo, TTM_PL_FLAG_VRAM, &gpu_addr);
-	if (ret) {
-		ttm_bo_unreserve(&bo->bo);
-		return ret;
-	}
-
-	ttm_bo_unreserve(&bo->bo);
-	bochs_hw_setbase(bochs, x, y, gpu_addr);
-	return 0;
-}
-
-static int bochs_crtc_mode_set(struct drm_crtc *crtc,
-			       struct drm_display_mode *mode,
-			       struct drm_display_mode *adjusted_mode,
-			       int x, int y, struct drm_framebuffer *old_fb)
-{
-	struct bochs_device *bochs =
-		container_of(crtc, struct bochs_device, crtc);
-
-	if (WARN_ON(crtc->primary->fb == NULL))
-		return -EINVAL;
-
-	bochs_hw_setmode(bochs, mode);
-	bochs_hw_setformat(bochs, crtc->primary->fb->format);
-	bochs_crtc_mode_set_base(crtc, x, y, old_fb);
-	return 0;
-}
-
 static void bochs_crtc_mode_set_nofb(struct drm_crtc *crtc)
 {
 	struct bochs_device *bochs =
@@ -96,14 +28,6 @@ static void bochs_crtc_mode_set_nofb(struct drm_crtc *crtc)
 	bochs_hw_setmode(bochs, &crtc->mode);
 }
 
-static void bochs_crtc_prepare(struct drm_crtc *crtc)
-{
-}
-
-static void bochs_crtc_commit(struct drm_crtc *crtc)
-{
-}
-
 static void bochs_crtc_atomic_enable(struct drm_crtc *crtc,
 				     struct drm_crtc_state *old_crtc_state)
 {
@@ -138,12 +62,7 @@ static const struct drm_crtc_funcs bochs_crtc_funcs = {
 };
 
 static const struct drm_crtc_helper_funcs bochs_helper_funcs = {
-	.dpms = bochs_crtc_dpms,
-	.mode_set = bochs_crtc_mode_set,
-	.mode_set_base = bochs_crtc_mode_set_base,
 	.mode_set_nofb = bochs_crtc_mode_set_nofb,
-	.prepare = bochs_crtc_prepare,
-	.commit = bochs_crtc_commit,
 	.atomic_enable = bochs_crtc_atomic_enable,
 	.atomic_flush = bochs_crtc_atomic_flush,
 };
Signature · 1 line
2.9.3
Reviewed-by on v1 9/14
#23 lore raw

Re: [PATCH 09/14] drm/bochs: remove old bochs_crtc_* functions

Quoted 3 lines · Gerd Hoffmann

Remove the old, now unused crtc callbacks.

Quoted 111 lines
---
  drivers/gpu/drm/bochs/bochs_kms.c | 81 ---------------------------------------
  1 file changed, 81 deletions(-)
drivers/gpu/drm/bochs/bochs_kms.c +0 -81
index 9e836386e9..85dd268fa1 100644
@@ -20,74 +20,6 @@ MODULE_PARM_DESC(defy, "default y resolution");
 
  /* ---------------------------------------------------------------------- */
 
-static void bochs_crtc_dpms(struct drm_crtc *crtc, int mode)
-{
-	switch (mode) {
-	case DRM_MODE_DPMS_ON:
-	case DRM_MODE_DPMS_STANDBY:
-	case DRM_MODE_DPMS_SUSPEND:
-	case DRM_MODE_DPMS_OFF:
-	default:
-		return;
-	}
-}
-
-static int bochs_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
-				    struct drm_framebuffer *old_fb)
-{
-	struct bochs_device *bochs =
-		container_of(crtc, struct bochs_device, crtc);
-	struct bochs_bo *bo;
-	u64 gpu_addr = 0;
-	int ret;
-
-	if (old_fb) {
-		bo = gem_to_bochs_bo(old_fb->obj[0]);
-		ret = ttm_bo_reserve(&bo->bo, true, false, NULL);
-		if (ret) {
-			DRM_ERROR("failed to reserve old_fb bo\n");
-		} else {
-			bochs_bo_unpin(bo);
-			ttm_bo_unreserve(&bo->bo);
-		}
-	}
-
-	if (WARN_ON(crtc->primary->fb == NULL))
-		return -EINVAL;
-
-	bo = gem_to_bochs_bo(crtc->primary->fb->obj[0]);
-	ret = ttm_bo_reserve(&bo->bo, true, false, NULL);
-	if (ret)
-		return ret;
-
-	ret = bochs_bo_pin(bo, TTM_PL_FLAG_VRAM, &gpu_addr);
-	if (ret) {
-		ttm_bo_unreserve(&bo->bo);
-		return ret;
-	}
-
-	ttm_bo_unreserve(&bo->bo);
-	bochs_hw_setbase(bochs, x, y, gpu_addr);
-	return 0;
-}
-
-static int bochs_crtc_mode_set(struct drm_crtc *crtc,
-			       struct drm_display_mode *mode,
-			       struct drm_display_mode *adjusted_mode,
-			       int x, int y, struct drm_framebuffer *old_fb)
-{
-	struct bochs_device *bochs =
-		container_of(crtc, struct bochs_device, crtc);
-
-	if (WARN_ON(crtc->primary->fb == NULL))
-		return -EINVAL;
-
-	bochs_hw_setmode(bochs, mode);
-	bochs_hw_setformat(bochs, crtc->primary->fb->format);
-	bochs_crtc_mode_set_base(crtc, x, y, old_fb);
-	return 0;
-}
-
  static void bochs_crtc_mode_set_nofb(struct drm_crtc *crtc)
  {
  	struct bochs_device *bochs =
@@ -96,14 +28,6 @@ static void bochs_crtc_mode_set_nofb(struct drm_crtc *crtc)
  	bochs_hw_setmode(bochs, &crtc->mode);
  }
 
-static void bochs_crtc_prepare(struct drm_crtc *crtc)
-{
-}
-
-static void bochs_crtc_commit(struct drm_crtc *crtc)
-{
-}
-
  static void bochs_crtc_atomic_enable(struct drm_crtc *crtc,
  				     struct drm_crtc_state *old_crtc_state)
  {
@@ -138,12 +62,7 @@ static const struct drm_crtc_funcs bochs_crtc_funcs = {
  };
 
  static const struct drm_crtc_helper_funcs bochs_helper_funcs = {
-	.dpms = bochs_crtc_dpms,
-	.mode_set = bochs_crtc_mode_set,
-	.mode_set_base = bochs_crtc_mode_set_base,
  	.mode_set_nofb = bochs_crtc_mode_set_nofb,
-	.prepare = bochs_crtc_prepare,
-	.commit = bochs_crtc_commit,
  	.atomic_enable = bochs_crtc_atomic_enable,
  	.atomic_flush = bochs_crtc_atomic_flush,
  };
#24 lore raw

PATCH 9/14 drm/bochs: remove old bochs_crtc_* functions

In reply to Gerd Hoffmann

Remove the old, now unused crtc callbacks.

---
 drivers/gpu/drm/bochs/bochs_kms.c | 81 ---------------------------------------
 1 file changed, 81 deletions(-)
drivers/gpu/drm/bochs/bochs_kms.c +0 -81
index 9e836386e9..85dd268fa1 100644
@@ -20,74 +20,6 @@ MODULE_PARM_DESC(defy, "default y resolution");
 
 /* ---------------------------------------------------------------------- */
 
-static void bochs_crtc_dpms(struct drm_crtc *crtc, int mode)
-{
-	switch (mode) {
-	case DRM_MODE_DPMS_ON:
-	case DRM_MODE_DPMS_STANDBY:
-	case DRM_MODE_DPMS_SUSPEND:
-	case DRM_MODE_DPMS_OFF:
-	default:
-		return;
-	}
-}
-
-static int bochs_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
-				    struct drm_framebuffer *old_fb)
-{
-	struct bochs_device *bochs =
-		container_of(crtc, struct bochs_device, crtc);
-	struct bochs_bo *bo;
-	u64 gpu_addr = 0;
-	int ret;
-
-	if (old_fb) {
-		bo = gem_to_bochs_bo(old_fb->obj[0]);
-		ret = ttm_bo_reserve(&bo->bo, true, false, NULL);
-		if (ret) {
-			DRM_ERROR("failed to reserve old_fb bo\n");
-		} else {
-			bochs_bo_unpin(bo);
-			ttm_bo_unreserve(&bo->bo);
-		}
-	}
-
-	if (WARN_ON(crtc->primary->fb == NULL))
-		return -EINVAL;
-
-	bo = gem_to_bochs_bo(crtc->primary->fb->obj[0]);
-	ret = ttm_bo_reserve(&bo->bo, true, false, NULL);
-	if (ret)
-		return ret;
-
-	ret = bochs_bo_pin(bo, TTM_PL_FLAG_VRAM, &gpu_addr);
-	if (ret) {
-		ttm_bo_unreserve(&bo->bo);
-		return ret;
-	}
-
-	ttm_bo_unreserve(&bo->bo);
-	bochs_hw_setbase(bochs, x, y, gpu_addr);
-	return 0;
-}
-
-static int bochs_crtc_mode_set(struct drm_crtc *crtc,
-			       struct drm_display_mode *mode,
-			       struct drm_display_mode *adjusted_mode,
-			       int x, int y, struct drm_framebuffer *old_fb)
-{
-	struct bochs_device *bochs =
-		container_of(crtc, struct bochs_device, crtc);
-
-	if (WARN_ON(crtc->primary->fb == NULL))
-		return -EINVAL;
-
-	bochs_hw_setmode(bochs, mode);
-	bochs_hw_setformat(bochs, crtc->primary->fb->format);
-	bochs_crtc_mode_set_base(crtc, x, y, old_fb);
-	return 0;
-}
-
 static void bochs_crtc_mode_set_nofb(struct drm_crtc *crtc)
 {
 	struct bochs_device *bochs =
@@ -96,14 +28,6 @@ static void bochs_crtc_mode_set_nofb(struct drm_crtc *crtc)
 	bochs_hw_setmode(bochs, &crtc->mode);
 }
 
-static void bochs_crtc_prepare(struct drm_crtc *crtc)
-{
-}
-
-static void bochs_crtc_commit(struct drm_crtc *crtc)
-{
-}
-
 static void bochs_crtc_atomic_enable(struct drm_crtc *crtc,
 				     struct drm_crtc_state *old_crtc_state)
 {
@@ -138,12 +62,7 @@ static const struct drm_crtc_funcs bochs_crtc_funcs = {
 };
 
 static const struct drm_crtc_helper_funcs bochs_helper_funcs = {
-	.dpms = bochs_crtc_dpms,
-	.mode_set = bochs_crtc_mode_set,
-	.mode_set_base = bochs_crtc_mode_set_base,
 	.mode_set_nofb = bochs_crtc_mode_set_nofb,
-	.prepare = bochs_crtc_prepare,
-	.commit = bochs_crtc_commit,
 	.atomic_enable = bochs_crtc_atomic_enable,
 	.atomic_flush = bochs_crtc_atomic_flush,
 };
Signature · 1 line
2.9.3
#25 lore raw

PATCH 10/14 drm/bochs: drop unused gpu_addr arg from bochs_bo_pin()

In reply to Gerd Hoffmann

It's always NULL, so just remove it.

---
 drivers/gpu/drm/bochs/bochs.h       |  2 +-
 drivers/gpu/drm/bochs/bochs_fbdev.c |  2 +-
 drivers/gpu/drm/bochs/bochs_kms.c   |  2 +-
 drivers/gpu/drm/bochs/bochs_mm.c    | 11 +----------
 4 files changed, 4 insertions(+), 13 deletions(-)
drivers/gpu/drm/bochs/bochs.h +1 -1
index 4dc1b6384e..d0d474e06f 100644
@@ -142,7 +142,7 @@ int bochs_dumb_create(struct drm_file *file, struct drm_device *dev,
 int bochs_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev,
 			   uint32_t handle, uint64_t *offset);
 
-int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag, u64 *gpu_addr);
+int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag);
 int bochs_bo_unpin(struct bochs_bo *bo);
 
 /* bochs_kms.c */
drivers/gpu/drm/bochs/bochs_fbdev.c +1 -1
index d9f3d42999..92feb817ff 100644
@@ -81,7 +81,7 @@ static int bochsfb_create(struct drm_fb_helper *helper,
 	if (ret)
 		return ret;
 
-	ret = bochs_bo_pin(bo, TTM_PL_FLAG_VRAM, NULL);
+	ret = bochs_bo_pin(bo, TTM_PL_FLAG_VRAM);
 	if (ret) {
 		DRM_ERROR("failed to pin fbcon\n");
 		ttm_bo_unreserve(&bo->bo);
drivers/gpu/drm/bochs/bochs_kms.c +1 -1
index 85dd268fa1..a1a0129f3e 100644
@@ -96,7 +96,7 @@ static int bochs_plane_prepare_fb(struct drm_plane *plane,
 	if (!new_state->fb)
 		return 0;
 	bo = gem_to_bochs_bo(new_state->fb->obj[0]);
-	return bochs_bo_pin(bo, TTM_PL_FLAG_VRAM, NULL);
+	return bochs_bo_pin(bo, TTM_PL_FLAG_VRAM);
 }
 
 static void bochs_plane_cleanup_fb(struct drm_plane *plane,
drivers/gpu/drm/bochs/bochs_mm.c +1 -10
index 0980411e41..5a0e092847 100644
@@ -210,20 +210,13 @@ static void bochs_ttm_placement(struct bochs_bo *bo, int domain)
 	bo->placement.num_busy_placement = c;
 }
 
-static inline u64 bochs_bo_gpu_offset(struct bochs_bo *bo)
-{
-	return bo->bo.offset;
-}
-
-int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag, u64 *gpu_addr)
+int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag)
 {
 	struct ttm_operation_ctx ctx = { false, false };
 	int i, ret;
 
 	if (bo->pin_count) {
 		bo->pin_count++;
-		if (gpu_addr)
-			*gpu_addr = bochs_bo_gpu_offset(bo);
 		return 0;
 	}
 
@@ -235,8 +228,6 @@ int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag, u64 *gpu_addr)
 		return ret;
 
 	bo->pin_count = 1;
-	if (gpu_addr)
-		*gpu_addr = bochs_bo_gpu_offset(bo);
 	return 0;
 }
 
Signature · 1 line
2.9.3
Reviewed-by on v1 10/14
#26 lore raw

Re: [PATCH 10/14] drm/bochs: drop unused gpu_addr arg from bochs_bo_pin()

Quoted 3 lines · Gerd Hoffmann

It's always NULL, so just remove it.

Quoted 81 lines
---
  drivers/gpu/drm/bochs/bochs.h       |  2 +-
  drivers/gpu/drm/bochs/bochs_fbdev.c |  2 +-
  drivers/gpu/drm/bochs/bochs_kms.c   |  2 +-
  drivers/gpu/drm/bochs/bochs_mm.c    | 11 +----------
  4 files changed, 4 insertions(+), 13 deletions(-)
drivers/gpu/drm/bochs/bochs.h +1 -1
index 4dc1b6384e..d0d474e06f 100644
@@ -142,7 +142,7 @@ int bochs_dumb_create(struct drm_file *file, struct drm_device *dev,
  int bochs_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev,
  			   uint32_t handle, uint64_t *offset);
 
-int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag, u64 *gpu_addr);
+int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag);
  int bochs_bo_unpin(struct bochs_bo *bo);
 
  /* bochs_kms.c */
drivers/gpu/drm/bochs/bochs_fbdev.c +1 -1
index d9f3d42999..92feb817ff 100644
@@ -81,7 +81,7 @@ static int bochsfb_create(struct drm_fb_helper *helper,
  	if (ret)
  		return ret;
 
-	ret = bochs_bo_pin(bo, TTM_PL_FLAG_VRAM, NULL);
+	ret = bochs_bo_pin(bo, TTM_PL_FLAG_VRAM);
  	if (ret) {
  		DRM_ERROR("failed to pin fbcon\n");
  		ttm_bo_unreserve(&bo->bo);
drivers/gpu/drm/bochs/bochs_kms.c +1 -1
index 85dd268fa1..a1a0129f3e 100644
@@ -96,7 +96,7 @@ static int bochs_plane_prepare_fb(struct drm_plane *plane,
  	if (!new_state->fb)
  		return 0;
  	bo = gem_to_bochs_bo(new_state->fb->obj[0]);
-	return bochs_bo_pin(bo, TTM_PL_FLAG_VRAM, NULL);
+	return bochs_bo_pin(bo, TTM_PL_FLAG_VRAM);
  }
 
  static void bochs_plane_cleanup_fb(struct drm_plane *plane,
drivers/gpu/drm/bochs/bochs_mm.c +1 -10
index 0980411e41..5a0e092847 100644
@@ -210,20 +210,13 @@ static void bochs_ttm_placement(struct bochs_bo *bo, int domain)
  	bo->placement.num_busy_placement = c;
  }
 
-static inline u64 bochs_bo_gpu_offset(struct bochs_bo *bo)
-{
-	return bo->bo.offset;
-}
-
-int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag, u64 *gpu_addr)
+int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag)
  {
  	struct ttm_operation_ctx ctx = { false, false };
  	int i, ret;
 
  	if (bo->pin_count) {
  		bo->pin_count++;
-		if (gpu_addr)
-			*gpu_addr = bochs_bo_gpu_offset(bo);
  		return 0;
  	}
 
@@ -235,8 +228,6 @@ int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag, u64 *gpu_addr)
  		return ret;
 
  	bo->pin_count = 1;
-	if (gpu_addr)
-		*gpu_addr = bochs_bo_gpu_offset(bo);
  	return 0;
  }
 
#27 lore raw

PATCH 10/14 drm/bochs: drop unused gpu_addr arg from bochs_bo_pin()

In reply to Gerd Hoffmann

It's always NULL, so just remove it.

---
 drivers/gpu/drm/bochs/bochs.h       |  2 +-
 drivers/gpu/drm/bochs/bochs_fbdev.c |  2 +-
 drivers/gpu/drm/bochs/bochs_kms.c   |  2 +-
 drivers/gpu/drm/bochs/bochs_mm.c    | 11 +----------
 4 files changed, 4 insertions(+), 13 deletions(-)
drivers/gpu/drm/bochs/bochs.h +1 -1
index 4dc1b6384e..d0d474e06f 100644
@@ -142,7 +142,7 @@ int bochs_dumb_create(struct drm_file *file, struct drm_device *dev,
 int bochs_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev,
 			   uint32_t handle, uint64_t *offset);
 
-int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag, u64 *gpu_addr);
+int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag);
 int bochs_bo_unpin(struct bochs_bo *bo);
 
 /* bochs_kms.c */
drivers/gpu/drm/bochs/bochs_fbdev.c +1 -1
index d9f3d42999..92feb817ff 100644
@@ -81,7 +81,7 @@ static int bochsfb_create(struct drm_fb_helper *helper,
 	if (ret)
 		return ret;
 
-	ret = bochs_bo_pin(bo, TTM_PL_FLAG_VRAM, NULL);
+	ret = bochs_bo_pin(bo, TTM_PL_FLAG_VRAM);
 	if (ret) {
 		DRM_ERROR("failed to pin fbcon\n");
 		ttm_bo_unreserve(&bo->bo);
drivers/gpu/drm/bochs/bochs_kms.c +1 -1
index 85dd268fa1..a1a0129f3e 100644
@@ -96,7 +96,7 @@ static int bochs_plane_prepare_fb(struct drm_plane *plane,
 	if (!new_state->fb)
 		return 0;
 	bo = gem_to_bochs_bo(new_state->fb->obj[0]);
-	return bochs_bo_pin(bo, TTM_PL_FLAG_VRAM, NULL);
+	return bochs_bo_pin(bo, TTM_PL_FLAG_VRAM);
 }
 
 static void bochs_plane_cleanup_fb(struct drm_plane *plane,
drivers/gpu/drm/bochs/bochs_mm.c +1 -10
index 0980411e41..5a0e092847 100644
@@ -210,20 +210,13 @@ static void bochs_ttm_placement(struct bochs_bo *bo, int domain)
 	bo->placement.num_busy_placement = c;
 }
 
-static inline u64 bochs_bo_gpu_offset(struct bochs_bo *bo)
-{
-	return bo->bo.offset;
-}
-
-int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag, u64 *gpu_addr)
+int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag)
 {
 	struct ttm_operation_ctx ctx = { false, false };
 	int i, ret;
 
 	if (bo->pin_count) {
 		bo->pin_count++;
-		if (gpu_addr)
-			*gpu_addr = bochs_bo_gpu_offset(bo);
 		return 0;
 	}
 
@@ -235,8 +228,6 @@ int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag, u64 *gpu_addr)
 		return ret;
 
 	bo->pin_count = 1;
-	if (gpu_addr)
-		*gpu_addr = bochs_bo_gpu_offset(bo);
 	return 0;
 }
 
Signature · 1 line
2.9.3
#28 lore raw

PATCH 11/14 drm/bochs: add basic prime support

In reply to Gerd Hoffmann

Generic framebuffer emulation needs this.

---
 drivers/gpu/drm/bochs/bochs.h     | 11 +++++++
 drivers/gpu/drm/bochs/bochs_drv.c | 15 +++++++++-
 drivers/gpu/drm/bochs/bochs_mm.c  | 63 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 88 insertions(+), 1 deletion(-)
drivers/gpu/drm/bochs/bochs.h +11 -0
index d0d474e06f..4236d5d811 100644
@@ -145,6 +145,17 @@ int bochs_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev,
 int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag);
 int bochs_bo_unpin(struct bochs_bo *bo);
 
+int bochs_gem_prime_pin(struct drm_gem_object *obj);
+void bochs_gem_prime_unpin(struct drm_gem_object *obj);
+struct sg_table *bochs_gem_prime_get_sg_table(struct drm_gem_object *obj);
+struct drm_gem_object *bochs_gem_prime_import_sg_table(
+        struct drm_device *dev, struct dma_buf_attachment *attach,
+        struct sg_table *sgt);
+void *bochs_gem_prime_vmap(struct drm_gem_object *obj);
+void bochs_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
+int bochs_gem_prime_mmap(struct drm_gem_object *obj,
+			 struct vm_area_struct *vma);
+
 /* bochs_kms.c */
 int bochs_kms_init(struct bochs_device *bochs);
 void bochs_kms_fini(struct bochs_device *bochs);
drivers/gpu/drm/bochs/bochs_drv.c +14 -1
index 278f9d2e7f..a9c7140e3b 100644
@@ -81,7 +81,8 @@ static const struct file_operations bochs_fops = {
 };
 
 static struct drm_driver bochs_driver = {
-	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
+	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC |
+				  DRIVER_PRIME,
 	.fops			= &bochs_fops,
 	.name			= "bochs-drm",
 	.desc			= "bochs dispi vga interface (qemu stdvga)",
@@ -91,6 +92,18 @@ static struct drm_driver bochs_driver = {
 	.gem_free_object_unlocked = bochs_gem_free_object,
 	.dumb_create            = bochs_dumb_create,
 	.dumb_map_offset        = bochs_dumb_mmap_offset,
+
+	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
+	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
+	.gem_prime_export = drm_gem_prime_export,
+	.gem_prime_import = drm_gem_prime_import,
+	.gem_prime_pin = bochs_gem_prime_pin,
+	.gem_prime_unpin = bochs_gem_prime_unpin,
+	.gem_prime_get_sg_table = bochs_gem_prime_get_sg_table,
+	.gem_prime_import_sg_table = bochs_gem_prime_import_sg_table,
+	.gem_prime_vmap = bochs_gem_prime_vmap,
+	.gem_prime_vunmap = bochs_gem_prime_vunmap,
+	.gem_prime_mmap = bochs_gem_prime_mmap,
 };
 
 /* ---------------------------------------------------------------------- */
drivers/gpu/drm/bochs/bochs_mm.c +63 -0

66 lines not on this page · raw message

Signature · 1 line
2.9.3
Reviewed-by on v1 11/14
#29 lore raw

Re: [PATCH 11/14] drm/bochs: add basic prime support

Quoted 14 lines · Gerd Hoffmann

Generic framebuffer emulation needs this.

---
  drivers/gpu/drm/bochs/bochs.h     | 11 +++++++
  drivers/gpu/drm/bochs/bochs_drv.c | 15 +++++++++-
  drivers/gpu/drm/bochs/bochs_mm.c  | 63 +++++++++++++++++++++++++++++++++++++++
  3 files changed, 88 insertions(+), 1 deletion(-)
drivers/gpu/drm/bochs/bochs.h +0 -0
index d0d474e06f..4236d5d811 100644

drivers/gpu/drm/bochs/bochs.h int bochs_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev, · line 153

Quoted 9 lines
drivers/gpu/drm/bochs/bochs.h +6 -0
@@ -145,6 +145,17 @@ int bochs_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev,
  int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag);
  int bochs_bo_unpin(struct bochs_bo *bo);
 
+int bochs_gem_prime_pin(struct drm_gem_object *obj);
+void bochs_gem_prime_unpin(struct drm_gem_object *obj);
+struct sg_table *bochs_gem_prime_get_sg_table(struct drm_gem_object *obj);
+struct drm_gem_object *bochs_gem_prime_import_sg_table(
+        struct drm_device *dev, struct dma_buf_attachment *attach,
+        struct sg_table *sgt);

Please change 8 spaces to a single tab

Quoted 102 lines
drivers/gpu/drm/bochs/bochs.h +5 -0
+void *bochs_gem_prime_vmap(struct drm_gem_object *obj);
+void bochs_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
+int bochs_gem_prime_mmap(struct drm_gem_object *obj,
+			 struct vm_area_struct *vma);
+
  /* bochs_kms.c */
  int bochs_kms_init(struct bochs_device *bochs);
  void bochs_kms_fini(struct bochs_device *bochs);
drivers/gpu/drm/bochs/bochs_drv.c +14 -1
index 278f9d2e7f..a9c7140e3b 100644
@@ -81,7 +81,8 @@ static const struct file_operations bochs_fops = {
  };
 
  static struct drm_driver bochs_driver = {
-	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
+	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC |
+				  DRIVER_PRIME,
  	.fops			= &bochs_fops,
  	.name			= "bochs-drm",
  	.desc			= "bochs dispi vga interface (qemu stdvga)",
@@ -91,6 +92,18 @@ static struct drm_driver bochs_driver = {
  	.gem_free_object_unlocked = bochs_gem_free_object,
  	.dumb_create            = bochs_dumb_create,
  	.dumb_map_offset        = bochs_dumb_mmap_offset,
+
+	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
+	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
+	.gem_prime_export = drm_gem_prime_export,
+	.gem_prime_import = drm_gem_prime_import,
+	.gem_prime_pin = bochs_gem_prime_pin,
+	.gem_prime_unpin = bochs_gem_prime_unpin,
+	.gem_prime_get_sg_table = bochs_gem_prime_get_sg_table,
+	.gem_prime_import_sg_table = bochs_gem_prime_import_sg_table,
+	.gem_prime_vmap = bochs_gem_prime_vmap,
+	.gem_prime_vunmap = bochs_gem_prime_vunmap,
+	.gem_prime_mmap = bochs_gem_prime_mmap,
  };
 
  /* ---------------------------------------------------------------------- */
drivers/gpu/drm/bochs/bochs_mm.c +53 -0
index 5a0e092847..cfe061c25f 100644
@@ -387,3 +387,66 @@ int bochs_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev,
  	drm_gem_object_put_unlocked(obj);
  	return 0;
  }
+
+/* ---------------------------------------------------------------------- */
+
+int bochs_gem_prime_pin(struct drm_gem_object *obj)
+{
+	struct bochs_bo *bo = gem_to_bochs_bo(obj);
+
+	return bochs_bo_pin(bo, TTM_PL_FLAG_VRAM);
+}
+
+void bochs_gem_prime_unpin(struct drm_gem_object *obj)
+{
+	struct bochs_bo *bo = gem_to_bochs_bo(obj);
+
+	bochs_bo_unpin(bo);
+}
+
+struct sg_table *bochs_gem_prime_get_sg_table(struct drm_gem_object *obj)
+{
+	WARN_ONCE(1, "not implemented");
+	return ERR_PTR(-ENODEV);
+}
+
+struct drm_gem_object *bochs_gem_prime_import_sg_table(
+	struct drm_device *dev, struct dma_buf_attachment *attach,
+	struct sg_table *table)
+{
+	WARN_ONCE(1, "not implemented");
+	return ERR_PTR(-ENODEV);
+}
+
+void *bochs_gem_prime_vmap(struct drm_gem_object *obj)
+{
+	struct bochs_bo *bo = gem_to_bochs_bo(obj);
+	bool is_iomem;
+	int ret;
+
+	ret = bochs_bo_pin(bo, TTM_PL_FLAG_VRAM);
+	if (ret)
+		return NULL;
+	ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages, &bo->kmap);
+	if (ret) {
+		bochs_bo_unpin(bo);
+		return NULL;
+	}
+	return ttm_kmap_obj_virtual(&bo->kmap, &is_iomem);
+}
+
+void bochs_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr)
+{
+	struct bochs_bo *bo = gem_to_bochs_bo(obj);
+
+	ttm_bo_kunmap(&bo->kmap);

drivers/gpu/drm/bochs/bochs_mm.c int bochs_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev, · line 452

Quoted 10 lines
drivers/gpu/drm/bochs/bochs_mm.c +10 -0
+	bochs_bo_unpin(bo);
+}
+
+int bochs_gem_prime_mmap(struct drm_gem_object *obj,
+			 struct vm_area_struct *vma)
+{
+	struct bochs_bo *bo = gem_to_bochs_bo(obj);
+
+	return ttm_fbdev_mmap(vma, &bo->bo);
+}

With the above fixed:

#30 lore raw

PATCH 11/14 drm/bochs: add basic prime support

In reply to Gerd Hoffmann

Generic framebuffer emulation needs this.

---
 drivers/gpu/drm/bochs/bochs.h     | 11 +++++++
 drivers/gpu/drm/bochs/bochs_drv.c | 15 +++++++++-
 drivers/gpu/drm/bochs/bochs_mm.c  | 63 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 88 insertions(+), 1 deletion(-)
drivers/gpu/drm/bochs/bochs.h +11 -0
index d0d474e06f..4236d5d811 100644
@@ -145,6 +145,17 @@ int bochs_dumb_mmap_offset(struct drm_file *file, struct drm_device *dev,
 int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag);
 int bochs_bo_unpin(struct bochs_bo *bo);
 
+int bochs_gem_prime_pin(struct drm_gem_object *obj);
+void bochs_gem_prime_unpin(struct drm_gem_object *obj);
+struct sg_table *bochs_gem_prime_get_sg_table(struct drm_gem_object *obj);
+struct drm_gem_object *bochs_gem_prime_import_sg_table(
+        struct drm_device *dev, struct dma_buf_attachment *attach,
+        struct sg_table *sgt);
+void *bochs_gem_prime_vmap(struct drm_gem_object *obj);
+void bochs_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr);
+int bochs_gem_prime_mmap(struct drm_gem_object *obj,
+			 struct vm_area_struct *vma);
+
 /* bochs_kms.c */
 int bochs_kms_init(struct bochs_device *bochs);
 void bochs_kms_fini(struct bochs_device *bochs);
drivers/gpu/drm/bochs/bochs_drv.c +14 -1
index 278f9d2e7f..a9c7140e3b 100644
@@ -81,7 +81,8 @@ static const struct file_operations bochs_fops = {
 };
 
 static struct drm_driver bochs_driver = {
-	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
+	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC |
+				  DRIVER_PRIME,
 	.fops			= &bochs_fops,
 	.name			= "bochs-drm",
 	.desc			= "bochs dispi vga interface (qemu stdvga)",
@@ -91,6 +92,18 @@ static struct drm_driver bochs_driver = {
 	.gem_free_object_unlocked = bochs_gem_free_object,
 	.dumb_create            = bochs_dumb_create,
 	.dumb_map_offset        = bochs_dumb_mmap_offset,
+
+	.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
+	.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
+	.gem_prime_export = drm_gem_prime_export,
+	.gem_prime_import = drm_gem_prime_import,
+	.gem_prime_pin = bochs_gem_prime_pin,
+	.gem_prime_unpin = bochs_gem_prime_unpin,
+	.gem_prime_get_sg_table = bochs_gem_prime_get_sg_table,
+	.gem_prime_import_sg_table = bochs_gem_prime_import_sg_table,
+	.gem_prime_vmap = bochs_gem_prime_vmap,
+	.gem_prime_vunmap = bochs_gem_prime_vunmap,
+	.gem_prime_mmap = bochs_gem_prime_mmap,
 };
 
 /* ---------------------------------------------------------------------- */
drivers/gpu/drm/bochs/bochs_mm.c +63 -0

66 lines not on this page · raw message

Signature · 1 line
2.9.3
#31 lore raw

PATCH 12/14 drm/bochs: switch to generic drm fbdev emulation

In reply to Gerd Hoffmann
---
 drivers/gpu/drm/bochs/bochs_drv.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/bochs/bochs_drv.c +1 -4
index a9c7140e3b..f1f65324bb 100644
@@ -27,7 +27,6 @@ static void bochs_unload(struct drm_device *dev)
 {
 	struct bochs_device *bochs = dev->dev_private;
 
-	bochs_fbdev_fini(bochs);
 	bochs_kms_fini(bochs);
 	bochs_mm_fini(bochs);
 	bochs_hw_fini(dev);
@@ -58,9 +57,6 @@ static int bochs_load(struct drm_device *dev)
 	if (ret)
 		goto err;
 
-	if (enable_fbdev)
-		bochs_fbdev_init(bochs);
-
 	return 0;
 
 err:
@@ -178,6 +174,7 @@ static int bochs_pci_probe(struct pci_dev *pdev,
 	if (ret)
 		goto err_unload;
 
+	drm_fbdev_generic_setup(dev, 32);
 	return ret;
 
 err_unload:
Signature · 1 line
2.9.3
#32 lore raw

Re: [PATCH 12/14] drm/bochs: switch to generic drm fbdev emulation

Quoted 18 lines · Gerd Hoffmann
---
  drivers/gpu/drm/bochs/bochs_drv.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpu/drm/bochs/bochs_drv.c +0 -1
index a9c7140e3b..f1f65324bb 100644
@@ -27,7 +27,6 @@ static void bochs_unload(struct drm_device *dev)
  {
  	struct bochs_device *bochs = dev->dev_private;
 
-	bochs_fbdev_fini(bochs);
  	bochs_kms_fini(bochs);
  	bochs_mm_fini(bochs);
  	bochs_hw_fini(dev);

drivers/gpu/drm/bochs/bochs_drv.c static int bochs_load(struct drm_device *dev) · line 63

Quoted 6 lines
drivers/gpu/drm/bochs/bochs_drv.c +0 -3
@@ -58,9 +57,6 @@ static int bochs_load(struct drm_device *dev)
  	if (ret)
  		goto err;
 
-	if (enable_fbdev)
-		bochs_fbdev_init(bochs);
-

I think that after this change you don't need "module_param_named(fbdev, enable_fbdev, bool, 0444);"

Quoted 11 lines
drivers/gpu/drm/bochs/bochs_drv.c +1 -0
  	return 0;
 
  err:
@@ -178,6 +174,7 @@ static int bochs_pci_probe(struct pci_dev *pdev,
  	if (ret)
  		goto err_unload;
 
+	drm_fbdev_generic_setup(dev, 32);
  	return ret;
 
  err_unload:
#33 lore raw

PATCH 13/14 drm/bochs: drop old fbdev emulation code

In reply to Gerd Hoffmann

Not needed any more, bochs uses the generic emulation now.

---
 drivers/gpu/drm/bochs/bochs.h       |   9 ---
 drivers/gpu/drm/bochs/bochs_drv.c   |   6 --
 drivers/gpu/drm/bochs/bochs_fbdev.c | 137 ------------------------------------
 3 files changed, 152 deletions(-)
drivers/gpu/drm/bochs/bochs.h +0 -9
index 4236d5d811..42a587e71e 100644
@@ -80,12 +80,6 @@ struct bochs_device {
 		struct ttm_bo_device bdev;
 		bool initialized;
 	} ttm;
-
-	/* fbdev */
-	struct {
-		struct drm_framebuffer *fb;
-		struct drm_fb_helper helper;
-	} fb;
 };
 
 struct bochs_bo {
@@ -161,7 +155,4 @@ int bochs_kms_init(struct bochs_device *bochs);
 void bochs_kms_fini(struct bochs_device *bochs);
 
 /* bochs_fbdev.c */
-int bochs_fbdev_init(struct bochs_device *bochs);
-void bochs_fbdev_fini(struct bochs_device *bochs);
-
 extern const struct drm_mode_config_funcs bochs_mode_funcs;
drivers/gpu/drm/bochs/bochs_drv.c +0 -6
index f1f65324bb..ad1290ca7b 100644
@@ -110,12 +110,9 @@ static int bochs_pm_suspend(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
-	struct bochs_device *bochs = drm_dev->dev_private;
 
 	drm_kms_helper_poll_disable(drm_dev);
 
-	drm_fb_helper_set_suspend_unlocked(&bochs->fb.helper, 1);
-
 	return 0;
 }
 
@@ -123,12 +120,9 @@ static int bochs_pm_resume(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
-	struct bochs_device *bochs = drm_dev->dev_private;
 
 	drm_helper_resume_force_mode(drm_dev);
 
-	drm_fb_helper_set_suspend_unlocked(&bochs->fb.helper, 0);
-
 	drm_kms_helper_poll_enable(drm_dev);
 	return 0;
 }
drivers/gpu/drm/bochs/bochs_fbdev.c +0 -137

146 lines not on this page · raw message

Signature · 1 line
2.9.3
Reviewed-by on v1 13/14
#34 lore raw

Re: [PATCH 13/14] drm/bochs: drop old fbdev emulation code

Quoted 3 lines · Gerd Hoffmann

Not needed any more, bochs uses the generic emulation now.

Quoted 203 lines
---
  drivers/gpu/drm/bochs/bochs.h       |   9 ---
  drivers/gpu/drm/bochs/bochs_drv.c   |   6 --
  drivers/gpu/drm/bochs/bochs_fbdev.c | 137 ------------------------------------
  3 files changed, 152 deletions(-)
drivers/gpu/drm/bochs/bochs.h +0 -9
index 4236d5d811..42a587e71e 100644
@@ -80,12 +80,6 @@ struct bochs_device {
  		struct ttm_bo_device bdev;
  		bool initialized;
  	} ttm;
-
-	/* fbdev */
-	struct {
-		struct drm_framebuffer *fb;
-		struct drm_fb_helper helper;
-	} fb;
  };
 
  struct bochs_bo {
@@ -161,7 +155,4 @@ int bochs_kms_init(struct bochs_device *bochs);
  void bochs_kms_fini(struct bochs_device *bochs);
 
  /* bochs_fbdev.c */
-int bochs_fbdev_init(struct bochs_device *bochs);
-void bochs_fbdev_fini(struct bochs_device *bochs);
-
  extern const struct drm_mode_config_funcs bochs_mode_funcs;
drivers/gpu/drm/bochs/bochs_drv.c +0 -6
index f1f65324bb..ad1290ca7b 100644
@@ -110,12 +110,9 @@ static int bochs_pm_suspend(struct device *dev)
  {
  	struct pci_dev *pdev = to_pci_dev(dev);
  	struct drm_device *drm_dev = pci_get_drvdata(pdev);
-	struct bochs_device *bochs = drm_dev->dev_private;
 
  	drm_kms_helper_poll_disable(drm_dev);
 
-	drm_fb_helper_set_suspend_unlocked(&bochs->fb.helper, 1);
-
  	return 0;
  }
 
@@ -123,12 +120,9 @@ static int bochs_pm_resume(struct device *dev)
  {
  	struct pci_dev *pdev = to_pci_dev(dev);
  	struct drm_device *drm_dev = pci_get_drvdata(pdev);
-	struct bochs_device *bochs = drm_dev->dev_private;
 
  	drm_helper_resume_force_mode(drm_dev);
 
-	drm_fb_helper_set_suspend_unlocked(&bochs->fb.helper, 0);
-
  	drm_kms_helper_poll_enable(drm_dev);
  	return 0;
  }
drivers/gpu/drm/bochs/bochs_fbdev.c +0 -127
index 92feb817ff..7cac3f5253 100644
@@ -11,132 +11,6 @@
 
  /* ---------------------------------------------------------------------- */
 
-static int bochsfb_mmap(struct fb_info *info,
-			struct vm_area_struct *vma)
-{
-	struct drm_fb_helper *fb_helper = info->par;
-	struct bochs_bo *bo = gem_to_bochs_bo(fb_helper->fb->obj[0]);
-
-	return ttm_fbdev_mmap(vma, &bo->bo);
-}
-
-static struct fb_ops bochsfb_ops = {
-	.owner = THIS_MODULE,
-	DRM_FB_HELPER_DEFAULT_OPS,
-	.fb_fillrect = drm_fb_helper_cfb_fillrect,
-	.fb_copyarea = drm_fb_helper_cfb_copyarea,
-	.fb_imageblit = drm_fb_helper_cfb_imageblit,
-	.fb_mmap = bochsfb_mmap,
-};
-
-static int bochsfb_create_object(struct bochs_device *bochs,
-				 const struct drm_mode_fb_cmd2 *mode_cmd,
-				 struct drm_gem_object **gobj_p)
-{
-	struct drm_device *dev = bochs->dev;
-	struct drm_gem_object *gobj;
-	u32 size;
-	int ret = 0;
-
-	size = mode_cmd->pitches[0] * mode_cmd->height;
-	ret = bochs_gem_create(dev, size, true, &gobj);
-	if (ret)
-		return ret;
-
-	*gobj_p = gobj;
-	return ret;
-}
-
-static int bochsfb_create(struct drm_fb_helper *helper,
-			  struct drm_fb_helper_surface_size *sizes)
-{
-	struct bochs_device *bochs =
-		container_of(helper, struct bochs_device, fb.helper);
-	struct fb_info *info;
-	struct drm_framebuffer *fb;
-	struct drm_mode_fb_cmd2 mode_cmd;
-	struct drm_gem_object *gobj = NULL;
-	struct bochs_bo *bo = NULL;
-	int size, ret;
-
-	if (sizes->surface_bpp != 32)
-		return -EINVAL;
-
-	mode_cmd.width = sizes->surface_width;
-	mode_cmd.height = sizes->surface_height;
-	mode_cmd.pitches[0] = sizes->surface_width * 4;
-	mode_cmd.pixel_format = DRM_FORMAT_HOST_XRGB8888;
-	size = mode_cmd.pitches[0] * mode_cmd.height;
-
-	/* alloc, pin & map bo */
-	ret = bochsfb_create_object(bochs, &mode_cmd, &gobj);
-	if (ret) {
-		DRM_ERROR("failed to create fbcon backing object %d\n", ret);
-		return ret;
-	}
-
-	bo = gem_to_bochs_bo(gobj);
-
-	ret = ttm_bo_reserve(&bo->bo, true, false, NULL);
-	if (ret)
-		return ret;
-
-	ret = bochs_bo_pin(bo, TTM_PL_FLAG_VRAM);
-	if (ret) {
-		DRM_ERROR("failed to pin fbcon\n");
-		ttm_bo_unreserve(&bo->bo);
-		return ret;
-	}
-
-	ret = ttm_bo_kmap(&bo->bo, 0, bo->bo.num_pages,
-			  &bo->kmap);
-	if (ret) {
-		DRM_ERROR("failed to kmap fbcon\n");
-		ttm_bo_unreserve(&bo->bo);
-		return ret;
-	}
-
-	ttm_bo_unreserve(&bo->bo);
-
-	/* init fb device */
-	info = drm_fb_helper_alloc_fbi(helper);
-	if (IS_ERR(info)) {
-		DRM_ERROR("Failed to allocate fbi: %ld\n", PTR_ERR(info));
-		return PTR_ERR(info);
-	}
-
-	info->par = &bochs->fb.helper;
-
-	fb = drm_gem_fbdev_fb_create(bochs->dev, sizes, 0, gobj, NULL);
-	if (IS_ERR(fb)) {
-		DRM_ERROR("Failed to create framebuffer: %ld\n", PTR_ERR(fb));
-		return PTR_ERR(fb);
-	}
-
-	/* setup helper */
-	bochs->fb.helper.fb = fb;
-
-	strcpy(info->fix.id, "bochsdrmfb");
-
-	info->fbops = &bochsfb_ops;
-
-	drm_fb_helper_fill_fix(info, fb->pitches[0], fb->format->depth);
-	drm_fb_helper_fill_var(info, &bochs->fb.helper, sizes->fb_width,
-			       sizes->fb_height);
-
-	info->screen_base = bo->kmap.virtual;
-	info->screen_size = size;
-
-	drm_vma_offset_remove(&bo->bo.bdev->vma_manager, &bo->bo.vma_node);
-	info->fix.smem_start = 0;
-	info->fix.smem_len = size;
-	return 0;
-}
-
-static const struct drm_fb_helper_funcs bochs_fb_helper_funcs = {
-	.fb_probe = bochsfb_create,
-};
-
  static struct drm_framebuffer *
  bochs_gem_fb_create(struct drm_device *dev, struct drm_file *file,
  		    const struct drm_mode_fb_cmd2 *mode_cmd)
@@ -153,14 +27,3 @@ const struct drm_mode_config_funcs bochs_mode_funcs = {
  	.atomic_check = drm_atomic_helper_check,
  	.atomic_commit = drm_atomic_helper_commit,
  };
-

drivers/gpu/drm/bochs/bochs_fbdev.c const struct drm_mode_config_funcs bochs_mode_funcs = { · line 166

Quoted 10 lines
drivers/gpu/drm/bochs/bochs_fbdev.c +0 -10
-int bochs_fbdev_init(struct bochs_device *bochs)
-{
-	return drm_fb_helper_fbdev_setup(bochs->dev, &bochs->fb.helper,
-					 &bochs_fb_helper_funcs, 32, 1);
-}
-
-void bochs_fbdev_fini(struct bochs_device *bochs)
-{
-	drm_fb_helper_fbdev_teardown(bochs->dev);
-}

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

#35 lore raw

PATCH 13/14 drm/bochs: drop old fbdev emulation code

In reply to Gerd Hoffmann

Not needed any more, bochs uses the generic emulation now.

---
 drivers/gpu/drm/bochs/bochs.h       |   9 ---
 drivers/gpu/drm/bochs/bochs_drv.c   |   6 --
 drivers/gpu/drm/bochs/bochs_fbdev.c | 137 ------------------------------------
 3 files changed, 152 deletions(-)
drivers/gpu/drm/bochs/bochs.h +0 -9
index 4236d5d811..42a587e71e 100644
@@ -80,12 +80,6 @@ struct bochs_device {
 		struct ttm_bo_device bdev;
 		bool initialized;
 	} ttm;
-
-	/* fbdev */
-	struct {
-		struct drm_framebuffer *fb;
-		struct drm_fb_helper helper;
-	} fb;
 };
 
 struct bochs_bo {
@@ -161,7 +155,4 @@ int bochs_kms_init(struct bochs_device *bochs);
 void bochs_kms_fini(struct bochs_device *bochs);
 
 /* bochs_fbdev.c */
-int bochs_fbdev_init(struct bochs_device *bochs);
-void bochs_fbdev_fini(struct bochs_device *bochs);
-
 extern const struct drm_mode_config_funcs bochs_mode_funcs;
drivers/gpu/drm/bochs/bochs_drv.c +0 -6
index f1f65324bb..ad1290ca7b 100644
@@ -110,12 +110,9 @@ static int bochs_pm_suspend(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
-	struct bochs_device *bochs = drm_dev->dev_private;
 
 	drm_kms_helper_poll_disable(drm_dev);
 
-	drm_fb_helper_set_suspend_unlocked(&bochs->fb.helper, 1);
-
 	return 0;
 }
 
@@ -123,12 +120,9 @@ static int bochs_pm_resume(struct device *dev)
 {
 	struct pci_dev *pdev = to_pci_dev(dev);
 	struct drm_device *drm_dev = pci_get_drvdata(pdev);
-	struct bochs_device *bochs = drm_dev->dev_private;
 
 	drm_helper_resume_force_mode(drm_dev);
 
-	drm_fb_helper_set_suspend_unlocked(&bochs->fb.helper, 0);
-
 	drm_kms_helper_poll_enable(drm_dev);
 	return 0;
 }
drivers/gpu/drm/bochs/bochs_fbdev.c +0 -137

146 lines not on this page · raw message

Signature · 1 line
2.9.3
#36 lore raw

PATCH 14/14 drm/bochs: move remaining fb bits to kms

In reply to Gerd Hoffmann

bochs_fbdev.c is almost empty now. Move the remaining framebuffer bits over to bochs_kms.c. Pure code motion. No functional change.

---
 drivers/gpu/drm/bochs/bochs_fbdev.c | 29 -----------------------------
 drivers/gpu/drm/bochs/bochs_kms.c   | 17 +++++++++++++++++
 drivers/gpu/drm/bochs/Makefile      |  2 +-
 3 files changed, 18 insertions(+), 30 deletions(-)
 delete mode 100644 drivers/gpu/drm/bochs/bochs_fbdev.c
drivers/gpu/drm/bochs/bochs_fbdev.c deleted +0 -29
deleted file mode 100644
index 7cac3f5253..0000000000
@@ -1,29 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#include "bochs.h"
-#include <drm/drm_atomic_helper.h>
-#include <drm/drm_gem_framebuffer_helper.h>
-
-/* ---------------------------------------------------------------------- */
-
-static struct drm_framebuffer *
-bochs_gem_fb_create(struct drm_device *dev, struct drm_file *file,
-		    const struct drm_mode_fb_cmd2 *mode_cmd)
-{
-	if (mode_cmd->pixel_format != DRM_FORMAT_XRGB8888 &&
-	    mode_cmd->pixel_format != DRM_FORMAT_BGRX8888)
-		return ERR_PTR(-EINVAL);
-
-	return drm_gem_fb_create(dev, file, mode_cmd);
-}
-
-const struct drm_mode_config_funcs bochs_mode_funcs = {
-	.fb_create = bochs_gem_fb_create,
-	.atomic_check = drm_atomic_helper_check,
-	.atomic_commit = drm_atomic_helper_commit,
-};
drivers/gpu/drm/bochs/bochs_kms.c +17 -0
index a1a0129f3e..3688d0b616 100644
@@ -9,6 +9,7 @@
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_plane_helper.h>
 #include <drm/drm_atomic_uapi.h>
+#include <drm/drm_gem_framebuffer_helper.h>
 
 static int defx = 1024;
 static int defy = 768;
@@ -256,6 +257,22 @@ static void bochs_connector_init(struct drm_device *dev)
 	}
 }
 
+static struct drm_framebuffer *
+bochs_gem_fb_create(struct drm_device *dev, struct drm_file *file,
+		    const struct drm_mode_fb_cmd2 *mode_cmd)
+{
+	if (mode_cmd->pixel_format != DRM_FORMAT_XRGB8888 &&
+	    mode_cmd->pixel_format != DRM_FORMAT_BGRX8888)
+		return ERR_PTR(-EINVAL);
+
+	return drm_gem_fb_create(dev, file, mode_cmd);
+}
+
+const struct drm_mode_config_funcs bochs_mode_funcs = {
+	.fb_create = bochs_gem_fb_create,
+	.atomic_check = drm_atomic_helper_check,
+	.atomic_commit = drm_atomic_helper_commit,
+};
 
 int bochs_kms_init(struct bochs_device *bochs)
 {
drivers/gpu/drm/bochs/Makefile +1 -1
index 98ef60a19e..e9e0f8f5eb 100644
@@ -1,3 +1,3 @@
-bochs-drm-y := bochs_drv.o bochs_mm.o bochs_kms.o bochs_fbdev.o bochs_hw.o
+bochs-drm-y := bochs_drv.o bochs_mm.o bochs_kms.o bochs_hw.o
 
 obj-$(CONFIG_DRM_BOCHS)	+= bochs-drm.o
Signature · 1 line
2.9.3
Reviewed-by on v1 14/14
#37 lore raw

Re: [PATCH 14/14] drm/bochs: move remaining fb bits to kms

Quoted 4 lines · Gerd Hoffmann

bochs_fbdev.c is almost empty now. Move the remaining framebuffer bits over to bochs_kms.c. Pure code motion. No functional change.

Quoted 86 lines
---
  drivers/gpu/drm/bochs/bochs_fbdev.c | 29 -----------------------------
  drivers/gpu/drm/bochs/bochs_kms.c   | 17 +++++++++++++++++
  drivers/gpu/drm/bochs/Makefile      |  2 +-
  3 files changed, 18 insertions(+), 30 deletions(-)

delete mode 100644 drivers/gpu/drm/bochs/bochs_fbdev.c

drivers/gpu/drm/bochs/bochs_fbdev.c deleted +0 -29
deleted file mode 100644
index 7cac3f5253..0000000000
@@ -1,29 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#include "bochs.h"
-#include <drm/drm_atomic_helper.h>
-#include <drm/drm_gem_framebuffer_helper.h>
-
-/* ---------------------------------------------------------------------- */
-
-static struct drm_framebuffer *
-bochs_gem_fb_create(struct drm_device *dev, struct drm_file *file,
-		    const struct drm_mode_fb_cmd2 *mode_cmd)
-{
-	if (mode_cmd->pixel_format != DRM_FORMAT_XRGB8888 &&
-	    mode_cmd->pixel_format != DRM_FORMAT_BGRX8888)
-		return ERR_PTR(-EINVAL);
-
-	return drm_gem_fb_create(dev, file, mode_cmd);
-}
-
-const struct drm_mode_config_funcs bochs_mode_funcs = {
-	.fb_create = bochs_gem_fb_create,
-	.atomic_check = drm_atomic_helper_check,
-	.atomic_commit = drm_atomic_helper_commit,
-};
drivers/gpu/drm/bochs/bochs_kms.c +17 -0
index a1a0129f3e..3688d0b616 100644
@@ -9,6 +9,7 @@
  #include <drm/drm_atomic_helper.h>
  #include <drm/drm_plane_helper.h>
  #include <drm/drm_atomic_uapi.h>
+#include <drm/drm_gem_framebuffer_helper.h>
 
  static int defx = 1024;
  static int defy = 768;
@@ -256,6 +257,22 @@ static void bochs_connector_init(struct drm_device *dev)
  	}
  }
 
+static struct drm_framebuffer *
+bochs_gem_fb_create(struct drm_device *dev, struct drm_file *file,
+		    const struct drm_mode_fb_cmd2 *mode_cmd)
+{
+	if (mode_cmd->pixel_format != DRM_FORMAT_XRGB8888 &&
+	    mode_cmd->pixel_format != DRM_FORMAT_BGRX8888)
+		return ERR_PTR(-EINVAL);
+
+	return drm_gem_fb_create(dev, file, mode_cmd);
+}
+
+const struct drm_mode_config_funcs bochs_mode_funcs = {
+	.fb_create = bochs_gem_fb_create,
+	.atomic_check = drm_atomic_helper_check,
+	.atomic_commit = drm_atomic_helper_commit,
+};
 
  int bochs_kms_init(struct bochs_device *bochs)
  {
drivers/gpu/drm/bochs/Makefile +1 -1
index 98ef60a19e..e9e0f8f5eb 100644
@@ -1,3 +1,3 @@
-bochs-drm-y := bochs_drv.o bochs_mm.o bochs_kms.o bochs_fbdev.o bochs_hw.o
+bochs-drm-y := bochs_drv.o bochs_mm.o bochs_kms.o bochs_hw.o
 
  obj-$(CONFIG_DRM_BOCHS)	+= bochs-drm.o
#38 lore raw

PATCH 14/14 drm/bochs: move remaining fb bits to kms

In reply to Gerd Hoffmann

bochs_fbdev.c is almost empty now. Move the remaining framebuffer bits over to bochs_kms.c. Pure code motion. No functional change.

---
 drivers/gpu/drm/bochs/bochs_fbdev.c | 29 -----------------------------
 drivers/gpu/drm/bochs/bochs_kms.c   | 17 +++++++++++++++++
 drivers/gpu/drm/bochs/Makefile      |  2 +-
 3 files changed, 18 insertions(+), 30 deletions(-)
 delete mode 100644 drivers/gpu/drm/bochs/bochs_fbdev.c
drivers/gpu/drm/bochs/bochs_fbdev.c deleted +0 -29
deleted file mode 100644
index 7cac3f5253..0000000000
@@ -1,29 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#include "bochs.h"
-#include <drm/drm_atomic_helper.h>
-#include <drm/drm_gem_framebuffer_helper.h>
-
-/* ---------------------------------------------------------------------- */
-
-static struct drm_framebuffer *
-bochs_gem_fb_create(struct drm_device *dev, struct drm_file *file,
-		    const struct drm_mode_fb_cmd2 *mode_cmd)
-{
-	if (mode_cmd->pixel_format != DRM_FORMAT_XRGB8888 &&
-	    mode_cmd->pixel_format != DRM_FORMAT_BGRX8888)
-		return ERR_PTR(-EINVAL);
-
-	return drm_gem_fb_create(dev, file, mode_cmd);
-}
-
-const struct drm_mode_config_funcs bochs_mode_funcs = {
-	.fb_create = bochs_gem_fb_create,
-	.atomic_check = drm_atomic_helper_check,
-	.atomic_commit = drm_atomic_helper_commit,
-};
drivers/gpu/drm/bochs/bochs_kms.c +17 -0
index a1a0129f3e..3688d0b616 100644
@@ -9,6 +9,7 @@
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_plane_helper.h>
 #include <drm/drm_atomic_uapi.h>
+#include <drm/drm_gem_framebuffer_helper.h>
 
 static int defx = 1024;
 static int defy = 768;
@@ -256,6 +257,22 @@ static void bochs_connector_init(struct drm_device *dev)
 	}
 }
 
+static struct drm_framebuffer *
+bochs_gem_fb_create(struct drm_device *dev, struct drm_file *file,
+		    const struct drm_mode_fb_cmd2 *mode_cmd)
+{
+	if (mode_cmd->pixel_format != DRM_FORMAT_XRGB8888 &&
+	    mode_cmd->pixel_format != DRM_FORMAT_BGRX8888)
+		return ERR_PTR(-EINVAL);
+
+	return drm_gem_fb_create(dev, file, mode_cmd);
+}
+
+const struct drm_mode_config_funcs bochs_mode_funcs = {
+	.fb_create = bochs_gem_fb_create,
+	.atomic_check = drm_atomic_helper_check,
+	.atomic_commit = drm_atomic_helper_commit,
+};
 
 int bochs_kms_init(struct bochs_device *bochs)
 {
drivers/gpu/drm/bochs/Makefile +1 -1
index 98ef60a19e..e9e0f8f5eb 100644
@@ -1,3 +1,3 @@
-bochs-drm-y := bochs_drv.o bochs_mm.o bochs_kms.o bochs_fbdev.o bochs_hw.o
+bochs-drm-y := bochs_drv.o bochs_mm.o bochs_kms.o bochs_hw.o
 
 obj-$(CONFIG_DRM_BOCHS)	+= bochs-drm.o
Signature · 1 line
2.9.3