From: "Jan Beulich" Subject: [PATCH] x86: improve "PCI reset register" rebooting Date: Fri, 13 Mar 2015 10:41:05 +0000 Message-ID: <5502CCD10200007800069AF6@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part50640AD1.1__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YWN1k-0002CC-Il for xen-devel@lists.xenproject.org; Fri, 13 Mar 2015 10:41:12 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Andrew Cooper , Keir Fraser List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part50640AD1.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline The way this method works allows for honoring "warm" reboot requested by the user and additionally has a way to power-cycle the machine. Signed-off-by: Jan Beulich --- a/docs/misc/xen-command-line.markdown +++ b/docs/misc/xen-command-line.markdown @@ -1117,7 +1117,7 @@ The following resources are available: * `rmid_max` indicates the max value for rmid. =20 ### reboot -> `=3D t[riple] | k[bd] | a[cpi] | p[ci] | e[fi] | n[o] [, [w]arm | = [c]old]` +> `=3D t[riple] | k[bd] | a[cpi] | p[ci] | P[ower] | e[fi] | n[o] [, = [w]arm | [c]old]` =20 > Default: `0` =20 @@ -1137,6 +1137,8 @@ Specify the host reboot method. =20 `pci` instructs Xen to reboot the host using PCI reset register (port = CF9). =20 +`Power` instructs Xen to power-cycle the host using PCI reset register = (port CF9). + 'efi' instructs Xen to reboot using the EFI reboot call (in EFI mode by default it will use that method first). =20 --- a/xen/arch/x86/shutdown.c +++ b/xen/arch/x86/shutdown.c @@ -33,6 +33,7 @@ enum reboot_type { BOOT_KBD =3D 'k', BOOT_ACPI =3D 'a', BOOT_CF9 =3D 'p', + BOOT_CF9_PWR =3D 'P', BOOT_EFI =3D 'e', }; =20 @@ -47,6 +48,7 @@ static int reboot_mode; * kbd Use the keyboard controller. cold reset (default) * acpi Use the RESET_REG in the FADT * pci Use the so-called "PCI reset register", CF9 + * Power Like 'pci' but for a full power-cyle reset * efi Use the EFI reboot (if running under EFI) */ static enum reboot_type reboot_type =3D BOOT_INVALID; @@ -68,8 +70,9 @@ static void __init set_reboot_type(char=20 case 'a': case 'e': case 'k': - case 't': + case 'P': case 'p': + case 't': reboot_type =3D *str; break; } @@ -571,11 +574,18 @@ void machine_restart(unsigned int delay_ reboot_type =3D BOOT_KBD; break; case BOOT_CF9: + case BOOT_CF9_PWR: { - u8 cf9 =3D inb(0xcf9) & ~6; - outb(cf9|2, 0xcf9); /* Request hard reset */ + u8 cf9 =3D inb(0xcf9) & ~0x0e; + + /* Request warm, hard, or power-cycle reset. */ + if ( reboot_type =3D=3D BOOT_CF9_PWR ) + cf9 |=3D 0x0a; + else if ( reboot_mode =3D=3D 0 ) + cf9 |=3D 0x02; + outb(cf9, 0xcf9); udelay(50); - outb(cf9|6, 0xcf9); /* Actually do the reset */ + outb(cf9 | 0x04, 0xcf9); /* Actually do the reset. */ udelay(50); } reboot_type =3D BOOT_ACPI; --=__Part50640AD1.1__= Content-Type: text/plain; name="x86-CF9-reset.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-CF9-reset.patch" x86: improve "PCI reset register" rebooting=0A=0AThe way this method works = allows for honoring "warm" reboot requested=0Aby the user and additionally = has a way to power-cycle the machine.=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- a/docs/misc/xen-command-line.markdown=0A+++ = b/docs/misc/xen-command-line.markdown=0A@@ -1117,7 +1117,7 @@ The = following resources are available:=0A * `rmid_max` indicates the max = value for rmid.=0A =0A ### reboot=0A-> `=3D t[riple] | k[bd] | a[cpi] | = p[ci] | e[fi] | n[o] [, [w]arm | [c]old]`=0A+> `=3D t[riple] | k[bd] | = a[cpi] | p[ci] | P[ower] | e[fi] | n[o] [, [w]arm | [c]old]`=0A =0A > = Default: `0`=0A =0A@@ -1137,6 +1137,8 @@ Specify the host reboot method.=0A= =0A `pci` instructs Xen to reboot the host using PCI reset register (port = CF9).=0A =0A+`Power` instructs Xen to power-cycle the host using PCI reset = register (port CF9).=0A+=0A 'efi' instructs Xen to reboot using the EFI = reboot call (in EFI mode by=0A default it will use that method first).=0A = =0A--- a/xen/arch/x86/shutdown.c=0A+++ b/xen/arch/x86/shutdown.c=0A@@ = -33,6 +33,7 @@ enum reboot_type {=0A BOOT_KBD =3D 'k',=0A = BOOT_ACPI =3D 'a',=0A BOOT_CF9 =3D 'p',=0A+ BOOT_CF9_PWR = =3D 'P',=0A BOOT_EFI =3D 'e',=0A };=0A =0A@@ -47,6 +48,7 @@ static = int reboot_mode;=0A * kbd Use the keyboard controller. cold reset = (default)=0A * acpi Use the RESET_REG in the FADT=0A * pci Use the = so-called "PCI reset register", CF9=0A+ * Power Like 'pci' but for a full = power-cyle reset=0A * efi Use the EFI reboot (if running under EFI)=0A = */=0A static enum reboot_type reboot_type =3D BOOT_INVALID;=0A@@ -68,8 = +70,9 @@ static void __init set_reboot_type(char =0A case 'a':=0A = case 'e':=0A case 'k':=0A- case 't':=0A+ case = 'P':=0A case 'p':=0A+ case 't':=0A reboot_type = =3D *str;=0A break;=0A }=0A@@ -571,11 +574,18 @@ void = machine_restart(unsigned int delay_=0A reboot_type =3D = BOOT_KBD;=0A break;=0A case BOOT_CF9:=0A+ case = BOOT_CF9_PWR:=0A {=0A- u8 cf9 =3D inb(0xcf9) & = ~6;=0A- outb(cf9|2, 0xcf9); /* Request hard reset */=0A+ = u8 cf9 =3D inb(0xcf9) & ~0x0e;=0A+=0A+ /* = Request warm, hard, or power-cycle reset. */=0A+ if ( = reboot_type =3D=3D BOOT_CF9_PWR )=0A+ cf9 |=3D = 0x0a;=0A+ else if ( reboot_mode =3D=3D 0 )=0A+ = cf9 |=3D 0x02;=0A+ outb(cf9, 0xcf9);=0A = udelay(50);=0A- outb(cf9|6, 0xcf9); /* Actually do the = reset */=0A+ outb(cf9 | 0x04, 0xcf9); /* Actually do the = reset. */=0A udelay(50);=0A }=0A = reboot_type =3D BOOT_ACPI;=0A --=__Part50640AD1.1__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part50640AD1.1__=--