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

Configure Feed

Select the types of activity you want to include in your feed.

Coresight: Change to read the trace ID from coresight_path

The source device can directly read the trace ID from the coresight_path
which result in etm_read_alloc_trace_id and etm4_read_alloc_trace_id being
deleted.

Co-developed-by: James Clark <james.clark@linaro.org>
Signed-off-by: James Clark <james.clark@linaro.org>
Signed-off-by: Jie Gan <quic_jiegan@quicinc.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20250303032931.2500935-7-quic_jiegan@quicinc.com

authored by

Jie Gan and committed by
Suzuki K Poulose
7b365f05 d87d76d8

+25 -108
+1 -1
drivers/hwtracing/coresight/coresight-dummy.c
··· 24 24 25 25 static int dummy_source_enable(struct coresight_device *csdev, 26 26 struct perf_event *event, enum cs_mode mode, 27 - __maybe_unused struct coresight_trace_id_map *id_map) 27 + __maybe_unused struct coresight_path *path) 28 28 { 29 29 if (!coresight_take_mode(csdev, mode)) 30 30 return -EBUSY;
+2 -6
drivers/hwtracing/coresight/coresight-etm-perf.c
··· 461 461 struct coresight_device *sink, *csdev = per_cpu(csdev_src, cpu); 462 462 struct coresight_path *path; 463 463 u64 hw_id; 464 - u8 trace_id; 465 464 466 465 if (!csdev) 467 466 goto fail; ··· 503 504 goto fail_end_stop; 504 505 505 506 /* Finally enable the tracer */ 506 - if (source_ops(csdev)->enable(csdev, event, CS_MODE_PERF, 507 - &sink->perf_sink_id_map)) 507 + if (source_ops(csdev)->enable(csdev, event, CS_MODE_PERF, path)) 508 508 goto fail_disable_path; 509 509 510 510 /* ··· 513 515 if (!cpumask_test_cpu(cpu, &event_data->aux_hwid_done)) { 514 516 cpumask_set_cpu(cpu, &event_data->aux_hwid_done); 515 517 516 - trace_id = coresight_trace_id_read_cpu_id_map(cpu, &sink->perf_sink_id_map); 517 - 518 518 hw_id = FIELD_PREP(CS_AUX_HW_ID_MAJOR_VERSION_MASK, 519 519 CS_AUX_HW_ID_MAJOR_VERSION); 520 520 hw_id |= FIELD_PREP(CS_AUX_HW_ID_MINOR_VERSION_MASK, 521 521 CS_AUX_HW_ID_MINOR_VERSION); 522 - hw_id |= FIELD_PREP(CS_AUX_HW_ID_TRACE_ID_MASK, trace_id); 522 + hw_id |= FIELD_PREP(CS_AUX_HW_ID_TRACE_ID_MASK, path->trace_id); 523 523 hw_id |= FIELD_PREP(CS_AUX_HW_ID_SINK_ID_MASK, coresight_get_sink_id(sink)); 524 524 525 525 perf_report_aux_output_id(event, hw_id);
-1
drivers/hwtracing/coresight/coresight-etm.h
··· 284 284 void etm_set_default(struct etm_config *config); 285 285 void etm_config_trace_mode(struct etm_config *config); 286 286 struct etm_config *get_etm_config(struct etm_drvdata *drvdata); 287 - int etm_read_alloc_trace_id(struct etm_drvdata *drvdata); 288 287 void etm_release_trace_id(struct etm_drvdata *drvdata); 289 288 #endif
+7 -47
drivers/hwtracing/coresight/coresight-etm3x-core.c
··· 455 455 return drvdata->cpu; 456 456 } 457 457 458 - int etm_read_alloc_trace_id(struct etm_drvdata *drvdata) 459 - { 460 - int trace_id; 461 - 462 - /* 463 - * This will allocate a trace ID to the cpu, 464 - * or return the one currently allocated. 465 - * 466 - * trace id function has its own lock 467 - */ 468 - trace_id = coresight_trace_id_get_cpu_id(drvdata->cpu); 469 - if (IS_VALID_CS_TRACE_ID(trace_id)) 470 - drvdata->traceid = (u8)trace_id; 471 - else 472 - dev_err(&drvdata->csdev->dev, 473 - "Failed to allocate trace ID for %s on CPU%d\n", 474 - dev_name(&drvdata->csdev->dev), drvdata->cpu); 475 - return trace_id; 476 - } 477 - 478 458 void etm_release_trace_id(struct etm_drvdata *drvdata) 479 459 { 480 460 coresight_trace_id_put_cpu_id(drvdata->cpu); ··· 462 482 463 483 static int etm_enable_perf(struct coresight_device *csdev, 464 484 struct perf_event *event, 465 - struct coresight_trace_id_map *id_map) 485 + struct coresight_path *path) 466 486 { 467 487 struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); 468 - int trace_id; 469 488 470 489 if (WARN_ON_ONCE(drvdata->cpu != smp_processor_id())) 471 490 return -EINVAL; 472 491 473 492 /* Configure the tracer based on the session's specifics */ 474 493 etm_parse_event_config(drvdata, event); 475 - 476 - /* 477 - * perf allocates cpu ids as part of _setup_aux() - device needs to use 478 - * the allocated ID. This reads the current version without allocation. 479 - * 480 - * This does not use the trace id lock to prevent lock_dep issues 481 - * with perf locks - we know the ID cannot change until perf shuts down 482 - * the session 483 - */ 484 - trace_id = coresight_trace_id_read_cpu_id_map(drvdata->cpu, id_map); 485 - if (!IS_VALID_CS_TRACE_ID(trace_id)) { 486 - dev_err(&drvdata->csdev->dev, "Failed to set trace ID for %s on CPU%d\n", 487 - dev_name(&drvdata->csdev->dev), drvdata->cpu); 488 - return -EINVAL; 489 - } 490 - drvdata->traceid = (u8)trace_id; 494 + drvdata->traceid = path->trace_id; 491 495 492 496 /* And enable it */ 493 497 return etm_enable_hw(drvdata); 494 498 } 495 499 496 - static int etm_enable_sysfs(struct coresight_device *csdev) 500 + static int etm_enable_sysfs(struct coresight_device *csdev, struct coresight_path *path) 497 501 { 498 502 struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); 499 503 struct etm_enable_arg arg = { }; ··· 485 521 486 522 spin_lock(&drvdata->spinlock); 487 523 488 - /* sysfs needs to allocate and set a trace ID */ 489 - ret = etm_read_alloc_trace_id(drvdata); 490 - if (ret < 0) 491 - goto unlock_enable_sysfs; 524 + drvdata->traceid = path->trace_id; 492 525 493 526 /* 494 527 * Configure the ETM only if the CPU is online. If it isn't online ··· 506 545 if (ret) 507 546 etm_release_trace_id(drvdata); 508 547 509 - unlock_enable_sysfs: 510 548 spin_unlock(&drvdata->spinlock); 511 549 512 550 if (!ret) ··· 514 554 } 515 555 516 556 static int etm_enable(struct coresight_device *csdev, struct perf_event *event, 517 - enum cs_mode mode, struct coresight_trace_id_map *id_map) 557 + enum cs_mode mode, struct coresight_path *path) 518 558 { 519 559 int ret; 520 560 struct etm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); ··· 526 566 527 567 switch (mode) { 528 568 case CS_MODE_SYSFS: 529 - ret = etm_enable_sysfs(csdev); 569 + ret = etm_enable_sysfs(csdev, path); 530 570 break; 531 571 case CS_MODE_PERF: 532 - ret = etm_enable_perf(csdev, event, id_map); 572 + ret = etm_enable_perf(csdev, event, path); 533 573 break; 534 574 default: 535 575 ret = -EINVAL;
+8 -46
drivers/hwtracing/coresight/coresight-etm4x-core.c
··· 232 232 return drvdata->cpu; 233 233 } 234 234 235 - int etm4_read_alloc_trace_id(struct etmv4_drvdata *drvdata) 236 - { 237 - int trace_id; 238 - 239 - /* 240 - * This will allocate a trace ID to the cpu, 241 - * or return the one currently allocated. 242 - * The trace id function has its own lock 243 - */ 244 - trace_id = coresight_trace_id_get_cpu_id(drvdata->cpu); 245 - if (IS_VALID_CS_TRACE_ID(trace_id)) 246 - drvdata->trcid = (u8)trace_id; 247 - else 248 - dev_err(&drvdata->csdev->dev, 249 - "Failed to allocate trace ID for %s on CPU%d\n", 250 - dev_name(&drvdata->csdev->dev), drvdata->cpu); 251 - return trace_id; 252 - } 253 - 254 235 void etm4_release_trace_id(struct etmv4_drvdata *drvdata) 255 236 { 256 237 coresight_trace_id_put_cpu_id(drvdata->cpu); ··· 791 810 792 811 static int etm4_enable_perf(struct coresight_device *csdev, 793 812 struct perf_event *event, 794 - struct coresight_trace_id_map *id_map) 813 + struct coresight_path *path) 795 814 { 796 - int ret = 0, trace_id; 815 + int ret = 0; 797 816 struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); 798 817 799 818 if (WARN_ON_ONCE(drvdata->cpu != smp_processor_id())) { ··· 806 825 if (ret) 807 826 goto out; 808 827 809 - /* 810 - * perf allocates cpu ids as part of _setup_aux() - device needs to use 811 - * the allocated ID. This reads the current version without allocation. 812 - * 813 - * This does not use the trace id lock to prevent lock_dep issues 814 - * with perf locks - we know the ID cannot change until perf shuts down 815 - * the session 816 - */ 817 - trace_id = coresight_trace_id_read_cpu_id_map(drvdata->cpu, id_map); 818 - if (!IS_VALID_CS_TRACE_ID(trace_id)) { 819 - dev_err(&drvdata->csdev->dev, "Failed to set trace ID for %s on CPU%d\n", 820 - dev_name(&drvdata->csdev->dev), drvdata->cpu); 821 - ret = -EINVAL; 822 - goto out; 823 - } 824 - drvdata->trcid = (u8)trace_id; 828 + drvdata->trcid = path->trace_id; 825 829 826 830 /* And enable it */ 827 831 ret = etm4_enable_hw(drvdata); ··· 815 849 return ret; 816 850 } 817 851 818 - static int etm4_enable_sysfs(struct coresight_device *csdev) 852 + static int etm4_enable_sysfs(struct coresight_device *csdev, struct coresight_path *path) 819 853 { 820 854 struct etmv4_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); 821 855 struct etm4_enable_arg arg = { }; ··· 832 866 833 867 spin_lock(&drvdata->spinlock); 834 868 835 - /* sysfs needs to read and allocate a trace ID */ 836 - ret = etm4_read_alloc_trace_id(drvdata); 837 - if (ret < 0) 838 - goto unlock_sysfs_enable; 869 + drvdata->trcid = path->trace_id; 839 870 840 871 /* 841 872 * Executing etm4_enable_hw on the cpu whose ETM is being enabled ··· 849 886 if (ret) 850 887 etm4_release_trace_id(drvdata); 851 888 852 - unlock_sysfs_enable: 853 889 spin_unlock(&drvdata->spinlock); 854 890 855 891 if (!ret) ··· 857 895 } 858 896 859 897 static int etm4_enable(struct coresight_device *csdev, struct perf_event *event, 860 - enum cs_mode mode, struct coresight_trace_id_map *id_map) 898 + enum cs_mode mode, struct coresight_path *path) 861 899 { 862 900 int ret; 863 901 ··· 868 906 869 907 switch (mode) { 870 908 case CS_MODE_SYSFS: 871 - ret = etm4_enable_sysfs(csdev); 909 + ret = etm4_enable_sysfs(csdev, path); 872 910 break; 873 911 case CS_MODE_PERF: 874 - ret = etm4_enable_perf(csdev, event, id_map); 912 + ret = etm4_enable_perf(csdev, event, path); 875 913 break; 876 914 default: 877 915 ret = -EINVAL;
-1
drivers/hwtracing/coresight/coresight-etm4x.h
··· 1066 1066 return drvdata->arch >= ETM_ARCH_ETE; 1067 1067 } 1068 1068 1069 - int etm4_read_alloc_trace_id(struct etmv4_drvdata *drvdata); 1070 1069 void etm4_release_trace_id(struct etmv4_drvdata *drvdata); 1071 1070 #endif
+1 -1
drivers/hwtracing/coresight/coresight-stm.c
··· 195 195 196 196 static int stm_enable(struct coresight_device *csdev, struct perf_event *event, 197 197 enum cs_mode mode, 198 - __maybe_unused struct coresight_trace_id_map *trace_id) 198 + __maybe_unused struct coresight_path *path) 199 199 { 200 200 struct stm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); 201 201
+4 -3
drivers/hwtracing/coresight/coresight-sysfs.c
··· 53 53 EXPORT_SYMBOL_GPL(coresight_simple_show32); 54 54 55 55 static int coresight_enable_source_sysfs(struct coresight_device *csdev, 56 - enum cs_mode mode, void *data) 56 + enum cs_mode mode, 57 + struct coresight_path *path) 57 58 { 58 59 int ret; 59 60 ··· 65 64 */ 66 65 lockdep_assert_held(&coresight_mutex); 67 66 if (coresight_get_mode(csdev) != CS_MODE_SYSFS) { 68 - ret = source_ops(csdev)->enable(csdev, data, mode, NULL); 67 + ret = source_ops(csdev)->enable(csdev, NULL, mode, path); 69 68 if (ret) 70 69 return ret; 71 70 } ··· 218 217 if (ret) 219 218 goto err_path; 220 219 221 - ret = coresight_enable_source_sysfs(csdev, CS_MODE_SYSFS, NULL); 220 + ret = coresight_enable_source_sysfs(csdev, CS_MODE_SYSFS, path); 222 221 if (ret) 223 222 goto err_source; 224 223
+1 -1
drivers/hwtracing/coresight/coresight-tpdm.c
··· 480 480 481 481 static int tpdm_enable(struct coresight_device *csdev, struct perf_event *event, 482 482 enum cs_mode mode, 483 - __maybe_unused struct coresight_trace_id_map *id_map) 483 + __maybe_unused struct coresight_path *path) 484 484 { 485 485 struct tpdm_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); 486 486
+1 -1
include/linux/coresight.h
··· 401 401 struct coresight_ops_source { 402 402 int (*cpu_id)(struct coresight_device *csdev); 403 403 int (*enable)(struct coresight_device *csdev, struct perf_event *event, 404 - enum cs_mode mode, struct coresight_trace_id_map *id_map); 404 + enum cs_mode mode, struct coresight_path *path); 405 405 void (*disable)(struct coresight_device *csdev, 406 406 struct perf_event *event); 407 407 };