drm/amdgpu: modify mcbp implement for gfx9
Subsystems (2)
PATCH 1/3 drm/amdgpu: modify mcbp implement for gfx9
From: "Jiadong.Zhu" <[email protected]>
1. Use unmap_queue package to trigger preemption on gfx9 Add trailing fence to track the preemption done.
2. Modify emit_ce_meta emit_de_meta functions for the resumed ibs.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 1 + drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 156 ++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/soc15d.h | 2 + 3 files changed, 138 insertions(+), 21 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1 -0
@@ -59,6 +59,7 @@ enum amdgpu_ring_priority_level {#define AMDGPU_FENCE_FLAG_64BIT (1 << 0)#define AMDGPU_FENCE_FLAG_INT (1 << 1)#define AMDGPU_FENCE_FLAG_TC_WB_ONLY (1 << 2) +#define AMDGPU_FENCE_FLAG_EXEC (1 << 3)#define to_amdgpu_ring (s) container_of((s), struct amdgpu_ring, sched)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +135 -21
230 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/soc15d.h +2 -0
@@ -162,6 +162,7 @@* 2 - Bypass */ #define INDIRECT_BUFFER_PRE_ENB (x) ((x) << 21) +#define INDIRECT_BUFFER_PRE_RESUME (x) ((x) << 30)#define PACKET3_COPY_DATA 0x40#define PACKET3_PFP_SYNC_ME 0x42#define PACKET3_COND_WRITE 0x45
@@ -184,6 +185,7 @@#define EOP_TC_ACTION_EN (1 << 17)/* L2 */ #define EOP_TC_NC_ACTION_EN (1 << 19)#define EOP_TC_MD_ACTION_EN (1 << 21)/* L2 metadata */ +#define EOP_EXEC (1 << 28)/* For Trailing Fence */ #define DATA_SEL (x) ((x) << 29)/* 0 - discard
Signature · 1 line
2.25.1
PATCH 2/3 drm/amdgpu: add mcbp support for sdma v4.0
From: "Jiadong.Zhu" <[email protected]>
Set register to enable mcbp according to amdgpu_mcbp. Add sdma preempt_ib function used for debugfs test.
--- drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 53 ++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +53 -0
@@ -1502,6 +1502,11 @@ static int sdma_v4_0_start(struct amdgpu_device *adev)/* set utc l1 enable flag always to 1 */ temp =RREG32_SDMA (i, mmSDMA0_CNTL); temp =REG_SET_FIELD (temp,SDMA0_CNTL ,UTC_L1_ENABLE ,1 ); + +if (amdgpu_mcbp){ +/* enable MCBP */ + temp =REG_SET_FIELD (temp,SDMA0_CNTL ,MIDCMD_PREEMPT_ENABLE ,1 ); + }WREG32_SDMA (i, mmSDMA0_CNTL, temp);if (!amdgpu_sriov_vf (adev)) {
@@ -2102,6 +2107,53 @@ static int sdma_v4_0_soft_reset(void *handle)return 0 ; } +static int sdma_v4_0_ring_preempt_ib (struct amdgpu_ring *ring) +{ +int i, r =0 ; +struct amdgpu_device *adev = ring->adev; +u32 index =0 ; +u64 sdma_gfx_preempt; + +amdgpu_sdma_get_index_from_ring (ring, &index); +if (index ==0 ) + sdma_gfx_preempt = mmSDMA0_GFX_PREEMPT; +else + sdma_gfx_preempt = mmSDMA1_GFX_PREEMPT; + +/* assert preemption condition */ +amdgpu_ring_set_preempt_cond_exec (ring, false); + +/* emit the trailing fence */ + ring->trail_seq +=1 ; +amdgpu_ring_alloc (ring,10 ); +sdma_v4_0_ring_emit_fence (ring, ring->trail_fence_gpu_addr, + ring->trail_seq,0 ); +amdgpu_ring_commit (ring); + +/* assert IB preemption */ +WREG32 (sdma_gfx_preempt,1 ); + +/* poll the trailing fence */ +for (i =0 ; i < adev->usec_timeout; i++) { +if (ring->trail_seq == +le32_to_cpu (*(ring->trail_fence_cpu_addr))) +break ; +udelay (1 ); + } + +if (i >= adev->usec_timeout) { + r = -EINVAL ; +DRM_ERROR ("ring %d failed to be preempted\n" , ring->idx); + } + +/* deassert IB preemption */ +WREG32 (sdma_gfx_preempt,0 ); + +/* deassert the preemption condition */ +amdgpu_ring_set_preempt_cond_exec (ring, true); +return r; +} + static int sdma_v4_0_set_trap_irq_state(struct amdgpu_device *adev, struct amdgpu_irq_src *source, unsigned type,
@@ -2435,6 +2487,7 @@ static const struct amdgpu_ring_funcs sdma_v4_0_ring_funcs = { .emit_wreg = sdma_v4_0_ring_emit_wreg, .emit_reg_wait = sdma_v4_0_ring_emit_reg_wait, .emit_reg_write_reg_wait = amdgpu_ring_emit_reg_write_reg_wait_helper, + .preempt_ib = sdma_v4_0_ring_preempt_ib, };/*
Signature · 1 line
2.25.1
PATCH 3/3 drm/amdgpu: skip put fence if signal fails
In reply to [email protected]From: "Jiadong.Zhu" <[email protected]>
Dma_fence_signal returning non-zero indicates that the fence is signaled and put somewhere else. Skip dma_fence_put to make the fence refcount correct.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2 -2
@@ -1500,8 +1500,8 @@ static void amdgpu_ib_preempt_signal_fences(struct dma_fence **fences, fence = fences[i];if (!fence)continue ; -dma_fence_signal (fence); -dma_fence_put (fence); +if (!dma_fence_signal (fence)) +dma_fence_put (fence); } }
Signature · 1 line
2.25.1
Re: [PATCH 3/3] drm/amdgpu: skip put fence if signal fails
Am 15.07.22 um 10:43 schrieb [email protected]:
Quoted 5 lines
From: "Jiadong.Zhu" <[email protected]>
Dma_fence_signalreturning non-zero indicates that the fence is signaled and put somewhere else. Skipdma_fence_putto make the fence refcount correct.
Well quite a big NAK on this.
Reference counting should be completely independent where a fence signals.
Andrey can you take a look at this as well?
Thanks,
Christian.
Quoted 21 lines
Signed-off-by Jiadong.Zhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-2@@ -1500,8 +1500,8 @@ static void amdgpu_ib_preempt_signal_fences(struct dma_fence **fences, fence = fences[i];if (!fence)continue ; -dma_fence_signal (fence); -dma_fence_put (fence); +if (!dma_fence_signal (fence)) +dma_fence_put (fence); } }
Zhu, Jiadong
Reviewed-by Andrey GrodzovskyRE: [PATCH 3/3] drm/amdgpu: skip put fence if signal fails
[AMD Official Use Only - General]
Hi Christian,
The resubmitted job in function amdgpu_ib_preempt_job_recovery returns the same hw fence because of this commit:
static void amdgpu_ib_preempt_job_recovery(struct drm_gpu_scheduler *sched)
{
struct drm_sched_job *s_job;
struct dma_fence *fence;
spin_lock(&sched->job_list_lock);
list_for_each_entry(s_job, &sched->pending_list, list) {
fence = sched->ops->run_job(s_job); //fence returned has the same address with swapped fences
dma_fence_put(fence);
}
spin_unlock(&sched->job_list_lock);
}commit c530b02f39850a639b72d01ebbf7e5d745c60831
Author: Jack Zhang <[email protected]> Date: Wed May 12 15:06:35 2021 +0800
drm/amd/amdgpu embed hw_fence into amdgpu_job
Why: Previously hw fence is alloced separately with job. It caused historical lifetime issues and corner cases. The ideal situation is to take fence to manage both job and fence's lifetime, and simplify the design of gpu-scheduler.
How:
We propose to embed hw_fence into amdgpu_job.
1. We cover the normal job submission by this method.
2. For ib_test, and submit without a parent job keep the legacy way to create a hw fence separately.
v2:
use AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT to show that the fence is embedded in a job.
v3:
remove redundant variable ring in amdgpu_job
v4:
add tdr sequence support for this feature. Add a job_run_counter to indicate whether this job is a resubmit job.
v5
add missing handling in amdgpu_fence_enable_signaling
Reviewed by: Monk Liu <[email protected]>
Thus the fence we swapped out is signaled and put twice in the following 2 functions and we get " refcount_t: underflow; use-after-free. " errors latter.
/* wait for jobs finished */
amdgpu_fence_wait_empty(ring); //signal and put the resubmitted jobs fence.
/* signal the old fences */
amdgpu_ib_preempt_signal_fences(fences, length); //signal and put the previous swapped fence, signal would return -22.
Thanks,
Jiadong
-----Original Message-----
From: Christian König <[email protected]>
Sent: Friday, July 15, 2022 4:48 PM
To: Zhu, Jiadong <[email protected]>; [email protected]; Grodzovsky, Andrey <[email protected]>
Cc: Huang, Ray <[email protected]>; Liu, Aaron <[email protected]>
Subject: Re: [PATCH 3/3] drm/amdgpu: skip put fence if signal fails
[CAUTION: External Email]
Am 15.07.22 um 10:43 schrieb [email protected]:
Quoted 5 lines
From: "Jiadong.Zhu" <[email protected]>
Dma_fence_signalreturning non-zero indicates that the fence is signaled and put somewhere else.
Skipdma_fence_putto make the fence refcount correct.
Well quite a big NAK on this.
Reference counting should be completely independent where a fence signals.
Andrey can you take a look at this as well?
Thanks,
Christian.
Quoted 22 lines
Signed-off-by Jiadong.Zhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-2@@ -1500,8 +1500,8 @@ static void amdgpu_ib_preempt_signal_fences(struct dma_fence **fences, fence = fences[i];if (!fence)continue ; -dma_fence_signal (fence); -dma_fence_put (fence); +if (!dma_fence_signal (fence)) +dma_fence_put (fence); } }
Zhu, Jiadong
Reviewed-by Andrey GrodzovskyRE: [PATCH 3/3] drm/amdgpu: skip put fence if signal fails
[AMD Official Use Only - General]
Updated some comments
-----Original Message-----
From: Zhu, Jiadong
Sent: Friday, July 15, 2022 5:13 PM
To: Christian König <[email protected]>; [email protected]; Grodzovsky, Andrey <[email protected]>
Cc: Huang, Ray <[email protected]>; Liu, Aaron <[email protected]>
Subject: RE: [PATCH 3/3] drm/amdgpu: skip put fence if signal fails
Hi Christian,
The resubmitted job in function amdgpu_ib_preempt_job_recovery returns the same hw fence because of this commit:
static void amdgpu_ib_preempt_job_recovery(struct drm_gpu_scheduler *sched) {
struct drm_sched_job *s_job;
struct dma_fence *fence;
spin_lock(&sched->job_list_lock);
list_for_each_entry(s_job, &sched->pending_list, list) {
fence = sched->ops->run_job(s_job); //fence returned has the same address with swapped fences
dma_fence_put(fence);
}
spin_unlock(&sched->job_list_lock);
}commit c530b02f39850a639b72d01ebbf7e5d745c60831
Author: Jack Zhang <[email protected]> Date: Wed May 12 15:06:35 2021 +0800
drm/amd/amdgpu embed hw_fence into amdgpu_job
Why: Previously hw fence is alloced separately with job. It caused historical lifetime issues and corner cases. The ideal situation is to take fence to manage both job and fence's lifetime, and simplify the design of gpu-scheduler.
How:
We propose to embed hw_fence into amdgpu_job.
1. We cover the normal job submission by this method.
2. For ib_test, and submit without a parent job keep the legacy way to create a hw fence separately.
v2:
use AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT to show that the fence is embedded in a job.
v3:
remove redundant variable ring in amdgpu_job
v4:
add tdr sequence support for this feature. Add a job_run_counter to indicate whether this job is a resubmit job.
v5
add missing handling in amdgpu_fence_enable_signaling
Reviewed by: Monk Liu <[email protected]>
Thus the fence we swapped out is signaled and put twice in the following 2 functions and we get " refcount_t: underflow; use-after-free. " errors latter.
/* wait for jobs finished */
amdgpu_fence_wait_empty(ring); //wait on the resubmitted fence which is signaled and put somewhere else. The refcount decreased by 1 after amdgpu_fence_wait_empty.
/* signal the old fences */
amdgpu_ib_preempt_signal_fences(fences, length); //signal and put the previous swapped fence, signal would return -22.
Thanks,
Jiadong
-----Original Message-----
From: Christian König <[email protected]>
Sent: Friday, July 15, 2022 4:48 PM
To: Zhu, Jiadong <[email protected]>; [email protected]; Grodzovsky, Andrey <[email protected]>
Cc: Huang, Ray <[email protected]>; Liu, Aaron <[email protected]>
Subject: Re: [PATCH 3/3] drm/amdgpu: skip put fence if signal fails
[CAUTION: External Email]
Am 15.07.22 um 10:43 schrieb [email protected]:
Quoted 5 lines
From: "Jiadong.Zhu" <[email protected]>
Dma_fence_signalreturning non-zero indicates that the fence is signaled and put somewhere else.
Skipdma_fence_putto make the fence refcount correct.
Well quite a big NAK on this.
Reference counting should be completely independent where a fence signals.
Andrey can you take a look at this as well?
Thanks,
Christian.
Quoted 22 lines
Signed-off-by Jiadong.Zhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-2@@ -1500,8 +1500,8 @@ static void amdgpu_ib_preempt_signal_fences(struct dma_fence **fences, fence = fences[i];if (!fence)continue ; -dma_fence_signal (fence); -dma_fence_put (fence); +if (!dma_fence_signal (fence)) +dma_fence_put (fence); } }
Re: [PATCH 3/3] drm/amdgpu: skip put fence if signal fails
Quoted 65 lines · Jiadong
[AMD Official Use Only - General]
Updated some comments
-----Original Message-----
From: Zhu, Jiadong
Sent: Friday, July 15, 2022 5:13 PM
To: Christian König <[email protected]>; [email protected]; Grodzovsky, Andrey <[email protected]>
Cc: Huang, Ray <[email protected]>; Liu, Aaron <[email protected]>
Subject: RE: [PATCH 3/3] drm/amdgpu: skip put fence if signal failsHi Christian,
The resubmitted job in function
amdgpu_ib_preempt_job_recoveryreturns the same hw fence because of this commit:static void amdgpu_ib_preempt_job_recovery(struct drm_gpu_scheduler *sched) { struct drm_sched_job *s_job; struct dma_fence *fence; spin_lock(&sched->job_list_lock); list_for_each_entry(s_job, &sched->pending_list, list) { fence = sched->ops->run_job(s_job); //fence returned has the same address with swapped fences dma_fence_put(fence); } spin_unlock(&sched->job_list_lock); }commit
c530b02f39850a639b72d01ebbf7e5d745c60831Author: Jack Zhang <[email protected]> Date: Wed May 12 15:06:35 2021 +0800drm/amd/amdgpu embed
hw_fenceintoamdgpu_jobWhy: Previously hw fence is alloced separately with job. It caused historical lifetime issues and corner cases. The ideal situation is to take fence to manage both job and fence's lifetime, and simplify the design of gpu-scheduler.
How:
We propose to embedhw_fenceintoamdgpu_job.
1. We cover the normal job submission by this method.
2. Forib_test, and submit without a parent job keep the legacy way to create a hw fence separately.
v2:
useAMDGPU_FENCE_FLAG_EMBED_IN_JOB_BITto show that the fence is embedded in a job.
v3:
remove redundant variable ring inamdgpu_job
v4:
add tdr sequence support for this feature. Add ajob_run_counterto indicate whether this job is a resubmit job.
v5
add missing handling inamdgpu_fence_enable_signalingSigned-off-by Jingwen Chen <[email protected]>Signed-off-by Jack Zhang <[email protected]>Reviewed-by Andrey Grodzovsky <[email protected]>Reviewed by: Monk Liu <[email protected]>
Signed-off-by Alex Deucher <[email protected]>Thus the fence we swapped out is signaled and put twice in the following 2 functions and we get "
refcount_t: underflow; use-after-free. " errors latter.
Quoted 8 lines
/* wait for jobs finished */
amdgpu_fence_wait_empty(ring); //wait on the resubmitted fence which is signaled and put somewhere else. The refcount decreased by 1 afteramdgpu_fence_wait_empty./* signal the old fences */
amdgpu_ib_preempt_signal_fences(fences, length); //signal and put the previous swapped fence, signal would return -22.Thanks,
Jiadong
Did you have 'drm/amdgpu: Follow up change to previous drm scheduler change.' this commit in your branch while you encountered this problem ? I don't see an underflow issue for the preempted job when inspecting the code with this commit in mind -
amdgpu_fence_emit
dma_fence_init 1
dma_fence_get(fence) 2 rcu_assign_pointer(*ptr, dma_fence_get(fence) 3
drm_sched_main
s_fence->parent = dma_fence_get(fence); 4
dma_fence_put(fence); 3
amdgpu_ib_preempt_job_recovery
amdgpu_fence_emit
if (job && job->job_run_counter) -> dma_fence_get(fence); 4 rcu_assign_pointer(*ptr, dma_fence_get(fence)); 5
dma_fence_put(fence); 4
amdgpu_fence_wait_empty
dma_fence_get_rcu(fence) 5
dma_fence_put(fence) 4
amdgpu_process_fence (EOP interrupt for re-submission of preempted job) dma_fence_put 3
amdgpu_ib_preempt_signal_fences
dma_fence_put 2
amdgpu_job_free_cb
dma_fence_put(&job->hw_fence) 1
drm_sched_fence_release_scheduled
dma_fence_put(fence->parent); 0
Also take a look here for reference - https://drive.google.com/file/d/1yEoeW6OQC9WnwmzFW6NBLhFP_jD0xcHm/view
Andrey
Andrey
Quoted 47 lines
-----Original Message-----
From: Christian König <[email protected]>
Sent: Friday, July 15, 2022 4:48 PM
To: Zhu, Jiadong <[email protected]>; [email protected]; Grodzovsky, Andrey <[email protected]>
Cc: Huang, Ray <[email protected]>; Liu, Aaron <[email protected]>
Subject: Re: [PATCH 3/3] drm/amdgpu: skip put fence if signal fails[CAUTION: External Email]
Am 15.07.22 um 10:43 schrieb [email protected]:
Quoted 5 lines
From: "Jiadong.Zhu" <[email protected]>
Dma_fence_signalreturning non-zero indicates that the fence is signaled and put somewhere else.
Skipdma_fence_putto make the fence refcount correct.Well quite a big NAK on this.
Reference counting should be completely independent where a fence signals.
Andrey can you take a look at this as well?
Thanks,
Christian.Quoted 21 lines
Signed-off-by Jiadong.Zhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-2@@ -1500,8 +1500,8 @@ static void amdgpu_ib_preempt_signal_fences(struct dma_fence **fences, fence = fences[i];if (!fence)continue ; -dma_fence_signal (fence); -dma_fence_put (fence); +if (!dma_fence_signal (fence)) +dma_fence_put (fence); } }
RE: [PATCH 3/3] drm/amdgpu: skip put fence if signal fails
[AMD Official Use Only - General]
Hi Andrey,
Thank you for your clarifying.
The refcount modified by amdgpu_fence_emit on my side is different.
I update my code and get the patch 'drm/amdgpu: Follow up change to previous drm scheduler change.' , the " underflow " disappears.
My patch is not needed.
Thanks,
Jiadong
-----Original Message-----
From: Grodzovsky, Andrey <[email protected]>
Sent: Friday, July 15, 2022 11:43 PM
To: Zhu, Jiadong <[email protected]>; Christian König <[email protected]>; [email protected]
Cc: Huang, Ray <[email protected]>; Liu, Aaron <[email protected]>
Subject: Re: [PATCH 3/3] drm/amdgpu: skip put fence if signal fails
Quoted 67 lines · Jiadong
[AMD Official Use Only - General]
Updated some comments
-----Original Message-----
From: Zhu, Jiadong
Sent: Friday, July 15, 2022 5:13 PM
To: Christian König <[email protected]>; [email protected]; Grodzovsky, Andrey <[email protected]>
Cc: Huang, Ray <[email protected]>; Liu, Aaron <[email protected]>
Subject: RE: [PATCH 3/3] drm/amdgpu: skip put fence if signal failsHi Christian,
The resubmitted job in function
amdgpu_ib_preempt_job_recoveryreturns the same hw fence because of this commit:static void amdgpu_ib_preempt_job_recovery(struct drm_gpu_scheduler *sched) { struct drm_sched_job *s_job; struct dma_fence *fence; spin_lock(&sched->job_list_lock); list_for_each_entry(s_job, &sched->pending_list, list) { fence = sched->ops->run_job(s_job); //fence returned has the same address with swapped fences dma_fence_put(fence); } spin_unlock(&sched->job_list_lock); }commit
c530b02f39850a639b72d01ebbf7e5d745c60831Author: Jack Zhang <[email protected]> Date: Wed May 12 15:06:35 2021 +0800drm/amd/amdgpu embed
hw_fenceintoamdgpu_jobWhy: Previously hw fence is alloced separately with job. It caused historical lifetime issues and corner cases. The ideal situation is to take fence to manage both job and fence's lifetime, and simplify the design of gpu-scheduler.
How:
We propose to embedhw_fenceintoamdgpu_job.
1. We cover the normal job submission by this method.
2. Forib_test, and submit without a parent job keep the legacy way to create a hw fence separately.
v2:
useAMDGPU_FENCE_FLAG_EMBED_IN_JOB_BITto show that the fence is embedded in a job.
v3:
remove redundant variable ring inamdgpu_job
v4:
add tdr sequence support for this feature. Add ajob_run_counterto indicate whether this job is a resubmit job.
v5
add missing handling inamdgpu_fence_enable_signalingSigned-off-by Jingwen Chen <[email protected]>Signed-off-by Jack Zhang <[email protected]>Reviewed-by Andrey Grodzovsky <[email protected]>Reviewed by: Monk Liu <[email protected]>
Signed-off-by Alex Deucher <[email protected]>Thus the fence we swapped out is signaled and put twice in the following 2 functions and we get "
refcount_t: underflow; use-after-free. " errors latter.
Quoted 8 lines
/* wait for jobs finished */
amdgpu_fence_wait_empty(ring); //wait on the resubmitted fence which is signaled and put somewhere else. The refcount decreased by 1 afteramdgpu_fence_wait_empty./* signal the old fences */
amdgpu_ib_preempt_signal_fences(fences, length); //signal and put the previous swapped fence, signal would return -22.Thanks,
Jiadong
Did you have 'drm/amdgpu: Follow up change to previous drm scheduler change.' this commit in your branch while you encountered this problem ? I don't see an underflow issue
for the preempted job when inspecting the code with this commit in mind -
amdgpu_fence_emit
dma_fence_init 1
dma_fence_get(fence) 2 rcu_assign_pointer(*ptr, dma_fence_get(fence) 3
drm_sched_main
s_fence->parent = dma_fence_get(fence); 4
dma_fence_put(fence); 3amdgpu_ib_preempt_job_recovery
amdgpu_fence_emit
if (job && job->job_run_counter) -> dma_fence_get(fence); 4
rcu_assign_pointer(*ptr, dma_fence_get(fence)); 5
dma_fence_put(fence); 4amdgpu_fence_wait_empty
dma_fence_get_rcu(fence) 5
dma_fence_put(fence) 4
amdgpu_process_fence (EOP interrupt for re-submission of preempted job)
dma_fence_put 3
amdgpu_ib_preempt_signal_fences
dma_fence_put 2
amdgpu_job_free_cb
dma_fence_put(&job->hw_fence) 1
drm_sched_fence_release_scheduled
dma_fence_put(fence->parent); 0
Also take a look here for reference -
https://drive.google.com/file/d/1yEoeW6OQC9WnwmzFW6NBLhFP_jD0xcHm/view
Andrey
Andrey
Quoted 48 lines
-----Original Message-----
From: Christian König <[email protected]>
Sent: Friday, July 15, 2022 4:48 PM
To: Zhu, Jiadong <[email protected]>; [email protected]; Grodzovsky, Andrey <[email protected]>
Cc: Huang, Ray <[email protected]>; Liu, Aaron <[email protected]>
Subject: Re: [PATCH 3/3] drm/amdgpu: skip put fence if signal fails[CAUTION: External Email]
Am 15.07.22 um 10:43 schrieb [email protected]:
Quoted 5 lines
From: "Jiadong.Zhu" <[email protected]>
Dma_fence_signalreturning non-zero indicates that the fence is signaled and put somewhere else.
Skipdma_fence_putto make the fence refcount correct.Well quite a big NAK on this.
Reference counting should be completely independent where a fence signals.
Andrey can you take a look at this as well?
Thanks,
Christian.Quoted 21 lines
Signed-off-by Jiadong.Zhu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2
-2@@ -1500,8 +1500,8 @@ static void amdgpu_ib_preempt_signal_fences(struct dma_fence **fences, fence = fences[i];if (!fence)continue ; -dma_fence_signal (fence); -dma_fence_put (fence); +if (!dma_fence_signal (fence)) +dma_fence_put (fence); } }