From b21116485f0131c87f17f01a35a36e471adc7549 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Mon, 29 Jun 2020 11:53:51 -0500 Subject: [PATCH] gpu: nvgpu: Add device debug printing Add some prints that can be enabled by the nvgpu_info() infrastructure. These prints dump device information for devices as they get parsed. JIRA NVGPU-5420 Change-Id: Iaf43b9ee0ff5fb0a2e93407315e6827cba30332f Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2368311 Reviewed-by: automaticguardword Reviewed-by: Seshendra Gadagottu Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: Konsta Holtta Reviewed-by: Deepak Nibade Reviewed-by: mobile promotions Tested-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/device.c | 50 +++++++++++++++++++++++- drivers/gpu/nvgpu/include/nvgpu/device.h | 13 ++++++ 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/nvgpu/common/device.c b/drivers/gpu/nvgpu/common/device.c index 13a346f06..12b4e6406 100644 --- a/drivers/gpu/nvgpu/common/device.c +++ b/drivers/gpu/nvgpu/common/device.c @@ -27,6 +27,11 @@ #include #include +#define device_dbg(g, fmt, args...) \ + do { \ + nvgpu_log(g, gpu_dbg_device, fmt, ##args); \ + } while (0) + static inline struct nvgpu_device * nvgpu_device_from_dev_list_node(struct nvgpu_list_node *node) { @@ -35,6 +40,47 @@ nvgpu_device_from_dev_list_node(struct nvgpu_list_node *node) dev_list_node)); }; +static inline const char *nvgpu_device_type_to_str(const struct nvgpu_device *dev) +{ + const char *str = "Unknown"; + + switch (dev->type) { + case NVGPU_DEVTYPE_GRAPHICS: + str = "GFX"; + break; + case NVGPU_DEVTYPE_COPY0: + str = "CE0"; + break; + case NVGPU_DEVTYPE_COPY1: + str = "CE1"; + break; + case NVGPU_DEVTYPE_COPY2: + str = "CE2"; + break; + case NVGPU_DEVTYPE_IOCTRL: + str = "IOCTRL"; + break; + case NVGPU_DEVTYPE_LCE: + str = "LCE"; + break; + default: + break; + } + + return str; +} + +void nvgpu_device_dump_dev(struct gk20a *g, const struct nvgpu_device *dev) +{ + device_dbg(g, "Device %s:%d", + nvgpu_device_type_to_str(dev), dev->inst_id); + device_dbg(g, " EngineID: %2u FaultID: %2u", + dev->engine_id, dev->fault_id); + device_dbg(g, " RunlistID: %2u IntrID: %2u ResetID: %u", + dev->runlist_id, dev->intr_id, dev->reset_id); + device_dbg(g, " PRI Base: 0x%x", dev->pri_base); +} + /* * Faciliate the parsing of the TOP array describing the devices present in the * GPU. @@ -52,7 +98,7 @@ static int nvgpu_device_parse_hw_table(struct gk20a *g) break; } - nvgpu_log(g, gpu_dbg_info, "Parsed one device: %u", dev->type); + nvgpu_device_dump_dev(g, dev); /* * Otherwise we have a device - let's add it to the right device @@ -83,7 +129,7 @@ int nvgpu_device_init(struct gk20a *g) return 0; } - nvgpu_log(g, gpu_dbg_info, "Initialization GPU device list"); + device_dbg(g, "Initializating GPU device list"); g->devs = nvgpu_kzalloc(g, sizeof(*g->devs)); if (g->devs == NULL) { diff --git a/drivers/gpu/nvgpu/include/nvgpu/device.h b/drivers/gpu/nvgpu/include/nvgpu/device.h index 9beac0411..d35ab665f 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/device.h +++ b/drivers/gpu/nvgpu/include/nvgpu/device.h @@ -225,4 +225,17 @@ bool nvgpu_device_is_ce(struct gk20a *g, const struct nvgpu_device *dev); */ bool nvgpu_device_is_graphics(struct gk20a *g, const struct nvgpu_device *dev); +/** + * @brief Dubug dump for a device. Prints under the gpu_dbg_device log + * level. + * + * @param g [in] The GPU. + * @param dev [in] A device. + * + * Use the nvgpu_info() framework for printing a given given device's + * state information. This uses the gpu_dbg_device log level to condition + * the prints. + */ +void nvgpu_device_dump_dev(struct gk20a *g, const struct nvgpu_device *dev); + #endif /* NVGPU_DEVICE_H */