Skip to content

Commit 8bd8236

Browse files
ChristianKoenigAMDalexdeucher
authored andcommitted
drm/amdgpu: revert "take runtime pm reference when we attach a buffer" v2
This reverts commit b8c415e ("drm/amdgpu: take runtime pm reference when we attach a buffer") and commit 425285d ("drm/amdgpu: add amdgpu runpm usage trace for separate funcs"). Taking a runtime pm reference for DMA-buf is actually completely unnecessary and even dangerous. The problem is that calling pm_runtime_get_sync() from the DMA-buf callbacks is illegal because we have the reservation locked here which is also taken during resume. So this would deadlock. When the buffer is in GTT it is still accessible even when the GPU is powered down and when it is in VRAM the buffer gets migrated to GTT before powering down. The only use case which would make it mandatory to keep the runtime pm reference would be if we pin the buffer into VRAM, and that's not something we currently do. v2: improve the commit message Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> CC: stable@vger.kernel.org
1 parent 49c9ffa commit 8bd8236

3 files changed

Lines changed: 0 additions & 51 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
#include <linux/dma-buf.h>
4242
#include <linux/dma-fence-array.h>
4343
#include <linux/pci-p2pdma.h>
44-
#include <linux/pm_runtime.h>
45-
#include "amdgpu_trace.h"
4644

4745
/**
4846
* amdgpu_dma_buf_attach - &dma_buf_ops.attach implementation
@@ -58,42 +56,11 @@ static int amdgpu_dma_buf_attach(struct dma_buf *dmabuf,
5856
struct drm_gem_object *obj = dmabuf->priv;
5957
struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
6058
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
61-
int r;
6259

6360
if (pci_p2pdma_distance(adev->pdev, attach->dev, false) < 0)
6461
attach->peer2peer = false;
6562

66-
r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
67-
trace_amdgpu_runpm_reference_dumps(1, __func__);
68-
if (r < 0)
69-
goto out;
70-
7163
return 0;
72-
73-
out:
74-
pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
75-
trace_amdgpu_runpm_reference_dumps(0, __func__);
76-
return r;
77-
}
78-
79-
/**
80-
* amdgpu_dma_buf_detach - &dma_buf_ops.detach implementation
81-
*
82-
* @dmabuf: DMA-buf where we remove the attachment from
83-
* @attach: the attachment to remove
84-
*
85-
* Called when an attachment is removed from the DMA-buf.
86-
*/
87-
static void amdgpu_dma_buf_detach(struct dma_buf *dmabuf,
88-
struct dma_buf_attachment *attach)
89-
{
90-
struct drm_gem_object *obj = dmabuf->priv;
91-
struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
92-
struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
93-
94-
pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
95-
pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
96-
trace_amdgpu_runpm_reference_dumps(0, __func__);
9764
}
9865

9966
/**
@@ -267,7 +234,6 @@ static int amdgpu_dma_buf_begin_cpu_access(struct dma_buf *dma_buf,
267234

268235
const struct dma_buf_ops amdgpu_dmabuf_ops = {
269236
.attach = amdgpu_dma_buf_attach,
270-
.detach = amdgpu_dma_buf_detach,
271237
.pin = amdgpu_dma_buf_pin,
272238
.unpin = amdgpu_dma_buf_unpin,
273239
.map_dma_buf = amdgpu_dma_buf_map,

drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **f, struct amd
181181
amdgpu_ring_emit_fence(ring, ring->fence_drv.gpu_addr,
182182
seq, flags | AMDGPU_FENCE_FLAG_INT);
183183
pm_runtime_get_noresume(adev_to_drm(adev)->dev);
184-
trace_amdgpu_runpm_reference_dumps(1, __func__);
185184
ptr = &ring->fence_drv.fences[seq & ring->fence_drv.num_fences_mask];
186185
if (unlikely(rcu_dereference_protected(*ptr, 1))) {
187186
struct dma_fence *old;
@@ -309,7 +308,6 @@ bool amdgpu_fence_process(struct amdgpu_ring *ring)
309308
dma_fence_put(fence);
310309
pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
311310
pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
312-
trace_amdgpu_runpm_reference_dumps(0, __func__);
313311
} while (last_seq != seq);
314312

315313
return true;

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -554,21 +554,6 @@ TRACE_EVENT(amdgpu_reset_reg_dumps,
554554
__entry->value)
555555
);
556556

557-
TRACE_EVENT(amdgpu_runpm_reference_dumps,
558-
TP_PROTO(uint32_t index, const char *func),
559-
TP_ARGS(index, func),
560-
TP_STRUCT__entry(
561-
__field(uint32_t, index)
562-
__string(func, func)
563-
),
564-
TP_fast_assign(
565-
__entry->index = index;
566-
__assign_str(func);
567-
),
568-
TP_printk("amdgpu runpm reference dump 0x%x: 0x%s\n",
569-
__entry->index,
570-
__get_str(func))
571-
);
572557
#undef AMDGPU_JOB_GET_TIMELINE_NAME
573558
#endif
574559

0 commit comments

Comments
 (0)