drm/amdgpu: check context id for context switching (v2)
authorJammy Zhou <Jammy.Zhou@amd.com>
Fri, 8 May 2015 14:18:47 +0000 (22:18 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 4 Jun 2015 01:03:29 +0000 (21:03 -0400)
check the filp is not robust, and sometimes different contexts may
have same filp value.

v2: check both filp and ctx_id

Signed-off-by: Jammy Zhou <Jammy.Zhou@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c

index bf0c607de195c9c063924b1524f80e294fa2c571..a88302c0c93a44e75b0ca9ce191e3109f06804fc 100644 (file)
@@ -945,6 +945,7 @@ struct amdgpu_ring {
        unsigned                next_rptr_offs;
        unsigned                fence_offs;
        struct drm_file         *current_filp;
+       unsigned                current_ctx;
        bool                    need_ctx_switch;
        enum amdgpu_ring_type   type;
        char                    name[16];
index 86b93245bf9d850dc81f164046399b9aaeaee6e3..1035e443700f7bc24a9850f69299f94b0eaa1c6a 100644 (file)
@@ -642,8 +642,10 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,
                        ib->is_const_ib = true;
                if (chunk_ib->flags & AMDGPU_IB_FLAG_GDS)
                        ib->gds_needed = true;
-               if (ib->ring->current_filp != parser->filp) {
+               if ((ib->ring->current_filp != parser->filp) ||
+                   (ib->ring->current_ctx != parser->ctx_id)) {
                        ib->ring->need_ctx_switch = true;
+                       ib->ring->current_ctx = parser->ctx_id;
                        ib->ring->current_filp = parser->filp;
                }