Skip to contentSkip to conversation

virtio: fix virtio_gpu_mode_dumb_create

PATCH In review Gerd Hoffmann 4 participants 14 messages Apr 3, 2017

Subsystems (4)
lore
Share & tools
lore
author maintainer
#1 lore raw

PATCH 1/2 drm: virtio: add virtio_gpu_translate_format

In reply to Gerd Hoffmann

Factors out code, no functional change.

---
 drivers/gpu/drm/virtio/virtgpu_drv.h   |  1 +
 drivers/gpu/drm/virtio/virtgpu_fb.c    | 58 +----------------------------
 drivers/gpu/drm/virtio/virtgpu_plane.c | 68 ++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+), 56 deletions(-)
drivers/gpu/drm/virtio/virtgpu_drv.h +1 -0
index 93900a8..1328185 100644
@@ -334,6 +334,7 @@ int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev);
 void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev);
 
 /* virtio_gpu_plane.c */
+uint32_t virtio_gpu_translate_format(uint32_t drm_fourcc);
 struct drm_plane *virtio_gpu_plane_init(struct virtio_gpu_device *vgdev,
 					enum drm_plane_type type,
 					int index);
drivers/gpu/drm/virtio/virtgpu_fb.c +2 -56

65 lines not on this page · raw message

drivers/gpu/drm/virtio/virtgpu_plane.c +68 -0

74 lines not on this page · raw message

Signature · 1 line
2.9.3
author maintainer
#6 lore raw

PATCH 2/2 drm: virtio: fix virtio_gpu_mode_dumb_create

In reply to Gerd Hoffmann

Lookup format using virtio_gpu_translate_format()
instead of hardcoding it. Fixes xorg display on
bigendian guests (i.e. ppc64).

---
 drivers/gpu/drm/virtio/virtgpu_gem.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/virtio/virtgpu_gem.c +4 -2
index 336a57f..cc025d8 100644
@@ -88,6 +88,7 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,
 	int ret;
 	uint32_t pitch;
 	uint32_t resid;
+	uint32_t format;
 
 	pitch = args->width * ((args->bpp + 1) / 8);
 	args->size = pitch * args->height;
@@ -98,9 +99,10 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,
 	if (ret)
 		goto fail;
 
+	format = virtio_gpu_translate_format(DRM_FORMAT_XRGB8888);
 	virtio_gpu_resource_id_get(vgdev, &resid);
-	virtio_gpu_cmd_create_resource(vgdev, resid,
-				       2, args->width, args->height);
+	virtio_gpu_cmd_create_resource(vgdev, resid, format,
+				       args->width, args->height);
 
 	/* attach the object to the resource */
 	obj = gem_to_virtio_gpu_obj(gobj);
Signature · 1 line
2.9.3

Gerd Hoffmann

author maintainer
#0 lore raw

cover virtio: fix virtio_gpu_mode_dumb_create

Hi,

Little series to fix xorg display on virtio on bigendian machines. First patch factors out the drm -> virtio format mapping code into a helper function, second patch actually fixes the issue using the new helper.

cheers,
Gerd

Gerd Hoffmann (2):
drm: virtio: add virtio_gpu_translate_format
drm: virtio: fix virtio_gpu_mode_dumb_create

 drivers/gpu/drm/virtio/virtgpu_drv.h   |  1 +
 drivers/gpu/drm/virtio/virtgpu_fb.c    | 58 +----------------------------
 drivers/gpu/drm/virtio/virtgpu_gem.c   |  6 ++-
 drivers/gpu/drm/virtio/virtgpu_plane.c | 68 ++++++++++++++++++++++++++++++++++
 4 files changed, 75 insertions(+), 58 deletions(-)
Signature · 6 lines
2.9.3

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

PATCH 2/2 drm: virtio: fix virtio_gpu_mode_dumb_create

Lookup format using virtio_gpu_translate_format()
instead of hardcoding it. Fixes xorg display on
bigendian guests (i.e. ppc64).

---
 drivers/gpu/drm/virtio/virtgpu_gem.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/virtio/virtgpu_gem.c +4 -2
index 336a57f..cc025d8 100644
@@ -88,6 +88,7 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,
 	int ret;
 	uint32_t pitch;
 	uint32_t resid;
+	uint32_t format;
 
 	pitch = args->width * ((args->bpp + 1) / 8);
 	args->size = pitch * args->height;
