drm/nouveau: Accept 'legacy' format modifiers
Subsystems (3)
PATCH v2 1/1 drm/nouveau: Accept 'legacy' format modifiers
Accept the DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK() family of modifiers to handle broken userspace Xorg modesetting and Mesa drivers. Existing Mesa drivers are still aware of only these older format modifiers which do not differentiate between different variations of the block linear layout. When the format modifier support flag was flipped in the nouveau kernel driver, the X.org modesetting driver began attempting to use its format modifier-enabled framebuffer path. Because the set of format modifiers advertised by the kernel prior to this change do not intersect with the set of format modifiers advertised by Mesa, allocating GBM buffers using format modifiers fails and the modesetting driver falls back to non-modifier allocation. However, it still later queries the modifier of the GBM buffer when creating its DRM-KMS framebuffer object, receives the old-format modifier from Mesa, and attempts to create a framebuffer with it. Since the kernel is still not aware of these formats, this fails.
Userspace should not be attempting to query format modifiers of GBM buffers allocated with a non- format-modifier-aware allocation path, but to avoid breaking existing userspace behavior, this change accepts the old-style format modifiers when creating framebuffers and applying them to planes by translating them to the equivalent new-style modifier. To accomplish this, some layout parameters must be assumed to match properties of the device targeted by the relevant ioctls. To avoid perpetuating misuse of the old-style modifiers, this change does not advertise support for them. Doing so would imply compatibility between devices with incompatible memory layouts.
Tested with Xorg 1.20 modesetting driver, weston@c46c70dac84a4b3030cd05b380f9f410536690fc, gnome & KDE wayland desktops from Ubuntu 18.04, and sway 1.5
--- drivers/gpu/drm/nouveau/nouveau_display.c | 26 +++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_display.c +24 -2
@@ -191,8 +191,14 @@ nouveau_decode_mod(struct nouveau_drm *drm,uint32_t *tile_mode, uint8_t *kind) { + struct nouveau_display *disp = nouveau_display(drm->dev);BUG_ON (!tile_mode || !kind); +if ((modifier & (0xffull <<12 )) ==0ull ) { +/* Legacy modifier. Translate to this device's 'kind.' */ + modifier |= disp->format_modifiers[0 ] & (0xffull <<12 ); + } +if (modifier ==DRM_FORMAT_MOD_LINEAR ) {/* tile_mode will not be used in this case */ *tile_mode =0 ;
@@ -227,6 +233,16 @@ nouveau_framebuffer_get_layout(struct drm_framebuffer *fb, } } +static const u64 legacy_modifiers[] = { +DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK (0 ), +DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK (1 ), +DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK (2 ), +DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK (3 ), +DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK (4 ), +DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK (5 ), +DRM_FORMAT_MOD_INVALID +}; + static int nouveau_validate_decode_mod(struct nouveau_drm *drm, uint64_t modifier,
@@ -247,8 +263,14 @@ nouveau_validate_decode_mod(struct nouveau_drm *drm, (disp->format_modifiers[mod] != modifier); mod++); -if (disp->format_modifiers[mod] ==DRM_FORMAT_MOD_INVALID ) -return -EINVAL ; +if (disp->format_modifiers[mod] ==DRM_FORMAT_MOD_INVALID ) { +for (mod =0 ; + (legacy_modifiers[mod] !=DRM_FORMAT_MOD_INVALID ) && + (legacy_modifiers[mod] != modifier); + mod++); +if (legacy_modifiers[mod] ==DRM_FORMAT_MOD_INVALID ) +return -EINVAL ; + }nouveau_decode_mod (drm, modifier, tile_mode, kind);
Signature · 1 line
2.17.1
Quoted 56 lines · James Jones
Accept the
DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK()family of modifiers to handle broken userspace Xorg modesetting and Mesa drivers. Existing Mesa drivers are still aware of only these older format modifiers which do not differentiate between different variations of the block linear layout. When the format modifier support flag was flipped in the nouveau kernel driver, the X.org modesetting driver began attempting to use its format modifier-enabled framebuffer path. Because the set of format modifiers advertised by the kernel prior to this change do not intersect with the set of format modifiers advertised by Mesa, allocating GBM buffers using format modifiers fails and the modesetting driver falls back to non-modifier allocation. However, it still later queries the modifier of the GBM buffer when creating its DRM-KMS framebuffer object, receives the old-format modifier from Mesa, and attempts to create a framebuffer with it. Since the kernel is still not aware of these formats, this fails.Userspace should not be attempting to query format modifiers of GBM buffers allocated with a non- format-modifier-aware allocation path, but to avoid breaking existing userspace behavior, this change accepts the old-style format modifiers when creating framebuffers and applying them to planes by translating them to the equivalent new-style modifier. To accomplish this, some layout parameters must be assumed to match properties of the device targeted by the relevant ioctls. To avoid perpetuating misuse of the old-style modifiers, this change does not advertise support for them. Doing so would imply compatibility between devices with incompatible memory layouts.
Tested with Xorg 1.20 modesetting driver, weston@c46c70dac84a4b3030cd05b380f9f410536690fc, gnome & KDE wayland desktops from Ubuntu 18.04, and sway 1.5
Reported-by Kirill A. Shutemov <[email protected]>Fixes fa4f4c213f5f ("drm/nouveau/kms: Support NVIDIA format modifiers")Signed-off-by James Jones <[email protected]>--- drivers/gpu/drm/nouveau/nouveau_display.c | 26 +++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)drivers/gpu/drm/nouveau/nouveau_display.c +0
-0
drivers/gpu/drm/nouveau/nouveau_display.c nouveau_decode_mod(struct nouveau_drm *drm, · line 200
Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_display.c +5
-0@@ -191,8 +191,14 @@ nouveau_decode_mod(struct nouveau_drm *drm,uint32_t *tile_mode, uint8_t *kind) { + struct nouveau_display *disp = nouveau_display(drm->dev);BUG_ON (!tile_mode || !kind); +if ((modifier & (0xffull <<12 )) ==0ull ) { +/* Legacy modifier. Translate to this device's 'kind.' */ + modifier |= disp->format_modifiers[0 ] & (0xffull <<12 ); + }
I believe this should be moved into the != MOD_LINEAR case.
Quoted 45 lines
drivers/gpu/drm/nouveau/nouveau_display.c +19
-3+if (modifier ==DRM_FORMAT_MOD_LINEAR ) {/* tile_mode will not be used in this case */ *tile_mode =0 ;@@ -227,6 +233,16 @@ nouveau_framebuffer_get_layout(struct drm_framebuffer *fb, } } +static const u64 legacy_modifiers[] = { +DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK (0 ), +DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK (1 ), +DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK (2 ), +DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK (3 ), +DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK (4 ), +DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK (5 ), +DRM_FORMAT_MOD_INVALID +}; + static int nouveau_validate_decode_mod(struct nouveau_drm *drm, uint64_t modifier,@@ -247,8 +263,14 @@ nouveau_validate_decode_mod(struct nouveau_drm *drm, (disp->format_modifiers[mod] != modifier); mod++); -if (disp->format_modifiers[mod] ==DRM_FORMAT_MOD_INVALID ) -return -EINVAL ; +if (disp->format_modifiers[mod] ==DRM_FORMAT_MOD_INVALID ) { +for (mod =0 ; + (legacy_modifiers[mod] !=DRM_FORMAT_MOD_INVALID ) && + (legacy_modifiers[mod] != modifier); + mod++); +if (legacy_modifiers[mod] ==DRM_FORMAT_MOD_INVALID ) +return -EINVAL ; + }nouveau_decode_mod (drm, modifier, tile_mode, kind); --2.17.1
_______________________________________________
Nouveau mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
Quoted 63 lines · Ben Skeggs
Quoted 62 lines · James Jones
Accept the
DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK()family of modifiers to handle broken userspace Xorg modesetting and Mesa drivers. Existing Mesa drivers are still aware of only these older format modifiers which do not differentiate between different variations of the block linear layout. When the format modifier support flag was flipped in the nouveau kernel driver, the X.org modesetting driver began attempting to use its format modifier-enabled framebuffer path. Because the set of format modifiers advertised by the kernel prior to this change do not intersect with the set of format modifiers advertised by Mesa, allocating GBM buffers using format modifiers fails and the modesetting driver falls back to non-modifier allocation. However, it still later queries the modifier of the GBM buffer when creating its DRM-KMS framebuffer object, receives the old-format modifier from Mesa, and attempts to create a framebuffer with it. Since the kernel is still not aware of these formats, this fails.Userspace should not be attempting to query format modifiers of GBM buffers allocated with a non- format-modifier-aware allocation path, but to avoid breaking existing userspace behavior, this change accepts the old-style format modifiers when creating framebuffers and applying them to planes by translating them to the equivalent new-style modifier. To accomplish this, some layout parameters must be assumed to match properties of the device targeted by the relevant ioctls. To avoid perpetuating misuse of the old-style modifiers, this change does not advertise support for them. Doing so would imply compatibility between devices with incompatible memory layouts.
Tested with Xorg 1.20 modesetting driver, weston@c46c70dac84a4b3030cd05b380f9f410536690fc, gnome & KDE wayland desktops from Ubuntu 18.04, and sway 1.5
Reported-by Kirill A. Shutemov <[email protected]>Fixes fa4f4c213f5f ("drm/nouveau/kms: Support NVIDIA format modifiers")Signed-off-by James Jones <[email protected]>--- drivers/gpu/drm/nouveau/nouveau_display.c | 26 +++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)drivers/gpu/drm/nouveau/nouveau_display.c +1
-0@@ -191,8 +191,14 @@ nouveau_decode_mod(struct nouveau_drm *drm,uint32_t *tile_mode, uint8_t *kind) { + struct nouveau_display *disp = nouveau_display(drm->dev);BUG_ON (!tile_mode || !kind);
Quoted 5 lines
drivers/gpu/drm/nouveau/nouveau_display.c nouveau_decode_mod(struct nouveau_drm *drm, · line 200
Quoted 4 lines
drivers/gpu/drm/nouveau/nouveau_display.c +4
-0+if ((modifier & (0xffull <<12 )) ==0ull ) { +/* Legacy modifier. Translate to this device's 'kind.' */ + modifier |= disp->format_modifiers[0 ] & (0xffull <<12 ); + }I believe this should be moved into the !=
MOD_LINEARcase.
Yes, of course, thanks. I need to re-evaluate my testing yet again to make sure I hit that case too. Preparing a v3...
Thanks,
-James
Quoted 45 lines
Quoted 45 lines
drivers/gpu/drm/nouveau/nouveau_display.c +19
-3+if (modifier ==DRM_FORMAT_MOD_LINEAR ) {/* tile_mode will not be used in this case */ *tile_mode =0 ;@@ -227,6 +233,16 @@ nouveau_framebuffer_get_layout(struct drm_framebuffer *fb, } } +static const u64 legacy_modifiers[] = { +DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK (0 ), +DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK (1 ), +DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK (2 ), +DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK (3 ), +DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK (4 ), +DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK (5 ), +DRM_FORMAT_MOD_INVALID +}; + static int nouveau_validate_decode_mod(struct nouveau_drm *drm, uint64_t modifier,@@ -247,8 +263,14 @@ nouveau_validate_decode_mod(struct nouveau_drm *drm, (disp->format_modifiers[mod] != modifier); mod++); -if (disp->format_modifiers[mod] ==DRM_FORMAT_MOD_INVALID ) -return -EINVAL ; +if (disp->format_modifiers[mod] ==DRM_FORMAT_MOD_INVALID ) { +for (mod =0 ; + (legacy_modifiers[mod] !=DRM_FORMAT_MOD_INVALID ) && + (legacy_modifiers[mod] != modifier); + mod++); +if (legacy_modifiers[mod] ==DRM_FORMAT_MOD_INVALID ) +return -EINVAL ; + }nouveau_decode_mod (drm, modifier, tile_mode, kind); --2.17.1
_______________________________________________
Nouveau mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
Dave Airlie
maintainerQuoted 65 lines · James Jones
Quoted 63 lines · Ben Skeggs
Quoted 62 lines · James Jones
Accept the
DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK()family of modifiers to handle broken userspace Xorg modesetting and Mesa drivers. Existing Mesa drivers are still aware of only these older format modifiers which do not differentiate between different variations of the block linear layout. When the format modifier support flag was flipped in the nouveau kernel driver, the X.org modesetting driver began attempting to use its format modifier-enabled framebuffer path. Because the set of format modifiers advertised by the kernel prior to this change do not intersect with the set of format modifiers advertised by Mesa, allocating GBM buffers using format modifiers fails and the modesetting driver falls back to non-modifier allocation. However, it still later queries the modifier of the GBM buffer when creating its DRM-KMS framebuffer object, receives the old-format modifier from Mesa, and attempts to create a framebuffer with it. Since the kernel is still not aware of these formats, this fails.Userspace should not be attempting to query format modifiers of GBM buffers allocated with a non- format-modifier-aware allocation path, but to avoid breaking existing userspace behavior, this change accepts the old-style format modifiers when creating framebuffers and applying them to planes by translating them to the equivalent new-style modifier. To accomplish this, some layout parameters must be assumed to match properties of the device targeted by the relevant ioctls. To avoid perpetuating misuse of the old-style modifiers, this change does not advertise support for them. Doing so would imply compatibility between devices with incompatible memory layouts.
Tested with Xorg 1.20 modesetting driver, weston@c46c70dac84a4b3030cd05b380f9f410536690fc, gnome & KDE wayland desktops from Ubuntu 18.04, and sway 1.5
Reported-by Kirill A. Shutemov <[email protected]>Fixes fa4f4c213f5f ("drm/nouveau/kms: Support NVIDIA format modifiers")Signed-off-by James Jones <[email protected]>--- drivers/gpu/drm/nouveau/nouveau_display.c | 26 +++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)drivers/gpu/drm/nouveau/nouveau_display.c +1
-0@@ -191,8 +191,14 @@ nouveau_decode_mod(struct nouveau_drm *drm,uint32_t *tile_mode, uint8_t *kind) { + struct nouveau_display *disp = nouveau_display(drm->dev);BUG_ON (!tile_mode || !kind);
Quoted 8 lines
Quoted 5 lines
drivers/gpu/drm/nouveau/nouveau_display.c nouveau_decode_mod(struct nouveau_drm *drm, · line 200
Quoted 4 lines
drivers/gpu/drm/nouveau/nouveau_display.c +4
-0+if ((modifier & (0xffull <<12 )) ==0ull ) { +/* Legacy modifier. Translate to this device's 'kind.' */ + modifier |= disp->format_modifiers[0 ] & (0xffull <<12 ); + }I believe this should be moved into the !=
MOD_LINEARcase.Yes, of course, thanks. I need to re-evaluate my testing yet again to make sure I hit that case too. Preparing a v3...
Going to need something here in the next day, two max.
Linus may wait for another week, but it's not guaranteed.
Dave.
Quoted 73 lines · Dave Airlie
Quoted 71 lines · James Jones
Quoted 68 lines · Ben Skeggs
Quoted 56 lines · James Jones
Accept the
DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK()family of modifiers to handle broken userspace Xorg modesetting and Mesa drivers. Existing Mesa drivers are still aware of only these older format modifiers which do not differentiate between different variations of the block linear layout. When the format modifier support flag was flipped in the nouveau kernel driver, the X.org modesetting driver began attempting to use its format modifier-enabled framebuffer path. Because the set of format modifiers advertised by the kernel prior to this change do not intersect with the set of format modifiers advertised by Mesa, allocating GBM buffers using format modifiers fails and the modesetting driver falls back to non-modifier allocation. However, it still later queries the modifier of the GBM buffer when creating its DRM-KMS framebuffer object, receives the old-format modifier from Mesa, and attempts to create a framebuffer with it. Since the kernel is still not aware of these formats, this fails.Userspace should not be attempting to query format modifiers of GBM buffers allocated with a non- format-modifier-aware allocation path, but to avoid breaking existing userspace behavior, this change accepts the old-style format modifiers when creating framebuffers and applying them to planes by translating them to the equivalent new-style modifier. To accomplish this, some layout parameters must be assumed to match properties of the device targeted by the relevant ioctls. To avoid perpetuating misuse of the old-style modifiers, this change does not advertise support for them. Doing so would imply compatibility between devices with incompatible memory layouts.
Tested with Xorg 1.20 modesetting driver, weston@c46c70dac84a4b3030cd05b380f9f410536690fc, gnome & KDE wayland desktops from Ubuntu 18.04, and sway 1.5
Reported-by Kirill A. Shutemov <[email protected]>Fixes fa4f4c213f5f ("drm/nouveau/kms: Support NVIDIA format modifiers")Signed-off-by James Jones <[email protected]>--- drivers/gpu/drm/nouveau/nouveau_display.c | 26 +++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)drivers/gpu/drm/nouveau/nouveau_display.c +0
-0drivers/gpu/drm/nouveau/nouveau_display.c nouveau_decode_mod(struct nouveau_drm *drm, · line 200
Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_display.c +5
-0@@ -191,8 +191,14 @@ nouveau_decode_mod(struct nouveau_drm *drm,uint32_t *tile_mode, uint8_t *kind) { + struct nouveau_display *disp = nouveau_display(drm->dev);BUG_ON (!tile_mode || !kind); +if ((modifier & (0xffull <<12 )) ==0ull ) { +/* Legacy modifier. Translate to this device's 'kind.' */ + modifier |= disp->format_modifiers[0 ] & (0xffull <<12 ); + }I believe this should be moved into the !=
MOD_LINEARcase.
Quoted 6 lines
Quoted 2 lines
Yes, of course, thanks. I need to re-evaluate my testing yet again to make sure I hit that case too. Preparing a v3...
Going to need something here in the next day, two max.
Linus may wait for another week, but it's not guaranteed.
I tested a whole bunch of GPUs before sending nouveau's -next tree, and with the change I suggested to this patch + the other stuff I sent through -fixes already, things seemed to be in OK shape.
Ben.
Quoted 2 lines
Dave.
Quoted 77 lines · Ben Skeggs
Quoted 76 lines · Dave Airlie
Quoted 73 lines · James Jones
Quoted 63 lines · Ben Skeggs
Quoted 62 lines · James Jones
Accept the
DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK()family of modifiers to handle broken userspace Xorg modesetting and Mesa drivers. Existing Mesa drivers are still aware of only these older format modifiers which do not differentiate between different variations of the block linear layout. When the format modifier support flag was flipped in the nouveau kernel driver, the X.org modesetting driver began attempting to use its format modifier-enabled framebuffer path. Because the set of format modifiers advertised by the kernel prior to this change do not intersect with the set of format modifiers advertised by Mesa, allocating GBM buffers using format modifiers fails and the modesetting driver falls back to non-modifier allocation. However, it still later queries the modifier of the GBM buffer when creating its DRM-KMS framebuffer object, receives the old-format modifier from Mesa, and attempts to create a framebuffer with it. Since the kernel is still not aware of these formats, this fails.Userspace should not be attempting to query format modifiers of GBM buffers allocated with a non- format-modifier-aware allocation path, but to avoid breaking existing userspace behavior, this change accepts the old-style format modifiers when creating framebuffers and applying them to planes by translating them to the equivalent new-style modifier. To accomplish this, some layout parameters must be assumed to match properties of the device targeted by the relevant ioctls. To avoid perpetuating misuse of the old-style modifiers, this change does not advertise support for them. Doing so would imply compatibility between devices with incompatible memory layouts.
Tested with Xorg 1.20 modesetting driver, weston@c46c70dac84a4b3030cd05b380f9f410536690fc, gnome & KDE wayland desktops from Ubuntu 18.04, and sway 1.5
Reported-by Kirill A. Shutemov <[email protected]>Fixes fa4f4c213f5f ("drm/nouveau/kms: Support NVIDIA format modifiers")Signed-off-by James Jones <[email protected]>--- drivers/gpu/drm/nouveau/nouveau_display.c | 26 +++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)drivers/gpu/drm/nouveau/nouveau_display.c +1
-0@@ -191,8 +191,14 @@ nouveau_decode_mod(struct nouveau_drm *drm,uint32_t *tile_mode, uint8_t *kind) { + struct nouveau_display *disp = nouveau_display(drm->dev);BUG_ON (!tile_mode || !kind);Quoted 5 lines
drivers/gpu/drm/nouveau/nouveau_display.c nouveau_decode_mod(struct nouveau_drm *drm, · line 200
Quoted 4 lines
drivers/gpu/drm/nouveau/nouveau_display.c +4
-0+if ((modifier & (0xffull <<12 )) ==0ull ) { +/* Legacy modifier. Translate to this device's 'kind.' */ + modifier |= disp->format_modifiers[0 ] & (0xffull <<12 ); + }I believe this should be moved into the !=
MOD_LINEARcase.Yes, of course, thanks. I need to re-evaluate my testing yet again to make sure I hit that case too. Preparing a v3...
Quoted 6 lines
Quoted 3 lines
Going to need something here in the next day, two max.
Linus may wait for another week, but it's not guaranteed.
I tested a whole bunch of GPUs before sending nouveau's -next tree, and with the change I suggested to this patch + the other stuff I sent through -fixes already, things seemed to be in OK shape.
JFYI, the adjusted (moved into != MOD_LINEAR case) patch works fine for me on top of drm-fixes-2020-07-29.
Signature · 1 line
Kirill A. Shutemov
Quoted 80 lines · Kirill A. Shutemov
Quoted 79 lines · Ben Skeggs
Quoted 78 lines · Dave Airlie
Quoted 65 lines · James Jones
Quoted 63 lines · Ben Skeggs
Quoted 62 lines · James Jones
Accept the
DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK()family of modifiers to handle broken userspace Xorg modesetting and Mesa drivers. Existing Mesa drivers are still aware of only these older format modifiers which do not differentiate between different variations of the block linear layout. When the format modifier support flag was flipped in the nouveau kernel driver, the X.org modesetting driver began attempting to use its format modifier-enabled framebuffer path. Because the set of format modifiers advertised by the kernel prior to this change do not intersect with the set of format modifiers advertised by Mesa, allocating GBM buffers using format modifiers fails and the modesetting driver falls back to non-modifier allocation. However, it still later queries the modifier of the GBM buffer when creating its DRM-KMS framebuffer object, receives the old-format modifier from Mesa, and attempts to create a framebuffer with it. Since the kernel is still not aware of these formats, this fails.Userspace should not be attempting to query format modifiers of GBM buffers allocated with a non- format-modifier-aware allocation path, but to avoid breaking existing userspace behavior, this change accepts the old-style format modifiers when creating framebuffers and applying them to planes by translating them to the equivalent new-style modifier. To accomplish this, some layout parameters must be assumed to match properties of the device targeted by the relevant ioctls. To avoid perpetuating misuse of the old-style modifiers, this change does not advertise support for them. Doing so would imply compatibility between devices with incompatible memory layouts.
Tested with Xorg 1.20 modesetting driver, weston@c46c70dac84a4b3030cd05b380f9f410536690fc, gnome & KDE wayland desktops from Ubuntu 18.04, and sway 1.5
Reported-by Kirill A. Shutemov <[email protected]>Fixes fa4f4c213f5f ("drm/nouveau/kms: Support NVIDIA format modifiers")Signed-off-by James Jones <[email protected]>--- drivers/gpu/drm/nouveau/nouveau_display.c | 26 +++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-)drivers/gpu/drm/nouveau/nouveau_display.c +1
-0@@ -191,8 +191,14 @@ nouveau_decode_mod(struct nouveau_drm *drm,uint32_t *tile_mode, uint8_t *kind) { + struct nouveau_display *disp = nouveau_display(drm->dev);BUG_ON (!tile_mode || !kind);Quoted 8 lines
Quoted 5 lines
drivers/gpu/drm/nouveau/nouveau_display.c nouveau_decode_mod(struct nouveau_drm *drm, · line 200
Quoted 4 lines
drivers/gpu/drm/nouveau/nouveau_display.c +4
-0+if ((modifier & (0xffull <<12 )) ==0ull ) { +/* Legacy modifier. Translate to this device's 'kind.' */ + modifier |= disp->format_modifiers[0 ] & (0xffull <<12 ); + }I believe this should be moved into the !=
MOD_LINEARcase.Yes, of course, thanks. I need to re-evaluate my testing yet again to make sure I hit that case too. Preparing a v3...
Going to need something here in the next day, two max.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Linus may wait for another week, but it's not guaranteed.
I tested a whole bunch of GPUs before sending nouveau's -next tree, and with the change I suggested to this patch + the other stuff I sent through -fixes already, things seemed to be in OK shape.
JFYI, the adjusted (moved into !=
MOD_LINEARcase) patch works fine for me on top of drm-fixes-2020-07-29.
Sorry again for the delays (life is terrible lately), but the signed-off version with Ben's suggestion went out this morning, and I specifically tested linear modifiers in addition to retesting all the other test cases mentioned in the patch.
Thanks,
-James