Skip to contentSkip to conversation

tpm: ibmvtpm: Fix unused suspend callback with CONFIG_PM_SLEEP=n

PATCH Superseded Zhouyi Zhou 2 participants 3 messages Nov 27

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm: ibmvtpm: Fix unused suspend callback with CONFIG_PM_SLEEP=n

Discovered in the Open Source Lab of Oregon State University when running RCU torture.sh on a ppc64le VM.

With CONFIG_TCG_IBMVTPM=y and CONFIG_PM_SLEEP disabled, SIMPLE_DEV_PM_OPS() omits the references to the system sleep callbacks. This leaves tpm_ibmvtpm_suspend() unused and produces the following warning:

warning: 'tpm_ibmvtpm_suspend' defined but not used [-Wunused-function]

Use DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() so that the compiler sees the callback references and can discard the unused PM code when system sleep is disabled. Preserve tpm_ibmvtpm_resume(), which is also called directly from tpm_ibmvtpm_send().

Tested on PPC VM of the Open Source Lab
of Oregon State University.

Fixes fc0ddb3174b0 ("char: tpm: Use SIMPLE_DEV_PM_OPS for ibmvtpm power management")
---
 drivers/char/tpm/tpm_ibmvtpm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm_ibmvtpm.c +3 -2
index 51c7e2add3d2..9840d0ebe6a3 100644
@@ -462,7 +462,8 @@ static const struct tpm_class_ops tpm_ibmvtpm = {
 	.req_canceled = tpm_ibmvtpm_req_canceled,
 };
 
