@@ -74,12 +74,6 @@ struct xe_oa_config {
74
74
struct rcu_head rcu ;
75
75
};
76
76
77
- struct flex {
78
- struct xe_reg reg ;
79
- u32 offset ;
80
- u32 value ;
81
- };
82
-
83
77
struct xe_oa_open_param {
84
78
struct xe_file * xef ;
85
79
u32 oa_unit_id ;
@@ -596,19 +590,38 @@ static __poll_t xe_oa_poll(struct file *file, poll_table *wait)
596
590
return ret ;
597
591
}
598
592
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
+
599
609
static struct dma_fence * xe_oa_submit_bb (struct xe_oa_stream * stream , enum xe_oa_submit_deps deps ,
600
610
struct xe_bb * bb )
601
611
{
612
+ struct xe_exec_queue * q = stream -> exec_q ?: stream -> k_exec_q ;
602
613
struct xe_sched_job * job ;
603
614
struct dma_fence * fence ;
604
615
int err = 0 ;
605
616
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 );
608
620
if (IS_ERR (job )) {
609
621
err = PTR_ERR (job );
610
622
goto exit ;
611
623
}
624
+ job -> ggtt = true;
612
625
613
626
if (deps == XE_OA_SUBMIT_ADD_DEPS ) {
614
627
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
623
636
fence = dma_fence_get (& job -> drm .s_fence -> finished );
624
637
xe_sched_job_push (job );
625
638
639
+ xe_oa_unlock_vma (q );
640
+
626
641
return fence ;
627
642
err_put_job :
628
643
xe_sched_job_put (job );
629
644
exit :
645
+ xe_oa_unlock_vma (q );
630
646
return ERR_PTR (err );
631
647
}
632
648
@@ -675,63 +691,19 @@ static void xe_oa_free_configs(struct xe_oa_stream *stream)
675
691
dma_fence_put (stream -> last_fence );
676
692
}
677
693
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 )
723
695
{
724
696
struct dma_fence * fence ;
725
697
struct xe_bb * bb ;
726
698
int err ;
727
699
728
- bb = xe_bb_new (stream -> gt , 3 , false);
700
+ bb = xe_bb_new (stream -> gt , 2 * count + 1 , false);
729
701
if (IS_ERR (bb )) {
730
702
err = PTR_ERR (bb );
731
703
goto exit ;
732
704
}
733
705
734
- write_cs_mi_lri (bb , reg_lri , 1 );
706
+ write_cs_mi_lri (bb , reg_lri , count );
735
707
736
708
fence = xe_oa_submit_bb (stream , XE_OA_SUBMIT_NO_DEPS , bb );
737
709
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
751
723
static int xe_oa_configure_oar_context (struct xe_oa_stream * stream , bool enable )
752
724
{
753
725
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 );
756
726
u32 oacontrol = __format_to_oactrl (format , OAR_OACONTROL_COUNTER_SEL_MASK ) |
757
727
(enable ? OAR_OACONTROL_COUNTER_ENABLE : 0 );
758
728
759
- struct flex regs_context [] = {
729
+ struct xe_oa_reg reg_lri [] = {
760
730
{
761
731
OACTXCONTROL (stream -> hwe -> mmio_base ),
762
- stream -> oa -> ctx_oactxctrl_offset [stream -> hwe -> class ] + 1 ,
763
732
enable ? OA_COUNTER_RESUME : 0 ,
764
733
},
734
+ {
735
+ OAR_OACONTROL ,
736
+ oacontrol ,
737
+ },
765
738
{
766
739
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 )
769
742
},
770
743
};
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 ;
779
744
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 ));
782
746
}
783
747
784
748
static int xe_oa_configure_oac_context (struct xe_oa_stream * stream , bool enable )
785
749
{
786
750
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 );
789
751
u32 oacontrol = __format_to_oactrl (format , OAR_OACONTROL_COUNTER_SEL_MASK ) |
790
752
(enable ? OAR_OACONTROL_COUNTER_ENABLE : 0 );
791
- struct flex regs_context [] = {
753
+ struct xe_oa_reg reg_lri [] = {
792
754
{
793
755
OACTXCONTROL (stream -> hwe -> mmio_base ),
794
- stream -> oa -> ctx_oactxctrl_offset [stream -> hwe -> class ] + 1 ,
795
756
enable ? OA_COUNTER_RESUME : 0 ,
796
757
},
758
+ {
759
+ OAC_OACONTROL ,
760
+ oacontrol
761
+ },
797
762
{
798
763
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 ) |
801
766
_MASKED_FIELD (CTX_CTRL_RUN_ALONE , enable ? CTX_CTRL_RUN_ALONE : 0 ),
802
767
},
803
768
};
804
- struct xe_oa_reg reg_lri = { OAC_OACONTROL , oacontrol };
805
- int err ;
806
769
807
770
/* Set ccs select to enable programming of OAC_OACONTROL */
808
771
xe_mmio_write32 (& stream -> gt -> mmio , __oa_regs (stream )-> oa_ctrl ,
809
772
__oa_ccs_select (stream ));
810
773
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 ));
819
775
}
820
776
821
777
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
2066
2022
if (XE_IOCTL_DBG (oa -> xe , !param .exec_q ))
2067
2023
return - ENOENT ;
2068
2024
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 ;
2071
2027
}
2072
2028
2073
2029
/*
0 commit comments