Skip to content

Commit

Permalink
drm/i915: Move the execbuffer domain computations together
Browse files Browse the repository at this point in the history
This eliminates the dev_set_domain function and just in-lines it
where its used, with the goal of moving the manipulation and use of
invalidate_domains and flush_domains closer together. This also
avoids calling add_request unless some domain has been flushed.

Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Dave Airlie <airlied@redhat.com>
  • Loading branch information
Keith Packard authored and Dave Airlie committed Dec 4, 2008
1 parent c0d9082 commit 646f0f6
Showing 1 changed file with 21 additions and 44 deletions.
65 changes: 21 additions & 44 deletions drivers/gpu/drm/i915/i915_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1646,38 +1646,6 @@ i915_gem_object_set_cpu_read_domain_range(struct drm_gem_object *obj,
return 0;
}

/**
* Once all of the objects have been set in the proper domain,
* perform the necessary flush and invalidate operations.
*
* Returns the write domains flushed, for use in flush tracking.
*/
static uint32_t
i915_gem_dev_set_domain(struct drm_device *dev)
{
uint32_t flush_domains = dev->flush_domains;

/*
* Now that all the buffers are synced to the proper domains,
* flush and invalidate the collected domains
*/
if (dev->invalidate_domains | dev->flush_domains) {
#if WATCH_EXEC
DRM_INFO("%s: invalidate_domains %08x flush_domains %08x\n",
__func__,
dev->invalidate_domains,
dev->flush_domains);
#endif
i915_gem_flush(dev,
dev->invalidate_domains,
dev->flush_domains);
dev->invalidate_domains = 0;
dev->flush_domains = 0;
}

return flush_domains;
}

/**
* Pin an object to the GTT and evaluate the relocations landing in it.
*/
Expand Down Expand Up @@ -2002,13 +1970,6 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
return -EBUSY;
}

/* Zero the gloabl flush/invalidate flags. These
* will be modified as each object is bound to the
* gtt
*/
dev->invalidate_domains = 0;
dev->flush_domains = 0;

/* Look up object handles and perform the relocations */
for (i = 0; i < args->buffer_count; i++) {
object_list[i] = drm_gem_object_lookup(dev, file_priv,
Expand Down Expand Up @@ -2039,19 +2000,37 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,

i915_verify_inactive(dev, __FILE__, __LINE__);

/* Zero the global flush/invalidate flags. These
* will be modified as new domains are computed
* for each object
*/
dev->invalidate_domains = 0;
dev->flush_domains = 0;

for (i = 0; i < args->buffer_count; i++) {
struct drm_gem_object *obj = object_list[i];

/* Compute new gpu domains and update invalidate/flushing */
/* Compute new gpu domains and update invalidate/flush */
i915_gem_object_set_to_gpu_domain(obj,
obj->pending_read_domains,
obj->pending_write_domain);
}

i915_verify_inactive(dev, __FILE__, __LINE__);

/* Flush/invalidate caches and chipset buffer */
flush_domains = i915_gem_dev_set_domain(dev);
if (dev->invalidate_domains | dev->flush_domains) {
#if WATCH_EXEC
DRM_INFO("%s: invalidate_domains %08x flush_domains %08x\n",
__func__,
dev->invalidate_domains,
dev->flush_domains);
#endif
i915_gem_flush(dev,
dev->invalidate_domains,
dev->flush_domains);
if (dev->flush_domains)
(void)i915_add_request(dev, dev->flush_domains);
}

i915_verify_inactive(dev, __FILE__, __LINE__);

Expand All @@ -2071,8 +2050,6 @@ i915_gem_execbuffer(struct drm_device *dev, void *data,
~0);
#endif

(void)i915_add_request(dev, flush_domains);

/* Exec the batchbuffer */
ret = i915_dispatch_gem_execbuffer(dev, args, exec_offset);
if (ret) {
Expand Down

0 comments on commit 646f0f6

Please sign in to comment.