<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">On 1/4/2025 8:45 PM, Jiang Liu wrote:<br>
</div>
<blockquote type="cite" cite="mid:f19a505b4ca42302ea8b8c399c07eb8f9f06a0c6.1736044362.git.gerry@linux.alibaba.com">
<pre wrap="" class="moz-quote-pre">Function detects initialization status by checking sched->ops, so set
sched->ops to non-NULL just before return in function drm_sched_init()</pre>
</blockquote>
<p>This commit message is not what the change did: you <span style="white-space: pre-wrap">set sched->ops to NULL just after return from drm_sched_init.</span></p>
<p><span style="white-space: pre-wrap">Other than that this change looks good to me.</span></p>
<p><span style="white-space: pre-wrap">Regards</span></p>
<p><span style="white-space: pre-wrap">Xiaogang
</span></p>
<br>
<blockquote type="cite" cite="mid:f19a505b4ca42302ea8b8c399c07eb8f9f06a0c6.1736044362.git.gerry@linux.alibaba.com">
<pre wrap="" class="moz-quote-pre">
to avoid possible invalid memory access on error recover path.
Signed-off-by: Jiang Liu <a class="moz-txt-link-rfc2396E" href="mailto:gerry@linux.alibaba.com"><gerry@linux.alibaba.com></a>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 1 +
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 5ff53a3b9851..475ab635c699 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2857,6 +2857,7 @@ static int amdgpu_device_init_schedulers(struct amdgpu_device *adev)
if (r) {
DRM_ERROR("Failed to create scheduler on ring %s.\n",
ring->name);
+ ring->sched.ops = NULL;
return r;
}
r = amdgpu_uvd_entity_init(adev, ring);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index 2f24a6aa13bf..b5e87b515139 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -656,8 +656,10 @@ void amdgpu_fence_driver_sw_fini(struct amdgpu_device *adev)
* The natural check would be sched.ready, which is
* set as drm_sched_init() finishes...
*/
- if (ring->sched.ops)
+ if (ring->sched.ops) {
drm_sched_fini(&ring->sched);
+ ring->sched.ops = NULL;
+ }
for (j = 0; j <= ring->fence_drv.num_fences_mask; ++j)
dma_fence_put(ring->fence_drv.fences[j]);
</pre>
</blockquote>
</body>
</html>