aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
index c539fb6a597e..d71dc164b469 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
@@ -227,6 +227,40 @@ static int amdgpu_ctx_query(struct amdgpu_device *adev,
227 return 0; 227 return 0;
228} 228}
229 229
230static int amdgpu_ctx_query2(struct amdgpu_device *adev,
231 struct amdgpu_fpriv *fpriv, uint32_t id,
232 union drm_amdgpu_ctx_out *out)
233{
234 struct amdgpu_ctx *ctx;
235 struct amdgpu_ctx_mgr *mgr;
236
237 if (!fpriv)
238 return -EINVAL;
239
240 mgr = &fpriv->ctx_mgr;
241 mutex_lock(&mgr->lock);
242 ctx = idr_find(&mgr->ctx_handles, id);
243 if (!ctx) {
244 mutex_unlock(&mgr->lock);
245 return -EINVAL;
246 }
247
248 out->state.flags = 0x0;
249 out->state.hangs = 0x0;
250
251 if (ctx->reset_counter != atomic_read(&adev->gpu_reset_counter))
252 out->state.flags |= AMDGPU_CTX_QUERY2_FLAGS_RESET;
253
254 if (ctx->vram_lost_counter != atomic_read(&adev->vram_lost_counter))
255 out->state.flags |= AMDGPU_CTX_QUERY2_FLAGS_VRAMLOST;
256
257 if (atomic_read(&ctx->guilty))
258 out->state.flags |= AMDGPU_CTX_QUERY2_FLAGS_GUILTY;
259
260 mutex_unlock(&mgr->lock);
261 return 0;
262}
263
230int amdgpu_ctx_ioctl(struct drm_device *dev, void *data, 264int amdgpu_ctx_ioctl(struct drm_device *dev, void *data,
231 struct drm_file *filp) 265 struct drm_file *filp)
232{ 266{
@@ -258,6 +292,9 @@ int amdgpu_ctx_ioctl(struct drm_device *dev, void *data,
258 case AMDGPU_CTX_OP_QUERY_STATE: 292 case AMDGPU_CTX_OP_QUERY_STATE:
259 r = amdgpu_ctx_query(adev, fpriv, id, &args->out); 293 r = amdgpu_ctx_query(adev, fpriv, id, &args->out);
260 break; 294 break;
295 case AMDGPU_CTX_OP_QUERY_STATE2:
296 r = amdgpu_ctx_query2(adev, fpriv, id, &args->out);
297 break;
261 default: 298 default:
262 return -EINVAL; 299 return -EINVAL;
263 } 300 }