[intel-gem] Execute MI_FLUSH in leavevt_ioctl

In leavevt_ioctl, queue an MI_FLUSH and then block waiting for it to
complete. This will empty the active and flushing lists. That leaves only
the inactive list to evict.
main
Keith Packard 2008-06-13 19:49:47 -07:00
parent 19c3418848
commit 3e48e14499
1 changed files with 34 additions and 20 deletions

View File

@ -2127,6 +2127,10 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data,
return ret; return ret;
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
BUG_ON(!list_empty(&dev_priv->mm.active_list));
BUG_ON(!list_empty(&dev_priv->mm.flushing_list));
BUG_ON(!list_empty(&dev_priv->mm.inactive_list));
BUG_ON(!list_empty(&dev_priv->mm.request_list));
dev_priv->mm.suspended = 0; dev_priv->mm.suspended = 0;
mutex_unlock(&dev->struct_mutex); mutex_unlock(&dev->struct_mutex);
return 0; return 0;
@ -2170,6 +2174,8 @@ i915_gem_leavevt_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv) struct drm_file *file_priv)
{ {
drm_i915_private_t *dev_priv = dev->dev_private; drm_i915_private_t *dev_priv = dev->dev_private;
uint32_t seqno;
int ret;
mutex_lock(&dev->struct_mutex); mutex_lock(&dev->struct_mutex);
/* Hack! Don't let anybody do execbuf while we don't control the chip. /* Hack! Don't let anybody do execbuf while we don't control the chip.
@ -2177,32 +2183,40 @@ i915_gem_leavevt_ioctl(struct drm_device *dev, void *data,
*/ */
dev_priv->mm.suspended = 1; dev_priv->mm.suspended = 1;
/* Move all buffers out of the GTT. */ i915_kernel_lost_context(dev);
i915_gem_evict_from_list(dev, &dev_priv->mm.active_list);
i915_gem_evict_from_list(dev, &dev_priv->mm.flushing_list);
i915_gem_evict_from_list(dev, &dev_priv->mm.inactive_list);
/* Make sure the harware's idle. */ /* Flush the GPU along with all non-CPU write domains
while (!list_empty(&dev_priv->mm.request_list)) { */
struct drm_i915_gem_request *request; i915_gem_flush(dev, ~I915_GEM_DOMAIN_CPU, ~I915_GEM_DOMAIN_CPU);
int ret; seqno = i915_add_request(dev, ~I915_GEM_DOMAIN_CPU);
if (seqno == 0) {
request = list_first_entry(&dev_priv->mm.request_list, mutex_unlock(&dev->struct_mutex);
struct drm_i915_gem_request, return -ENOMEM;
list);
ret = i915_wait_request(dev, request->seqno);
if (ret != 0) {
DRM_ERROR("Error waiting for idle at LeaveVT: %d\n",
ret);
mutex_unlock(&dev->struct_mutex);
return ret;
}
} }
ret = i915_wait_request(dev, seqno);
if (ret) {
mutex_unlock(&dev->struct_mutex);
return ret;
}
/* Active and flushing should now be empty as we've
* waited for a sequence higher than any pending execbuffer
*/
BUG_ON(!list_empty(&dev_priv->mm.active_list));
BUG_ON(!list_empty(&dev_priv->mm.flushing_list));
/* Request should now be empty as we've also waited
* for the last request in the list
*/
BUG_ON(!list_empty(&dev_priv->mm.request_list));
/* Move all buffers out of the GTT. */
i915_gem_evict_from_list(dev, &dev_priv->mm.inactive_list);
BUG_ON(!list_empty(&dev_priv->mm.active_list)); BUG_ON(!list_empty(&dev_priv->mm.active_list));
BUG_ON(!list_empty(&dev_priv->mm.flushing_list)); BUG_ON(!list_empty(&dev_priv->mm.flushing_list));
BUG_ON(!list_empty(&dev_priv->mm.inactive_list)); BUG_ON(!list_empty(&dev_priv->mm.inactive_list));
BUG_ON(!list_empty(&dev_priv->mm.request_list));
i915_gem_cleanup_ringbuffer(dev); i915_gem_cleanup_ringbuffer(dev);