This change is aimed at improving the maintainability of the code and
laying the groundwork for versioning within the driver.
No functional changes are introduced in this commit; the driver's
behavior and performance remain unchanged.
Signed-off-by: Gowthami Thiagarajan <gthiagarajan@marvell.com>
---
drivers/perf/marvell_cn10k_ddr_pmu.c | 61 ++++++++++++++++++----------
1 file changed, 40 insertions(+), 21 deletions(-)
diff --git a/drivers/perf/marvell_cn10k_ddr_pmu.c b/drivers/perf/marvell_cn10k_ddr_pmu.c
index 648ad3a740bf..86e63a2b02d7 100644
--- a/drivers/perf/marvell_cn10k_ddr_pmu.c
+++ b/drivers/perf/marvell_cn10k_ddr_pmu.c
@@ -124,10 +124,19 @@
#define CN10K_DDRC_PERF_CNT_VALUE_WR_OP 0x80D0
#define CN10K_DDRC_PERF_CNT_VALUE_RD_OP 0x80D8
+enum mrvl_ddr_pmu_version {
+ DDR_PMU_V1 = 1,
+};
+
+struct ddr_pmu_data {
+ int id;
+};
+
struct cn10k_ddr_pmu {
struct pmu pmu;
void __iomem *base;
const struct ddr_pmu_platform_data *p_data;
+ int version;
unsigned int cpu;
struct device *dev;
int active_events;
@@ -738,12 +747,17 @@ static const struct ddr_pmu_platform_data cn10k_ddr_pmu_pdata = {
.ops = &ddr_pmu_ops,
};
+static const struct ddr_pmu_data ddr_pmu_data = {
+ .id = DDR_PMU_V1,
+};
+
static int cn10k_ddr_perf_probe(struct platform_device *pdev)
{
const struct ddr_pmu_data *dev_data;
struct cn10k_ddr_pmu *ddr_pmu;
struct resource *res;
void __iomem *base;
+ int version;
char *name;
int ret;
@@ -760,31 +774,36 @@ static int cn10k_ddr_perf_probe(struct platform_device *pdev)
return -ENODEV;
}
+ version = dev_data->id;
+ ddr_pmu->version = version;
+
base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
if (IS_ERR(base))
return PTR_ERR(base);
ddr_pmu->base = base;
- ddr_pmu->p_data = &cn10k_ddr_pmu_pdata;
- /* Setup the PMU counter to work in manual mode */
- writeq_relaxed(OP_MODE_CTRL_VAL_MANUAL, ddr_pmu->base +
- ddr_pmu->p_data->ddrc_perf_cnt_op_mode_ctrl);
-
- ddr_pmu->pmu = (struct pmu) {
- .module = THIS_MODULE,
- .capabilities = PERF_PMU_CAP_NO_EXCLUDE,
- .task_ctx_nr = perf_invalid_context,
- .attr_groups = cn10k_attr_groups,
- .event_init = cn10k_ddr_perf_event_init,
- .add = cn10k_ddr_perf_event_add,
- .del = cn10k_ddr_perf_event_del,
- .start = cn10k_ddr_perf_event_start,
- .stop = cn10k_ddr_perf_event_stop,
- .read = cn10k_ddr_perf_event_update,
- .pmu_enable = cn10k_ddr_perf_pmu_enable,
- .pmu_disable = cn10k_ddr_perf_pmu_disable,
- };
+ if (version == DDR_PMU_V1) {
+ ddr_pmu->p_data = &cn10k_ddr_pmu_pdata;
+ /* Setup the PMU counter to work in manual mode */
+ writeq_relaxed(OP_MODE_CTRL_VAL_MANUAL, ddr_pmu->base +
+ ddr_pmu->p_data->ddrc_perf_cnt_op_mode_ctrl);
+
+ ddr_pmu->pmu = (struct pmu) {
+ .module = THIS_MODULE,
+ .capabilities = PERF_PMU_CAP_NO_EXCLUDE,
+ .task_ctx_nr = perf_invalid_context,
+ .attr_groups = cn10k_attr_groups,
+ .event_init = cn10k_ddr_perf_event_init,
+ .add = cn10k_ddr_perf_event_add,
+ .del = cn10k_ddr_perf_event_del,
+ .start = cn10k_ddr_perf_event_start,
+ .stop = cn10k_ddr_perf_event_stop,
+ .read = cn10k_ddr_perf_event_update,
+ .pmu_enable = cn10k_ddr_perf_pmu_enable,
+ .pmu_disable = cn10k_ddr_perf_pmu_disable,
+ };
+ }
/* Choose this cpu to collect perf data */
ddr_pmu->cpu = raw_smp_processor_id();
@@ -827,7 +846,7 @@ static void cn10k_ddr_perf_remove(struct platform_device *pdev)
#ifdef CONFIG_OF
static const struct of_device_id cn10k_ddr_pmu_of_match[] = {
- { .compatible = "marvell,cn10k-ddr-pmu", },
+ { .compatible = "marvell,cn10k-ddr-pmu", .data = &ddr_pmu_data},
{ },
};
MODULE_DEVICE_TABLE(of, cn10k_ddr_pmu_of_match);
@@ -835,7 +854,7 @@ MODULE_DEVICE_TABLE(of, cn10k_ddr_pmu_of_match);
#ifdef CONFIG_ACPI
static const struct acpi_device_id cn10k_ddr_pmu_acpi_match[] = {
- {"MRVL000A", 0},
+ {"MRVL000A", (kernel_ulong_t)&ddr_pmu_data},
{},
};
MODULE_DEVICE_TABLE(acpi, cn10k_ddr_pmu_acpi_match);
--
2.25.1
Hi Gowthami,
kernel test robot noticed the following build warnings:
[auto build test WARNING on soc/for-next]
[also build test WARNING on linus/master v6.11-rc6 next-20240906]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Gowthami-Thiagarajan/perf-marvell-Refactor-to-extract-platform-data-no-functional-change/20240905-022904
base: https://git.kernel.org/pub/scm/linux/kernel/git/soc/soc.git for-next
patch link: https://lore.kernel.org/r/20240904182605.953927-4-gthiagarajan%40marvell.com
patch subject: [PATCH v7 3/6] perf/marvell: Refactor to add version - no functional change
config: x86_64-buildonly-randconfig-006-20240908 (https://download.01.org/0day-ci/archive/20240908/202409080342.NUUWhk1l-lkp@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240908/202409080342.NUUWhk1l-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202409080342.NUUWhk1l-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/perf/marvell_cn10k_ddr_pmu.c:750:34: warning: unused variable 'ddr_pmu_data' [-Wunused-const-variable]
750 | static const struct ddr_pmu_data ddr_pmu_data = {
| ^~~~~~~~~~~~
1 warning generated.
vim +/ddr_pmu_data +750 drivers/perf/marvell_cn10k_ddr_pmu.c
749
> 750 static const struct ddr_pmu_data ddr_pmu_data = {
751 .id = DDR_PMU_V1,
752 };
753
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
© 2016 - 2025 Red Hat, Inc.