winsys/amdgpu: pass PIPE_CONTEXT_* flags to ctx_create
instead of using our own flags; also REALTIME_PRIORITY is never used, so the relevant code is removed Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34983>
This commit is contained in:
@@ -382,7 +382,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
|
||||
|
||||
slab_create_child(&r300->pool_transfers, &r300screen->pool_transfers);
|
||||
|
||||
r300->ctx = rws->ctx_create(rws, RADEON_CTX_PRIORITY_MEDIUM, false);
|
||||
r300->ctx = rws->ctx_create(rws, flags);
|
||||
if (!r300->ctx)
|
||||
goto fail;
|
||||
|
||||
|
||||
@@ -622,7 +622,7 @@ bool r600_common_context_init(struct r600_common_context *rctx,
|
||||
if (!rctx->b.const_uploader)
|
||||
return false;
|
||||
|
||||
rctx->ctx = rctx->ws->ctx_create(rctx->ws, RADEON_CTX_PRIORITY_MEDIUM, false);
|
||||
rctx->ctx = rctx->ws->ctx_create(rctx->ws, context_flags);
|
||||
if (!rctx->ctx)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -2882,8 +2882,7 @@ struct pipe_video_codec *radeon_create_decoder(struct pipe_context *context,
|
||||
goto err;
|
||||
for (i = 0; i < dec->njctx; i++) {
|
||||
/* Initialize the context handle and the command stream. */
|
||||
dec->jctx[i] = dec->ws->ctx_create(dec->ws, RADEON_CTX_PRIORITY_MEDIUM,
|
||||
sctx->context_flags & PIPE_CONTEXT_LOSE_CONTEXT_ON_RESET);
|
||||
dec->jctx[i] = dec->ws->ctx_create(dec->ws, sctx->context_flags);
|
||||
if (!sctx->ctx)
|
||||
goto error;
|
||||
if (!dec->ws->cs_create(&dec->jcs[i], dec->jctx[i], ring, NULL, NULL)) {
|
||||
|
||||
@@ -505,7 +505,6 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign
|
||||
struct si_context *sctx = CALLOC_STRUCT(si_context);
|
||||
struct radeon_winsys *ws = sscreen->ws;
|
||||
int shader, i;
|
||||
enum radeon_ctx_priority priority;
|
||||
|
||||
if (!sctx) {
|
||||
fprintf(stderr, "radeonsi: can't allocate a context\n");
|
||||
@@ -549,26 +548,16 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, unsign
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & PIPE_CONTEXT_HIGH_PRIORITY) {
|
||||
priority = RADEON_CTX_PRIORITY_HIGH;
|
||||
} else if (flags & PIPE_CONTEXT_LOW_PRIORITY) {
|
||||
priority = RADEON_CTX_PRIORITY_LOW;
|
||||
} else {
|
||||
priority = RADEON_CTX_PRIORITY_MEDIUM;
|
||||
}
|
||||
|
||||
bool allow_context_lost = flags & PIPE_CONTEXT_LOSE_CONTEXT_ON_RESET;
|
||||
|
||||
/* Initialize the context handle and the command stream. */
|
||||
sctx->ctx = sctx->ws->ctx_create(sctx->ws, priority, allow_context_lost);
|
||||
if (!sctx->ctx && priority != RADEON_CTX_PRIORITY_MEDIUM) {
|
||||
sctx->ctx = sctx->ws->ctx_create(sctx->ws, sctx->context_flags);
|
||||
if (!sctx->ctx && sctx->context_flags & PIPE_CONTEXT_HIGH_PRIORITY) {
|
||||
/* Context priority should be treated as a hint. If context creation
|
||||
* fails with the requested priority, for example because the caller
|
||||
* lacks CAP_SYS_NICE capability or other system resource constraints,
|
||||
* fallback to normal priority.
|
||||
*/
|
||||
priority = RADEON_CTX_PRIORITY_MEDIUM;
|
||||
sctx->ctx = sctx->ws->ctx_create(sctx->ws, priority, allow_context_lost);
|
||||
sctx->context_flags &= ~PIPE_CONTEXT_HIGH_PRIORITY;
|
||||
sctx->ctx = sctx->ws->ctx_create(sctx->ws, sctx->context_flags);
|
||||
}
|
||||
if (!sctx->ctx) {
|
||||
fprintf(stderr, "radeonsi: can't create radeon_winsys_ctx\n");
|
||||
|
||||
@@ -133,14 +133,6 @@ enum radeon_value_id
|
||||
RADEON_CS_THREAD_TIME,
|
||||
};
|
||||
|
||||
enum radeon_ctx_priority
|
||||
{
|
||||
RADEON_CTX_PRIORITY_LOW = 0,
|
||||
RADEON_CTX_PRIORITY_MEDIUM,
|
||||
RADEON_CTX_PRIORITY_HIGH,
|
||||
RADEON_CTX_PRIORITY_REALTIME,
|
||||
};
|
||||
|
||||
enum radeon_ctx_pstate
|
||||
{
|
||||
RADEON_CTX_PSTATE_NONE = 0,
|
||||
@@ -528,13 +520,9 @@ struct radeon_winsys {
|
||||
* Create a command submission context.
|
||||
* Various command streams can be submitted to the same context.
|
||||
*
|
||||
* \param allow_context_lost If true, lost contexts skip command submission and report
|
||||
* the reset status.
|
||||
* If false, losing the context results in undefined behavior.
|
||||
* \param flags PIPE_CONTEXT_* flags (priority, allow losing the context)
|
||||
*/
|
||||
struct radeon_winsys_ctx *(*ctx_create)(struct radeon_winsys *ws,
|
||||
enum radeon_ctx_priority priority,
|
||||
bool allow_context_lost);
|
||||
struct radeon_winsys_ctx *(*ctx_create)(struct radeon_winsys *ws, unsigned flags);
|
||||
|
||||
/**
|
||||
* Destroy a context.
|
||||
|
||||
@@ -247,31 +247,15 @@ amdgpu_cs_get_next_fence(struct radeon_cmdbuf *rcs)
|
||||
|
||||
/* CONTEXTS */
|
||||
|
||||
static uint32_t
|
||||
radeon_to_amdgpu_priority(enum radeon_ctx_priority radeon_priority)
|
||||
{
|
||||
switch (radeon_priority) {
|
||||
case RADEON_CTX_PRIORITY_REALTIME:
|
||||
return AMDGPU_CTX_PRIORITY_VERY_HIGH;
|
||||
case RADEON_CTX_PRIORITY_HIGH:
|
||||
return AMDGPU_CTX_PRIORITY_HIGH;
|
||||
case RADEON_CTX_PRIORITY_MEDIUM:
|
||||
return AMDGPU_CTX_PRIORITY_NORMAL;
|
||||
case RADEON_CTX_PRIORITY_LOW:
|
||||
return AMDGPU_CTX_PRIORITY_LOW;
|
||||
default:
|
||||
unreachable("Invalid context priority");
|
||||
}
|
||||
}
|
||||
|
||||
static struct radeon_winsys_ctx *amdgpu_ctx_create(struct radeon_winsys *rws,
|
||||
enum radeon_ctx_priority priority,
|
||||
bool allow_context_lost)
|
||||
static struct radeon_winsys_ctx *amdgpu_ctx_create(struct radeon_winsys *rws, unsigned flags)
|
||||
{
|
||||
struct amdgpu_ctx *ctx = CALLOC_STRUCT(amdgpu_ctx);
|
||||
int r;
|
||||
struct amdgpu_bo_alloc_request alloc_buffer = {};
|
||||
uint32_t amdgpu_priority = radeon_to_amdgpu_priority(priority);
|
||||
assert(!(flags & PIPE_CONTEXT_REALTIME_PRIORITY)); /* not supported */
|
||||
uint32_t amdgpu_priority = flags & PIPE_CONTEXT_HIGH_PRIORITY ? AMDGPU_CTX_PRIORITY_HIGH :
|
||||
flags & PIPE_CONTEXT_LOW_PRIORITY ? AMDGPU_CTX_PRIORITY_LOW :
|
||||
AMDGPU_CTX_PRIORITY_NORMAL;
|
||||
ac_drm_device *dev;
|
||||
ac_drm_bo buf_handle;
|
||||
|
||||
@@ -280,8 +264,7 @@ static struct radeon_winsys_ctx *amdgpu_ctx_create(struct radeon_winsys *rws,
|
||||
|
||||
ctx->aws = amdgpu_winsys(rws);
|
||||
ctx->reference.count = 1;
|
||||
ctx->allow_context_lost = allow_context_lost;
|
||||
ctx->priority = priority;
|
||||
ctx->flags = flags;
|
||||
|
||||
dev = ctx->aws->dev;
|
||||
|
||||
@@ -457,7 +440,7 @@ amdgpu_ctx_set_sw_reset_status(struct radeon_winsys_ctx *rwctx, enum pipe_reset_
|
||||
|
||||
ctx->sw_status = status;
|
||||
|
||||
if (!ctx->allow_context_lost) {
|
||||
if (!(ctx->flags & PIPE_CONTEXT_LOSE_CONTEXT_ON_RESET)) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
@@ -939,7 +922,7 @@ amdgpu_cs_create(struct radeon_cmdbuf *rcs,
|
||||
} else {
|
||||
switch (ip_type) {
|
||||
case AMD_IP_GFX:
|
||||
if (ctx->priority >= RADEON_CTX_PRIORITY_HIGH)
|
||||
if (ctx->flags & PIPE_CONTEXT_HIGH_PRIORITY)
|
||||
acs->queue_index = AMDGPU_QUEUE_GFX_HIGH_PRIO;
|
||||
else
|
||||
acs->queue_index = AMDGPU_QUEUE_GFX;
|
||||
|
||||
@@ -31,14 +31,9 @@ struct amdgpu_ctx {
|
||||
uint32_t user_fence_bo_kms_handle;
|
||||
uint64_t *user_fence_cpu_address_base;
|
||||
|
||||
/* If true, report lost contexts and skip command submission.
|
||||
* If false, terminate the process.
|
||||
*/
|
||||
bool allow_context_lost;
|
||||
|
||||
/* Lost context status due to ioctl and allocation failures. */
|
||||
enum pipe_reset_status sw_status;
|
||||
enum radeon_ctx_priority priority;
|
||||
unsigned flags;
|
||||
};
|
||||
|
||||
struct amdgpu_cs_buffer {
|
||||
|
||||
@@ -52,8 +52,7 @@ static void radeon_fence_reference(struct radeon_winsys *ws,
|
||||
struct pipe_fence_handle *src);
|
||||
|
||||
static struct radeon_winsys_ctx *radeon_drm_ctx_create(struct radeon_winsys *ws,
|
||||
enum radeon_ctx_priority priority,
|
||||
bool allow_context_lost)
|
||||
unsigned flags)
|
||||
{
|
||||
struct radeon_ctx *ctx = CALLOC_STRUCT(radeon_ctx);
|
||||
if (!ctx)
|
||||
|
||||
Reference in New Issue
Block a user