Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH] perf/marvell: cn10k_tad: Publish the OF module alias
@ 2026-09-05 13:43 hpp.iscas
  2026-09-05 13:50 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: hpp.iscas @ 2026-09-05 13:43 UTC (permalink / raw)
  To: Will Deacon
  Cc: hpp.iscas, Mark Rutland, linux-arm-kernel, linux-perf-users,
	linux-kernel, Bhaskara Budiredla

The TAD PMU platform driver has ACPI and OF match tables, but only
the ACPI table is published. A Device Tree platform device emits an
OF modalias, so the ACPI alias does not select this module for it.

Publish the OF table inside CONFIG_OF and retain ACPI support.

Fixes: 036a7584bede ("drivers: perf: Add LLC-TAD perf counter support")
Signed-off-by: hpp.iscas <hppiscas@163.com>
---
 drivers/perf/marvell_cn10k_tad_pmu.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/perf/marvell_cn10k_tad_pmu.c b/drivers/perf/marvell_cn10k_tad_pmu.c
index 54909d0..301be4d 100644
--- a/drivers/perf/marvell_cn10k_tad_pmu.c
+++ b/drivers/perf/marvell_cn10k_tad_pmu.c
@@ -424,6 +424,7 @@ static const struct of_device_id tad_pmu_of_match[] = {
 	{ .compatible = "marvell,cn10k-tad-pmu", .data = &tad_pmu_data },
 	{},
 };
+MODULE_DEVICE_TABLE(of, tad_pmu_of_match);
 #endif
 
 #ifdef CONFIG_ACPI


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] perf/marvell: cn10k_tad: Publish the OF module alias
  2026-09-05 13:43 [PATCH] perf/marvell: cn10k_tad: Publish the OF module alias hpp.iscas
@ 2026-09-05 13:50 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-09-05 13:50 UTC (permalink / raw)
  To: hpp.iscas; +Cc: linux-perf-users

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Modifying the device's shared memory resource start address in-place during probe corrupts it for future probe attempts, leading to a NULL pointer dereference.
--

commit bd6b6a4110e1310bd038c78cce7c34d20371595d
Author: hpp.iscas <hppiscas@163.com>

perf/marvell: cn10k_tad: Publish the OF module alias
    
The TAD PMU platform driver has ACPI and OF match tables, but only
the ACPI table is published. A Device Tree platform device emits an
OF modalias, so the ACPI alias does not select this module for it.
Publish the OF table inside CONFIG_OF and retain ACPI support.

> diff --git a/drivers/perf/marvell_cn10k_tad_pmu.c b/drivers/perf/marvell_cn10k_tad_pmu.c
> index 54909d0031b77..301be4d92b1bb 100644
> --- a/drivers/perf/marvell_cn10k_tad_pmu.c
> +++ b/drivers/perf/marvell_cn10k_tad_pmu.c
> @@ -424,6 +424,7 @@ static const struct of_device_id tad_pmu_of_match[] = {
>  	{ .compatible = "marvell,cn10k-tad-pmu", .data = &tad_pmu_data },
>  	{},
>  };
> +MODULE_DEVICE_TABLE(of, tad_pmu_of_match);
>  #endif

[Severity: High]
This isn't a bug introduced by this patch, but modifying the device's
shared memory resource start address in-place during probe corrupts it for
future probe attempts:

drivers/perf/marvell_cn10k_tad_pmu.c:tad_pmu_probe() {
	...
	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res) {
		dev_err(&pdev->dev, "Mem resource not found\n");
		return -ENODEV;
	}
	...
	/* ioremap the distributed TAD pmu regions */
	for (i = 0; i < tad_cnt && res->start < res->end; i++) {
		regions[i].base = devm_ioremap(&pdev->dev,
					       res->start,
					       tad_pmu_page_size);
		if (!regions[i].base) {
			dev_err(&pdev->dev, "TAD%d ioremap fail\n", i);
			return -ENOMEM;
		}
		res->start += tad_page_size;
	}
	...
}

Because platform_get_resource() returns a pointer to the global platform
device resource, advancing res->start permanently alters it.

If the driver is unbound and rebound, the subsequent probe receives the
corrupted resource where res->start is already advanced past res->end. The
loop will not execute, leaving all regions[i].base pointers as NULL.

Any subsequent perf event execution will then call readq() on a NULL pointer
in tad_pmu_event_counter_read(), resulting in a kernel panic. 

Could we avoid modifying the global resource in-place and use a local
variable for the address calculation?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260905134317.67317-1-hppiscas@163.com?part=1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-05 13:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-05 13:43 [PATCH] perf/marvell: cn10k_tad: Publish the OF module alias hpp.iscas
2026-09-05 13:50 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox