@@ -802,9 +802,9 @@ static void xive_init_default_vp(struct xive_vp *vp,
802
802
vp -> w0 = VP_W0_VALID ;
803
803
}
804
804
805
- static void xive_init_default_eq (uint32_t vp_blk , uint32_t vp_idx ,
806
- struct xive_eq * eq , void * backing_page ,
807
- uint8_t prio )
805
+ static void xive_init_emu_eq (uint32_t vp_blk , uint32_t vp_idx ,
806
+ struct xive_eq * eq , void * backing_page ,
807
+ uint8_t prio )
808
808
{
809
809
memset (eq , 0 , sizeof (struct xive_eq ));
810
810
@@ -2810,12 +2810,9 @@ void xive_cpu_callin(struct cpu_thread *cpu)
2810
2810
out_8 (xs -> tm_ring1 + TM_QW3_HV_PHYS + TM_WORD2 , 0x80 );
2811
2811
2812
2812
xive_cpu_dbg (cpu , "Initialized interrupt management area\n" );
2813
-
2814
- /* Now unmask the IPI */
2815
- xive_ipi_init (x , cpu );
2816
2813
}
2817
2814
2818
- static void xive_init_cpu_defaults (struct xive_cpu_state * xs )
2815
+ static void xive_setup_hw_for_emu (struct xive_cpu_state * xs )
2819
2816
{
2820
2817
struct xive_eq eq ;
2821
2818
struct xive_vp vp ;
@@ -2835,8 +2832,8 @@ static void xive_init_cpu_defaults(struct xive_cpu_state *xs)
2835
2832
assert (x_eq );
2836
2833
2837
2834
/* Initialize the structure */
2838
- xive_init_default_eq (xs -> vp_blk , xs -> vp_idx , & eq ,
2839
- xs -> eq_page , XIVE_EMULATION_PRIO );
2835
+ xive_init_emu_eq (xs -> vp_blk , xs -> vp_idx , & eq ,
2836
+ xs -> eq_page , XIVE_EMULATION_PRIO );
2840
2837
2841
2838
/* Use the cache watch to write it out */
2842
2839
xive_eqc_cache_update (x_eq , xs -> eq_blk ,
@@ -2886,25 +2883,60 @@ static void xive_provision_cpu(struct xive_cpu_state *xs, struct cpu_thread *c)
2886
2883
xs -> eq_page = p ;
2887
2884
}
2888
2885
2889
- static void xive_init_xics_emulation (struct xive_cpu_state * xs )
2886
+ static void xive_init_cpu_emulation (struct xive_cpu_state * xs ,
2887
+ struct cpu_thread * cpu )
2890
2888
{
2891
2889
struct xive * x ;
2892
2890
2891
+ /* Setup HW EQ and VP */
2892
+ xive_setup_hw_for_emu (xs );
2893
+
2894
+ /* Setup and unmask the IPI */
2895
+ xive_ipi_init (xs -> xive , cpu );
2896
+
2897
+ /* Initialize remaining state */
2893
2898
xs -> cppr = 0 ;
2894
2899
xs -> mfrr = 0xff ;
2895
-
2896
- xs -> eqbuf = xive_get_eq_buf ( xs -> vp_blk , xs -> eq_idx + XIVE_EMULATION_PRIO );
2900
+ xs -> eqbuf = xive_get_eq_buf ( xs -> vp_blk ,
2901
+ xs -> eq_idx + XIVE_EMULATION_PRIO );
2897
2902
assert (xs -> eqbuf );
2898
2903
2899
2904
xs -> eqptr = 0 ;
2900
2905
xs -> eqmsk = (0x10000 /4 ) - 1 ;
2901
2906
xs -> eqgen = 0 ;
2902
-
2903
2907
x = xive_from_vc_blk (xs -> eq_blk );
2904
2908
assert (x );
2905
2909
xs -> eqmmio = x -> eq_mmio + (xs -> eq_idx + XIVE_EMULATION_PRIO ) * 0x20000 ;
2906
2910
}
2907
2911
2912
+ static void xive_init_cpu_exploitation (struct xive_cpu_state * xs )
2913
+ {
2914
+ struct xive_vp vp ;
2915
+ struct xive * x_vp ;
2916
+
2917
+ /* Grab the XIVE where the VP resides. It could be different from
2918
+ * the local chip XIVE if not using block group mode
2919
+ */
2920
+ x_vp = xive_from_pc_blk (xs -> vp_blk );
2921
+ assert (x_vp );
2922
+
2923
+ /* Initialize/enable the VP */
2924
+ xive_init_default_vp (& vp , xs -> eq_blk , xs -> eq_idx );
2925
+
2926
+ /* Use the cache watch to write it out */
2927
+ xive_vpc_cache_update (x_vp , xs -> vp_blk , xs -> vp_idx ,
2928
+ 0 , 8 , & vp , false, true);
2929
+
2930
+ /* Clenaup remaining state */
2931
+ xs -> cppr = 0 ;
2932
+ xs -> mfrr = 0xff ;
2933
+ xs -> eqbuf = NULL ;
2934
+ xs -> eqptr = 0 ;
2935
+ xs -> eqmsk = 0 ;
2936
+ xs -> eqgen = 0 ;
2937
+ xs -> eqmmio = NULL ;
2938
+ }
2939
+
2908
2940
static void xive_configure_ex_special_bar (struct xive * x , struct cpu_thread * c )
2909
2941
{
2910
2942
uint64_t xa , val ;
@@ -2915,7 +2947,7 @@ static void xive_configure_ex_special_bar(struct xive *x, struct cpu_thread *c)
2915
2947
val = (uint64_t )x -> tm_base | P9X_EX_NCU_SPEC_BAR_ENABLE ;
2916
2948
if (x -> tm_shift == 16 )
2917
2949
val |= P9X_EX_NCU_SPEC_BAR_256K ;
2918
- printf ( "NCU_SPEC_BAR_XA[%08llx]=%016llx\n" , xa , val );
2950
+ xive_cpu_dbg ( c , "NCU_SPEC_BAR_XA[%08llx]=%016llx\n" , xa , val );
2919
2951
rc = xscom_write (c -> chip_id , xa , val );
2920
2952
if (rc ) {
2921
2953
xive_cpu_err (c , "Failed to setup NCU_SPEC_BAR\n" );
@@ -2962,11 +2994,8 @@ static void xive_init_cpu(struct cpu_thread *c)
2962
2994
/* Provision a VP and some EQDs for a physical CPU */
2963
2995
xive_provision_cpu (xs , c );
2964
2996
2965
- /* Configure the default EQ/VP */
2966
- xive_init_cpu_defaults (xs );
2967
-
2968
2997
/* Initialize the XICS emulation related fields */
2969
- xive_init_xics_emulation (xs );
2998
+ xive_init_cpu_emulation (xs , c );
2970
2999
}
2971
3000
2972
3001
static void xive_init_cpu_properties (struct cpu_thread * cpu )
@@ -3529,7 +3558,8 @@ static int64_t opal_xive_set_queue_info(uint64_t vp, uint32_t prio,
3529
3558
if (!xive_decode_vp (vp , & vp_blk , & vp_idx , NULL , & group ))
3530
3559
return OPAL_PARAMETER ;
3531
3560
3532
- /* Make a local copy which we will later try to commit using
3561
+ /*
3562
+ * Make a local copy which we will later try to commit using
3533
3563
* the cache watch facility
3534
3564
*/
3535
3565
eq = * old_eq ;
@@ -3747,13 +3777,14 @@ static void xive_reset_one(struct xive *x)
3747
3777
3748
3778
/* Reset all allocated EQs and free the user ones */
3749
3779
bitmap_for_each_one (* x -> eq_map , MAX_EQ_COUNT >> 3 , i ) {
3750
- struct xive_eq eq0 = { 0 } ;
3780
+ struct xive_eq eq0 ;
3751
3781
struct xive_eq * eq ;
3752
3782
int j ;
3753
3783
3754
3784
if (i == 0 )
3755
3785
continue ;
3756
3786
eq_firmware = false;
3787
+ memset (& eq0 , 0 , sizeof (eq0 ));
3757
3788
for (j = 0 ; j < 8 ; j ++ ) {
3758
3789
uint32_t idx = (i << 3 ) | j ;
3759
3790
@@ -3821,23 +3852,17 @@ static void xive_reset_one(struct xive *x)
3821
3852
/* The rest must not be called with the lock held */
3822
3853
unlock (& x -> lock );
3823
3854
3824
- /* Re-configure the CPUs */
3855
+ /* Re-configure VPs and emulation */
3825
3856
for_each_present_cpu (c ) {
3826
3857
struct xive_cpu_state * xs = c -> xstate ;
3827
3858
3828
3859
if (c -> chip_id != x -> chip_id || !xs )
3829
3860
continue ;
3830
3861
3831
- /* Setup default VP and EQ */
3832
- xive_init_cpu_defaults (xs );
3833
-
3834
- /* Re-Initialize the XICS emulation related fields
3835
- * and re-enable IPI
3836
- */
3837
- if (xive_mode == XIVE_MODE_EMU ) {
3838
- xive_init_xics_emulation (xs );
3839
- xive_ipi_init (x , c );
3840
- }
3862
+ if (xive_mode == XIVE_MODE_EMU )
3863
+ xive_init_cpu_emulation (xs , c );
3864
+ else
3865
+ xive_init_cpu_exploitation (xs );
3841
3866
}
3842
3867
}
3843
3868
0 commit comments