All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Arlott <simon@octiron.net>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Jonathan Corbet <corbet@lwn.net>,
	linux-doc@vger.kernel.org
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
	Christoph Hellwig <hch@infradead.org>,
	Damien Le Moal <Damien.LeMoal@wdc.com>,
	Pavel Machek <pavel@ucw.cz>,
	Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Subject: [PATCH 2/2] x86/reboot/quirks: Add ASRock Z170 Extreme4
Date: Mon, 29 Jun 2020 21:58:05 +0100	[thread overview]
Message-ID: <a7c26ca1-0201-7526-8b69-484868725ee3@0882a8b5-c6c3-11e9-b005-00805fc181fe> (raw)
In-Reply-To: <f4a7b539-eeac-1a59-2350-3eefc8c17801@0882a8b5-c6c3-11e9-b005-00805fc181fe>

If a PCI mode reboot is performed on the ASRock Z170 Extreme4, a power
cycle will occur. Automatically set the reboot quirk for this to prepare
for the power off (i.e. stop all disks).

This will only take effect if PCI mode is manually used. It'll be too late
in the reboot process to prepare for power off if the other reboot methods
fail.

It is necessary to re-order the processing of DMI checks because this quirk
must apply even if a reboot= command line parameter is used as that's the
only way to specify a PCI mode reboot.

Signed-off-by: Simon Arlott <simon@octiron.net>
---
Previous patches to make scsi/sd stop before a reboot:
https://lore.kernel.org/lkml/499138c8-b6d5-ef4a-2780-4f750ed337d3@0882a8b5-c6c3-11e9-b005-00805fc181fe/
https://lore.kernel.org/lkml/e726ffd8-8897-4a79-c3d6-6271eda8aebb@0882a8b5-c6c3-11e9-b005-00805fc181fe/

 arch/x86/kernel/reboot.c | 51 ++++++++++++++++++++++++++++++++++------
 1 file changed, 44 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 0ec7ced727fe..a82d5db1c8ca 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -147,6 +147,13 @@ STACK_FRAME_NON_STANDARD(machine_real_restart);
  */
 static int __init set_pci_reboot(const struct dmi_system_id *d)
 {
+	/*
+	 * Only apply the DMI-based change if reboot_type hasn't been
+	 * overridden on the command line.
+	 */
+	if (!reboot_default)
+		return 0;
+
 	if (reboot_type != BOOT_CF9_FORCE) {
 		reboot_type = BOOT_CF9_FORCE;
 		pr_info("%s series board detected. Selecting %s-method for reboots.\n",
@@ -157,6 +164,13 @@ static int __init set_pci_reboot(const struct dmi_system_id *d)
 
 static int __init set_kbd_reboot(const struct dmi_system_id *d)
 {
+	/*
+	 * Only apply the DMI-based change if reboot_type hasn't been
+	 * overridden on the command line.
+	 */
+	if (!reboot_default)
+		return 0;
+
 	if (reboot_type != BOOT_KBD) {
 		reboot_type = BOOT_KBD;
 		pr_info("%s series board detected. Selecting %s-method for reboot.\n",
@@ -165,6 +179,21 @@ static int __init set_kbd_reboot(const struct dmi_system_id *d)
 	return 0;
 }
 
+static int __init set_pci_power_cycle_reboot(const struct dmi_system_id *d)
+{
+	/*
+	 * This has to be applied even if reboot_type has been set on the
+	 * command line because that's the only way to enable PCI mode.
+	 */
+
+	if (reboot_type == BOOT_CF9_FORCE) {
+		reboot_quirks |= REBOOT_QUIRK_POWER_CYCLE;
+		pr_info("%s series board detected. Assume that a PCI reboot includes a power cycle.\n",
+			d->ident);
+	}
+	return 0;
+}
+
 /*
  * This is a single dmi_table handling all reboot quirks.
  */
@@ -247,6 +276,14 @@ static const struct dmi_system_id reboot_dmi_table[] __initconst = {
 			DMI_MATCH(DMI_BOARD_NAME, "Q1900DC-ITX"),
 		},
 	},
+	{	/* PCI reboots cause a power cycle */
+		.callback = set_pci_power_cycle_reboot,
+		.ident = "ASRock Z170 Extreme4",
+		.matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "ASRock"),
+			DMI_MATCH(DMI_BOARD_NAME, "Z170 Extreme4"),
+		},
+	},
 
 	/* ASUS */
 	{	/* Handle problems with rebooting on ASUS P4S800 */
@@ -494,13 +531,6 @@ static int __init reboot_init(void)
 {
 	int rv;
 
-	/*
-	 * Only do the DMI check if reboot_type hasn't been overridden
-	 * on the command line
-	 */
-	if (!reboot_default)
-		return 0;
-
 	/*
 	 * The DMI quirks table takes precedence. If no quirks entry
 	 * matches and the ACPI Hardware Reduced bit is set and EFI
@@ -508,6 +538,13 @@ static int __init reboot_init(void)
 	 */
 	rv = dmi_check_system(reboot_dmi_table);
 
+	/*
+	 * Only force EFI reboot if reboot_type hasn't been overridden
+	 * on the command line.
+	 */
+	if (!reboot_default)
+		return 0;
+
 	if (!rv && efi_reboot_required() && !efi_runtime_disabled())
 		reboot_type = BOOT_EFI;
 
-- 
2.17.1

-- 
Simon Arlott

  reply	other threads:[~2020-06-29 20:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-29 20:56 [PATCH 1/2] reboot: add a "power cycle" quirk to prepare for a power off on reboot Simon Arlott
2020-06-29 20:58 ` Simon Arlott [this message]
2020-07-15 18:12   ` [PATCH 2/2] x86/reboot/quirks: Add ASRock Z170 Extreme4 Christoph Hellwig
2020-07-15 18:11 ` [PATCH 1/2] reboot: add a "power cycle" quirk to prepare for a power off on reboot Christoph Hellwig
2020-07-15 20:14   ` Martin K. Petersen

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=a7c26ca1-0201-7526-8b69-484868725ee3@0882a8b5-c6c3-11e9-b005-00805fc181fe \
    --to=simon@octiron.net \
    --cc=Damien.LeMoal@wdc.com \
    --cc=bp@alien8.de \
    --cc=bvanassche@acm.org \
    --cc=corbet@lwn.net \
    --cc=hch@infradead.org \
    --cc=hmh@hmh.eng.br \
    --cc=hpa@zytor.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mingo@redhat.com \
    --cc=pavel@ucw.cz \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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 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.