|
41 | 41 | #include "amdgpu_trace.h" |
42 | 42 | #include "amdgpu_reset.h" |
43 | 43 |
|
44 | | -/* |
45 | | - * Fences mark an event in the GPUs pipeline and are used |
46 | | - * for GPU/CPU synchronization. When the fence is written, |
47 | | - * it is expected that all buffers associated with that fence |
48 | | - * are no longer in use by the associated ring on the GPU and |
49 | | - * that the relevant GPU caches have been flushed. |
50 | | - */ |
51 | | - |
52 | | -struct amdgpu_fence { |
53 | | - struct dma_fence base; |
54 | | - |
55 | | - /* RB, DMA, etc. */ |
56 | | - struct amdgpu_ring *ring; |
57 | | - ktime_t start_timestamp; |
58 | | -}; |
59 | | - |
60 | 44 | static struct kmem_cache *amdgpu_fence_slab; |
61 | 45 |
|
62 | 46 | int amdgpu_fence_slab_init(void) |
@@ -151,12 +135,12 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **f, struct amd |
151 | 135 | am_fence = kmem_cache_alloc(amdgpu_fence_slab, GFP_ATOMIC); |
152 | 136 | if (am_fence == NULL) |
153 | 137 | return -ENOMEM; |
154 | | - fence = &am_fence->base; |
155 | | - am_fence->ring = ring; |
156 | 138 | } else { |
157 | 139 | /* take use of job-embedded fence */ |
158 | | - fence = &job->hw_fence; |
| 140 | + am_fence = &job->hw_fence; |
159 | 141 | } |
| 142 | + fence = &am_fence->base; |
| 143 | + am_fence->ring = ring; |
160 | 144 |
|
161 | 145 | seq = ++ring->fence_drv.sync_seq; |
162 | 146 | if (job && job->job_run_counter) { |
@@ -718,7 +702,7 @@ void amdgpu_fence_driver_clear_job_fences(struct amdgpu_ring *ring) |
718 | 702 | * it right here or we won't be able to track them in fence_drv |
719 | 703 | * and they will remain unsignaled during sa_bo free. |
720 | 704 | */ |
721 | | - job = container_of(old, struct amdgpu_job, hw_fence); |
| 705 | + job = container_of(old, struct amdgpu_job, hw_fence.base); |
722 | 706 | if (!job->base.s_fence && !dma_fence_is_signaled(old)) |
723 | 707 | dma_fence_signal(old); |
724 | 708 | RCU_INIT_POINTER(*ptr, NULL); |
@@ -780,7 +764,7 @@ static const char *amdgpu_fence_get_timeline_name(struct dma_fence *f) |
780 | 764 |
|
781 | 765 | static const char *amdgpu_job_fence_get_timeline_name(struct dma_fence *f) |
782 | 766 | { |
783 | | - struct amdgpu_job *job = container_of(f, struct amdgpu_job, hw_fence); |
| 767 | + struct amdgpu_job *job = container_of(f, struct amdgpu_job, hw_fence.base); |
784 | 768 |
|
785 | 769 | return (const char *)to_amdgpu_ring(job->base.sched)->name; |
786 | 770 | } |
@@ -810,7 +794,7 @@ static bool amdgpu_fence_enable_signaling(struct dma_fence *f) |
810 | 794 | */ |
811 | 795 | static bool amdgpu_job_fence_enable_signaling(struct dma_fence *f) |
812 | 796 | { |
813 | | - struct amdgpu_job *job = container_of(f, struct amdgpu_job, hw_fence); |
| 797 | + struct amdgpu_job *job = container_of(f, struct amdgpu_job, hw_fence.base); |
814 | 798 |
|
815 | 799 | if (!timer_pending(&to_amdgpu_ring(job->base.sched)->fence_drv.fallback_timer)) |
816 | 800 | amdgpu_fence_schedule_fallback(to_amdgpu_ring(job->base.sched)); |
@@ -845,7 +829,7 @@ static void amdgpu_job_fence_free(struct rcu_head *rcu) |
845 | 829 | struct dma_fence *f = container_of(rcu, struct dma_fence, rcu); |
846 | 830 |
|
847 | 831 | /* free job if fence has a parent job */ |
848 | | - kfree(container_of(f, struct amdgpu_job, hw_fence)); |
| 832 | + kfree(container_of(f, struct amdgpu_job, hw_fence.base)); |
849 | 833 | } |
850 | 834 |
|
851 | 835 | /** |
|
0 commit comments