@@ -62,7 +62,7 @@ static struct ice_pf *ice_get_ctrl_pf(struct ice_pf *pf)
62
62
return !pf -> adapter ? NULL : pf -> adapter -> ctrl_pf ;
63
63
}
64
64
65
- static __maybe_unused struct ice_ptp * ice_get_ctrl_ptp (struct ice_pf * pf )
65
+ static struct ice_ptp * ice_get_ctrl_ptp (struct ice_pf * pf )
66
66
{
67
67
struct ice_pf * ctrl_pf = ice_get_ctrl_pf (pf );
68
68
@@ -734,16 +734,16 @@ static enum ice_tx_tstamp_work ice_ptp_tx_tstamp_owner(struct ice_pf *pf)
734
734
struct ice_ptp_port * port ;
735
735
unsigned int i ;
736
736
737
- mutex_lock (& pf -> ptp . ports_owner .lock );
738
- list_for_each_entry (port , & pf -> ptp . ports_owner . ports , list_member ) {
737
+ mutex_lock (& pf -> adapter -> ports .lock );
738
+ list_for_each_entry (port , & pf -> adapter -> ports . ports , list_node ) {
739
739
struct ice_ptp_tx * tx = & port -> tx ;
740
740
741
741
if (!tx || !tx -> init )
742
742
continue ;
743
743
744
744
ice_ptp_process_tx_tstamp (tx );
745
745
}
746
- mutex_unlock (& pf -> ptp . ports_owner .lock );
746
+ mutex_unlock (& pf -> adapter -> ports .lock );
747
747
748
748
for (i = 0 ; i < ICE_GET_QUAD_NUM (pf -> hw .ptp .num_lports ); i ++ ) {
749
749
u64 tstamp_ready ;
@@ -908,7 +908,7 @@ ice_ptp_flush_all_tx_tracker(struct ice_pf *pf)
908
908
{
909
909
struct ice_ptp_port * port ;
910
910
911
- list_for_each_entry (port , & pf -> ptp . ports_owner . ports , list_member )
911
+ list_for_each_entry (port , & pf -> adapter -> ports . ports , list_node )
912
912
ice_ptp_flush_tx_tracker (ptp_port_to_pf (port ), & port -> tx );
913
913
}
914
914
@@ -1508,10 +1508,10 @@ static void ice_ptp_restart_all_phy(struct ice_pf *pf)
1508
1508
{
1509
1509
struct list_head * entry ;
1510
1510
1511
- list_for_each (entry , & pf -> ptp . ports_owner .ports ) {
1511
+ list_for_each (entry , & pf -> adapter -> ports .ports ) {
1512
1512
struct ice_ptp_port * port = list_entry (entry ,
1513
1513
struct ice_ptp_port ,
1514
- list_member );
1514
+ list_node );
1515
1515
1516
1516
if (port -> link_up )
1517
1517
ice_ptp_port_phy_restart (port );
@@ -2939,6 +2939,50 @@ void ice_ptp_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
2939
2939
dev_err (ice_pf_to_dev (pf ), "PTP reset failed %d\n" , err );
2940
2940
}
2941
2941
2942
+ static bool ice_is_primary (struct ice_hw * hw )
2943
+ {
2944
+ return ice_is_e825c (hw ) && ice_is_dual (hw ) ?
2945
+ !!(hw -> dev_caps .nac_topo .mode & ICE_NAC_TOPO_PRIMARY_M ) : true;
2946
+ }
2947
+
2948
+ static int ice_ptp_setup_adapter (struct ice_pf * pf )
2949
+ {
2950
+ if (!ice_pf_src_tmr_owned (pf ) || !ice_is_primary (& pf -> hw ))
2951
+ return - EPERM ;
2952
+
2953
+ pf -> adapter -> ctrl_pf = pf ;
2954
+
2955
+ return 0 ;
2956
+ }
2957
+
2958
+ static int ice_ptp_setup_pf (struct ice_pf * pf )
2959
+ {
2960
+ struct ice_ptp * ctrl_ptp = ice_get_ctrl_ptp (pf );
2961
+ struct ice_ptp * ptp = & pf -> ptp ;
2962
+
2963
+ if (WARN_ON (!ctrl_ptp ) || ice_get_phy_model (& pf -> hw ) == ICE_PHY_UNSUP )
2964
+ return - ENODEV ;
2965
+
2966
+ INIT_LIST_HEAD (& ptp -> port .list_node );
2967
+ mutex_lock (& pf -> adapter -> ports .lock );
2968
+
2969
+ list_add (& ptp -> port .list_node ,
2970
+ & pf -> adapter -> ports .ports );
2971
+ mutex_unlock (& pf -> adapter -> ports .lock );
2972
+
2973
+ return 0 ;
2974
+ }
2975
+
2976
+ static void ice_ptp_cleanup_pf (struct ice_pf * pf )
2977
+ {
2978
+ struct ice_ptp * ptp = & pf -> ptp ;
2979
+
2980
+ if (ice_get_phy_model (& pf -> hw ) != ICE_PHY_UNSUP ) {
2981
+ mutex_lock (& pf -> adapter -> ports .lock );
2982
+ list_del (& ptp -> port .list_node );
2983
+ mutex_unlock (& pf -> adapter -> ports .lock );
2984
+ }
2985
+ }
2942
2986
/**
2943
2987
* ice_ptp_aux_dev_to_aux_pf - Get auxiliary PF handle for the auxiliary device
2944
2988
* @aux_dev: auxiliary device to get the auxiliary PF for
@@ -2990,9 +3034,9 @@ static int ice_ptp_auxbus_probe(struct auxiliary_device *aux_dev,
2990
3034
if (WARN_ON (!owner_pf ))
2991
3035
return - ENODEV ;
2992
3036
2993
- INIT_LIST_HEAD (& aux_pf -> ptp .port .list_member );
3037
+ INIT_LIST_HEAD (& aux_pf -> ptp .port .list_node );
2994
3038
mutex_lock (& owner_pf -> ptp .ports_owner .lock );
2995
- list_add (& aux_pf -> ptp .port .list_member ,
3039
+ list_add (& aux_pf -> ptp .port .list_node ,
2996
3040
& owner_pf -> ptp .ports_owner .ports );
2997
3041
mutex_unlock (& owner_pf -> ptp .ports_owner .lock );
2998
3042
@@ -3009,7 +3053,7 @@ static void ice_ptp_auxbus_remove(struct auxiliary_device *aux_dev)
3009
3053
struct ice_pf * aux_pf = ice_ptp_aux_dev_to_aux_pf (aux_dev );
3010
3054
3011
3055
mutex_lock (& owner_pf -> ptp .ports_owner .lock );
3012
- list_del (& aux_pf -> ptp .port .list_member );
3056
+ list_del (& aux_pf -> ptp .port .list_node );
3013
3057
mutex_unlock (& owner_pf -> ptp .ports_owner .lock );
3014
3058
}
3015
3059
@@ -3069,7 +3113,7 @@ ice_ptp_auxbus_create_id_table(struct ice_pf *pf, const char *name)
3069
3113
* ice_ptp_register_auxbus_driver - Register PTP auxiliary bus driver
3070
3114
* @pf: Board private structure
3071
3115
*/
3072
- static int ice_ptp_register_auxbus_driver (struct ice_pf * pf )
3116
+ static int __always_unused ice_ptp_register_auxbus_driver (struct ice_pf * pf )
3073
3117
{
3074
3118
struct auxiliary_driver * aux_driver ;
3075
3119
struct ice_ptp * ptp ;
@@ -3112,7 +3156,7 @@ static int ice_ptp_register_auxbus_driver(struct ice_pf *pf)
3112
3156
* ice_ptp_unregister_auxbus_driver - Unregister PTP auxiliary bus driver
3113
3157
* @pf: Board private structure
3114
3158
*/
3115
- static void ice_ptp_unregister_auxbus_driver (struct ice_pf * pf )
3159
+ static void __always_unused ice_ptp_unregister_auxbus_driver (struct ice_pf * pf )
3116
3160
{
3117
3161
struct auxiliary_driver * aux_driver = & pf -> ptp .ports_owner .aux_driver ;
3118
3162
@@ -3131,15 +3175,12 @@ static void ice_ptp_unregister_auxbus_driver(struct ice_pf *pf)
3131
3175
*/
3132
3176
int ice_ptp_clock_index (struct ice_pf * pf )
3133
3177
{
3134
- struct auxiliary_device * aux_dev ;
3135
- struct ice_pf * owner_pf ;
3178
+ struct ice_ptp * ctrl_ptp = ice_get_ctrl_ptp (pf );
3136
3179
struct ptp_clock * clock ;
3137
3180
3138
- aux_dev = & pf -> ptp .port .aux_dev ;
3139
- owner_pf = ice_ptp_aux_dev_to_owner_pf (aux_dev );
3140
- if (!owner_pf )
3181
+ if (!ctrl_ptp )
3141
3182
return -1 ;
3142
- clock = owner_pf -> ptp . clock ;
3183
+ clock = ctrl_ptp -> clock ;
3143
3184
3144
3185
return clock ? ptp_clock_index (clock ) : -1 ;
3145
3186
}
@@ -3199,15 +3240,7 @@ static int ice_ptp_init_owner(struct ice_pf *pf)
3199
3240
if (err )
3200
3241
goto err_clk ;
3201
3242
3202
- err = ice_ptp_register_auxbus_driver (pf );
3203
- if (err ) {
3204
- dev_err (ice_pf_to_dev (pf ), "Failed to register PTP auxbus driver" );
3205
- goto err_aux ;
3206
- }
3207
-
3208
3243
return 0 ;
3209
- err_aux :
3210
- ptp_clock_unregister (pf -> ptp .clock );
3211
3244
err_clk :
3212
3245
pf -> ptp .clock = NULL ;
3213
3246
err_exit :
@@ -3283,7 +3316,7 @@ static void ice_ptp_release_auxbus_device(struct device *dev)
3283
3316
* ice_ptp_create_auxbus_device - Create PTP auxiliary bus device
3284
3317
* @pf: Board private structure
3285
3318
*/
3286
- static int ice_ptp_create_auxbus_device (struct ice_pf * pf )
3319
+ static __always_unused int ice_ptp_create_auxbus_device (struct ice_pf * pf )
3287
3320
{
3288
3321
struct auxiliary_device * aux_dev ;
3289
3322
struct ice_ptp * ptp ;
@@ -3330,7 +3363,7 @@ static int ice_ptp_create_auxbus_device(struct ice_pf *pf)
3330
3363
* ice_ptp_remove_auxbus_device - Remove PTP auxiliary bus device
3331
3364
* @pf: Board private structure
3332
3365
*/
3333
- static void ice_ptp_remove_auxbus_device (struct ice_pf * pf )
3366
+ static __always_unused void ice_ptp_remove_auxbus_device (struct ice_pf * pf )
3334
3367
{
3335
3368
struct auxiliary_device * aux_dev = & pf -> ptp .port .aux_dev ;
3336
3369
@@ -3394,40 +3427,43 @@ void ice_ptp_init(struct ice_pf *pf)
3394
3427
/* If this function owns the clock hardware, it must allocate and
3395
3428
* configure the PTP clock device to represent it.
3396
3429
*/
3397
- if (ice_pf_src_tmr_owned (pf )) {
3430
+ if (ice_pf_src_tmr_owned (pf ) && ice_is_primary (hw )) {
3431
+ err = ice_ptp_setup_adapter (pf );
3432
+ if (err )
3433
+ goto err_exit ;
3398
3434
err = ice_ptp_init_owner (pf );
3399
3435
if (err )
3400
- goto err ;
3436
+ goto err_exit ;
3401
3437
}
3402
3438
3439
+ err = ice_ptp_setup_pf (pf );
3440
+ if (err )
3441
+ goto err_exit ;
3442
+
3403
3443
ptp -> port .port_num = hw -> pf_id ;
3404
3444
if (ice_is_e825c (hw ) && hw -> ptp .is_2x50g_muxed_topo )
3405
3445
ptp -> port .port_num = hw -> pf_id * 2 ;
3406
3446
3407
3447
err = ice_ptp_init_port (pf , & ptp -> port );
3408
3448
if (err )
3409
- goto err ;
3449
+ goto err_exit ;
3410
3450
3411
3451
/* Start the PHY timestamping block */
3412
3452
ice_ptp_reset_phy_timestamping (pf );
3413
3453
3414
3454
/* Configure initial Tx interrupt settings */
3415
3455
ice_ptp_cfg_tx_interrupt (pf );
3416
3456
3417
- err = ice_ptp_create_auxbus_device (pf );
3418
- if (err )
3419
- goto err ;
3420
-
3421
3457
ptp -> state = ICE_PTP_READY ;
3422
3458
3423
3459
err = ice_ptp_init_work (pf , ptp );
3424
3460
if (err )
3425
- goto err ;
3461
+ goto err_exit ;
3426
3462
3427
3463
dev_info (ice_pf_to_dev (pf ), "PTP init successful\n" );
3428
3464
return ;
3429
3465
3430
- err :
3466
+ err_exit :
3431
3467
/* If we registered a PTP clock, release it */
3432
3468
if (pf -> ptp .clock ) {
3433
3469
ptp_clock_unregister (ptp -> clock );
@@ -3454,7 +3490,7 @@ void ice_ptp_release(struct ice_pf *pf)
3454
3490
/* Disable timestamping for both Tx and Rx */
3455
3491
ice_ptp_disable_timestamp_mode (pf );
3456
3492
3457
- ice_ptp_remove_auxbus_device (pf );
3493
+ ice_ptp_cleanup_pf (pf );
3458
3494
3459
3495
ice_ptp_release_tx_tracker (pf , & pf -> ptp .port .tx );
3460
3496
@@ -3469,9 +3505,6 @@ void ice_ptp_release(struct ice_pf *pf)
3469
3505
pf -> ptp .kworker = NULL ;
3470
3506
}
3471
3507
3472
- if (ice_pf_src_tmr_owned (pf ))
3473
- ice_ptp_unregister_auxbus_driver (pf );
3474
-
3475
3508
if (!pf -> ptp .clock )
3476
3509
return ;
3477
3510
0 commit comments