forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/arch/arm/mach-imx/mmdc.c
....@@ -1,14 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Copyright 2017 NXP
34 * Copyright 2011,2016 Freescale Semiconductor, Inc.
45 * Copyright 2011 Linaro Ltd.
5
- *
6
- * The code contained herein is licensed under the GNU General Public
7
- * License. You may obtain a copy of the GNU General Public License
8
- * Version 2 or later at the following locations:
9
- *
10
- * http://www.opensource.org/licenses/gpl-license.html
11
- * http://www.gnu.org/copyleft/gpl.html
126 */
137
148 #include <linux/clk.h>
....@@ -105,6 +99,7 @@
10599 cpumask_t cpu;
106100 struct hrtimer hrtimer;
107101 unsigned int active_events;
102
+ int id;
108103 struct device *dev;
109104 struct perf_event *mmdc_events[MMDC_NUM_COUNTERS];
110105 struct hlist_node node;
....@@ -295,13 +290,7 @@
295290 return -EOPNOTSUPP;
296291 }
297292
298
- if (event->attr.exclude_user ||
299
- event->attr.exclude_kernel ||
300
- event->attr.exclude_hv ||
301
- event->attr.exclude_idle ||
302
- event->attr.exclude_host ||
303
- event->attr.exclude_guest ||
304
- event->attr.sample_period)
293
+ if (event->attr.sample_period)
305294 return -EINVAL;
306295
307296 if (cfg < 0 || cfg >= MMDC_NUM_COUNTERS)
....@@ -445,8 +434,6 @@
445434 static int mmdc_pmu_init(struct mmdc_pmu *pmu_mmdc,
446435 void __iomem *mmdc_base, struct device *dev)
447436 {
448
- int mmdc_num;
449
-
450437 *pmu_mmdc = (struct mmdc_pmu) {
451438 .pmu = (struct pmu) {
452439 .task_ctx_nr = perf_invalid_context,
....@@ -457,21 +444,23 @@
457444 .start = mmdc_pmu_event_start,
458445 .stop = mmdc_pmu_event_stop,
459446 .read = mmdc_pmu_event_update,
447
+ .capabilities = PERF_PMU_CAP_NO_EXCLUDE,
460448 },
461449 .mmdc_base = mmdc_base,
462450 .dev = dev,
463451 .active_events = 0,
464452 };
465453
466
- mmdc_num = ida_simple_get(&mmdc_ida, 0, 0, GFP_KERNEL);
454
+ pmu_mmdc->id = ida_simple_get(&mmdc_ida, 0, 0, GFP_KERNEL);
467455
468
- return mmdc_num;
456
+ return pmu_mmdc->id;
469457 }
470458
471459 static int imx_mmdc_remove(struct platform_device *pdev)
472460 {
473461 struct mmdc_pmu *pmu_mmdc = platform_get_drvdata(pdev);
474462
463
+ ida_simple_remove(&mmdc_ida, pmu_mmdc->id);
475464 cpuhp_state_remove_instance_nocalls(cpuhp_mmdc_state, &pmu_mmdc->node);
476465 perf_pmu_unregister(&pmu_mmdc->pmu);
477466 iounmap(pmu_mmdc->mmdc_base);
....@@ -485,7 +474,6 @@
485474 {
486475 struct mmdc_pmu *pmu_mmdc;
487476 char *name;
488
- int mmdc_num;
489477 int ret;
490478 const struct of_device_id *of_id =
491479 of_match_device(imx_mmdc_dt_ids, &pdev->dev);
....@@ -508,14 +496,14 @@
508496 cpuhp_mmdc_state = ret;
509497 }
510498
511
- mmdc_num = mmdc_pmu_init(pmu_mmdc, mmdc_base, &pdev->dev);
512
- pmu_mmdc->mmdc_ipg_clk = mmdc_ipg_clk;
513
- if (mmdc_num == 0)
514
- name = "mmdc";
515
- else
516
- name = devm_kasprintf(&pdev->dev,
517
- GFP_KERNEL, "mmdc%d", mmdc_num);
499
+ ret = mmdc_pmu_init(pmu_mmdc, mmdc_base, &pdev->dev);
500
+ if (ret < 0)
501
+ goto pmu_free;
518502
503
+ name = devm_kasprintf(&pdev->dev,
504
+ GFP_KERNEL, "mmdc%d", ret);
505
+
506
+ pmu_mmdc->mmdc_ipg_clk = mmdc_ipg_clk;
519507 pmu_mmdc->devtype_data = (struct fsl_mmdc_devtype_data *)of_id->data;
520508
521509 hrtimer_init(&pmu_mmdc->hrtimer, CLOCK_MONOTONIC,
....@@ -536,6 +524,7 @@
536524
537525 pmu_register_err:
538526 pr_warn("MMDC Perf PMU failed (%d), disabled\n", ret);
527
+ ida_simple_remove(&mmdc_ida, pmu_mmdc->id);
539528 cpuhp_state_remove_instance_nocalls(cpuhp_mmdc_state, &pmu_mmdc->node);
540529 hrtimer_cancel(&pmu_mmdc->hrtimer);
541530 pmu_free: