@@ -302,7 +302,7 @@ void i915_pmu_gt_parked(struct intel_gt *gt)
302302{
303303 struct i915_pmu * pmu = & gt -> i915 -> pmu ;
304304
305- if (!pmu -> base . event_init )
305+ if (!pmu -> registered )
306306 return ;
307307
308308 spin_lock_irq (& pmu -> lock );
@@ -324,7 +324,7 @@ void i915_pmu_gt_unparked(struct intel_gt *gt)
324324{
325325 struct i915_pmu * pmu = & gt -> i915 -> pmu ;
326326
327- if (!pmu -> base . event_init )
327+ if (!pmu -> registered )
328328 return ;
329329
330330 spin_lock_irq (& pmu -> lock );
@@ -626,7 +626,7 @@ static int i915_pmu_event_init(struct perf_event *event)
626626 struct drm_i915_private * i915 = pmu_to_i915 (pmu );
627627 int ret ;
628628
629- if (pmu -> closed )
629+ if (! pmu -> registered )
630630 return - ENODEV ;
631631
632632 if (event -> attr .type != event -> pmu -> type )
@@ -724,7 +724,7 @@ static void i915_pmu_event_read(struct perf_event *event)
724724 struct hw_perf_event * hwc = & event -> hw ;
725725 u64 prev , new ;
726726
727- if (pmu -> closed ) {
727+ if (! pmu -> registered ) {
728728 event -> hw .state = PERF_HES_STOPPED ;
729729 return ;
730730 }
@@ -850,7 +850,7 @@ static void i915_pmu_event_start(struct perf_event *event, int flags)
850850{
851851 struct i915_pmu * pmu = event_to_pmu (event );
852852
853- if (pmu -> closed )
853+ if (! pmu -> registered )
854854 return ;
855855
856856 i915_pmu_enable (event );
@@ -861,7 +861,7 @@ static void i915_pmu_event_stop(struct perf_event *event, int flags)
861861{
862862 struct i915_pmu * pmu = event_to_pmu (event );
863863
864- if (pmu -> closed )
864+ if (! pmu -> registered )
865865 goto out ;
866866
867867 if (flags & PERF_EF_UPDATE )
@@ -877,7 +877,7 @@ static int i915_pmu_event_add(struct perf_event *event, int flags)
877877{
878878 struct i915_pmu * pmu = event_to_pmu (event );
879879
880- if (pmu -> closed )
880+ if (! pmu -> registered )
881881 return - ENODEV ;
882882
883883 if (flags & PERF_EF_START )
@@ -1177,8 +1177,6 @@ static int i915_pmu_cpu_online(unsigned int cpu, struct hlist_node *node)
11771177{
11781178 struct i915_pmu * pmu = hlist_entry_safe (node , typeof (* pmu ), cpuhp .node );
11791179
1180- GEM_BUG_ON (!pmu -> base .event_init );
1181-
11821180 /* Select the first online CPU as a designated reader. */
11831181 if (cpumask_empty (& i915_pmu_cpumask ))
11841182 cpumask_set_cpu (cpu , & i915_pmu_cpumask );
@@ -1191,13 +1189,11 @@ static int i915_pmu_cpu_offline(unsigned int cpu, struct hlist_node *node)
11911189 struct i915_pmu * pmu = hlist_entry_safe (node , typeof (* pmu ), cpuhp .node );
11921190 unsigned int target = i915_pmu_target_cpu ;
11931191
1194- GEM_BUG_ON (!pmu -> base .event_init );
1195-
11961192 /*
11971193 * Unregistering an instance generates a CPU offline event which we must
11981194 * ignore to avoid incorrectly modifying the shared i915_pmu_cpumask.
11991195 */
1200- if (pmu -> closed )
1196+ if (! pmu -> registered )
12011197 return 0 ;
12021198
12031199 if (cpumask_test_and_clear_cpu (cpu , & i915_pmu_cpumask )) {
@@ -1218,7 +1214,7 @@ static int i915_pmu_cpu_offline(unsigned int cpu, struct hlist_node *node)
12181214 return 0 ;
12191215}
12201216
1221- static enum cpuhp_state cpuhp_slot = CPUHP_INVALID ;
1217+ static enum cpuhp_state cpuhp_state = CPUHP_INVALID ;
12221218
12231219int i915_pmu_init (void )
12241220{
@@ -1232,28 +1228,28 @@ int i915_pmu_init(void)
12321228 pr_notice ("Failed to setup cpuhp state for i915 PMU! (%d)\n" ,
12331229 ret );
12341230 else
1235- cpuhp_slot = ret ;
1231+ cpuhp_state = ret ;
12361232
12371233 return 0 ;
12381234}
12391235
12401236void i915_pmu_exit (void )
12411237{
1242- if (cpuhp_slot != CPUHP_INVALID )
1243- cpuhp_remove_multi_state (cpuhp_slot );
1238+ if (cpuhp_state != CPUHP_INVALID )
1239+ cpuhp_remove_multi_state (cpuhp_state );
12441240}
12451241
12461242static int i915_pmu_register_cpuhp_state (struct i915_pmu * pmu )
12471243{
1248- if (cpuhp_slot == CPUHP_INVALID )
1244+ if (cpuhp_state == CPUHP_INVALID )
12491245 return - EINVAL ;
12501246
1251- return cpuhp_state_add_instance (cpuhp_slot , & pmu -> cpuhp .node );
1247+ return cpuhp_state_add_instance (cpuhp_state , & pmu -> cpuhp .node );
12521248}
12531249
12541250static void i915_pmu_unregister_cpuhp_state (struct i915_pmu * pmu )
12551251{
1256- cpuhp_state_remove_instance (cpuhp_slot , & pmu -> cpuhp .node );
1252+ cpuhp_state_remove_instance (cpuhp_state , & pmu -> cpuhp .node );
12571253}
12581254
12591255void i915_pmu_register (struct drm_i915_private * i915 )
@@ -1265,7 +1261,6 @@ void i915_pmu_register(struct drm_i915_private *i915)
12651261 & i915_pmu_cpumask_attr_group ,
12661262 NULL
12671263 };
1268-
12691264 int ret = - ENOMEM ;
12701265
12711266 spin_lock_init (& pmu -> lock );
@@ -1316,14 +1311,15 @@ void i915_pmu_register(struct drm_i915_private *i915)
13161311 if (ret )
13171312 goto err_unreg ;
13181313
1314+ pmu -> registered = true;
1315+
13191316 return ;
13201317
13211318err_unreg :
13221319 perf_pmu_unregister (& pmu -> base );
13231320err_groups :
13241321 kfree (pmu -> base .attr_groups );
13251322err_attr :
1326- pmu -> base .event_init = NULL ;
13271323 free_event_attributes (pmu );
13281324err_name :
13291325 if (IS_DGFX (i915 ))
@@ -1336,23 +1332,17 @@ void i915_pmu_unregister(struct drm_i915_private *i915)
13361332{
13371333 struct i915_pmu * pmu = & i915 -> pmu ;
13381334
1339- if (!pmu -> base . event_init )
1335+ if (!pmu -> registered )
13401336 return ;
13411337
1342- /*
1343- * "Disconnect" the PMU callbacks - since all are atomic synchronize_rcu
1344- * ensures all currently executing ones will have exited before we
1345- * proceed with unregistration.
1346- */
1347- pmu -> closed = true;
1348- synchronize_rcu ();
1338+ /* Disconnect the PMU callbacks */
1339+ pmu -> registered = false;
13491340
13501341 hrtimer_cancel (& pmu -> timer );
13511342
13521343 i915_pmu_unregister_cpuhp_state (pmu );
13531344
13541345 perf_pmu_unregister (& pmu -> base );
1355- pmu -> base .event_init = NULL ;
13561346 kfree (pmu -> base .attr_groups );
13571347 if (IS_DGFX (i915 ))
13581348 kfree (pmu -> name );
0 commit comments