Skip to content

Commit 143f83e

Browse files
jic23djbw
authored andcommitted
perf: Allow a PMU to have a parent
Some PMUs have well defined parents such as PCI devices. As the device_initialize() and device_add() are all within pmu_dev_alloc() which is called from perf_pmu_register() there is no opportunity to set the parent from within a driver. Add a struct device *parent field to struct pmu and use that to set the parent. Reviewed-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Link: https://lore.kernel.org/r/20230526095824.16336-2-Jonathan.Cameron@huawei.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 7877cb9 commit 143f83e

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

include/linux/perf_event.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ struct pmu {
303303

304304
struct module *module;
305305
struct device *dev;
306+
struct device *parent;
306307
const struct attribute_group **attr_groups;
307308
const struct attribute_group **attr_update;
308309
const char *name;

kernel/events/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11379,6 +11379,7 @@ static int pmu_dev_alloc(struct pmu *pmu)
1137911379

1138011380
dev_set_drvdata(pmu->dev, pmu);
1138111381
pmu->dev->bus = &pmu_bus;
11382+
pmu->dev->parent = pmu->parent;
1138211383
pmu->dev->release = pmu_dev_release;
1138311384

1138411385
ret = dev_set_name(pmu->dev, "%s", pmu->name);

0 commit comments

Comments
 (0)