linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* thermal: int340x: New notifications for INT340X thermal
@ 2020-09-15 22:36 Srinivas Pandruvada
  2020-09-15 22:36 ` [PATCH 1/3] thermal: int340x: Provide notification for OEM variable change Srinivas Pandruvada
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Srinivas Pandruvada @ 2020-09-15 22:36 UTC (permalink / raw)
  To: rui.zhang, daniel.lezcano, amitk
  Cc: linux-pm, linux-kernel, Srinivas Pandruvada

This series contains notifications to user space using currently
used mechanism in these drivers. 

Srinivas Pandruvada (3):
  thermal: int340x: Provide notification for OEM variable change
  thermal: core: Add new event for sending keep alive notifications
  thermal: int340x: Add keep alive response method

 .../intel/int340x_thermal/int3400_thermal.c   | 51 +++++++++++++++----
 include/linux/thermal.h                       |  1 +
 2 files changed, 41 insertions(+), 11 deletions(-)

-- 
2.25.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] thermal: int340x: Provide notification for OEM variable change
  2020-09-15 22:36 thermal: int340x: New notifications for INT340X thermal Srinivas Pandruvada
@ 2020-09-15 22:36 ` Srinivas Pandruvada
  2020-09-15 22:36 ` [PATCH 2/3] thermal: core: Add new event for sending keep alive notifications Srinivas Pandruvada
  2020-09-15 22:36 ` [PATCH 3/3] thermal: int340x: Add keep alive response method Srinivas Pandruvada
  2 siblings, 0 replies; 4+ messages in thread
From: Srinivas Pandruvada @ 2020-09-15 22:36 UTC (permalink / raw)
  To: rui.zhang, daniel.lezcano, amitk
  Cc: linux-pm, linux-kernel, Srinivas Pandruvada

When we receive ACPI notification for OEM variable change pass the
notification to user space handler. This will avoid polling for
OEM variable change from user space.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 .../intel/int340x_thermal/int3400_thermal.c   | 22 +++++++++----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
index 4f5859d4c780..2ca295e6e64d 100644
--- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
+++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
@@ -349,30 +349,30 @@ static void int3400_notify(acpi_handle handle,
 {
 	struct int3400_thermal_priv *priv = data;
 	char *thermal_prop[5];
+	int therm_event;
 
 	if (!priv)
 		return;
 
 	switch (event) {
 	case INT3400_THERMAL_TABLE_CHANGED:
-		thermal_prop[0] = kasprintf(GFP_KERNEL, "NAME=%s",
-				priv->thermal->type);
-		thermal_prop[1] = kasprintf(GFP_KERNEL, "TEMP=%d",
-				priv->thermal->temperature);
-		thermal_prop[2] = kasprintf(GFP_KERNEL, "TRIP=");
-		thermal_prop[3] = kasprintf(GFP_KERNEL, "EVENT=%d",
-				THERMAL_TABLE_CHANGED);
-		thermal_prop[4] = NULL;
-		kobject_uevent_env(&priv->thermal->device.kobj, KOBJ_CHANGE,
-				thermal_prop);
+		therm_event = THERMAL_TABLE_CHANGED;
 		break;
 	case INT3400_ODVP_CHANGED:
 		evaluate_odvp(priv);
+		therm_event = THERMAL_DEVICE_POWER_CAPABILITY_CHANGED;
 		break;
 	default:
 		/* Ignore unknown notification codes sent to INT3400 device */
-		break;
+		return;
 	}
+
+	thermal_prop[0] = kasprintf(GFP_KERNEL, "NAME=%s", priv->thermal->type);
+	thermal_prop[1] = kasprintf(GFP_KERNEL, "TEMP=%d", priv->thermal->temperature);
+	thermal_prop[2] = kasprintf(GFP_KERNEL, "TRIP=");
+	thermal_prop[3] = kasprintf(GFP_KERNEL, "EVENT=%d", therm_event);
+	thermal_prop[4] = NULL;
+	kobject_uevent_env(&priv->thermal->device.kobj, KOBJ_CHANGE, thermal_prop);
 }
 
 static int int3400_thermal_get_temp(struct thermal_zone_device *thermal,
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] thermal: core: Add new event for sending keep alive notifications
  2020-09-15 22:36 thermal: int340x: New notifications for INT340X thermal Srinivas Pandruvada
  2020-09-15 22:36 ` [PATCH 1/3] thermal: int340x: Provide notification for OEM variable change Srinivas Pandruvada
@ 2020-09-15 22:36 ` Srinivas Pandruvada
  2020-09-15 22:36 ` [PATCH 3/3] thermal: int340x: Add keep alive response method Srinivas Pandruvada
  2 siblings, 0 replies; 4+ messages in thread
From: Srinivas Pandruvada @ 2020-09-15 22:36 UTC (permalink / raw)
  To: rui.zhang, daniel.lezcano, amitk
  Cc: linux-pm, linux-kernel, Srinivas Pandruvada

This event is sent by the platform firmware to confirm that
user space thermal solution is alive. The response to this event
from the user space thermal solution is platform specific.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 include/linux/thermal.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 42ef807e5d84..42b69d4072a4 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -55,6 +55,7 @@ enum thermal_notify_event {
 	THERMAL_DEVICE_UP, /* Thermal device is up after a down event */
 	THERMAL_DEVICE_POWER_CAPABILITY_CHANGED, /* power capability changed */
 	THERMAL_TABLE_CHANGED, /* Thermal table(s) changed */
+	THERMAL_EVENT_KEEP_ALIVE, /* Request for user space handler to respond */
 };
 
 struct thermal_zone_device_ops {
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] thermal: int340x: Add keep alive response method
  2020-09-15 22:36 thermal: int340x: New notifications for INT340X thermal Srinivas Pandruvada
  2020-09-15 22:36 ` [PATCH 1/3] thermal: int340x: Provide notification for OEM variable change Srinivas Pandruvada
  2020-09-15 22:36 ` [PATCH 2/3] thermal: core: Add new event for sending keep alive notifications Srinivas Pandruvada
@ 2020-09-15 22:36 ` Srinivas Pandruvada
  2 siblings, 0 replies; 4+ messages in thread
From: Srinivas Pandruvada @ 2020-09-15 22:36 UTC (permalink / raw)
  To: rui.zhang, daniel.lezcano, amitk
  Cc: linux-pm, linux-kernel, Srinivas Pandruvada

When firmware requests keep alive response, send an event to user space
to confirm by using imok sysfs entry.

Create a new sysf entry called "imok". User space can write an integer,
which results in execution of IMOK ACPI method of INT3400 thermal zone
device. This results in sending response to firmware request for keep
alive.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
 .../intel/int340x_thermal/int3400_thermal.c   | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
index 2ca295e6e64d..0966551cbaaa 100644
--- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
+++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
@@ -14,6 +14,7 @@
 
 #define INT3400_THERMAL_TABLE_CHANGED 0x83
 #define INT3400_ODVP_CHANGED 0x88
+#define INT3400_KEEP_ALIVE 0xA0
 
 enum int3400_thermal_uuid {
 	INT3400_THERMAL_PASSIVE_1,
@@ -83,8 +84,33 @@ static struct bin_attribute *data_attributes[] = {
 	NULL,
 };
 
+static ssize_t imok_store(struct device *dev, struct device_attribute *attr,
+			  const char *buf, size_t count)
+{
+	struct int3400_thermal_priv *priv = dev_get_drvdata(dev);
+	acpi_status status;
+	int input, ret;
+
+	ret = kstrtouint(buf, 10, &input);
+	if (ret)
+		return ret;
+	status = acpi_execute_simple_method(priv->adev->handle, "IMOK", input);
+	if (ACPI_FAILURE(status))
+		return -EIO;
+
+	return count;
+}
+
+static DEVICE_ATTR_WO(imok);
+
+static struct attribute *imok_attr[] = {
+	&dev_attr_imok.attr,
+	NULL
+};
+
 static const struct attribute_group data_attribute_group = {
 	.bin_attrs = data_attributes,
+	.attrs = imok_attr,
 };
 
 static ssize_t available_uuids_show(struct device *dev,
@@ -358,6 +384,9 @@ static void int3400_notify(acpi_handle handle,
 	case INT3400_THERMAL_TABLE_CHANGED:
 		therm_event = THERMAL_TABLE_CHANGED;
 		break;
+	case INT3400_KEEP_ALIVE:
+		therm_event = THERMAL_EVENT_KEEP_ALIVE;
+		break;
 	case INT3400_ODVP_CHANGED:
 		evaluate_odvp(priv);
 		therm_event = THERMAL_DEVICE_POWER_CAPABILITY_CHANGED;
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-15 22:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-15 22:36 thermal: int340x: New notifications for INT340X thermal Srinivas Pandruvada
2020-09-15 22:36 ` [PATCH 1/3] thermal: int340x: Provide notification for OEM variable change Srinivas Pandruvada
2020-09-15 22:36 ` [PATCH 2/3] thermal: core: Add new event for sending keep alive notifications Srinivas Pandruvada
2020-09-15 22:36 ` [PATCH 3/3] thermal: int340x: Add keep alive response method Srinivas Pandruvada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).