Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Gowthami Thiagarajan and committed by
Will Deacon
59731e23 d950c381

+28 -3
+28 -3
drivers/perf/marvell_cn10k_tad_pmu.c
··· 37 37 DECLARE_BITMAP(counters_map, TAD_MAX_COUNTERS); 38 38 }; 39 39 40 + enum mrvl_tad_pmu_version { 41 + TAD_PMU_V1 = 1, 42 + }; 43 + 44 + struct tad_pmu_data { 45 + int id; 46 + }; 47 + 40 48 static int tad_pmu_cpuhp_state; 41 49 42 50 static void tad_pmu_event_counter_read(struct perf_event *event) ··· 262 254 263 255 static int tad_pmu_probe(struct platform_device *pdev) 264 256 { 257 + const struct tad_pmu_data *dev_data; 265 258 struct device *dev = &pdev->dev; 266 259 struct tad_region *regions; 267 260 struct tad_pmu *tad_pmu; ··· 270 261 u32 tad_pmu_page_size; 271 262 u32 tad_page_size; 272 263 u32 tad_cnt; 264 + int version; 273 265 int i, ret; 274 266 char *name; 275 267 ··· 279 269 return -ENOMEM; 280 270 281 271 platform_set_drvdata(pdev, tad_pmu); 272 + 273 + dev_data = device_get_match_data(&pdev->dev); 274 + if (!dev_data) { 275 + dev_err(&pdev->dev, "Error: No device match data found\n"); 276 + return -ENODEV; 277 + } 278 + version = dev_data->id; 282 279 283 280 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 284 281 if (!res) { ··· 336 319 tad_pmu->pmu = (struct pmu) { 337 320 338 321 .module = THIS_MODULE, 339 - .attr_groups = tad_pmu_attr_groups, 340 322 .capabilities = PERF_PMU_CAP_NO_EXCLUDE | 341 323 PERF_PMU_CAP_NO_INTERRUPT, 342 324 .task_ctx_nr = perf_invalid_context, ··· 347 331 .stop = tad_pmu_event_counter_stop, 348 332 .read = tad_pmu_event_counter_read, 349 333 }; 334 + 335 + if (version == TAD_PMU_V1) 336 + tad_pmu->pmu.attr_groups = tad_pmu_attr_groups; 350 337 351 338 tad_pmu->cpu = raw_smp_processor_id(); 352 339 ··· 379 360 perf_pmu_unregister(&pmu->pmu); 380 361 } 381 362 363 + #if defined(CONFIG_OF) || defined(CONFIG_ACPI) 364 + static const struct tad_pmu_data tad_pmu_data = { 365 + .id = TAD_PMU_V1, 366 + }; 367 + #endif 368 + 382 369 #ifdef CONFIG_OF 383 370 static const struct of_device_id tad_pmu_of_match[] = { 384 - { .compatible = "marvell,cn10k-tad-pmu", }, 371 + { .compatible = "marvell,cn10k-tad-pmu", .data = &tad_pmu_data }, 385 372 {}, 386 373 }; 387 374 #endif 388 375 389 376 #ifdef CONFIG_ACPI 390 377 static const struct acpi_device_id tad_pmu_acpi_match[] = { 391 - {"MRVL000B", 0}, 378 + {"MRVL000B", (kernel_ulong_t)&tad_pmu_data}, 392 379 {}, 393 380 }; 394 381 MODULE_DEVICE_TABLE(acpi, tad_pmu_acpi_match);