Skip to content

Commit 783d6cd

Browse files
committed
drm/xe: Kill xe_device_mem_access_{get*,put}
Let's simply convert all the current callers towards direct xe_pm_runtime access and remove this extra layer of indirection. No functional change is expected with this patch since xe_mem_access_get was already using the xe_pm_runtime_get_noresume at this point. v2: Convert all the current callers instead of a big refactor at once. v3: - Rebased - Squashed the GSC/HDCP - Added a new case: sriov_pf_policy - Improved commit message to highlight that there's no functional change in this patch. Reviewed-by: Matthew Auld <[email protected]> #v2 Cc: Suraj Kandpal <[email protected]> Cc: Michal Wajdeczko <[email protected]> Signed-off-by: Rodrigo Vivi <[email protected]> Reviewed-by: Suraj Kandpal <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 62422b7 commit 783d6cd

File tree

11 files changed

+25
-63
lines changed

11 files changed

+25
-63
lines changed

drivers/gpu/drm/xe/display/xe_fb_pin.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "intel_fb_pin.h"
1111
#include "xe_ggtt.h"
1212
#include "xe_gt.h"
13+
#include "xe_pm.h"
1314

1415
#include <drm/ttm/ttm_bo.h>
1516

@@ -193,7 +194,7 @@ static int __xe_pin_fb_vma_ggtt(struct intel_framebuffer *fb,
193194
/* TODO: Consider sharing framebuffer mapping?
194195
* embed i915_vma inside intel_framebuffer
195196
*/
196-
xe_device_mem_access_get(tile_to_xe(ggtt->tile));
197+
xe_pm_runtime_get_noresume(tile_to_xe(ggtt->tile));
197198
ret = mutex_lock_interruptible(&ggtt->lock);
198199
if (ret)
199200
goto out;
@@ -244,7 +245,7 @@ static int __xe_pin_fb_vma_ggtt(struct intel_framebuffer *fb,
244245
out_unlock:
245246
mutex_unlock(&ggtt->lock);
246247
out:
247-
xe_device_mem_access_put(tile_to_xe(ggtt->tile));
248+
xe_pm_runtime_put(tile_to_xe(ggtt->tile));
248249
return ret;
249250
}
250251

drivers/gpu/drm/xe/display/xe_hdcp_gsc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ ssize_t intel_hdcp_gsc_msg_send(struct xe_device *xe, u8 *msg_in,
215215
addr_out_off = PAGE_SIZE;
216216

217217
host_session_id = xe_gsc_create_host_session_id();
218-
xe_device_mem_access_get(xe);
218+
xe_pm_runtime_get_noresume(xe);
219219
addr_in_wr_off = xe_gsc_emit_header(xe, &hdcp_message->hdcp_bo->vmap,
220220
addr_in_wr_off, HECI_MEADDRESS_HDCP,
221221
host_session_id, msg_in_len);
@@ -247,6 +247,6 @@ ssize_t intel_hdcp_gsc_msg_send(struct xe_device *xe, u8 *msg_in,
247247
msg_out_len);
248248

249249
out:
250-
xe_device_mem_access_put(xe);
250+
xe_pm_runtime_put(xe);
251251
return ret;
252252
}

drivers/gpu/drm/xe/xe_bo.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict,
716716

717717
xe_assert(xe, migrate);
718718
trace_xe_bo_move(bo, new_mem->mem_type, old_mem_type, move_lacks_source);
719-
xe_device_mem_access_get(xe);
719+
xe_pm_runtime_get_noresume(xe);
720720

721721
if (xe_bo_is_pinned(bo) && !xe_bo_is_user(bo)) {
722722
/*
@@ -740,7 +740,7 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict,
740740

741741
if (XE_WARN_ON(new_mem->start == XE_BO_INVALID_OFFSET)) {
742742
ret = -EINVAL;
743-
xe_device_mem_access_put(xe);
743+
xe_pm_runtime_put(xe);
744744
goto out;
745745
}
746746

@@ -758,7 +758,7 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict,
758758
new_mem, handle_system_ccs);
759759
if (IS_ERR(fence)) {
760760
ret = PTR_ERR(fence);
761-
xe_device_mem_access_put(xe);
761+
xe_pm_runtime_put(xe);
762762
goto out;
763763
}
764764
if (!move_lacks_source) {
@@ -783,7 +783,7 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict,
783783
dma_fence_put(fence);
784784
}
785785

786-
xe_device_mem_access_put(xe);
786+
xe_pm_runtime_put(xe);
787787

788788
out:
789789
return ret;

drivers/gpu/drm/xe/xe_device.c

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -729,42 +729,6 @@ void xe_device_assert_mem_access(struct xe_device *xe)
729729
xe_assert(xe, !xe_pm_runtime_suspended(xe));
730730
}
731731

732-
void xe_device_mem_access_get(struct xe_device *xe)
733-
{
734-
int ref;
735-
736-
/*
737-
* This looks racy, but should be fine since the pm_callback_task only
738-
* transitions from NULL -> current (and back to NULL again), during the
739-
* runtime_resume() or runtime_suspend() callbacks, for which there can
740-
* only be a single one running for our device. We only need to prevent
741-
* recursively calling the runtime_get or runtime_put from those
742-
* callbacks, as well as preventing triggering any access_ongoing
743-
* asserts.
744-
*/
745-
if (xe_pm_read_callback_task(xe) == current)
746-
return;
747-
748-
xe_pm_runtime_get_noresume(xe);
749-
ref = atomic_inc_return(&xe->mem_access.ref);
750-
751-
xe_assert(xe, ref != S32_MAX);
752-
753-
}
754-
755-
void xe_device_mem_access_put(struct xe_device *xe)
756-
{
757-
int ref;
758-
759-
if (xe_pm_read_callback_task(xe) == current)
760-
return;
761-
762-
ref = atomic_dec_return(&xe->mem_access.ref);
763-
xe_pm_runtime_put(xe);
764-
765-
xe_assert(xe, ref >= 0);
766-
}
767-
768732
void xe_device_snapshot_print(struct xe_device *xe, struct drm_printer *p)
769733
{
770734
struct xe_gt *gt;

drivers/gpu/drm/xe/xe_device.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ static inline struct xe_force_wake *gt_to_fw(struct xe_gt *gt)
133133
return &gt->mmio.fw;
134134
}
135135

136-
void xe_device_mem_access_get(struct xe_device *xe);
137-
void xe_device_mem_access_put(struct xe_device *xe);
138-
139136
void xe_device_assert_mem_access(struct xe_device *xe);
140137

141138
static inline bool xe_device_in_fault_mode(struct xe_device *xe)

drivers/gpu/drm/xe/xe_device_types.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,6 @@ struct xe_device {
384384
* triggering additional actions when they occur.
385385
*/
386386
struct {
387-
/** @mem_access.ref: ref count of memory accesses */
388-
atomic_t ref;
389-
390387
/**
391388
* @mem_access.vram_userfault: Encapsulate vram_userfault
392389
* related stuff

drivers/gpu/drm/xe/xe_exec_queue.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ int xe_exec_queue_create_ioctl(struct drm_device *dev, void *data,
589589
return -EINVAL;
590590

591591
/* The migration vm doesn't hold rpm ref */
592-
xe_device_mem_access_get(xe);
592+
xe_pm_runtime_get_noresume(xe);
593593

594594
flags = EXEC_QUEUE_FLAG_VM | (id ? EXEC_QUEUE_FLAG_BIND_ENGINE_CHILD : 0);
595595

@@ -598,7 +598,7 @@ int xe_exec_queue_create_ioctl(struct drm_device *dev, void *data,
598598
args->width, hwe, flags,
599599
args->extensions);
600600

601-
xe_device_mem_access_put(xe); /* now held by engine */
601+
xe_pm_runtime_put(xe); /* now held by engine */
602602

603603
xe_vm_put(migrate_vm);
604604
if (IS_ERR(new)) {

drivers/gpu/drm/xe/xe_ggtt.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "xe_gt_printk.h"
2222
#include "xe_gt_tlb_invalidation.h"
2323
#include "xe_map.h"
24+
#include "xe_pm.h"
2425
#include "xe_sriov.h"
2526
#include "xe_wopcm.h"
2627

@@ -403,7 +404,7 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
403404
if (err)
404405
return err;
405406

406-
xe_device_mem_access_get(tile_to_xe(ggtt->tile));
407+
xe_pm_runtime_get_noresume(tile_to_xe(ggtt->tile));
407408
mutex_lock(&ggtt->lock);
408409
err = drm_mm_insert_node_in_range(&ggtt->mm, &bo->ggtt_node, bo->size,
409410
alignment, 0, start, end, 0);
@@ -413,7 +414,7 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
413414

414415
if (!err && bo->flags & XE_BO_FLAG_GGTT_INVALIDATE)
415416
xe_ggtt_invalidate(ggtt);
416-
xe_device_mem_access_put(tile_to_xe(ggtt->tile));
417+
xe_pm_runtime_put(tile_to_xe(ggtt->tile));
417418

418419
return err;
419420
}
@@ -432,7 +433,7 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
432433
void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
433434
bool invalidate)
434435
{
435-
xe_device_mem_access_get(tile_to_xe(ggtt->tile));
436+
xe_pm_runtime_get_noresume(tile_to_xe(ggtt->tile));
436437

437438
mutex_lock(&ggtt->lock);
438439
xe_ggtt_clear(ggtt, node->start, node->size);
@@ -443,7 +444,7 @@ void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
443444
if (invalidate)
444445
xe_ggtt_invalidate(ggtt);
445446

446-
xe_device_mem_access_put(tile_to_xe(ggtt->tile));
447+
xe_pm_runtime_put(tile_to_xe(ggtt->tile));
447448
}
448449

449450
void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)

drivers/gpu/drm/xe/xe_gt_sriov_pf_policy.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "xe_gt_sriov_printk.h"
1313
#include "xe_guc_ct.h"
1414
#include "xe_guc_klv_helpers.h"
15+
#include "xe_pm.h"
1516

1617
/*
1718
* Return: number of KLVs that were successfully parsed and saved,
@@ -368,7 +369,7 @@ int xe_gt_sriov_pf_policy_reprovision(struct xe_gt *gt, bool reset)
368369
{
369370
int err = 0;
370371

371-
xe_device_mem_access_get(gt_to_xe(gt));
372+
xe_pm_runtime_get_noresume(gt_to_xe(gt));
372373

373374
mutex_lock(xe_gt_sriov_pf_master_mutex(gt));
374375
if (reset)
@@ -378,7 +379,7 @@ int xe_gt_sriov_pf_policy_reprovision(struct xe_gt *gt, bool reset)
378379
err |= pf_reprovision_sample_period(gt);
379380
mutex_unlock(xe_gt_sriov_pf_master_mutex(gt));
380381

381-
xe_device_mem_access_put(gt_to_xe(gt));
382+
xe_pm_runtime_put(gt_to_xe(gt));
382383

383384
return err ? -ENXIO : 0;
384385
}

drivers/gpu/drm/xe/xe_sched_job.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "xe_hw_fence.h"
1717
#include "xe_lrc.h"
1818
#include "xe_macros.h"
19+
#include "xe_pm.h"
1920
#include "xe_sync_types.h"
2021
#include "xe_trace.h"
2122
#include "xe_vm.h"
@@ -159,7 +160,7 @@ struct xe_sched_job *xe_sched_job_create(struct xe_exec_queue *q,
159160

160161
/* All other jobs require a VM to be open which has a ref */
161162
if (unlikely(q->flags & EXEC_QUEUE_FLAG_KERNEL))
162-
xe_device_mem_access_get(job_to_xe(job));
163+
xe_pm_runtime_get_noresume(job_to_xe(job));
163164
xe_device_assert_mem_access(job_to_xe(job));
164165

165166
trace_xe_sched_job_create(job);
@@ -192,7 +193,7 @@ void xe_sched_job_destroy(struct kref *ref)
192193
container_of(ref, struct xe_sched_job, refcount);
193194

194195
if (unlikely(job->q->flags & EXEC_QUEUE_FLAG_KERNEL))
195-
xe_device_mem_access_put(job_to_xe(job));
196+
xe_pm_runtime_put(job_to_xe(job));
196197
xe_exec_queue_put(job->q);
197198
dma_fence_put(job->fence);
198199
drm_sched_job_cleanup(&job->drm);

0 commit comments

Comments
 (0)