perf/marvell: Refactor to extract platform data

Refactor the Marvell TAD PMU driver to add versioning to the
existing driver.

Make no functional changes, the behavior and performance
of the driver remain unchanged.

Signed-off-by: Gowthami Thiagarajan <gthiagarajan@marvell.com>
Link: https://lore.kernel.org/r/20241108040619.753343-5-gthiagarajan@marvell.com
Signed-off-by: Will Deacon <will@kernel.org>
This commit is contained in:
Gowthami Thiagarajan 2024-11-08 09:36:18 +05:30 committed by Will Deacon
parent d950c381dc
commit 59731e231c

View File

@ -37,6 +37,14 @@ struct tad_pmu {
DECLARE_BITMAP(counters_map, TAD_MAX_COUNTERS);
};
enum mrvl_tad_pmu_version {
TAD_PMU_V1 = 1,
};
struct tad_pmu_data {
int id;
};
static int tad_pmu_cpuhp_state;
static void tad_pmu_event_counter_read(struct perf_event *event)
@ -254,6 +262,7 @@ static const struct attribute_group *tad_pmu_attr_groups[] = {
static int tad_pmu_probe(struct platform_device *pdev)
{
const struct tad_pmu_data *dev_data;
struct device *dev = &pdev->dev;
struct tad_region *regions;
struct tad_pmu *tad_pmu;
@ -261,6 +270,7 @@ static int tad_pmu_probe(struct platform_device *pdev)
u32 tad_pmu_page_size;
u32 tad_page_size;
u32 tad_cnt;
int version;
int i, ret;
char *name;
@ -270,6 +280,13 @@ static int tad_pmu_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, tad_pmu);
dev_data = device_get_match_data(&pdev->dev);
if (!dev_data) {
dev_err(&pdev->dev, "Error: No device match data found\n");
return -ENODEV;
}
version = dev_data->id;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(&pdev->dev, "Mem resource not found\n");
@ -319,7 +336,6 @@ static int tad_pmu_probe(struct platform_device *pdev)
tad_pmu->pmu = (struct pmu) {
.module = THIS_MODULE,
.attr_groups = tad_pmu_attr_groups,
.capabilities = PERF_PMU_CAP_NO_EXCLUDE |
PERF_PMU_CAP_NO_INTERRUPT,
.task_ctx_nr = perf_invalid_context,
@ -332,6 +348,9 @@ static int tad_pmu_probe(struct platform_device *pdev)
.read = tad_pmu_event_counter_read,
};
if (version == TAD_PMU_V1)
tad_pmu->pmu.attr_groups = tad_pmu_attr_groups;
tad_pmu->cpu = raw_smp_processor_id();
/* Register pmu instance for cpu hotplug */
@ -360,16 +379,22 @@ static void tad_pmu_remove(struct platform_device *pdev)
perf_pmu_unregister(&pmu->pmu);
}
#if defined(CONFIG_OF) || defined(CONFIG_ACPI)
static const struct tad_pmu_data tad_pmu_data = {
.id = TAD_PMU_V1,
};
#endif
#ifdef CONFIG_OF
static const struct of_device_id tad_pmu_of_match[] = {
{ .compatible = "marvell,cn10k-tad-pmu", },
{ .compatible = "marvell,cn10k-tad-pmu", .data = &tad_pmu_data },
{},
};
#endif
#ifdef CONFIG_ACPI
static const struct acpi_device_id tad_pmu_acpi_match[] = {
{"MRVL000B", 0},
{"MRVL000B", (kernel_ulong_t)&tad_pmu_data},
{},
};
MODULE_DEVICE_TABLE(acpi, tad_pmu_acpi_match);