-static SIMPLE_DEV_PM_OPS(tpm_ibmvtpm_pm_ops, tpm_ibmvtpm_suspend, tpm_ibmvtpm_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(tpm_ibmvtpm_pm_ops,
+				tpm_ibmvtpm_suspend, tpm_ibmvtpm_resume);
 
 /**
  * ibmvtpm_crq_get_next - Get next responded crq
@@ -714,7 +715,7 @@ static struct vio_driver ibmvtpm_driver = {
 	.remove		 = tpm_ibmvtpm_remove,
 	.get_desired_dma = tpm_ibmvtpm_get_desired_dma,
 	.name		 = tpm_ibmvtpm_driver_name,
-	.pm		 = &tpm_ibmvtpm_pm_ops,
+	.pm		 = pm_sleep_ptr(&tpm_ibmvtpm_pm_ops),
 };
 
 /**

base-commit: 5f22fb20497f4983094131f00a734362300d22d2

maintainer
#1 lore raw
Quoted 14 lines · Zhouyi Zhou

Discovered in the Open Source Lab of Oregon State University when running RCU torture.sh on a ppc64le VM.

With CONFIG_TCG_IBMVTPM=y and CONFIG_PM_SLEEP disabled, SIMPLE_DEV_PM_OPS() omits the references to the system sleep callbacks. This leaves tpm_ibmvtpm_suspend() unused and produces the following warning:

warning: 'tpm_ibmvtpm_suspend' defined but not used [-Wunused-function]

Use DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() so that the compiler sees the callback references and can discard the unused PM code when system sleep is disabled. Preserve tpm_ibmvtpm_resume(), which is also called directly from tpm_ibmvtpm_send().

Quoted 5 lines

Tested on PPC VM of the Open Source Lab
of Oregon State University.

Fixes fc0ddb3174b0 ("char: tpm: Use SIMPLE_DEV_PM_OPS for ibmvtpm power management")

nit: should not have empty line here.

Quoted 10 lines
---
 drivers/char/tpm/tpm_ibmvtpm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm_ibmvtpm.c +0 -0
index 51c7e2add3d2..9840d0ebe6a3 100644

drivers/char/tpm/tpm_ibmvtpm.c static const struct tpm_class_ops tpm_ibmvtpm = { · line 466

Quoted 6 lines
drivers/char/tpm/tpm_ibmvtpm.c +2 -1
@@ -462,7 +462,8 @@ static const struct tpm_class_ops tpm_ibmvtpm = {
 	.req_canceled = tpm_ibmvtpm_req_canceled,
 };
 
-static SIMPLE_DEV_PM_OPS(tpm_ibmvtpm_pm_ops, tpm_ibmvtpm_suspend, tpm_ibmvtpm_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(tpm_ibmvtpm_pm_ops,
+				tpm_ibmvtpm_suspend, tpm_ibmvtpm_resume);

I'd keep these in same line.

Quoted 13 lines
drivers/char/tpm/tpm_ibmvtpm.c +1 -1
 /**
  * ibmvtpm_crq_get_next - Get next responded crq
@@ -714,7 +715,7 @@ static struct vio_driver ibmvtpm_driver = {
 	.remove		 = tpm_ibmvtpm_remove,
 	.get_desired_dma = tpm_ibmvtpm_get_desired_dma,
 	.name		 = tpm_ibmvtpm_driver_name,
-	.pm		 = &tpm_ibmvtpm_pm_ops,
+	.pm		 = pm_sleep_ptr(&tpm_ibmvtpm_pm_ops),
 };
 
 /**
Quoted 1 line

base-commit: 5f22fb20497f4983094131f00a734362300d22d2

Otherwise, it's good.

Br, Jarkko

#2 lore raw

Thank Jarkko for your review

I will prepare a 2nd version of patch

Thanks
Zhouyi

Quoted 65 lines · Jarkko Sakkinen
Quoted 4 lines · Zhouyi Zhou

Discovered in the Open Source Lab of Oregon State University when running RCU torture.sh on a ppc64le VM.

With CONFIG_TCG_IBMVTPM=y and CONFIG_PM_SLEEP disabled,

SIMPLE_DEV_PM_OPS()

Quoted 10 lines

omits the references to the system sleep callbacks. This leaves tpm_ibmvtpm_suspend() unused and produces the following warning:

warning: 'tpm_ibmvtpm_suspend' defined but not used [-Wunused-function]

Use DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() so that the compiler sees the callback references and can discard the unused PM code when system sleep is disabled. Preserve tpm_ibmvtpm_resume(), which is also called directly from tpm_ibmvtpm_send().

Quoted 4 lines

Tested on PPC VM of the Open Source Lab
of Oregon State University.

Fixes fc0ddb3174b0 ("char: tpm: Use SIMPLE_DEV_PM_OPS for ibmvtpm power

management")

Quoted 1 line

nit: should not have empty line here.

Review

Quoted 6 lines
---
 drivers/char/tpm/tpm_ibmvtpm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/char/tpm/tpm_ibmvtpm.c

drivers/char/tpm/tpm_ibmvtpm.c static const struct tpm_class_ops tpm_ibmvtpm = { · line 465

Quoted 8 lines

index 51c7e2add3d2..9840d0ebe6a3 100644

drivers/char/tpm/tpm_ibmvtpm.c +0 -1
@@ -462,7 +462,8 @@ static const struct tpm_class_ops tpm_ibmvtpm = {
      .req_canceled = tpm_ibmvtpm_req_canceled,
 };
 
-static SIMPLE_DEV_PM_OPS(tpm_ibmvtpm_pm_ops, tpm_ibmvtpm_suspend,

tpm_ibmvtpm_resume);

drivers/char/tpm/tpm_ibmvtpm.c static const struct tpm_class_ops tpm_ibmvtpm = { · line 466

Quoted 2 lines
drivers/char/tpm/tpm_ibmvtpm.c +2 -0
+static DEFINE_SIMPLE_DEV_PM_OPS(tpm_ibmvtpm_pm_ops,
+                             tpm_ibmvtpm_suspend, tpm_ibmvtpm_resume);

I'd keep these in same line.

Quoted 13 lines
drivers/char/tpm/tpm_ibmvtpm.c +1 -1
 /**
  * ibmvtpm_crq_get_next - Get next responded crq
@@ -714,7 +715,7 @@ static struct vio_driver ibmvtpm_driver = {
      .remove          = tpm_ibmvtpm_remove,
      .get_desired_dma = tpm_ibmvtpm_get_desired_dma,
      .name            = tpm_ibmvtpm_driver_name,
-     .pm              = &tpm_ibmvtpm_pm_ops,
+     .pm              = pm_sleep_ptr(&tpm_ibmvtpm_pm_ops),
 };
 
 /**
Quoted 1 line

base-commit: 5f22fb20497f4983094131f00a734362300d22d2

Otherwise, it's good.

Br, Jarkko