0441-drm-vc4-Start-switching-to-using-debugfs_reg32-helpe.patch 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. From 65b36b9316eb06fa8fb7163206dc8878d36091ae Mon Sep 17 00:00:00 2001
  2. From: Eric Anholt <eric@anholt.net>
  3. Date: Fri, 20 May 2016 16:24:47 -0700
  4. Subject: [PATCH] drm/vc4: Start switching to using debugfs_reg32 helpers for
  5. debugfs.
  6. Every file was defining its own little struct and dumping for the
  7. regs, when there's a helper in debugfs for doing just this. However,
  8. instead of printing:
  9. PV_HORZA (0x000c): 0x00000000
  10. we now print:
  11. PV_HORZA = 0x00000000
  12. Signed-off-by: Eric Anholt <eric@anholt.net>
  13. ---
  14. drivers/gpu/drm/vc4/vc4_crtc.c | 48 ++++++++++++++++--------------------------
  15. drivers/gpu/drm/vc4/vc4_drv.c | 13 ++++++++++++
  16. drivers/gpu/drm/vc4/vc4_drv.h | 6 ++++++
  17. 3 files changed, 37 insertions(+), 30 deletions(-)
  18. --- a/drivers/gpu/drm/vc4/vc4_crtc.c
  19. +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
  20. @@ -35,6 +35,7 @@
  21. #include "drm_atomic_helper.h"
  22. #include "drm_crtc_helper.h"
  23. #include "linux/clk.h"
  24. +#include "linux/debugfs.h"
  25. #include "drm_fb_cma_helper.h"
  26. #include "linux/component.h"
  27. #include "linux/of_device.h"
  28. @@ -85,35 +86,25 @@ struct vc4_crtc_data {
  29. #define CRTC_WRITE(offset, val) writel(val, vc4_crtc->regs + (offset))
  30. #define CRTC_READ(offset) readl(vc4_crtc->regs + (offset))
  31. -#define CRTC_REG(reg) { reg, #reg }
  32. -static const struct {
  33. - u32 reg;
  34. - const char *name;
  35. -} crtc_regs[] = {
  36. - CRTC_REG(PV_CONTROL),
  37. - CRTC_REG(PV_V_CONTROL),
  38. - CRTC_REG(PV_VSYNCD_EVEN),
  39. - CRTC_REG(PV_HORZA),
  40. - CRTC_REG(PV_HORZB),
  41. - CRTC_REG(PV_VERTA),
  42. - CRTC_REG(PV_VERTB),
  43. - CRTC_REG(PV_VERTA_EVEN),
  44. - CRTC_REG(PV_VERTB_EVEN),
  45. - CRTC_REG(PV_INTEN),
  46. - CRTC_REG(PV_INTSTAT),
  47. - CRTC_REG(PV_STAT),
  48. - CRTC_REG(PV_HACT_ACT),
  49. +static const struct debugfs_reg32 crtc_regs[] = {
  50. + VC4_DEBUG_REG(PV_CONTROL),
  51. + VC4_DEBUG_REG(PV_V_CONTROL),
  52. + VC4_DEBUG_REG(PV_VSYNCD_EVEN),
  53. + VC4_DEBUG_REG(PV_HORZA),
  54. + VC4_DEBUG_REG(PV_HORZB),
  55. + VC4_DEBUG_REG(PV_VERTA),
  56. + VC4_DEBUG_REG(PV_VERTB),
  57. + VC4_DEBUG_REG(PV_VERTA_EVEN),
  58. + VC4_DEBUG_REG(PV_VERTB_EVEN),
  59. + VC4_DEBUG_REG(PV_INTEN),
  60. + VC4_DEBUG_REG(PV_INTSTAT),
  61. + VC4_DEBUG_REG(PV_STAT),
  62. + VC4_DEBUG_REG(PV_HACT_ACT),
  63. };
  64. static void vc4_crtc_dump_regs(struct vc4_crtc *vc4_crtc)
  65. {
  66. - int i;
  67. -
  68. - for (i = 0; i < ARRAY_SIZE(crtc_regs); i++) {
  69. - DRM_INFO("0x%04x (%s): 0x%08x\n",
  70. - crtc_regs[i].reg, crtc_regs[i].name,
  71. - CRTC_READ(crtc_regs[i].reg));
  72. - }
  73. + vc4_dump_regs32(crtc_regs, ARRAY_SIZE(crtc_regs), vc4_crtc->regs, "");
  74. }
  75. #ifdef CONFIG_DEBUG_FS
  76. @@ -136,11 +127,8 @@ int vc4_crtc_debugfs_regs(struct seq_fil
  77. return 0;
  78. vc4_crtc = to_vc4_crtc(crtc);
  79. - for (i = 0; i < ARRAY_SIZE(crtc_regs); i++) {
  80. - seq_printf(m, "%s (0x%04x): 0x%08x\n",
  81. - crtc_regs[i].name, crtc_regs[i].reg,
  82. - CRTC_READ(crtc_regs[i].reg));
  83. - }
  84. + debugfs_print_regs32(m, crtc_regs, ARRAY_SIZE(crtc_regs),
  85. + vc4_crtc->regs, "");
  86. return 0;
  87. }
  88. --- a/drivers/gpu/drm/vc4/vc4_drv.c
  89. +++ b/drivers/gpu/drm/vc4/vc4_drv.c
  90. @@ -9,6 +9,7 @@
  91. #include <linux/clk.h>
  92. #include <linux/component.h>
  93. +#include <linux/debugfs.h>
  94. #include <linux/device.h>
  95. #include <linux/io.h>
  96. #include <linux/module.h>
  97. @@ -52,6 +53,18 @@ static void vc4_drm_preclose(struct drm_
  98. vc4_cancel_page_flip(crtc, file);
  99. }
  100. +void vc4_dump_regs32(const struct debugfs_reg32 *regs, unsigned int num_regs,
  101. + void __iomem *base, const char *prefix)
  102. +{
  103. + unsigned int i;
  104. +
  105. + for (i = 0; i < num_regs; i++) {
  106. + DRM_INFO("%s0x%04lx (%s): 0x%08x\n",
  107. + prefix, regs[i].offset, regs[i].name,
  108. + readl(base + regs[i].offset));
  109. + }
  110. +}
  111. +
  112. static void vc4_lastclose(struct drm_device *dev)
  113. {
  114. struct vc4_dev *vc4 = to_vc4_dev(dev);
  115. --- a/drivers/gpu/drm/vc4/vc4_drv.h
  116. +++ b/drivers/gpu/drm/vc4/vc4_drv.h
  117. @@ -9,6 +9,8 @@
  118. #include "drmP.h"
  119. #include "drm_gem_cma_helper.h"
  120. +struct debugfs_reg32;
  121. +
  122. struct vc4_dev {
  123. struct drm_device *dev;
  124. @@ -207,6 +209,8 @@ to_vc4_encoder(struct drm_encoder *encod
  125. #define HVS_READ(offset) readl(vc4->hvs->regs + offset)
  126. #define HVS_WRITE(offset, val) writel(val, vc4->hvs->regs + offset)
  127. +#define VC4_DEBUG_REG(reg) { .name = #reg, .offset = reg }
  128. +
  129. struct vc4_exec_info {
  130. /* Sequence number for this bin/render job. */
  131. uint64_t seqno;
  132. @@ -418,6 +422,8 @@ void vc4_debugfs_cleanup(struct drm_mino
  133. /* vc4_drv.c */
  134. void __iomem *vc4_ioremap_regs(struct platform_device *dev, int index);
  135. +void vc4_dump_regs32(const struct debugfs_reg32 *reg, unsigned int num_regs,
  136. + void __iomem *base, const char *prefix);
  137. /* vc4_dpi.c */
  138. extern struct platform_driver vc4_dpi_driver;