xf86-video-intel: 3 commits - src/intel_display.c src/intel_dri.c src/intel.h
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Keith,
a couple suggestions below from a quick look over these patches.
Quoted 16 lines · Keith Packard
commit
e1ff5182304e00c0d392092069422cae7626cf8dAuthor: Keith Packard <[email protected]> Date: Wed Mar 9 17:00:41 2011 -0800Handle drawable/client destruction in pending swaps/flips
A pending swap or flip holds references to drawables and clients which become invalid when destroyed. Add suitable resources to the database to track those lifetimes and clean up the pending data structure then.
Later, when the pending swap or flip occurs, handle a missing drawable by just discarding the flip or swap. Handle a missing client by not sending an event or reply.
Signed-off-by Keith Packard <[email protected]>
[...]
src/intel_display.c static const xf86CrtcConfigFuncsRec intel_xf86crtc_config_funcs = { · line 1515
Quoted 10 lines
src/intel_display.c +1
-1@@ -1512,7 +1512,7 @@ static const xf86CrtcConfigFuncsRec intel_xf86crtc_config_funcs = {static void intel_vblank_handler (int fd,unsigned int frame,unsigned int tv_sec, -unsigned int tv_usec,DRI2FrameEventPtr event) +unsigned int tv_usec,void *event)
This seems to just revert a change from the previous commit?
Quoted 8 lines
src/intel_display.c +0
-0{I830DRI2FrameEventHandler (frame, tv_sec, tv_usec, event); }src/intel_dri.c +0
-0@@ -577,6 +577,69 @@ I830DRI2DrawablePipe(DrawablePtr pDraw)
[...]
Quoted 32 lines
src/intel_dri.c +28
-0+/* +* Hook this frame event into the server resource +* database so we can clean it up if the drawable or +* client exits while the swap is pending +*/ +static Bool +i830_dri2_add_frame_event (DRI2FrameEventPtr frame_event) +{ + frame_event->client_id =FakeClientID (frame_event->client->index); + +if (!AddResource (frame_event->client_id, frame_event_client_type, frame_event)) +return FALSE; + +if (!AddResource (frame_event->drawable_id, frame_event_drawable_type, frame_event)) +return FALSE; + +return TRUE; +} + +static void +i830_dri2_del_frame_event (DRI2FrameEventPtr frame_event) +{ +if (frame_event->client_id) +FreeResourceByType (frame_event->client_id, frame_event_client_type, FALSE); +if (frame_event->drawable_id) +FreeResourceByType (frame_event->drawable_id, frame_event_drawable_type, FALSE); +} +static void I830DRI2ExchangeBuffers (DrawablePtr draw,DRI2BufferPtr front,DRI2BufferPtr back)
src/intel_dri.c I830DRI2ScheduleFlip(struct intel_screen_private *intel, · line 709
Quoted 5 lines
src/intel_dri.c +2
-0@@ -642,11 +705,18 @@ I830DRI2ScheduleFlip(struct intel_screen_private *intel, flip_info->event_data = data; flip_info->frame = target_msc; +i830_dri2_add_frame_event (flip_info); +
if (!i830_dri_add_frame_event(flip_info))
return FALSE;
?
Quoted 16 lines
src/intel_dri.c +8
-3/* Page flip the full screen buffer */ back_priv = back->driverPrivate; -return intel_do_pageflip (intel, -intel_get_pixmap_bo (back_priv->pixmap), - flip_info, ref_crtc_hw_id); +if (intel_do_pageflip (intel, +intel_get_pixmap_bo (back_priv->pixmap), + flip_info, ref_crtc_hw_id)) +return TRUE; + +i830_dri2_del_frame_event (flip_info); +free (flip_info); +return FALSE; } static Bool
[...]
src/intel_dri.c I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front, · line 962
Quoted 6 lines
src/intel_dri.c +2
-0@@ -876,6 +958,8 @@ I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front,I830DRI2ReferenceBuffer (front);I830DRI2ReferenceBuffer (back); +i830_dri2_add_frame_event (swap_info); +
if (!i830_dri2_add_frame_event(swap_info)
goto blit_fallback;
?
src/intel_dri.c I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front, · line 965
Quoted 3 lines
src/intel_dri.c +0
-0/* Get current count */ vbl.request.type =DRM_VBLANK_RELATIVE ;if (pipe >0 )
[...]
Cheers,
Julien
Quoted 3 lines · Julien Cristau
Hi Keith,
a couple suggestions below from a quick look over these patches.
Thanks for your review!
Quoted 6 lines
Review
Quoted 4 lines
static void
intel_vblank_handler(int fd, unsigned int frame, unsigned inttv_sec,(quoted diff) +1
-1- unsigned int tv_usec, DRI2FrameEventPtr event) + unsigned int tv_usec, void *event)This seems to just revert a change from the previous commit?
Sadly, yes -- intel_vblank_handler gets stuffed into the event_context.vblank_handler callback slot which uses 'void *' in the function signature. As DRI2FrameEventPtr is a private type, we can't go fix the public drmEventContext type to match.
A cleaner patch sequence would have removed the change from both patches. Oops!
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ i830_dri2_add_frame_event(flip_info); +if (!i830_dri_add_frame_event(flip_info))
return FALSE;?
...
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ i830_dri2_add_frame_event(swap_info); +if (!i830_dri2_add_frame_event(swap_info)
goto blit_fallback;?
Good catch. Not quite that easy to fix; the swap_info needs to be freed, and a partial add_frame_event must clean up after itself.
src/intel_dri.c +11 -3
@@ -625,8 +625,10 @@ i830_dri2_add_frame_event(DRI2FrameEventPtr frame_event)if (!AddResource (frame_event->client_id, frame_event_client_type, frame_event))return FALSE; -if (!AddResource (frame_event->drawable_id, frame_event_drawable_type, frame_event)) +if (!AddResource (frame_event->drawable_id, frame_event_drawable_type, frame_event)) { +FreeResourceByType (frame_event->client_id, frame_event_client_type, TRUE);return FALSE; + }return TRUE; }
@@ -705,7 +707,10 @@ I830DRI2ScheduleFlip(struct intel_screen_private *intel, flip_info->event_data = data; flip_info->frame = target_msc; -i830_dri2_add_frame_event (flip_info); +if (!i830_dri2_add_frame_event (flip_info)) { +free (flip_info); +return FALSE; + }/* Page flip the full screen buffer */ back_priv = back->driverPrivate;
@@ -958,7 +963,10 @@ I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front,I830DRI2ReferenceBuffer (front);I830DRI2ReferenceBuffer (back); -i830_dri2_add_frame_event (swap_info); +if (!i830_dri2_add_frame_event (swap_info)) { +free (swap_info); + goto blit_fallback; + }/* Get current count */ vbl.request.type =DRM_VBLANK_RELATIVE ;
Signature · 1 line
[email protected]
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 29 lines · Keith Packard
src/intel_dri.c +7
-2@@ -625,8 +625,10 @@ i830_dri2_add_frame_event(DRI2FrameEventPtr frame_event)if (!AddResource (frame_event->client_id, frame_event_client_type, frame_event))return FALSE; -if (!AddResource (frame_event->drawable_id, frame_event_drawable_type, frame_event)) +if (!AddResource (frame_event->drawable_id, frame_event_drawable_type, frame_event)) { +FreeResourceByType (frame_event->client_id, frame_event_client_type, TRUE);return FALSE; + }return TRUE; }@@ -705,7 +707,10 @@ I830DRI2ScheduleFlip(struct intel_screen_private *intel, flip_info->event_data = data; flip_info->frame = target_msc; -i830_dri2_add_frame_event (flip_info); +if (!i830_dri2_add_frame_event (flip_info)) { +free (flip_info); +return FALSE; + }/* Page flip the full screen buffer */ back_priv = back->driverPrivate;
src/intel_dri.c I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front, · line 967
Quoted 6 lines
src/intel_dri.c +2
-1@@ -958,7 +963,10 @@ I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front,I830DRI2ReferenceBuffer (front);I830DRI2ReferenceBuffer (back); -i830_dri2_add_frame_event (swap_info); +if (!i830_dri2_add_frame_event (swap_info)) { +free (swap_info);
This will cause a double free as the blit_fallback path does it too.
src/intel_dri.c I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front, · line 972
Quoted 6 lines
src/intel_dri.c +2
-0+ goto blit_fallback; + }/* Get current count */ vbl.request.type =DRM_VBLANK_RELATIVE ;
Cheers,
Julien
Quoted 1 line · Julien Cristau
This will cause a double free as the
blit_fallbackpath does it too.
Argh! So we need to check before we reference the buffers and set swap_info to NULL. This code is too twisty...
@@ -955,11 +960,16 @@ I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front,
swap_info->event_data = data;
swap_info->front = front;
swap_info->back = back;
+
+ if (!i830_dri2_add_frame_event(swap_info)) {
+ free(swap_info);
+ swap_info = NULL;
+ goto blit_fallback;
+ }
+
I830DRI2ReferenceBuffer(front);
I830DRI2ReferenceBuffer(back);- i830_dri2_add_frame_event(swap_info);
-
/* Get current count */
vbl.request.type = DRM_VBLANK_RELATIVE;
if (pipe > 0)Signature · 1 line
[email protected]
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Julien Cristau
Reviewed-byQuoted 17 lines · Keith Packard
Quoted 1 line · Julien Cristau
This will cause a double free as the
blit_fallbackpath does it too.Argh! So we need to check before we reference the buffers and set
swap_infoto NULL. This code is too twisty...(quoted diff) +5
-0@@ -955,11 +960,16 @@ I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front, swap_info->event_data = data; swap_info->front = front; swap_info->back = back; + + if (!i830_dri2_add_frame_event(swap_info)) { + free(swap_info); + swap_info = NULL; + goto blit_fallback;
Review I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front, · line 975
Quoted 10 lines
(quoted diff) +2
-2+ } + I830DRI2ReferenceBuffer(front); I830DRI2ReferenceBuffer(back); - i830_dri2_add_frame_event(swap_info); - /* Get current count */ vbl.request.type = DRM_VBLANK_RELATIVE; if (pipe > 0)
With that change,
Thanks!
Julien
Quoted 2 lines · Julien Cristau
With that change,
Reviewed-by Julien Cristau <[email protected]>
Thanks for catching my bugs before they caused any damage...
Pushed.
ec133ab..7ccbec8 master -> master
Signature · 1 line
[email protected]
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx