hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hwtracing/coresight/coresight-cpu-debug.c
....@@ -346,10 +346,10 @@
346346 switch (mode) {
347347 case EDDEVID_IMPL_FULL:
348348 drvdata->edvidsr_present = true;
349
- /* Fall through */
349
+ fallthrough;
350350 case EDDEVID_IMPL_EDPCSR_EDCIDSR:
351351 drvdata->edcidsr_present = true;
352
- /* Fall through */
352
+ fallthrough;
353353 case EDDEVID_IMPL_EDPCSR:
354354 /*
355355 * In ARM DDI 0487A.k, the EDDEVID1.PCSROffset is used to
....@@ -379,9 +379,10 @@
379379 int cpu;
380380 struct debug_drvdata *drvdata;
381381
382
- mutex_lock(&debug_lock);
382
+ /* Bail out if we can't acquire the mutex or the functionality is off */
383
+ if (!mutex_trylock(&debug_lock))
384
+ return NOTIFY_DONE;
383385
384
- /* Bail out if the functionality is disabled */
385386 if (!debug_enable)
386387 goto skip_dump;
387388
....@@ -400,7 +401,7 @@
400401
401402 skip_dump:
402403 mutex_unlock(&debug_lock);
403
- return 0;
404
+ return NOTIFY_DONE;
404405 }
405406
406407 static struct notifier_block debug_notifier = {
....@@ -525,23 +526,12 @@
525526
526527 static int debug_func_init(void)
527528 {
528
- struct dentry *file;
529529 int ret;
530530
531531 /* Create debugfs node */
532532 debug_debugfs_dir = debugfs_create_dir("coresight_cpu_debug", NULL);
533
- if (!debug_debugfs_dir) {
534
- pr_err("%s: unable to create debugfs directory\n", __func__);
535
- return -ENOMEM;
536
- }
537
-
538
- file = debugfs_create_file("enable", 0644, debug_debugfs_dir, NULL,
539
- &debug_func_knob_fops);
540
- if (!file) {
541
- pr_err("%s: unable to create enable knob file\n", __func__);
542
- ret = -ENOMEM;
543
- goto err;
544
- }
533
+ debugfs_create_file("enable", 0644, debug_debugfs_dir, NULL,
534
+ &debug_func_knob_fops);
545535
546536 /* Register function to be called for panic */
547537 ret = atomic_notifier_chain_register(&panic_notifier_list,
....@@ -572,14 +562,16 @@
572562 struct device *dev = &adev->dev;
573563 struct debug_drvdata *drvdata;
574564 struct resource *res = &adev->res;
575
- struct device_node *np = adev->dev.of_node;
576565 int ret;
577566
578567 drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
579568 if (!drvdata)
580569 return -ENOMEM;
581570
582
- drvdata->cpu = np ? of_coresight_get_cpu(np) : 0;
571
+ drvdata->cpu = coresight_get_cpu(dev);
572
+ if (drvdata->cpu < 0)
573
+ return drvdata->cpu;
574
+
583575 if (per_cpu(debug_drvdata, drvdata->cpu)) {
584576 dev_err(dev, "CPU%d drvdata has already been initialized\n",
585577 drvdata->cpu);
....@@ -636,7 +628,7 @@
636628 return ret;
637629 }
638630
639
-static int debug_remove(struct amba_device *adev)
631
+static void debug_remove(struct amba_device *adev)
640632 {
641633 struct device *dev = &adev->dev;
642634 struct debug_drvdata *drvdata = amba_get_drvdata(adev);
....@@ -651,30 +643,29 @@
651643
652644 if (!--debug_count)
653645 debug_func_exit();
654
-
655
- return 0;
656646 }
657647
658
-static const struct amba_id debug_ids[] = {
659
- { /* Debug for Cortex-A53 */
660
- .id = 0x000bbd03,
661
- .mask = 0x000fffff,
662
- },
663
- { /* Debug for Cortex-A57 */
664
- .id = 0x000bbd07,
665
- .mask = 0x000fffff,
666
- },
667
- { /* Debug for Cortex-A72 */
668
- .id = 0x000bbd08,
669
- .mask = 0x000fffff,
670
- },
671
- { /* Debug for Cortex-A73 */
672
- .id = 0x000bbd09,
673
- .mask = 0x000fffff,
674
- },
675
- { 0, 0 },
648
+static const struct amba_cs_uci_id uci_id_debug[] = {
649
+ {
650
+ /* CPU Debug UCI data */
651
+ .devarch = 0x47706a15,
652
+ .devarch_mask = 0xfff0ffff,
653
+ .devtype = 0x00000015,
654
+ }
676655 };
677656
657
+static const struct amba_id debug_ids[] = {
658
+ CS_AMBA_ID(0x000bbd03), /* Cortex-A53 */
659
+ CS_AMBA_ID(0x000bbd07), /* Cortex-A57 */
660
+ CS_AMBA_ID(0x000bbd08), /* Cortex-A72 */
661
+ CS_AMBA_ID(0x000bbd09), /* Cortex-A73 */
662
+ CS_AMBA_UCI_ID(0x000f0205, uci_id_debug), /* Qualcomm Kryo */
663
+ CS_AMBA_UCI_ID(0x000f0211, uci_id_debug), /* Qualcomm Kryo */
664
+ {},
665
+};
666
+
667
+MODULE_DEVICE_TABLE(amba, debug_ids);
668
+
678669 static struct amba_driver debug_driver = {
679670 .drv = {
680671 .name = "coresight-cpu-debug",