Skip to content

Commit

Permalink
debug reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhong,Fangjian committed Jun 8, 2023
1 parent db57813 commit 8a864e4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
15 changes: 14 additions & 1 deletion arch/x86/kernel/reboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,15 +589,23 @@ static void native_machine_emergency_restart(void)
int orig_reboot_type = reboot_type;
unsigned short mode;

if (reboot_emergency)
pr_notice("%s - %d reboot_type:%x\n", __FUNCTION__, __LINE__, reboot_type);
if (reboot_emergency) {
pr_notice("%s - %d reboot_type:%x\n", __FUNCTION__, __LINE__, reboot_type);
emergency_vmx_disable_all();
pr_notice("%s - %d reboot_type:%x\n", __FUNCTION__, __LINE__, reboot_type);
}

pr_notice("%s - %d reboot_type:%x\n", __FUNCTION__, __LINE__, reboot_type);
tboot_shutdown(TB_SHUTDOWN_REBOOT);
pr_notice("%s - %d reboot_type:%x\n", __FUNCTION__, __LINE__, reboot_type);


/* Tell the BIOS if we want cold or warm reboot */
mode = reboot_mode == REBOOT_WARM ? 0x1234 : 0;
*((unsigned short *)__va(0x472)) = mode;

pr_notice("%s - %d reboot_type:%x\n", __FUNCTION__, __LINE__, reboot_type);
/*
* If an EFI capsule has been registered with the firmware then
* override the reboot= parameter.
Expand All @@ -608,8 +616,10 @@ static void native_machine_emergency_restart(void)
}

for (;;) {
pr_notice("%s - %d reboot_type:%x\n", __FUNCTION__, __LINE__, reboot_type);
/* Could also try the reset bit in the Hammer NB */
switch (reboot_type) {
pr_notice("%s - %d reboot_type:%x\n", __FUNCTION__, __LINE__, reboot_type);
case BOOT_ACPI:
acpi_reboot();
mdelay(15);
Expand Down Expand Up @@ -711,10 +721,12 @@ void native_machine_shutdown(void)
#ifdef CONFIG_X86_64
x86_platform.iommu_shutdown();
#endif
pr_notice("%s - %d reboot_type:%x\n", __FUNCTION__, __LINE__, reboot_type);
}

static void __machine_emergency_restart(int emergency)
{
pr_notice("%s - %d reboot_type:%x\n", __FUNCTION__, __LINE__, reboot_type);
reboot_emergency = emergency;
machine_ops.emergency_restart();
}
Expand Down Expand Up @@ -767,6 +779,7 @@ void machine_power_off(void)

void machine_shutdown(void)
{
pr_notice("%s - %d reboot_type:%x\n", __FUNCTION__, __LINE__, reboot_type);
machine_ops.shutdown();
}

Expand Down
2 changes: 2 additions & 0 deletions drivers/acpi/acpica/hwxface.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@ acpi_status acpi_reset(void)
* compatibility with other ACPI implementations that have allowed
* BIOS code with bad register width values to go unnoticed.
*/
printk("%s - %d \n", __FUNCTION__, __LINE__);
status = acpi_os_write_port((acpi_io_address)reset_reg->address,
acpi_gbl_FADT.reset_value,
ACPI_RESET_REGISTER_WIDTH);
} else {
/* Write the reset value to the reset register */

printk("%s - %d \n", __FUNCTION__, __LINE__);
status = acpi_hw_write(acpi_gbl_FADT.reset_value, reset_reg);
}

Expand Down
2 changes: 2 additions & 0 deletions drivers/acpi/osl.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ EXPORT_SYMBOL(acpi_os_read_port);

acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
{
printk("%s - %d port:%x, value:%x width:%x\n", __FUNCTION__, __LINE__, port, value, width);
if (width <= 8) {
outb(value, port);
} else if (width <= 16) {
Expand Down Expand Up @@ -755,6 +756,7 @@ acpi_os_write_memory(acpi_physical_address phys_addr, u64 value, u32 width)
unmap = true;
}

printk("%s - %d va:%llx, value:%x\n", __FUNCTION__, __LINE__, virt_addr, value);
switch (width) {
case 8:
writeb(value, virt_addr);
Expand Down
18 changes: 15 additions & 3 deletions drivers/acpi/reboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,35 +38,45 @@ void acpi_reboot(void)
struct acpi_generic_address *rr;
u8 reset_value;

if (acpi_disabled)
if (acpi_disabled) {
pr_notice("%s - %d \n", __FUNCTION__, __LINE__);
return;
}

rr = &acpi_gbl_FADT.reset_register;

/* ACPI reset register was only introduced with v2 of the FADT */

if (acpi_gbl_FADT.header.revision < 2)
if (acpi_gbl_FADT.header.revision < 2) {
pr_notice("%s - %d \n", __FUNCTION__, __LINE__);
return;
}

/* Is the reset register supported? The spec says we should be
* checking the bit width and bit offset, but Windows ignores
* these fields */
if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER))
if (!(acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER)) {
pr_notice("%s - %d \n", __FUNCTION__, __LINE__);
return;
}

reset_value = acpi_gbl_FADT.reset_value;

/* The reset register can only exist in I/O, Memory or PCI config space
* on a device on bus 0. */
switch (rr->space_id) {
case ACPI_ADR_SPACE_PCI_CONFIG:
pr_notice("%s - %d rr->space_id:%x\n", __FUNCTION__, __LINE__, rr->space_id);
acpi_pci_reboot(rr, reset_value);
pr_notice("%s - %d rr->space_id:%x\n", __FUNCTION__, __LINE__, rr->space_id);
break;

case ACPI_ADR_SPACE_SYSTEM_MEMORY:
case ACPI_ADR_SPACE_SYSTEM_IO:
pr_debug("ACPI MEMORY or I/O RESET_REG.\n");
pr_notice("%s - %d rr->space_id:%x\n", __FUNCTION__, __LINE__, rr->space_id);
acpi_reset();
pr_notice("%s - %d rr->space_id:%x\n", __FUNCTION__, __LINE__, rr->space_id);
break;
}

Expand All @@ -78,5 +88,7 @@ void acpi_reboot(void)
* The 15ms delay has been found to be long enough for the system
* to reboot on the affected platforms.
*/
pr_notice("%s - %d \n", __FUNCTION__, __LINE__);
mdelay(15);
pr_notice("%s - %d \n", __FUNCTION__, __LINE__);
}

0 comments on commit 8a864e4

Please sign in to comment.