@@ -98,9 +99,10 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,
 	if (ret)
 		goto fail;
 
+	format = virtio_gpu_translate_format(DRM_FORMAT_XRGB8888);
 	virtio_gpu_resource_id_get(vgdev, &resid);
-	virtio_gpu_cmd_create_resource(vgdev, resid,
-				       2, args->width, args->height);
+	virtio_gpu_cmd_create_resource(vgdev, resid, format,
+				       args->width, args->height);
 
 	/* attach the object to the resource */
 	obj = gem_to_virtio_gpu_obj(gobj);
Signature · 6 lines
2.9.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
maintainer Reviewed-by on v1 2/2
#8 lore raw

Re: [PATCH 2/2] drm: virtio: fix virtio_gpu_mode_dumb_create

Quoted 5 lines · Gerd Hoffmann

Lookup format using virtio_gpu_translate_format()
instead of hardcoding it. Fixes xorg display on
bigendian guests (i.e. ppc64).

For the series,

Quoted 36 lines
---
 drivers/gpu/drm/virtio/virtgpu_gem.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/virtio/virtgpu_gem.c +4 -3
index 336a57f..cc025d8 100644
@@ -88,6 +88,7 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,
        int ret;
        uint32_t pitch;
        uint32_t resid;
+       uint32_t format;
 
        pitch = args->width * ((args->bpp + 1) / 8);
        args->size = pitch * args->height;
@@ -98,9 +99,10 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,
        if (ret)
                goto fail;
 
+       format = virtio_gpu_translate_format(DRM_FORMAT_XRGB8888);
        virtio_gpu_resource_id_get(vgdev, &resid);
-       virtio_gpu_cmd_create_resource(vgdev, resid,
-                                      2, args->width, args->height);
+       virtio_gpu_cmd_create_resource(vgdev, resid, format,
+                                      args->width, args->height);
 
        /* attach the object to the resource */
        obj = gem_to_virtio_gpu_obj(gobj);
--

2.9.3

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

Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] drm: virtio: add virtio_gpu_translate_format

In reply to Gerd Hoffmann
Quoted 3 lines · Gerd Hoffmann

Factors out code, no functional change.

Ugh on the big endian define, I guess we'll never managed to figure this aspect of drm pixel formats out correctly - they're supposed to encode endinaness.

But the copy-paste looks correct :-)

Quoted 174 lines
---
 drivers/gpu/drm/virtio/virtgpu_drv.h   |  1 +
 drivers/gpu/drm/virtio/virtgpu_fb.c    | 58 +----------------------------
 drivers/gpu/drm/virtio/virtgpu_plane.c | 68 ++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+), 56 deletions(-)
drivers/gpu/drm/virtio/virtgpu_drv.h +1 -0
index 93900a8..1328185 100644
@@ -334,6 +334,7 @@ int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev);
 void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev);
 
 /* virtio_gpu_plane.c */
+uint32_t virtio_gpu_translate_format(uint32_t drm_fourcc);
 struct drm_plane *virtio_gpu_plane_init(struct virtio_gpu_device *vgdev,
 					enum drm_plane_type type,
 					int index);
drivers/gpu/drm/virtio/virtgpu_fb.c +2 -56
index 9bfaef3..33df067 100644
@@ -231,63 +231,9 @@ static int virtio_gpufb_create(struct drm_fb_helper *helper,
 	mode_cmd.pitches[0] = mode_cmd.width * 4;
 	mode_cmd.pixel_format = drm_mode_legacy_fb_format(32, 24);
 
-	switch (mode_cmd.pixel_format) {
-#ifdef __BIG_ENDIAN
-	case DRM_FORMAT_XRGB8888:
-		format = VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM;
-		break;
-	case DRM_FORMAT_ARGB8888:
-		format = VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM;
-		break;
-	case DRM_FORMAT_BGRX8888:
-		format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
-		break;
-	case DRM_FORMAT_BGRA8888:
-		format = VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM;
-		break;
-	case DRM_FORMAT_RGBX8888:
-		format = VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM;
-		break;
-	case DRM_FORMAT_RGBA8888:
-		format = VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM;
-		break;
-	case DRM_FORMAT_XBGR8888:
-		format = VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM;
-		break;
-	case DRM_FORMAT_ABGR8888:
-		format = VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM;
-		break;
-#else
-	case DRM_FORMAT_XRGB8888:
-		format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
-		break;
-	case DRM_FORMAT_ARGB8888:
-		format = VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM;
-		break;
-	case DRM_FORMAT_BGRX8888:
-		format = VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM;
-		break;
-	case DRM_FORMAT_BGRA8888:
-		format = VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM;
-		break;
-	case DRM_FORMAT_RGBX8888:
-		format = VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM;
-		break;
-	case DRM_FORMAT_RGBA8888:
-		format = VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM;
-		break;
-	case DRM_FORMAT_XBGR8888:
-		format = VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM;
-		break;
-	case DRM_FORMAT_ABGR8888:
-		format = VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM;
-		break;
-#endif
-	default:
-		DRM_ERROR("failed to find virtio gpu format for %d\n",
-			  mode_cmd.pixel_format);
+	format = virtio_gpu_translate_format(mode_cmd.pixel_format);
+	if (format == 0)
 		return -EINVAL;
-	}
 
 	size = mode_cmd.pitches[0] * mode_cmd.height;
 	obj = virtio_gpu_alloc_object(dev, size, false, true);
drivers/gpu/drm/virtio/virtgpu_plane.c +68 -0
index 1ff9c64..372c91c 100644
@@ -42,6 +42,74 @@ static const uint32_t virtio_gpu_cursor_formats[] = {
 	DRM_FORMAT_ARGB8888,
 };
 
+uint32_t virtio_gpu_translate_format(uint32_t drm_fourcc)
+{
+	uint32_t format;
+
+	switch (drm_fourcc) {
+#ifdef __BIG_ENDIAN
+	case DRM_FORMAT_XRGB8888:
+		format = VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM;
+		break;
+	case DRM_FORMAT_ARGB8888:
+		format = VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM;
+		break;
+	case DRM_FORMAT_BGRX8888:
+		format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
+		break;
+	case DRM_FORMAT_BGRA8888:
+		format = VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM;
+		break;
+	case DRM_FORMAT_RGBX8888:
+		format = VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM;
+		break;
+	case DRM_FORMAT_RGBA8888:
+		format = VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM;
+		break;
+	case DRM_FORMAT_XBGR8888:
+		format = VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM;
+		break;
+	case DRM_FORMAT_ABGR8888:
+		format = VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM;
+		break;
+#else
+	case DRM_FORMAT_XRGB8888:
+		format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
+		break;
+	case DRM_FORMAT_ARGB8888:
+		format = VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM;
+		break;
+	case DRM_FORMAT_BGRX8888:
+		format = VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM;
+		break;
+	case DRM_FORMAT_BGRA8888:
+		format = VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM;
+		break;
+	case DRM_FORMAT_RGBX8888:
+		format = VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM;
+		break;
+	case DRM_FORMAT_RGBA8888:
+		format = VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM;
+		break;
+	case DRM_FORMAT_XBGR8888:
+		format = VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM;
+		break;
+	case DRM_FORMAT_ABGR8888:
+		format = VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM;
+		break;
+#endif
+	default:
+		/*
+		 * This should not happen, we handle everything listed
+		 * in virtio_gpu_formats[].
+		 */
+		format = 0;
+		break;
+	}
+	WARN_ON(format == 0);
+	return format;
+}
+
 static void virtio_gpu_plane_destroy(struct drm_plane *plane)
 {
 	drm_plane_cleanup(plane);
Signature · 6 lines
2.9.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Acked-by on v1 1/2
#3 lore raw

Re: [PATCH 1/2] drm: virtio: add virtio_gpu_translate_format

In reply to Gerd Hoffmann
Quoted 3 lines · Gerd Hoffmann

Factors out code, no functional change.

Ugh on the big endian define, I guess we'll never managed to figure this aspect of drm pixel formats out correctly - they're supposed to encode endinaness.

But the copy-paste looks correct :-)

Quoted 174 lines
---
 drivers/gpu/drm/virtio/virtgpu_drv.h   |  1 +
 drivers/gpu/drm/virtio/virtgpu_fb.c    | 58 +----------------------------
 drivers/gpu/drm/virtio/virtgpu_plane.c | 68 ++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+), 56 deletions(-)
drivers/gpu/drm/virtio/virtgpu_drv.h +1 -0
index 93900a8..1328185 100644
@@ -334,6 +334,7 @@ int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev);
 void virtio_gpu_modeset_fini(struct virtio_gpu_device *vgdev);
 
 /* virtio_gpu_plane.c */
