thermal/int340x_thermal: Export GDDV
PATCH v2 1/3 thermal/int340x_thermal: Export GDDV
From: Matthew Garrett <[email protected]>
Implementing DPTF properly requires making use of firmware-provided information associated with the INT3400 device. Calling GDDV provides a buffer of information which userland can then interpret to determine appropriate DPTF policy.
--- .../intel/int340x_thermal/int3400_thermal.c | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+)
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +60 -0
@@ -52,6 +52,25 @@ struct int3400_thermal_priv {u8 uuid_bitmap;int rel_misc_dev_res;int current_uuid_index; +char *data_vault; +}; + +static ssize_t data_vault_read (struct file *file,struct kobject *kobj, +struct bin_attribute *attr,char *buf,loff_t off,size_t count) +{ +memcpy (buf, attr->private + off, count); +return count; +} + +static BIN_ATTR_RO(data_vault, 0); + +static struct bin_attribute *data_attributes[] = { + &bin_attr_data_vault, +NULL , +}; + +static const struct attribute_group data_attribute_group = { + .bin_attrs = data_attributes, }; static ssize_t available_uuids_show(struct device *dev,
@@ -278,6 +297,32 @@ static struct thermal_zone_params int3400_thermal_params = { .no_hwmon = true, }; +static void int3400_setup_gddv (struct int3400_thermal_priv *priv) +{ +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *obj; +acpi_status status; + + status =acpi_evaluate_object (priv->adev->handle,"GDDV" ,NULL , + &buffer); +if (ACPI_FAILURE (status) || !buffer.length) +return ; + + obj = buffer.pointer; +if (obj->type !=ACPI_TYPE_PACKAGE || obj->package.count !=1 + || obj->package.elements[0 ].type !=ACPI_TYPE_BUFFER ) { +kfree (buffer.pointer); +return ; + } + + priv->data_vault =kmemdup (obj->package.elements[0 ].buffer.pointer, + obj->package.elements[0 ].buffer.length, +GFP_KERNEL ); + bin_attr_data_vault.private = priv->data_vault; + bin_attr_data_vault.size = obj->package.elements[0 ].buffer.length; +kfree (buffer.pointer); +} +static int int3400_thermal_probe (struct platform_device *pdev) {struct acpi_device *adev =ACPI_COMPANION (&pdev->dev);
@@ -309,6 +354,8 @@ static int int3400_thermal_probe(struct platform_device *pdev)platform_set_drvdata (pdev, priv); +int3400_setup_gddv (priv); + int3400_thermal_ops.get_mode = int3400_thermal_get_mode; int3400_thermal_ops.set_mode = int3400_thermal_set_mode;
@@ -327,6 +374,13 @@ static int int3400_thermal_probe(struct platform_device *pdev)if (result) goto free_rel_misc; +if (priv->data_vault) { + result =sysfs_create_group (&pdev->dev.kobj, + &data_attribute_group); +if (result) + goto free_uuid; + } + result =acpi_install_notify_handler ( priv->adev->handle,ACPI_DEVICE_NOTIFY , int3400_notify, (void *)priv);
@@ -336,6 +390,9 @@ static int int3400_thermal_probe(struct platform_device *pdev)return 0 ; free_sysfs: +if (priv->data_vault) +sysfs_remove_group (&pdev->dev.kobj, &data_attribute_group); +free_uuid:sysfs_remove_group (&pdev->dev.kobj, &uuid_attribute_group); free_rel_misc:if (!priv->rel_misc_dev_res)
@@ -360,8 +417,11 @@ static int int3400_thermal_remove(struct platform_device *pdev)if (!priv->rel_misc_dev_res)acpi_thermal_rel_misc_device_remove (priv->adev->handle); +if (priv->data_vault) +sysfs_remove_group (&pdev->dev.kobj, &data_attribute_group);sysfs_remove_group (&pdev->dev.kobj, &uuid_attribute_group);thermal_zone_device_unregister (priv->thermal); +kfree (priv->data_vault);kfree (priv->trts);kfree (priv->arts);kfree (priv);
Signature · 1 line
2.26.0.110.g2183baf09c-goog
PATCH v2 2/3 thermal/int340x_thermal: Export OEM vendor variables
From: Matthew Garrett <[email protected]>
The platform vendor may expose an array of OEM-specific values to be used in determining DPTF policy. These are obtained via the ODVP method, and then simply exposed in sysfs. In addition, they are updated when a notification is received or when the DPTF policy is changed by userland.
--- .../intel/int340x_thermal/int3400_thermal.c | 132 +++++++++++++++++- 1 file changed, 131 insertions(+), 1 deletion(-)
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +131 -1
@@ -13,6 +13,7 @@#include "acpi_thermal_rel.h" #define INT3400_THERMAL_TABLE_CHANGED 0x83 +#define INT3400_ODVP_CHANGED 0x88enum int3400_thermal_uuid {INT3400_THERMAL_PASSIVE_1 ,
@@ -41,8 +42,11 @@ static char *int3400_thermal_uuids[INT3400_THERMAL_MAXIMUM_UUID] = { "BE84BABF-C4D4-403D-B495-3128FD44dAC1", }; +struct odvp_attr ; +struct int3400_thermal_priv {struct acpi_device *adev; +struct platform_device *pdev;struct thermal_zone_device *thermal;int mode;int art_count;
@@ -53,6 +57,17 @@ struct int3400_thermal_priv {int rel_misc_dev_res;int current_uuid_index;char *data_vault; +int odvp_count; +int *odvp; +struct odvp_attr *odvp_attrs; +}; + +static int evaluate_odvp (struct int3400_thermal_priv *priv); + +struct odvp_attr { +int odvp; +struct int3400_thermal_priv *priv; +struct kobj_attribute attr; }; static ssize_t data_vault_read(struct file *file, struct kobject *kobj,
@@ -210,9 +225,110 @@ static int int3400_thermal_run_osc(acpi_handle handle, result = -EPERM ;kfree (context.ret.pointer); +return result; } +static ssize_t odvp_show (struct kobject *kobj,struct kobj_attribute *attr, +char *buf) +{ +struct odvp_attr *odvp_attr; + + odvp_attr = container_of(attr, struct odvp_attr, attr); + +return sprintf (buf,"%d\n" , odvp_attr->priv->odvp[odvp_attr->odvp]); +} + +static void cleanup_odvp (struct int3400_thermal_priv *priv) +{ +int i; + +if (priv->odvp_attrs) { +for (i =0 ; i < priv->odvp_count; i++) { +sysfs_remove_file (&priv->pdev->dev.kobj, + &priv->odvp_attrs[i].attr.attr); +kfree (priv->odvp_attrs[i].attr.attr.name); + } +kfree (priv->odvp_attrs); + } +kfree (priv->odvp); + priv->odvp_count =0 ; +} + +static int evaluate_odvp (struct int3400_thermal_priv *priv) +{ +struct acpi_buffer odvp = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *obj =NULL ; +acpi_status status; +int i, ret; + + status =acpi_evaluate_object (priv->adev->handle,"ODVP" ,NULL , &odvp); +if (ACPI_FAILURE (status)) { + ret = -EINVAL ; + goto out_err; + } + + obj = odvp.pointer; +if (obj->type !=ACPI_TYPE_PACKAGE ) { + ret = -EINVAL ; + goto out_err; + } + +if (priv->odvp ==NULL ) { + priv->odvp_count = obj->package.count; + priv->odvp =kmalloc_array (priv->odvp_count,sizeof (int ), +GFP_KERNEL ); +if (!priv->odvp) { + ret = -ENOMEM ; + goto out_err; + } + } + +if (priv->odvp_attrs ==NULL ) { + priv->odvp_attrs =kcalloc (priv->odvp_count, +sizeof (struct odvp_attr ), +GFP_KERNEL ); +if (!priv->odvp_attrs) { + ret = -ENOMEM ; + goto out_err; + } +for (i =0 ; i < priv->odvp_count; i++) { +struct odvp_attr *odvp = &priv->odvp_attrs[i]; + +sysfs_attr_init (&odvp->attr.attr); + odvp->priv = priv; + odvp->odvp = i; + odvp->attr.attr.name =kasprintf (GFP_KERNEL , +"odvp%d" , i); + +if (!odvp->attr.attr.name) { + ret = -ENOMEM ; + goto out_err; + } + odvp->attr.attr.mode =0444 ; + odvp->attr.show = odvp_show; + odvp->attr.store =NULL ; + ret =sysfs_create_file (&priv->pdev->dev.kobj, + &odvp->attr.attr); +if (ret) + goto out_err; + } + } + +for (i =0 ; i < obj->package.count; i++) { +if (obj->package.elements[i].type ==ACPI_TYPE_INTEGER ) + priv->odvp[i] = obj->package.elements[i].integer.value; + } + +kfree (obj); +return 0 ; + +out_err: +cleanup_odvp (priv); +kfree (obj); +return ret; +} +static void int3400_notify (acpi_handle handle,u32 event,void *data)
@@ -236,6 +352,9 @@ static void int3400_notify(acpi_handle handle,kobject_uevent_env (&priv->thermal->device.kobj,KOBJ_CHANGE , thermal_prop);break ; +case INT3400_ODVP_CHANGED : +evaluate_odvp (priv); +break ;default :/* Ignore unknown notification codes sent to INT3400 device */ break ;
@@ -285,6 +404,9 @@ static int int3400_thermal_set_mode(struct thermal_zone_device *thermal, priv->current_uuid_index, enable); } + +evaluate_odvp (priv); +return result; }
@@ -336,6 +458,7 @@ static int int3400_thermal_probe(struct platform_device *pdev)if (!priv)return -ENOMEM ; + priv->pdev = pdev; priv->adev = adev; result =int3400_thermal_get_uuids (priv);
@@ -356,6 +479,8 @@ static int int3400_thermal_probe(struct platform_device *pdev)int3400_setup_gddv (priv); +evaluate_odvp (priv); + int3400_thermal_ops.get_mode = int3400_thermal_get_mode; int3400_thermal_ops.set_mode = int3400_thermal_set_mode;
@@ -390,8 +515,11 @@ static int int3400_thermal_probe(struct platform_device *pdev)return 0 ; free_sysfs: -if (priv->data_vault) +cleanup_odvp (priv); +if (priv->data_vault) {sysfs_remove_group (&pdev->dev.kobj, &data_attribute_group); +kfree (priv->data_vault); + } free_uuid:sysfs_remove_group (&pdev->dev.kobj, &uuid_attribute_group); free_rel_misc:
@@ -414,6 +542,8 @@ static int int3400_thermal_remove(struct platform_device *pdev) priv->adev->handle,ACPI_DEVICE_NOTIFY , int3400_notify); +cleanup_odvp (priv); +if (!priv->rel_misc_dev_res)acpi_thermal_rel_misc_device_remove (priv->adev->handle);
Signature · 1 line
2.26.0.110.g2183baf09c-goog
Re: [PATCH V2 2/3] thermal/int340x_thermal: Export OEM vendor variables
Quoted 11 lines · Matthew Garrett
From: Matthew Garrett <[email protected]>
The platform vendor may expose an array of OEM-specific values to be used
in determining DPTF policy. These are obtained via the ODVP method, and
then simply exposed in sysfs. In addition, they are updated when a notification is received or when the DPTF policy is changed by userland.Signed-off-by Matthew Garrett <[email protected]>
Quoted 237 lines
--- .../intel/int340x_thermal/int3400_thermal.c | 132 +++++++++++++++++- 1 file changed, 131 insertions(+), 1 deletion(-)drivers/thermal/intel/int340x_thermal/int3400_thermal.c +4
-0@@ -13,6 +13,7 @@#include "acpi_thermal_rel.h" #define INT3400_THERMAL_TABLE_CHANGED 0x83 +#define INT3400_ODVP_CHANGED 0x88enum int3400_thermal_uuid {INT3400_THERMAL_PASSIVE_1 ,@@ -41,8 +42,11 @@ static char *int3400_thermal_uuids[INT3400_THERMAL_MAXIMUM_UUID] = { "BE84BABF-C4D4-403D-B495-3128FD44dAC1", }; +struct odvp_attr ; +struct int3400_thermal_priv {struct acpi_device *adev; +struct platform_device *pdev;struct thermal_zone_device *thermal;int mode;drivers/thermal/intel/int340x_thermal/int3400_thermal.c +11
-0int art_count;@@ -53,6 +57,17 @@ struct int3400_thermal_priv {int rel_misc_dev_res;int current_uuid_index;char *data_vault; +int odvp_count; +int *odvp; +struct odvp_attr *odvp_attrs; +}; + +static int evaluate_odvp (struct int3400_thermal_priv *priv); + +struct odvp_attr { +int odvp; +struct int3400_thermal_priv *priv; +struct kobj_attribute attr; }; static ssize_t data_vault_read(struct file *file, struct kobject*kobj,
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +19
-0@@ -210,9 +225,110 @@ static int int3400_thermal_run_osc(acpi_handle handle, result = -EPERM ;kfree (context.ret.pointer); +return result; } +static ssize_t odvp_show (struct kobject *kobj,struct kobj_attribute *attr, +char *buf) +{ +struct odvp_attr *odvp_attr; + + odvp_attr = container_of(attr, struct odvp_attr, attr); + +return sprintf (buf,"%d\n" , odvp_attr->priv->odvp[odvp_attr- >odvp]); +} + +static void cleanup_odvp (struct int3400_thermal_priv *priv) +{ +int i; + +if (priv->odvp_attrs) { +for (i =0 ; i < priv->odvp_count; i++) { + sysfs_remove_file(&priv->pdev->dev.kobj, + &priv-Quoted 1 line
odvp_attrs[i].attr.attr);
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +16
-0+kfree (priv->odvp_attrs[i].attr.attr.name); + } +kfree (priv->odvp_attrs); + } +kfree (priv->odvp); + priv->odvp_count =0 ; +} + +static int evaluate_odvp (struct int3400_thermal_priv *priv) +{ +struct acpi_buffer odvp = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *obj =NULL ; +acpi_status status; +int i, ret; + + status = acpi_evaluate_object(priv->adev->handle, "ODVP", NULL,&odvp);
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +14
-0+if (ACPI_FAILURE (status)) { + ret = -EINVAL ; + goto out_err; + } + + obj = odvp.pointer; +if (obj->type !=ACPI_TYPE_PACKAGE ) { + ret = -EINVAL ; + goto out_err; + } + +if (priv->odvp ==NULL ) { + priv->odvp_count = obj->package.count; + priv->odvp = kmalloc_array(priv->odvp_count,sizeof(int),
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +41
-0+ GFP_KERNEL); +if (!priv->odvp) { + ret = -ENOMEM ; + goto out_err; + } + } + +if (priv->odvp_attrs ==NULL ) { + priv->odvp_attrs =kcalloc (priv->odvp_count, +sizeof (struct odvp_attr ), +GFP_KERNEL ); +if (!priv->odvp_attrs) { + ret = -ENOMEM ; + goto out_err; + } +for (i =0 ; i < priv->odvp_count; i++) { +struct odvp_attr *odvp = &priv->odvp_attrs[i]; + +sysfs_attr_init (&odvp->attr.attr); + odvp->priv = priv; + odvp->odvp = i; + odvp->attr.attr.name =kasprintf (GFP_KERNEL , +"odvp%d" , i); + +if (!odvp->attr.attr.name) { + ret = -ENOMEM ; + goto out_err; + } + odvp->attr.attr.mode =0444 ; + odvp->attr.show = odvp_show; + odvp->attr.store =NULL ; + ret =sysfs_create_file (&priv->pdev->dev.kobj, + &odvp->attr.attr); +if (ret) + goto out_err; + } + } + +for (i =0 ; i < obj->package.count; i++) { +if (obj->package.elements[i].type ==ACPI_TYPE_INTEGER ) + priv->odvp[i] = obj-Quoted 1 line
package.elements[i].integer.value;
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +14
-0+ } + +kfree (obj); +return 0 ; + +out_err: +cleanup_odvp (priv); +kfree (obj); +return ret; +} +static void int3400_notify (acpi_handle handle,u32 event,void *data)@@ -236,6 +352,9 @@ static void int3400_notify(acpi_handle handle,kobject_uevent_env (&priv->thermal->device.kobj,KOBJ_CHANGE , thermal_prop);break ; +case INT3400_ODVP_CHANGED : +evaluate_odvp (priv); +break ;default :/* Ignore unknown notification codes sent to INT3400 device */
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +3
-0break ;@@ -285,6 +404,9 @@ static int int3400_thermal_set_mode(struct thermal_zone_device *thermal, priv- >current_uuid_index, enable); } + +evaluate_odvp (priv); +return result;}
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +1
-0@@ -336,6 +458,7 @@ static int int3400_thermal_probe(struct platform_device *pdev)if (!priv)return -ENOMEM ; + priv->pdev = pdev; priv->adev = adev;drivers/thermal/intel/int340x_thermal/int3400_thermal.c +6
-1result =int3400_thermal_get_uuids (priv);@@ -356,6 +479,8 @@ static int int3400_thermal_probe(struct platform_device *pdev)int3400_setup_gddv (priv ); +evaluate_odvp (priv); + int3400_thermal_ops.get_mode = int3400_thermal_get_mode; int3400_thermal_ops.set_mode = int3400_thermal_set_mode;@@ -390,8 +515,11 @@ static int int3400_thermal_probe(struct platform_device *pdev)return 0 ; free_sysfs: -if (priv->data_vault) +cleanup_odvp (priv); +if (priv->data_vault) {sysfs_remove_group (&pdev->dev.kobj, &data_attribute_group); +kfree (priv->data_vault); + } free_uuid:drivers/thermal/intel/int340x_thermal/int3400_thermal.c +2
-0sysfs_remove_group (&pdev->dev.kobj, &uuid_attribute_group); free_rel_misc:@@ -414,6 +542,8 @@ static int int3400_thermal_remove(struct platform_device *pdev) priv->adev->handle, ACPI_DEVICE_NOTIFY, int3400_notify); +cleanup_odvp (priv); +if (!priv->rel_misc_dev_res) acpi_thermal_rel_misc_device_remove(priv->adev-Quoted 1 line
handle);
PATCH v2 3/3 thermal/int340x_thermal: Don't require IDSP to exist
In reply to Matthew GarrettFrom: Matthew Garrett <[email protected]>
The IDSP method doesn't appear to exist on the most recent Intel platforms:
instead, the IDSP data is included in the GDDV blob. Since we probably don't want to decompress and parse that in-kernel, just allow any UUID to be written if IDSP is missing.
--- .../intel/int340x_thermal/int3400_thermal.c | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-)
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +22 -8
@@ -96,6 +96,9 @@ static ssize_t available_uuids_show(struct device *dev,int i;int length =0 ; +if (!priv->uuid_bitmap) +return sprintf (buf,"UNKNOWN\n" ); +for (i =0 ; i <INT3400_THERMAL_MAXIMUM_UUID ; i++) {if (priv->uuid_bitmap & (1 << i))if (PAGE_SIZE - length >0 )
@@ -113,11 +116,11 @@ static ssize_t current_uuid_show(struct device *dev, {struct int3400_thermal_priv *priv =dev_get_drvdata (dev); -if (priv->uuid_bitmap & (1 << priv->current_uuid_index)) -return sprintf (buf,"%s\n" , - int3400_thermal_uuids[priv->current_uuid_index]); -else +if (priv->current_uuid_index ==-1 )return sprintf (buf,"INVALID\n" ); + +return sprintf (buf,"%s\n" , + int3400_thermal_uuids[priv->current_uuid_index]); } static ssize_t current_uuid_store(struct device *dev,
@@ -128,9 +131,16 @@ static ssize_t current_uuid_store(struct device *dev,int i;for (i =0 ; i <INT3400_THERMAL_MAXIMUM_UUID ; ++i) { -if ((priv->uuid_bitmap & (1 << i)) && - !(strncmp (buf, int3400_thermal_uuids[i], -sizeof (int3400_thermal_uuids[i]) -1 ))) { +if (!strncmp (buf, int3400_thermal_uuids[i], +sizeof (int3400_thermal_uuids[i]) -1 )) { +/* +* If we have a list of supported UUIDs, make sure +* this one is supported. +*/ +if (priv->uuid_bitmap && + !(priv->uuid_bitmap & (1 << i))) +return -EINVAL ; + priv->current_uuid_index = i;return count; }
@@ -462,9 +472,13 @@ static int int3400_thermal_probe(struct platform_device *pdev) priv->adev = adev; result =int3400_thermal_get_uuids (priv); -if (result) + +/* Missing IDSP isn't fatal */ +if (result && result != -ENODEV ) goto free_priv; + priv->current_uuid_index =-1 ; + result =acpi_parse_art (priv->adev->handle, &priv->art_count, &priv->arts, true);if (result)
Signature · 1 line
2.26.0.110.g2183baf09c-goog
Re: [PATCH V2 3/3] thermal/int340x_thermal: Don't require IDSP to exist
Quoted 11 lines · Matthew Garrett
From: Matthew Garrett <[email protected]>
The IDSP method doesn't appear to exist on the most recent Intel platforms:
instead, the IDSP data is included in the GDDV blob. Since we probably don't
want to decompress and parse that in-kernel, just allow any UUID to be
written if IDSP is missing.Signed-off-by Matthew Garrett <[email protected]>
Quoted 78 lines
--- .../intel/int340x_thermal/int3400_thermal.c | 30 ++++++++++++++--- -- 1 file changed, 22 insertions(+), 8 deletions(-)drivers/thermal/intel/int340x_thermal/int3400_thermal.c +3
-0@@ -96,6 +96,9 @@ static ssize_t available_uuids_show(struct device *dev, int i;int length =0 ; +if (!priv->uuid_bitmap) +return sprintf (buf,"UNKNOWN\n" ); +for (i =0 ; i <INT3400_THERMAL_MAXIMUM_UUID ; i++) {if (priv->uuid_bitmap & (1 << i))drivers/thermal/intel/int340x_thermal/int3400_thermal.c +4
-4if (PAGE_SIZE - length >0 )@@ -113,11 +116,11 @@ static ssize_t current_uuid_show(struct device *dev, {struct int3400_thermal_priv *priv =dev_get_drvdata (dev); -if (priv->uuid_bitmap & (1 << priv->current_uuid_index)) -return sprintf (buf,"%s\n" , - int3400_thermal_uuids[priv- >current_uuid_index]); -else +if (priv->current_uuid_index ==-1 )return sprintf (buf,"INVALID\n" ); + +return sprintf (buf,"%s\n" , + int3400_thermal_uuids[priv- >current_uuid_index]);}
static
ssize_tcurrent_uuid_store(struct device *dev,drivers/thermal/intel/int340x_thermal/int3400_thermal.c +4
-3@@ -128,9 +131,16 @@ static ssize_t current_uuid_store(struct device *dev, int i;for (i =0 ; i <INT3400_THERMAL_MAXIMUM_UUID ; ++i) { -if ((priv->uuid_bitmap & (1 << i)) && - !(strncmp (buf, int3400_thermal_uuids[i], -sizeof (int3400_thermal_uuids[i]) -1 ))) { +if (!strncmp (buf, int3400_thermal_uuids[i], +sizeof (int3400_thermal_uuids[i]) -1 )) { +/* +* If we have a list of supported UUIDs, make sure
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +11
-1+* this one is supported. +*/ +if (priv->uuid_bitmap && + !(priv->uuid_bitmap & (1 << i))) +return -EINVAL ; + priv->current_uuid_index = i;return count; }@@ -462,9 +472,13 @@ static int int3400_thermal_probe(struct platform_device *pdev) priv->adev = adev; result =int3400_thermal_get_uuids (priv); -if (result) + +/* Missing IDSP isn't fatal */ +if (result && result != -ENODEV ) goto free_priv; + priv->current_uuid_index =-1 ; + result =acpi_parse_art (priv->adev->handle, &priv->art_count, &priv->arts, true);if (result)
Quoted 8 lines · Matthew Garrett
From: Matthew Garrett <[email protected]>
Implementing DPTF properly requires making use of firmware-provided information associated with the INT3400 device. Calling GDDV provides a
buffer of information which userland can then interpret to determine appropriate DPTF policy.
Anything changed in v2 series?
Thanks,
Srinivas
Quoted 129 lines
Signed-off-by Matthew Garrett <[email protected]>--- .../intel/int340x_thermal/int3400_thermal.c | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+)drivers/thermal/intel/int340x_thermal/int3400_thermal.c +19
-0@@ -52,6 +52,25 @@ struct int3400_thermal_priv {u8 uuid_bitmap;int rel_misc_dev_res;int current_uuid_index; +char *data_vault; +}; + +static ssize_t data_vault_read (struct file *file,struct kobject *kobj, +struct bin_attribute *attr,char *buf,loff_t off,size_t count) +{ +memcpy (buf, attr->private + off, count); +return count; +} + +static BIN_ATTR_RO(data_vault, 0); + +static struct bin_attribute *data_attributes[] = { + &bin_attr_data_vault, +NULL , +}; + +static const struct attribute_group data_attribute_group = { + .bin_attrs = data_attributes, };static
ssize_tavailable_uuids_show(struct device *dev,drivers/thermal/intel/int340x_thermal/int3400_thermal.c +23
-0@@ -278,6 +297,32 @@ static struct thermal_zone_params int3400_thermal_params = { .no_hwmon = true, }; +static void int3400_setup_gddv (struct int3400_thermal_priv *priv) +{ +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *obj; +acpi_status status; + + status =acpi_evaluate_object (priv->adev->handle,"GDDV" ,NULL , + &buffer); +if (ACPI_FAILURE (status) || !buffer.length) +return ; + + obj = buffer.pointer; +if (obj->type !=ACPI_TYPE_PACKAGE || obj->package.count !=1 + || obj->package.elements[0 ].type !=ACPI_TYPE_BUFFER ) { +kfree (buffer.pointer); +return ; + } + + priv->data_vault =kmemdup (obj- >package.elements[0].buffer.pointer, + obj- >package.elements[0].buffer.length, +GFP_KERNEL ); + bin_attr_data_vault.private = priv->data_vault; + bin_attr_data_vault.size = obj-Quoted 1 line
package.elements[0].buffer.length;
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +12
-0+kfree (buffer.pointer); +} +static int int3400_thermal_probe (struct platform_device *pdev) {struct acpi_device *adev =ACPI_COMPANION (&pdev->dev);@@ -309,6 +354,8 @@ static int int3400_thermal_probe(struct platform_device *pdev)platform_set_drvdata (pdev ,priv ); +int3400_setup_gddv (priv); + int3400_thermal_ops.get_mode = int3400_thermal_get_mode; int3400_thermal_ops.set_mode = int3400_thermal_set_mode;@@ -327,6 +374,13 @@ static int int3400_thermal_probe(struct platform_device *pdev)if (result) goto free_rel_misc; +if (priv->data_vault) { + result =sysfs_create_group (&pdev->dev.kobj, + &data_attribute_group); +if (result) + goto free_uuid; + } + result = acpi_install_notify_handler( priv->adev->handle, ACPI_DEVICE_NOTIFY,
int3400_notify,drivers/thermal/intel/int340x_thermal/int3400_thermal.c +3
-0(void *)priv);@@ -336,6 +390,9 @@ static int int3400_thermal_probe(struct platform_device *pdev)return 0 ; free_sysfs: +if (priv->data_vault) +sysfs_remove_group (&pdev->dev.kobj, &data_attribute_group); +free_uuid:sysfs_remove_group (&pdev->dev.kobj, &uuid_attribute_group);
free_rel_misc:drivers/thermal/intel/int340x_thermal/int3400_thermal.c +3
-0if (!priv->rel_misc_dev_res)@@ -360,8 +417,11 @@ static int int3400_thermal_remove(struct platform_device *pdev)if (!priv->rel_misc_dev_res)acpi_thermal_rel_misc_device_remove (priv->adev- >handle); +if (priv->data_vault) +sysfs_remove_group (&pdev->dev.kobj, &data_attribute_group);sysfs_remove_group (&pdev->dev.kobj, &uuid_attribute_group);thermal_zone_device_unregister (priv->thermal); +kfree (priv->data_vault);drivers/thermal/intel/int340x_thermal/int3400_thermal.c +0
-0kfree (priv->trts);kfree (priv->arts);kfree (priv);
Quoted 1 line · Srinivas
Anything changed in v2 series?
Sorry, forgot to explain the diffs. Patch 2 in V2 was passing the wrong value to sysfs_attr_init(), but I didn't notice during testing because that's a macro that does nothing unless a specific debug flag is set. The kernel build bot noticed. Only difference is passing the correct argument there.
Quoted 9 lines · Matthew Garrett
Quoted 1 line · Srinivas
Anything changed in v2 series?
Sorry, forgot to explain the diffs. Patch 2 in V2 was passing the wrong value to
sysfs_attr_init(), but I didn't notice during testing because that's a macro that does nothing unless a specific debug flag is set. The kernel build bot noticed. Only difference is passing the correct argument there.
Thanks.
I will give a try next week.
-Srinivas
Quoted 9 lines · Matthew Garrett
From: Matthew Garrett <[email protected]>
Implementing DPTF properly requires making use of firmware-provided information associated with the INT3400 device. Calling GDDV provides a
buffer of information which userland can then interpret to determine appropriate DPTF policy.Signed-off-by Matthew Garrett <[email protected]>
Quoted 128 lines
--- .../intel/int340x_thermal/int3400_thermal.c | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+)drivers/thermal/intel/int340x_thermal/int3400_thermal.c +19
-0@@ -52,6 +52,25 @@ struct int3400_thermal_priv {u8 uuid_bitmap;int rel_misc_dev_res;int current_uuid_index; +char *data_vault; +}; + +static ssize_t data_vault_read (struct file *file,struct kobject *kobj, +struct bin_attribute *attr,char *buf,loff_t off,size_t count) +{ +memcpy (buf, attr->private + off, count); +return count; +} + +static BIN_ATTR_RO(data_vault, 0); + +static struct bin_attribute *data_attributes[] = { + &bin_attr_data_vault, +NULL , +}; + +static const struct attribute_group data_attribute_group = { + .bin_attrs = data_attributes, };static
ssize_tavailable_uuids_show(struct device *dev,drivers/thermal/intel/int340x_thermal/int3400_thermal.c +23
-0@@ -278,6 +297,32 @@ static struct thermal_zone_params int3400_thermal_params = { .no_hwmon = true, }; +static void int3400_setup_gddv (struct int3400_thermal_priv *priv) +{ +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *obj; +acpi_status status; + + status =acpi_evaluate_object (priv->adev->handle,"GDDV" ,NULL , + &buffer); +if (ACPI_FAILURE (status) || !buffer.length) +return ; + + obj = buffer.pointer; +if (obj->type !=ACPI_TYPE_PACKAGE || obj->package.count !=1 + || obj->package.elements[0 ].type !=ACPI_TYPE_BUFFER ) { +kfree (buffer.pointer); +return ; + } + + priv->data_vault =kmemdup (obj- >package.elements[0].buffer.pointer, + obj- >package.elements[0].buffer.length, +GFP_KERNEL ); + bin_attr_data_vault.private = priv->data_vault; + bin_attr_data_vault.size = obj-Quoted 1 line
package.elements[0].buffer.length;
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +12
-0+kfree (buffer.pointer); +} +static int int3400_thermal_probe (struct platform_device *pdev) {struct acpi_device *adev =ACPI_COMPANION (&pdev->dev);@@ -309,6 +354,8 @@ static int int3400_thermal_probe(struct platform_device *pdev)platform_set_drvdata (pdev ,priv ); +int3400_setup_gddv (priv); + int3400_thermal_ops.get_mode = int3400_thermal_get_mode; int3400_thermal_ops.set_mode = int3400_thermal_set_mode;@@ -327,6 +374,13 @@ static int int3400_thermal_probe(struct platform_device *pdev)if (result) goto free_rel_misc; +if (priv->data_vault) { + result =sysfs_create_group (&pdev->dev.kobj, + &data_attribute_group); +if (result) + goto free_uuid; + } + result = acpi_install_notify_handler( priv->adev->handle, ACPI_DEVICE_NOTIFY,
int3400_notify,drivers/thermal/intel/int340x_thermal/int3400_thermal.c +3
-0(void *)priv);@@ -336,6 +390,9 @@ static int int3400_thermal_probe(struct platform_device *pdev)return 0 ; free_sysfs: +if (priv->data_vault) +sysfs_remove_group (&pdev->dev.kobj, &data_attribute_group); +free_uuid:sysfs_remove_group (&pdev->dev.kobj, &uuid_attribute_group);
free_rel_misc:drivers/thermal/intel/int340x_thermal/int3400_thermal.c +3
-0if (!priv->rel_misc_dev_res)@@ -360,8 +417,11 @@ static int int3400_thermal_remove(struct platform_device *pdev)if (!priv->rel_misc_dev_res)acpi_thermal_rel_misc_device_remove (priv->adev- >handle); +if (priv->data_vault) +sysfs_remove_group (&pdev->dev.kobj, &data_attribute_group);sysfs_remove_group (&pdev->dev.kobj, &uuid_attribute_group);thermal_zone_device_unregister (priv->thermal); +kfree (priv->data_vault);drivers/thermal/intel/int340x_thermal/int3400_thermal.c +0
-0kfree (priv->trts);kfree (priv->arts);kfree (priv);
Quoted 11 lines · Srinivas
Quoted 10 lines · Matthew Garrett
From: Matthew Garrett <[email protected]>
Implementing DPTF properly requires making use of firmware-provided information associated with the INT3400 device. Calling GDDV provides
a
buffer of information which userland can then interpret to determine
appropriate DPTF policy.
Quoted 2 lines
Quoted 1 line
Signed-off-by Matthew Garrett <[email protected]>Tested-by Pandruvada, Srinivas <[email protected]>
Can we take this series for 5.8?
Thanks,
Srinivas
Quoted 130 lines
Quoted 130 lines
--- .../intel/int340x_thermal/int3400_thermal.c | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+)diff --git
a/drivers/thermal/intel/int340x_thermal/int3400_thermal.cb/drivers/thermal/intel/int340x_thermal/int3400_thermal.cindexceef89c956bd4..00a7732724cd0100644drivers/thermal/intel/int340x_thermal/int3400_thermal.c +19
-0@@ -52,6 +52,25 @@ struct int3400_thermal_priv {u8 uuid_bitmap;int rel_misc_dev_res;int current_uuid_index; +char *data_vault; +}; + +static ssize_t data_vault_read (struct file *file,struct kobject *kobj, +struct bin_attribute *attr,char *buf,loff_t off,size_t count) +{ +memcpy (buf, attr->private + off, count); +return count; +} + +static BIN_ATTR_RO(data_vault, 0); + +static struct bin_attribute *data_attributes[] = { + &bin_attr_data_vault, +NULL , +}; + +static const struct attribute_group data_attribute_group = { + .bin_attrs = data_attributes, };static
ssize_tavailable_uuids_show(struct device *dev,drivers/thermal/intel/int340x_thermal/int3400_thermal.c +23
-0@@ -278,6 +297,32 @@ static struct thermal_zone_params int3400_thermal_params = { .no_hwmon = true, }; +static void int3400_setup_gddv (struct int3400_thermal_priv *priv) +{ +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *obj; +acpi_status status; + + status =acpi_evaluate_object (priv->adev->handle,"GDDV" ,NULL , + &buffer); +if (ACPI_FAILURE (status) || !buffer.length) +return ; + + obj = buffer.pointer; +if (obj->type !=ACPI_TYPE_PACKAGE || obj->package.count !=1 + || obj->package.elements[0 ].type !=ACPI_TYPE_BUFFER ) { +kfree (buffer.pointer); +return ; + } + + priv->data_vault =kmemdup (obj- > package.elements[0].buffer.pointer, + obj- > package.elements[0].buffer.length, +GFP_KERNEL ); + bin_attr_data_vault.private = priv->data_vault; + bin_attr_data_vault.size = obj-Quoted 1 line
package.elements[0].buffer.length;
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +12
-0+kfree (buffer.pointer); +} +static int int3400_thermal_probe (struct platform_device *pdev) {struct acpi_device *adev =ACPI_COMPANION (&pdev->dev);@@ -309,6 +354,8 @@ static int int3400_thermal_probe(struct platform_device *pdev)platform_set_drvdata (pdev ,priv ); +int3400_setup_gddv (priv); + int3400_thermal_ops.get_mode = int3400_thermal_get_mode; int3400_thermal_ops.set_mode = int3400_thermal_set_mode;@@ -327,6 +374,13 @@ static int int3400_thermal_probe(struct platform_device *pdev)if (result) goto free_rel_misc; +if (priv->data_vault) { + result =sysfs_create_group (&pdev->dev.kobj, + &data_attribute_group); +if (result) + goto free_uuid; + } + result = acpi_install_notify_handler( priv->adev->handle, ACPI_DEVICE_NOTIFY,
int3400_notify,drivers/thermal/intel/int340x_thermal/int3400_thermal.c +3
-0(void *)priv);@@ -336,6 +390,9 @@ static int int3400_thermal_probe(struct platform_device *pdev)return 0 ; free_sysfs: +if (priv->data_vault) +sysfs_remove_group (&pdev->dev.kobj, &data_attribute_group); +free_uuid:sysfs_remove_group (&pdev->dev.kobj, &uuid_attribute_group);
free_rel_misc:drivers/thermal/intel/int340x_thermal/int3400_thermal.c +3
-0if (!priv->rel_misc_dev_res)@@ -360,8 +417,11 @@ static int int3400_thermal_remove(struct platform_device *pdev)if (!priv->rel_misc_dev_res)acpi_thermal_rel_misc_device_remove (priv->adev- > handle); +if (priv->data_vault) +sysfs_remove_group (&pdev->dev.kobj, &data_attribute_group);sysfs_remove_group (&pdev->dev.kobj, &uuid_attribute_group);thermal_zone_device_unregister (priv->thermal); +kfree (priv->data_vault);drivers/thermal/intel/int340x_thermal/int3400_thermal.c +0
-0kfree (priv->trts);kfree (priv->arts);kfree (priv);
Zhang Rui
reviewerQuoted 13 lines · Srinivas
Quoted 12 lines · Srinivas
Quoted 11 lines · Matthew Garrett
From: Matthew Garrett <[email protected]>
Implementing DPTF properly requires making use of firmware- provided
information associated with the INT3400 device. Calling GDDV provides
a
buffer of information which userland can then interpret to determine
appropriate DPTF policy.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Matthew Garrett <[email protected]>Tested-by: Pandruvada, Srinivas <
[email protected]>Can we take this series for 5.8?
They are in testing branch and has just passed the build test, will queue them for 5.8.
thanks,
rui
Quoted 139 lines
Thanks,
SrinivasQuoted 135 lines
Quoted 135 lines
--- .../intel/int340x_thermal/int3400_thermal.c | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+)diff --git
a/drivers/thermal/intel/int340x_thermal/int3400_thermal.cb/drivers/thermal/intel/int340x_thermal/int3400_thermal.cindexceef89c956bd4..00a7732724cd0100644drivers/thermal/intel/int340x_thermal/int3400_thermal.c +19
-0@@ -52,6 +52,25 @@ struct int3400_thermal_priv {u8 uuid_bitmap;int rel_misc_dev_res;int current_uuid_index; +char *data_vault; +}; + +static ssize_t data_vault_read (struct file *file,struct kobject *kobj, +struct bin_attribute *attr,char *buf,loff_t off,size_t count) +{ +memcpy (buf, attr->private + off, count); +return count; +} + +static BIN_ATTR_RO(data_vault, 0); + +static struct bin_attribute *data_attributes[] = { + &bin_attr_data_vault, +NULL , +}; + +static const struct attribute_group data_attribute_group = { + .bin_attrs = data_attributes, };static
ssize_tavailable_uuids_show(struct device *dev,drivers/thermal/intel/int340x_thermal/int3400_thermal.c +20
-0@@ -278,6 +297,32 @@ static struct thermal_zone_params int3400_thermal_params = { .no_hwmon = true, }; +static void int3400_setup_gddv (struct int3400_thermal_priv *priv) +{ +struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL }; +union acpi_object *obj; +acpi_status status; + + status =acpi_evaluate_object (priv->adev->handle,"GDDV" ,NULL , + &buffer); +if (ACPI_FAILURE (status) || !buffer.length) +return ; + + obj = buffer.pointer; +if (obj->type !=ACPI_TYPE_PACKAGE || obj->package.count !=1 + || obj->package.elements[0 ].type !=ACPI_TYPE_BUFFER ) { +kfree (buffer.pointer); +return ; + } + + priv->data_vault = kmemdup(obj- > package.elements[0].buffer.pointer, + obj-Quoted 1 line
package.elements[0].buffer.length,
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +3
-0+ GFP_KERNEL); + bin_attr_data_vault.private = priv->data_vault; + bin_attr_data_vault.size = obj-Quoted 1 line
package.elements[0].buffer.length;
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +12
-0+kfree (buffer.pointer); +} +static int int3400_thermal_probe (struct platform_device *pdev) {struct acpi_device *adev =ACPI_COMPANION (&pdev->dev);@@ -309,6 +354,8 @@ static int int3400_thermal_probe(struct platform_device *pdev)platform_set_drvdata (pdev ,priv ); +int3400_setup_gddv (priv); + int3400_thermal_ops.get_mode = int3400_thermal_get_mode; int3400_thermal_ops.set_mode = int3400_thermal_set_mode;@@ -327,6 +374,13 @@ static int int3400_thermal_probe(struct platform_device *pdev)if (result) goto free_rel_misc; +if (priv->data_vault) { + result =sysfs_create_group (&pdev->dev.kobj, + &data_attribute_group); +if (result) + goto free_uuid; + } + result = acpi_install_notify_handler( priv->adev->handle, ACPI_DEVICE_NOTIFY,
int3400_notify,drivers/thermal/intel/int340x_thermal/int3400_thermal.c +3
-0(void *)priv);@@ -336,6 +390,9 @@ static int int3400_thermal_probe(struct platform_device *pdev)return 0 ; free_sysfs: +if (priv->data_vault) +sysfs_remove_group (&pdev->dev.kobj, &data_attribute_group); +free_uuid:sysfs_remove_group (&pdev->dev.kobj, &uuid_attribute_group);
free_rel_misc:drivers/thermal/intel/int340x_thermal/int3400_thermal.c +3
-0if (!priv->rel_misc_dev_res)@@ -360,8 +417,11 @@ static int int3400_thermal_remove(struct platform_device *pdev)if (!priv->rel_misc_dev_res)acpi_thermal_rel_misc_device_remove (priv->adev- > handle); +if (priv->data_vault) +sysfs_remove_group (&pdev->dev.kobj, &data_attribute_group);sysfs_remove_group (&pdev->dev.kobj, &uuid_attribute_group);thermal_zone_device_unregister (priv->thermal); +kfree (priv->data_vault);kfree (priv->trts);kfree (priv->arts);kfree (priv);