mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-09 23:39:18 +00:00
drm/amdgpu: add optional dependencies to the CS IOCTL v2
v2: remove unrelated whitespace change, fix C comment Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
03507c4f2f
commit
2b48d323b2
@ -226,6 +226,9 @@ int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case AMDGPU_CHUNK_ID_DEPENDENCIES:
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
r = -EINVAL;
|
r = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
@ -663,6 +666,55 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int amdgpu_cs_dependencies(struct amdgpu_device *adev,
|
||||||
|
struct amdgpu_cs_parser *p)
|
||||||
|
{
|
||||||
|
struct amdgpu_ib *ib;
|
||||||
|
int i, j, r;
|
||||||
|
|
||||||
|
if (!p->num_ibs)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Add dependencies to first IB */
|
||||||
|
ib = &p->ibs[0];
|
||||||
|
for (i = 0; i < p->nchunks; ++i) {
|
||||||
|
struct drm_amdgpu_cs_chunk_dep *deps;
|
||||||
|
struct amdgpu_cs_chunk *chunk;
|
||||||
|
unsigned num_deps;
|
||||||
|
|
||||||
|
chunk = &p->chunks[i];
|
||||||
|
|
||||||
|
if (chunk->chunk_id != AMDGPU_CHUNK_ID_DEPENDENCIES)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
deps = (struct drm_amdgpu_cs_chunk_dep *)chunk->kdata;
|
||||||
|
num_deps = chunk->length_dw * 4 /
|
||||||
|
sizeof(struct drm_amdgpu_cs_chunk_dep);
|
||||||
|
|
||||||
|
for (j = 0; j < num_deps; ++j) {
|
||||||
|
struct amdgpu_fence *fence;
|
||||||
|
struct amdgpu_ring *ring;
|
||||||
|
|
||||||
|
r = amdgpu_cs_get_ring(adev, deps[j].ip_type,
|
||||||
|
deps[j].ip_instance,
|
||||||
|
deps[j].ring, &ring);
|
||||||
|
if (r)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
r = amdgpu_fence_recreate(ring, p->filp,
|
||||||
|
deps[j].handle,
|
||||||
|
&fence);
|
||||||
|
if (r)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
amdgpu_sync_fence(&ib->sync, fence);
|
||||||
|
amdgpu_fence_unref(&fence);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
|
int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
|
||||||
{
|
{
|
||||||
struct amdgpu_device *adev = dev->dev_private;
|
struct amdgpu_device *adev = dev->dev_private;
|
||||||
@ -697,11 +749,16 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
|
|||||||
else
|
else
|
||||||
DRM_ERROR("Failed to process the buffer list %d!\n", r);
|
DRM_ERROR("Failed to process the buffer list %d!\n", r);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if (!r) {
|
||||||
reserved_buffers = true;
|
reserved_buffers = true;
|
||||||
r = amdgpu_cs_ib_fill(adev, &parser);
|
r = amdgpu_cs_ib_fill(adev, &parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!r)
|
||||||
|
r = amdgpu_cs_dependencies(adev, &parser);
|
||||||
|
|
||||||
if (r) {
|
if (r) {
|
||||||
amdgpu_cs_parser_fini(&parser, r, reserved_buffers);
|
amdgpu_cs_parser_fini(&parser, r, reserved_buffers);
|
||||||
up_read(&adev->exclusive_lock);
|
up_read(&adev->exclusive_lock);
|
||||||
|
@ -348,6 +348,7 @@ struct drm_amdgpu_gem_va {
|
|||||||
|
|
||||||
#define AMDGPU_CHUNK_ID_IB 0x01
|
#define AMDGPU_CHUNK_ID_IB 0x01
|
||||||
#define AMDGPU_CHUNK_ID_FENCE 0x02
|
#define AMDGPU_CHUNK_ID_FENCE 0x02
|
||||||
|
#define AMDGPU_CHUNK_ID_DEPENDENCIES 0x03
|
||||||
|
|
||||||
struct drm_amdgpu_cs_chunk {
|
struct drm_amdgpu_cs_chunk {
|
||||||
uint32_t chunk_id;
|
uint32_t chunk_id;
|
||||||
@ -399,6 +400,14 @@ struct drm_amdgpu_cs_chunk_ib {
|
|||||||
uint32_t ring;
|
uint32_t ring;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct drm_amdgpu_cs_chunk_dep {
|
||||||
|
uint32_t ip_type;
|
||||||
|
uint32_t ip_instance;
|
||||||
|
uint32_t ring;
|
||||||
|
uint32_t ctx_id;
|
||||||
|
uint64_t handle;
|
||||||
|
};
|
||||||
|
|
||||||
struct drm_amdgpu_cs_chunk_fence {
|
struct drm_amdgpu_cs_chunk_fence {
|
||||||
uint32_t handle;
|
uint32_t handle;
|
||||||
uint32_t offset;
|
uint32_t offset;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user