Skip to contentSkip to conversation

PM-Trace: add pm-trace support for suspending phase

PATCH In review Fu, Zhonghui 2 participants 4 messages Feb 9, 2015 – Feb 11, 2015

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PM-Trace: add pm-trace support for suspending phase

Quoted 1 line

From ec9c0f24e800461361eaf8b280abe4272b00772d Mon Sep 17 00:00:00 2001

From: Zhonghui Fu <[email protected]>
Date: Mon, 9 Feb 2015 11:09:22 +0800
Subject: [PATCH] PM-Trace: add pm-trace support for suspending phase

Occasinally, the system can't come back up after suspend/resume due to problems of device suspending phase. This patch make PM_TRACE infrastructure cover device suspending phase of suspend/resume process, and the information in RTC can tell develpers which device suspending function make system hang.

---
 arch/x86/include/asm/resume-trace.h |    2 +-
 drivers/base/power/main.c           |   30 +++++++++++++++++++++---------
 include/linux/resume-trace.h        |    2 +-
 3 files changed, 23 insertions(+), 11 deletions(-)
arch/x86/include/asm/resume-trace.h +1 -1
index 3ff1c2c..0ca2215 100644
@@ -3,7 +3,7 @@
 
 #include <asm/asm.h>
 
-#define TRACE_RESUME(user)					\
+#define TRACE_SUSPEND_RESUME(user)				\
 do {								\
 	if (pm_trace_enabled) {					\
 		const void *tracedata;				\
drivers/base/power/main.c +21 -9
index 9717d5f..d2070b5 100644
@@ -477,7 +477,7 @@ static int device_resume_noirq(struct device *dev, pm_message_t state, bool asyn
 	int error = 0;
 
 	TRACE_DEVICE(dev);
-	TRACE_RESUME(0);
+	TRACE_SUSPEND_RESUME(0);
 
 	if (dev->power.syscore || dev->power.direct_complete)
 		goto Out;
@@ -511,7 +511,7 @@ static int device_resume_noirq(struct device *dev, pm_message_t state, bool asyn
 
  Out:
 	complete_all(&dev->power.completion);
-	TRACE_RESUME(error);
+	TRACE_SUSPEND_RESUME(error);
 	return error;
 }
 
@@ -606,7 +606,7 @@ static int device_resume_early(struct device *dev, pm_message_t state, bool asyn
 	int error = 0;
 
 	TRACE_DEVICE(dev);
-	TRACE_RESUME(0);
+	TRACE_SUSPEND_RESUME(0);
 
 	if (dev->power.syscore || dev->power.direct_complete)
 		goto Out;
@@ -639,7 +639,7 @@ static int device_resume_early(struct device *dev, pm_message_t state, bool asyn
 	dev->power.is_late_suspended = false;
 
  Out:
-	TRACE_RESUME(error);
+	TRACE_SUSPEND_RESUME(error);
 
 	pm_runtime_enable(dev);
 	complete_all(&dev->power.completion);
@@ -735,7 +735,7 @@ static int device_resume(struct device *dev, pm_message_t state, bool async)
 	DECLARE_DPM_WATCHDOG_ON_STACK(wd);
 
 	TRACE_DEVICE(dev);
-	TRACE_RESUME(0);
+	TRACE_SUSPEND_RESUME(0);
 
 	if (dev->power.syscore)
 		goto Complete;
@@ -811,7 +811,7 @@ static int device_resume(struct device *dev, pm_message_t state, bool async)
  Complete:
 	complete_all(&dev->power.completion);
 
-	TRACE_RESUME(error);
+	TRACE_SUSPEND_RESUME(error);
 
 	return error;
 }
@@ -1017,6 +1017,9 @@ static int __device_suspend_noirq(struct device *dev, pm_message_t state, bool a
 	char *info = NULL;
 	int error = 0;
 
+	TRACE_DEVICE(dev);
+	TRACE_SUSPEND_RESUME(0);
+
 	if (async_error)
 		goto Complete;
 
@@ -1057,6 +1060,7 @@ static int __device_suspend_noirq(struct device *dev, pm_message_t state, bool a
 
 Complete:
 	complete_all(&dev->power.completion);
+	TRACE_SUSPEND_RESUME(error);
 	return error;
 }
 
@@ -1078,7 +1082,7 @@ static int device_suspend_noirq(struct device *dev)
 {
 	reinit_completion(&dev->power.completion);
 
-	if (pm_async_enabled && dev->power.async_suspend) {
+	if (is_async(dev)) {
 		get_device(dev);
 		async_schedule(async_suspend_noirq, dev);
 		return 0;
@@ -1157,6 +1161,9 @@ static int __device_suspend_late(struct device *dev, pm_message_t state, bool as
 	char *info = NULL;
 	int error = 0;
 
+	TRACE_DEVICE(dev);
+	TRACE_SUSPEND_RESUME(0);
+
 	__pm_runtime_disable(dev, false);
 
 	if (async_error)
@@ -1198,6 +1205,7 @@ static int __device_suspend_late(struct device *dev, pm_message_t state, bool as
 		async_error = error;
 
 Complete:
+	TRACE_SUSPEND_RESUME(error);
 	complete_all(&dev->power.completion);
 	return error;
 }
@@ -1219,7 +1227,7 @@ static int device_suspend_late(struct device *dev)
 {
 	reinit_completion(&dev->power.completion);
 
-	if (pm_async_enabled && dev->power.async_suspend) {
+	if (is_async(dev)) {
 		get_device(dev);
 		async_schedule(async_suspend_late, dev);
 		return 0;
@@ -1338,6 +1346,9 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
 	int error = 0;
 	DECLARE_DPM_WATCHDOG_ON_STACK(wd);
 
+	TRACE_DEVICE(dev);
+	TRACE_SUSPEND_RESUME(0);
+
 	dpm_wait_for_children(dev, async);
 
 	if (async_error)
@@ -1444,6 +1455,7 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
 	if (error)
 		async_error = error;
 
+	TRACE_SUSPEND_RESUME(error);
 	return error;
 }
 
@@ -1465,7 +1477,7 @@ static int device_suspend(struct device *dev)
 {
 	reinit_completion(&dev->power.completion);
 
-	if (pm_async_enabled && dev->power.async_suspend) {
+	if (is_async(dev)) {
 		get_device(dev);
 		async_schedule(async_suspend, dev);
 		return 0;
include/linux/resume-trace.h +1 -1
index f31db23..9080f25 100644
@@ -27,7 +27,7 @@ extern int show_trace_dev_match(char *buf, size_t size);
 static inline int pm_trace_is_enabled(void) { return 0; }
 
 #define TRACE_DEVICE(dev) do { } while (0)
-#define TRACE_RESUME(dev) do { } while (0)
+#define TRACE_SUSPEND_RESUME(dev) do { } while (0)
 
 #endif
 

-- 1.7.1

#1 lore raw
Quoted 4 lines · Zhonghui
Quoted 1 line

From ec9c0f24e800461361eaf8b280abe4272b00772d Mon Sep 17 00:00:00 2001

From: Zhonghui Fu <[email protected]>
Date: Mon, 9 Feb 2015 11:09:22 +0800
Subject: [PATCH] PM-Trace: add pm-trace support for suspending phase

Why is this crud here?

Quoted 19 lines

Occasinally, the system can't come back up after suspend/resume due to problems of device suspending phase. This patch make PM_TRACE infrastructure cover device suspending phase of suspend/resume process, and the information in RTC can tell develpers which device suspending function make system hang.

---
 arch/x86/include/asm/resume-trace.h |    2 +-
 drivers/base/power/main.c           |   30 +++++++++++++++++++++---------
 include/linux/resume-trace.h        |    2 +-
 3 files changed, 23 insertions(+), 11 deletions(-)
arch/x86/include/asm/resume-trace.h +0 -0
index 3ff1c2c..0ca2215 100644

arch/x86/include/asm/resume-trace.h line 9

Quoted 8 lines
arch/x86/include/asm/resume-trace.h +1 -1
@@ -3,7 +3,7 @@
 
 #include <asm/asm.h>
 
-#define TRACE_RESUME(user)					\
+#define TRACE_SUSPEND_RESUME(user)				\
 do {								\
 	if (pm_trace_enabled) {					\
 		const void *tracedata;				\

Why rename this?

If you want to do that, do it in 2 different functions (rename first, with justification, add new functionality in a second patch)

arch/x86/include/asm/resume-trace.h static int device_suspend_noirq(struct device *dev) · line 1085

Quoted 6 lines
arch/x86/include/asm/resume-trace.h +1 -1
@@ -1078,7 +1082,7 @@ static int device_suspend_noirq(struct device *dev)
 {
 	reinit_completion(&dev->power.completion);
 
-	if (pm_async_enabled && dev->power.async_suspend) {
+	if (is_async(dev)) {

Why change this logic?

greg k-h

#2 lore raw
Quoted 6 lines · Greg Kroah-Hartman
Quoted 4 lines · Zhonghui
Quoted 1 line

From ec9c0f24e800461361eaf8b280abe4272b00772d Mon Sep 17 00:00:00 2001

From: Zhonghui Fu <[email protected]>
Date: Mon, 9 Feb 2015 11:09:22 +0800
Subject: [PATCH] PM-Trace: add pm-trace support for suspending phase

Why is this crud here?

I will fix this in new patch.

Quoted 29 lines
Quoted 19 lines

Occasinally, the system can't come back up after suspend/resume due to problems of device suspending phase. This patch make PM_TRACE infrastructure cover device suspending phase of suspend/resume process, and the information in RTC can tell develpers which device suspending function make system hang.

---
 arch/x86/include/asm/resume-trace.h |    2 +-
 drivers/base/power/main.c           |   30 +++++++++++++++++++++---------
 include/linux/resume-trace.h        |    2 +-
 3 files changed, 23 insertions(+), 11 deletions(-)
arch/x86/include/asm/resume-trace.h +0 -0
index 3ff1c2c..0ca2215 100644

arch/x86/include/asm/resume-trace.h line 9

Quoted 8 lines
arch/x86/include/asm/resume-trace.h +1 -1
@@ -3,7 +3,7 @@
 
 #include <asm/asm.h>
 
-#define TRACE_RESUME(user)					\
+#define TRACE_SUSPEND_RESUME(user)				\
 do {								\
 	if (pm_trace_enabled) {					\
 		const void *tracedata;				\

Why rename this?

Quoted 2 lines

If you want to do that, do it in 2 different functions (rename first, with justification, add new functionality in a second patch)

Good comments, I will sent a new patch.

Quoted 8 lines

arch/x86/include/asm/resume-trace.h static int device_suspend_noirq(struct device *dev) · line 1085

Quoted 7 lines
arch/x86/include/asm/resume-trace.h +1 -1
@@ -1078,7 +1082,7 @@ static int device_suspend_noirq(struct device *dev)
 {
 	reinit_completion(&dev->power.completion);
 
-	if (pm_async_enabled && dev->power.async_suspend) {
+	if (is_async(dev)) {

Why change this logic?

Now, PM Trace does not support asynchronous suspend/resume mode. is_async() function can inhibit async mode during using PM Trace.

Thanks,
Zhonghui

Quoted 7 lines

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#3 lore raw

I have sent a new patch with the same subject in another mail. Any comments are welcome.

Thanks,
Zhonghui

Quoted 56 lines · Zhonghui
Quoted 6 lines · Greg Kroah-Hartman
Quoted 4 lines · Zhonghui
Quoted 1 line

From ec9c0f24e800461361eaf8b280abe4272b00772d Mon Sep 17 00:00:00 2001

From: Zhonghui Fu <[email protected]>
Date: Mon, 9 Feb 2015 11:09:22 +0800
Subject: [PATCH] PM-Trace: add pm-trace support for suspending phase

Why is this crud here?

I will fix this in new patch.

Quoted 28 lines
Quoted 18 lines

Occasinally, the system can't come back up after suspend/resume due to problems of device suspending phase. This patch make PM_TRACE infrastructure cover device suspending phase of suspend/resume process, and the information in RTC can tell develpers which device suspending function make system hang.

---
 arch/x86/include/asm/resume-trace.h |    2 +-
 drivers/base/power/main.c           |   30 +++++++++++++++++++++---------
 include/linux/resume-trace.h        |    2 +-
 3 files changed, 23 insertions(+), 11 deletions(-)
arch/x86/include/asm/resume-trace.h +0 -0
index 3ff1c2c..0ca2215 100644

arch/x86/include/asm/resume-trace.h line 9

Quoted 8 lines
arch/x86/include/asm/resume-trace.h +1 -1
@@ -3,7 +3,7 @@
 
 #include <asm/asm.h>
 
-#define TRACE_RESUME(user)					\
+#define TRACE_SUSPEND_RESUME(user)				\
 do {								\
 	if (pm_trace_enabled) {					\
 		const void *tracedata;				\

Why rename this?

Quoted 2 lines

If you want to do that, do it in 2 different functions (rename first, with justification, add new functionality in a second patch)

Good comments, I will sent a new patch.

Quoted 7 lines

arch/x86/include/asm/resume-trace.h static int device_suspend_noirq(struct device *dev) · line 1085

Quoted 6 lines
arch/x86/include/asm/resume-trace.h +1 -1
@@ -1078,7 +1082,7 @@ static int device_suspend_noirq(struct device *dev)
 {
 	reinit_completion(&dev->power.completion);
 
-	if (pm_async_enabled && dev->power.async_suspend) {
+	if (is_async(dev)) {

Why change this logic?

Now, PM Trace does not support asynchronous suspend/resume mode. is_async() function can inhibit async mode during using PM Trace.

Thanks,
Zhonghui

Quoted 6 lines

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/