[PATCH 1/4] drm/amdgpu: introduce the cgs print helpers

Huang Rui ray.huang at amd.com
Thu Dec 8 05:23:08 UTC 2016


This patch introduces cgs print helpers, this helpers will be used on
powerplay part instead of raw printk. Then we can dynamic adjust
powerplay print level. The prefix of print is like below:

[  310.200991] amdgpu 0000:01:00.0: [powerplay] ...

Signed-off-by: Huang Rui <ray.huang at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c  | 26 +++++++++++++++++++++++++-
 drivers/gpu/drm/amd/include/cgs_common.h | 24 ++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
index 9ada56c..aade225 100755
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
@@ -42,6 +42,26 @@ struct amdgpu_cgs_device {
 	struct amdgpu_device *adev =					\
 		((struct amdgpu_cgs_device *)cgs_device)->adev
 
+#define DECLARE_CGS_PRINT(level) 			 \
+static void						 \
+amdgpu_cgs_##level(struct cgs_device *cgs_device,	 \
+		   const char *fmt, ...)		 \
+{							 \
+	CGS_FUNC_ADEV;					 \
+	struct va_format vaf;				 \
+	va_list args;					 \
+	va_start(args, fmt);				 \
+	vaf.fmt = fmt;					 \
+	vaf.va = &args;					 \
+	dev_##level(adev->dev, "[powerplay] %pV", &vaf); \
+	va_end(args);					 \
+}
+
+DECLARE_CGS_PRINT(err);
+DECLARE_CGS_PRINT(warn);
+DECLARE_CGS_PRINT(info);
+DECLARE_CGS_PRINT(dbg);
+
 static int amdgpu_cgs_gpu_mem_info(struct cgs_device *cgs_device, enum cgs_gpu_mem_type type,
 				   uint64_t *mc_start, uint64_t *mc_size,
 				   uint64_t *mem_size)
@@ -1235,7 +1255,11 @@ static const struct cgs_ops amdgpu_cgs_ops = {
 	amdgpu_cgs_notify_dpm_enabled,
 	amdgpu_cgs_call_acpi_method,
 	amdgpu_cgs_query_system_info,
-	amdgpu_cgs_is_virtualization_enabled
+	amdgpu_cgs_is_virtualization_enabled,
+	amdgpu_cgs_err,
+	amdgpu_cgs_warn,
+	amdgpu_cgs_info,
+	amdgpu_cgs_dbg,
 };
 
 static const struct cgs_os_ops amdgpu_cgs_os_ops = {
diff --git a/drivers/gpu/drm/amd/include/cgs_common.h b/drivers/gpu/drm/amd/include/cgs_common.h
index e4a1697..242be9f 100755
--- a/drivers/gpu/drm/amd/include/cgs_common.h
+++ b/drivers/gpu/drm/amd/include/cgs_common.h
@@ -620,6 +620,15 @@ typedef int (*cgs_call_acpi_method)(struct cgs_device *cgs_device,
 typedef int (*cgs_query_system_info)(struct cgs_device *cgs_device,
 				struct cgs_system_info *sys_info);
 
+typedef void (*cgs_err)(struct cgs_device *cgs_device,
+			const char *format, ...);
+typedef void (*cgs_warn)(struct cgs_device *cgs_device,
+			 const char *format, ...);
+typedef void (*cgs_info)(struct cgs_device *cgs_device,
+			 const char *format, ...);
+typedef void (*cgs_dbg)(struct cgs_device *cgs_device,
+			const char *format, ...);
+
 typedef int (*cgs_is_virtualization_enabled_t)(void *cgs_device);
 
 struct cgs_ops {
@@ -674,6 +683,11 @@ struct cgs_ops {
 	/* get system info */
 	cgs_query_system_info query_system_info;
 	cgs_is_virtualization_enabled_t is_virtualization_enabled;
+	/* cgs prints */
+	cgs_err err;
+	cgs_warn warn;
+	cgs_info info;
+	cgs_dbg dbg;
 };
 
 struct cgs_os_ops; /* To be define in OS-specific CGS header */
@@ -772,6 +786,16 @@ struct cgs_device
 	CGS_CALL(call_acpi_method, dev, acpi_method, acpi_function, pintput, poutput, output_count, input_size, output_size)
 #define cgs_query_system_info(dev, sys_info)	\
 	CGS_CALL(query_system_info, dev, sys_info)
+
+#define cgs_err(dev, format, ...)     \
+	CGS_CALL(err, dev, format, ##__VA_ARGS__)
+#define cgs_warn(dev, format, ...)     \
+	CGS_CALL(warn, dev, format, ##__VA_ARGS__)
+#define cgs_info(dev, format, ...)     \
+	CGS_CALL(info, dev, format, ##__VA_ARGS__)
+#define cgs_dbg(dev, format, ...)     \
+	CGS_CALL(dbg, dev, format, ##__VA_ARGS__)
+
 #define cgs_get_pci_resource(cgs_device, resource_type, size, offset, \
 	resource_base) \
 	CGS_CALL(get_pci_resource, cgs_device, resource_type, size, offset, \
-- 
2.7.4



More information about the amd-gfx mailing list