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
--- src/drmmode_display.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
src/drmmode_display.c +15 -8
@@ -1194,14 +1194,20 @@ drmmode_show_cursor (xf86CrtcPtr crtc) info->cursor_w, info->cursor_h); } +/* 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
@@ -1209,11 +1215,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): 20170228085939.24243-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.
--- src/drmmode_display.c | 65 +++++++++++++++------------------------------------ 1 file changed, 19 insertions(+), 46 deletions(-)
src/drmmode_display.c +19 -46
@@ -550,10 +550,9 @@ 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;RADEONInfoPtr info =RADEONPTR (pScrn);
@@ -561,11 +560,11 @@ drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc,drmmode_ptr drmmode = drmmode_crtc->drmmode;struct radeon_surface surface;uint32_t tiling =RADEON_CREATE_PIXMAP_TILING_MACRO ; -int ret; +int pitch; -if (scanout->bo) { +if (scanout->pixmap) {if (scanout->width == width && scanout->height == height) -return scanout->bo->ptr; +return scanout->pixmap;drmmode_crtc_scanout_destroy (drmmode, scanout); }
@@ -574,48 +573,16 @@ drmmode_crtc_scanout_allocate(xf86CrtcPtr crtc, tiling |=RADEON_CREATE_PIXMAP_TILING_MICRO ; scanout->bo =radeon_alloc_pixmap_bo (pScrn, width, height, pScrn->depth, tiling, pScrn->bitsPerPixel, - pitch, &surface, &tiling); + &pitch, &surface, &tiling);if (scanout->bo ==NULL ) -return NULL ; - -radeon_bo_map (scanout->bo,1 ); + goto error; - ret =drmModeAddFB (drmmode->fd, width, height, pScrn->depth, - pScrn->bitsPerPixel, *pitch, +if (drmModeAddFB (drmmode->fd, width, height, pScrn->depth, + pScrn->bitsPerPixel, pitch, scanout->bo->handle, - &scanout->fb_id); -if (ret) { + &scanout->fb_id) !=0 ) {ErrorF ("failed to add scanout fb\n" ); -radeon_bo_unref (scanout->bo); - scanout->bo =NULL ; -return NULL ; - } - - scanout->width = width; - scanout->height = height; -return scanout->bo->ptr; -} - -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 ; + goto error; } scanout->pixmap = drmmode_create_bo_pixmap(pScrn,
@@ -623,9 +590,15 @@ drmmode_crtc_scanout_create(xf86CrtcPtr crtc, struct drmmode_scanout *scanout, pScrn->depth, pScrn->bitsPerPixel, pitch, scanout->bo, NULL); -if (scanout->pixmap ==NULL ) +if (scanout->pixmap) { + scanout->width = width; + scanout->height = height; + }else {xf86DrvMsg (pScrn->scrnIndex,X_ERROR ,"Couldn't allocate scanout pixmap for CRTC\n" ); +error: +drmmode_crtc_scanout_destroy (drmmode, scanout); + }return scanout->pixmap; }
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.
--- src/drmmode_display.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
src/drmmode_display.c +5 -8
@@ -673,23 +673,20 @@ drmmode_crtc_update_tear_free(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 -drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; -RADEONInfoPtr info =RADEONPTR (crtc->scrn); - - crtc->driverIsPerformingTransform = crtc->transformPresent || - (drmmode_crtc->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): 20170228085939.24243-3-michel-otUistvHUpPR7s880joybQ@public.gmane.org
Alex Deucher
Reviewed-byRe: [PATCH xf86-video-ati 3/3] Handle rotation in the driver also with Xorg 1.12-1.18
Quoted 6 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.
Signed-off-by Michel Dänzer <[email protected]>
Series is:
Quoted 40 lines
--- src/drmmode_display.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)src/drmmode_display.c +5
-9@@ -673,23 +673,20 @@ drmmode_crtc_update_tear_free(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 -drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; -RADEONInfoPtr info =RADEONPTR (crtc->scrn); - - crtc->driverIsPerformingTransform = crtc->transformPresent || - (drmmode_crtc->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