+uint32_t virtio_gpu_translate_format(uint32_t drm_fourcc);
 struct drm_plane *virtio_gpu_plane_init(struct virtio_gpu_device *vgdev,
 					enum drm_plane_type type,
 					int index);
drivers/gpu/drm/virtio/virtgpu_fb.c +2 -56
index 9bfaef3..33df067 100644
@@ -231,63 +231,9 @@ static int virtio_gpufb_create(struct drm_fb_helper *helper,
 	mode_cmd.pitches[0] = mode_cmd.width * 4;
 	mode_cmd.pixel_format = drm_mode_legacy_fb_format(32, 24);
 
-	switch (mode_cmd.pixel_format) {
-#ifdef __BIG_ENDIAN
-	case DRM_FORMAT_XRGB8888:
-		format = VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM;
-		break;
-	case DRM_FORMAT_ARGB8888:
-		format = VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM;
-		break;
-	case DRM_FORMAT_BGRX8888:
-		format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
-		break;
-	case DRM_FORMAT_BGRA8888:
-		format = VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM;
-		break;
-	case DRM_FORMAT_RGBX8888:
-		format = VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM;
-		break;
-	case DRM_FORMAT_RGBA8888:
-		format = VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM;
-		break;
-	case DRM_FORMAT_XBGR8888:
-		format = VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM;
-		break;
-	case DRM_FORMAT_ABGR8888:
-		format = VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM;
-		break;
-#else
-	case DRM_FORMAT_XRGB8888:
-		format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
-		break;
-	case DRM_FORMAT_ARGB8888:
-		format = VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM;
-		break;
-	case DRM_FORMAT_BGRX8888:
-		format = VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM;
-		break;
-	case DRM_FORMAT_BGRA8888:
-		format = VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM;
-		break;
-	case DRM_FORMAT_RGBX8888:
-		format = VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM;
-		break;
-	case DRM_FORMAT_RGBA8888:
-		format = VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM;
-		break;
-	case DRM_FORMAT_XBGR8888:
-		format = VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM;
-		break;
-	case DRM_FORMAT_ABGR8888:
-		format = VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM;
-		break;
-#endif
-	default:
-		DRM_ERROR("failed to find virtio gpu format for %d\n",
-			  mode_cmd.pixel_format);
+	format = virtio_gpu_translate_format(mode_cmd.pixel_format);
+	if (format == 0)
 		return -EINVAL;
-	}
 
 	size = mode_cmd.pitches[0] * mode_cmd.height;
 	obj = virtio_gpu_alloc_object(dev, size, false, true);
drivers/gpu/drm/virtio/virtgpu_plane.c +68 -0
index 1ff9c64..372c91c 100644
@@ -42,6 +42,74 @@ static const uint32_t virtio_gpu_cursor_formats[] = {
 	DRM_FORMAT_ARGB8888,
 };
 
+uint32_t virtio_gpu_translate_format(uint32_t drm_fourcc)
+{
+	uint32_t format;
+
+	switch (drm_fourcc) {
+#ifdef __BIG_ENDIAN
+	case DRM_FORMAT_XRGB8888:
+		format = VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM;
+		break;
+	case DRM_FORMAT_ARGB8888:
+		format = VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM;
+		break;
+	case DRM_FORMAT_BGRX8888:
+		format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
+		break;
+	case DRM_FORMAT_BGRA8888:
+		format = VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM;
+		break;
+	case DRM_FORMAT_RGBX8888:
+		format = VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM;
+		break;
+	case DRM_FORMAT_RGBA8888:
+		format = VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM;
+		break;
+	case DRM_FORMAT_XBGR8888:
+		format = VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM;
+		break;
+	case DRM_FORMAT_ABGR8888:
+		format = VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM;
+		break;
+#else
+	case DRM_FORMAT_XRGB8888:
+		format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
+		break;
+	case DRM_FORMAT_ARGB8888:
+		format = VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM;
+		break;
+	case DRM_FORMAT_BGRX8888:
+		format = VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM;
+		break;
+	case DRM_FORMAT_BGRA8888:
+		format = VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM;
+		break;
+	case DRM_FORMAT_RGBX8888:
+		format = VIRTIO_GPU_FORMAT_X8B8G8R8_UNORM;
+		break;
+	case DRM_FORMAT_RGBA8888:
+		format = VIRTIO_GPU_FORMAT_A8B8G8R8_UNORM;
+		break;
+	case DRM_FORMAT_XBGR8888:
+		format = VIRTIO_GPU_FORMAT_R8G8B8X8_UNORM;
+		break;
+	case DRM_FORMAT_ABGR8888:
+		format = VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM;
+		break;
+#endif
+	default:
+		/*
+		 * This should not happen, we handle everything listed
+		 * in virtio_gpu_formats[].
+		 */
+		format = 0;
+		break;
+	}
+	WARN_ON(format == 0);
+	return format;
+}
+
 static void virtio_gpu_plane_destroy(struct drm_plane *plane)
 {
 	drm_plane_cleanup(plane);
Signature · 6 lines
2.9.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Acked-by on v1 2/2
#9 lore raw

Re: [PATCH 2/2] drm: virtio: fix virtio_gpu_mode_dumb_create

In reply to Gerd Hoffmann
Quoted 5 lines · Gerd Hoffmann

Lookup format using virtio_gpu_translate_format()
instead of hardcoding it. Fixes xorg display on
bigendian guests (i.e. ppc64).

ow ... :(

With what kind of client have you tested this? fbdev? kms native?

Should we patch drm_fourcc.h and essentially state that _all_ drm_fourcc are in native endian, don't dare mixing things up? Would be good to send out an rfc and discuss it with radeon/amd maintainers. Afaik they are the only ones who also care about some big endian platforms.

On the patch itself, once you've added more details about what/how it falls over:

-Daniel

Quoted 36 lines
---
 drivers/gpu/drm/virtio/virtgpu_gem.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/virtio/virtgpu_gem.c +4 -2
index 336a57f..cc025d8 100644
@@ -88,6 +88,7 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,
 	int ret;
 	uint32_t pitch;
 	uint32_t resid;
+	uint32_t format;
 
 	pitch = args->width * ((args->bpp + 1) / 8);
 	args->size = pitch * args->height;
@@ -98,9 +99,10 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,
 	if (ret)
 		goto fail;
 
+	format = virtio_gpu_translate_format(DRM_FORMAT_XRGB8888);
 	virtio_gpu_resource_id_get(vgdev, &resid);
-	virtio_gpu_cmd_create_resource(vgdev, resid,
-				       2, args->width, args->height);
+	virtio_gpu_cmd_create_resource(vgdev, resid, format,
+				       args->width, args->height);
 
 	/* attach the object to the resource */
 	obj = gem_to_virtio_gpu_obj(gobj);
Signature · 6 lines
2.9.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Acked-by on v1 2/2
#10 lore raw

Re: [PATCH 2/2] drm: virtio: fix virtio_gpu_mode_dumb_create

In reply to Gerd Hoffmann
Quoted 5 lines · Gerd Hoffmann

Lookup format using virtio_gpu_translate_format()
instead of hardcoding it. Fixes xorg display on
bigendian guests (i.e. ppc64).

ow ... :(

With what kind of client have you tested this? fbdev? kms native?

Should we patch drm_fourcc.h and essentially state that _all_ drm_fourcc are in native endian, don't dare mixing things up? Would be good to send out an rfc and discuss it with radeon/amd maintainers. Afaik they are the only ones who also care about some big endian platforms.

On the patch itself, once you've added more details about what/how it falls over:

-Daniel

Quoted 36 lines
---
 drivers/gpu/drm/virtio/virtgpu_gem.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/virtio/virtgpu_gem.c +4 -2
index 336a57f..cc025d8 100644
@@ -88,6 +88,7 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,
 	int ret;
 	uint32_t pitch;
 	uint32_t resid;
+	uint32_t format;
 
 	pitch = args->width * ((args->bpp + 1) / 8);
 	args->size = pitch * args->height;
@@ -98,9 +99,10 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,
 	if (ret)
 		goto fail;
 
+	format = virtio_gpu_translate_format(DRM_FORMAT_XRGB8888);
 	virtio_gpu_resource_id_get(vgdev, &resid);
-	virtio_gpu_cmd_create_resource(vgdev, resid,
-				       2, args->width, args->height);
+	virtio_gpu_cmd_create_resource(vgdev, resid, format,
+				       args->width, args->height);
 
 	/* attach the object to the resource */
 	obj = gem_to_virtio_gpu_obj(gobj);
Signature · 6 lines
2.9.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Tested-by on the v1 series
#13 lore raw
In reply to Gerd Hoffmann
Quoted 14 lines · Gerd Hoffmann

Hi,

Little series to fix xorg display on virtio on bigendian machines. First patch factors out the drm -> virtio format mapping code into a helper function, second patch actually fixes the issue using the new helper.

cheers,
Gerd

Gerd Hoffmann (2):
drm: virtio: add virtio_gpu_translate_format
drm: virtio: fix virtio_gpu_mode_dumb_create

Quoted 6 lines
 drivers/gpu/drm/virtio/virtgpu_drv.h   |  1 +
 drivers/gpu/drm/virtio/virtgpu_fb.c    | 58 +----------------------------
 drivers/gpu/drm/virtio/virtgpu_gem.c   |  6 ++-
 drivers/gpu/drm/virtio/virtgpu_plane.c | 68 ++++++++++++++++++++++++++++++++++
 4 files changed, 75 insertions(+), 58 deletions(-)

Tested with BE endian kernel in QEMU pseries emulation on a LE endian kernel host.

This fixes mixed RGB colors with X11.

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

author maintainer
#11 lore raw

Re: [PATCH 2/2] drm: virtio: fix virtio_gpu_mode_dumb_create

In reply to Daniel Vetter
Quoted 10 lines · Daniel Vetter
Quoted 5 lines · Gerd Hoffmann

Lookup format using virtio_gpu_translate_format()
instead of hardcoding it. Fixes xorg display on
bigendian guests (i.e. ppc64).

ow ... :(

With what kind of client have you tested this? fbdev? kms native?

text console (fbcon) is fine, xorg (modesetting driver) fails.

Quoted 2 lines

Should we patch drm_fourcc.h and essentially state that _all_ drm_fourcc are in native endian, don't dare mixing things up?

Well, I don't think this needs clarification. I never assumed that fourcc is something else than native endian. It really was just an oversight in the virtio driver.

One code path (which creates the framebuffer for fbdev emulation) did proper drm_fourcc -> virtio format mapping, including endianness handling. Patch 1/2 of this series factors this code out into a helper function so we can easily reuse it.

The other code path (for creating dumb buffers) had the virtio format hardcoded which happened to work correctly in the little endian case.

cheers,
Gerd

author maintainer
#12 lore raw

Re: [PATCH 2/2] drm: virtio: fix virtio_gpu_mode_dumb_create

In reply to Daniel Vetter
Quoted 10 lines · Daniel Vetter
Quoted 5 lines · Gerd Hoffmann

Lookup format using virtio_gpu_translate_format()
instead of hardcoding it. Fixes xorg display on
bigendian guests (i.e. ppc64).

ow ... :(

With what kind of client have you tested this? fbdev? kms native?

text console (fbcon) is fine, xorg (modesetting driver) fails.

Quoted 2 lines

Should we patch drm_fourcc.h and essentially state that _all_ drm_fourcc are in native endian, don't dare mixing things up?

Well, I don't think this needs clarification. I never assumed that fourcc is something else than native endian. It really was just an oversight in the virtio driver.

One code path (which creates the framebuffer for fbdev emulation) did proper drm_fourcc -> virtio format mapping, including endianness handling. Patch 1/2 of this series factors this code out into a helper function so we can easily reuse it.

The other code path (for creating dumb buffers) had the virtio format hardcoded which happened to work correctly in the little endian case.

cheers,
Gerd

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

author maintainer
#4 lore raw

Re: [PATCH 1/2] drm: virtio: add virtio_gpu_translate_format

In reply to Daniel Vetter
Quoted 8 lines · Daniel Vetter
Quoted 3 lines · Gerd Hoffmann

Factors out code, no functional change.

Ugh on the big endian define, I guess we'll never managed to figure this aspect of drm pixel formats out correctly - they're supposed to encode endinaness.

Oh, ok. (reading your patch replies out-of-order).

Yep, in that case it maybe is a good idea to discuss fourcc semantics ...

cheers,
Gerd

author maintainer
#5 lore raw

Re: [PATCH 1/2] drm: virtio: add virtio_gpu_translate_format

In reply to Daniel Vetter
Quoted 8 lines · Daniel Vetter
Quoted 3 lines · Gerd Hoffmann

Factors out code, no functional change.

Ugh on the big endian define, I guess we'll never managed to figure this aspect of drm pixel formats out correctly - they're supposed to encode endinaness.

Oh, ok. (reading your patch replies out-of-order).

Yep, in that case it maybe is a good idea to discuss fourcc semantics ...

cheers,
Gerd

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