All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] platform/x86: think-lmi: Add pending_reboot support
@ 2021-06-28 22:28 Mark Pearson
  2021-07-06 10:02 ` Hans de Goede
  2021-07-14 13:08 ` Hans de Goede
  0 siblings, 2 replies; 3+ messages in thread
From: Mark Pearson @ 2021-06-28 22:28 UTC (permalink / raw)
  To: markpearson; +Cc: hdegoede, mgross, platform-driver-x86, mario.limonciello

The Think-lmi driver was missing pending_reboot support as it wasn't
available from the BIOS. Turns out this is really useful to have from
user space so implementing from a purely SW point of view.

Thanks to Mario Limonciello for guidance on how fwupd would use this.

Suggested-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Mark Pearson <markpearson@lenovo.com>
---
Changes in v2: 
  - added in Mario's Suggested-by tag (and will use correct email when
    submitting patch)

 drivers/platform/x86/think-lmi.c | 19 +++++++++++++++++++
 drivers/platform/x86/think-lmi.h |  1 +
 2 files changed, 20 insertions(+)

diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c
index b57061079..bcc3d6fcd 100644
--- a/drivers/platform/x86/think-lmi.c
+++ b/drivers/platform/x86/think-lmi.c
@@ -566,6 +566,11 @@ static ssize_t current_value_store(struct kobject *kobj,
 	else
 		ret = tlmi_save_bios_settings("");
 
+	if (!ret && !tlmi_priv.pending_changes) {
+		tlmi_priv.pending_changes = true;
+		/* let userland know it may need to check reboot pending again */
+		kobject_uevent(&tlmi_priv.class_dev->kobj, KOBJ_CHANGE);
+	}
 out:
 	kfree(auth_str);
 	kfree(set_str);
@@ -641,6 +646,14 @@ static struct kobj_type tlmi_pwd_setting_ktype = {
 	.sysfs_ops	= &tlmi_kobj_sysfs_ops,
 };
 
+static ssize_t pending_reboot_show(struct kobject *kobj, struct kobj_attribute *attr,
+				   char *buf)
+{
+	return sprintf(buf, "%d\n", tlmi_priv.pending_changes);
+}
+
+static struct kobj_attribute pending_reboot = __ATTR_RO(pending_reboot);
+
 /* ---- Initialisation --------------------------------------------------------- */
 static void tlmi_release_attr(void)
 {
@@ -662,6 +675,7 @@ static void tlmi_release_attr(void)
 	sysfs_remove_group(&tlmi_priv.pwd_power->kobj, &auth_attr_group);
 	kobject_put(&tlmi_priv.pwd_power->kobj);
 	kset_unregister(tlmi_priv.authentication_kset);
+	sysfs_remove_file(&tlmi_priv.class_dev->kobj, &pending_reboot.attr);
 }
 
 static int tlmi_sysfs_init(void)
@@ -730,6 +744,11 @@ static int tlmi_sysfs_init(void)
 	if (ret)
 		goto fail_create_attr;
 
+	/* Create global sysfs files */
+	ret = sysfs_create_file(&tlmi_priv.class_dev->kobj, &pending_reboot.attr);
+	if (ret)
+		goto fail_create_attr;
+
 	return ret;
 
 fail_create_attr:
diff --git a/drivers/platform/x86/think-lmi.h b/drivers/platform/x86/think-lmi.h
index 6fa8da7af..eb5988466 100644
--- a/drivers/platform/x86/think-lmi.h
+++ b/drivers/platform/x86/think-lmi.h
@@ -60,6 +60,7 @@ struct think_lmi {
 	bool can_get_bios_selections;
 	bool can_set_bios_password;
 	bool can_get_password_settings;
+	bool pending_changes;
 
 	struct tlmi_attr_setting *setting[TLMI_SETTINGS_COUNT];
 	struct device *class_dev;
-- 
2.31.1


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

* Re: [PATCH v2] platform/x86: think-lmi: Add pending_reboot support
  2021-06-28 22:28 [PATCH v2] platform/x86: think-lmi: Add pending_reboot support Mark Pearson
@ 2021-07-06 10:02 ` Hans de Goede
  2021-07-14 13:08 ` Hans de Goede
  1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2021-07-06 10:02 UTC (permalink / raw)
  To: Mark Pearson; +Cc: mgross, platform-driver-x86, mario.limonciello

Hi,

On 6/29/21 12:28 AM, Mark Pearson wrote:
> The Think-lmi driver was missing pending_reboot support as it wasn't
> available from the BIOS. Turns out this is really useful to have from
> user space so implementing from a purely SW point of view.
> 
> Thanks to Mario Limonciello for guidance on how fwupd would use this.
> 
> Suggested-by: Mario Limonciello <mario.limonciello@amd.com>
> Signed-off-by: Mark Pearson <markpearson@lenovo.com>
> ---
> Changes in v2: 
>   - added in Mario's Suggested-by tag (and will use correct email when
>     submitting patch)

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

I'll merge this once v5.14-rc1 is out and I'll also include this in my
next pdx86-fixes for 5.14 pull-req to Linus.

Regards,

Hans




> 
>  drivers/platform/x86/think-lmi.c | 19 +++++++++++++++++++
>  drivers/platform/x86/think-lmi.h |  1 +
>  2 files changed, 20 insertions(+)
> 
> diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c
> index b57061079..bcc3d6fcd 100644
> --- a/drivers/platform/x86/think-lmi.c
> +++ b/drivers/platform/x86/think-lmi.c
> @@ -566,6 +566,11 @@ static ssize_t current_value_store(struct kobject *kobj,
>  	else
>  		ret = tlmi_save_bios_settings("");
>  
> +	if (!ret && !tlmi_priv.pending_changes) {
> +		tlmi_priv.pending_changes = true;
> +		/* let userland know it may need to check reboot pending again */
> +		kobject_uevent(&tlmi_priv.class_dev->kobj, KOBJ_CHANGE);
> +	}
>  out:
>  	kfree(auth_str);
>  	kfree(set_str);
> @@ -641,6 +646,14 @@ static struct kobj_type tlmi_pwd_setting_ktype = {
>  	.sysfs_ops	= &tlmi_kobj_sysfs_ops,
>  };
>  
> +static ssize_t pending_reboot_show(struct kobject *kobj, struct kobj_attribute *attr,
> +				   char *buf)
> +{
> +	return sprintf(buf, "%d\n", tlmi_priv.pending_changes);
> +}
> +
> +static struct kobj_attribute pending_reboot = __ATTR_RO(pending_reboot);
> +
>  /* ---- Initialisation --------------------------------------------------------- */
>  static void tlmi_release_attr(void)
>  {
> @@ -662,6 +675,7 @@ static void tlmi_release_attr(void)
>  	sysfs_remove_group(&tlmi_priv.pwd_power->kobj, &auth_attr_group);
>  	kobject_put(&tlmi_priv.pwd_power->kobj);
>  	kset_unregister(tlmi_priv.authentication_kset);
> +	sysfs_remove_file(&tlmi_priv.class_dev->kobj, &pending_reboot.attr);
>  }
>  
>  static int tlmi_sysfs_init(void)
> @@ -730,6 +744,11 @@ static int tlmi_sysfs_init(void)
>  	if (ret)
>  		goto fail_create_attr;
>  
> +	/* Create global sysfs files */
> +	ret = sysfs_create_file(&tlmi_priv.class_dev->kobj, &pending_reboot.attr);
> +	if (ret)
> +		goto fail_create_attr;
> +
>  	return ret;
>  
>  fail_create_attr:
> diff --git a/drivers/platform/x86/think-lmi.h b/drivers/platform/x86/think-lmi.h
> index 6fa8da7af..eb5988466 100644
> --- a/drivers/platform/x86/think-lmi.h
> +++ b/drivers/platform/x86/think-lmi.h
> @@ -60,6 +60,7 @@ struct think_lmi {
>  	bool can_get_bios_selections;
>  	bool can_set_bios_password;
>  	bool can_get_password_settings;
> +	bool pending_changes;
>  
>  	struct tlmi_attr_setting *setting[TLMI_SETTINGS_COUNT];
>  	struct device *class_dev;
> 


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

* Re: [PATCH v2] platform/x86: think-lmi: Add pending_reboot support
  2021-06-28 22:28 [PATCH v2] platform/x86: think-lmi: Add pending_reboot support Mark Pearson
  2021-07-06 10:02 ` Hans de Goede
@ 2021-07-14 13:08 ` Hans de Goede
  1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2021-07-14 13:08 UTC (permalink / raw)
  To: Mark Pearson; +Cc: mgross, platform-driver-x86, mario.limonciello

Hi,

On 6/29/21 12:28 AM, Mark Pearson wrote:
> The Think-lmi driver was missing pending_reboot support as it wasn't
> available from the BIOS. Turns out this is really useful to have from
> user space so implementing from a purely SW point of view.
> 
> Thanks to Mario Limonciello for guidance on how fwupd would use this.
> 
> Suggested-by: Mario Limonciello <mario.limonciello@amd.com>
> Signed-off-by: Mark Pearson <markpearson@lenovo.com>

Thank you for your patch, I've applied this patch to my review-hans 
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

I will also apply this to the fixes branch and include it in my
upcoming v5.14 pdx86 fixes pull-req to Linus.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans

> ---
> Changes in v2: 
>   - added in Mario's Suggested-by tag (and will use correct email when
>     submitting patch)
> 
>  drivers/platform/x86/think-lmi.c | 19 +++++++++++++++++++
>  drivers/platform/x86/think-lmi.h |  1 +
>  2 files changed, 20 insertions(+)
> 
> diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c
> index b57061079..bcc3d6fcd 100644
> --- a/drivers/platform/x86/think-lmi.c
> +++ b/drivers/platform/x86/think-lmi.c
> @@ -566,6 +566,11 @@ static ssize_t current_value_store(struct kobject *kobj,
>  	else
>  		ret = tlmi_save_bios_settings("");
>  
> +	if (!ret && !tlmi_priv.pending_changes) {
> +		tlmi_priv.pending_changes = true;
> +		/* let userland know it may need to check reboot pending again */
> +		kobject_uevent(&tlmi_priv.class_dev->kobj, KOBJ_CHANGE);
> +	}
>  out:
>  	kfree(auth_str);
>  	kfree(set_str);
> @@ -641,6 +646,14 @@ static struct kobj_type tlmi_pwd_setting_ktype = {
>  	.sysfs_ops	= &tlmi_kobj_sysfs_ops,
>  };
>  
> +static ssize_t pending_reboot_show(struct kobject *kobj, struct kobj_attribute *attr,
> +				   char *buf)
> +{
> +	return sprintf(buf, "%d\n", tlmi_priv.pending_changes);
> +}
> +
> +static struct kobj_attribute pending_reboot = __ATTR_RO(pending_reboot);
> +
>  /* ---- Initialisation --------------------------------------------------------- */
>  static void tlmi_release_attr(void)
>  {
> @@ -662,6 +675,7 @@ static void tlmi_release_attr(void)
>  	sysfs_remove_group(&tlmi_priv.pwd_power->kobj, &auth_attr_group);
>  	kobject_put(&tlmi_priv.pwd_power->kobj);
>  	kset_unregister(tlmi_priv.authentication_kset);
> +	sysfs_remove_file(&tlmi_priv.class_dev->kobj, &pending_reboot.attr);
>  }
>  
>  static int tlmi_sysfs_init(void)
> @@ -730,6 +744,11 @@ static int tlmi_sysfs_init(void)
>  	if (ret)
>  		goto fail_create_attr;
>  
> +	/* Create global sysfs files */
> +	ret = sysfs_create_file(&tlmi_priv.class_dev->kobj, &pending_reboot.attr);
> +	if (ret)
> +		goto fail_create_attr;
> +
>  	return ret;
>  
>  fail_create_attr:
> diff --git a/drivers/platform/x86/think-lmi.h b/drivers/platform/x86/think-lmi.h
> index 6fa8da7af..eb5988466 100644
> --- a/drivers/platform/x86/think-lmi.h
> +++ b/drivers/platform/x86/think-lmi.h
> @@ -60,6 +60,7 @@ struct think_lmi {
>  	bool can_get_bios_selections;
>  	bool can_set_bios_password;
>  	bool can_get_password_settings;
> +	bool pending_changes;
>  
>  	struct tlmi_attr_setting *setting[TLMI_SETTINGS_COUNT];
>  	struct device *class_dev;
> 


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

end of thread, other threads:[~2021-07-14 13:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-28 22:28 [PATCH v2] platform/x86: think-lmi: Add pending_reboot support Mark Pearson
2021-07-06 10:02 ` Hans de Goede
2021-07-14 13:08 ` Hans de Goede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.