Call drmmode_crtc_scanout_create in drmmode_crtc_shadow_allocate as well
PATCH 1/3 Call drmmode_crtc_scanout_create in drmmode_crtc_shadow_allocate as well
From: Michel Dänzer <[email protected]>
Calling drmmode_crtc_scanout_allocate in drmmode_crtc_shadow_allocate resulted in drmmode_crtc_scanout_create called from drmmode_crtc_shadow_create passing an uninitialized pitch value to drmmode_create_bo_pixmap.
Fixes issues such as failure to allocate the scanout pixmap or visual corruption and GPUVM faults when attempting to use rotation with Xorg <1.19.
Bugzilla: https://bugs.freedesktop.org/99916
drmmode_create_bo_pixmap")
(Ported from radeon commit 987a34adb319923ad36e2b47a26837248f187c3e)
--- src/drmmode_display.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
src/drmmode_display.c +17 -10
@@ -1047,14 +1047,20 @@ static void drmmode_show_cursor(xf86CrtcPtr crtc) info->cursor_w, info->cursor_h); } -static void *drmmode_crtc_shadow_allocate (xf86CrtcPtr crtc,int width, -int height) +/* Xorg expects a non-NULL return value from drmmode_crtc_shadow_allocate, and +* passes that back to drmmode_crtc_scanout_create; it doesn't use it for +* anything else. +*/ +static void * +drmmode_crtc_shadow_allocate (xf86CrtcPtr crtc,int width,int height) {drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; -int pitch; -return drmmode_crtc_scanout_allocate (crtc, &drmmode_crtc->rotate, - width, height, &pitch); +if (!drmmode_crtc_scanout_create (crtc, &drmmode_crtc->rotate, width, + height)) +return NULL ; + +return (void *)~0UL ; } static PixmapPtr
@@ -1062,11 +1068,12 @@ drmmode_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height) {drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; -/* Xorg passes in the return value of drmmode_crtc_shadow_allocate -* for data, but that's redundant for drmmode_crtc_scanout_create. -*/ -return drmmode_crtc_scanout_create (crtc, &drmmode_crtc->rotate, width, - height); +if (!data) { +drmmode_crtc_scanout_create (crtc, &drmmode_crtc->rotate, width, + height); + } + +return drmmode_crtc->rotate.pixmap; } static void
Signature · 6 lines
2.11.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20170302075942.7109-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org
PATCH 2/3 Fold drmmode_crtc_scanout_allocate into drmmode_crtc_scanout_create
From: Michel Dänzer <[email protected]>
Not used anywhere else anymore.
(Ported from radeon commit ae921a3150f69c38b5b3c88a9e37d54fdf0d5093)
--- src/drmmode_display.c | 71 ++++++++++++++++----------------------------------- 1 file changed, 22 insertions(+), 49 deletions(-)
src/drmmode_display.c +22 -49
@@ -494,71 +494,39 @@ drmmode_scanout_free(ScrnInfoPtr scrn)drmmode_crtc_scanout_free (xf86_config->crtc[c]->driver_private); } -static void * -drmmode_crtc_scanout_allocate (xf86CrtcPtr crtc, -struct drmmode_scanout *scanout, -int width,int height,int *pitch) +static PixmapPtr +drmmode_crtc_scanout_create (xf86CrtcPtr crtc,struct drmmode_scanout *scanout, +int width,int height) {ScrnInfoPtr pScrn = crtc->scrn;AMDGPUEntPtr pAMDGPUEnt =AMDGPUEntPriv (pScrn);drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;drmmode_ptr drmmode = drmmode_crtc->drmmode; -int ret;union gbm_bo_handle bo_handle; +int pitch; -if (scanout->bo) { +if (scanout->pixmap) {if (scanout->width == width && scanout->height == height) -return scanout->bo; +return scanout->pixmap;drmmode_crtc_scanout_destroy (drmmode, scanout); } scanout->bo =amdgpu_alloc_pixmap_bo (pScrn, width, height, pScrn->depth,0 , - pScrn->bitsPerPixel, pitch); + pScrn->bitsPerPixel, &pitch);if (!scanout->bo) {xf86DrvMsg (pScrn->scrnIndex,X_ERROR , -"Failed to allocate rotation buffer memory\n" ); -return NULL ; +"Failed to allocate scanout buffer memory\n" ); + goto error; } bo_handle =gbm_bo_get_handle (scanout->bo->bo.gbm); - ret =drmModeAddFB (pAMDGPUEnt->fd, width, height, pScrn->depth, - pScrn->bitsPerPixel, *pitch, - bo_handle.u32, &scanout->fb_id); -if (ret) { -ErrorF ("failed to add rotate fb\n" ); -amdgpu_bo_unref (&scanout->bo); - scanout->bo =NULL ; -return NULL ; - } - - scanout->width = width; - scanout->height = height; -return scanout->bo; -} - -static PixmapPtr -drmmode_crtc_scanout_create (xf86CrtcPtr crtc, -struct drmmode_scanout *scanout, -int width,int height) -{ -ScrnInfoPtr pScrn = crtc->scrn; -drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; -drmmode_ptr drmmode = drmmode_crtc->drmmode; -int pitch; - -if (scanout->pixmap) { -if (scanout->width == width && scanout->height == height) -return scanout->pixmap; - -drmmode_crtc_scanout_destroy (drmmode, scanout); - } - -if (!scanout->bo) { -if (!drmmode_crtc_scanout_allocate (crtc, scanout, width, height, - &pitch)) -return NULL ; +if (drmModeAddFB (pAMDGPUEnt->fd, width, height, pScrn->depth, + pScrn->bitsPerPixel, pitch, + bo_handle.u32, &scanout->fb_id) !=0 ) { +ErrorF ("failed to add scanout fb\n" ); + goto error; } scanout->pixmap = drmmode_create_bo_pixmap(pScrn,
@@ -566,12 +534,17 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc, pScrn->depth, pScrn->bitsPerPixel, pitch, scanout->bo); -if (scanout->pixmap ==NULL ) { +if (scanout->pixmap) { + scanout->width = width; + scanout->height = height; + }else {xf86DrvMsg (pScrn->scrnIndex,X_ERROR , -"Couldn't allocate shadow pixmap for rotated CRTC\n" ); +"Couldn't allocate scanout pixmap for CRTC\n" ); +error: +drmmode_crtc_scanout_destroy (drmmode, scanout); } -return scanout->pixmap; +return scanout->pixmap; } static void
Signature · 6 lines
2.11.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/3 Handle rotation in the driver also with Xorg 1.12-1.18
In reply to a message not in the archiveFrom: Michel Dänzer <[email protected]>
We cannot use the HW cursor in that case, but in turn we get more efficient and less teary updates of rotated outputs.
(Ported from radeon commit f2bc882f1c1082bed9f496cfab6c8f07a76bc122)
--- src/drmmode_display.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
src/drmmode_display.c +5 -7
@@ -589,22 +589,20 @@ drmmode_can_use_hw_cursor(xf86CrtcPtr crtc)#if XF86_CRTC_VERSION >=4 +#if XF86_CRTC_VERSION <7 +#define XF86DriverTransformOutput TRUE +#define XF86DriverTransformNone FALSE +#endif +static Bool drmmode_handle_transform (xf86CrtcPtr crtc) {Bool ret; -#if XF86_CRTC_VERSION >=7 if (crtc->transformPresent || crtc->rotation != RR_Rotate_0) crtc->driverIsPerformingTransform = XF86DriverTransformOutput;else crtc->driverIsPerformingTransform = XF86DriverTransformNone; -#else -AMDGPUInfoPtr info =AMDGPUPTR (crtc->scrn); - - crtc->driverIsPerformingTransform = crtc->transformPresent || - (info->tear_free && crtc->rotation != RR_Rotate_0); -#endif ret =xf86CrtcRotate (crtc);
Signature · 6 lines
2.11.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20170302075942.7109-3-michel-otUistvHUpPR7s880joybQ@public.gmane.org
Alex Deucher
Reviewed-byRe: [PATCH xf86-video-amdgpu 3/3] Handle rotation in the driver also with Xorg 1.12-1.18
Quoted 8 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
We cannot use the HW cursor in that case, but in turn we get more efficient and less teary updates of rotated outputs.
(Ported from radeon commit
f2bc882f1c1082bed9f496cfab6c8f07a76bc122)Signed-off-by Michel Dänzer <[email protected]>
Series is:
Quoted 39 lines
--- src/drmmode_display.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)src/drmmode_display.c +5
-8@@ -589,22 +589,20 @@ drmmode_can_use_hw_cursor(xf86CrtcPtr crtc)#if XF86_CRTC_VERSION >=4 +#if XF86_CRTC_VERSION <7 +#define XF86DriverTransformOutput TRUE +#define XF86DriverTransformNone FALSE +#endif +static Bool drmmode_handle_transform (xf86CrtcPtr crtc) {Bool ret; -#if XF86_CRTC_VERSION >=7 if (crtc->transformPresent || crtc->rotation != RR_Rotate_0) crtc->driverIsPerformingTransform = XF86DriverTransformOutput;else crtc->driverIsPerformingTransform = XF86DriverTransformNone; -#else -AMDGPUInfoPtr info =AMDGPUPTR (crtc->scrn); - - crtc->driverIsPerformingTransform = crtc->transformPresent || - (info->tear_free && crtc->rotation != RR_Rotate_0); -#endif ret =xf86CrtcRotate (crtc); --2.11.0
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx