lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240809131343.1173369-1-mmaslanka@google.com>
Date: Fri,  9 Aug 2024 13:13:32 +0000
From: Marek Maslanka <mmaslanka@...gle.com>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Marek Maslanka <mmaslanka@...gle.com>, Daniel Lezcano <daniel.lezcano@...aro.org>, 
	Thomas Gleixner <tglx@...utronix.de>, Rajneesh Bhardwaj <irenic.rajneesh@...il.com>, 
	David E Box <david.e.box@...el.com>, Hans de Goede <hdegoede@...hat.com>, 
	"Ilpo Järvinen" <ilpo.jarvinen@...ux.intel.com>, platform-driver-x86@...r.kernel.org
Subject: [PATCH v4 1/2] clocksource: acpi_pm: Add external callback for suspend/resume

Provides the capability to register an external callback for the ACPI PM
timer, which is called during the suspend and resume processes.

Signed-off-by: Marek Maslanka <mmaslanka@...gle.com>

---
Changes in v4:
- No changes as this was introduced as a separated patch after the v3
  review.
- Link to v3: https://lore.kernel.org/lkml/20240730120546.1042515-1-mmaslanka@google.com/
---
---
 drivers/clocksource/acpi_pm.c | 27 +++++++++++++++++++++++++++
 drivers/clocksource/acpi_pm.h | 16 ++++++++++++++++
 2 files changed, 43 insertions(+)
 create mode 100644 drivers/clocksource/acpi_pm.h

diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c
index 82338773602ca..c629f5462bc0f 100644
--- a/drivers/clocksource/acpi_pm.c
+++ b/drivers/clocksource/acpi_pm.c
@@ -25,6 +25,12 @@
 #include <asm/io.h>
 #include <asm/time.h>
 
+#include "acpi_pm.h"
+
+static void *suspend_resume_cb_data;
+
+static void (*suspend_resume_callback)(void *data, bool suspend);
+
 /*
  * The I/O port the PMTMR resides at.
  * The location is detected during setup_arch(),
@@ -58,6 +64,25 @@ u32 acpi_pm_read_verified(void)
 	return v2;
 }
 
+void acpi_pm_register_suspend_resume_callback(void (*cb)(void *data, bool suspend),
+					      void *data)
+{
+	suspend_resume_callback = cb;
+	suspend_resume_cb_data = data;
+}
+
+static void acpi_pm_suspend(struct clocksource *cs)
+{
+	if (suspend_resume_callback)
+		suspend_resume_callback(suspend_resume_cb_data, true);
+}
+
+static void acpi_pm_resume(struct clocksource *cs)
+{
+	if (suspend_resume_callback)
+		suspend_resume_callback(suspend_resume_cb_data, false);
+}
+
 static u64 acpi_pm_read(struct clocksource *cs)
 {
 	return (u64)read_pmtmr();
@@ -69,6 +94,8 @@ static struct clocksource clocksource_acpi_pm = {
 	.read		= acpi_pm_read,
 	.mask		= (u64)ACPI_PM_MASK,
 	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,
+	.suspend	= acpi_pm_suspend,
+	.resume		= acpi_pm_resume,
 };
 
 
diff --git a/drivers/clocksource/acpi_pm.h b/drivers/clocksource/acpi_pm.h
new file mode 100644
index 0000000000000..c932899f04282
--- /dev/null
+++ b/drivers/clocksource/acpi_pm.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ACPI_PM_H__
+#define __ACPI_PM_H__
+
+#include <linux/types.h>
+
+/**
+ * Register callback for suspend and resume event
+ *
+ * @cb Callback triggered on suspend and resume
+ * @data Data passed with the callback
+ */
+void acpi_pm_register_suspend_resume_callback(void (*cb)(void *data, bool suspend),
+					      void *data);
+
+#endif
-- 
2.46.0.76.ge559c4bf1a-goog


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