103-MIPS-perf-ath79-Fix-perfcount-IRQ-assignment.patch 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. From 852a88f35f4b7e5ebb717fed3c3a3330d5ad4336 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Petr=20=C5=A0tetiar?= <[email protected]>
  3. Date: Wed, 10 Apr 2019 16:43:27 +0200
  4. Subject: [PATCH v2] MIPS: perf: ath79: Fix perfcount IRQ assignment
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Currently it's not possible to use perf on ath79 due to genirq flags
  9. mismatch happening on static virtual IRQ 13 which is used for
  10. performance counters hardware IRQ 5.
  11. On TP-Link Archer C7v5:
  12. CPU0
  13. 2: 0 MIPS 2 ath9k
  14. 4: 318 MIPS 4 19000000.eth
  15. 7: 55034 MIPS 7 timer
  16. 8: 1236 MISC 3 ttyS0
  17. 12: 0 INTC 1 ehci_hcd:usb1
  18. 13: 0 gpio-ath79 2 keys
  19. 14: 0 gpio-ath79 5 keys
  20. 15: 31 AR724X PCI 1 ath10k_pci
  21. $ perf top
  22. genirq: Flags mismatch irq 13. 00014c83 (mips_perf_pmu) vs. 00002003 (keys)
  23. On TP-Link Archer C7v4:
  24. CPU0
  25. 4: 0 MIPS 4 19000000.eth
  26. 5: 7135 MIPS 5 1a000000.eth
  27. 7: 98379 MIPS 7 timer
  28. 8: 30 MISC 3 ttyS0
  29. 12: 90028 INTC 0 ath9k
  30. 13: 5520 INTC 1 ehci_hcd:usb1
  31. 14: 4623 INTC 2 ehci_hcd:usb2
  32. 15: 32844 AR724X PCI 1 ath10k_pci
  33. 16: 0 gpio-ath79 16 keys
  34. 23: 0 gpio-ath79 23 keys
  35. $ perf top
  36. genirq: Flags mismatch irq 13. 00014c80 (mips_perf_pmu) vs. 00000080 (ehci_hcd:usb1)
  37. This problem is happening, because currently statically assigned virtual
  38. IRQ 13 for performance counters is not claimed during the initialization
  39. of MIPS PMU during the bootup, so the IRQ subsystem doesn't know, that
  40. this interrupt isn't available for further use.
  41. So this patch fixes the issue by simply booking hardware IRQ 5 for MIPS PMU.
  42. Tested-by: Kevin 'ldir' Darbyshire-Bryant <[email protected]>
  43. Signed-off-by: Petr Štetiar <[email protected]>
  44. ---
  45. Changes since v1:
  46. I've incorporated two comments which I've received on IRC from blogic and
  47. I've also reworded the commit message to match the changes in v2 of this
  48. patch.
  49. * use actual hardware perfcount IRQ 5 instead of the virtual IRQ 13
  50. * dropped the CONFIG_PERF_EVENTS ifdef around irq_create_mapping
  51. arch/mips/ath79/setup.c | 6 ------
  52. drivers/irqchip/irq-ath79-misc.c | 11 +++++++++++
  53. 2 files changed, 11 insertions(+), 6 deletions(-)
  54. diff --git a/arch/mips/ath79/setup.c b/arch/mips/ath79/setup.c
  55. index 4a70c5d..25a5789 100644
  56. --- a/arch/mips/ath79/setup.c
  57. +++ b/arch/mips/ath79/setup.c
  58. @@ -210,12 +210,6 @@ const char *get_system_type(void)
  59. return ath79_sys_type;
  60. }
  61. -int get_c0_perfcount_int(void)
  62. -{
  63. - return ATH79_MISC_IRQ(5);
  64. -}
  65. -EXPORT_SYMBOL_GPL(get_c0_perfcount_int);
  66. -
  67. unsigned int get_c0_compare_int(void)
  68. {
  69. return CP0_LEGACY_COMPARE_IRQ;
  70. diff --git a/drivers/irqchip/irq-ath79-misc.c b/drivers/irqchip/irq-ath79-misc.c
  71. index aa72907..0390603 100644
  72. --- a/drivers/irqchip/irq-ath79-misc.c
  73. +++ b/drivers/irqchip/irq-ath79-misc.c
  74. @@ -22,6 +22,15 @@
  75. #define AR71XX_RESET_REG_MISC_INT_ENABLE 4
  76. #define ATH79_MISC_IRQ_COUNT 32
  77. +#define ATH79_MISC_PERF_IRQ 5
  78. +
  79. +static int ath79_perfcount_irq;
  80. +
  81. +int get_c0_perfcount_int(void)
  82. +{
  83. + return ath79_perfcount_irq;
  84. +}
  85. +EXPORT_SYMBOL_GPL(get_c0_perfcount_int);
  86. static void ath79_misc_irq_handler(struct irq_desc *desc)
  87. {
  88. @@ -113,6 +122,8 @@ static void __init ath79_misc_intc_domain_init(
  89. {
  90. void __iomem *base = domain->host_data;
  91. + ath79_perfcount_irq = irq_create_mapping(domain, ATH79_MISC_PERF_IRQ);
  92. +
  93. /* Disable and clear all interrupts */
  94. __raw_writel(0, base + AR71XX_RESET_REG_MISC_INT_ENABLE);
  95. __raw_writel(0, base + AR71XX_RESET_REG_MISC_INT_STATUS);
  96. --
  97. 1.9.1