mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 09:38:07 +02:00
i965/drm: Make register write check handle execbuffer directly.
I'm about to rewrite how relocation handling works, at which point
drm_bacon_bo_emit_reloc() and drm_bacon_bo_mrb_exec() won't exist
anymore. This code is already largely not using the batchbuffer
infrastructure, so just go all the way and handle relocations, the
validation list, and execbuffer ourselves. That way, we don't have
to think the weird case where we only have a screen, and no context,
when redesigning the relocation handling.
v2: Write reloc.presumed_offset + reloc.delta into the batch, rather
than duplicating the comment, so it's obvious that they match
(suggested by Chris). Also add a comment about why we don't do
any error checking.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
parent
6368284a34
commit
e7ab0ea5e7
1 changed files with 34 additions and 7 deletions
|
|
@ -1368,6 +1368,9 @@ static bool
|
|||
intel_detect_pipelined_register(struct intel_screen *screen,
|
||||
int reg, uint32_t expected_value, bool reset)
|
||||
{
|
||||
if (screen->no_hw)
|
||||
return false;
|
||||
|
||||
drm_bacon_bo *results, *bo;
|
||||
uint32_t *batch;
|
||||
uint32_t offset = 0;
|
||||
|
|
@ -1395,11 +1398,14 @@ intel_detect_pipelined_register(struct intel_screen *screen,
|
|||
/* Save the register's value back to the buffer. */
|
||||
*batch++ = MI_STORE_REGISTER_MEM | (3 - 2);
|
||||
*batch++ = reg;
|
||||
drm_bacon_bo_emit_reloc(bo, (char *)batch -(char *)bo->virtual,
|
||||
results, offset*sizeof(uint32_t),
|
||||
I915_GEM_DOMAIN_INSTRUCTION,
|
||||
I915_GEM_DOMAIN_INSTRUCTION);
|
||||
*batch++ = ((uint32_t) results->offset64) + offset*sizeof(uint32_t);
|
||||
struct drm_i915_gem_relocation_entry reloc = {
|
||||
.offset = (char *) batch - (char *) bo->virtual,
|
||||
.delta = offset * sizeof(uint32_t),
|
||||
.target_handle = results->handle,
|
||||
.read_domains = I915_GEM_DOMAIN_INSTRUCTION,
|
||||
.write_domain = I915_GEM_DOMAIN_INSTRUCTION,
|
||||
};
|
||||
*batch++ = reloc.presumed_offset + reloc.delta;
|
||||
|
||||
/* And afterwards clear the register */
|
||||
if (reset) {
|
||||
|
|
@ -1410,8 +1416,29 @@ intel_detect_pipelined_register(struct intel_screen *screen,
|
|||
|
||||
*batch++ = MI_BATCH_BUFFER_END;
|
||||
|
||||
drm_bacon_bo_mrb_exec(bo, ALIGN((char *)batch - (char *)bo->virtual, 8),
|
||||
I915_EXEC_RENDER);
|
||||
struct drm_i915_gem_exec_object2 exec_objects[2] = {
|
||||
{
|
||||
.handle = results->handle,
|
||||
},
|
||||
{
|
||||
.handle = bo->handle,
|
||||
.relocation_count = 1,
|
||||
.relocs_ptr = (uintptr_t) &reloc,
|
||||
}
|
||||
};
|
||||
|
||||
struct drm_i915_gem_execbuffer2 execbuf = {
|
||||
.buffers_ptr = (uintptr_t) exec_objects,
|
||||
.buffer_count = 2,
|
||||
.batch_len = ALIGN((char *) batch - (char *) bo->virtual, 8),
|
||||
.flags = I915_EXEC_RENDER,
|
||||
};
|
||||
|
||||
/* Don't bother with error checking - if the execbuf fails, the
|
||||
* value won't be written and we'll just report that there's no access.
|
||||
*/
|
||||
__DRIscreen *dri_screen = screen->driScrnPriv;
|
||||
drmIoctl(dri_screen->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
|
||||
|
||||
/* Check whether the value got written. */
|
||||
if (drm_bacon_bo_map(results, false) == 0) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue