summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolai Hähnle <nicolai.haehnle@amd.com>2016-10-04 10:50:55 +0200
committerNicolai Hähnle <nicolai.haehnle@amd.com>2016-10-04 16:37:44 +0200
commitdfc1afda83a22d8e6b23f003748cd78fd089a0ac (patch)
treef37c99fa34c76032019ecfef3d1df86012be3586
parent71a5cf6f3b8c6baee8ec71f1a2bef3b2efa5b91a (diff)
winsys/radeon: add buffer_get_reloc_offset
Really fix the bug that was supposed to be fixed by commits 3e7cced4b and a48bf02d: even when virtual addresses are used, the legacy relocation-based method with offsets relative to the kernel's buffer object are used for video submissions. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97969 Reviewed-by: Christian König <christian.koenig@amd.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
-rw-r--r--src/gallium/drivers/radeon/radeon_uvd.c2
-rw-r--r--src/gallium/drivers/radeon/radeon_vce.c2
-rw-r--r--src/gallium/drivers/radeon/radeon_winsys.h12
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm_bo.c11
4 files changed, 25 insertions, 2 deletions
diff --git a/src/gallium/drivers/radeon/radeon_uvd.c b/src/gallium/drivers/radeon/radeon_uvd.c
index 9c376cb278..fb1491a282 100644
--- a/src/gallium/drivers/radeon/radeon_uvd.c
+++ b/src/gallium/drivers/radeon/radeon_uvd.c
@@ -123,7 +123,7 @@ static void send_cmd(struct ruvd_decoder *dec, unsigned cmd,
set_reg(dec, RUVD_GPCOM_VCPU_DATA0, addr);
set_reg(dec, RUVD_GPCOM_VCPU_DATA1, addr >> 32);
} else {
- off += dec->ws->buffer_get_virtual_address(buf);
+ off += dec->ws->buffer_get_reloc_offset(buf);
set_reg(dec, RUVD_GPCOM_VCPU_DATA0, off);
set_reg(dec, RUVD_GPCOM_VCPU_DATA1, reloc_idx * 4);
}
diff --git a/src/gallium/drivers/radeon/radeon_vce.c b/src/gallium/drivers/radeon/radeon_vce.c
index 30705c1cae..ef93e46c19 100644
--- a/src/gallium/drivers/radeon/radeon_vce.c
+++ b/src/gallium/drivers/radeon/radeon_vce.c
@@ -549,7 +549,7 @@ void rvce_add_buffer(struct rvce_encoder *enc, struct pb_buffer *buf,
RVCE_CS(addr >> 32);
RVCE_CS(addr);
} else {
- offset += enc->ws->buffer_get_virtual_address(buf);
+ offset += enc->ws->buffer_get_reloc_offset(buf);
RVCE_CS(reloc_idx * 4);
RVCE_CS(offset);
}
diff --git a/src/gallium/drivers/radeon/radeon_winsys.h b/src/gallium/drivers/radeon/radeon_winsys.h
index e8fc6d62c4..7146737c82 100644
--- a/src/gallium/drivers/radeon/radeon_winsys.h
+++ b/src/gallium/drivers/radeon/radeon_winsys.h
@@ -515,6 +515,18 @@ struct radeon_winsys {
uint64_t (*buffer_get_virtual_address)(struct pb_buffer *buf);
/**
+ * Return the offset of this buffer relative to the relocation base.
+ * This is only non-zero for sub-allocated buffers.
+ *
+ * This is only supported in the radeon winsys, since amdgpu uses virtual
+ * addresses in submissions even for the video engines.
+ *
+ * \param buf A winsys buffer object
+ * \return the offset for relocations
+ */
+ unsigned (*buffer_get_reloc_offset)(struct pb_buffer *buf);
+
+ /**
* Query the initial placement of the buffer from the kernel driver.
*/
enum radeon_bo_domain (*buffer_get_initial_domain)(struct pb_buffer *buf);
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
index 5818006cc2..a15d559b01 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c
@@ -1339,6 +1339,16 @@ static uint64_t radeon_winsys_bo_va(struct pb_buffer *buf)
return ((struct radeon_bo*)buf)->va;
}
+static unsigned radeon_winsys_bo_get_reloc_offset(struct pb_buffer *buf)
+{
+ struct radeon_bo *bo = radeon_bo(buf);
+
+ if (bo->handle)
+ return 0;
+
+ return bo->va - bo->u.slab.real->va;
+}
+
void radeon_drm_bo_init_functions(struct radeon_drm_winsys *ws)
{
ws->base.buffer_set_metadata = radeon_bo_set_metadata;
@@ -1352,5 +1362,6 @@ void radeon_drm_bo_init_functions(struct radeon_drm_winsys *ws)
ws->base.buffer_is_user_ptr = radeon_winsys_bo_is_user_ptr;
ws->base.buffer_get_handle = radeon_winsys_bo_get_handle;
ws->base.buffer_get_virtual_address = radeon_winsys_bo_va;
+ ws->base.buffer_get_reloc_offset = radeon_winsys_bo_get_reloc_offset;
ws->base.buffer_get_initial_domain = radeon_bo_get_initial_domain;
}