diff options
author | Keith Packard <keithp@keithp.com> | 2013-11-19 23:20:38 -0800 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2014-06-02 08:32:11 +0100 |
commit | 14ff08c2827d36f7f08256dc57b84aaf80d17ab4 (patch) | |
tree | c8ba4be380e34b6a720faa2b1e008c54e5c8287f | |
parent | 7f28b1cfa20eb4fc11c1a9c1e0c0fac7847be72e (diff) |
uxa: Restructure DRM event handling.
This refactors the drm interrupt handling logic quite a bit, both to
allow for either DRI2 or Present handlers, but also to eliminate
passing pointers through the kernel. Passing pointers left the kernel
holding the only reference to some internal X server data structures.
After a server reset, the X server would end up using stale pointers
stored in those structures. Using simple integers makes it possible to
empty the queue of pending interrupt data and then ignore the stale
kernel data.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
-rw-r--r-- | src/uxa/intel.h | 26 | ||||
-rw-r--r-- | src/uxa/intel_display.c | 306 | ||||
-rw-r--r-- | src/uxa/intel_dri.c | 98 |
3 files changed, 376 insertions, 54 deletions
diff --git a/src/uxa/intel.h b/src/uxa/intel.h index 1d641f26..6366db44 100644 --- a/src/uxa/intel.h +++ b/src/uxa/intel.h @@ -407,6 +407,20 @@ extern void intel_mode_disable_unused_functions(ScrnInfoPtr scrn); extern void intel_mode_remove_fb(intel_screen_private *intel); extern void intel_mode_close(intel_screen_private *intel); extern void intel_mode_fini(intel_screen_private *intel); +extern int intel_mode_read_drm_events(intel_screen_private *intel); + +typedef void (*intel_drm_handler_proc)(ScrnInfoPtr scrn, + xf86CrtcPtr crtc, + uint64_t seq, + uint64_t usec, + void *data); + +typedef void (*intel_drm_abort_proc)(ScrnInfoPtr scrn, + xf86CrtcPtr crtc, + void *data); + +extern uint32_t intel_drm_queue_alloc(ScrnInfoPtr scrn, xf86CrtcPtr crtc, void *data, intel_drm_handler_proc handler, intel_drm_abort_proc abort); +extern void intel_drm_abort(ScrnInfoPtr scrn, Bool (*match)(void *data, void *match_data), void *match_data); extern int intel_get_pipe_from_crtc_id(drm_intel_bufmgr *bufmgr, xf86CrtcPtr crtc); extern int intel_crtc_id(xf86CrtcPtr crtc); @@ -434,6 +448,12 @@ typedef void (*DRI2SwapEventPtr)(ClientPtr client, void *data, int type, CARD64 ust, CARD64 msc, CARD64 sbc); #endif +typedef void (*intel_pageflip_handler_proc) (uint64_t frame, + uint64_t usec, + void *data); + +typedef void (*intel_pageflip_abort_proc) (void *data); + typedef struct _DRI2FrameEvent { struct intel_screen_private *intel; @@ -456,7 +476,11 @@ typedef struct _DRI2FrameEvent { extern Bool intel_do_pageflip(intel_screen_private *intel, dri_bo *new_front, - DRI2FrameEventPtr flip_info, int ref_crtc_hw_id); + int ref_crtc_hw_id, + Bool async, + void *pageflip_data, + intel_pageflip_handler_proc pageflip_handler, + intel_pageflip_abort_proc pageflip_abort); static inline intel_screen_private * intel_get_screen_private(ScrnInfoPtr scrn) diff --git a/src/uxa/intel_display.c b/src/uxa/intel_display.c index dac1a821..4a41d4d1 100644 --- a/src/uxa/intel_display.c +++ b/src/uxa/intel_display.c @@ -61,6 +61,22 @@ #define KNOWN_MODE_FLAGS ((1<<14)-1) +struct intel_drm_queue { + struct list list; + xf86CrtcPtr crtc; + uint32_t seq; + void *data; + ScrnInfoPtr scrn; + intel_drm_handler_proc handler; + intel_drm_abort_proc abort; +}; + +static void +intel_drm_abort_scrn(ScrnInfoPtr scrn); + +static uint32_t intel_drm_seq; +static struct list intel_drm_queue; + struct intel_mode { int fd; uint32_t fb_id; @@ -68,14 +84,17 @@ struct intel_mode { int cpp; drmEventContext event_context; - DRI2FrameEventPtr flip_info; int old_fb_id; int flip_count; uint64_t fe_msc; - uint64_t fe_usec; + uint64_t fe_usec; struct list outputs; struct list crtcs; + + void *pageflip_data; + intel_pageflip_handler_proc pageflip_handler; + intel_pageflip_abort_proc pageflip_abort; }; struct intel_pageflip { @@ -361,6 +380,7 @@ intel_crtc_apply(xf86CrtcPtr crtc) if (scrn->pScreen) xf86_reload_cursors(scrn->pScreen); + intel_drm_abort_scrn(scrn); done: free(output_ids); @@ -1459,10 +1479,27 @@ fail: return FALSE; } +static void +intel_pageflip_handler(ScrnInfoPtr scrn, xf86CrtcPtr crtc, + uint64_t frame, uint64_t usec, void *data); + +static void +intel_pageflip_abort(ScrnInfoPtr scrn, xf86CrtcPtr crtc, void *data); + +static void +intel_pageflip_complete(struct intel_mode *mode); + +static void +intel_drm_abort_seq (ScrnInfoPtr scrn, uint32_t seq); + Bool intel_do_pageflip(intel_screen_private *intel, dri_bo *new_front, - DRI2FrameEventPtr flip_info, int ref_crtc_hw_id) + int ref_crtc_hw_id, + Bool async, + void *pageflip_data, + intel_pageflip_handler_proc pageflip_handler, + intel_pageflip_abort_proc pageflip_abort) { ScrnInfoPtr scrn = intel->scrn; xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); @@ -1471,6 +1508,8 @@ intel_do_pageflip(intel_screen_private *intel, unsigned int pitch = scrn->displayWidth * intel->cpp; struct intel_pageflip *flip; uint32_t new_fb_id; + uint32_t flags; + uint32_t seq; int i; /* @@ -1485,6 +1524,10 @@ intel_do_pageflip(intel_screen_private *intel, intel_glamor_flush(intel); intel_batch_submit(scrn); + mode->pageflip_data = pageflip_data; + mode->pageflip_handler = pageflip_handler; + mode->pageflip_abort = pageflip_abort; + /* * Queue flips on all enabled CRTCs * Note that if/when we get per-CRTC buffers, we'll have to update this. @@ -1497,13 +1540,13 @@ intel_do_pageflip(intel_screen_private *intel, mode->fe_msc = 0; mode->fe_usec = 0; + flags = DRM_MODE_PAGE_FLIP_EVENT; + if (async) + flags |= DRM_MODE_PAGE_FLIP_ASYNC; for (i = 0; i < config->num_crtc; i++) { if (!intel_crtc_on(config->crtc[i])) continue; - mode->flip_info = flip_info; - mode->flip_count++; - crtc = config->crtc[i]->driver_private; flip = calloc(1, sizeof(struct intel_pageflip)); @@ -1519,19 +1562,38 @@ intel_do_pageflip(intel_screen_private *intel, flip->dispatch_me = (intel_crtc_to_pipe(crtc->crtc) == ref_crtc_hw_id); flip->mode = mode; + seq = intel_drm_queue_alloc(scrn, config->crtc[i], flip, intel_pageflip_handler, intel_pageflip_abort); + if (!seq) { + free(flip); + goto error_undo; + } + +again: if (drmModePageFlip(mode->fd, crtc_id(crtc), new_fb_id, - DRM_MODE_PAGE_FLIP_EVENT, flip)) { + flags, (void *)(uintptr_t)seq)) { + if (intel_mode_read_drm_events(intel)) { + xf86DrvMsg(scrn->scrnIndex, X_WARNING, + "flip queue retry\n"); + goto again; + } xf86DrvMsg(scrn->scrnIndex, X_WARNING, "flip queue failed: %s\n", strerror(errno)); + if (seq) + intel_drm_abort_seq(scrn, seq); free(flip); goto error_undo; } + mode->flip_count++; } mode->old_fb_id = mode->fb_id; mode->fb_id = new_fb_id; + + if (!mode->flip_count) + intel_pageflip_complete(mode); + return TRUE; error_undo: @@ -1544,6 +1606,8 @@ error_undo: error_out: xf86DrvMsg(scrn->scrnIndex, X_WARNING, "Page flip failed: %s\n", strerror(errno)); + + mode->flip_count = 0; return FALSE; } @@ -1551,6 +1615,98 @@ static const xf86CrtcConfigFuncsRec intel_xf86crtc_config_funcs = { intel_xf86crtc_resize }; +/* + * Enqueue a potential drm response; when the associated response + * appears, we've got data to pass to the handler from here + */ +uint32_t +intel_drm_queue_alloc(ScrnInfoPtr scrn, + xf86CrtcPtr crtc, + void *data, + intel_drm_handler_proc handler, + intel_drm_abort_proc abort) +{ + struct intel_drm_queue *q; + + q = calloc(1, sizeof(struct intel_drm_queue)); + if (!q) + return 0; + + if (!intel_drm_seq) + ++intel_drm_seq; + q->seq = intel_drm_seq++; + q->scrn = scrn; + q->crtc = crtc; + q->data = data; + q->handler = handler; + q->abort = abort; + + list_add(&q->list, &intel_drm_queue); + + return q->seq; +} + +/* + * Abort one queued DRM entry, removing it + * from the list, calling the abort function and + * freeing the memory + */ +static void +intel_drm_abort_one(struct intel_drm_queue *q) +{ + list_del(&q->list); + q->abort(q->scrn, q->crtc, q->data); + free(q); +} + +/* + * Externally usable abort function that uses a callback to match a single queued + * entry to abort + */ +void +intel_drm_abort(ScrnInfoPtr scrn, Bool (*match)(void *data, void *match_data), void *match_data) +{ + struct intel_drm_queue *q; + + list_for_each_entry(q, &intel_drm_queue, list) { + if (match(q->data, match_data)) { + intel_drm_abort_one(q); + break; + } + } +} + +/* + * Abort by drm queue sequence number + */ +static void +intel_drm_abort_seq(ScrnInfoPtr scrn, uint32_t seq) +{ + struct intel_drm_queue *q; + + list_for_each_entry(q, &intel_drm_queue, list) { + if (q->seq == seq) { + intel_drm_abort_one(q); + break; + } + } +} + +/* + * Abort all queued entries on a specific scrn, used + * when resetting the X server + */ +static void +intel_drm_abort_scrn(ScrnInfoPtr scrn) +{ + struct intel_drm_queue *q, *tmp; + + list_for_each_entry_safe(q, tmp, &intel_drm_queue, list) { + if (q->scrn == scrn) + intel_drm_abort_one(q); + } +} + static uint32_t pipe_select(int pipe) { if (pipe > 1) @@ -1652,44 +1808,110 @@ intel_crtc_msc_to_sequence(ScrnInfoPtr scrn, xf86CrtcPtr crtc, uint64_t expect) return (uint32_t) (expect - intel_crtc->vblank_offset); } +/* + * General DRM kernel handler. Looks for the matching sequence number in the + * drm event queue and calls the handler for it. + */ static void -intel_vblank_handler(int fd, unsigned int frame, unsigned int tv_sec, - unsigned int tv_usec, void *event) -{ - I830DRI2FrameEventHandler(frame, tv_sec, tv_usec, event); +intel_drm_handler(int fd, uint32_t frame, uint32_t sec, uint32_t usec, void *user_ptr) +{ + uint32_t user_data = (intptr_t)user_ptr; + struct intel_drm_queue *q; + + list_for_each_entry(q, &intel_drm_queue, list) { + if (q->seq == user_data) { + list_del(&q->list); + q->handler(q->scrn, q->crtc, + intel_sequence_to_crtc_msc(q->crtc, frame), + (uint64_t)sec * 1000000 + usec, q->data); + free(q); + break; + } + } } + +/* + * Notify the page flip caller that the flip is + * complete + */ static void -intel_page_flip_handler(int fd, unsigned int frame, unsigned int tv_sec, - unsigned int tv_usec, void *event_data) +intel_pageflip_complete(struct intel_mode *mode) +{ + /* Release framebuffer */ + drmModeRmFB(mode->fd, mode->old_fb_id); + + if (!mode->pageflip_handler) + return; + + mode->pageflip_handler(mode->fe_msc, mode->fe_usec, + mode->pageflip_data); +} + +/* + * One pageflip event has completed. Update the saved msc/ust values + * as needed, then check to see if the whole set of events are + * complete and notify the application at that point + */ +static struct intel_mode * +intel_handle_pageflip(struct intel_pageflip *flip, uint64_t msc, uint64_t usec) { - struct intel_pageflip *flip = event_data; struct intel_mode *mode = flip->mode; - /* Is this the event whose info shall be delivered to higher level? */ if (flip->dispatch_me) { /* Yes: Cache msc, ust for later delivery. */ - mode->fe_msc = frame; - mode->fe_usec = (uint64_t) tv_sec * 1000000 + tv_usec; + mode->fe_msc = msc; + mode->fe_usec = usec; } free(flip); /* Last crtc completed flip? */ mode->flip_count--; if (mode->flip_count > 0) + return NULL; + + return mode; +} + +/* + * Called from the DRM event queue when a single flip has completed + */ +static void +intel_pageflip_handler(ScrnInfoPtr scrn, xf86CrtcPtr crtc, + uint64_t msc, uint64_t usec, void *data) +{ + struct intel_pageflip *flip = data; + struct intel_mode *mode = intel_handle_pageflip(flip, msc, usec); + + if (!mode) + return; + intel_pageflip_complete(mode); +} + +/* + * Called from the DRM queue abort code when a flip has been aborted + */ +static void +intel_pageflip_abort(ScrnInfoPtr scrn, xf86CrtcPtr crtc, void *data) +{ + struct intel_pageflip *flip = data; + struct intel_mode *mode = intel_handle_pageflip(flip, 0, 0); + + if (!mode) return; /* Release framebuffer */ drmModeRmFB(mode->fd, mode->old_fb_id); - if (mode->flip_info == NULL) + if (!mode->pageflip_abort) return; - /* Deliver cached msc, ust from reference crtc to flip event handler */ - I830DRI2FlipEventHandler((uint32_t) mode->fe_msc, mode->fe_usec / 1000000, - mode->fe_usec % 1000000, mode->flip_info); + mode->pageflip_abort(mode->pageflip_data); } +/* + * Check for pending DRM events and process them. + */ static void drm_wakeup_handler(pointer data, int err, pointer p) { @@ -1705,6 +1927,26 @@ drm_wakeup_handler(pointer data, int err, pointer p) drmHandleEvent(mode->fd, &mode->event_context); } +/* + * If there are any available, read drm_events + */ +int +intel_mode_read_drm_events(struct intel_screen_private *intel) +{ + struct intel_mode *mode = intel->modes; + struct pollfd p = { .fd = mode->fd, .events = POLLIN }; + int r; + + do { + r = poll(&p, 1, 0); + } while (r == -1 && (errno == EINTR || errno == EAGAIN)); + + if (r <= 0) + return 0; + + return drmHandleEvent(mode->fd, &mode->event_context); +} + static drmModeEncoderPtr intel_get_kencoder(struct intel_mode *mode, int num) { @@ -1804,8 +2046,12 @@ Bool intel_mode_pre_init(ScrnInfoPtr scrn, int fd, int cpp) xf86InitialConfiguration(scrn, TRUE); mode->event_context.version = DRM_EVENT_CONTEXT_VERSION; - mode->event_context.vblank_handler = intel_vblank_handler; - mode->event_context.page_flip_handler = intel_page_flip_handler; + mode->event_context.vblank_handler = intel_drm_handler; + mode->event_context.page_flip_handler = intel_drm_handler; + + /* XXX assumes only one intel screen */ + list_init(&intel_drm_queue); + intel_drm_seq = 0; has_flipping = 0; gp.param = I915_PARAM_HAS_PAGEFLIPPING; @@ -1848,14 +2094,6 @@ intel_mode_remove_fb(intel_screen_private *intel) } } -static Bool has_pending_events(int fd) -{ - struct pollfd pfd; - pfd.fd = fd; - pfd.events = POLLIN; - return poll(&pfd, 1, 0) == 1; -} - void intel_mode_close(intel_screen_private *intel) { @@ -1864,8 +2102,7 @@ intel_mode_close(intel_screen_private *intel) if (mode == NULL) return; - while (has_pending_events(mode->fd)) - drmHandleEvent(mode->fd, &mode->event_context); + intel_drm_abort_scrn(intel->scrn); RemoveBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA, drm_wakeup_handler, mode); @@ -1944,7 +2181,8 @@ Bool intel_crtc_on(xf86CrtcPtr crtc) return FALSE; ret = (drm_crtc->mode_valid && - intel_crtc->mode->fb_id == drm_crtc->buffer_id); + (intel_crtc->mode->fb_id == drm_crtc->buffer_id || + intel_crtc->mode->old_fb_id == drm_crtc->buffer_id)); free(drm_crtc); return ret; diff --git a/src/uxa/intel_dri.c b/src/uxa/intel_dri.c index 29b1942d..ef66aa53 100644 --- a/src/uxa/intel_dri.c +++ b/src/uxa/intel_dri.c @@ -593,7 +593,7 @@ I830DRI2DrawableCrtc(DrawablePtr pDraw) /* Make sure the CRTC is valid and this is the real front buffer */ if (crtc != NULL && !crtc->rotatedData) - return crtc; + return crtc; return NULL; } @@ -726,15 +726,15 @@ i830_dri2_add_frame_event(DRI2FrameEventPtr info) } static void -i830_dri2_del_frame_event(DrawablePtr drawable, DRI2FrameEventPtr info) +i830_dri2_del_frame_event(DRI2FrameEventPtr info) { list_del(&info->client_resource); list_del(&info->drawable_resource); if (info->front) - I830DRI2DestroyBuffer(drawable, info->front); + I830DRI2DestroyBuffer(NULL, info->front); if (info->back) - I830DRI2DestroyBuffer(drawable, info->back); + I830DRI2DestroyBuffer(NULL, info->back); free(info); } @@ -832,6 +832,24 @@ static drm_intel_bo *get_pixmap_bo(I830DRI2BufferPrivatePtr priv) return bo; } +static void +I830DRI2FlipComplete(uint64_t frame, uint64_t usec, void *pageflip_data) +{ + DRI2FrameEventPtr info = pageflip_data; + + I830DRI2FlipEventHandler((uint32_t) frame, usec / 1000000, + usec % 1000000, + info); +} + +static void +I830DRI2FlipAbort(void *pageflip_data) +{ + DRI2FrameEventPtr info = pageflip_data; + + i830_dri2_del_frame_event(info); +} + /* * Our internal swap routine takes care of actually exchanging, blitting, or * flipping buffers as necessary. @@ -849,7 +867,9 @@ I830DRI2ScheduleFlip(struct intel_screen_private *intel, info->type = DRI2_SWAP; if (!intel_do_pageflip(intel, get_pixmap_bo(priv), - info, info->pipe)) + info->pipe, FALSE, info, + I830DRI2FlipComplete, + I830DRI2FlipAbort)) return FALSE; I830DRI2ExchangeBuffers(intel, info->front, info->back); @@ -904,7 +924,7 @@ I830DRI2ScheduleFlip(struct intel_screen_private *intel, } old_back = get_pixmap_bo(priv); - if (!intel_do_pageflip(intel, old_back, info, info->pipe)) { + if (!intel_do_pageflip(intel, old_back, info->pipe, FALSE, info, I830DRI2FlipComplete, I830DRI2FlipAbort)) { intel->back_buffer = new_back; return FALSE; } @@ -1003,7 +1023,7 @@ void I830DRI2FrameEventHandler(unsigned int frame, unsigned int tv_sec, status = dixLookupDrawable(&drawable, swap_info->drawable_id, serverClient, M_ANY, DixWriteAccess); if (status != Success) { - i830_dri2_del_frame_event(NULL, swap_info); + i830_dri2_del_frame_event(swap_info); return; } @@ -1037,7 +1057,7 @@ void I830DRI2FrameEventHandler(unsigned int frame, unsigned int tv_sec, break; } - i830_dri2_del_frame_event(drawable, swap_info); + i830_dri2_del_frame_event(swap_info); } void I830DRI2FlipEventHandler(unsigned int frame, unsigned int tv_sec, @@ -1098,7 +1118,7 @@ void I830DRI2FlipEventHandler(unsigned int frame, unsigned int tv_sec, serverClient, M_ANY, DixWriteAccess); if (chain_drawable == NULL) { - i830_dri2_del_frame_event(chain_drawable, chain); + i830_dri2_del_frame_event(chain); } else if (!can_exchange(chain_drawable, chain->front, chain->back) || !I830DRI2ScheduleFlip(intel, chain_drawable, chain)) { I830DRI2FallbackBlitSwap(chain_drawable, @@ -1109,7 +1129,7 @@ void I830DRI2FlipEventHandler(unsigned int frame, unsigned int tv_sec, DRI2_BLIT_COMPLETE, chain->client ? chain->event_complete : NULL, chain->event_data); - i830_dri2_del_frame_event(chain_drawable, chain); + i830_dri2_del_frame_event(chain); } } break; @@ -1121,7 +1141,7 @@ void I830DRI2FlipEventHandler(unsigned int frame, unsigned int tv_sec, break; } - i830_dri2_del_frame_event(drawable, flip_info); + i830_dri2_del_frame_event(flip_info); } static uint32_t pipe_select(int pipe) @@ -1134,6 +1154,28 @@ static uint32_t pipe_select(int pipe) return 0; } +static void +intel_dri2_vblank_handler(ScrnInfoPtr scrn, + xf86CrtcPtr crtc, + uint64_t msc, + uint64_t usec, + void *data) +{ + DRI2FrameEventPtr swap_info = data; + + I830DRI2FrameEventHandler((uint32_t) msc, usec / 1000000, usec % 1000000, swap_info); +} + +static void +intel_dri2_vblank_abort(ScrnInfoPtr scrn, + xf86CrtcPtr crtc, + void *data) +{ + DRI2FrameEventPtr swap_info = data; + + i830_dri2_del_frame_event(swap_info); +} + /* * ScheduleSwap is responsible for requesting a DRM vblank event for the * appropriate frame. @@ -1171,6 +1213,7 @@ I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front, enum DRI2FrameEventType swap_type = DRI2_SWAP; uint64_t current_msc, current_ust; uint64_t request_msc; + uint32_t seq; /* Drawable not displayed... just complete the swap */ if (pipe == -1) @@ -1249,8 +1292,13 @@ I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front, if (current_msc >= *target_msc) *target_msc = current_msc; + seq = intel_drm_queue_alloc(scrn, crtc, swap_info, intel_dri2_vblank_handler, intel_dri2_vblank_abort); + if (!seq) + goto blit_fallback; + vbl.request.sequence = intel_crtc_msc_to_sequence(scrn, crtc, *target_msc); - vbl.request.signal = (unsigned long)swap_info; + vbl.request.signal = seq; + ret = drmWaitVBlank(intel->drmSubFD, &vbl); if (ret) { xf86DrvMsg(scrn->scrnIndex, X_WARNING, @@ -1292,12 +1340,14 @@ I830DRI2ScheduleSwap(ClientPtr client, DrawablePtr draw, DRI2BufferPtr front, if (request_msc <= current_msc) request_msc += divisor; - vbl.request.sequence = intel_crtc_msc_to_sequence(scrn, crtc, request_msc); + seq = intel_drm_queue_alloc(scrn, crtc, swap_info, intel_dri2_vblank_handler, intel_dri2_vblank_abort); + if (!seq) + goto blit_fallback; /* Account for 1 frame extra pageflip delay if flip > 0 */ - vbl.request.sequence -= flip; + vbl.request.sequence = intel_crtc_msc_to_sequence(scrn, crtc, request_msc) - flip; + vbl.request.signal = seq; - vbl.request.signal = (unsigned long)swap_info; ret = drmWaitVBlank(intel->drmSubFD, &vbl); if (ret) { xf86DrvMsg(scrn->scrnIndex, X_WARNING, @@ -1316,7 +1366,7 @@ blit_fallback: I830DRI2FallbackBlitSwap(draw, front, back); DRI2SwapComplete(client, draw, 0, 0, 0, DRI2_BLIT_COMPLETE, func, data); if (swap_info) - i830_dri2_del_frame_event(draw, swap_info); + i830_dri2_del_frame_event(swap_info); *target_msc = 0; /* offscreen, so zero out target vblank count */ return TRUE; } @@ -1386,6 +1436,7 @@ I830DRI2ScheduleWaitMSC(ClientPtr client, DrawablePtr draw, CARD64 target_msc, xf86CrtcPtr crtc = I830DRI2DrawableCrtc(draw); int pipe = crtc ? intel_crtc_to_pipe(crtc) : -1; CARD64 current_msc, current_ust, request_msc; + uint32_t seq; /* Drawable not visible, return immediately */ if (pipe == -1) @@ -1423,12 +1474,17 @@ I830DRI2ScheduleWaitMSC(ClientPtr client, DrawablePtr draw, CARD64 target_msc, * sending us MSC targets from the past by forcibly updating * their count on this call. */ + seq = intel_drm_queue_alloc(scrn, crtc, wait_info, intel_dri2_vblank_handler, intel_dri2_vblank_abort); + if (!seq) + goto out_free; + if (current_msc >= target_msc) target_msc = current_msc; vbl.request.type = DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT | pipe_select(pipe); vbl.request.sequence = intel_crtc_msc_to_sequence(scrn, crtc, target_msc); - vbl.request.signal = (unsigned long)wait_info; + vbl.request.signal = seq; + ret = drmWaitVBlank(intel->drmSubFD, &vbl); if (ret) { static int limit = 5; @@ -1465,9 +1521,13 @@ I830DRI2ScheduleWaitMSC(ClientPtr client, DrawablePtr draw, CARD64 target_msc, if ((current_msc % divisor) >= remainder) request_msc += divisor; + seq = intel_drm_queue_alloc(scrn, crtc, wait_info, intel_dri2_vblank_handler, intel_dri2_vblank_abort); + if (!seq) + goto out_free; + vbl.request.sequence = intel_crtc_msc_to_sequence(scrn, crtc, request_msc); + vbl.request.signal = seq; - vbl.request.signal = (unsigned long)wait_info; ret = drmWaitVBlank(intel->drmSubFD, &vbl); if (ret) { static int limit = 5; @@ -1487,7 +1547,7 @@ I830DRI2ScheduleWaitMSC(ClientPtr client, DrawablePtr draw, CARD64 target_msc, return TRUE; out_free: - i830_dri2_del_frame_event(draw, wait_info); + i830_dri2_del_frame_event(wait_info); out_complete: DRI2WaitMSCComplete(client, draw, target_msc, 0, 0); return TRUE; |