Skip to content

Commit 9116b57

Browse files
committed
drm/i915/pmu: Stop setting event_init to NULL
Setting event_init to NULL is mostly done to detect when the driver is partially working: i915 probed, but pmu is not registered. However, checking for event_init is odd as it was supposed to always be set and kernel/events/ would just crash if it found it set to NULL. Since there's already a "closed" boolean, use that instead and extend it's meaning to unregistered/unregistering. Reviewed-by: Matt Roper <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Lucas De Marchi <[email protected]>
1 parent c62018a commit 9116b57

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

drivers/gpu/drm/i915/i915_pmu.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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->closed)
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->closed)
328328
return;
329329

330330
spin_lock_irq(&pmu->lock);
@@ -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,8 +1189,6 @@ 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.
@@ -1265,9 +1261,10 @@ void i915_pmu_register(struct drm_i915_private *i915)
12651261
&i915_pmu_cpumask_attr_group,
12661262
NULL
12671263
};
1268-
12691264
int ret = -ENOMEM;
12701265

1266+
pmu->closed = true;
1267+
12711268
spin_lock_init(&pmu->lock);
12721269
hrtimer_init(&pmu->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
12731270
pmu->timer.function = i915_sample;
@@ -1316,14 +1313,15 @@ void i915_pmu_register(struct drm_i915_private *i915)
13161313
if (ret)
13171314
goto err_unreg;
13181315

1316+
pmu->closed = false;
1317+
13191318
return;
13201319

13211320
err_unreg:
13221321
perf_pmu_unregister(&pmu->base);
13231322
err_groups:
13241323
kfree(pmu->base.attr_groups);
13251324
err_attr:
1326-
pmu->base.event_init = NULL;
13271325
free_event_attributes(pmu);
13281326
err_name:
13291327
if (IS_DGFX(i915))
@@ -1336,9 +1334,6 @@ void i915_pmu_unregister(struct drm_i915_private *i915)
13361334
{
13371335
struct i915_pmu *pmu = &i915->pmu;
13381336

1339-
if (!pmu->base.event_init)
1340-
return;
1341-
13421337
/*
13431338
* "Disconnect" the PMU callbacks - since all are atomic synchronize_rcu
13441339
* ensures all currently executing ones will have exited before we
@@ -1352,7 +1347,6 @@ void i915_pmu_unregister(struct drm_i915_private *i915)
13521347
i915_pmu_unregister_cpuhp_state(pmu);
13531348

13541349
perf_pmu_unregister(&pmu->base);
1355-
pmu->base.event_init = NULL;
13561350
kfree(pmu->base.attr_groups);
13571351
if (IS_DGFX(i915))
13581352
kfree(pmu->name);

0 commit comments

Comments
 (0)