Allow relocation to be skipped when buffers don't move.
authorKeith Packard <keithp@keithp.com>
Tue, 4 Dec 2007 20:22:30 +0000 (12:22 -0800)
committerKeith Packard <keithp@keithp.com>
Wed, 12 Dec 2007 04:23:00 +0000 (20:23 -0800)
commit57b9a54eb668477407c8be54c041d7a9f92c1f51
tree45210a219a48374ac1a85e087aae5b1fcd145b5e
parentcfa21b22b43c7113107b5eb086b5f4d4ec36dc0a
Allow relocation to be skipped when buffers don't move.

One of the costs of superioctl has been the need to perform relocations
inside the kernel. The cost of mapping the buffers to the CPU and writing
data is fairly high, especially if those buffers have been mapped and read
by the GPU.

If we assume that buffers don't move around very often, we can have the
client compute the relocations itself using the previous GPU address. When
that object doesn't move, the kernel can skip computing and writing the
updated data.

Here's a patch which adds a new field to struct drm_bo_info_req called
'presumed_offset', and a new DRM_BO_HINT_PRESUMED_OFFSET that is set when
this field has been filled in by the client.

There are two separate optimizations performed when the presumed_offset is
correct:

 1. i915_exec_reloc checks to see if all previous buffer offsets were guessed
    correctly. If so, there's no need for it to look at *any* of the
    relocations for a buffer. When this happens, it skips the whole
    relocation process, simply returning success.

 2. i915_apply_reloc checks to see if the target buffer offset was guessed
    correctly. If so, it skips mapping the relocatee, computing the
    relocation and writing the value. If no relocations are needed, the
    relocatee should never be mapped to the CPU, and so the kernel shouldn't
    need to wait for any fences to pass.
shared-core/drm.h
shared-core/i915_dma.c