public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matteo Croce <mcroce@linux.microsoft.com>
To: linux-kernel@vger.kernel.org
Cc: Petr Mladek <pmladek@suse.com>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH 1/2] reboot: allow to override reboot type if quirks are found
Date: Mon, 30 Nov 2020 18:37:16 +0100	[thread overview]
Message-ID: <20201130173717.198952-2-mcroce@linux.microsoft.com> (raw)
In-Reply-To: <20201130173717.198952-1-mcroce@linux.microsoft.com>

From: Matteo Croce <mcroce@microsoft.com>

On some machines a quirk can force a specific reboot type.
Quirks are found during a DMI scan, the list of machines which need
special reboot handling is defined in reboot_dmi_table.

The kernel command line reboot= option overrides this via a global
variable `reboot_default`, so that the reboot type requested in
the command line is really performed.

This was not true when setting the reboot type via the new sysfs
interface. Fix this by setting reboot_default upon the first change,
like reboot_setup() does for the command line.

Signed-off-by: Matteo Croce <mcroce@microsoft.com>
---
 kernel/reboot.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/reboot.c b/kernel/reboot.c
index ea6347b99b14..d80e3d64fe23 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -656,6 +656,8 @@ static ssize_t mode_store(struct kobject *kobj, struct kobj_attribute *attr,
 	else
 		return -EINVAL;
 
+	reboot_default = 0;
+
 	return count;
 }
 static struct kobj_attribute reboot_mode_attr = __ATTR_RW(mode);
@@ -710,6 +712,8 @@ static ssize_t type_store(struct kobject *kobj, struct kobj_attribute *attr,
 	else
 		return -EINVAL;
 
+	reboot_default = 0;
+
 	return count;
 }
 static struct kobj_attribute reboot_type_attr = __ATTR_RW(type);
@@ -735,6 +739,7 @@ static ssize_t cpu_store(struct kobject *kobj, struct kobj_attribute *attr,
 	if (cpunum >= num_possible_cpus())
 		return -ERANGE;
 
+	reboot_default = 0;
 	reboot_cpu = cpunum;
 
 	return count;
@@ -756,6 +761,7 @@ static ssize_t force_store(struct kobject *kobj, struct kobj_attribute *attr,
 	if (kstrtobool(buf, &res))
 		return -EINVAL;
 
+	reboot_default = 0;
 	reboot_force = res;
 
 	return count;
-- 
2.28.0


  reply	other threads:[~2020-11-30 17:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30 17:37 [PATCH 0/2] reboot: sysfs improvements Matteo Croce
2020-11-30 17:37 ` Matteo Croce [this message]
2020-12-01 10:46   ` [PATCH 1/2] reboot: allow to override reboot type if quirks are found Petr Mladek
2020-11-30 17:37 ` [PATCH 2/2] reboot: hide from sysfs not applicable settings Matteo Croce
2020-12-01 10:52   ` Petr Mladek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201130173717.198952-2-mcroce@linux.microsoft.com \
    --to=mcroce@linux.microsoft.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmladek@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox