Fix crash when page flipping in multi-X-Screen/Zaphod mode
PATCH 1/1 Fix crash when page flipping in multi-X-Screen/Zaphod mode
radeon_do_pageflip() indexed the flipdata->fb[] array indexing over config->num_crtc, but the flip completion routines, e.g., drmmode_flip_handler(), index that array via the crtc hw id from drmmode_get_crtc_id(crtc).
This is mismatched and causes indexing into the wrong array slot at flip completion -> Server crash.
Always use drmmode_get_crtc_id(crtc) for indexing into the array to fix this.
Tested on a dual-X-Screen setup with one video output assigned to each X-Screen, page-flipping an OpenGL app on either of both X-Screens. This used to crash when flipping on X-Screen 1, now it doesn't anymore.
This patch needs to be ported to amdgpu-ddx as well, which suffers the same bug.
--- src/drmmode_display.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
src/drmmode_display.c +9 -7
@@ -3297,6 +3297,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,xf86CrtcConfigPtr config =XF86_CRTC_CONFIG_PTR (scrn);xf86CrtcPtr crtc =NULL ;drmmode_crtc_private_ptr drmmode_crtc = config->crtc[0 ]->driver_private; +int crtc_id;uint32_t flip_flags = flip_sync ==FLIP_ASYNC ?DRM_MODE_PAGE_FLIP_ASYNC :0 ;drmmode_flipdata_ptr flipdata;Bool handle_deferred = FALSE;
@@ -3304,7 +3305,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,struct drmmode_fb *fb;int i =0 ; - flipdata =calloc (1 ,sizeof (*flipdata) + config->num_crtc * + flipdata =calloc (1 ,sizeof (*flipdata) + drmmode_crtc->drmmode->count_crtcs *sizeof (flipdata->fb[0 ]));if (!flipdata) { xf86DrvMsg(scrn->scrnIndex, X_WARNING,
@@ -3336,6 +3337,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,for (i =0 ; i < config->num_crtc; i++) { crtc = config->crtc[i]; drmmode_crtc = crtc->driver_private; + crtc_id =drmmode_get_crtc_id (crtc);if (!drmmode_crtc_can_flip (crtc) || (drmmode_crtc->tear_free && crtc != ref_crtc))
@@ -3369,9 +3371,9 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, goto next; } -drmmode_fb_reference (pRADEONEnt->fd, &flipdata->fb[i], +drmmode_fb_reference (pRADEONEnt->fd, &flipdata->fb[crtc_id],radeon_pixmap_get_fb (drmmode_crtc->scanout[scanout_id].pixmap)); -if (!flipdata->fb[i]) { +if (!flipdata->fb[crtc_id]) {ErrorF ("Failed to get FB for TearFree flip\n" ); goto error; }
@@ -3387,13 +3389,13 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, drmmode_crtc->scanout_update_pending =0 ; } }else { -drmmode_fb_reference (pRADEONEnt->fd, &flipdata->fb[i], fb); +drmmode_fb_reference (pRADEONEnt->fd, &flipdata->fb[crtc_id], fb); }if (crtc == ref_crtc) {if (drmmode_page_flip_target_absolute (pRADEONEnt, drmmode_crtc, - flipdata->fb[i]->handle, + flipdata->fb[crtc_id]->handle, flip_flags, drm_queue_seq, target_msc) !=0 )
@@ -3401,7 +3403,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, }else {if (drmmode_page_flip_target_relative (pRADEONEnt, drmmode_crtc, - flipdata->fb[i]->handle, + flipdata->fb[crtc_id]->handle, flip_flags, drm_queue_seq,0 ) !=0 ) goto flip_error;
@@ -3414,7 +3416,7 @@ Bool radeon_do_pageflip(ScrnInfoPtr scrn, ClientPtr client, next:drmmode_fb_reference (pRADEONEnt->fd, &drmmode_crtc->flip_pending, - flipdata->fb[i]); + flipdata->fb[crtc_id]); drm_queue_seq =0 ; }
Signature · 6 lines
2.7.4 _______________________________________________ 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): 20181218104035.3708-1-mario.kleiner.de-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Michel Dänzer
Reviewed-byQuoted 16 lines · Mario Kleiner
radeon_do_pageflip()indexed the flipdata->fb[] array indexing overconfig->num_crtc, but the flip completion routines, e.g.,drmmode_flip_handler(), index that array via the crtc hw id fromdrmmode_get_crtc_id(crtc).This is mismatched and causes indexing into the wrong array slot at flip completion -> Server crash.
Always use
drmmode_get_crtc_id(crtc)for indexing into the array to fix this.Tested on a dual-X-Screen setup with one video output assigned to each X-Screen, page-flipping an OpenGL app on either of both X-Screens. This used to crash when flipping on X-Screen 1, now it doesn't anymore.
Quoted 4 lines
This patch needs to be ported to amdgpu-ddx as well, which suffers the same bug.
Signed-off-by Mario Kleiner <[email protected]>
Good catch, thanks! Pushed with
Do you want to make an xf86-video-amdgpu merge request as well? If not, I can take care of porting the fix. If you do it, please enable the "Allow commits from members who can merge to the target branch" checkbox for the MR.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ 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): 1458bf4e-e9be-01e1-940a-f45352ce74df-otUistvHUpPR7s880joybQ@public.gmane.org
Quoted 4 lines · Michel Dänzer
Good catch, thanks! Pushed with
Quoted 9 lines
Fixes 740f0850f1e4 "Store FB for each CRTC in drmmode_flipdata_rec"Reviewed-by Michel Dänzer <[email protected]>Do you want to make an xf86-video-amdgpu merge request as well? If not, I can take care of porting the fix. If you do it, please enable the "Allow commits from members who can merge to the target branch" checkbox for the MR.
Hi Michel,
thanks for the fast review! If you could port it to amdgpu, that would be good. I first have to learn the new gitlab workflow and find out how those merge requests work.
Thanks,
-mario
Quoted 4 lines
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 14 lines · Mario Kleiner
Quoted 12 lines · Michel Dänzer
Good catch, thanks! Pushed with
Fixes 740f0850f1e4 "Store FB for each CRTC in drmmode_flipdata_rec"Reviewed-by Michel Dänzer <[email protected]>Do you want to make an xf86-video-amdgpu merge request as well? If not, I can take care of porting the fix. If you do it, please enable the "Allow commits from members who can merge to the target branch" checkbox for the MR.
Quoted 5 lines
Hi Michel,
thanks for the fast review! If you could port it to amdgpu, that would be good. I first have to learn the new gitlab workflow and find out how those merge requests work.
It's easy:
Click the "Fork" button on
https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu to create your personal repository.
Push the change(s) to be part of the merge request (MR) to a new branch in your personal repository. The terminal output of git push should contain an URL for creating a merge request for the new branch.
Make sure the "Allow commits from members who can merge to the target branch" box is checked. I usually check the "Remove source branch when merge request is accepted" box as well.
Once the MR is created, make sure the CI pipeline passes, or investigate and fix any failures.
The MR page has a button for rebasing the branch if needed. If you need to make any other modifications to the commits, just (force-)push to the same branch again and reload the MR page.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 2 lines · Michel Dänzer
Do you want to make an xf86-video-amdgpu merge request as well? If not, I can take care of porting the fix. If you do it, please enable the
Ok Michel, spent some more time. Patch for amdgpu-ddx should be out as well via good ol' e-mail.
This one is successfully tested on a Polaris11 4-display setup with 4 separate X-Screens, so we know that the new > 2 X-Screens code works as well :)
thanks,
-mario
Quoted 7 lines
"Allow commits from members who can merge to the target branch" checkbox for the MR.
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx