[RFC 0/2] drm/msm: additions for firmware debugging

Rob Clark robdclark at gmail.com
Wed Dec 13 20:12:55 UTC 2017

A couple patches aimed in particular at simplifying firmware debugging.

The first patch adds some debugfs to dump out state, as well as a
debugfs file that can be written to trigger GPU reset and firmware

The second patch adds a new SUBMIT ioctl flag to allow userspace to
submit cmdstream that is executed from the ringbuffer (RB) instead of
from IB1.  *Normally* this isn't something you want to allow userspace
to do, so it is (a) restricted to CAP_SYS_ADMIN and (b) hidden behind
an additional kconfig option.  But it *is* quite useful for debugging
since it allows you to execute a single command and then dump out the
PFP and/or ME microcontroller registers/state, without having that state
overwritten by handling of the return-from-CP_INDIRECT_BUFFER or other
commands that the kernel normally writes into RB as part of handling of

Compared to hacking up the kernel to submit different commands and
dumping state, these two patches avoid much kernel rebuilding and
rebooting.  Also it makes it much easier to debug commands that have
pointers to other GPU buffers, since it re-uses all the existing SUBMIT
reloc logic.

Maybe I should also add a module_param() to unlock the "sudo" flag on
SUBMIT, or some other mechanism to prevent accidental use?  Suggestions

So far, the "sudo" flag is only supported on a5xx.. a4xx and before had
different instruction sets for PFP and ME (which seem to closely match
the PFP and ME instruction sets for r600), and I haven't tried to write
an assembler/disassembler for those yet (and therefore haven't needed
this feature).

In case anyone else wants to play with this, see:


Rob Clark (2):
  drm/msm: add a5xx specific debugfs
  drm/msm: add sudo flag to submit ioctl

 drivers/gpu/drm/msm/Kconfig                |  13 ++
 drivers/gpu/drm/msm/Makefile               |   2 +
 drivers/gpu/drm/msm/adreno/a5xx_debugfs.c  | 188 +++++++++++++++++++++++++++++
 drivers/gpu/drm/msm/adreno/a5xx_gpu.c      |  66 ++++++++++
 drivers/gpu/drm/msm/adreno/a5xx_gpu.h      |   4 +
 drivers/gpu/drm/msm/adreno/adreno_device.c |   6 +
 drivers/gpu/drm/msm/msm_debugfs.c          |   5 +-
 drivers/gpu/drm/msm/msm_gem.h              |   1 +
 drivers/gpu/drm/msm/msm_gem_submit.c       |   9 ++
 drivers/gpu/drm/msm/msm_gpu.h              |   2 +
 include/uapi/drm/msm_drm.h                 |   2 +
 11 files changed, 297 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/msm/adreno/a5xx_debugfs.c


More information about the dri-devel mailing list