drm/amdgpu: add begin/end_use ring callbacks
authorChristian König <christian.koenig@amd.com>
Wed, 20 Jul 2016 11:49:34 +0000 (13:49 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 29 Jul 2016 18:37:02 +0000 (14:37 -0400)
For manual UVD/VCE power and clock gating.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c

index 30124f4916d20a1a968d2b35b60f32345b4bfb1b..51c4924b60b7fdaf12cb37974fe624a89db8cd73 100644 (file)
@@ -313,6 +313,9 @@ struct amdgpu_ring_funcs {
        void (*pad_ib)(struct amdgpu_ring *ring, struct amdgpu_ib *ib);
        unsigned (*init_cond_exec)(struct amdgpu_ring *ring);
        void (*patch_cond_exec)(struct amdgpu_ring *ring, unsigned offset);
+       /* note usage for clock and power gating */
+       void (*begin_use)(struct amdgpu_ring *ring);
+       void (*end_use)(struct amdgpu_ring *ring);
 };
 
 /*
index f305f6309e8e4a8830fb03e62cf8e35aef3d4268..85aeb0a804bbcef1a5860f7bcca3ba2c822386b8 100644 (file)
@@ -75,6 +75,10 @@ int amdgpu_ring_alloc(struct amdgpu_ring *ring, unsigned ndw)
 
        ring->count_dw = ndw;
        ring->wptr_old = ring->wptr;
+
+       if (ring->funcs->begin_use)
+               ring->funcs->begin_use(ring);
+
        return 0;
 }
 
@@ -127,6 +131,9 @@ void amdgpu_ring_commit(struct amdgpu_ring *ring)
 
        mb();
        amdgpu_ring_set_wptr(ring);
+
+       if (ring->funcs->end_use)
+               ring->funcs->end_use(ring);
 }
 
 /**
@@ -139,6 +146,9 @@ void amdgpu_ring_commit(struct amdgpu_ring *ring)
 void amdgpu_ring_undo(struct amdgpu_ring *ring)
 {
        ring->wptr = ring->wptr_old;
+
+       if (ring->funcs->end_use)
+               ring->funcs->end_use(ring);
 }
 
 /**