0028-RISC-V-Support-CPUID-for-risc-v-in-perf.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. From 81ab7f42a1153d6d93b3d429ae0c779e97b0d3d6 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Jo=C3=A3o=20M=C3=A1rio=20Domingos?=
  3. <[email protected]>
  4. Date: Tue, 16 Nov 2021 15:48:10 +0000
  5. Subject: [PATCH 28/55] RISC-V: Support CPUID for risc-v in perf
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. This patch creates the header.c file for the risc-v architecture and introduces support for
  10. PMU identification through sysfs.
  11. It is now possible to configure pmu-events in risc-v.
  12. Depends on patch [1], that introduces the id sysfs file.
  13. Signed-off-by: João Mário Domingos <[email protected]>
  14. Signed-off-by: minda.chen <[email protected]>
  15. ---
  16. drivers/perf/riscv_pmu.c | 18 ++++++++++++++++++
  17. 1 file changed, 18 insertions(+)
  18. --- a/drivers/perf/riscv_pmu.c
  19. +++ b/drivers/perf/riscv_pmu.c
  20. @@ -18,6 +18,23 @@
  21. #include <asm/sbi.h>
  22. +PMU_FORMAT_ATTR(event, "config:0-63");
  23. +
  24. +static struct attribute *riscv_arch_formats_attr[] = {
  25. + &format_attr_event.attr,
  26. + NULL,
  27. +};
  28. +
  29. +static struct attribute_group riscv_pmu_format_group = {
  30. + .name = "format",
  31. + .attrs = riscv_arch_formats_attr,
  32. +};
  33. +
  34. +static const struct attribute_group *riscv_pmu_attr_groups[] = {
  35. + &riscv_pmu_format_group,
  36. + NULL,
  37. +};
  38. +
  39. static bool riscv_perf_user_access(struct perf_event *event)
  40. {
  41. return ((event->attr.type == PERF_TYPE_HARDWARE) ||
  42. @@ -407,6 +424,7 @@ struct riscv_pmu *riscv_pmu_alloc(void)
  43. cpuc->snapshot_addr = NULL;
  44. }
  45. pmu->pmu = (struct pmu) {
  46. + .attr_groups = riscv_pmu_attr_groups,
  47. .event_init = riscv_pmu_event_init,
  48. .event_mapped = riscv_pmu_event_mapped,
  49. .event_unmapped = riscv_pmu_event_unmapped,