All of lore.kernel.org
 help / color / mirror / Atom feed
From: Huang Rui <ray.huang-5C7GfCeVMHo@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	"Alex Deucher" <alexander.deucher-5C7GfCeVMHo@public.gmane.org>,
	"Christian König" <christian.koenig-5C7GfCeVMHo@public.gmane.org>
Cc: Arindam Nath <Arindam.Nath-5C7GfCeVMHo@public.gmane.org>,
	Huang Rui <ray.huang-5C7GfCeVMHo@public.gmane.org>
Subject: [PATCH 1/4] drm/amdgpu: introduce the cgs print helpers
Date: Thu, 8 Dec 2016 13:23:08 +0800	[thread overview]
Message-ID: <1481174591-2187-2-git-send-email-ray.huang@amd.com> (raw)
In-Reply-To: <1481174591-2187-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>

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@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

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2016-12-08  5:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-08  5:23 [PATCH 0/4] drm/amd/powerplay: introduce the cgs print helpers Huang Rui
     [not found] ` <1481174591-2187-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org>
2016-12-08  5:23   ` Huang Rui [this message]
2016-12-08  5:23   ` [PATCH 2/4] drm/amd/powerplay: update printk to cgs debug prints for smumgr Huang Rui
2016-12-08  5:23   ` [PATCH 3/4] drm/amd/powerplay: update printk to cgs debug prints for common part Huang Rui
2016-12-08  5:23   ` [PATCH 4/4] drm/amd/powerplay: update printk to cgs debug prints for hwmgr Huang Rui
2016-12-08  8:41   ` [PATCH 0/4] drm/amd/powerplay: introduce the cgs print helpers Christian König
     [not found]     ` <9672b4c9-a905-8fef-9fa4-cd0cbe94a67b-5C7GfCeVMHo@public.gmane.org>
2016-12-08  9:02       ` Huang Rui
2016-12-08  9:27         ` Christian König
     [not found]           ` <752e5cbf-0bcb-d42f-8542-6f7a788d9299-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2016-12-08  9:50             ` Huang Rui
2016-12-08 13:04               ` Grazvydas Ignotas
     [not found]                 ` <CANOLnOOqGWKw5XdR-d=3GRrqWQ45KT_NJymWQW39kb0RtfK5Qw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-12-09  2:29                   ` Huang Rui
2016-12-22 10:52                   ` Huang Rui
2016-12-23  2:38                     ` Huang Rui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1481174591-2187-2-git-send-email-ray.huang@amd.com \
    --to=ray.huang-5c7gfcevmho@public.gmane.org \
    --cc=Arindam.Nath-5C7GfCeVMHo@public.gmane.org \
    --cc=alexander.deucher-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=christian.koenig-5C7GfCeVMHo@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.