Skip to content

Commit 273b3eb

Browse files
committed
Merge tag 'drm-xe-fixes-2025-01-02' of https://gitlab.freedesktop.org/drm/xe/kernel into drm-fixes
Driver Changes: - A couple of OA fixes squashed for stable backporting (Umesh) Signed-off-by: Dave Airlie <airlied@redhat.com> From: Thomas Hellstrom <thomas.hellstrom@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/Z3bur0RmH6-70YSh@fedora
2 parents 198c653 + f0ed398 commit 273b3eb

File tree

3 files changed

+51
-90
lines changed

3 files changed

+51
-90
lines changed

drivers/gpu/drm/xe/xe_oa.c

Lines changed: 45 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,6 @@ struct xe_oa_config {
7474
struct rcu_head rcu;
7575
};
7676

77-
struct flex {
78-
struct xe_reg reg;
79-
u32 offset;
80-
u32 value;
81-
};
82-
8377
struct xe_oa_open_param {
8478
struct xe_file *xef;
8579
u32 oa_unit_id;
@@ -596,19 +590,38 @@ static __poll_t xe_oa_poll(struct file *file, poll_table *wait)
596590
return ret;
597591
}
598592

593+
static void xe_oa_lock_vma(struct xe_exec_queue *q)
594+
{
595+
if (q->vm) {
596+
down_read(&q->vm->lock);
597+
xe_vm_lock(q->vm, false);
598+
}
599+
}
600+
601+
static void xe_oa_unlock_vma(struct xe_exec_queue *q)
602+
{
603+
if (q->vm) {
604+
xe_vm_unlock(q->vm);
605+
up_read(&q->vm->lock);
606+
}
607+
}
608+
599609
static struct dma_fence *xe_oa_submit_bb(struct xe_oa_stream *stream, enum xe_oa_submit_deps deps,
600610
struct xe_bb *bb)
601611
{
612+
struct xe_exec_queue *q = stream->exec_q ?: stream->k_exec_q;
602613
struct xe_sched_job *job;
603614
struct dma_fence *fence;
604615
int err = 0;
605616

606-
/* Kernel configuration is issued on stream->k_exec_q, not stream->exec_q */
607-
job = xe_bb_create_job(stream->k_exec_q, bb);
617+
xe_oa_lock_vma(q);
618+
619+
job = xe_bb_create_job(q, bb);
608620
if (IS_ERR(job)) {
609621
err = PTR_ERR(job);
610622
goto exit;
611623
}
624+
job->ggtt = true;
612625

613626
if (deps == XE_OA_SUBMIT_ADD_DEPS) {
614627
for (int i = 0; i < stream->num_syncs && !err; i++)
@@ -623,10 +636,13 @@ static struct dma_fence *xe_oa_submit_bb(struct xe_oa_stream *stream, enum xe_oa
623636
fence = dma_fence_get(&job->drm.s_fence->finished);
624637
xe_sched_job_push(job);
625638

639+
xe_oa_unlock_vma(q);
640+
626641
return fence;
627642
err_put_job:
628643
xe_sched_job_put(job);
629644
exit:
645+
xe_oa_unlock_vma(q);
630646
return ERR_PTR(err);
631647
}
632648

@@ -675,63 +691,19 @@ static void xe_oa_free_configs(struct xe_oa_stream *stream)
675691
dma_fence_put(stream->last_fence);
676692
}
677693

678-
static void xe_oa_store_flex(struct xe_oa_stream *stream, struct xe_lrc *lrc,
679-
struct xe_bb *bb, const struct flex *flex, u32 count)
680-
{
681-
u32 offset = xe_bo_ggtt_addr(lrc->bo);
682-
683-
do {
684-
bb->cs[bb->len++] = MI_STORE_DATA_IMM | MI_SDI_GGTT | MI_SDI_NUM_DW(1);
685-
bb->cs[bb->len++] = offset + flex->offset * sizeof(u32);
686-
bb->cs[bb->len++] = 0;
687-
bb->cs[bb->len++] = flex->value;
688-
689-
} while (flex++, --count);
690-
}
691-
692-
static int xe_oa_modify_ctx_image(struct xe_oa_stream *stream, struct xe_lrc *lrc,
693-
const struct flex *flex, u32 count)
694-
{
695-
struct dma_fence *fence;
696-
struct xe_bb *bb;
697-
int err;
698-
699-
bb = xe_bb_new(stream->gt, 4 * count, false);
700-
if (IS_ERR(bb)) {
701-
err = PTR_ERR(bb);
702-
goto exit;
703-
}
704-
705-
xe_oa_store_flex(stream, lrc, bb, flex, count);
706-
707-
fence = xe_oa_submit_bb(stream, XE_OA_SUBMIT_NO_DEPS, bb);
708-
if (IS_ERR(fence)) {
709-
err = PTR_ERR(fence);
710-
goto free_bb;
711-
}
712-
xe_bb_free(bb, fence);
713-
dma_fence_put(fence);
714-
715-
return 0;
716-
free_bb:
717-
xe_bb_free(bb, NULL);
718-
exit:
719-
return err;
720-
}
721-
722-
static int xe_oa_load_with_lri(struct xe_oa_stream *stream, struct xe_oa_reg *reg_lri)
694+
static int xe_oa_load_with_lri(struct xe_oa_stream *stream, struct xe_oa_reg *reg_lri, u32 count)
723695
{
724696
struct dma_fence *fence;
725697
struct xe_bb *bb;
726698
int err;
727699

728-
bb = xe_bb_new(stream->gt, 3, false);
700+
bb = xe_bb_new(stream->gt, 2 * count + 1, false);
729701
if (IS_ERR(bb)) {
730702
err = PTR_ERR(bb);
731703
goto exit;
732704
}
733705

734-
write_cs_mi_lri(bb, reg_lri, 1);
706+
write_cs_mi_lri(bb, reg_lri, count);
735707

736708
fence = xe_oa_submit_bb(stream, XE_OA_SUBMIT_NO_DEPS, bb);
737709
if (IS_ERR(fence)) {
@@ -751,71 +723,55 @@ static int xe_oa_load_with_lri(struct xe_oa_stream *stream, struct xe_oa_reg *re
751723
static int xe_oa_configure_oar_context(struct xe_oa_stream *stream, bool enable)
752724
{
753725
const struct xe_oa_format *format = stream->oa_buffer.format;
754-
struct xe_lrc *lrc = stream->exec_q->lrc[0];
755-
u32 regs_offset = xe_lrc_regs_offset(lrc) / sizeof(u32);
756726
u32 oacontrol = __format_to_oactrl(format, OAR_OACONTROL_COUNTER_SEL_MASK) |
757727
(enable ? OAR_OACONTROL_COUNTER_ENABLE : 0);
758728

759-
struct flex regs_context[] = {
729+
struct xe_oa_reg reg_lri[] = {
760730
{
761731
OACTXCONTROL(stream->hwe->mmio_base),
762-
stream->oa->ctx_oactxctrl_offset[stream->hwe->class] + 1,
763732
enable ? OA_COUNTER_RESUME : 0,
764733
},
734+
{
735+
OAR_OACONTROL,
736+
oacontrol,
737+
},
765738
{
766739
RING_CONTEXT_CONTROL(stream->hwe->mmio_base),
767-
regs_offset + CTX_CONTEXT_CONTROL,
768-
_MASKED_BIT_ENABLE(CTX_CTRL_OAC_CONTEXT_ENABLE),
740+
_MASKED_FIELD(CTX_CTRL_OAC_CONTEXT_ENABLE,
741+
enable ? CTX_CTRL_OAC_CONTEXT_ENABLE : 0)
769742
},
770743
};
771-
struct xe_oa_reg reg_lri = { OAR_OACONTROL, oacontrol };
772-
int err;
773-
774-
/* Modify stream hwe context image with regs_context */
775-
err = xe_oa_modify_ctx_image(stream, stream->exec_q->lrc[0],
776-
regs_context, ARRAY_SIZE(regs_context));
777-
if (err)
778-
return err;
779744

780-
/* Apply reg_lri using LRI */
781-
return xe_oa_load_with_lri(stream, &reg_lri);
745+
return xe_oa_load_with_lri(stream, reg_lri, ARRAY_SIZE(reg_lri));
782746
}
783747

784748
static int xe_oa_configure_oac_context(struct xe_oa_stream *stream, bool enable)
785749
{
786750
const struct xe_oa_format *format = stream->oa_buffer.format;
787-
struct xe_lrc *lrc = stream->exec_q->lrc[0];
788-
u32 regs_offset = xe_lrc_regs_offset(lrc) / sizeof(u32);
789751
u32 oacontrol = __format_to_oactrl(format, OAR_OACONTROL_COUNTER_SEL_MASK) |
790752
(enable ? OAR_OACONTROL_COUNTER_ENABLE : 0);
791-
struct flex regs_context[] = {
753+
struct xe_oa_reg reg_lri[] = {
792754
{
793755
OACTXCONTROL(stream->hwe->mmio_base),
794-
stream->oa->ctx_oactxctrl_offset[stream->hwe->class] + 1,
795756
enable ? OA_COUNTER_RESUME : 0,
796757
},
758+
{
759+
OAC_OACONTROL,
760+
oacontrol
761+
},
797762
{
798763
RING_CONTEXT_CONTROL(stream->hwe->mmio_base),
799-
regs_offset + CTX_CONTEXT_CONTROL,
800-
_MASKED_BIT_ENABLE(CTX_CTRL_OAC_CONTEXT_ENABLE) |
764+
_MASKED_FIELD(CTX_CTRL_OAC_CONTEXT_ENABLE,
765+
enable ? CTX_CTRL_OAC_CONTEXT_ENABLE : 0) |
801766
_MASKED_FIELD(CTX_CTRL_RUN_ALONE, enable ? CTX_CTRL_RUN_ALONE : 0),
802767
},
803768
};
804-
struct xe_oa_reg reg_lri = { OAC_OACONTROL, oacontrol };
805-
int err;
806769

807770
/* Set ccs select to enable programming of OAC_OACONTROL */
808771
xe_mmio_write32(&stream->gt->mmio, __oa_regs(stream)->oa_ctrl,
809772
__oa_ccs_select(stream));
810773

811-
/* Modify stream hwe context image with regs_context */
812-
err = xe_oa_modify_ctx_image(stream, stream->exec_q->lrc[0],
813-
regs_context, ARRAY_SIZE(regs_context));
814-
if (err)
815-
return err;
816-
817-
/* Apply reg_lri using LRI */
818-
return xe_oa_load_with_lri(stream, &reg_lri);
774+
return xe_oa_load_with_lri(stream, reg_lri, ARRAY_SIZE(reg_lri));
819775
}
820776

821777
static int xe_oa_configure_oa_context(struct xe_oa_stream *stream, bool enable)
@@ -2066,8 +2022,8 @@ int xe_oa_stream_open_ioctl(struct drm_device *dev, u64 data, struct drm_file *f
20662022
if (XE_IOCTL_DBG(oa->xe, !param.exec_q))
20672023
return -ENOENT;
20682024

2069-
if (param.exec_q->width > 1)
2070-
drm_dbg(&oa->xe->drm, "exec_q->width > 1, programming only exec_q->lrc[0]\n");
2025+
if (XE_IOCTL_DBG(oa->xe, param.exec_q->width > 1))
2026+
return -EOPNOTSUPP;
20712027
}
20722028

20732029
/*

drivers/gpu/drm/xe/xe_ring_ops.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,10 @@ static int emit_pipe_imm_ggtt(u32 addr, u32 value, bool stall_only, u32 *dw,
221221

222222
static u32 get_ppgtt_flag(struct xe_sched_job *job)
223223
{
224-
return job->q->vm ? BIT(8) : 0;
224+
if (job->q->vm && !job->ggtt)
225+
return BIT(8);
226+
227+
return 0;
225228
}
226229

227230
static int emit_copy_timestamp(struct xe_lrc *lrc, u32 *dw, int i)

drivers/gpu/drm/xe/xe_sched_job_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ struct xe_sched_job {
5656
u32 migrate_flush_flags;
5757
/** @ring_ops_flush_tlb: The ring ops need to flush TLB before payload. */
5858
bool ring_ops_flush_tlb;
59+
/** @ggtt: mapped in ggtt. */
60+
bool ggtt;
5961
/** @ptrs: per instance pointers. */
6062
struct xe_job_ptrs ptrs[];
6163
};

0 commit comments

Comments
 (0)