* [PATCH v2 1/2] drm/virtio: Use XRGB8888 also for big endian systems
@ 2024-08-20 9:07 Jocelyn Falempe
2024-08-20 9:07 ` [PATCH v2 2/2] drm/virtio: Fix host color format for big endian guests Jocelyn Falempe
2024-08-21 11:12 ` [PATCH v2 1/2] drm/virtio: Use XRGB8888 also for big endian systems Gerd Hoffmann
0 siblings, 2 replies; 9+ messages in thread
From: Jocelyn Falempe @ 2024-08-20 9:07 UTC (permalink / raw)
To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
Daniel Vetter, dri-devel, virtualization
Cc: Jocelyn Falempe, Javier Martinez Canillas
Mesa doesn't support BGRX8888, that means most wayland compositors
don't work on big endian guests.
Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
---
drivers/gpu/drm/virtio/virtgpu_display.c | 4 ++--
drivers/gpu/drm/virtio/virtgpu_gem.c | 2 +-
drivers/gpu/drm/virtio/virtgpu_plane.c | 10 ++--------
3 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
index 64baf2f22d9f0..3572a53ea2061 100644
--- a/drivers/gpu/drm/virtio/virtgpu_display.c
+++ b/drivers/gpu/drm/virtio/virtgpu_display.c
@@ -299,8 +299,8 @@ virtio_gpu_user_framebuffer_create(struct drm_device *dev,
struct virtio_gpu_framebuffer *virtio_gpu_fb;
int ret;
- if (mode_cmd->pixel_format != DRM_FORMAT_HOST_XRGB8888 &&
- mode_cmd->pixel_format != DRM_FORMAT_HOST_ARGB8888)
+ if (mode_cmd->pixel_format != DRM_FORMAT_XRGB8888 &&
+ mode_cmd->pixel_format != DRM_FORMAT_ARGB8888)
return ERR_PTR(-ENOENT);
/* lookup object associated with res handle */
diff --git a/drivers/gpu/drm/virtio/virtgpu_gem.c b/drivers/gpu/drm/virtio/virtgpu_gem.c
index 7db48d17ee3a8..601e06962530f 100644
--- a/drivers/gpu/drm/virtio/virtgpu_gem.c
+++ b/drivers/gpu/drm/virtio/virtgpu_gem.c
@@ -75,7 +75,7 @@ int virtio_gpu_mode_dumb_create(struct drm_file *file_priv,
args->size = pitch * args->height;
args->size = ALIGN(args->size, PAGE_SIZE);
- params.format = virtio_gpu_translate_format(DRM_FORMAT_HOST_XRGB8888);
+ params.format = virtio_gpu_translate_format(DRM_FORMAT_XRGB8888);
params.width = args->width;
params.height = args->height;
params.size = args->size;
diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c
index a72a2dbda031c..860b5757ec3fc 100644
--- a/drivers/gpu/drm/virtio/virtgpu_plane.c
+++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
@@ -30,11 +30,11 @@
#include "virtgpu_drv.h"
static const uint32_t virtio_gpu_formats[] = {
- DRM_FORMAT_HOST_XRGB8888,
+ DRM_FORMAT_XRGB8888,
};
static const uint32_t virtio_gpu_cursor_formats[] = {
- DRM_FORMAT_HOST_ARGB8888,
+ DRM_FORMAT_ARGB8888,
};
uint32_t virtio_gpu_translate_format(uint32_t drm_fourcc)
@@ -48,12 +48,6 @@ uint32_t virtio_gpu_translate_format(uint32_t drm_fourcc)
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;
default:
/*
* This should not happen, we handle everything listed
base-commit: 8befe8fa5a4e4b30787b17e078d9d7b5cb92ea19
--
2.46.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/2] drm/virtio: Fix host color format for big endian guests
2024-08-20 9:07 [PATCH v2 1/2] drm/virtio: Use XRGB8888 also for big endian systems Jocelyn Falempe
@ 2024-08-20 9:07 ` Jocelyn Falempe
2024-08-20 12:48 ` Thomas Zimmermann
2024-08-21 10:46 ` Gerd Hoffmann
2024-08-21 11:12 ` [PATCH v2 1/2] drm/virtio: Use XRGB8888 also for big endian systems Gerd Hoffmann
1 sibling, 2 replies; 9+ messages in thread
From: Jocelyn Falempe @ 2024-08-20 9:07 UTC (permalink / raw)
To: David Airlie, Gerd Hoffmann, Gurchetan Singh, Chia-I Wu,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
Daniel Vetter, dri-devel, virtualization
Cc: Jocelyn Falempe, Javier Martinez Canillas
The colors are inverted when testing a s390x VM on a s390x host.
Changing the conversion from DRM_FORMAT -> VIRTIO_GPU_FORMAT on big
endian guests fixes the colors. But it may break big-endian guest on
little-endian host. In this case, the fix should be in qemu, because
the host endianess is not known in the guest VM.
Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
---
drivers/gpu/drm/virtio/virtgpu_plane.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c
index 860b5757ec3fc..0ec6ecc96eb13 100644
--- a/drivers/gpu/drm/virtio/virtgpu_plane.c
+++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
@@ -37,16 +37,24 @@ static const uint32_t virtio_gpu_cursor_formats[] = {
DRM_FORMAT_ARGB8888,
};
+#ifdef __BIG_ENDIAN
+#define VIRTIO_GPU_HOST_XRGB8888 VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM
+#define VIRTIO_GPU_HOST_ARGB8888 VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM
+#else
+#define VIRTIO_GPU_HOST_XRGB8888 VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM
+#define VIRTIO_GPU_HOST_ARGB8888 VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM
+#endif
+
uint32_t virtio_gpu_translate_format(uint32_t drm_fourcc)
{
uint32_t format;
switch (drm_fourcc) {
case DRM_FORMAT_XRGB8888:
- format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
+ format = VIRTIO_GPU_HOST_XRGB8888;
break;
case DRM_FORMAT_ARGB8888:
- format = VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM;
+ format = VIRTIO_GPU_HOST_ARGB8888;
break;
default:
/*
--
2.46.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] drm/virtio: Fix host color format for big endian guests
2024-08-20 9:07 ` [PATCH v2 2/2] drm/virtio: Fix host color format for big endian guests Jocelyn Falempe
@ 2024-08-20 12:48 ` Thomas Zimmermann
2024-08-20 12:55 ` Jocelyn Falempe
2024-08-21 10:46 ` Gerd Hoffmann
1 sibling, 1 reply; 9+ messages in thread
From: Thomas Zimmermann @ 2024-08-20 12:48 UTC (permalink / raw)
To: Jocelyn Falempe, David Airlie, Gerd Hoffmann, Gurchetan Singh,
Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Daniel Vetter,
dri-devel, virtualization
Cc: Javier Martinez Canillas
Hi
Am 20.08.24 um 11:07 schrieb Jocelyn Falempe:
> The colors are inverted when testing a s390x VM on a s390x host.
> Changing the conversion from DRM_FORMAT -> VIRTIO_GPU_FORMAT on big
> endian guests fixes the colors. But it may break big-endian guest on
> little-endian host. In this case, the fix should be in qemu, because
> the host endianess is not known in the guest VM.
>
> Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
> Acked-by: Javier Martinez Canillas <javierm@redhat.com>
> ---
> drivers/gpu/drm/virtio/virtgpu_plane.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c
> index 860b5757ec3fc..0ec6ecc96eb13 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_plane.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
> @@ -37,16 +37,24 @@ static const uint32_t virtio_gpu_cursor_formats[] = {
> DRM_FORMAT_ARGB8888,
> };
>
> +#ifdef __BIG_ENDIAN
> +#define VIRTIO_GPU_HOST_XRGB8888 VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM
> +#define VIRTIO_GPU_HOST_ARGB8888 VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM
> +#else
> +#define VIRTIO_GPU_HOST_XRGB8888 VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM
> +#define VIRTIO_GPU_HOST_ARGB8888 VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM
> +#endif
As these defines are only used here, would it be beneficial to put the
__BIG_ENDIAN branch directly around the switch statement?
Best regards
Thomas
> +
> uint32_t virtio_gpu_translate_format(uint32_t drm_fourcc)
> {
> uint32_t format;
>
> switch (drm_fourcc) {
> case DRM_FORMAT_XRGB8888:
> - format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
> + format = VIRTIO_GPU_HOST_XRGB8888;
> break;
> case DRM_FORMAT_ARGB8888:
> - format = VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM;
> + format = VIRTIO_GPU_HOST_ARGB8888;
> break;
> default:
> /*
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] drm/virtio: Fix host color format for big endian guests
2024-08-20 12:48 ` Thomas Zimmermann
@ 2024-08-20 12:55 ` Jocelyn Falempe
2024-08-20 13:25 ` Thomas Zimmermann
2024-08-20 14:27 ` Javier Martinez Canillas
0 siblings, 2 replies; 9+ messages in thread
From: Jocelyn Falempe @ 2024-08-20 12:55 UTC (permalink / raw)
To: Thomas Zimmermann, David Airlie, Gerd Hoffmann, Gurchetan Singh,
Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Daniel Vetter,
dri-devel, virtualization
Cc: Javier Martinez Canillas
On 20/08/2024 14:48, Thomas Zimmermann wrote:
> Hi
>
> Am 20.08.24 um 11:07 schrieb Jocelyn Falempe:
>> The colors are inverted when testing a s390x VM on a s390x host.
>> Changing the conversion from DRM_FORMAT -> VIRTIO_GPU_FORMAT on big
>> endian guests fixes the colors. But it may break big-endian guest on
>> little-endian host. In this case, the fix should be in qemu, because
>> the host endianess is not known in the guest VM.
>>
>> Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
>> Acked-by: Javier Martinez Canillas <javierm@redhat.com>
>> ---
>> drivers/gpu/drm/virtio/virtgpu_plane.c | 12 ++++++++++--
>> 1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c
>> b/drivers/gpu/drm/virtio/virtgpu_plane.c
>> index 860b5757ec3fc..0ec6ecc96eb13 100644
>> --- a/drivers/gpu/drm/virtio/virtgpu_plane.c
>> +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
>> @@ -37,16 +37,24 @@ static const uint32_t virtio_gpu_cursor_formats[] = {
>> DRM_FORMAT_ARGB8888,
>> };
>> +#ifdef __BIG_ENDIAN
>> +#define VIRTIO_GPU_HOST_XRGB8888 VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM
>> +#define VIRTIO_GPU_HOST_ARGB8888 VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM
>> +#else
>> +#define VIRTIO_GPU_HOST_XRGB8888 VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM
>> +#define VIRTIO_GPU_HOST_ARGB8888 VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM
>> +#endif
>
> As these defines are only used here, would it be beneficial to put the
> __BIG_ENDIAN branch directly around the switch statement?
That was my first version, but I found it difficult to read, when I mix
#ifdef in a switch case.
or maybe something like the following would be better ?
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;
#else
case DRM_FORMAT_XRGB8888:
format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
break;
case DRM_FORMAT_ARGB8888:
format = VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM;
break;
#endif
>
> Best regards
> Thomas
>
>> +
>> uint32_t virtio_gpu_translate_format(uint32_t drm_fourcc)
>> {
>> uint32_t format;
>> switch (drm_fourcc) {
>> case DRM_FORMAT_XRGB8888:
>> - format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
>> + format = VIRTIO_GPU_HOST_XRGB8888;
>> break;
>> case DRM_FORMAT_ARGB8888:
>> - format = VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM;
>> + format = VIRTIO_GPU_HOST_ARGB8888;
>> break;
>> default:
>> /*
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] drm/virtio: Fix host color format for big endian guests
2024-08-20 12:55 ` Jocelyn Falempe
@ 2024-08-20 13:25 ` Thomas Zimmermann
2024-08-20 14:27 ` Javier Martinez Canillas
1 sibling, 0 replies; 9+ messages in thread
From: Thomas Zimmermann @ 2024-08-20 13:25 UTC (permalink / raw)
To: Jocelyn Falempe, David Airlie, Gerd Hoffmann, Gurchetan Singh,
Chia-I Wu, Maarten Lankhorst, Maxime Ripard, Daniel Vetter,
dri-devel, virtualization
Cc: Javier Martinez Canillas
Hi
Am 20.08.24 um 14:55 schrieb Jocelyn Falempe:
> On 20/08/2024 14:48, Thomas Zimmermann wrote:
>> Hi
>>
>> Am 20.08.24 um 11:07 schrieb Jocelyn Falempe:
>>> The colors are inverted when testing a s390x VM on a s390x host.
>>> Changing the conversion from DRM_FORMAT -> VIRTIO_GPU_FORMAT on big
>>> endian guests fixes the colors. But it may break big-endian guest on
>>> little-endian host. In this case, the fix should be in qemu, because
>>> the host endianess is not known in the guest VM.
>>>
>>> Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
>>> Acked-by: Javier Martinez Canillas <javierm@redhat.com>
>>> ---
>>> drivers/gpu/drm/virtio/virtgpu_plane.c | 12 ++++++++++--
>>> 1 file changed, 10 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c
>>> b/drivers/gpu/drm/virtio/virtgpu_plane.c
>>> index 860b5757ec3fc..0ec6ecc96eb13 100644
>>> --- a/drivers/gpu/drm/virtio/virtgpu_plane.c
>>> +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
>>> @@ -37,16 +37,24 @@ static const uint32_t
>>> virtio_gpu_cursor_formats[] = {
>>> DRM_FORMAT_ARGB8888,
>>> };
>>> +#ifdef __BIG_ENDIAN
>>> +#define VIRTIO_GPU_HOST_XRGB8888 VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM
>>> +#define VIRTIO_GPU_HOST_ARGB8888 VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM
>>> +#else
>>> +#define VIRTIO_GPU_HOST_XRGB8888 VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM
>>> +#define VIRTIO_GPU_HOST_ARGB8888 VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM
>>> +#endif
>>
>> As these defines are only used here, would it be beneficial to put
>> the __BIG_ENDIAN branch directly around the switch statement?
>
> That was my first version, but I found it difficult to read, when I
> mix #ifdef in a switch case.
>
>
> or maybe something like the following would be better ?
>
>
> 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;
> #else
> case DRM_FORMAT_XRGB8888:
> format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
> break;
> case DRM_FORMAT_ARGB8888:
> format = VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM;
> break;
> #endif
I have no preference. Maybe the virtio devs can comment.
Best regards
Thomas
>>
>> Best regards
>> Thomas
>>
>>> +
>>> uint32_t virtio_gpu_translate_format(uint32_t drm_fourcc)
>>> {
>>> uint32_t format;
>>> switch (drm_fourcc) {
>>> case DRM_FORMAT_XRGB8888:
>>> - format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
>>> + format = VIRTIO_GPU_HOST_XRGB8888;
>>> break;
>>> case DRM_FORMAT_ARGB8888:
>>> - format = VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM;
>>> + format = VIRTIO_GPU_HOST_ARGB8888;
>>> break;
>>> default:
>>> /*
>>
>
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] drm/virtio: Fix host color format for big endian guests
2024-08-20 12:55 ` Jocelyn Falempe
2024-08-20 13:25 ` Thomas Zimmermann
@ 2024-08-20 14:27 ` Javier Martinez Canillas
1 sibling, 0 replies; 9+ messages in thread
From: Javier Martinez Canillas @ 2024-08-20 14:27 UTC (permalink / raw)
To: Jocelyn Falempe, Thomas Zimmermann, David Airlie, Gerd Hoffmann,
Gurchetan Singh, Chia-I Wu, Maarten Lankhorst, Maxime Ripard,
Daniel Vetter, dri-devel, virtualization
Jocelyn Falempe <jfalempe@redhat.com> writes:
> On 20/08/2024 14:48, Thomas Zimmermann wrote:
>> Hi
>>
>> Am 20.08.24 um 11:07 schrieb Jocelyn Falempe:
>>> The colors are inverted when testing a s390x VM on a s390x host.
>>> Changing the conversion from DRM_FORMAT -> VIRTIO_GPU_FORMAT on big
>>> endian guests fixes the colors. But it may break big-endian guest on
>>> little-endian host. In this case, the fix should be in qemu, because
>>> the host endianess is not known in the guest VM.
>>>
>>> Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
>>> Acked-by: Javier Martinez Canillas <javierm@redhat.com>
>>> ---
>>> drivers/gpu/drm/virtio/virtgpu_plane.c | 12 ++++++++++--
>>> 1 file changed, 10 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c
>>> b/drivers/gpu/drm/virtio/virtgpu_plane.c
>>> index 860b5757ec3fc..0ec6ecc96eb13 100644
>>> --- a/drivers/gpu/drm/virtio/virtgpu_plane.c
>>> +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
>>> @@ -37,16 +37,24 @@ static const uint32_t virtio_gpu_cursor_formats[] = {
>>> DRM_FORMAT_ARGB8888,
>>> };
>>> +#ifdef __BIG_ENDIAN
>>> +#define VIRTIO_GPU_HOST_XRGB8888 VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM
>>> +#define VIRTIO_GPU_HOST_ARGB8888 VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM
>>> +#else
>>> +#define VIRTIO_GPU_HOST_XRGB8888 VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM
>>> +#define VIRTIO_GPU_HOST_ARGB8888 VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM
>>> +#endif
>>
>> As these defines are only used here, would it be beneficial to put the
>> __BIG_ENDIAN branch directly around the switch statement?
>
> That was my first version, but I found it difficult to read, when I mix
> #ifdef in a switch case.
>
>
> or maybe something like the following would be better ?
>
>
> 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;
> #else
> case DRM_FORMAT_XRGB8888:
> format = VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM;
> break;
> case DRM_FORMAT_ARGB8888:
> format = VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM;
> break;
> #endif
IMO your current patch is easier to read than having the ifdefery
in the switch statement.
--
Best regards,
Javier Martinez Canillas
Core Platforms
Red Hat
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 2/2] drm/virtio: Fix host color format for big endian guests
2024-08-20 9:07 ` [PATCH v2 2/2] drm/virtio: Fix host color format for big endian guests Jocelyn Falempe
2024-08-20 12:48 ` Thomas Zimmermann
@ 2024-08-21 10:46 ` Gerd Hoffmann
1 sibling, 0 replies; 9+ messages in thread
From: Gerd Hoffmann @ 2024-08-21 10:46 UTC (permalink / raw)
To: Jocelyn Falempe
Cc: David Airlie, Gurchetan Singh, Chia-I Wu, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, Daniel Vetter, dri-devel,
virtualization, Javier Martinez Canillas
On Tue, Aug 20, 2024 at 11:07:41AM GMT, Jocelyn Falempe wrote:
> The colors are inverted when testing a s390x VM on a s390x host.
> Changing the conversion from DRM_FORMAT -> VIRTIO_GPU_FORMAT on big
> endian guests fixes the colors. But it may break big-endian guest on
> little-endian host. In this case, the fix should be in qemu, because
> the host endianess is not known in the guest VM.
>
> Signed-off-by: Jocelyn Falempe <jfalempe@redhat.com>
> Acked-by: Javier Martinez Canillas <javierm@redhat.com>
> ---
> drivers/gpu/drm/virtio/virtgpu_plane.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c
> index 860b5757ec3fc..0ec6ecc96eb13 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_plane.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
> @@ -37,16 +37,24 @@ static const uint32_t virtio_gpu_cursor_formats[] = {
> DRM_FORMAT_ARGB8888,
> };
>
> +#ifdef __BIG_ENDIAN
> +#define VIRTIO_GPU_HOST_XRGB8888 VIRTIO_GPU_FORMAT_X8R8G8B8_UNORM
> +#define VIRTIO_GPU_HOST_ARGB8888 VIRTIO_GPU_FORMAT_A8R8G8B8_UNORM
> +#else
> +#define VIRTIO_GPU_HOST_XRGB8888 VIRTIO_GPU_FORMAT_B8G8R8X8_UNORM
> +#define VIRTIO_GPU_HOST_ARGB8888 VIRTIO_GPU_FORMAT_B8G8R8A8_UNORM
> +#endif
VIRTIO_GPU_FORMAT_* is little endian (like DRM_FORMAT_*), there should
be no need to do anything byte order specific here. This looks like you
are papering over a bug somewhere else.
take care,
Gerd
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] drm/virtio: Use XRGB8888 also for big endian systems
2024-08-20 9:07 [PATCH v2 1/2] drm/virtio: Use XRGB8888 also for big endian systems Jocelyn Falempe
2024-08-20 9:07 ` [PATCH v2 2/2] drm/virtio: Fix host color format for big endian guests Jocelyn Falempe
@ 2024-08-21 11:12 ` Gerd Hoffmann
2024-08-22 14:46 ` Jocelyn Falempe
1 sibling, 1 reply; 9+ messages in thread
From: Gerd Hoffmann @ 2024-08-21 11:12 UTC (permalink / raw)
To: Jocelyn Falempe
Cc: David Airlie, Gurchetan Singh, Chia-I Wu, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, Daniel Vetter, dri-devel,
virtualization, Javier Martinez Canillas
On Tue, Aug 20, 2024 at 11:07:40AM GMT, Jocelyn Falempe wrote:
> Mesa doesn't support BGRX8888, that means most wayland compositors
> don't work on big endian guests.
So you are doing a hard switch from native endian to little endian.
While this should be fine for modern userspace API (aka ADDFB2 ioctl) it
is not for older APIs (ADDFB ioctl, also fbdev emulation) where only
depth=32 is specified and userspace typically expects a framebuffer in
native byte order.
Ideally virtio-gpu would support both big endian and little endian
framebuffer formats (simliar to bochs drm driver). That probably is a
somewhat more invasive change because the DRM_IOCTL_MODE_CREATE_DUMB
doesn't tell use the format which will be used. Possible options I see:
(1) Be lazy on creating host resources, i.e. call
virtio_gpu_cmd_create_resource() not at DRM_IOCTL_MODE_CREATE_DUMB
time but later when the resource will be actually be used (and
specifically after DRM_IOCTL_MODE_ADDFB(2) ioctl so we know the
format). Needs additional state tracking (whenever the resource
has been created or not) in possibly lots of places.
(2) Support changing the resource format, i.e. in case
DRM_IOCTL_MODE_ADDFB(2) is called with a format different from the
current one go through a destroy-and-recreate cycle for the host
resource. Might have tricky corner cases (resource being in use
when DRM_IOCTL_MODE_ADDFB(2) is called).
HTH & take care,
Gerd
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/2] drm/virtio: Use XRGB8888 also for big endian systems
2024-08-21 11:12 ` [PATCH v2 1/2] drm/virtio: Use XRGB8888 also for big endian systems Gerd Hoffmann
@ 2024-08-22 14:46 ` Jocelyn Falempe
0 siblings, 0 replies; 9+ messages in thread
From: Jocelyn Falempe @ 2024-08-22 14:46 UTC (permalink / raw)
To: Gerd Hoffmann
Cc: David Airlie, Gurchetan Singh, Chia-I Wu, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, Daniel Vetter, dri-devel,
virtualization, Javier Martinez Canillas
On 21/08/2024 13:12, Gerd Hoffmann wrote:
> On Tue, Aug 20, 2024 at 11:07:40AM GMT, Jocelyn Falempe wrote:
>> Mesa doesn't support BGRX8888, that means most wayland compositors
>> don't work on big endian guests.
>
> So you are doing a hard switch from native endian to little endian.
>
> While this should be fine for modern userspace API (aka ADDFB2 ioctl) it
> is not for older APIs (ADDFB ioctl, also fbdev emulation) where only
> depth=32 is specified and userspace typically expects a framebuffer in
> native byte order.
>
> Ideally virtio-gpu would support both big endian and little endian
> framebuffer formats (simliar to bochs drm driver). That probably is a
> somewhat more invasive change because the DRM_IOCTL_MODE_CREATE_DUMB
> doesn't tell use the format which will be used. Possible options I see:
>
> (1) Be lazy on creating host resources, i.e. call
> virtio_gpu_cmd_create_resource() not at DRM_IOCTL_MODE_CREATE_DUMB
> time but later when the resource will be actually be used (and
> specifically after DRM_IOCTL_MODE_ADDFB(2) ioctl so we know the
> format). Needs additional state tracking (whenever the resource
> has been created or not) in possibly lots of places.
>
> (2) Support changing the resource format, i.e. in case
> DRM_IOCTL_MODE_ADDFB(2) is called with a format different from the
> current one go through a destroy-and-recreate cycle for the host
> resource. Might have tricky corner cases (resource being in use
> when DRM_IOCTL_MODE_ADDFB(2) is called).
I've implemented (1), I will send a new series soon.
Thanks for your advice.
--
Jocelyn
>
> HTH & take care,
> Gerd
>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-08-22 14:46 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-20 9:07 [PATCH v2 1/2] drm/virtio: Use XRGB8888 also for big endian systems Jocelyn Falempe
2024-08-20 9:07 ` [PATCH v2 2/2] drm/virtio: Fix host color format for big endian guests Jocelyn Falempe
2024-08-20 12:48 ` Thomas Zimmermann
2024-08-20 12:55 ` Jocelyn Falempe
2024-08-20 13:25 ` Thomas Zimmermann
2024-08-20 14:27 ` Javier Martinez Canillas
2024-08-21 10:46 ` Gerd Hoffmann
2024-08-21 11:12 ` [PATCH v2 1/2] drm/virtio: Use XRGB8888 also for big endian systems Gerd Hoffmann
2024-08-22 14:46 ` Jocelyn Falempe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox